xterm-330/0000755000175100001440000000000013122344247011241 5ustar tomusersxterm-330/data.h0000644000175100001440000001575213113414235012330 0ustar tomusers/* $XTermId: data.h,v 1.130 2017/05/31 01:13:01 tom Exp $ */ /* * Copyright 2002-2016,2017 by Thomas E. Dickey * * All Rights Reserved * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * Except as contained in this notice, the name(s) of the above copyright * holders shall not be used in advertising or otherwise to promote the * sale, use or other dealings in this Software without prior written * authorization. * * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ #ifndef included_data_h #define included_data_h 1 #include extern Widget toplevel; extern XtAppContext app_con; #ifdef VMS /* actually in vms.c */ extern int tt_width; extern int tt_length; extern int tt_changed; extern int tt_pasting; extern int tt_new_output; #define VMS_TERM_BUFFER_SIZE 500 struct q_head { int flink; int blink; }; extern struct q_head read_queue; #endif #if OPT_TEK4014 extern Char *Tpushb; extern Char *Tpushback; extern TekLink *tekRefreshList; extern TekWidget tekWidget; extern Widget tekshellwidget; extern int T_lastx; extern int T_lasty; extern int Ttoggled; extern jmp_buf Tekend; #endif extern char *ptydev; extern char *ttydev; extern int hold_screen; extern PtyData *VTbuffer; extern int am_slave; extern int max_plus1; extern jmp_buf VTend; #ifdef DEBUG extern int debug; #endif /* DEBUG */ extern PtySelect Select_mask; extern PtySelect X_mask; extern PtySelect pty_mask; extern int ice_fd; extern XtermWidget term; extern SIG_ATOMIC_T need_cleanup; extern SIG_ATOMIC_T caught_intr; #if defined(HAVE_XKB_BELL_EXT) #include /* has the prototype */ #include /* has the XkbBI_xxx definitions */ #endif #ifndef XkbBI_Info #define XkbBI_Info 0 #define XkbBI_MinorError 1 #define XkbBI_MajorError 2 #define XkbBI_TerminalBell 9 #define XkbBI_MarginBell 10 #endif extern char *ProgramName; extern Arg ourTopLevelShellArgs[]; extern Cardinal number_ourTopLevelShellArgs; extern Atom wm_delete_window; #if HANDLE_STRUCT_NOTIFY /* Flag icon name with "*** " on window output when iconified. * I'd like to do something like reverse video, but I don't * know how to tell this to window managers in general. * * mapstate can be IsUnmapped, !IsUnmapped, or -1; * -1 means no change; the other two are set by event handlers * and indicate a new mapstate. !IsMapped is done in the handler. * we worry about IsUnmapped when output occurs. -IAN! */ extern int mapstate; #endif /* HANDLE_STRUCT_NOTIFY */ #ifdef HAVE_LIB_XCURSOR extern char *xterm_cursor_theme; #endif typedef struct XTERM_RESOURCE { char *icon_geometry; char *title; char *icon_hint; char *icon_name; char *term_name; char *tty_modes; int minBufSize; int maxBufSize; Boolean hold_screen; /* true if we keep window open */ Boolean utmpInhibit; Boolean utmpDisplayId; Boolean messages; String menuLocale; String omitTranslation; String keyboardType; #if OPT_PRINT_ON_EXIT int printModeNow; int printModeOnXError; int printOptsNow; int printOptsOnXError; String printFileNow; String printFileOnXError; #endif Boolean oldKeyboard; /* placeholder for decode_keyboard_type */ #if OPT_SUNPC_KBD Boolean sunKeyboard; #endif #if OPT_HP_FUNC_KEYS Boolean hpFunctionKeys; #endif #if OPT_SCO_FUNC_KEYS Boolean scoFunctionKeys; #endif #if OPT_SUN_FUNC_KEYS Boolean sunFunctionKeys; /* %%% should be VT100 widget resource? */ #endif #if OPT_TCAP_FKEYS Boolean termcapKeys; #endif #if OPT_INITIAL_ERASE Boolean ptyInitialErase; /* if true, use pty's sense of erase char */ Boolean backarrow_is_erase; /* override backspace/delete */ #endif Boolean useInsertMode; #if OPT_ZICONBEEP int zIconBeep; /* beep level when output while iconified */ char *zIconFormat; /* format for icon name */ #endif #if OPT_PTY_HANDSHAKE Boolean wait_for_map; Boolean wait_for_map0; /* ...initial value of .wait_for_map */ Boolean ptyHandshake; /* use pty-handshaking */ Boolean ptySttySize; /* reset TTY size after pty handshake */ #endif #if OPT_REPORT_CCLASS Boolean reportCClass; /* show character-class information */ #endif #if OPT_REPORT_COLORS Boolean reportColors; /* show color information as allocated */ #endif #if OPT_REPORT_FONTS Boolean reportFonts; /* show bitmap-font information as loaded */ #endif #if OPT_SAME_NAME Boolean sameName; /* Don't change the title or icon name if it is * the same. This prevents flicker on the * screen at the cost of an extra request to * the server. */ #endif #if OPT_SESSION_MGT Boolean sessionMgt; #endif #if OPT_TOOLBAR Boolean toolBar; #endif #if OPT_MAXIMIZE Boolean maximized; String fullscreen_s; /* resource for "fullscreen" */ int fullscreen; /* derived from fullscreen_s */ #endif } XTERM_RESOURCE; extern Boolean guard_keyboard_type; extern XTERM_RESOURCE resource; #ifdef USE_IGNORE_RC extern int ignore_unused; #endif #endif /* included_data_h */ xterm-330/fontutils.c0000644000175100001440000034176613122163173013452 0ustar tomusers/* $XTermId: fontutils.c,v 1.531 2017/06/20 09:10:19 tom Exp $ */ /* * Copyright 1998-2016,2017 by Thomas E. Dickey * * All Rights Reserved * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * Except as contained in this notice, the name(s) of the above copyright * holders shall not be used in advertising or otherwise to promote the * sale, use or other dealings in this Software without prior written * authorization. */ /* * A portion of this module (for FontNameProperties) was adapted from EMU 1.3; * it constructs font names with specific properties changed, e.g., for bold * and double-size characters. */ #define RES_OFFSET(field) XtOffsetOf(SubResourceRec, field) #include #include #include #include #include #include #include #include #include #include #define SetFontWidth(screen,dst,src) (dst)->f_width = (src) #define SetFontHeight(screen,dst,src) (dst)->f_height = dimRound((screen)->scale_height * (float) (src)) /* from X11/Xlibint.h - not all vendors install this file */ #define CI_NONEXISTCHAR(cs) (((cs)->width == 0) && \ (((cs)->rbearing|(cs)->lbearing| \ (cs)->ascent|(cs)->descent) == 0)) #define CI_GET_CHAR_INFO_1D(fs,col,cs) \ { \ cs = 0; \ if (col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \ if (fs->per_char == NULL) { \ cs = &fs->min_bounds; \ } else { \ cs = &fs->per_char[(col - fs->min_char_or_byte2)]; \ } \ if (CI_NONEXISTCHAR(cs)) cs = 0; \ } \ } #define CI_GET_CHAR_INFO_2D(fs,row,col,cs) \ { \ cs = 0; \ if (row >= fs->min_byte1 && row <= fs->max_byte1 && \ col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \ if (fs->per_char == NULL) { \ cs = &fs->min_bounds; \ } else { \ cs = &fs->per_char[((row - fs->min_byte1) * \ (fs->max_char_or_byte2 - \ fs->min_char_or_byte2 + 1)) + \ (col - fs->min_char_or_byte2)]; \ } \ if (CI_NONEXISTCHAR(cs)) cs = 0; \ } \ } #define FREE_FNAME(field) \ if (fonts == 0 || myfonts.field != fonts->field) { \ FREE_STRING(myfonts.field); \ myfonts.field = 0; \ } /* * A structure to hold the relevant properties from a font * we need to make a well formed font name for it. */ typedef struct { /* registry, foundry, family */ const char *beginning; /* weight */ const char *weight; /* slant */ const char *slant; /* wideness */ const char *wideness; /* add style */ const char *add_style; int pixel_size; const char *point_size; int res_x; int res_y; const char *spacing; int average_width; /* charset registry, charset encoding */ char *end; } FontNameProperties; #if OPT_LOAD_VTFONTS || OPT_WIDE_CHARS static Boolean merge_sublist(char ***, char **); #endif static void save2FontList(XtermWidget, const char *, XtermFontNames *, VTFontEnum, const char *, Bool); #if OPT_RENDERFONT static void fillInFaceSize(XtermWidget, int); #endif #if OPT_SHIFT_FONTS static int lookupOneFontSize(XtermWidget, int); #endif #if OPT_REPORT_FONTS || OPT_WIDE_CHARS static unsigned countGlyphs(XFontStruct *fp) { unsigned count = 0; if (fp != 0) { if (fp->min_byte1 == 0 && fp->max_byte1 == 0) { count = fp->max_char_or_byte2 - fp->min_char_or_byte2 + 1; } else if (fp->min_char_or_byte2 < 256 && fp->max_char_or_byte2 < 256) { unsigned first = (fp->min_byte1 << 8) + fp->min_char_or_byte2; unsigned last = (fp->max_byte1 << 8) + fp->max_char_or_byte2; count = last + 1 - first; } } return count; } #endif #if OPT_WIDE_CHARS /* * Verify that the wide-bold font is at least a bold font with roughly as many * glyphs as the wide font. The counts should be the same, but settle for * filtering out the worst of the font mismatches. */ static Bool compatibleWideCounts(XFontStruct *wfs, XFontStruct *wbfs) { unsigned count_w = countGlyphs(wfs); unsigned count_wb = countGlyphs(wbfs); if (count_w <= 256 || count_wb <= 256 || ((count_w / 4) * 3) > count_wb) { TRACE(("...font server lied (count wide %u vs wide-bold %u)\n", count_w, count_wb)); return False; } return True; } #endif /* OPT_WIDE_CHARS */ #if OPT_BOX_CHARS static void setupPackedFonts(XtermWidget xw) { TScreen *screen = TScreenOf(xw); Bool value = False; #if OPT_RENDERFONT if (xw->work.render_font == True) { int e; for (e = 0; e < fMAX; ++e) { XTermXftFonts *data = getMyXftFont(xw, e, screen->menu_font_number); if (data != 0) { if (data->map.mixed) { screen->allow_packing = True; break; } } } } #endif /* OPT_RENDERFONT */ value = screen->allow_packing; SetItemSensitivity(fontMenuEntries[fontMenu_font_packedfont].widget, value); } #endif /* * Returns the fields from start to stop in a dash- separated string. This * function will modify the source, putting '\0's in the appropriate place and * moving the beginning forward to after the '\0' * * This will NOT work for the last field (but we won't need it). */ static char * n_fields(char **source, int start, int stop) { int i; char *str, *str1; /* * find the start-1th dash */ for (i = start - 1, str = *source; i; i--, str++) { if ((str = strchr(str, '-')) == 0) return 0; } /* * find the stopth dash */ for (i = stop - start + 1, str1 = str; i; i--, str1++) { if ((str1 = strchr(str1, '-')) == 0) return 0; } /* * put a \0 at the end of the fields */ *(str1 - 1) = '\0'; /* * move source forward */ *source = str1; return str; } static Boolean check_fontname(const char *name) { Boolean result = True; if (IsEmpty(name)) { TRACE(("fontname missing\n")); result = False; } return result; } /* * Gets the font properties from a given font structure. We use the FONT name * to find them out, since that seems easier. * * Returns a pointer to a static FontNameProperties structure * or NULL on error. */ static FontNameProperties * get_font_name_props(Display *dpy, XFontStruct *fs, char **result) { static FontNameProperties props; static char *last_name; Atom fontatom = XInternAtom(dpy, "FONT", False); char *name = 0; char *str; /* * first get the full font name */ if (fontatom != 0) { XFontProp *fp; int i; for (i = 0, fp = fs->properties; i < fs->n_properties; i++, fp++) { if (fp->name == fontatom) { name = XGetAtomName(dpy, fp->card32); break; } } } if (name == 0) return 0; /* * XGetAtomName allocates memory - don't leak */ if (last_name != 0) XFree(last_name); last_name = name; if (result != 0) { if (!check_fontname(name)) return 0; if (*result != 0) free(*result); *result = x_strdup(name); } /* * Now split it up into parts and put them in * their places. Since we are using parts of * the original string, we must not free the Atom Name */ /* registry, foundry, family */ if ((props.beginning = n_fields(&name, 1, 3)) == 0) return 0; /* weight is the next */ if ((props.weight = n_fields(&name, 1, 1)) == 0) return 0; /* slant */ if ((props.slant = n_fields(&name, 1, 1)) == 0) return 0; /* width */ if ((props.wideness = n_fields(&name, 1, 1)) == 0) return 0; /* add style */ if ((props.add_style = n_fields(&name, 1, 1)) == 0) return 0; /* pixel size */ if ((str = n_fields(&name, 1, 1)) == 0) return 0; if ((props.pixel_size = atoi(str)) == 0) return 0; /* point size */ if ((props.point_size = n_fields(&name, 1, 1)) == 0) return 0; /* res_x */ if ((str = n_fields(&name, 1, 1)) == 0) return 0; if ((props.res_x = atoi(str)) == 0) return 0; /* res_y */ if ((str = n_fields(&name, 1, 1)) == 0) return 0; if ((props.res_y = atoi(str)) == 0) return 0; /* spacing */ if ((props.spacing = n_fields(&name, 1, 1)) == 0) return 0; /* average width */ if ((str = n_fields(&name, 1, 1)) == 0) return 0; if ((props.average_width = atoi(str)) == 0) return 0; /* the rest: charset registry and charset encoding */ props.end = name; return &props; } #define ALLOCHUNK(n) ((n | 127) + 1) static void alloca_fontname(char **result, size_t next) { size_t last = (*result != 0) ? strlen(*result) : 0; size_t have = (*result != 0) ? ALLOCHUNK(last) : 0; size_t want = last + next + 2; if (want >= have) { want = ALLOCHUNK(want); if (last != 0) { char *save = *result; *result = TypeRealloc(char, want, *result); if (*result == 0) free(save); } else { if ((*result = TypeMallocN(char, want)) != 0) **result = '\0'; } } } static void append_fontname_str(char **result, const char *value) { if (value == 0) value = "*"; alloca_fontname(result, strlen(value)); if (*result != 0) { if (**result != '\0') strcat(*result, "-"); strcat(*result, value); } } static void append_fontname_num(char **result, int value) { if (value < 0) { append_fontname_str(result, "*"); } else { char temp[100]; sprintf(temp, "%d", value); append_fontname_str(result, temp); } } /* * Take the given font props and try to make a well formed font name specifying * the same base font and size and everything, but with different weight/width * according to the parameters. The return value is allocated, should be freed * by the caller. */ static char * derive_font_name(FontNameProperties *props, const char *use_weight, int use_average_width, const char *use_encoding) { char *result = 0; append_fontname_str(&result, props->beginning); append_fontname_str(&result, use_weight); append_fontname_str(&result, props->slant); append_fontname_str(&result, 0); append_fontname_str(&result, 0); append_fontname_num(&result, props->pixel_size); append_fontname_str(&result, props->point_size); append_fontname_num(&result, props->res_x); append_fontname_num(&result, props->res_y); append_fontname_str(&result, props->spacing); append_fontname_num(&result, use_average_width); append_fontname_str(&result, use_encoding); return result; } static char * bold_font_name(FontNameProperties *props, int use_average_width) { return derive_font_name(props, "bold", use_average_width, props->end); } #if OPT_WIDE_ATTRS static char * italic_font_name(FontNameProperties *props, const char *slant) { FontNameProperties myprops = *props; myprops.slant = slant; return derive_font_name(&myprops, props->weight, myprops.average_width, props->end); } static Boolean open_italic_font(XtermWidget xw, int n, FontNameProperties *fp, XTermFonts * data) { static const char *slant[] = { "o", "i" }; char *name; Cardinal pass; Boolean result = False; for (pass = 0; pass < XtNumber(slant); ++pass) { if ((name = italic_font_name(fp, slant[pass])) != 0) { TRACE(("open_italic_font %s %s\n", whichFontEnum((VTFontEnum) n), name)); if (xtermOpenFont(xw, name, data, False)) { result = (data->fs != 0); #if OPT_REPORT_FONTS if (resource.reportFonts) { printf("opened italic version of %s:\n\t%s\n", whichFontEnum(n), name); } #endif } free(name); if (result) break; } } #if OPT_TRACE if (result) { XFontStruct *fs = data->fs; if (fs != 0) { TRACE(("...actual size %dx%d (ascent %d, descent %d)\n", fs->ascent + fs->descent, fs->max_bounds.width, fs->ascent, fs->descent)); } } #endif return result; } #endif #if OPT_WIDE_CHARS #define derive_wide_font(props, weight) \ derive_font_name(props, weight, props->average_width * 2, "ISO10646-1") static char * wide_font_name(FontNameProperties *props) { return derive_wide_font(props, "medium"); } static char * widebold_font_name(FontNameProperties *props) { return derive_wide_font(props, "bold"); } #endif /* OPT_WIDE_CHARS */ #if OPT_DEC_CHRSET /* * Take the given font props and try to make a well formed font name specifying * the same base font but changed depending on the given attributes and chrset. * * For double width fonts, we just double the X-resolution, for double height * fonts we double the pixel-size and Y-resolution */ char * xtermSpecialFont(XtermWidget xw, unsigned attr_flags, unsigned draw_flags, unsigned chrset) { TScreen *screen = TScreenOf(xw); #if OPT_TRACE static char old_spacing[80]; static FontNameProperties old_props; #endif FontNameProperties *props; char *result = 0; const char *weight; int pixel_size; int res_x; int res_y; props = get_font_name_props(screen->display, getNormalFont(screen, fNorm)->fs, 0); if (props == 0) return result; pixel_size = props->pixel_size; res_x = props->res_x; res_y = props->res_y; if (attr_flags & BOLD) weight = "bold"; else weight = props->weight; if (CSET_DOUBLE(chrset)) res_x *= 2; if (chrset == CSET_DHL_TOP || chrset == CSET_DHL_BOT) { res_y *= 2; pixel_size *= 2; } #if OPT_TRACE if (old_props.res_x != res_x || old_props.res_x != res_y || old_props.pixel_size != pixel_size || strcmp(old_props.spacing, props->spacing)) { TRACE(("xtermSpecialFont(atts = %#x, draw = %#x, chrset = %#x)\n", attr_flags, draw_flags, chrset)); TRACE(("res_x = %d\n", res_x)); TRACE(("res_y = %d\n", res_y)); TRACE(("point_size = %s\n", props->point_size)); TRACE(("pixel_size = %d\n", pixel_size)); TRACE(("spacing = %s\n", props->spacing)); old_props.res_x = res_x; old_props.res_y = res_y; old_props.pixel_size = pixel_size; old_props.spacing = old_spacing; sprintf(old_spacing, "%.*s", (int) sizeof(old_spacing) - 2, props->spacing); } #endif append_fontname_str(&result, props->beginning); append_fontname_str(&result, weight); append_fontname_str(&result, props->slant); append_fontname_str(&result, props->wideness); append_fontname_str(&result, props->add_style); append_fontname_num(&result, pixel_size); append_fontname_str(&result, props->point_size); append_fontname_num(&result, (draw_flags & NORESOLUTION) ? -1 : res_x); append_fontname_num(&result, (draw_flags & NORESOLUTION) ? -1 : res_y); append_fontname_str(&result, props->spacing); append_fontname_str(&result, 0); append_fontname_str(&result, props->end); return result; } #endif /* OPT_DEC_CHRSET */ /* * Case-independent comparison for font-names, including wildcards. * XLFD allows '?' as a wildcard, but we do not handle that (no one seems * to use it). */ static Bool same_font_name(const char *pattern, const char *match) { Bool result = False; if (pattern && match) { while (*pattern && *match) { if (*pattern == *match) { pattern++; match++; } else if (*pattern == '*' || *match == '*') { if (same_font_name(pattern + 1, match)) { return True; } else if (same_font_name(pattern, match + 1)) { return True; } else { return False; } } else { int p = x_toupper(*pattern++); int m = x_toupper(*match++); if (p != m) return False; } } result = (*pattern == *match); /* both should be NUL */ } return result; } /* * Double-check the fontname that we asked for versus what the font server * actually gave us. The larger fixed fonts do not always have a matching bold * font, and the font server may try to scale another font or otherwise * substitute a mismatched font. * * If we cannot get what we requested, we will fallback to the original * behavior, which simulates bold by overstriking each character at one pixel * offset. */ static int got_bold_font(Display *dpy, XFontStruct *fs, String requested) { char *actual = 0; int got; if (get_font_name_props(dpy, fs, &actual) == 0) got = 0; else got = same_font_name(requested, actual); free(actual); return got; } /* * Check normal/bold (or wide/wide-bold) font pairs to see if we will be able * to check for missing glyphs in a comparable manner. */ static int comparable_metrics(XFontStruct *normal, XFontStruct *bold) { #define DATA "comparable_metrics: " int result = 0; if (normal == 0 || bold == 0) { ; } else if (normal->all_chars_exist) { if (bold->all_chars_exist) { result = 1; } else { TRACE((DATA "all chars exist in normal font, but not in bold\n")); } } else if (normal->per_char != 0) { if (bold->per_char != 0) { result = 1; } else { TRACE((DATA "normal font has per-char metrics, but not bold\n")); } } else { TRACE((DATA "normal font is not very good!\n")); result = 1; /* give in (we're not going in reverse) */ } return result; #undef DATA } /* * If the font server tries to adjust another font, it may not adjust it * properly. Check that the bounding boxes are compatible. Otherwise we'll * leave trash on the display when we mix normal and bold fonts. */ static int same_font_size(XtermWidget xw, XFontStruct *nfs, XFontStruct *bfs) { TScreen *screen = TScreenOf(xw); int result = 0; if (nfs != 0 && bfs != 0) { TRACE(("same_font_size height %d/%d, min %d/%d max %d/%d\n", nfs->ascent + nfs->descent, bfs->ascent + bfs->descent, nfs->min_bounds.width, bfs->min_bounds.width, nfs->max_bounds.width, bfs->max_bounds.width)); result = screen->free_bold_box || ((nfs->ascent + nfs->descent) == (bfs->ascent + bfs->descent) && (nfs->min_bounds.width == bfs->min_bounds.width || nfs->min_bounds.width == bfs->min_bounds.width + 1) && (nfs->max_bounds.width == bfs->max_bounds.width || nfs->max_bounds.width == bfs->max_bounds.width + 1)); } return result; } /* * Check if the font looks like it has fixed width */ static int is_fixed_font(XFontStruct *fs) { if (fs) return (fs->min_bounds.width == fs->max_bounds.width); return 1; } /* * Check if the font looks like a double width font (i.e. contains * characters of width X and 2X */ #if OPT_WIDE_CHARS static int is_double_width_font(XFontStruct *fs) { return ((2 * fs->min_bounds.width) == fs->max_bounds.width); } #else #define is_double_width_font(fs) 0 #endif #if OPT_WIDE_CHARS && OPT_RENDERFONT && defined(HAVE_TYPE_FCCHAR32) #define HALF_WIDTH_TEST_STRING "1234567890" /* '1234567890' in Chinese characters in UTF-8 */ #define FULL_WIDTH_TEST_STRING "\xe4\xb8\x80\xe4\xba\x8c\xe4\xb8\x89" \ "\xe5\x9b\x9b\xe4\xba\x94" \ "\xef\xa7\x91\xe4\xb8\x83\xe5\x85\xab" \ "\xe4\xb9\x9d\xef\xa6\xb2" /* '1234567890' in Korean script in UTF-8 */ #define FULL_WIDTH_TEST_STRING2 "\xec\x9d\xbc\xec\x9d\xb4\xec\x82\xbc" \ "\xec\x82\xac\xec\x98\xa4" \ "\xec\x9c\xa1\xec\xb9\xa0\xed\x8c\x94" \ "\xea\xb5\xac\xec\x98\x81" #define HALF_WIDTH_CHAR1 0x0031 /* '1' */ #define HALF_WIDTH_CHAR2 0x0057 /* 'W' */ #define FULL_WIDTH_CHAR1 0x4E00 /* CJK Ideograph 'number one' */ #define FULL_WIDTH_CHAR2 0xAC00 /* Korean script syllable 'Ka' */ static Bool is_double_width_font_xft(Display *dpy, XftFont *font) { XGlyphInfo gi1, gi2; FcChar32 c1 = HALF_WIDTH_CHAR1, c2 = HALF_WIDTH_CHAR2; String fwstr = FULL_WIDTH_TEST_STRING; String hwstr = HALF_WIDTH_TEST_STRING; /* Some Korean fonts don't have Chinese characters at all. */ if (!XftCharExists(dpy, font, FULL_WIDTH_CHAR1)) { if (!XftCharExists(dpy, font, FULL_WIDTH_CHAR2)) return False; /* Not a CJK font */ else /* a Korean font without CJK Ideographs */ fwstr = FULL_WIDTH_TEST_STRING2; } XftTextExtents32(dpy, font, &c1, 1, &gi1); XftTextExtents32(dpy, font, &c2, 1, &gi2); if (gi1.xOff != gi2.xOff) /* Not a fixed-width font */ return False; XftTextExtentsUtf8(dpy, font, (_Xconst FcChar8 *) hwstr, (int) strlen(hwstr), &gi1); XftTextExtentsUtf8(dpy, font, (_Xconst FcChar8 *) fwstr, (int) strlen(fwstr), &gi2); /* * fontconfig and Xft prior to 2.2(?) set the width of half-width * characters identical to that of full-width character in CJK double-width * (bi-width / monospace) font even though the former is half as wide as * the latter. This was fixed sometime before the release of fontconfig * 2.2 in early 2003. See * http://bugzilla.mozilla.org/show_bug.cgi?id=196312 * In the meantime, we have to check both possibilities. */ return ((2 * gi1.xOff == gi2.xOff) || (gi1.xOff == gi2.xOff)); } #else #define is_double_width_font_xft(dpy, xftfont) 0 #endif #define EmptyFont(fs) (fs != 0 \ && ((fs)->ascent + (fs)->descent == 0 \ || (fs)->max_bounds.width == 0)) #define FontSize(fs) (((fs)->ascent + (fs)->descent) \ * (fs)->max_bounds.width) const VTFontNames * xtermFontName(const char *normal) { static VTFontNames data; FREE_STRING(data.f_n); memset(&data, 0, sizeof(data)); if (normal) data.f_n = x_strdup(normal); return &data; } const VTFontNames * defaultVTFontNames(XtermWidget xw) { static VTFontNames data; memset(&data, 0, sizeof(data)); data.f_n = DefaultFontN(xw); data.f_b = DefaultFontB(xw); #if OPT_WIDE_CHARS data.f_w = DefaultFontW(xw); data.f_wb = DefaultFontWB(xw); #endif return &data; } static void cache_menu_font_name(TScreen *screen, int fontnum, int which, const char *name) { if (name != 0) { String last = screen->menu_font_names[fontnum][which]; if (last != 0) { if (strcmp(last, name)) { FREE_STRING(last); TRACE(("caching menu fontname %d.%d %s\n", fontnum, which, name)); screen->menu_font_names[fontnum][which] = x_strdup(name); } } else { TRACE(("caching menu fontname %d.%d %s\n", fontnum, which, name)); screen->menu_font_names[fontnum][which] = x_strdup(name); } } } typedef struct _cannotFont { struct _cannotFont *next; char *where; } CannotFont; static void cannotFont(XtermWidget xw, const char *who, const char *what, const char *where) { static CannotFont *ignored; CannotFont *list; switch (xw->misc.fontWarnings) { case fwNever: return; case fwResource: for (list = ignored; list != 0; list = list->next) { if (!strcmp(where, list->where)) { return; } } if ((list = TypeMalloc(CannotFont)) != 0) { list->where = x_strdup(where); list->next = ignored; ignored = list; } break; case fwAlways: break; } TRACE(("OOPS: cannot %s%s%s font \"%s\"\n", who, *what ? " " : "", what, where)); xtermWarning("cannot %s%s%s font \"%s\"\n", who, *what ? " " : "", what, where); } /* * Open the given font and verify that it is non-empty. Return a null on * failure. */ Bool xtermOpenFont(XtermWidget xw, const char *name, XTermFonts * result, Bool force) { Bool code = False; TScreen *screen = TScreenOf(xw); if (!IsEmpty(name)) { if ((result->fs = XLoadQueryFont(screen->display, name)) != 0) { code = True; if (EmptyFont(result->fs)) { xtermCloseFont(xw, result); code = False; } else { result->fn = x_strdup(name); } } else if (XmuCompareISOLatin1(name, DEFFONT) != 0) { if (result->warn <= xw->misc.fontWarnings #if OPT_RENDERFONT && !UsingRenderFont(xw) #endif ) { TRACE(("OOPS: cannot load font %s\n", name)); cannotFont(xw, "load", "", name); } else { TRACE(("xtermOpenFont: cannot load font '%s'\n", name)); } if (force) { result->warn = fwAlways; code = xtermOpenFont(xw, DEFFONT, result, True); } } } result->warn = fwAlways; return code; } /* * Close the font and free the font info. */ void xtermCloseFont(XtermWidget xw, XTermFonts * fnt) { if (fnt != 0 && fnt->fs != 0) { TScreen *screen = TScreenOf(xw); clrCgsFonts(xw, WhichVWin(screen), fnt); XFreeFont(screen->display, fnt->fs); xtermFreeFontInfo(fnt); } } /* * Close and free the font (as well as any aliases). */ static void xtermCloseFont2(XtermWidget xw, XTermFonts * fnts, int which) { XFontStruct *thisFont = fnts[which].fs; if (thisFont != 0) { int k; xtermCloseFont(xw, &fnts[which]); for (k = 0; k < fMAX; ++k) { if (k != which) { if (thisFont == fnts[k].fs) { xtermFreeFontInfo(&fnts[k]); } } } } } /* * Close the listed fonts, noting that some may use copies of the pointer. */ void xtermCloseFonts(XtermWidget xw, XTermFonts * fnts) { int j; for (j = 0; j < fMAX; ++j) { xtermCloseFont2(xw, fnts, j); } } /* * Make a copy of the source, assuming the XFontStruct's to be unique, but * ensuring that the names are reallocated to simplify freeing. */ void xtermCopyFontInfo(XTermFonts * target, XTermFonts * source) { xtermFreeFontInfo(target); target->chrset = source->chrset; target->flags = source->flags; target->fn = x_strdup(source->fn); target->fs = source->fs; target->warn = source->warn; } void xtermFreeFontInfo(XTermFonts * target) { target->chrset = 0; target->flags = 0; if (target->fn != 0) { free(target->fn); target->fn = 0; } target->fs = 0; } #if OPT_REPORT_FONTS static void reportXCharStruct(const char *tag, XCharStruct * cs) { printf("\t\t%s:\n", tag); printf("\t\t\tlbearing: %d\n", cs->lbearing); printf("\t\t\trbearing: %d\n", cs->rbearing); printf("\t\t\twidth: %d\n", cs->width); printf("\t\t\tascent: %d\n", cs->ascent); printf("\t\t\tdescent: %d\n", cs->descent); } static void reportOneVTFont(const char *tag, XTermFonts * fnt) { if (!IsEmpty(fnt->fn) && fnt->fs != 0) { XFontStruct *fs = fnt->fs; unsigned first_char = 0; unsigned last_char = 0; if (fs->max_byte1 == 0) { first_char = fs->min_char_or_byte2; last_char = fs->max_char_or_byte2; } else { first_char = (fs->min_byte1 * 256) + fs->min_char_or_byte2; last_char = (fs->max_byte1 * 256) + fs->max_char_or_byte2; } printf("\t%s: %s\n", tag, NonNull(fnt->fn)); printf("\t\tall chars: %s\n", fs->all_chars_exist ? "yes" : "no"); printf("\t\tdefault char: %d\n", fs->default_char); printf("\t\tdirection: %d\n", fs->direction); printf("\t\tascent: %d\n", fs->ascent); printf("\t\tdescent: %d\n", fs->descent); printf("\t\tfirst char: %u\n", first_char); printf("\t\tlast char: %u\n", last_char); printf("\t\tmaximum-chars: %u\n", countGlyphs(fs)); if (FontLacksMetrics(fnt)) { printf("\t\tmissing-chars: ?\n"); printf("\t\tpresent-chars: ?\n"); } else { unsigned missing = 0; unsigned ch; for (ch = first_char; ch <= last_char; ++ch) { if (xtermMissingChar(ch, fnt)) { ++missing; } } printf("\t\tmissing-chars: %u\n", missing); printf("\t\tpresent-chars: %u\n", countGlyphs(fs) - missing); } printf("\t\tmin_byte1: %d\n", fs->min_byte1); printf("\t\tmax_byte1: %d\n", fs->max_byte1); printf("\t\tproperties: %d\n", fs->n_properties); reportXCharStruct("min_bounds", &(fs->min_bounds)); reportXCharStruct("max_bounds", &(fs->max_bounds)); /* TODO: report fs->properties and fs->per_char */ } } static void reportVTFontInfo(XtermWidget xw, int fontnum) { if (resource.reportFonts) { TScreen *screen = TScreenOf(xw); if (fontnum) { printf("Loaded VTFonts(font%d)\n", fontnum); } else { printf("Loaded VTFonts(default)\n"); } reportOneVTFont("fNorm", getNormalFont(screen, fNorm)); reportOneVTFont("fBold", getNormalFont(screen, fBold)); #if OPT_WIDE_CHARS reportOneVTFont("fWide", getNormalFont(screen, fWide)); reportOneVTFont("fWBold", getNormalFont(screen, fWBold)); #endif } } #endif typedef XTermFonts *(*MyGetFont) (TScreen *, int); void xtermUpdateFontGCs(XtermWidget xw, Bool italic) { TScreen *screen = TScreenOf(xw); #if OPT_WIDE_ATTRS || OPT_RENDERWIDE MyGetFont myfunc = italic ? getItalicFont : getNormalFont; #else MyGetFont myfunc = getNormalFont; #endif VTwin *win = WhichVWin(screen); Pixel new_normal = getXtermForeground(xw, xw->flags, xw->cur_foreground); Pixel new_revers = getXtermBackground(xw, xw->flags, xw->cur_background); (void) italic; setCgsFore(xw, win, gcNorm, new_normal); setCgsBack(xw, win, gcNorm, new_revers); setCgsFont(xw, win, gcNorm, myfunc(screen, fNorm)); copyCgs(xw, win, gcBold, gcNorm); setCgsFont(xw, win, gcBold, myfunc(screen, fBold)); setCgsFore(xw, win, gcNormReverse, new_revers); setCgsBack(xw, win, gcNormReverse, new_normal); setCgsFont(xw, win, gcNormReverse, myfunc(screen, fNorm)); copyCgs(xw, win, gcBoldReverse, gcNormReverse); setCgsFont(xw, win, gcBoldReverse, myfunc(screen, fBold)); if_OPT_WIDE_CHARS(screen, { XTermFonts *wide_xx = myfunc(screen, fWide); XTermFonts *bold_xx = myfunc(screen, fWBold); if (wide_xx->fs != 0 && bold_xx->fs != 0) { setCgsFore(xw, win, gcWide, new_normal); setCgsBack(xw, win, gcWide, new_revers); setCgsFont(xw, win, gcWide, wide_xx); copyCgs(xw, win, gcWBold, gcWide); setCgsFont(xw, win, gcWBold, bold_xx); setCgsFore(xw, win, gcWideReverse, new_revers); setCgsBack(xw, win, gcWideReverse, new_normal); setCgsFont(xw, win, gcWideReverse, wide_xx); copyCgs(xw, win, gcWBoldReverse, gcWideReverse); setCgsFont(xw, win, gcWBoldReverse, bold_xx); } }); } #if OPT_TRACE static void show_font_misses(const char *name, XTermFonts * fp) { if (fp->fs != 0) { if (FontLacksMetrics(fp)) { TRACE(("%s font lacks metrics\n", name)); } else if (FontIsIncomplete(fp)) { TRACE(("%s font is incomplete\n", name)); } else { TRACE(("%s font is complete\n", name)); } } else { TRACE(("%s font is missing\n", name)); } } #endif static Bool loadNormFP(XtermWidget xw, char **nameOutP, XTermFonts * infoOut, int fontnum) { Bool status = True; TRACE(("loadNormFP (%s)\n", NonNull(*nameOutP))); if (!xtermOpenFont(xw, *nameOutP, infoOut, (fontnum == fontMenu_default))) { /* * If we are opening the default font, and it happens to be missing, * force that to the compiled-in default font, e.g., "fixed". If we * cannot open the font, disable it from the menu. */ if (fontnum != fontMenu_fontsel) { SetItemSensitivity(fontMenuEntries[fontnum].widget, False); } status = False; } return status; } static Bool loadBoldFP(XtermWidget xw, char **nameOutP, XTermFonts * infoOut, const char *nameRef, XTermFonts * infoRef, int fontnum) { TScreen *screen = TScreenOf(xw); Bool status = True; TRACE(("loadBoldFP (%s)\n", NonNull(*nameOutP))); if (!check_fontname(*nameOutP)) { FontNameProperties *fp; char *normal = x_strdup(nameRef); fp = get_font_name_props(screen->display, infoRef->fs, &normal); if (fp != 0) { *nameOutP = bold_font_name(fp, fp->average_width); if (!xtermOpenFont(xw, *nameOutP, infoOut, False)) { free(*nameOutP); *nameOutP = bold_font_name(fp, -1); xtermOpenFont(xw, *nameOutP, infoOut, False); } TRACE(("...derived bold '%s'\n", NonNull(*nameOutP))); } if (fp == 0 || infoOut->fs == 0) { xtermCopyFontInfo(infoOut, infoRef); TRACE(("...cannot load a matching bold font\n")); } else if (comparable_metrics(infoRef->fs, infoOut->fs) && same_font_size(xw, infoRef->fs, infoOut->fs) && got_bold_font(screen->display, infoOut->fs, *nameOutP)) { TRACE(("...got a matching bold font\n")); cache_menu_font_name(screen, fontnum, fBold, *nameOutP); } else { xtermCloseFont2(xw, infoOut - fBold, fBold); *infoOut = *infoRef; TRACE(("...did not get a matching bold font\n")); } free(normal); } else if (!xtermOpenFont(xw, *nameOutP, infoOut, False)) { xtermCopyFontInfo(infoOut, infoRef); TRACE(("...cannot load bold font '%s'\n", NonNull(*nameOutP))); } else { cache_menu_font_name(screen, fontnum, fBold, *nameOutP); } /* * Most of the time this call to load the font will succeed, even if * there is no wide font : the X server doubles the width of the * normal font, or similar. * * But if it did fail for some reason, then nevermind. */ if (EmptyFont(infoOut->fs)) status = False; /* can't use a 0-sized font */ if (!same_font_size(xw, infoRef->fs, infoOut->fs) && (is_fixed_font(infoRef->fs) && is_fixed_font(infoOut->fs))) { TRACE(("...ignoring mismatched normal/bold fonts\n")); xtermCloseFont2(xw, infoOut - fBold, fBold); xtermCopyFontInfo(infoOut, infoRef); } return status; } #if OPT_WIDE_CHARS static Bool loadWideFP(XtermWidget xw, char **nameOutP, XTermFonts * infoOut, const char *nameRef, XTermFonts * infoRef, int fontnum) { TScreen *screen = TScreenOf(xw); FontNameProperties *fp; Bool status = True; TRACE(("loadWideFP (%s)\n", NonNull(*nameOutP))); if (check_fontname(*nameOutP)) { cache_menu_font_name(screen, fontnum, fWide, *nameOutP); } else if (screen->utf8_fonts && !is_double_width_font(infoRef->fs)) { char *normal = x_strdup(nameRef); fp = get_font_name_props(screen->display, infoRef->fs, &normal); if (fp != 0) { *nameOutP = wide_font_name(fp); TRACE(("...derived wide %s\n", NonNull(*nameOutP))); cache_menu_font_name(screen, fontnum, fWide, *nameOutP); } free(normal); } if (check_fontname(*nameOutP)) { if (!xtermOpenFont(xw, *nameOutP, infoOut, False)) { xtermCopyFontInfo(infoOut, infoRef); } } else { xtermCopyFontInfo(infoOut, infoRef); } return status; } static Bool loadWBoldFP(XtermWidget xw, char **nameOutP, XTermFonts * infoOut, const char *wideNameRef, XTermFonts * wideInfoRef, const char *boldNameRef, XTermFonts * boldInfoRef, int fontnum) { TScreen *screen = TScreenOf(xw); Bool status = True; Boolean derived; char *bold = NULL; TRACE(("loadWBoldFP (%s)\n", NonNull(*nameOutP))); derived = False; if (!check_fontname(*nameOutP)) { FontNameProperties *fp; fp = get_font_name_props(screen->display, boldInfoRef->fs, &bold); if (fp != 0) { *nameOutP = widebold_font_name(fp); derived = True; } } if (check_fontname(*nameOutP)) { if (xtermOpenFont(xw, *nameOutP, infoOut, False) && derived && !compatibleWideCounts(wideInfoRef->fs, infoOut->fs)) { xtermCloseFont2(xw, infoOut - fWBold, fWBold); } if (infoOut->fs == 0) { if (derived) free(*nameOutP); if (IsEmpty(wideNameRef)) { *nameOutP = x_strdup(boldNameRef); xtermCopyFontInfo(infoOut, boldInfoRef); TRACE(("...cannot load wide-bold, use bold %s\n", NonNull(boldNameRef))); } else { *nameOutP = x_strdup(wideNameRef); xtermCopyFontInfo(infoOut, wideInfoRef); TRACE(("...cannot load wide-bold, use wide %s\n", NonNull(wideNameRef))); } } else { TRACE(("...%s wide/bold %s\n", derived ? "derived" : "given", NonNull(*nameOutP))); cache_menu_font_name(screen, fontnum, fWBold, *nameOutP); } } else if (is_double_width_font(boldInfoRef->fs)) { xtermCopyFontInfo(infoOut, boldInfoRef); TRACE(("...bold font is double-width, use it %s\n", NonNull(boldNameRef))); } else { xtermCopyFontInfo(infoOut, wideInfoRef); TRACE(("...cannot load wide bold font, use wide %s\n", NonNull(wideNameRef))); } free(bold); if (EmptyFont(infoOut->fs)) { status = False; /* can't use a 0-sized font */ } else { if ((!comparable_metrics(wideInfoRef->fs, infoOut->fs) || (!same_font_size(xw, wideInfoRef->fs, infoOut->fs) && is_fixed_font(wideInfoRef->fs) && is_fixed_font(infoOut->fs)))) { TRACE(("...ignoring mismatched normal/bold wide fonts\n")); xtermCloseFont2(xw, infoOut - fWBold, fWBold); xtermCopyFontInfo(infoOut, wideInfoRef); } } return status; } #endif int xtermLoadFont(XtermWidget xw, const VTFontNames * fonts, Bool doresize, int fontnum) { TScreen *screen = TScreenOf(xw); VTwin *win = WhichVWin(screen); VTFontNames myfonts; XTermFonts fnts[fMAX]; char *tmpname = NULL; Boolean proportional = False; memset(&myfonts, 0, sizeof(myfonts)); memset(fnts, 0, sizeof(fnts)); if (fonts != 0) myfonts = *fonts; if (!check_fontname(myfonts.f_n)) return 0; if (fontnum == fontMenu_fontescape && myfonts.f_n != screen->MenuFontName(fontnum)) { if ((tmpname = x_strdup(myfonts.f_n)) == 0) return 0; } TRACE(("Begin Cgs - xtermLoadFont(%s)\n", myfonts.f_n)); releaseWindowGCs(xw, win); #define DbgResource(name, field, index) \ TRACE(("xtermLoadFont #%d "name" %s%s\n", \ fontnum, \ (fnts[index].warn == fwResource) ? "*" : " ", \ NonNull(myfonts.field))) DbgResource("normal", f_n, fNorm); DbgResource("bold ", f_b, fBold); #if OPT_WIDE_CHARS DbgResource("wide ", f_w, fWide); DbgResource("w/bold", f_wb, fWBold); #endif if (!loadNormFP(xw, &myfonts.f_n, &fnts[fNorm], fontnum)) goto bad; if (!loadBoldFP(xw, &myfonts.f_b, &fnts[fBold], myfonts.f_n, &fnts[fNorm], fontnum)) goto bad; /* * If there is no widefont specified, fake it by doubling AVERAGE_WIDTH * of normal fonts XLFD, and asking for it. This plucks out 18x18ja * and 12x13ja as the corresponding fonts for 9x18 and 6x13. */ if_OPT_WIDE_CHARS(screen, { if (!loadWideFP(xw, &myfonts.f_w, &fnts[fWide], myfonts.f_n, &fnts[fNorm], fontnum)) goto bad; if (!loadWBoldFP(xw, &myfonts.f_wb, &fnts[fWBold], myfonts.f_w, &fnts[fWide], myfonts.f_b, &fnts[fBold], fontnum)) goto bad; }); /* * Normal/bold fonts should be the same width. Also, the min/max * values should be the same. */ if (!is_fixed_font(fnts[fNorm].fs) || !is_fixed_font(fnts[fBold].fs) || fnts[fNorm].fs->max_bounds.width != fnts[fBold].fs->max_bounds.width) { TRACE(("Proportional font! normal %d/%d, bold %d/%d\n", fnts[fNorm].fs->min_bounds.width, fnts[fNorm].fs->max_bounds.width, fnts[fBold].fs->min_bounds.width, fnts[fBold].fs->max_bounds.width)); proportional = True; } if_OPT_WIDE_CHARS(screen, { if (fnts[fWide].fs != 0 && fnts[fWBold].fs != 0 && (!is_fixed_font(fnts[fWide].fs) || !is_fixed_font(fnts[fWBold].fs) || fnts[fWide].fs->max_bounds.width != fnts[fWBold].fs->max_bounds.width)) { TRACE(("Proportional font! wide %d/%d, wide bold %d/%d\n", fnts[fWide].fs->min_bounds.width, fnts[fWide].fs->max_bounds.width, fnts[fWBold].fs->min_bounds.width, fnts[fWBold].fs->max_bounds.width)); proportional = True; } }); /* TODO : enforce that the width of the wide font is 2* the width of the narrow font */ /* * If we're switching fonts, free the old ones. Otherwise we'll leak * the memory that is associated with the old fonts. The * XLoadQueryFont call allocates a new XFontStruct. */ xtermCloseFonts(xw, screen->fnts); #if OPT_WIDE_ATTRS xtermCloseFonts(xw, screen->ifnts); screen->ifnts_ok = False; #endif xtermCopyFontInfo(getNormalFont(screen, fNorm), &fnts[fNorm]); xtermCopyFontInfo(getNormalFont(screen, fBold), &fnts[fBold]); #if OPT_WIDE_CHARS xtermCopyFontInfo(getNormalFont(screen, fWide), &fnts[fWide]); if (fnts[fWBold].fs == NULL) xtermCopyFontInfo(getNormalFont(screen, fWide), &fnts[fWide]); xtermCopyFontInfo(getNormalFont(screen, fWBold), &fnts[fWBold]); #endif xtermUpdateFontGCs(xw, False); #if OPT_BOX_CHARS screen->allow_packing = proportional; setupPackedFonts(xw); #endif screen->fnt_prop = (Boolean) (proportional && !(screen->force_packed)); screen->fnt_boxes = True; #if OPT_BOX_CHARS /* * xterm uses character positions 1-31 of a font for the line-drawing * characters. Check that they are all present. The null character * (0) is special, and is not used. */ #if OPT_RENDERFONT if (UsingRenderFont(xw)) { /* * FIXME: we shouldn't even be here if we're using Xft. */ screen->fnt_boxes = False; TRACE(("assume Xft missing line-drawing chars\n")); } else #endif { unsigned ch; #if OPT_TRACE #define TRACE_MISS(index) show_font_misses(#index, &fnts[index]) TRACE_MISS(fNorm); TRACE_MISS(fBold); #if OPT_WIDE_CHARS TRACE_MISS(fWide); TRACE_MISS(fWBold); #endif #endif for (ch = 1; ch < 32; ch++) { unsigned n = ch; #if OPT_WIDE_CHARS if (screen->utf8_mode || screen->unicode_font) { n = dec2ucs(ch); if (n == UCS_REPL) continue; } #endif if (IsXtermMissingChar(screen, n, &fnts[fNorm])) { TRACE(("missing normal char #%d\n", n)); screen->fnt_boxes = False; break; } if (IsXtermMissingChar(screen, n, &fnts[fBold])) { TRACE(("missing bold char #%d\n", n)); screen->fnt_boxes = False; break; } } } TRACE(("Will %suse internal line-drawing characters\n", screen->fnt_boxes ? "not " : "")); #endif if (screen->always_bold_mode) { screen->enbolden = screen->bold_mode; } else { screen->enbolden = screen->bold_mode && ((fnts[fNorm].fs == fnts[fBold].fs) || same_font_name(myfonts.f_n, myfonts.f_b)); } TRACE(("Will %suse 1-pixel offset/overstrike to simulate bold\n", screen->enbolden ? "" : "not ")); set_menu_font(False); screen->menu_font_number = fontnum; set_menu_font(True); if (tmpname) { /* if setting escape or sel */ if (screen->MenuFontName(fontnum)) FREE_STRING(screen->MenuFontName(fontnum)); screen->MenuFontName(fontnum) = tmpname; if (fontnum == fontMenu_fontescape) { update_font_escape(); } #if OPT_SHIFT_FONTS screen->menu_font_sizes[fontnum] = FontSize(fnts[fNorm].fs); #endif } set_cursor_gcs(xw); xtermUpdateFontInfo(xw, doresize); TRACE(("Success Cgs - xtermLoadFont\n")); #if OPT_REPORT_FONTS reportVTFontInfo(xw, fontnum); #endif FREE_FNAME(f_n); FREE_FNAME(f_b); #if OPT_WIDE_CHARS FREE_FNAME(f_w); FREE_FNAME(f_wb); #endif if (fnts[fNorm].fn == fnts[fBold].fn) { free(fnts[fNorm].fn); } else { free(fnts[fNorm].fn); free(fnts[fBold].fn); } #if OPT_WIDE_CHARS free(fnts[fWide].fn); free(fnts[fWBold].fn); #endif xtermSetWinSize(xw); return 1; bad: if (tmpname) free(tmpname); #if OPT_RENDERFONT if ((fontnum == fontMenu_fontsel) && (fontnum != screen->menu_font_number)) { int old_fontnum = screen->menu_font_number; #if OPT_TOOLBAR SetItemSensitivity(fontMenuEntries[fontnum].widget, True); #endif Bell(xw, XkbBI_MinorError, 0); myfonts.f_n = screen->MenuFontName(old_fontnum); return xtermLoadFont(xw, &myfonts, doresize, old_fontnum); } else if (x_strcasecmp(myfonts.f_n, DEFFONT)) { int code; myfonts.f_n = x_strdup(DEFFONT); TRACE(("...recovering for TrueType fonts\n")); code = xtermLoadFont(xw, &myfonts, doresize, fontnum); if (code) { if (fontnum != fontMenu_fontsel) { SetItemSensitivity(fontMenuEntries[fontnum].widget, UsingRenderFont(xw)); } TRACE(("...recovered size %dx%d\n", FontHeight(screen), FontWidth(screen))); } return code; } #endif releaseWindowGCs(xw, win); xtermCloseFonts(xw, fnts); TRACE(("Fail Cgs - xtermLoadFont\n")); return 0; } #if OPT_WIDE_ATTRS /* * (Attempt to) load matching italics for the current normal/bold/etc fonts. * If the attempt fails for a given style, use the non-italic font. */ void xtermLoadItalics(XtermWidget xw) { TScreen *screen = TScreenOf(xw); if (!screen->ifnts_ok) { int n; FontNameProperties *fp; XTermFonts *data; screen->ifnts_ok = True; for (n = 0; n < fMAX; ++n) { switch (n) { case fNorm: /* FALLTHRU */ case fBold: /* FALLTHRU */ #if OPT_WIDE_CHARS case fWide: /* FALLTHRU */ case fWBold: #endif /* FALLTHRU */ data = getItalicFont(screen, n); /* * FIXME - need to handle font-leaks */ data->fs = 0; if (getNormalFont(screen, n)->fs != 0 && (fp = get_font_name_props(screen->display, getNormalFont(screen, n)->fs, 0)) != 0) { if (!open_italic_font(xw, n, fp, data)) { if (n > 0) { xtermCopyFontInfo(data, getItalicFont(screen, n - 1)); } else { xtermOpenFont(xw, getNormalFont(screen, n)->fn, data, False); } } } break; } } } } #endif #if OPT_LOAD_VTFONTS || OPT_WIDE_CHARS /* * Collect font-names that we can modify with the load-vt-fonts() action. */ #define MERGE_SUBFONT(dst,src,name) \ if (IsEmpty(dst.name)) { \ TRACE(("MERGE_SUBFONT " #dst "." #name " merge \"%s\"\n", NonNull(src.name))); \ dst.name = x_strdup(src.name); \ } else { \ TRACE(("MERGE_SUBFONT " #dst "." #name " found \"%s\"\n", NonNull(dst.name))); \ } #define MERGE_SUBLIST(dst,src,name) \ if (merge_sublist(&(dst.fonts.x11.name), src.fonts.x11.name)) { \ TRACE(("MERGE_SUBLIST " #dst "." #name " merge \"%s\"\n", src.fonts.x11.name[0])); \ } else { \ TRACE(("MERGE_SUBLIST " #dst "." #name " found \"%s\"\n", dst.fonts.x11.name[0])); \ } #define INFER_SUBFONT(dst,src,name) \ if (IsEmpty(dst.name)) { \ TRACE(("INFER_SUBFONT " #dst "." #name " will infer\n")); \ dst.name = x_strdup(""); \ } else { \ TRACE(("INFER_SUBFONT " #dst "." #name " found \"%s\"\n", NonNull(dst.name))); \ } #define FREE_MENU_FONTS(dst) \ TRACE(("FREE_MENU_FONTS " #dst "\n")); \ for (n = fontMenu_default; n <= fontMenu_lastBuiltin; ++n) { \ for (m = 0; m < fMAX; ++m) { \ FREE_STRING(dst.menu_font_names[n][m]); \ dst.menu_font_names[n][m] = 0; \ } \ } #define COPY_MENU_FONTS(dst,src) \ TRACE(("COPY_MENU_FONTS " #src " to " #dst "\n")); \ for (n = fontMenu_default; n <= fontMenu_lastBuiltin; ++n) { \ for (m = 0; m < fMAX; ++m) { \ FREE_STRING(dst.menu_font_names[n][m]); \ dst.menu_font_names[n][m] = x_strdup(src.menu_font_names[n][m]); \ } \ TRACE((".. " #dst ".menu_fonts_names[%d] = %s\n", n, NonNull(dst.menu_font_names[n][fNorm]))); \ } #define COPY_DEFAULT_FONTS(target, source) \ TRACE(("COPY_DEFAULT_FONTS " #source " to " #target "\n")); \ xtermCopyVTFontNames(&target.default_font, &source.default_font) #define COPY_X11_FONTLISTS(target, source) \ TRACE(("COPY_X11_FONTLISTS " #source " to " #target "\n")); \ xtermCopyFontLists(xw, &target.fonts.x11, &source.fonts.x11) static void xtermCopyVTFontNames(VTFontNames * target, VTFontNames * source) { #define COPY_IT(name,field) \ TRACE((".. "#name" = %s\n", NonNull(source->field))); \ free(target->field); \ target->field = x_strdup(source->field) TRACE(("xtermCopyVTFontNames\n")); COPY_IT(font, f_n); COPY_IT(boldFont, f_b); #if OPT_WIDE_CHARS COPY_IT(wideFont, f_w); COPY_IT(wideBoldFont, f_wb); #endif #undef COPY_IT } static void xtermCopyFontLists(XtermWidget xw, VTFontList * target, VTFontList * source) { #define COPY_IT(name,field) \ copyFontList(&(target->field), source->field); \ TRACE_ARGV(".. " #name, source->field) (void) xw; TRACE(("xtermCopyFontLists %s ->%s\n", whichFontList(xw, source), whichFontList(xw, target))); COPY_IT(font, list_n); COPY_IT(fontBold, list_b); #if OPT_WIDE_ATTRS || OPT_RENDERWIDE COPY_IT(fontItal, list_i); #endif #if OPT_WIDE_CHARS COPY_IT(wideFont, list_w); COPY_IT(wideBoldFont, list_wb); COPY_IT(wideItalFont, list_wi); #endif #undef COPY_IT } void xtermSaveVTFonts(XtermWidget xw) { TScreen *screen = TScreenOf(xw); Cardinal n, m; if (!screen->savedVTFonts) { screen->savedVTFonts = True; TRACE(("xtermSaveVTFonts saving original\n")); COPY_DEFAULT_FONTS(screen->cacheVTFonts, xw->misc); COPY_X11_FONTLISTS(screen->cacheVTFonts, xw->work); COPY_MENU_FONTS(screen->cacheVTFonts, xw->screen); } } #define SAME_STRING(x,y) ((x) == (y) || ((x) && (y) && !strcmp(x, y))) #define SAME_MEMBER(n) SAME_STRING(a->n, b->n) static Boolean sameSubResources(SubResourceRec * a, SubResourceRec * b) { Boolean result = True; if (!SAME_MEMBER(default_font.f_n) || !SAME_MEMBER(default_font.f_b) #if OPT_WIDE_CHARS || !SAME_MEMBER(default_font.f_w) || !SAME_MEMBER(default_font.f_wb) #endif ) { TRACE(("sameSubResources: default_font differs\n")); result = False; } else { int n; for (n = 0; n < NMENUFONTS; ++n) { if (!SAME_MEMBER(menu_font_names[n][fNorm])) { TRACE(("sameSubResources: menu_font_names[%d] differs\n", n)); result = False; break; } } } return result; } /* * Load the "VT" font names from the given subresource name/class. These * correspond to the VT100 resources. */ static Bool xtermLoadVTFonts(XtermWidget xw, String myName, String myClass) { SubResourceRec subresourceRec; SubResourceRec referenceRec; /* * These are duplicates of the VT100 font resources, but with a special * application/classname passed in to distinguish them. */ static XtResource font_resources[] = { Sres(XtNfont, XtCFont, default_font.f_n, DEFFONT), Sres(XtNboldFont, XtCBoldFont, default_font.f_b, DEFBOLDFONT), #if OPT_WIDE_CHARS Sres(XtNwideFont, XtCWideFont, default_font.f_w, DEFWIDEFONT), Sres(XtNwideBoldFont, XtCWideBoldFont, default_font.f_wb, DEFWIDEBOLDFONT), #endif Sres(XtNfont1, XtCFont1, MenuFontName(fontMenu_font1), NULL), Sres(XtNfont2, XtCFont2, MenuFontName(fontMenu_font2), NULL), Sres(XtNfont3, XtCFont3, MenuFontName(fontMenu_font3), NULL), Sres(XtNfont4, XtCFont4, MenuFontName(fontMenu_font4), NULL), Sres(XtNfont5, XtCFont5, MenuFontName(fontMenu_font5), NULL), Sres(XtNfont6, XtCFont6, MenuFontName(fontMenu_font6), NULL), }; Cardinal n, m; Bool status = True; TScreen *screen = TScreenOf(xw); TRACE(("called xtermLoadVTFonts(name=%s, class=%s)\n", NonNull(myName), NonNull(myClass))); xtermSaveVTFonts(xw); if (IsEmpty(myName)) { TRACE(("xtermLoadVTFonts restoring original\n")); COPY_DEFAULT_FONTS(xw->misc, screen->cacheVTFonts); COPY_X11_FONTLISTS(xw->work, screen->cacheVTFonts); FREE_MENU_FONTS(xw->screen); COPY_MENU_FONTS(xw->screen, screen->cacheVTFonts); } else { TRACE(("xtermLoadVTFonts(%s, %s)\n", myName, myClass)); memset(&referenceRec, 0, sizeof(referenceRec)); memset(&subresourceRec, 0, sizeof(subresourceRec)); XtGetSubresources((Widget) xw, (XtPointer) &subresourceRec, myName, myClass, font_resources, (Cardinal) XtNumber(font_resources), NULL, (Cardinal) 0); /* * XtGetSubresources returns no status, so we compare the returned * data against a zero'd struct to see if any data is returned. */ if (memcmp(&referenceRec, &subresourceRec, sizeof(referenceRec)) && !sameSubResources(&(screen->cacheVTFonts), &subresourceRec)) { screen->mergedVTFonts = True; /* * To make it simple, reallocate the strings returned by * XtGetSubresources. We can free our own strings, but not theirs. */ ALLOC_STRING(subresourceRec.default_font.f_n); ALLOC_STRING(subresourceRec.default_font.f_b); #if OPT_WIDE_CHARS ALLOC_STRING(subresourceRec.default_font.f_w); ALLOC_STRING(subresourceRec.default_font.f_wb); #endif for (n = fontMenu_font1; n <= fontMenu_lastBuiltin; ++n) { ALLOC_STRING(subresourceRec.MenuFontName(n)); } /* * Now, save the string to a font-list for consistency */ #define ALLOC_SUBLIST(which,field) \ save2FontList(xw, "cached", \ &(subresourceRec.fonts), \ which, \ subresourceRec.default_font.field, False) ALLOC_SUBLIST(fNorm, f_n); ALLOC_SUBLIST(fBold, f_b); #if OPT_WIDE_CHARS ALLOC_SUBLIST(fWide, f_w); ALLOC_SUBLIST(fWBold, f_wb); #endif /* * If a particular resource value was not found, use the original. */ MERGE_SUBFONT(subresourceRec, xw->misc, default_font.f_n); INFER_SUBFONT(subresourceRec, xw->misc, default_font.f_b); MERGE_SUBLIST(subresourceRec, xw->work, list_n); MERGE_SUBLIST(subresourceRec, xw->work, list_b); #if OPT_WIDE_CHARS INFER_SUBFONT(subresourceRec, xw->misc, default_font.f_w); INFER_SUBFONT(subresourceRec, xw->misc, default_font.f_wb); MERGE_SUBLIST(subresourceRec, xw->work, list_w); MERGE_SUBLIST(subresourceRec, xw->work, list_wb); #endif for (n = fontMenu_font1; n <= fontMenu_lastBuiltin; ++n) { MERGE_SUBFONT(subresourceRec, xw->screen, MenuFontName(n)); } /* * Finally, copy the subresource data to the widget. */ COPY_DEFAULT_FONTS(xw->misc, subresourceRec); COPY_X11_FONTLISTS(xw->work, subresourceRec); FREE_MENU_FONTS(xw->screen); COPY_MENU_FONTS(xw->screen, subresourceRec); FREE_STRING(screen->MenuFontName(fontMenu_default)); FREE_STRING(screen->menu_font_names[0][fBold]); screen->MenuFontName(fontMenu_default) = x_strdup(DefaultFontN(xw)); screen->menu_font_names[0][fBold] = x_strdup(DefaultFontB(xw)); #if OPT_WIDE_CHARS FREE_STRING(screen->menu_font_names[0][fWide]); FREE_STRING(screen->menu_font_names[0][fWBold]); screen->menu_font_names[0][fWide] = x_strdup(DefaultFontW(xw)); screen->menu_font_names[0][fWBold] = x_strdup(DefaultFontWB(xw)); #endif /* * And remove our copies of strings. */ FREE_STRING(subresourceRec.default_font.f_n); FREE_STRING(subresourceRec.default_font.f_b); #if OPT_WIDE_CHARS FREE_STRING(subresourceRec.default_font.f_w); FREE_STRING(subresourceRec.default_font.f_wb); #endif for (n = fontMenu_font1; n <= fontMenu_lastBuiltin; ++n) { FREE_STRING(subresourceRec.MenuFontName(n)); } } else { TRACE(("...no resources found\n")); status = False; } } TRACE((".. xtermLoadVTFonts: %d\n", status)); return status; } #if OPT_WIDE_CHARS static Bool isWideFont(XFontStruct *fp, const char *tag, Bool nullOk) { Bool result = False; (void) tag; if (okFont(fp)) { unsigned count = countGlyphs(fp); TRACE(("isWideFont(%s) found %d cells\n", tag, count)); result = (count > 256) ? True : False; } else { result = nullOk; } return result; } /* * If the current fonts are not wide, load the UTF8 fonts. * * Called during initialization (for wide-character mode), the fonts have not * been setup, so we pass nullOk=True to isWideFont(). * * Called after initialization, e.g., in response to the UTF-8 menu entry * (starting from narrow character mode), it checks if the fonts are not wide. */ Bool xtermLoadWideFonts(XtermWidget xw, Bool nullOk) { TScreen *screen = TScreenOf(xw); Bool result; if (EmptyFont(getNormalFont(screen, fWide)->fs)) { result = (isWideFont(getNormalFont(screen, fNorm)->fs, "normal", nullOk) && isWideFont(getNormalFont(screen, fBold)->fs, "bold", nullOk)); } else { result = (isWideFont(getNormalFont(screen, fWide)->fs, "wide", nullOk) && isWideFont(getNormalFont(screen, fWBold)->fs, "wide-bold", nullOk)); if (result && !screen->utf8_latin1) { result = (isWideFont(getNormalFont(screen, fNorm)->fs, "normal", nullOk) && isWideFont(getNormalFont(screen, fBold)->fs, "bold", nullOk)); } } if (!result) { TRACE(("current fonts are not all wide%s\n", nullOk ? " nullOk" : "")); result = xtermLoadVTFonts(xw, XtNutf8Fonts, XtCUtf8Fonts); } TRACE(("xtermLoadWideFonts:%d\n", result)); return result; } #endif /* OPT_WIDE_CHARS */ /* * Restore the default fonts, i.e., if we had switched to wide-fonts. */ Bool xtermLoadDefaultFonts(XtermWidget xw) { Bool result; result = xtermLoadVTFonts(xw, NULL, NULL); TRACE(("xtermLoadDefaultFonts:%d\n", result)); return result; } #endif /* OPT_LOAD_VTFONTS || OPT_WIDE_CHARS */ #if OPT_LOAD_VTFONTS void HandleLoadVTFonts(Widget w, XEvent *event GCC_UNUSED, String *params GCC_UNUSED, Cardinal *param_count GCC_UNUSED) { XtermWidget xw; if ((xw = getXtermWidget(w)) != 0) { static char empty[] = ""; /* appease strict compilers */ TScreen *screen = TScreenOf(xw); char name_buf[80]; String name = (String) ((*param_count > 0) ? params[0] : empty); char *myName = MyStackAlloc(strlen(name) + 1, name_buf); TRACE(("HandleLoadVTFonts(%d)\n", *param_count)); if (myName != 0) { char class_buf[80]; String convert = (String) ((*param_count > 1) ? params[1] : myName); char *myClass = MyStackAlloc(strlen(convert) + 1, class_buf); strcpy(myName, name); if (myClass != 0) { strcpy(myClass, convert); if (*param_count == 1) myClass[0] = x_toupper(myClass[0]); if (xtermLoadVTFonts(xw, myName, myClass)) { int n; /* * When switching fonts, try to preserve the font-menu * selection, since it is less surprising to do that (if * the font-switching can be undone) than to switch to * "Default". */ int font_number = screen->menu_font_number; if (font_number > fontMenu_lastBuiltin) font_number = fontMenu_lastBuiltin; for (n = 0; n < NMENUFONTS; ++n) { screen->menu_font_sizes[n] = 0; } if (font_number == fontMenu_default) { SetVTFont(xw, font_number, True, defaultVTFontNames(xw)); } else { SetVTFont(xw, font_number, True, NULL); } } MyStackFree(myClass, class_buf); } MyStackFree(myName, name_buf); } } } #endif /* OPT_LOAD_VTFONTS */ /* * Set the limits for the box that outlines the cursor. */ void xtermSetCursorBox(TScreen *screen) { static XPoint VTbox[NBOX]; XPoint *vp; int fw = FontWidth(screen) - 1; int fh = FontHeight(screen) - 1; int ww = isCursorBar(screen) ? 1 : fw; int hh = isCursorUnderline(screen) ? 1 : fh; vp = &VTbox[1]; (vp++)->x = (short) ww; (vp++)->y = (short) hh; (vp++)->x = (short) -ww; vp->y = (short) -hh; screen->box = VTbox; } #define CACHE_XFT(dst,src) if (src != 0) {\ checkXft(xw, &(dst[fontnum]), src);\ TRACE(("Xft metrics %s[%d] = %d (%d,%d)%s advance %d, actual %d%s\n",\ #dst,\ fontnum,\ src->height,\ src->ascent,\ src->descent,\ ((src->ascent + src->descent) > src->height ? "*" : ""),\ src->max_advance_width,\ dst[fontnum].map.min_width,\ dst[fontnum].map.mixed ? " mixed" : ""));\ } #if OPT_RENDERFONT #if OPT_REPORT_FONTS static FcChar32 xtermXftFirstChar(XftFont *xft) { FcChar32 map[FC_CHARSET_MAP_SIZE]; FcChar32 next; FcChar32 first; int i; first = FcCharSetFirstPage(xft->charset, map, &next); for (i = 0; i < FC_CHARSET_MAP_SIZE; i++) { if (map[i]) { FcChar32 bits = map[i]; first += (FcChar32) i *32; while (!(bits & 0x1)) { bits >>= 1; first++; } break; } } return first; } static FcChar32 xtermXftLastChar(XftFont *xft) { FcChar32 this, last, next; FcChar32 map[FC_CHARSET_MAP_SIZE]; int i; last = FcCharSetFirstPage(xft->charset, map, &next); while ((this = FcCharSetNextPage(xft->charset, map, &next)) != FC_CHARSET_DONE) last = this; last &= (FcChar32) ~ 0xff; for (i = FC_CHARSET_MAP_SIZE - 1; i >= 0; i--) { if (map[i]) { FcChar32 bits = map[i]; last += (FcChar32) i *32 + 31; while (!(bits & 0x80000000)) { last--; bits <<= 1; } break; } } return (FcChar32) last; } #endif /* OPT_REPORT_FONTS */ #if OPT_TRACE > 1 static void dumpXft(XtermWidget xw, XTermXftFonts *data) { XftFont *xft = data->font; TScreen *screen = TScreenOf(xw); VTwin *win = WhichVWin(screen); FcChar32 c; FcChar32 first = xtermXftFirstChar(xft); FcChar32 last = xtermXftLastChar(xft); unsigned count = 0; unsigned outside = 0; TRACE(("dumpXft {{\n")); TRACE((" data range %#6x..%#6x\n", first, last)); for (c = first; c <= last; ++c) { if (FcCharSetHasChar(xft->charset, c)) { int width = my_wcwidth((int) c); XGlyphInfo extents; XftTextExtents32(XtDisplay(xw), xft, &c, 1, &extents); TRACE(("%#6x %2d %.1f\n", c, width, ((double) extents.width) / win->f_width)); if (extents.width > win->f_width) ++outside; ++count; } } TRACE(("}} %u total, %u outside\n", count, outside)); } #define DUMP_XFT(xw, data) dumpXft(xw, data) #else #define DUMP_XFT(xw, data) /* nothing */ #endif static void checkXft(XtermWidget xw, XTermXftFonts *data, XftFont *xft) { FcChar32 c; Dimension width = 0; data->font = xft; data->map.min_width = 0; data->map.max_width = (Dimension) xft->max_advance_width; /* * For each ASCII or ISO-8859-1 printable code, ask what its width is. * Given the maximum width for those, we have a reasonable estimate of * the single-column width. * * Ignore control characters - their extent information is misleading. */ for (c = 32; c < 256; ++c) { if (c >= 127 && c <= 159) continue; if (FcCharSetHasChar(xft->charset, c)) { XGlyphInfo extents; XftTextExtents32(XtDisplay(xw), xft, &c, 1, &extents); if (width < extents.width && extents.width <= data->map.max_width) { width = extents.width; } } } data->map.min_width = width; data->map.mixed = (data->map.max_width >= (data->map.min_width + 1)); } #if OPT_REPORT_FONTS static void reportXftFonts(XtermWidget xw, XftFont *fp, const char *name, const char *tag, XftPattern *match) { if (resource.reportFonts) { char buffer[1024]; FcChar32 first_char = xtermXftFirstChar(fp); FcChar32 last_char = xtermXftLastChar(fp); FcChar32 ch; unsigned missing = 0; printf("Loaded XftFonts(%s[%s])\n", name, tag); for (ch = first_char; ch <= last_char; ++ch) { if (xtermXftMissing(xw, fp, ch)) { ++missing; } } printf("\t\tfirst char: %u\n", first_char); printf("\t\tlast char: %u\n", last_char); printf("\t\tmissing-chars: %u\n", missing); printf("\t\tpresent-chars: %u\n", (last_char - first_char) + 1 - missing); if (XftNameUnparse(match, buffer, (int) sizeof(buffer))) { char *target; char *source = buffer; while ((target = strtok(source, ":")) != 0) { printf("\t%s\n", target); source = 0; } } } } #else #define reportXftFonts(xw, result, name, tag, match) /* empty */ #endif /* OPT_REPORT_FONTS */ static XftFont * xtermOpenXft(XtermWidget xw, const char *name, XftPattern *pat, const char *tag) { TScreen *screen = TScreenOf(xw); Display *dpy = screen->display; XftResult status; XftFont *result = 0; if (pat != 0) { XftPattern *match = XftFontMatch(dpy, DefaultScreen(dpy), pat, &status); if (match != 0) { result = XftFontOpenPattern(dpy, match); if (result != 0) { TRACE(("...matched %s font\n", tag)); reportXftFonts(xw, result, name, tag, match); } else { TRACE(("...could did not open %s font\n", tag)); XftPatternDestroy(match); if (xw->misc.fontWarnings >= fwAlways) { TRACE(("OOPS cannot open %s font \"%s\"\n", tag, name)); cannotFont(xw, "open", tag, name); } } } else { TRACE(("...did not match %s font\n", tag)); if (xw->misc.fontWarnings >= fwResource) { TRACE(("OOPS: cannot match %s font \"%s\"\n", tag, name)); cannotFont(xw, "match", tag, name); } } } return result; } #endif #if OPT_RENDERFONT #if OPT_SHIFT_FONTS /* * Don't make a dependency on the math library for a single function. * (Newton Raphson). */ static double dimSquareRoot(double value) { double result = 0.0; if (value > 0.0) { int n; double older = value; for (n = 0; n < 10; ++n) { double delta = (older * older - value) / (2.0 * older); double newer = older - delta; older = newer; result = newer; if (delta > -0.001 && delta < 0.001) break; } } return result; } #endif /* * Given the Xft font metrics, determine the actual font size. This is used * for each font to ensure that normal, bold and italic fonts follow the same * rule. */ static void setRenderFontsize(TScreen *screen, VTwin *win, XftFont *font, const char *tag) { if (font != 0) { int width, height, ascent, descent; (void) screen; width = font->max_advance_width; height = font->height; ascent = font->ascent; descent = font->descent; if (height < ascent + descent) { TRACE(("...increase height from %d\n", height)); height = ascent + descent; } if (is_double_width_font_xft(screen->display, font)) { TRACE(("...reduced width from %d\n", width)); width >>= 1; } if (tag == 0) { SetFontWidth(screen, win, width); SetFontHeight(screen, win, height); win->f_ascent = ascent; win->f_descent = descent; TRACE(("setRenderFontsize result %dx%d (%d+%d)\n", width, height, ascent, descent)); } else if (win->f_width < width || win->f_height < height || win->f_ascent < ascent || win->f_descent < descent) { TRACE(("setRenderFontsize %s changed %dx%d (%d+%d) to %dx%d (%d+%d)\n", tag, win->f_width, win->f_height, win->f_ascent, win->f_descent, width, height, ascent, descent)); SetFontWidth(screen, win, width); SetFontHeight(screen, win, height); win->f_ascent = ascent; win->f_descent = descent; } else { TRACE(("setRenderFontsize %s unchanged\n", tag)); } } } #endif static void checkFontInfo(int value, const char *tag) { if (value == 0) { xtermWarning("Selected font has no non-zero %s for ISO-8859-1 encoding\n", tag); exit(1); } } #if OPT_RENDERFONT void xtermCloseXft(TScreen *screen, XTermXftFonts *pub) { if (pub->font != 0) { XftFontClose(screen->display, pub->font); pub->font = 0; } } /* * Get the faceName/faceDoublesize resource setting. */ String getFaceName(XtermWidget xw, Bool wideName GCC_UNUSED) { #if OPT_RENDERWIDE String result = (wideName ? FirstItemOf(xw->work.fonts.xft.list_w) : CurrentXftFont(xw)); #else String result = CurrentXftFont(xw); #endif return x_nonempty(result); } /* * If we change the faceName, we'll have to re-acquire all of the fonts that * are derived from it. */ void setFaceName(XtermWidget xw, const char *value) { TScreen *screen = TScreenOf(xw); Boolean changed = (Boolean) ((CurrentXftFont(xw) == 0) || strcmp(CurrentXftFont(xw), value)); if (changed) { int n; CurrentXftFont(xw) = x_strdup(value); for (n = 0; n < NMENUFONTS; ++n) { int e; xw->misc.face_size[n] = -1.0; for (e = 0; e < fMAX; ++e) { xtermCloseXft(screen, getMyXftFont(xw, e, n)); } } } } #endif /* * Compute useful values for the font/window sizes */ void xtermComputeFontInfo(XtermWidget xw, VTwin *win, XFontStruct *font, int sbwidth) { TScreen *screen = TScreenOf(xw); int i, j, width, height; #if OPT_RENDERFONT int fontnum = screen->menu_font_number; #endif #if OPT_RENDERFONT /* * xterm contains a lot of references to fonts, assuming they are fixed * size. This chunk of code overrides the actual font-selection (see * drawXtermText()), if the user has selected render-font. All of the * font-loading for fixed-fonts still goes on whether or not this chunk * overrides it. */ if (UsingRenderFont(xw) && fontnum >= 0) { String face_name = getFaceName(xw, False); XftFont *norm = screen->renderFontNorm[fontnum].font; XftFont *bold = screen->renderFontBold[fontnum].font; XftFont *ital = screen->renderFontItal[fontnum].font; #if OPT_RENDERWIDE XftFont *wnorm = screen->renderWideNorm[fontnum].font; XftFont *wbold = screen->renderWideBold[fontnum].font; XftFont *wital = screen->renderWideItal[fontnum].font; #endif if (norm == 0 && face_name) { XftPattern *pat; double face_size; TRACE(("xtermComputeFontInfo font %d: norm(face %s, size %.1f)\n", fontnum, face_name, xw->misc.face_size[fontnum])); fillInFaceSize(xw, fontnum); face_size = xw->misc.face_size[fontnum]; /* * By observation (there is no documentation), XftPatternBuild is * cumulative. Build the bold- and italic-patterns on top of the * normal pattern. */ #define NormXftPattern \ XFT_FAMILY, XftTypeString, "mono", \ XFT_SIZE, XftTypeDouble, face_size #define BoldXftPattern(norm) \ XFT_WEIGHT, XftTypeInteger, XFT_WEIGHT_BOLD, \ XFT_CHAR_WIDTH, XftTypeInteger, norm->max_advance_width #define ItalXftPattern(norm) \ XFT_SLANT, XftTypeInteger, XFT_SLANT_ITALIC, \ XFT_CHAR_WIDTH, XftTypeInteger, norm->max_advance_width #if OPT_WIDE_ATTRS #define HAVE_ITALICS 1 #define FIND_ITALICS ((pat = XftNameParse(face_name)) != 0) #elif OPT_ISO_COLORS #define HAVE_ITALICS 1 #define FIND_ITALICS (screen->italicULMode && (pat = XftNameParse(face_name)) != 0) #else #define HAVE_ITALICS 0 #endif if ((pat = XftNameParse(face_name)) != 0) { #define OPEN_XFT(tag) xtermOpenXft(xw, face_name, pat, tag) XftPatternBuild(pat, NormXftPattern, (void *) 0); norm = OPEN_XFT("normal"); if (norm != 0) { XftPatternBuild(pat, BoldXftPattern(norm), (void *) 0); bold = OPEN_XFT("bold"); #if HAVE_ITALICS if (FIND_ITALICS) { XftPatternBuild(pat, NormXftPattern, ItalXftPattern(norm), (void *) 0); ital = OPEN_XFT("italic"); } #endif #undef OPEN_XFT /* * FIXME: just assume that the corresponding font has no * graphics characters. */ if (screen->fnt_boxes) { screen->fnt_boxes = False; TRACE(("Xft opened - will %suse internal line-drawing characters\n", screen->fnt_boxes ? "not " : "")); } } XftPatternDestroy(pat); } CACHE_XFT(screen->renderFontNorm, norm); CACHE_XFT(screen->renderFontBold, bold); CACHE_XFT(screen->renderFontItal, ital); /* * See xtermXftDrawString(). */ #if OPT_RENDERWIDE if (norm != 0 && screen->wide_chars) { int char_width = norm->max_advance_width * 2; #ifdef FC_ASPECT double aspect = ((FirstItemOf(xw->work.fonts.xft.list_w) || screen->renderFontNorm[fontnum].map.mixed) ? 1.0 : 2.0); #endif face_name = getFaceName(xw, True); TRACE(("xtermComputeFontInfo wide(face %s, char_width %d)\n", NonNull(face_name), char_width)); #define WideXftPattern \ XFT_FAMILY, XftTypeString, "mono", \ XFT_SIZE, XftTypeDouble, face_size, \ XFT_SPACING, XftTypeInteger, XFT_MONO if (face_name && (pat = XftNameParse(face_name)) != 0) { #define OPEN_XFT(tag) xtermOpenXft(xw, face_name, pat, tag) XftPatternBuild(pat, WideXftPattern, XFT_CHAR_WIDTH, XftTypeInteger, char_width, #ifdef FC_ASPECT FC_ASPECT, XftTypeDouble, aspect, #endif (void *) 0); wnorm = OPEN_XFT("wide"); if (wnorm != 0) { XftPatternBuild(pat, WideXftPattern, BoldXftPattern(wnorm), (void *) 0); wbold = OPEN_XFT("wide-bold"); #if HAVE_ITALICS if (FIND_ITALICS) { XftPatternBuild(pat, WideXftPattern, ItalXftPattern(wnorm), (void *) 0); wital = OPEN_XFT("wide-italic"); } #endif #undef OPEN_XFT } XftPatternDestroy(pat); } CACHE_XFT(screen->renderWideNorm, wnorm); CACHE_XFT(screen->renderWideBold, wbold); CACHE_XFT(screen->renderWideItal, wital); } #endif /* OPT_RENDERWIDE */ } if (norm == 0) { TRACE(("...no TrueType font found for number %d, disable menu entry\n", fontnum)); xw->work.render_font = False; update_font_renderfont(); /* now we will fall through into the bitmap fonts */ } else { setRenderFontsize(screen, win, norm, NULL); setRenderFontsize(screen, win, bold, "bold"); setRenderFontsize(screen, win, ital, "ital"); #if OPT_BOX_CHARS setupPackedFonts(xw); if (screen->force_packed) { XTermXftFonts *use = &(screen->renderFontNorm[fontnum]); SetFontHeight(screen, win, use->font->ascent + use->font->descent); SetFontWidth(screen, win, use->map.min_width); TRACE(("...packed TrueType font %dx%d vs %d\n", win->f_height, win->f_width, use->map.max_width)); } #endif DUMP_XFT(xw, &(screen->renderFontNorm[fontnum])); } } /* * Are we handling a bitmap font? */ else #endif /* OPT_RENDERFONT */ { if (is_double_width_font(font) && !(screen->fnt_prop)) { SetFontWidth(screen, win, font->min_bounds.width); } else { SetFontWidth(screen, win, font->max_bounds.width); } SetFontHeight(screen, win, font->ascent + font->descent); win->f_ascent = font->ascent; win->f_descent = font->descent; } i = 2 * screen->border + sbwidth; j = 2 * screen->border; width = MaxCols(screen) * win->f_width + i; height = MaxRows(screen) * win->f_height + j; win->fullwidth = (Dimension) width; win->fullheight = (Dimension) height; win->width = width - i; win->height = height - j; TRACE(("xtermComputeFontInfo window %dx%d (full %dx%d), fontsize %dx%d (asc %d, dsc %d)\n", win->height, win->width, win->fullheight, win->fullwidth, win->f_height, win->f_width, win->f_ascent, win->f_descent)); checkFontInfo(win->f_height, "height"); checkFontInfo(win->f_width, "width"); } /* save this information as a side-effect for double-sized characters */ void xtermSaveFontInfo(TScreen *screen, XFontStruct *font) { screen->fnt_wide = (Dimension) (font->max_bounds.width); screen->fnt_high = (Dimension) (font->ascent + font->descent); TRACE(("xtermSaveFontInfo %dx%d\n", screen->fnt_high, screen->fnt_wide)); } /* * After loading a new font, update the structures that use its size. */ void xtermUpdateFontInfo(XtermWidget xw, Bool doresize) { TScreen *screen = TScreenOf(xw); int scrollbar_width; VTwin *win = &(screen->fullVwin); scrollbar_width = (xw->misc.scrollbar ? (screen->scrollWidget->core.width + BorderWidth(screen->scrollWidget)) : 0); xtermComputeFontInfo(xw, win, getNormalFont(screen, fNorm)->fs, scrollbar_width); xtermSaveFontInfo(screen, getNormalFont(screen, fNorm)->fs); if (doresize) { if (VWindow(screen)) { xtermClear(xw); } TRACE(("xtermUpdateFontInfo {{\n")); DoResizeScreen(xw); /* set to the new natural size */ ResizeScrollBar(xw); Redraw(); TRACE(("... }} xtermUpdateFontInfo\n")); #ifdef SCROLLBAR_RIGHT updateRightScrollbar(xw); #endif } xtermSetCursorBox(screen); } #if OPT_BOX_CHARS || OPT_REPORT_FONTS /* * Returns true if the given character is missing from the specified font. */ Bool xtermMissingChar(unsigned ch, XTermFonts * font) { Bool result = False; XFontStruct *fs = font->fs; XCharStruct *pc = 0; if (fs->max_byte1 == 0) { #if OPT_WIDE_CHARS if (ch < 256) #endif { CI_GET_CHAR_INFO_1D(fs, E2A(ch), pc); } } #if OPT_WIDE_CHARS else { unsigned row = (ch >> 8); unsigned col = (ch & 0xff); CI_GET_CHAR_INFO_2D(fs, row, col, pc); } #endif if (pc == 0 || CI_NONEXISTCHAR(pc)) { TRACE2(("xtermMissingChar %#04x (!exists), %d cells\n", ch, my_wcwidth((wchar_t) ch))); result = True; } if (ch < KNOWN_MISSING) { font->known_missing[ch] = (Char) (result ? 2 : 1); } return result; } #endif #if OPT_BOX_CHARS /* * The grid is arbitrary, enough resolution that nothing's lost in * initialization. */ #define BOX_HIGH 60 #define BOX_WIDE 60 #define MID_HIGH (BOX_HIGH/2) #define MID_WIDE (BOX_WIDE/2) #define CHR_WIDE ((9*BOX_WIDE)/10) #define CHR_HIGH ((9*BOX_HIGH)/10) /* * ...since we'll scale the values anyway. */ #define SCALED_X(n) ((int)(n) * (((int) font_width) - 1)) / (BOX_WIDE-1) #define SCALED_Y(n) ((int)(n) * (((int) font_height) - 1)) / (BOX_HIGH-1) #define SCALE_X(n) n = SCALED_X(n) #define SCALE_Y(n) n = SCALED_Y(n) #define SEG(x0,y0,x1,y1) x0,y0, x1,y1 /* * Draw the given graphic character, if it is simple enough (i.e., a * line-drawing character). */ void xtermDrawBoxChar(XtermWidget xw, unsigned ch, unsigned attr_flags, unsigned draw_flags, GC gc, int x, int y, int cells) { TScreen *screen = TScreenOf(xw); /* *INDENT-OFF* */ static const short glyph_ht[] = { SEG(1*BOX_WIDE/10, 0, 1*BOX_WIDE/10,5*MID_HIGH/6), /* H */ SEG(6*BOX_WIDE/10, 0, 6*BOX_WIDE/10,5*MID_HIGH/6), SEG(1*BOX_WIDE/10,5*MID_HIGH/12,6*BOX_WIDE/10,5*MID_HIGH/12), SEG(2*BOX_WIDE/10, MID_HIGH, CHR_WIDE, MID_HIGH), /* T */ SEG(6*BOX_WIDE/10, MID_HIGH, 6*BOX_WIDE/10, CHR_HIGH), -1 }, glyph_ff[] = { SEG(1*BOX_WIDE/10, 0, 6*BOX_WIDE/10, 0), /* F */ SEG(1*BOX_WIDE/10,5*MID_HIGH/12,6*CHR_WIDE/12,5*MID_HIGH/12), SEG(1*BOX_WIDE/10, 0, 0*BOX_WIDE/3, 5*MID_HIGH/6), SEG(1*BOX_WIDE/3, MID_HIGH, CHR_WIDE, MID_HIGH), /* F */ SEG(1*BOX_WIDE/3, 8*MID_HIGH/6,10*CHR_WIDE/12,8*MID_HIGH/6), SEG(1*BOX_WIDE/3, MID_HIGH, 1*BOX_WIDE/3, CHR_HIGH), -1 }, glyph_lf[] = { SEG(1*BOX_WIDE/10, 0, 1*BOX_WIDE/10,9*MID_HIGH/12), /* L */ SEG(1*BOX_WIDE/10,9*MID_HIGH/12,6*BOX_WIDE/10,9*MID_HIGH/12), SEG(1*BOX_WIDE/3, MID_HIGH, CHR_WIDE, MID_HIGH), /* F */ SEG(1*BOX_WIDE/3, 8*MID_HIGH/6,10*CHR_WIDE/12,8*MID_HIGH/6), SEG(1*BOX_WIDE/3, MID_HIGH, 1*BOX_WIDE/3, CHR_HIGH), -1 }, glyph_nl[] = { SEG(1*BOX_WIDE/10,5*MID_HIGH/6, 1*BOX_WIDE/10, 0), /* N */ SEG(1*BOX_WIDE/10, 0, 5*BOX_WIDE/6, 5*MID_HIGH/6), SEG(5*BOX_WIDE/6, 5*MID_HIGH/6, 5*BOX_WIDE/6, 0), SEG(1*BOX_WIDE/3, MID_HIGH, 1*BOX_WIDE/3, CHR_HIGH), /* L */ SEG(1*BOX_WIDE/3, CHR_HIGH, CHR_WIDE, CHR_HIGH), -1 }, glyph_vt[] = { SEG(1*BOX_WIDE/10, 0, 5*BOX_WIDE/12,5*MID_HIGH/6), /* V */ SEG(5*BOX_WIDE/12,5*MID_HIGH/6, 5*BOX_WIDE/6, 0), SEG(2*BOX_WIDE/10, MID_HIGH, CHR_WIDE, MID_HIGH), /* T */ SEG(6*BOX_WIDE/10, MID_HIGH, 6*BOX_WIDE/10, CHR_HIGH), -1 }, plus_or_minus[] = { SEG( 0, 5*BOX_HIGH/6, CHR_WIDE, 5*BOX_HIGH/6), SEG( MID_WIDE, 2*BOX_HIGH/6, MID_WIDE, 4*BOX_HIGH/6), SEG( 0, 3*BOX_HIGH/6, CHR_WIDE, 3*BOX_HIGH/6), -1 }, lower_right_corner[] = { SEG( 0, MID_HIGH, MID_WIDE, MID_HIGH), SEG( MID_WIDE, MID_HIGH, MID_WIDE, 0), -1 }, upper_right_corner[] = { SEG( 0, MID_HIGH, MID_WIDE, MID_HIGH), SEG( MID_WIDE, MID_HIGH, MID_WIDE, BOX_HIGH), -1 }, upper_left_corner[] = { SEG( MID_WIDE, MID_HIGH, BOX_WIDE, MID_HIGH), SEG( MID_WIDE, MID_HIGH, MID_WIDE, BOX_HIGH), -1 }, lower_left_corner[] = { SEG( MID_WIDE, 0, MID_WIDE, MID_HIGH), SEG( MID_WIDE, MID_WIDE, BOX_WIDE, MID_HIGH), -1 }, cross[] = { SEG( 0, MID_HIGH, BOX_WIDE, MID_HIGH), SEG( MID_WIDE, 0, MID_WIDE, BOX_HIGH), -1 }, scan_line_1[] = { SEG( 0, 0, BOX_WIDE, 0), -1 }, scan_line_3[] = { SEG( 0, BOX_HIGH/4, BOX_WIDE, BOX_HIGH/4), -1 }, scan_line_7[] = { SEG( 0, MID_HIGH, BOX_WIDE, MID_HIGH), -1 }, scan_line_9[] = { SEG( 0, 3*BOX_HIGH/4, BOX_WIDE, 3*BOX_HIGH/4), -1 }, horizontal_line[] = { SEG( 0, BOX_HIGH, BOX_WIDE, BOX_HIGH), -1 }, left_tee[] = { SEG( MID_WIDE, 0, MID_WIDE, BOX_HIGH), SEG( MID_WIDE, MID_HIGH, BOX_WIDE, MID_HIGH), -1 }, right_tee[] = { SEG( MID_WIDE, 0, MID_WIDE, BOX_HIGH), SEG( MID_WIDE, MID_HIGH, 0, MID_HIGH), -1 }, bottom_tee[] = { SEG( 0, MID_HIGH, BOX_WIDE, MID_HIGH), SEG( MID_WIDE, 0, MID_WIDE, MID_HIGH), -1 }, top_tee[] = { SEG( 0, MID_HIGH, BOX_WIDE, MID_HIGH), SEG( MID_WIDE, MID_HIGH, MID_WIDE, BOX_HIGH), -1 }, vertical_line[] = { SEG( MID_WIDE, 0, MID_WIDE, BOX_HIGH), -1 }, less_than_or_equal[] = { SEG( CHR_WIDE, BOX_HIGH/3, 0, MID_HIGH), SEG( CHR_WIDE, 2*BOX_HIGH/3, 0, MID_HIGH), SEG( 0, 3*BOX_HIGH/4, CHR_WIDE, 3*BOX_HIGH/4), -1 }, greater_than_or_equal[] = { SEG( 0, BOX_HIGH/3, CHR_WIDE, MID_HIGH), SEG( 0, 2*BOX_HIGH/3, CHR_WIDE, MID_HIGH), SEG( 0, 3*BOX_HIGH/4, CHR_WIDE, 3*BOX_HIGH/4), -1 }, greek_pi[] = { SEG( 0, MID_HIGH, CHR_WIDE, MID_HIGH), SEG(5*CHR_WIDE/6, MID_HIGH, 5*CHR_WIDE/6, CHR_HIGH), SEG(2*CHR_WIDE/6, MID_HIGH, 2*CHR_WIDE/6, CHR_HIGH), -1 }, not_equal_to[] = { SEG(2*BOX_WIDE/3, 1*BOX_HIGH/3, 1*BOX_WIDE/3, CHR_HIGH), SEG( 0, 2*BOX_HIGH/3, CHR_WIDE, 2*BOX_HIGH/3), SEG( 0, MID_HIGH, CHR_WIDE, MID_HIGH), -1 }; /* *INDENT-ON* */ static const short *lines[] = { 0, /* 00 (unused) */ 0, /* 01 diamond */ 0, /* 02 box */ glyph_ht, /* 03 HT */ glyph_ff, /* 04 FF */ 0, /* 05 CR */ glyph_lf, /* 06 LF */ 0, /* 07 degrees (small circle) */ plus_or_minus, /* 08 */ glyph_nl, /* 09 */ glyph_vt, /* 0A */ lower_right_corner, /* 0B */ upper_right_corner, /* 0C */ upper_left_corner, /* 0D */ lower_left_corner, /* 0E */ cross, /* 0F */ scan_line_1, /* 10 */ scan_line_3, /* 11 */ scan_line_7, /* 12 */ scan_line_9, /* 13 */ horizontal_line, /* 14 */ left_tee, /* 15 */ right_tee, /* 16 */ bottom_tee, /* 17 */ top_tee, /* 18 */ vertical_line, /* 19 */ less_than_or_equal, /* 1A */ greater_than_or_equal, /* 1B */ greek_pi, /* 1C */ not_equal_to, /* 1D */ 0, /* 1E LB */ 0, /* 1F bullet */ }; GC gc2; CgsEnum cgsId = (ch == 2) ? gcDots : gcLine; VTwin *cgsWin = WhichVWin(screen); const short *p; unsigned font_width = (unsigned) (((draw_flags & DOUBLEWFONT) ? 2 : 1) * screen->fnt_wide); unsigned font_height = (unsigned) (((draw_flags & DOUBLEHFONT) ? 2 : 1) * screen->fnt_high); if (cells > 1) font_width *= (unsigned) cells; #if OPT_WIDE_CHARS /* * Try to show line-drawing characters if we happen to be in UTF-8 * mode, but have gotten an old-style font. */ if (screen->utf8_mode #if OPT_RENDERFONT && !UsingRenderFont(xw) #endif && (ch > 127) && (ch != UCS_REPL)) { unsigned n; for (n = 1; n < 32; n++) { if (dec2ucs(n) == ch && !((attr_flags & BOLD) ? IsXtermMissingChar(screen, n, getNormalFont(screen, fBold)) : IsXtermMissingChar(screen, n, getNormalFont(screen, fNorm)))) { TRACE(("...use xterm-style linedrawing\n")); ch = n; break; } } } #endif TRACE(("DRAW_BOX(%d) cell %dx%d at %d,%d%s\n", ch, font_height, font_width, y, x, (ch >= (sizeof(lines) / sizeof(lines[0])) ? "-BAD" : ""))); if (cgsId == gcDots) { setCgsFont(xw, cgsWin, cgsId, getCgsFont(xw, cgsWin, gc)); setCgsFore(xw, cgsWin, cgsId, getCgsFore(xw, cgsWin, gc)); setCgsBack(xw, cgsWin, cgsId, getCgsBack(xw, cgsWin, gc)); } else { setCgsFont(xw, cgsWin, cgsId, getCgsFont(xw, cgsWin, gc)); setCgsFore(xw, cgsWin, cgsId, getCgsBack(xw, cgsWin, gc)); setCgsBack(xw, cgsWin, cgsId, getCgsBack(xw, cgsWin, gc)); } gc2 = getCgsGC(xw, cgsWin, cgsId); if (!(draw_flags & NOBACKGROUND)) { XFillRectangle(screen->display, VDrawable(screen), gc2, x, y, font_width, font_height); } setCgsFont(xw, cgsWin, cgsId, getCgsFont(xw, cgsWin, gc)); setCgsFore(xw, cgsWin, cgsId, getCgsFore(xw, cgsWin, gc)); setCgsBack(xw, cgsWin, cgsId, getCgsBack(xw, cgsWin, gc)); gc2 = getCgsGC(xw, cgsWin, cgsId); XSetLineAttributes(screen->display, gc2, (attr_flags & BOLD) ? ((font_height > 12) ? font_height / 12 : 1) : ((font_height > 16) ? font_height / 16 : 1), LineSolid, CapProjecting, JoinMiter); if (ch == 1) { /* diamond */ XPoint points[5]; int npoints = 5, n; points[0].x = MID_WIDE; points[0].y = BOX_HIGH / 4; points[1].x = 8 * BOX_WIDE / 8; points[1].y = MID_HIGH; points[2].x = points[0].x; points[2].y = 3 * BOX_HIGH / 4; points[3].x = 0 * BOX_WIDE / 8; points[3].y = points[1].y; points[4].x = points[0].x; points[4].y = points[0].y; for (n = 0; n < npoints; ++n) { points[n].x = (short) SCALED_X(points[n].x); points[n].y = (short) SCALED_Y(points[n].y); points[n].x = (short) (points[n].x + x); points[n].y = (short) (points[n].y + y); } XFillPolygon(screen->display, VDrawable(screen), gc2, points, npoints, Convex, CoordModeOrigin); } else if (ch == 7) { /* degrees */ unsigned width = (BOX_WIDE / 3); int x_coord = MID_WIDE - (int) (width / 2); int y_coord = MID_HIGH - (int) width; SCALE_X(x_coord); SCALE_Y(y_coord); width = (unsigned) SCALED_X(width); XDrawArc(screen->display, VDrawable(screen), gc2, x + x_coord, y + y_coord, width, width, 0, 360 * 64); } else if (ch == 0x1f) { /* bullet */ unsigned width = 7 * BOX_WIDE / 10; int x_coord = MID_WIDE - (int) (width / 3); int y_coord = MID_HIGH - (int) (width / 3); SCALE_X(x_coord); SCALE_Y(y_coord); width = (unsigned) SCALED_X(width); XDrawArc(screen->display, VDrawable(screen), gc2, x + x_coord, y + y_coord, width, width, 0, 360 * 64); } else if (ch < (sizeof(lines) / sizeof(lines[0])) && (p = lines[ch]) != 0) { int coord[4]; int n = 0; while (*p >= 0) { coord[n++] = *p++; if (n == 4) { SCALE_X(coord[0]); SCALE_Y(coord[1]); SCALE_X(coord[2]); SCALE_Y(coord[3]); XDrawLine(screen->display, VDrawable(screen), gc2, x + coord[0], y + coord[1], x + coord[2], y + coord[3]); n = 0; } } } else if (screen->force_all_chars) { /* bounding rectangle, for debugging */ XDrawRectangle(screen->display, VDrawable(screen), gc2, x, y, font_width - 1, font_height - 1); } } #endif /* OPT_BOX_CHARS */ #if OPT_RENDERFONT /* * Check if the given character has a glyph known to Xft. * * see xc/lib/Xft/xftglyphs.c */ Bool xtermXftMissing(XtermWidget xw, XftFont *font, unsigned wc) { Bool result = False; if (font != 0) { TScreen *screen = TScreenOf(xw); if (!XftGlyphExists(screen->display, font, wc)) { #if OPT_WIDE_CHARS TRACE2(("xtermXftMissing %d (dec=%#x, ucs=%#x)\n", wc, ucs2dec(wc), dec2ucs(wc))); #else TRACE2(("xtermXftMissing %d\n", wc)); #endif result = True; } } return result; } #endif /* OPT_RENDERFONT */ #if OPT_WIDE_CHARS #define MY_UCS(ucs,dec) case ucs: result = dec; break unsigned ucs2dec(unsigned ch) { unsigned result = ch; if ((ch > 127) && (ch != UCS_REPL)) { switch (ch) { MY_UCS(0x25ae, 0); /* black vertical rectangle */ MY_UCS(0x25c6, 1); /* black diamond */ MY_UCS(0x2592, 2); /* medium shade */ MY_UCS(0x2409, 3); /* symbol for horizontal tabulation */ MY_UCS(0x240c, 4); /* symbol for form feed */ MY_UCS(0x240d, 5); /* symbol for carriage return */ MY_UCS(0x240a, 6); /* symbol for line feed */ MY_UCS(0x00b0, 7); /* degree sign */ MY_UCS(0x00b1, 8); /* plus-minus sign */ MY_UCS(0x2424, 9); /* symbol for newline */ MY_UCS(0x240b, 10); /* symbol for vertical tabulation */ MY_UCS(0x2518, 11); /* box drawings light up and left */ MY_UCS(0x2510, 12); /* box drawings light down and left */ MY_UCS(0x250c, 13); /* box drawings light down and right */ MY_UCS(0x2514, 14); /* box drawings light up and right */ MY_UCS(0x253c, 15); /* box drawings light vertical and horizontal */ MY_UCS(0x23ba, 16); /* box drawings scan 1 */ MY_UCS(0x23bb, 17); /* box drawings scan 3 */ MY_UCS(0x2500, 18); /* box drawings light horizontal */ MY_UCS(0x23bc, 19); /* box drawings scan 7 */ MY_UCS(0x23bd, 20); /* box drawings scan 9 */ MY_UCS(0x251c, 21); /* box drawings light vertical and right */ MY_UCS(0x2524, 22); /* box drawings light vertical and left */ MY_UCS(0x2534, 23); /* box drawings light up and horizontal */ MY_UCS(0x252c, 24); /* box drawings light down and horizontal */ MY_UCS(0x2502, 25); /* box drawings light vertical */ MY_UCS(0x2264, 26); /* less-than or equal to */ MY_UCS(0x2265, 27); /* greater-than or equal to */ MY_UCS(0x03c0, 28); /* greek small letter pi */ MY_UCS(0x2260, 29); /* not equal to */ MY_UCS(0x00a3, 30); /* pound sign */ MY_UCS(0x00b7, 31); /* middle dot */ } } return result; } #undef MY_UCS #define MY_UCS(ucs,dec) case dec: result = ucs; break unsigned dec2ucs(unsigned ch) { unsigned result = ch; if (xtermIsDecGraphic(ch)) { switch (ch) { MY_UCS(0x25ae, 0); /* black vertical rectangle */ MY_UCS(0x25c6, 1); /* black diamond */ MY_UCS(0x2592, 2); /* medium shade */ MY_UCS(0x2409, 3); /* symbol for horizontal tabulation */ MY_UCS(0x240c, 4); /* symbol for form feed */ MY_UCS(0x240d, 5); /* symbol for carriage return */ MY_UCS(0x240a, 6); /* symbol for line feed */ MY_UCS(0x00b0, 7); /* degree sign */ MY_UCS(0x00b1, 8); /* plus-minus sign */ MY_UCS(0x2424, 9); /* symbol for newline */ MY_UCS(0x240b, 10); /* symbol for vertical tabulation */ MY_UCS(0x2518, 11); /* box drawings light up and left */ MY_UCS(0x2510, 12); /* box drawings light down and left */ MY_UCS(0x250c, 13); /* box drawings light down and right */ MY_UCS(0x2514, 14); /* box drawings light up and right */ MY_UCS(0x253c, 15); /* box drawings light vertical and horizontal */ MY_UCS(0x23ba, 16); /* box drawings scan 1 */ MY_UCS(0x23bb, 17); /* box drawings scan 3 */ MY_UCS(0x2500, 18); /* box drawings light horizontal */ MY_UCS(0x23bc, 19); /* box drawings scan 7 */ MY_UCS(0x23bd, 20); /* box drawings scan 9 */ MY_UCS(0x251c, 21); /* box drawings light vertical and right */ MY_UCS(0x2524, 22); /* box drawings light vertical and left */ MY_UCS(0x2534, 23); /* box drawings light up and horizontal */ MY_UCS(0x252c, 24); /* box drawings light down and horizontal */ MY_UCS(0x2502, 25); /* box drawings light vertical */ MY_UCS(0x2264, 26); /* less-than or equal to */ MY_UCS(0x2265, 27); /* greater-than or equal to */ MY_UCS(0x03c0, 28); /* greek small letter pi */ MY_UCS(0x2260, 29); /* not equal to */ MY_UCS(0x00a3, 30); /* pound sign */ MY_UCS(0x00b7, 31); /* middle dot */ } } return result; } #endif /* OPT_WIDE_CHARS */ #if OPT_RENDERFONT || OPT_SHIFT_FONTS static int lookupOneFontSize(XtermWidget xw, int fontnum) { TScreen *screen = TScreenOf(xw); if (screen->menu_font_sizes[fontnum] == 0) { XTermFonts fnt; memset(&fnt, 0, sizeof(fnt)); screen->menu_font_sizes[fontnum] = -1; if (xtermOpenFont(xw, screen->MenuFontName(fontnum), &fnt, True)) { if (fontnum <= fontMenu_lastBuiltin || strcmp(fnt.fn, DEFFONT)) { screen->menu_font_sizes[fontnum] = FontSize(fnt.fs); if (screen->menu_font_sizes[fontnum] <= 0) screen->menu_font_sizes[fontnum] = -1; } xtermCloseFont(xw, &fnt); } } return (screen->menu_font_sizes[fontnum] > 0); } /* * Cache the font-sizes so subsequent larger/smaller font actions will go fast. */ static void lookupFontSizes(XtermWidget xw) { int n; for (n = 0; n < NMENUFONTS; n++) { (void) lookupOneFontSize(xw, n); } } #endif /* OPT_RENDERFONT || OPT_SHIFT_FONTS */ #if OPT_RENDERFONT static double defaultFaceSize(void) { double result; float value; if (sscanf(DEFFACESIZE, "%f", &value) == 1) result = value; else result = 14.0; return result; } static void fillInFaceSize(XtermWidget xw, int fontnum) { TScreen *screen = TScreenOf(xw); double face_size = xw->misc.face_size[fontnum]; if (face_size <= 0.0) { #if OPT_SHIFT_FONTS /* * If the user is switching font-sizes, make it follow by * default the same ratios to the default as the fixed fonts * would, for easy comparison. There will be some differences * since the fixed fonts have a variety of height/width ratios, * but this is simpler than adding another resource value - and * as noted above, the data for the fixed fonts are available. */ (void) lookupOneFontSize(xw, 0); if (fontnum == fontMenu_default) { face_size = defaultFaceSize(); } else if (lookupOneFontSize(xw, fontnum) && (screen->menu_font_sizes[0] != screen->menu_font_sizes[fontnum])) { double ratio; long num = screen->menu_font_sizes[fontnum]; long den = screen->menu_font_sizes[0]; if (den <= 0) den = 1; ratio = dimSquareRoot((double) num / (double) den); face_size = (ratio * xw->misc.face_size[0]); TRACE(("scaled[%d] using %3ld/%ld = %.2f -> %f\n", fontnum, num, den, ratio, face_size)); } else #endif { #define LikeBitmap(s) (((s) / 78.0) * xw->misc.face_size[fontMenu_default]) switch (fontnum) { case fontMenu_font1: face_size = LikeBitmap(2.0); break; case fontMenu_font2: face_size = LikeBitmap(35.0); break; case fontMenu_font3: face_size = LikeBitmap(60.0); break; default: face_size = defaultFaceSize(); break; case fontMenu_font4: face_size = LikeBitmap(90.0); break; case fontMenu_font5: face_size = LikeBitmap(135.0); break; case fontMenu_font6: face_size = LikeBitmap(200.0); break; } TRACE(("builtin[%d] -> %f\n", fontnum, face_size)); } xw->misc.face_size[fontnum] = (float) face_size; } } /* no selection or escape */ #define NMENU_RENDERFONTS (fontMenu_lastBuiltin + 1) /* * Workaround for breakage in font-packages - check if all of the bitmap font * sizes are the same, and if we're using TrueType fonts. */ static Boolean useFaceSizes(XtermWidget xw) { Boolean result = False; TRACE(("useFaceSizes {{\n")); if (UsingRenderFont(xw)) { Boolean nonzero = True; int n; for (n = 0; n < NMENU_RENDERFONTS; ++n) { if (xw->misc.face_size[n] <= 0.0) { nonzero = False; break; } } if (!nonzero) { Boolean broken_fonts = True; TScreen *screen = TScreenOf(xw); long first; lookupFontSizes(xw); first = screen->menu_font_sizes[0]; for (n = 0; n < NMENUFONTS; n++) { if (screen->menu_font_sizes[n] > 0 && screen->menu_font_sizes[n] != first) { broken_fonts = False; break; } } if (broken_fonts) { TRACE(("bitmap fonts are broken - set faceSize resources\n")); for (n = 0; n < NMENUFONTS; n++) { fillInFaceSize(xw, n); } } } result = True; } TRACE(("...}}useFaceSizes %d\n", result)); return result; } #endif /* OPT_RENDERFONT */ #if OPT_SHIFT_FONTS /* * Find the index of a larger/smaller font (according to the sign of 'relative' * and its magnitude), starting from the 'old' index. */ int lookupRelativeFontSize(XtermWidget xw, int old, int relative) { TScreen *screen = TScreenOf(xw); int m = -1; TRACE(("lookupRelativeFontSize(old=%d, relative=%d)\n", old, relative)); if (!IsIcon(screen)) { #if OPT_RENDERFONT if (useFaceSizes(xw)) { TRACE(("...using FaceSize\n")); if (relative != 0) { int n; for (n = 0; n < NMENU_RENDERFONTS; ++n) { fillInFaceSize(xw, n); if (xw->misc.face_size[n] > 0 && xw->misc.face_size[n] != xw->misc.face_size[old]) { int cmp_0 = ((xw->misc.face_size[n] > xw->misc.face_size[old]) ? relative : -relative); int cmp_m = ((m < 0) ? 1 : ((xw->misc.face_size[n] < xw->misc.face_size[m]) ? relative : -relative)); if (cmp_0 > 0 && cmp_m > 0) { m = n; } } } } } else #endif { TRACE(("...using bitmap areas\n")); lookupFontSizes(xw); if (relative != 0) { int n; for (n = 0; n < NMENUFONTS; ++n) { if (screen->menu_font_sizes[n] > 0 && screen->menu_font_sizes[n] != screen->menu_font_sizes[old]) { int cmp_0 = ((screen->menu_font_sizes[n] > screen->menu_font_sizes[old]) ? relative : -relative); int cmp_m = ((m < 0) ? 1 : ((screen->menu_font_sizes[n] < screen->menu_font_sizes[m]) ? relative : -relative)); if (cmp_0 > 0 && cmp_m > 0) { m = n; } } } } } TRACE(("...new index %d\n", m)); if (m >= 0) { if (relative > 1) m = lookupRelativeFontSize(xw, m, relative - 1); else if (relative < -1) m = lookupRelativeFontSize(xw, m, relative + 1); } } return m; } /* ARGSUSED */ void HandleLargerFont(Widget w GCC_UNUSED, XEvent *event GCC_UNUSED, String *params GCC_UNUSED, Cardinal *param_count GCC_UNUSED) { XtermWidget xw; TRACE(("Handle larger-vt-font for %p\n", (void *) w)); if ((xw = getXtermWidget(w)) != 0) { if (xw->misc.shift_fonts) { TScreen *screen = TScreenOf(xw); int m; m = lookupRelativeFontSize(xw, screen->menu_font_number, 1); if (m >= 0) { SetVTFont(xw, m, True, NULL); } else { Bell(xw, XkbBI_MinorError, 0); } } } } /* ARGSUSED */ void HandleSmallerFont(Widget w GCC_UNUSED, XEvent *event GCC_UNUSED, String *params GCC_UNUSED, Cardinal *param_count GCC_UNUSED) { XtermWidget xw; TRACE(("Handle smaller-vt-font for %p\n", (void *) w)); if ((xw = getXtermWidget(w)) != 0) { if (xw->misc.shift_fonts) { TScreen *screen = TScreenOf(xw); int m; m = lookupRelativeFontSize(xw, screen->menu_font_number, -1); if (m >= 0) { SetVTFont(xw, m, True, NULL); } else { Bell(xw, XkbBI_MinorError, 0); } } } } #endif /* OPT_SHIFT_FONTS */ int xtermGetFont(const char *param) { int fontnum; switch (param[0]) { case 'd': case 'D': case '0': fontnum = fontMenu_default; break; case '1': fontnum = fontMenu_font1; break; case '2': fontnum = fontMenu_font2; break; case '3': fontnum = fontMenu_font3; break; case '4': fontnum = fontMenu_font4; break; case '5': fontnum = fontMenu_font5; break; case '6': fontnum = fontMenu_font6; break; case 'e': case 'E': fontnum = fontMenu_fontescape; break; case 's': case 'S': fontnum = fontMenu_fontsel; break; default: fontnum = -1; break; } return fontnum; } /* ARGSUSED */ void HandleSetFont(Widget w GCC_UNUSED, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { XtermWidget xw; if ((xw = getXtermWidget(w)) != 0) { int fontnum; VTFontNames fonts; memset(&fonts, 0, sizeof(fonts)); if (*param_count == 0) { fontnum = fontMenu_default; } else { Cardinal maxparams = 1; /* total number of params allowed */ int result = xtermGetFont(params[0]); switch (result) { case fontMenu_default: /* FALLTHRU */ case fontMenu_font1: /* FALLTHRU */ case fontMenu_font2: /* FALLTHRU */ case fontMenu_font3: /* FALLTHRU */ case fontMenu_font4: /* FALLTHRU */ case fontMenu_font5: /* FALLTHRU */ case fontMenu_font6: /* FALLTHRU */ break; case fontMenu_fontescape: #if OPT_WIDE_CHARS maxparams = 5; #else maxparams = 3; #endif break; case fontMenu_fontsel: maxparams = 2; break; default: Bell(xw, XkbBI_MinorError, 0); return; } fontnum = result; if (*param_count > maxparams) { /* see if extra args given */ Bell(xw, XkbBI_MinorError, 0); return; } switch (*param_count) { /* assign 'em */ #if OPT_WIDE_CHARS case 5: fonts.f_wb = x_strdup(params[4]); /* FALLTHRU */ case 4: fonts.f_w = x_strdup(params[3]); #endif /* FALLTHRU */ case 3: fonts.f_b = x_strdup(params[2]); /* FALLTHRU */ case 2: fonts.f_n = x_strdup(params[1]); break; } } SetVTFont(xw, fontnum, True, &fonts); } } void SetVTFont(XtermWidget xw, int which, Bool doresize, const VTFontNames * fonts) { TScreen *screen = TScreenOf(xw); TRACE(("SetVTFont(which=%d, f_n=%s, f_b=%s)\n", which, (fonts && fonts->f_n) ? fonts->f_n : "", (fonts && fonts->f_b) ? fonts->f_b : "")); if (IsIcon(screen)) { Bell(xw, XkbBI_MinorError, 0); } else if (which >= 0 && which < NMENUFONTS) { VTFontNames myfonts; memset(&myfonts, 0, sizeof(myfonts)); if (fonts != 0) myfonts = *fonts; if (which == fontMenu_fontsel) { /* go get the selection */ FindFontSelection(xw, myfonts.f_n, False); } else { int oldFont = screen->menu_font_number; #define USE_CACHED(field, name) \ if (myfonts.field == 0) { \ myfonts.field = x_strdup(screen->menu_font_names[which][name]); \ TRACE(("set myfonts." #field " from menu_font_names[%d][" #name "] %s\n", \ which, NonNull(myfonts.field))); \ } else { \ TRACE(("set myfonts." #field " reused\n")); \ } #define SAVE_FNAME(field, name) \ if (myfonts.field != 0) { \ if (screen->menu_font_names[which][name] == 0 \ || strcmp(screen->menu_font_names[which][name], myfonts.field)) { \ TRACE(("updating menu_font_names[%d][" #name "] to %s\n", \ which, myfonts.field)); \ FREE_STRING(screen->menu_font_names[which][name]); \ screen->menu_font_names[which][name] = x_strdup(myfonts.field); \ } \ } USE_CACHED(f_n, fNorm); USE_CACHED(f_b, fBold); #if OPT_WIDE_CHARS USE_CACHED(f_w, fWide); USE_CACHED(f_wb, fWBold); #endif if (xtermLoadFont(xw, &myfonts, doresize, which)) { /* * If successful, save the data so that a subsequent query via * OSC-50 will return the expected values. */ SAVE_FNAME(f_n, fNorm); SAVE_FNAME(f_b, fBold); #if OPT_WIDE_CHARS SAVE_FNAME(f_w, fWide); SAVE_FNAME(f_wb, fWBold); #endif } else { (void) xtermLoadFont(xw, xtermFontName(screen->MenuFontName(oldFont)), doresize, oldFont); Bell(xw, XkbBI_MinorError, 0); } FREE_FNAME(f_n); FREE_FNAME(f_b); #if OPT_WIDE_CHARS FREE_FNAME(f_w); FREE_FNAME(f_wb); #endif } } else { Bell(xw, XkbBI_MinorError, 0); } return; } #if OPT_RENDERFONT static void trimSizeFromFace(char *face_name, float *face_size) { char *first = strstr(face_name, ":size="); if (first == 0) { first = face_name; } else { first++; } if (!strncmp(first, "size=", (size_t) 5)) { char *last = strchr(first, ':'); char mark; float value; char extra; TRACE(("...before trimming, font = \"%s\"\n", face_name)); if (last == 0) last = first + strlen(first); mark = *last; *last = '\0'; if (sscanf(first, "size=%g%c", &value, &extra) == 1) { TRACE(("...trimmed size from font: %g\n", value)); if (face_size != 0) *face_size = value; } if (mark) { while ((*first++ = *++last) != '\0') { ; } } else { if (first != face_name) --first; *first = '\0'; } TRACE(("...after trimming, font = \"%s\"\n", face_name)); } } #endif /* * Save a font specification to the proper list. */ static void save2FontList(XtermWidget xw, const char *name, XtermFontNames * fontnames, VTFontEnum which, const char *source, Bool ttf) { char *value; size_t plen; Bool marked = False; Bool use_ttf = ttf; (void) xw; if (source == 0) source = ""; while (isspace(CharOf(*source))) ++source; /* fontconfig patterns can contain ':' separators, but we'll treat * a leading prefix specially to denote whether the pattern might be * XLFD ("x" or "xlfd") versus Xft ("xft"). */ for (plen = 0; source[plen] != '\0'; ++plen) { if (source[plen] == ':') { marked = True; switch (plen) { case 0: ++plen; /* trim leading ':' */ break; case 1: if (!strncmp(source, "x", plen)) { ++plen; use_ttf = False; } else { marked = False; } break; case 3: if (!strncmp(source, "xft", plen)) { ++plen; use_ttf = True; } else { marked = False; } break; case 4: if (!strncmp(source, "xlfd", plen)) { ++plen; use_ttf = False; } else { marked = False; } break; default: marked = False; plen = 0; break; } break; } } if (!marked) plen = 0; value = x_strtrim(source + plen); if (value != 0) { Bool success = False; #if OPT_RENDERFONT VTFontList *target = (use_ttf ? &(fontnames->xft) : &(fontnames->x11)); #else VTFontList *target = &(fontnames->x11); #endif char ***list = 0; char **next = 0; size_t count = 0; (void) use_ttf; switch (which) { case fNorm: list = &(target->list_n); break; case fBold: list = &(target->list_b); break; #if OPT_WIDE_ATTRS || OPT_RENDERWIDE case fItal: list = &(target->list_i); break; #endif #if OPT_WIDE_CHARS case fWide: list = &(target->list_w); break; case fWBold: list = &(target->list_wb); break; case fWItal: list = &(target->list_wi); break; #endif case fMAX: list = 0; break; } if (list != 0) { success = True; if (*list != 0) { while ((*list)[count] != 0) { if (IsEmpty((*list)[count])) { TRACE(("... initial %s\n", value)); free((*list)[count]); break; } else if (!strcmp(value, (*list)[count])) { TRACE(("... duplicate %s\n", value)); success = False; break; } ++count; } } if (success) { next = realloc(*list, sizeof(char *) * (count + 2)); if (next != 0) { #if OPT_RENDERFONT if (use_ttf) { trimSizeFromFace(value, (count == 0 && which == fNorm) ? &(xw->misc.face_size[0]) : (float *) 0); } #endif next[count++] = value; next[count] = 0; *list = next; TRACE(("... saved %s %s %lu:%s\n", whichFontList(xw, target), whichFontList2(xw, *list), (unsigned long) count, value)); } else { fprintf(stderr, "realloc failure in save2FontList(%s)\n", name); freeFontList(list); success = False; } } } if (success) { size_t limit = use_ttf ? MAX_XFT_FONTS : MAX_XLFD_FONTS; if (count > limit && !IsEmpty(value)) { fprintf(stderr, "%s: too many fonts for %s, ignoring %s\n", ProgramName, whichFontEnum(which), value); if (list && *list) { free((*list)[limit]); (*list)[limit] = 0; } } } else { free(value); } } } /* * In principle, any of the font-name resources could be extended to be a list * of font-names. That would be bad for performance, but as a basis for an * extension, parse the font-name as a comma-separated list, creating/updating * an array of font-names. */ void allocFontList(XtermWidget xw, const char *name, XtermFontNames * target, VTFontEnum which, const char *source, Bool ttf) { char *blob; blob = x_strdup(source); if (!IsEmpty(blob)) { int n; int pass; char **list = 0; TRACE(("allocFontList %s %s '%s'\n", whichFontEnum(which), name, blob)); for (pass = 0; pass < 2; ++pass) { unsigned count = 0; if (pass) list[0] = blob; for (n = 0; blob[n] != '\0'; ++n) { if (blob[n] == ',') { ++count; if (pass != 0) { blob[n] = '\0'; list[count] = blob + n + 1; } } } if (!pass) { if (count == 0 && *blob == '\0') break; list = TypeCallocN(char *, count + 2); if (list == 0) break; } } if (list) { for (n = 0; list[n] != 0; ++n) { if (*list[n]) { save2FontList(xw, name, target, which, list[n], ttf); } } free(list); } } free(blob); } static void initFontList(XtermWidget xw, const char *name, XtermFontNames * target, Bool ttf) { int which; TRACE(("initFontList(%s)\n", name)); for (which = 0; which < fMAX; ++which) { save2FontList(xw, name, target, (VTFontEnum) which, "", ttf); } } void initFontLists(XtermWidget xw) { TRACE(("initFontLists\n")); initFontList(xw, "x11 font", &(xw->work.fonts), False); #if OPT_RENDERFONT initFontList(xw, "xft font", &(xw->work.fonts), True); #endif #if OPT_LOAD_VTFONTS || OPT_WIDE_CHARS initFontList(xw, "cached font", &(xw->screen.cacheVTFonts.fonts), False); #endif } void copyFontList(char ***targetp, char **source) { freeFontList(targetp); if (source != 0) { int pass; size_t count; for (pass = 0; pass < 2; ++pass) { for (count = 0; source[count] != 0; ++count) { if (pass) (*targetp)[count] = x_strdup(source[count]); } if (!pass) { ++count; *targetp = TypeCallocN(char *, count); } } } else { *targetp = TypeCallocN(char *, 2); (*targetp)[0] = x_strdup(""); } } #if OPT_LOAD_VTFONTS || OPT_WIDE_CHARS static Boolean merge_sublist(char ***targetp, char **source) { Boolean result = False; if ((*targetp == 0 || IsEmpty(**targetp)) && !IsEmpty(*source)) { copyFontList(targetp, source); result = True; } return result; } #endif void freeFontList(char ***targetp) { if (targetp != 0) { char **target = *targetp; if (target != 0) { int n; for (n = 0; target[n] != 0; ++n) { free(target[n]); } free(target); *targetp = 0; } } } void freeFontLists(VTFontList * lists) { int which; TRACE(("freeFontLists\n")); for (which = 0; which < fMAX; ++which) { char ***target = 0; switch (which) { case fNorm: target = &(lists->list_n); break; case fBold: target = &(lists->list_b); break; #if OPT_WIDE_ATTRS || OPT_RENDERWIDE case fItal: target = &(lists->list_i); break; #endif #if OPT_WIDE_CHARS case fWide: target = &(lists->list_w); break; case fWBold: target = &(lists->list_wb); break; case fWItal: target = &(lists->list_wi); break; #endif default: target = 0; break; } freeFontList(target); } } /* * Return a pointer to the XLFD font information for a given font class. * XXX make this allocate the font on demand. */ XTermFonts * getNormalFont(TScreen *screen, int which) { XTermFonts *result = 0; if (which >= 0 && which < fMAX) result = &(screen->fnts[which]); return result; } #if OPT_DEC_CHRSET XTermFonts * getDoubleFont(TScreen *screen, int which) { XTermFonts *result = 0; if ((int) which >= 0 && which < NUM_CHRSET) result = &(screen->double_fonts[which]); return result; } #endif #if OPT_WIDE_ATTRS || OPT_RENDERWIDE XTermFonts * getItalicFont(TScreen *screen, int which) { XTermFonts *result = 0; #if OPT_WIDE_ATTRS if (which >= 0 && which < fMAX) result = &(screen->ifnts[which]); #else (void) screen; (void) which; #endif return result; } #endif #if OPT_RENDERFONT /* * This returns a pointer to everything known about a given Xft font. * XXX make this allocate the font on demand. */ XTermXftFonts * getMyXftFont(XtermWidget xw, int which, int fontnum) { TScreen *screen = TScreenOf(xw); XTermXftFonts *result = 0; if (fontnum >= 0 && fontnum < NMENUFONTS) { switch ((VTFontEnum) which) { case fNorm: result = &(screen->renderFontNorm[fontnum]); break; case fBold: result = &(screen->renderFontBold[fontnum]); break; #if OPT_WIDE_ATTRS || OPT_RENDERWIDE case fItal: result = &(screen->renderFontItal[fontnum]); break; #endif #if OPT_WIDE_CHARS case fWide: result = &(screen->renderWideNorm[fontnum]); break; case fWBold: result = &(screen->renderWideBold[fontnum]); break; case fWItal: result = &(screen->renderWideItal[fontnum]); break; #endif case fMAX: break; } } return result; } XftFont * getXftFont(XtermWidget xw, VTFontEnum which, int fontnum) { XTermXftFonts *data = getMyXftFont(xw, which, fontnum); XftFont *result = 0; if (data != 0) result = data->font; return result; } #endif const char * whichFontEnum(VTFontEnum value) { const char *result = "?"; #define DATA(name) case name: result = #name; break switch (value) { DATA(fNorm); DATA(fBold); #if OPT_WIDE_ATTRS || OPT_RENDERWIDE DATA(fItal); #endif #if OPT_WIDE_CHARS DATA(fWide); DATA(fWBold); DATA(fWItal); #endif DATA(fMAX); } #undef DATA return result; } const char * whichFontList(XtermWidget xw, VTFontList * value) { const char *result = "?"; if (value == &(xw->work.fonts.x11)) result = "x11_fontnames"; #if OPT_RENDERFONT else if (value == &(xw->work.fonts.xft)) result = "xft_fontnames"; #endif #if OPT_LOAD_VTFONTS || OPT_WIDE_CHARS else if (value == &(xw->screen.cacheVTFonts.fonts.x11)) result = "cached_fontnames"; #endif return result; } static const char * whichFontList2s(VTFontList * list, char **value) { const char *result = 0; #define DATA(name) if (value == (list->name)) result = #name DATA(list_n); DATA(list_b); #if OPT_WIDE_ATTRS || OPT_RENDERWIDE DATA(list_i); #endif #if OPT_WIDE_CHARS DATA(list_w); DATA(list_wb); DATA(list_wi); #endif #undef DATA return result; } const char * whichFontList2(XtermWidget xw, char **value) { const char *result = 0; #define DATA(name) (result = whichFontList2s(&(xw->name), value)) if (DATA(work.fonts.x11) == 0) { #if OPT_RENDERFONT if (DATA(work.fonts.xft) == 0) #endif #if OPT_LOAD_VTFONTS || OPT_WIDE_CHARS if (DATA(screen.cacheVTFonts.fonts.x11) == 0) #endif result = "?"; } #undef DATA return result; } xterm-330/make.com0000644000175100001440000000363507050367166012675 0ustar tomusers$! make.com $! 25-JAN-2000, David Mathog $! builds xaw3d, xmu, and then xterm. $! $! $XFree86: xc/programs/xterm/make.com,v 1.1 2000/02/08 17:19:37 dawes Exp $ $! $!************************************************************ $! $! set up logicals for XAW, XMU and so forth $! $ define x11_directory decw$include $ thisfile = f$environment("PROCEDURE") $ thisis = f$parse(thisfile,,,"DEVICE") + f$parse(thisfile,,,"DIRECTORY") $ thisis = thisis - "]" $ define xaw_directory "''thisis'.lib.xaw3d]" $ define xmu_directory "''thisis'.lib.xmu]" $ define bitmap_directory "''thisis'.lib.bitmaps]" $ define/trans=(concealed) thisX11 "''thisis.lib.]" $ define X11 thisx11,decw$include $! $! note, ansi doesn't work with this variant of X11R5. $! $! don't build libs in debug mode $ if(P1 .eqs. "" .AND. P2 .eqs. "") $ then $! $! build XMU $! $ set ver $ set def [.lib.xmu] $ @make $! $! build XAW3D $! $ set def [-.xaw3d] $ @make $ set def [--] $ set nover $! $! move the two libraries to this level $! $ rename [.lib...]*.olb [] $ endif $! $ if(P1 .nes. "") $ then $ ccstub := cc/standard=vaxc/include=[]/debug/noopt $ mylink :== link/debug $ else $ ccstub := cc/standard=vaxc/include=[] $ mylink :== link $ endif $ mycc :== 'ccstub' - /define=(VMS,OPT_TEK4014,ALLOWLOGGING,OPT_NUM_LOCK) $! $! OPT_TOOLBAR doesn't work - it pulls in calls through Xaw3d and Xmu for $! XSHAPECOMBINEMASK and XSHAPEQUERYEXTENSION $! which seem not to exist in DW MOtif 1.2-5 $! $! $ set ver $ mycc BUTTON.C $ mycc CHARPROC.C $ mycc CHARSETS.C $ mycc CURSOR.C $ mycc DATA.C $ mycc DOUBLECHR.C $ mycc FONTUTILS.C $ mycc INPUT.C $ mycc KEYSYM2UCS.C $ mycc MAIN.C $ mycc MENU.C $ mycc MISC.C $ mycc PRINT.C $ mycc PTYDATA.C $! mycc RESIZE.C $ mycc SCREEN.C $ mycc SCROLLBAR.C $ mycc TABS.C $ mycc TEKPROC.C $ mycc TEKPRSTBL.C $ mycc TRACE.C $ mycc TTYSVR.C $ mycc UTIL.C $ mycc VMS.C $ mycc VTPRSTBL.C $! $ mylink/exe=xterm.exe xterm_axp.opt/option $ set nover $ exit xterm-330/uxterm.desktop0000644000175100001440000000360412667426462014200 0ustar tomusers# $XTermId: uxterm.desktop,v 1.14 2016/03/08 01:38:58 tom Exp $ # ----------------------------------------------------------------------------- # this file is part of xterm # # Copyright 2006-2012,2016 by Thomas E. Dickey # # All Rights Reserved # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name(s) of the above copyright # holders shall not be used in advertising or otherwise to promote the # sale, use or other dealings in this Software without prior written # authorization. # ----------------------------------------------------------------------------- [Desktop Entry] Name=UXTerm #GenericName=Terminal Comment=standard terminal emulator for the X window system Exec=uxterm Terminal=false Type=Application Encoding=UTF-8 Icon=xterm-color_48x48 Categories=System;TerminalEmulator; Keywords=shell;prompt;command;commandline;cmd; xterm-330/256colres.pl0000755000175100001440000000600610632366455013337 0ustar tomusers#! /usr/bin/perl # $XTermId: 256colres.pl,v 1.16 2007/06/08 23:58:37 tom Exp $ # ----------------------------------------------------------------------------- # this file is part of xterm # # Copyright 1999-2002,2007 by Thomas E. Dickey # # All Rights Reserved # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name(s) of the above copyright # holders shall not be used in advertising or otherwise to promote the # sale, use or other dealings in this Software without prior written # authorization. # ----------------------------------------------------------------------------- # Construct a header file defining default resources for the 256-color model # of xterm. This is modeled after the 256colors2.pl script. # use the resources for colors 0-15 - usually more-or-less a # reproduction of the standard ANSI colors, but possibly more # pleasing shades use strict; our ( $line1, $line2, $line3 ); our ( $red, $green, $blue, $gray ); our ( $level, $code, @steps ); print < */ /* * There are no configure options for these features: * ALLOWLOGFILECHANGES * ALLOWLOGFILEONOFF * CANT_OPEN_DEV_TTY * DEBUG* (any debug-option) * DUMP_BITMAP * DUMP_COLORS * HAS_LTCHARS * HAVE_SYS_PTEM_H * HAVE_X11_TRANSLATEI_H * PUCC_PTYD * USE_LOGIN_DASH_P * USE_X11TERM */ #undef ALLOWLOGFILEEXEC /* CF_ARG_ENABLE(enable-logfile-exec) */ #undef ALLOWLOGGING /* CF_ARG_ENABLE(enable-logging) */ #undef CC_HAS_PROTOS /* CF_ANSI_CC */ #undef CSRG_BASED /* CF_TYPE_FD_MASK */ #undef DECL_ERRNO /* CF_ERRNO */ #undef DEFDELETE_DEL /* AC_ARG_ENABLE(delete-is-del) */ #undef DEF_ALT_SENDS_ESC /* CF_ARG_ENABLE(alt-sends-esc) */ #undef DEF_BACKARO_BS /* CF_ARG_DISABLE(backarrow-key) */ #undef DEF_BACKARO_ERASE /* CF_ARG_ENABLE(backarrow-is-erase) */ #undef DEF_INITIAL_ERASE /* CF_ARG_DISABLE(initial-erase) */ #undef DEF_META_SENDS_ESC /* CF_ARG_ENABLE(meta-sends-esc) */ #undef DFT_COLORMODE /* AC_ARG_WITH(default-color-mode) */ #undef DFT_DECID /* AC_ARG_WITH(default-terminal-id) */ #undef DFT_TERMTYPE /* AC_ARG_WITH(default-term-type) */ #undef DISABLE_SETGID /* CF_ARG_DISABLE(setgid) */ #undef DISABLE_SETUID /* CF_ARG_DISABLE(setuid) */ #undef HAVE_GETHOSTNAME /* AC_CHECK_FUNCS(gethostname) */ #undef HAVE_GETLOGIN /* AC_CHECK_FUNCS(getlogin) */ #undef HAVE_GRANTPT /* CF_FUNC_GRANTPT */ #undef HAVE_GRANTPT_PTY_ISATTY /* CF_FUNC_GRANTPT */ #undef HAVE_INITGROUPS /* AC_CHECK_FUNCS(initgroups) */ #undef HAVE_LANGINFO_CODESET /* AM_LANGINFO_CODESET */ #undef HAVE_LASTLOG_H /* CF_LASTLOG */ #undef HAVE_LIBXPM /* CF_WITH_XPM */ #undef HAVE_LIB_NEXTAW /* CF_X_ATHENA(--with-neXtaw) */ #undef HAVE_LIB_PCRE /* CF_WITH_PCRE */ #undef HAVE_LIB_XAW /* CF_X_ATHENA */ #undef HAVE_LIB_XAW3D /* CF_X_ATHENA(--with-Xaw3d) */ #undef HAVE_LIB_XAW3DXFT /* CF_X_ATHENA(--with-Xaw3dxft) */ #undef HAVE_LIB_XAWPLUS /* CF_X_ATHENA(--with-XawPlus) */ #undef HAVE_LIB_XCURSOR /* AC_CHECK_LIB(Xcursor) */ #undef HAVE_MKDTEMP /* AC_CHECK_FUNCS(mkdtemp) */ #undef HAVE_NCURSES_CURSES_H /* AC_CHECK_HEADERS(ncurses/curses.h) */ #undef HAVE_NCURSES_TERM_H /* AC_CHECK_HEADERS(ncurses/term.h) */ #undef HAVE_PATHS_H /* CF_LASTLOG */ #undef HAVE_PCREPOSIX_H /* CF_WITH_PCRE */ #undef HAVE_POSIX_OPENPT /* CF_FUNC_GRANTPT */ #undef HAVE_POSIX_SAVED_IDS /* CF_POSIX_SAVED_IDS */ #undef HAVE_PTSNAME /* CF_FUNC_GRANTPT */ #undef HAVE_PUTENV /* AC_CHECK_FUNCS(putenv) */ #undef HAVE_SCHED_YIELD /* AC_CHECK_FUNCS(sched_yield) */ #undef HAVE_SETPGID /* AC_CHECK_FUNCS(setpgid) */ #undef HAVE_STDINT_H /* AC_PROG_CC_STDC */ #undef HAVE_STDLIB_H /* AC_CHECK_HEADERS(stdlib.h) */ #undef HAVE_STRFTIME /* AC_CHECK_FUNCS(strftime) */ #undef HAVE_SYS_TIME_H /* AC_HEADER_TIME */ #undef HAVE_SYS_TTYDEFAULTS_H /* AC_CHECK_HEADERS(sys/ttydefaults.h) */ #undef HAVE_SYS_WAIT_H /* AC_HEADER_SYS_WAIT */ #undef HAVE_TCGETATTR /* AC_CHECK_FUNCS(tcgetattr) */ #undef HAVE_TERMCAP_H /* AC_CHECK_HEADERS(termcap.h) */ #undef HAVE_TERMIOS_H /* AC_CHECK_HEADERS(termios.h) */ #undef HAVE_TERMIO_C_ISPEED /* CF_TERMIO_C_ISPEED */ #undef HAVE_TERM_H /* AC_CHECK_HEADERS(term.h) */ #undef HAVE_TIGETSTR /* AC_CHECK_FUNCS(tigetstr) */ #undef HAVE_UNISTD_H /* AC_CHECK_HEADERS(unistd.h) */ #undef HAVE_UNSETENV /* AC_CHECK_FUNCS(unsetenv) */ #undef HAVE_USE_EXTENDED_NAMES /* AC_CHECK_FUNCS(use_extended_names) */ #undef HAVE_UTMP /* CF_UTMP */ #undef HAVE_UTMP_UT_HOST /* CF_UTMP_UT_HOST */ #undef HAVE_UTMP_UT_SESSION /* CF_UTMP_UT_SESSION */ #undef HAVE_UTMP_UT_SYSLEN /* CF_UTMP_UT_SYSLEN */ #undef HAVE_UTMP_UT_XSTATUS /* CF_UTMP_UT_XSTATUS */ #undef HAVE_UTMP_UT_XTIME /* CF_UTMP_UT_XTIME */ #undef HAVE_WAITPID /* AC_CHECK_FUNCS(waitpid) */ #undef HAVE_WCHAR_H /* AC_CHECK_HEADERS(wchar.h) */ #undef HAVE_WCSWIDTH /* AC_CHECK_FUNCS(wcswidth) */ #undef HAVE_WCWIDTH /* AC_CHECK_FUNCS(wcwidth) */ #undef HAVE_X11_DECKEYSYM_H /* AC_CHECK_HEADERS(X11/DECkeysym.h) */ #undef HAVE_X11_EXTENSIONS_XINERAMA_H /* AC_CHECK_HEADERS(X11/extensions/Xinerama.h) */ #undef HAVE_X11_EXTENSIONS_XKB_H /* AC_CHECK_HEADERS(X11/extensions/XKB.h) */ #undef HAVE_X11_SUNKEYSYM_H /* AC_CHECK_HEADERS(X11/Sunkeysym.h) */ #undef HAVE_X11_XF86KEYSYM_H /* AC_CHECK_HEADERS(X11/XF86keysym.h) */ #undef HAVE_X11_XKBLIB_H /* AC_CHECK_HEADERS(X11/XKBlib.h) */ #undef HAVE_X11_XPOLL_H /* AC_CHECK_HEADERS(X11/Xpoll.h) */ #undef HAVE_XFTDRAWSETCLIP /* CF_X_FREETYPE */ #undef HAVE_XFTDRAWSETCLIPRECTANGLES /* CF_X_FREETYPE */ #undef HAVE_XKBKEYCODETOKEYSYM /* AC_CHECK_FUNCS(XkbKeycodeToKeysym) */ #undef HAVE_XKBQUERYEXTENSION /* AC_CHECK_FUNCS(XkbQueryExtension) */ #undef HAVE_XKB_BELL_EXT /* CF_XKB_BELL_EXT */ #undef LUIT_PATH /* CF_ARG_ENABLE(luit) */ #undef NO_ACTIVE_ICON /* CF_ARG_DISABLE(active-icon) */ #undef NO_LEAKS /* CF_ARG_DISABLE(leaks) */ #undef OPT_256_COLORS /* CF_ARG_ENABLE(256-color) */ #undef OPT_88_COLORS /* CF_ARG_ENABLE(88-color) */ #undef OPT_AIX_COLORS /* CF_ARG_DISABLE(16-color) */ #undef OPT_BLINK_CURS /* CF_ARG_DISABLE(blink-cursor) */ #undef OPT_BLINK_TEXT /* CF_ARG_DISABLE(blink-text) */ #undef OPT_BOX_CHARS /* CF_ARG_DISABLE(boxchars) */ #undef OPT_BROKEN_OSC /* CF_ARG_ENABLE(broken-osc) */ #undef OPT_BROKEN_ST /* CF_ARG_DISABLE(broken-st) */ #undef OPT_BUILTIN_XPMS /* CF_ARG_ENABLE(builtin-xpms) */ #undef OPT_C1_PRINT /* CF_ARG_DISABLE(c1-print) */ #undef OPT_COLOR_CLASS /* CF_ARG_DISABLE(color-class) */ #undef OPT_DABBREV /* CF_ARG_ENABLE(dabbrev) */ #undef OPT_DEC_CHRSET /* CF_ARG_DISABLE(doublechars) */ #undef OPT_DEC_LOCATOR /* CF_ARG_ENABLE(dec-locator) */ #undef OPT_DOUBLE_BUFFER /* CF_ARG_ENABLE(double-buffer) */ #undef OPT_DEC_RECTOPS /* CF_ARG_ENABLE(rectangles) */ #undef OPT_EXEC_XTERM /* CF_ARG_ENABLE(exec-xterm) */ #undef OPT_FIFO_LINES /* CF_ARG_ENABLE(fifo-lines) */ #undef OPT_HIGHLIGHT_COLOR /* CF_ARG_DISABLE(highlighting) */ #undef OPT_HP_FUNC_KEYS /* CF_ARG_ENABLE(hp-fkeys) */ #undef OPT_I18N_SUPPORT /* CF_ARG_DISABLE(i18n) */ #undef OPT_INITIAL_ERASE /* CF_ARG_DISABLE(initial-erase) */ #undef OPT_INPUT_METHOD /* CF_ARG_DISABLE(input-method) */ #undef OPT_ISO_COLORS /* CF_ARG_DISABLE(ansi-color) */ #undef OPT_LOAD_VTFONTS /* CF_ARG_ENABLE(load-vt-fonts) */ #undef OPT_LUIT_PROG /* CF_ARG_ENABLE(luit) */ #undef OPT_MAXIMIZE /* CF_ARG_DISABLE(maximize) */ #undef OPT_MINI_LUIT /* CF_ARG_ENABLE(mini-luit) */ #undef OPT_NUM_LOCK /* CF_ARG_DISABLE(num-lock) */ #undef OPT_PASTE64 /* CF_ARG_ENABLE(past64) */ #undef OPT_PC_COLORS /* CF_ARG_DISABLE(pc-color) */ #undef OPT_SCREEN_DUMPS /* CF_ARG_ENABLE(screen-dumps) */ #undef OPT_PTY_HANDSHAKE /* CF_ARG_ENABLE(pty-handshake) */ #undef OPT_READLINE /* CF_ARG_ENABLE(readline-mouse) */ #undef OPT_SAME_NAME /* CF_ARG_DISABLE(samename) */ #undef OPT_SCO_FUNC_KEYS /* CF_ARG_ENABLE(sco-fkeys) */ #undef OPT_SELECTION_OPS /* CF_ARG_DISABLE(selection-ops) */ #undef OPT_SELECT_REGEX /* CF_ARG_DISABLE(regex) */ #undef OPT_SESSION_MGT /* CF_ARG_DISABLE(session-mgt) */ #undef OPT_REGIS_GRAPHICS /* CF_ARG_ENABLE(regis-graphics) */ #undef OPT_SIXEL_GRAPHICS /* CF_ARG_ENABLE(sixel-graphics) */ #undef OPT_GRAPHICS /* CF_ARG_ENABLE(graphics) */ #undef OPT_SUN_FUNC_KEYS /* CF_ARG_ENABLE(sun-fkeys) */ #undef OPT_TCAP_FKEYS /* CF_ARG_ENABLE(tcap-fkeys) */ #undef OPT_TCAP_QUERY /* CF_ARG_ENABLE(tcap-query) */ #undef OPT_TEK4014 /* CF_ARG_DISABLE(tek4014) */ #undef OPT_TOOLBAR /* CF_ARG_ENABLE(toolbar) */ #undef OPT_VT52_MODE /* CF_ARG_DISABLE(vt52) */ #undef OPT_WIDER_ICHAR /* CF_ARG_ENABLE(16bit-chars) */ #undef OPT_WIDE_ATTRS /* CF_ARG_DISABLE(wide-attrs) */ #undef OPT_WIDE_CHARS /* CF_ARG_DISABLE(wide-chars) */ #undef OPT_XMC_GLITCH /* CF_ARG_ENABLE(xmc-glitch) */ #undef OPT_ZICONBEEP /* CF_ARG_DISABLE(ziconbeep) */ #undef OWN_TERMINFO_DIR /* AC_ARG_WITH(own-terminfo) */ #undef OWN_TERMINFO_ENV /* AC_ARG_ENABLE(env-terminfo) */ #undef PROCFS_ROOT /* CF_ARG_ENABLE(exec-xterm) */ #undef SCROLLBAR_RIGHT /* CF_ARG_ENABLE(rightbar) */ #undef SIG_ATOMIC_T /* CF_SIG_ATOMIC_T */ #undef SVR4 /* CF_SVR4, imake */ #undef SYSV /* CF_SYSV, imake */ #undef TIME_WITH_SYS_TIME /* AC_HEADER_TIME */ #undef TTY_GROUP_NAME /* CF_TTY_GROUP */ #undef USE_LASTLOG /* CF_LASTLOG */ #undef USE_POSIX_WAIT /* CF_POSIX_WAIT */ #undef USE_STRUCT_LASTLOG /* CF_STRUCT_LASTLOG */ #undef USE_SYSV_UTMP /* CF_UTMP */ #undef USE_SYS_SELECT_H /* CF_TYPE_FD_SET */ #undef USE_TERMCAP /* CF_FUNC_TGETENT */ #undef USE_TERMINFO /* CF_FUNC_TGETENT */ #undef USE_TTY_GROUP /* CF_TTY_GROUP */ #undef USE_UTEMPTER /* CF_UTEMPTER */ #undef USE_UTMP_SETGID /* AC_ARG_WITH(utmp-setgid) */ #undef UTMPX_FOR_UTMP /* CF_UTMP */ #undef XRENDERFONT /* CF_X_FREETYPE */ #undef cc_t /* CF_TYPE_CC_T */ #undef gid_t /* AC_TYPE_UID_T */ #undef mode_t /* AC_TYPE_MODE_T */ #undef off_t /* AC_TYPE_OFF_T */ #undef pid_t /* AC_TYPE_PID_T */ #undef time_t /* AC_CHECK_TYPE(time_t, long) */ #undef uid_t /* AC_TYPE_UID_T */ #undef ut_name /* CF_UTMP */ #undef ut_xstatus /* CF_UTMP_UT_XSTATUS */ #undef ut_xtime /* CF_UTMP_UT_XTIME */ /* * Ifdef'd to make it simple to override. */ #ifndef OPT_TRACE #undef OPT_TRACE /* CF_ARG_ENABLE(trace) */ #undef OPT_TRACE_FLAGS /* ...no option */ #endif /* * g++ support for __attribute__() is haphazard. */ #ifndef __cplusplus #undef GCC_PRINTF #undef GCC_PRINTFLIKE #undef GCC_NORETURN #undef GCC_UNUSED #endif #ifndef HAVE_X11_XPOLL_H #define NO_XPOLL_H /* X11R6.1 & up use Xpoll.h for select() definitions */ #endif /* vile:cmode */ #endif /* included_xtermcfg_h */ xterm-330/graphics_sixel.h0000644000175100001440000000352312722615077014430 0ustar tomusers/* $XTermId: graphics_sixel.h,v 1.4 2016/05/29 16:35:11 tom Exp $ */ /* * Copyright 2014,2016 by Ross Combs * Copyright 2014,2016 by Thomas E. Dickey * * All Rights Reserved * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * Except as contained in this notice, the name(s) of the above copyright * holders shall not be used in advertising or otherwise to promote the * sale, use or other dealings in this Software without prior written * authorization. */ #ifndef included_graphics_sixel_h #define included_graphics_sixel_h /* *INDENT-OFF* */ #include #if OPT_SIXEL_GRAPHICS extern int parse_sixel(XtermWidget /* xw */, ANSI */* params */, char const */* string */); #else #define parse_sixel(xw, params, string) /* nothing */ #endif /* *INDENT-ON* */ #endif /* included_graphics_sixel_h */ xterm-330/Tekparse.h0000644000175100001440000000366612775315636013220 0ustar tomusers/* $XTermId: Tekparse.h,v 1.8 2016/10/06 00:32:30 tom Exp $ */ /* * Copyright 1998-2006,2016 by Thomas E. Dickey * * All Rights Reserved * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * Except as contained in this notice, the name(s) of the above copyright * holders shall not be used in advertising or otherwise to promote the * sale, use or other dealings in this Software without prior written * authorization. */ #ifndef included_Tekparse_h #define included_Tekparse_h 1 #ifndef Const # if defined(__STDC__) && !defined(__cplusplus) # define Const const # else # define Const /**/ # endif #endif extern Const int Talptable[]; extern Const int Tbestable[]; extern Const int Tbyptable[]; extern Const int Tesctable[]; extern Const int Tipltable[]; extern Const int Tplttable[]; extern Const int Tpttable[]; extern Const int Tspttable[]; #include #endif /* included_Tekparse_h */ xterm-330/README.i18n0000644000175100001440000001751407754555565012734 0ustar tomusers-- $XFree86: xc/programs/xterm/README.i18n,v 1.1 2003/11/13 01:16:37 dickey Exp $ Using xterm in your language ============================ Since XFree86 version 4.0, the internationalization (i18n) feature of xterm is gradually improved. Xterm is being improved even now. You need only set the standard locale environment variables such as LC_CTYPE, LC_ALL, LC_CTYPE, or LANG. Once the locale is set up you can use xterm in your favorite character encoding. This document explains how the i18n feature is realized and how to configure xterm for your character encoding. Refer to locale(7) for details of the locale mechanism. Basic i18n-related settings and resources ========================================= These settings apply to XFree86 xterm patch #181, and the program luit which is distributed with XFree86 4.4 1. Usage of "locale mode" On startup, xterm must be in "locale mode" to make it follow the current locale. You can invoke xterm in locale mode in these ways: a. Set "vt100.locale" resource "true". This resource was introduced since XFree86 4.3. The default value of the "locale" resource is "medium", which means xterm follows the locale only in Chinese, Japanese, Korean, or Thai locales. For example, XTerm*locale: true in your ~/.Xresources file. or b. Invoke xterm with the "-lc" option. 2. Converter program "luit" The "luit" must be available in the standard XFree86 binary directory. It is usually available because it is part of the XFree86 distribution. The standard binary directory may differ from system to system. /usr/X11R6/bin/luit is an example. "luit" is used to convert between Unicode and the character encoding for your locale. When built for XFree86, xterm includes logic for invoking luit. 3. Locale setting Finally, you will need to configure your locale. We expect that you have already configured your locale for other software. For example, LANG=de_DE@euro export LANG in your ~/.xsession file. There are many ways to configure locale. For example, your display manager may have a mechanism to invoke a window manager in your favorite locale, or you may have system-wide locale setting in /etc/environment. You may also have set the LC_ALL variable instead of the LANG variable. How to use xterm in different locale temporarily ================================================ You may sometimes need to invoke xterm in a different character encoding than your current locale. For example, use xterm to login remote systems in different locale. Do this by invoking xterm in the target locale. For example, $ LANG=ru_RU.KOI8-R xterm & Previously, font setting has been used in such cases. $ xterm -fn -misc-fixed-medium-r-normal--10-*-*-*-*-*-koi8-r & This does not work well in conjunction with the "locale" resource, because luit and xterm combined rely upon Unicode fonts. How to set fonts for UTF-8/locale modes ======================================= Since xterm patch #181, xterm can automatically use Unicode fonts in UTF-8 mode and locale mode. Few of you will need to modify the default setting to display your language. In particular, Unicode fonts in combination with locale mode will satisfy the needs of not only ISO-8859-1 users but also East Asian and other non-ISO-8859-1 users. If you want to set your favorite Unicode font for UTF-8 and locale modes, you should add a line such as the following in your ~/.Xresources file: XTerm*VT100.utf8Fonts.font: \ -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1 The leading "XTerm*" pattern is more specific than the system's app-defaults file, therefore it overrides the corresponding line beginning with *VT100.utf8Fonts.font: Here is an additional note. If you want to display East Asian doublewidth characters (CJK Ideogram, Hiragana, Katakana, Hangul, and so on), we recommend using -misc-fixed-medium-r-semicondensed--13-*-*-*-*-*-iso10646-1 or -misc-fixed-medium-r-normal--18-*-*-*-*-*-iso10646-1 because these two fonts have corresponding doublewidth fonts. These fonts are used as default font and default "Large" font, respectively. The internals of xterm i18n =========================== You do not need to read this section if you only want to configure your xterm. Here we describe how xterm is implemented to support i18n. The original version of xterm does not support locale or character encoding. Its I/O stream is interpreted as a mere 8-bit index for a font. Beginning with XFree86 4.0, xterm supported UTF-8. It was implemented as a separate UTF-8 mode from the conventional 8-bit mode. Character encodings had no effect on the 8-bit mode. The UTF-8 mode has been extended to support doublewidth characters (for East Asian characters) and combining characters (such as accents for Latin alphabets and Thai vowels/tone marks). Doublewidth characters are characters that occupy two continuing columns on the terminal. Xterm uses separate fonts for normal (singlewidth) characters and doublewidth characters. Though xterm has configuration items for specifying doublewidth fonts, it will automatically search for a font with exactly twice as wide and the same name as the specified normal font. The default behavior of xterm was modified to use this UTF-8 mode in UTF-8 locales. A command line option of "-u8" and a resource of "utf8" were introduced to choose UTF-8 mode. "luit" was introduced to XFree86 at version 4.2. It converts between UTF-8 and other encodings. When luit is invoked in a UTF-8 terminal, the terminal acts as if it is really running in the other encoding. Since XFree86 version 4.3, xterm provides a new mode to invoke luit automatically to support various encodings. The mode where xterm invokes luit is called "locale mode". It is the third mode following conventional 8-bit mode and UTF-8 mode. In the locale mode, xterm is aware of the current locale and character encoding. Since locale mode uses luit, it is based on the UTF-8 mode. That is, xterm works in UTF-8 mode and luit works as a converter between UTF-8 and the character encoding for your locale. This is why the locale mode always needs Unicode fonts. The default behavior of xterm is modified so that the "locale mode" will be adopted in Chinese (Big5 and GB2312), Japanese (EUC-JP), Korean (EUC-KR), and Thai (ISO-8859-11, as known as TIS-620) locales. Locale mode is chosen for these character encodings because these encodings are not supported by conventional 8-bit mode even by changing fonts (ISO-8859-11 needs combining characters and others need doublewidth characters). To control the locale mode, command line options of "-lc" and "-en" and a resource of "locale" were introduced. The command line option of "-u8" and a resource of "utf8" were made obsolete by them, though retained for compatibility. Since XFree86 version 4.4, xterm can have two sets of default fonts, one for conventional 8-bit mode and another for UTF-8 and locale modes, by introducing the "utf8Fonts" subresource. Future TODO Items ================= We anticipate that xterm's locale mode will be used increasingly in the future. Since the UTF-8 and locale modes use more resources than conventional 8-bit mode (because it needs larger fonts and another process "luit"), faster hardware may be needed to gain complete acceptance by users. However, the locale mechanism allows users to manipulate data in a standard form. Its usefulness compensates in part for reduced performance. Xterm supports antialiased fonts ("-fa" and "-fs" command line options). Currently UTF-8 nor locale modes do not work with antialiased fonts. Xterm does not support bi-directional or RTL languages such as Hebrew and Arab. A simple standard how terminal should behave for these languages is needed. Xterm does not support Unicode characters above U+10000. xterm-330/XTerm-col.ad0000644000175100001440000001330211241555255013363 0ustar tomusers! $XTermId: XTerm-col.ad,v 1.22 2009/08/15 15:56:29 tom Exp $ ! ----------------------------------------------------------------------------- ! this file is part of xterm ! ! Copyright 2002-2006,2009 by Thomas E. Dickey ! ! All Rights Reserved ! ! Permission is hereby granted, free of charge, to any person obtaining a ! copy of this software and associated documentation files (the ! "Software"), to deal in the Software without restriction, including ! without limitation the rights to use, copy, modify, merge, publish, ! distribute, sublicense, and/or sell copies of the Software, and to ! permit persons to whom the Software is furnished to do so, subject to ! the following conditions: ! ! The above copyright notice and this permission notice shall be included ! in all copies or substantial portions of the Software. ! ! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ! OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ! MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. ! IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY ! CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, ! TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ! SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ! ! Except as contained in this notice, the name(s) of the above copyright ! holders shall not be used in advertising or otherwise to promote the ! sale, use or other dealings in this Software without prior written ! authorization. ! ----------------------------------------------------------------------------- #include "XTerm" *VT100*colorMode: on *VT100*boldColors: on *VT100*dynamicColors: on ! Uncomment this for "white" text on a dark background. !*VT100*foreground: gray90 !*VT100*background: black ! - OR - ! Uncomment this for black text on a "white" background. !*VT100*foreground: black !*VT100*background: gray90 ! - OR - ! leave the foreground/background colors alone (at the mercy of your desktop ! designer). ! Color the popup/pulldown menu border to match the text widget foreground. !*SimpleMenu*borderColor: gray15 ! Uncomment this to use color for underline attribute !*VT100*colorULMode: on *VT100*colorUL: yellow !*VT100*italicULMode: on ! Uncomment this to disable underlining, e.g., if colorULMode is set. !*VT100*underLine: off ! Uncomment this to use color for the bold attribute !*VT100*colorBDMode: on *VT100*colorBD: white ! Uncomment this to use the bold/underline colors in preference to other colors !*VT100*colorAttrMode: on ! These are the 8 ANSI colors and their bright equivalents. Depending on ! other resource settings, xterm may use the bright colors when displaying ! bold text (see the boldColors resource). *VT100*color0: black *VT100*color1: red3 *VT100*color2: green3 *VT100*color3: yellow3 *VT100*color4: blue2 *VT100*color5: magenta3 *VT100*color6: cyan3 *VT100*color7: gray90 *VT100*color8: gray50 *VT100*color9: red *VT100*color10: green *VT100*color11: yellow *VT100*color12: rgb:5c/5c/ff *VT100*color13: magenta *VT100*color14: cyan *VT100*color15: white ! Disclaimer: there are no standard colors used in terminal emulation. ! ! The choice for color4 and color12 is a tradeoff between contrast, depending ! on whether they are used for text or backgrounds. Note that either color4 or ! color12 would be used for text, while only color4 would be used for a ! background. These are treated specially, since the luminosity of blue is ! only about half that of red/green, and is typically not accounted for in the ! RGB scheme. ! ! Blue text on a black background should be readable. ! Blue backgrounds should not be "too" bright. ! ! Originally color4/color12 were set to the names blue3/blue !*VT100*color4: blue3 !*VT100*color12: blue ! ! They are from rgb.txt respectively: ! 0 0 205 blue3 ! 0 0 255 blue ! However, blue3 is not readable on a black background. ! ! Another choice was from the Debian settings: !*VT100*color4: DodgerBlue1 !*VT100*color12: SteelBlue1 ! ! From rgb.txt: ! 30 144 255 DodgerBlue1 ! 99 184 255 SteelBlue1 ! ! Some users object to this choice because the background (color4) is brighter ! than they are accustomed. Others point out that the different weights for ! the red/green components make it appear to be not really blue. Finally, it ! provides poor contrast against color13 and color14. ! ! The current choice uses equal weights for red/green (effectively adding a ! gray to the result). It is brighter than the original choice, and provides ! more contrast between color12 and color13, color14 than SteelBlue1 did. ! Contrast of color4 against black is slightly improved over the original. ! ! Some refinement is certainly possible (you are welcome to try) -TD #if PLANES > 8 ! Color the popup menus and the menubar to match: *SimpleMenu*background: AntiqueWhite *SimpleMenu*foreground: gray15 ! Color the menubar to match: *Form.menubar.background: AntiqueWhite *Form.menubar*background: AntiqueWhite *Form.menubar.foreground: gray15 *Form.menubar*foreground: gray15 *Form.background: AntiqueWhite *form.background: AntiqueWhite ! The following two sections take advantage of new features in version 7 ! of the Athena widget library. Comment them out if you have a shallow ! color depth. !*SimpleMenu*backgroundPixmap: gradient:vertical?dimension=350&start=gray90&end=gray60 !*SimpleMenu*foreground: gray15 !*VT100.scrollbar.thumb: vlines2 !*VT100.scrollbar.width: 14 !*VT100.scrollbar.background: gray60 !*VT100.scrollbar.foreground: rgb:a/5/5 !*VT100.scrollbar.borderWidth: 0 !*VT100.scrollbar.displayList:\ !foreground gray90;\ !lines 1,-1,-1,-1,-1,1;\ !foreground gray60;\ !lines -1,0,0,0,0,-1 #endif xterm-330/charclass.c0000644000175100001440000001666113113056732013361 0ustar tomusers/* $XTermId: charclass.c,v 1.28 2017/05/29 17:43:54 tom Exp $ */ /* * Compact and efficient reimplementation of the * xterm character class mechanism for large character sets * * Markus Kuhn -- mkuhn@acm.org -- 2000-07-03 * * xterm allows users to select entire words with a double-click on the left * mouse button. Opinions might differ on what type of characters are part of * separate words, therefore xterm allows users to configure a class code for * each 8-bit character. Words are maximum length sequences of neighboring * characters with identical class code. Extending this mechanism to Unicode * naively would create an at least 2^16 entries (128 kB) long class code * table. * * Instead, we transform the character class table into a list of intervals, * that will be accessed via a linear search. Changes made to the table by the * user will be appended. A special class code IDENT (default) marks * characters who have their code number as the class code. * * We could alternatively use a sorted table of non-overlapping intervals that * can be accessed via binary search, but merging in new intervals is * significantly more hassle and not worth the effort here. */ #include #include #if OPT_WIDE_CHARS static struct classentry { int cclass; int first; int last; } *classtab; /* * Special convention for classtab[0]: * - classtab[0].cclass is the allocated number of entries in classtab * - classtab[0].first = 1 (first used entry in classtab) * - classtab[0].last is the last used entry in classtab */ int SetCharacterClassRange(int low, int high, int value) { TRACE(("...SetCharacterClassRange (%#x .. %#x) = %d\n", low, high, value)); if (high < low) return -1; /* nothing to do */ /* make sure we have at least one free entry left at table end */ if (classtab[0].last > classtab[0].cclass - 2) { classtab[0].cclass += 5 + classtab[0].cclass / 4; classtab = TypeRealloc(struct classentry, (unsigned) classtab[0].cclass, classtab); if (!classtab) abort(); } /* simply append new interval to end of interval array */ classtab[0].last++; classtab[classtab[0].last].first = low; classtab[classtab[0].last].last = high; classtab[classtab[0].last].cclass = value; return 0; } typedef enum { IDENT = -1, ALNUM = 48, CNTRL = 1, BLANK = 32, U_CJK = 0x4e00, U_SUP = 0x2070, U_SUB = 0x2080, U_HIR = 0x3040, U_KAT = 0x30a0, U_HAN = 0xac00 } Classes; void init_classtab(void) { const int size = 50; TRACE(("init_classtab {{\n")); classtab = TypeMallocN(struct classentry, (unsigned) size); if (!classtab) abort(); classtab[0].cclass = size; classtab[0].first = 1; classtab[0].last = 0; /* old xterm default classes */ SetCharacterClassRange(0, 0, BLANK); SetCharacterClassRange(1, 31, CNTRL); SetCharacterClassRange('\t', '\t', BLANK); SetCharacterClassRange('0', '9', ALNUM); SetCharacterClassRange('A', 'Z', ALNUM); SetCharacterClassRange('_', '_', ALNUM); SetCharacterClassRange('a', 'z', ALNUM); SetCharacterClassRange(127, 159, CNTRL); SetCharacterClassRange(160, 191, IDENT); SetCharacterClassRange(192, 255, ALNUM); SetCharacterClassRange(215, 215, IDENT); SetCharacterClassRange(247, 247, IDENT); /* added Unicode classes */ SetCharacterClassRange(0x0100, 0xffdf, ALNUM); /* mostly characters */ SetCharacterClassRange(0x037e, 0x037e, IDENT); /* Greek question mark */ SetCharacterClassRange(0x0387, 0x0387, IDENT); /* Greek ano teleia */ SetCharacterClassRange(0x055a, 0x055f, IDENT); /* Armenian punctuation */ SetCharacterClassRange(0x0589, 0x0589, IDENT); /* Armenian full stop */ SetCharacterClassRange(0x0700, 0x070d, IDENT); /* Syriac punctuation */ SetCharacterClassRange(0x104a, 0x104f, IDENT); /* Myanmar punctuation */ SetCharacterClassRange(0x10fb, 0x10fb, IDENT); /* Georgian punctuation */ SetCharacterClassRange(0x1361, 0x1368, IDENT); /* Ethiopic punctuation */ SetCharacterClassRange(0x166d, 0x166e, IDENT); /* Canadian Syl. punctuation */ SetCharacterClassRange(0x17d4, 0x17dc, IDENT); /* Khmer punctuation */ SetCharacterClassRange(0x1800, 0x180a, IDENT); /* Mongolian punctuation */ SetCharacterClassRange(0x2000, 0x200a, BLANK); /* spaces */ SetCharacterClassRange(0x200b, 0x27ff, IDENT); /* punctuation and symbols */ SetCharacterClassRange(0x2070, 0x207f, U_SUP); /* superscript */ SetCharacterClassRange(0x2080, 0x208f, U_SUB); /* subscript */ SetCharacterClassRange(0x3000, 0x3000, BLANK); /* ideographic space */ SetCharacterClassRange(0x3001, 0x3020, IDENT); /* ideographic punctuation */ SetCharacterClassRange(0x3040, 0x309f, U_HIR); /* Hiragana */ SetCharacterClassRange(0x30a0, 0x30ff, U_KAT); /* Katakana */ SetCharacterClassRange(0x3300, 0x9fff, U_CJK); /* CJK Ideographs */ SetCharacterClassRange(0xac00, 0xd7a3, U_HAN); /* Hangul Syllables */ SetCharacterClassRange(0xf900, 0xfaff, U_CJK); /* CJK Ideographs */ SetCharacterClassRange(0xfe30, 0xfe6b, IDENT); /* punctuation forms */ SetCharacterClassRange(0xff00, 0xff0f, IDENT); /* half/fullwidth ASCII */ SetCharacterClassRange(0xff1a, 0xff20, IDENT); /* half/fullwidth ASCII */ SetCharacterClassRange(0xff3b, 0xff40, IDENT); /* half/fullwidth ASCII */ SetCharacterClassRange(0xff5b, 0xff64, IDENT); /* half/fullwidth ASCII */ TRACE(("}} init_classtab\n")); return; } int CharacterClass(int c) { int i, cclass = IDENT; for (i = classtab[0].first; i <= classtab[0].last; i++) if (classtab[i].first <= c && classtab[i].last >= c) cclass = classtab[i].cclass; if (cclass < 0) cclass = c; return cclass; } #if OPT_REPORT_CCLASS #define charFormat(code) ((code) > 255 ? "0x%04X" : "%d") static const char * class_name(Classes code) { static char buffer[80]; const char *result = "?"; switch (code) { case IDENT: result = "IDENT"; break; case ALNUM: result = "ALNUM"; break; case CNTRL: result = "CNTRL"; break; case BLANK: result = "BLANK"; break; case U_SUP: result = "superscript"; break; case U_SUB: result = "subscript"; break; case U_CJK: result = "CJK Ideographs"; break; case U_HIR: result = "Hiragana"; break; case U_KAT: result = "Katakana"; break; case U_HAN: result = "Hangul Syllables"; break; default: sprintf(buffer, charFormat(code), code); result = buffer; break; } return result; } void report_wide_char_class(void) { static const Classes known_classes[] = {IDENT, ALNUM, CNTRL, BLANK, U_SUP, U_SUB, U_HIR, U_KAT, U_CJK, U_HAN}; int i; printf("\n"); printf("Unicode charClass data uses the last match\n"); printf("from these overlapping intervals of character codes:\n"); for (i = classtab[0].first; i <= classtab[0].last; i++) { printf("\tU+%04X .. U+%04X %s\n", classtab[i].first, classtab[i].last, class_name(classtab[i].cclass)); } printf("\n"); printf("These class-names are used internally (the first character code in a class):\n"); for (i = 0; i < (int) XtNumber(known_classes); ++i) { printf("\t"); printf(charFormat(known_classes[i]), known_classes[i]); printf(" = %s\n", class_name(known_classes[i])); } } #endif /* OPT_REPORT_CCLASS */ #ifdef NO_LEAKS void noleaks_CharacterClass(void) { if (classtab != 0) { free(classtab); classtab = 0; } } #endif #endif /* OPT_WIDE_CHARS */ xterm-330/package/0000755000175100001440000000000013117604373012637 5ustar tomusersxterm-330/package/freebsd/0000755000175100001440000000000013117604373014251 5ustar tomusersxterm-330/package/freebsd/pkg-message0000644000175100001440000000116111531475635016403 0ustar tomusers================================================================================ You installed xterm with wide chars support. This introduces some limitations comparing to the plain single chars version: this version of xterm will use UTF-8 charset for selection buffers, breaking 8-bit copy/paste support unless you are using UTF-8 or ISO8859-1 locale. If you want 8-bit charset selections to work as before, use "eightBitSelectTypes" XTerm resource setting. For further information refer to the SELECT/PASTE section of xterm(1) manual page. ================================================================================ xterm-330/package/freebsd/pkg-descr0000644000175100001440000000073710100323317016043 0ustar tomusersThe xterm program is the standard terminal emulator for the X Window System. It provides DEC VT102/VT220 and Tektronix 4014 compatible terminals for programs that can't use the window system directly. If the underlying operating system supports terminal resizing capabilities (for example, the SIGWINCH signal in systems derived from 4.3bsd), xterm will use the facilities to notify programs running in the window whenever it is resized. WWW: http://invisible-island.net/xterm/ xterm-330/package/freebsd/Makefile0000644000175100001440000000610613117604373015714 0ustar tomusers# $FreeBSD$ # This is adapted from the FreeBSD port, installing as "xterm-dev" with # separate resource- and manpage files. # copy "xterm-${PORTVERSION}.tgz to the port's distfiles directory # and "make makesum". PORTNAME= xterm PORTVERSION= 330 CATEGORIES= x11 MASTER_SITES= ftp://invisible-island.net/xterm/ \ CRITICAL PKGNAMESUFFIX= -dev EXTRACT_SUFX= .tgz DISTFILES= ${DISTNAME}${EXTRACT_SUFX}:src1 \ bsd-xterm-icons-${ICONVERSION}${EXTRACT_SUFX}:src2 MAINTAINER= ehaupt@FreeBSD.org COMMENT= Terminal emulator for the X Window System CONFLICTS= x11iraf-[0-9]* USE_XORG= xft GNU_CONFIGURE= yes CONFIGURE_ARGS+= --with-utempter --enable-narrowproto CPPFLAGS+= -I${LOCALBASE}/include LIBS+= -L${LOCALBASE}/lib ICONVERSION= 1 OPTIONS_DEFINE= WCHAR LUIT DECTERM PCRE DABBREV 256COLOR SIXEL GNOME LOGGING TOOLBAR OPTIONS_RADIO= 3D OPTIONS_RADIO_3D= XAW3D XAW3DXFT NEXTAW TOOLBAR_DESC= Enable support menu/toolbar DABBREV_DESC= Enable support for dabbrev-expand DECTERM_DESC= Enable DECterm Locator support LUIT_DESC= Use LUIT for locale convertion from/to UTF-8 SIXEL_DESC= Enable Sixel graphics support WCHAR_DESC= Enable wide-character support 256COLOR_DESC= Enable 256-color support LOGGING_DESC= Enable logging terminal I/O to a file XAW3D_DESC= Link with Xaw 3d library XAW3DXFT_DESC= Link with Xaw 3d xft (extended fonts) library NEXTAW_DESC= Link with neXT Athena library OPTIONS_DEFAULT=WCHAR LUIT 256COLOR 256COLOR_CONFIGURE_ENABLE= 256-color LUIT_BUILD_DEPENDS= luit:${PORTSDIR}/x11/luit LUIT_CONFIGURE_ENABLE= luit WCHAR_CONFIGURE_ENABLE= wide-chars DECTERM_CONFIGURE_ENABLE= dec-locator PCRE_CONFIGURE_WITH= pcre PCRE_LIB_DEPENDS= libpcre.so:${PORTSDIR}/devel/pcre DABBREV_CONFIGURE_ENABLE= dabbrev SIXEL_CONFIGURE_ENABLE= sixel-graphics GNOME_USES= desktop-file-utils LOGGING_CONFIGURE_ENABLE= logging TOOLBAR_CONFIGURE_ENABLE= toolbar XAW3D_CONFIGURE_WITH= Xaw3d XAW3D_LIB_DEPENDS= libXaw3d.so:${PORTSDIR}/x11-toolkits/Xaw3d XAW3DXFT_CONFIGURE_WITH= Xaw3dxft XAW3DXFT_LIB_DEPENDS= libXaw3dxft.so:${PORTSDIR}/x11-toolkits/libxaw3dxft NEXTAW_CONFIGURE_WITH= neXtaw NEXTAW_LIB_DEPENDS= libneXtaw.so:${PORTSDIR}/x11-toolkits/neXtaw PKG_CLASS= XTermDev .include CONFIGURE_ARGS+= --program-suffix=${PKGNAMESUFFIX} --with-app-class=${PKG_CLASS} --without-xterm-symlink MAN1= resize${PKGNAMESUFFIX}.1 koi8rxterm${PKGNAMESUFFIX}.1 uxterm${PKGNAMESUFFIX}.1 xterm${PKGNAMESUFFIX}.1 .if ! ${PORT_OPTIONS:MXAW3D} && ! ${PORT_OPTIONS:MXAW3DXFT} && ! ${PORT_OPTIONS:MNEXTAW} USE_XORG+= xaw .endif .if ${OSVERSION} < 900004 LIB_DEPENDS+= libutempter.so:${PORTSDIR}/sysutils/libutempter .endif post-extract: @${CP} ${WRKDIR}/bsd-xterm-icons-1/*.png \ ${WRKDIR}/bsd-xterm-icons-1/*.xpm \ ${WRKSRC}/icons/ post-install: .for f in koi8rxterm${PKGNAMESUFFIX} resize${PKGNAMESUFFIX} uxterm${PKGNAMESUFFIX} xterm${PKGNAMESUFFIX} @${CHMOD} ${BINMODE} ${STAGEDIR}${PREFIX}/bin/${f} .endfor @${INSTALL_DATA} ${WRKSRC}/xterm.desktop \ ${STAGEDIR}${PREFIX}/share/applications/xterm${PKGNAMESUFFIX}.desktop .if ${PORT_OPTIONS:MWCHAR} @${CAT} ${PKGMESSAGE} .endif .include xterm-330/package/freebsd/pkg-plist0000644000175100001440000000132112364565307016111 0ustar tomusersbin/koi8rxterm-dev bin/resize-dev bin/uxterm-dev bin/xterm-dev lib/X11/app-defaults/KOI8RXTermDev lib/X11/app-defaults/KOI8RXTermDev-color lib/X11/app-defaults/UXTermDev lib/X11/app-defaults/UXTermDev-color lib/X11/app-defaults/XTermDev lib/X11/app-defaults/XTermDev-color man/man1/resize-dev.1.gz man/man1/koi8rxterm-dev.1.gz man/man1/uxterm-dev.1.gz man/man1/xterm-dev.1.gz share/applications/xterm-dev.desktop share/pixmaps/filled-xterm-dev_32x32.xpm share/pixmaps/filled-xterm-dev_48x48.xpm share/pixmaps/mini.xterm-dev_32x32.xpm share/pixmaps/mini.xterm-dev_48x48.xpm share/pixmaps/xterm-dev-color_32x32.xpm share/pixmaps/xterm-dev-color_48x48.xpm share/pixmaps/xterm-dev_32x32.xpm share/pixmaps/xterm-dev_48x48.xpm xterm-330/package/debian/0000755000175100001440000000000013117604373014061 5ustar tomusersxterm-330/package/debian/rules0000755000175100001440000001116013112656724015142 0ustar tomusers#!/usr/bin/make -f # Made with the aid of dh_make, by Craig Small # Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess. # Some lines taken from debmake, by Cristoph Lameter. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 # These are used for cross-compiling and for saving the configure script # from having to guess our platform (since we know it already) DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) DESKTOP_VENDOR = dickey PKG_SUFFIX = -dev PKG_CLASS = XTermDev PACKAGE := $(shell dpkg-parsechangelog| \ sed -n 's/^Source: \(.*\)$$/\1/p') PKG_APPDEFAULTS := /etc/X11/app-defaults PKG_DESKTOP := /usr/share/applications DSTDIR := $(CURDIR)/debian/$(PACKAGE) MY_DESKTOP := $(DSTDIR)/usr/share/applications CPPFLAGS := $(shell dpkg-buildflags --get CPPFLAGS) CFLAGS := $(shell dpkg-buildflags --get CFLAGS) LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS) ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS))) DEBOP=--enable-debug else DEBOP= endif ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) CFLAGS += -O0 else CFLAGS += -O2 endif ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) INSTALL_PROGRAM += -s endif configure: configure-stamp configure-stamp: dh_testdir CPPFLAGS="$(CPPFLAGS)" \ CFLAGS="$(CFLAGS)" \ LDFLAGS="$(LDFLAGS)" \ ./configure \ --host=$(DEB_HOST_GNU_TYPE) \ --build=$(DEB_BUILD_GNU_TYPE) \ --program-suffix=$(PKG_SUFFIX) \ --prefix=/usr \ --libexecdir=\$${prefix}/lib \ --mandir=\$${prefix}/share/man \ --sysconfdir=/etc/$(PACKAGE) \ --localstatedir=/var \ --libdir=/etc/$(PACKAGE) \ --with-app-class=$(PKG_CLASS) \ --without-xterm-symlink \ --disable-imake \ --enable-256-color \ --enable-88-color \ --enable-dabbrev \ --enable-dec-locator \ --enable-exec-xterm \ --enable-hp-fkeys \ --enable-load-vt-fonts \ --enable-logfile-exec \ --enable-logging \ --enable-mini-luit \ --enable-paste64 \ --enable-regis-graphics \ --enable-sco-fkeys \ --enable-screen-dumps \ --enable-sixel-graphics \ --enable-tcap-fkeys \ --enable-tcap-query \ --enable-toolbar \ --enable-wide-chars \ --enable-xmc-glitch \ --with-app-defaults=$(PKG_APPDEFAULTS) \ --with-icondir=\$${prefix}/share/icons \ --with-pixmapdir=\$${prefix}/share/pixmaps \ --with-own-terminfo=\$${prefix}/share/terminfo \ --with-icon-theme \ --with-terminal-type=xterm-new \ --with-utempter \ --with-icon-name=mini.xterm \ --with-xpm ${DEBOP} touch configure-stamp build: build-stamp build-stamp: configure-stamp dh_testdir $(MAKE) touch build-stamp clean: dh_testdir dh_testroot [ ! -f Makefile ] || $(MAKE) distclean dh_clean install: install-stamp install-stamp: build-stamp dh_testdir dh_testroot dh_clean -k dh_installdirs $(MAKE) install \ DESTDIR=$(CURDIR)/debian/$(PACKAGE) touch install-stamp install: install-indep install-arch install-indep: install-arch: dh_testdir dh_testroot dh_prep -s dh_installdirs -s $(MAKE) install-bin \ DESTDIR=$(DSTDIR) # Build architecture-independent files here. binary-indep: build install dh_testdir dh_testroot # This overwrites the Debian package's copy of app-defaults and icons. # But the resources are not the same; they are patched. sed -i -f package/debian/color.sed XTerm-col.ad sed -i -f package/debian/xterm-xres.sed XTerm.ad $(MAKE) install-app \ install-icon \ install-man \ DESTDIR=$(DSTDIR) # Follow-up with a check against the installed resource files. ( cd $(DSTDIR)$(PKG_APPDEFAULTS) \ && $(SHELL) -c 'for p in *; do \ test -f $(PKG_APPDEFAULTS)/$$p && \ diff -u $(PKG_APPDEFAULTS)/$$p $$p; \ done' ; \ exit 0 ) # The Debian package does not install desktop files. # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=486317 $(MAKE) install-desktop \ DESKTOP_FLAGS="--vendor='$(DESKTOP_VENDOR)' --dir $(MY_DESKTOP)" ( cd $(DSTDIR)$(PKG_DESKTOP) \ && $(SHELL) -c 'for p in *;do \ test -f $(PKG_DESKTOP)/$$p && \ diff -u $(PKG_DESKTOP)/$$p $$p; \ test -n "$(PKG_SUFFIX)" && mv $$p `basename $$p .desktop`$(PKG_SUFFIX).desktop; \ done' ; \ exit 0 ) dh_icons # Build architecture-dependent files here. binary-arch: build install dh_testdir dh_testroot dh_installdebconf dh_installdocs dh_installmenu dh_installmime dh_installexamples tektests vttests dh_installchangelogs dh_install dh_link dh_strip dh_compress -Xexamples dh_fixperms dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary install install-stamp xterm-330/package/debian/control0000644000175100001440000000204313112660124015452 0ustar tomusersSource: xterm-dev Section: x11 Priority: optional Maintainer: Thomas E. Dickey Homepage: http://invisible-island.net/xterm/ Build-Depends: debhelper (>= 7), xorg-docs-core Standards-Version: 3.8.2 Package: xterm-dev Architecture: any Depends: xbitmaps, libc6 (>= 2.11), libfontconfig1 (>= 2.9.0), libice6 (>= 1:1.0.0), libtinfo5, libutempter0 (>= 1.1.5), libx11-6, libxaw7, libxft2 (>> 2.1.1), libxmu6, libxt6 Provides: x-terminal-emulator Recommends: x11-utils | xutils | bluit Description: X terminal emulator (development version) xterm is the standard terminal emulator for the X Window System. It provides DEC VT102 and Tektronix 4014 compatible terminals for programs that cannot use the window system directly. This version implements ISO/ANSI colors, Unicode, and most of the control sequences used by DEC VT220 terminals. . This package contains a development version of xterm. It is configured to use "xterm-dev" and "XTermDev" for the program and its resource class, to avoid conflict with other packages. xterm-330/package/debian/xterm-dev.menu0000644000175100001440000000076213112654236016665 0ustar tomusers?package(xterm-dev):\ needs="x11"\ section="Applications/Terminal Emulators"\ longtitle="XTerm: terminal emulator for X (development)"\ title="XTermDev"\ icon="/usr/share/pixmaps/xterm-dev-color_32x32.xpm"\ command="xterm-dev" ?package(xterm-dev):\ needs="x11"\ section="Applications/Terminal Emulators"\ longtitle="XTerm: terminal emulator for X with Unicode support (development)"\ title="XTermDev (Unicode)"\ icon="/usr/share/pixmaps/xterm-dev-color_32x32.xpm"\ command="uxterm-dev" xterm-330/package/debian/watch0000644000175100001440000000014211460700355015103 0ustar tomusersversion=3 opts=passive ftp://invisible-island.net/xterm/current/xterm\.tar.gz \ debian uupdate xterm-330/package/debian/postinst0000644000175100001440000000053212424252524015664 0ustar tomusers#! /bin/sh echo "** postinst script for xterm: $*" set -e PRI=60 ALT=x-terminal-emulator PKG=xterm-dev BINDIR=/usr/bin MANDIR=/usr/share/man/man1 if [ $1 != "upgrade" ] then update-alternatives \ --install \ $BINDIR/$ALT $ALT \ $BINDIR/$PKG $PRI \ --slave $MANDIR/$ALT.1.gz $ALT.1.gz \ $MANDIR/$PKG.1.gz fi #DEBHELPER# exit 0 xterm-330/package/debian/source/0000755000175100001440000000000011410226414015347 5ustar tomusersxterm-330/package/debian/source/format0000644000175100001440000000001511410226414016556 0ustar tomusers3.0 (native) xterm-330/package/debian/prerm0000644000175100001440000000026712424250520015125 0ustar tomusers#! /bin/sh echo "** prerm script for xterm: $*" set -e if [ "x$1" != "xupgrade" ]; then update-alternatives --remove x-terminal-emulator /usr/bin/xterm-dev fi #DEBHELPER# exit 0 xterm-330/package/debian/color.sed0000644000175100001440000000045611461060326015673 0ustar tomuserss/! Uncomment this for "white" text on a dark background./! Set the default text foreground and background colors./ s/!\*VT100\*foreground: gray90/*VT100*foreground: gray90/ s/!\*VT100\*background: black/*VT100*background: black/ /!\*VT100.scrollbar.thumb:[ ]*vlines2/,/!lines[ ]*-1,0,0,0,0,-1/s/!// xterm-330/package/debian/xterm-xres.sed0000644000175100001440000000026312015672076016676 0ustar tomusers/\*tek4014\*fontSmall:[ ]*6x10/a\ \ ! Debian package customizations follow.\ *backarrowKeyIsErase: true\ *ptyInitialErase: true /!*allowWindowOps: false/a\ *allowWindowOps: true xterm-330/package/debian/changelog0000644000175100001440000002405413117604373015740 0ustar tomusersxterm-dev (330) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Mon, 12 Jun 2017 17:34:51 -0400 xterm-dev (329) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Sun, 04 Jun 2017 09:40:17 -0400 xterm-dev (328) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Mon, 24 Oct 2016 18:07:15 -0400 xterm-dev (327) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Sun, 02 Oct 2016 19:18:09 -0400 xterm-dev (326) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Wed, 07 Sep 2016 21:12:23 -0400 xterm-dev (325) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Thu, 12 May 2016 19:25:56 -0400 xterm-dev (324) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Thu, 10 Mar 2016 19:19:50 -0500 xterm-dev (323) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Wed, 27 Jan 2016 04:48:15 -0500 xterm-dev (322) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Sat, 02 Jan 2016 08:42:56 -0500 xterm-dev (321) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Sun, 27 Sep 2015 19:17:50 -0400 xterm-dev (320) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Wed, 26 Aug 2015 17:52:20 -0400 xterm-dev (319) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Wed, 22 Apr 2015 20:44:42 -0400 xterm-dev (318) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Mon, 06 Apr 2015 06:31:31 -0400 xterm-dev (317) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Fri, 20 Mar 2015 19:54:44 -0400 xterm-dev (316) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Thu, 05 Mar 2015 15:52:55 -0500 xterm-dev (315) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Fri, 02 Jan 2015 07:49:44 -0500 xterm-dev (314) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Mon, 01 Dec 2014 04:54:46 -0500 xterm-dev (313) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Mon, 06 Oct 2014 05:26:37 -0400 xterm-dev (312) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Fri, 26 Sep 2014 18:42:15 -0400 xterm-dev (311) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Mon, 28 Jul 2014 17:36:30 -0400 xterm-dev (310) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Mon, 14 Jul 2014 19:36:58 -0400 xterm-dev (309) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Sat, 28 Jun 2014 10:34:28 -0400 xterm-dev (308) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Thu, 19 Jun 2014 15:58:13 -0400 xterm-dev (307) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Wed, 04 Jun 2014 18:58:36 -0400 xterm-dev (306) unstable; urgency=low * fix incomplete implementation of new SGRs -- Thomas E. Dickey Tue, 03 Jun 2014 16:25:02 -0400 xterm-dev (305) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Mon, 05 May 2014 14:51:42 -0400 xterm-dev (304) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Wed, 09 Apr 2014 20:27:40 -0400 xterm-dev (303) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Tue, 04 Mar 2014 17:46:25 -0500 xterm-dev (302) unstable; urgency=low * maintenance updates -- Thomas E. Dickey Sat, 15 Feb 2014 16:19:35 -0500 xterm-dev (301) unstable; urgency=high * miscellaneous fixes -- Thomas E. Dickey Mon, 09 Dec 2013 07:59:24 -0500 xterm-dev (300) unstable; urgency=high * fix a regression from #298 changes -- Thomas E. Dickey Tue, 03 Dec 2013 18:59:58 -0500 xterm-dev (299) unstable; urgency=low * fix remaining regression from #297 changes -- Thomas E. Dickey Sun, 01 Dec 2013 11:48:42 -0500 xterm-dev (298) unstable; urgency=low * miscellaneous fixes -- Thomas E. Dickey Wed, 11 Sep 2013 17:16:37 -0400 xterm-dev (297) unstable; urgency=low * miscellaneous fixes for old issues -- Thomas E. Dickey Sun, 04 Aug 2013 08:58:31 -0400 xterm-dev (296) unstable; urgency=low * Build-fix for #295 changes -- Thomas E. Dickey Tue, 09 Jul 2013 21:20:04 -0400 xterm-dev (295) unstable; urgency=low * Workaround for problem with ld --as-needed option -- Thomas E. Dickey Sat, 06 Jul 2013 21:20:33 -0400 xterm-dev (294) unstable; urgency=low * Add experimental support for sixel graphics -- Thomas E. Dickey Sun, 23 Jun 2013 10:36:52 -0400 xterm-dev (293) unstable; urgency=low * Miscellaneous fixes. -- Thomas E. Dickey Wed, 08 May 2013 18:29:21 -0400 xterm-dev (292) unstable; urgency=low * Miscellaneous fixes. -- Thomas E. Dickey Tue, 26 Mar 2013 19:11:17 -0400 xterm-dev (291) unstable; urgency=low * Fix a different #282 change (Redhat #874327). -- Thomas E. Dickey Tue, 26 Feb 2013 19:09:32 -0500 xterm-dev (290) unstable; urgency=low * Fix incomplete revert of #282 change. -- Thomas E. Dickey Tue, 12 Feb 2013 19:48:21 -0500 xterm-dev (289) unstable; urgency=low * Miscellaneous fixes. * Fix regression with XTERM_SHELL feature. -- Thomas E. Dickey Sun, 03 Feb 2013 13:59:20 -0500 xterm-dev (288) unstable; urgency=low * Miscellaneous fixes. -- Thomas E. Dickey Mon, 26 Nov 2012 20:53:23 -0500 xterm-dev (287) unstable; urgency=low * Miscellaneous fixes. * Redhat #874327, #875305. -- Thomas E. Dickey Mon, 19 Nov 2012 04:53:39 -0500 xterm-dev (286) unstable; urgency=low * Redhat #869959 -- Thomas E. Dickey Thu, 25 Oct 2012 06:56:35 -0400 xterm-dev (285) unstable; urgency=low * Miscellaneous fixes. -- Thomas E. Dickey Mon, 15 Oct 2012 06:57:38 -0400 xterm-dev (284) unstable; urgency=low * fix documentation errata * fix regression in --enable-regex -- Thomas E. Dickey Wed, 10 Oct 2012 18:17:35 -0400 xterm-dev (283) unstable; urgency=low * Miscellaneous fixes. -- Thomas E. Dickey Mon, 01 Oct 2012 20:45:50 -0400 xterm-dev (282) unstable; urgency=low * Miscellaneous fixes. -- Thomas E. Dickey Mon, 20 Aug 2012 17:55:32 -0400 xterm-dev (281) unstable; urgency=low * fix regression in keyboard configuration. -- Thomas E. Dickey Tue, 26 Jun 2012 04:36:36 -0400 xterm-dev (280) unstable; urgency=low * Add Debian menu-file. * modify to support icon-theme * Miscellaneous fixes. -- Thomas E. Dickey Fri, 25 May 2012 05:36:50 -0400 xterm-dev (279) unstable; urgency=low * Miscellaneous fixes. -- Thomas E. Dickey Wed, 14 Mar 2012 20:33:27 -0400 xterm-dev (278) unstable; urgency=low * Fix regression in eightBitInput logic. * Fix regression in Darwin 9.x -- Thomas E. Dickey Thu, 12 Jan 2012 08:10:50 -0500 xterm-dev (277) unstable; urgency=low * Minor keyboard fix. -- Thomas E. Dickey Tue, 11 Oct 2011 20:12:14 -0400 xterm-dev (276) unstable; urgency=low * Regressions in #272, #274. -- Thomas E. Dickey Wed, 28 Sep 2011 17:34:20 -0400 xterm-dev (275) unstable; urgency=low * Regressions in #272, #274. -- Thomas E. Dickey Sun, 11 Sep 2011 09:46:57 -0400 xterm-dev (274) unstable; urgency=low * Various build-fixes. -- Thomas E. Dickey Sun, 28 Aug 2011 20:07:29 -0400 xterm-dev (273) unstable; urgency=low * Build-fixes/regressions from #272. -- Thomas E. Dickey Thu, 25 Aug 2011 05:42:58 -0400 xterm-dev (272) unstable; urgency=low * Build-fix for termcap systems. -- Thomas E. Dickey Fri, 15 Jul 2011 20:41:30 -0400 xterm-dev (271) unstable; urgency=low * Ubuntu #756273 (accommodate function keys as popup-menu triggers) -- Thomas E. Dickey Fri, 29 Apr 2011 20:30:29 -0400 xterm-dev (270) unstable; urgency=low * more fixes for fullscreen toggle. -- Thomas E. Dickey Sun, 20 Mar 2011 14:53:54 -0400 xterm-dev (269) unstable; urgency=low * amend translations for fullscreen toggle. -- Thomas E. Dickey Sun, 13 Feb 2011 19:20:48 -0500 xterm-dev (268) unstable; urgency=low * build-fixes, etc. -- Thomas E. Dickey Wed, 24 Nov 2010 06:17:16 -0500 xterm-dev (267) unstable; urgency=low * build-fixes, etc. -- Thomas E. Dickey Wed, 10 Nov 2010 18:46:41 -0500 xterm-dev (266) unstable; urgency=low * add build-script for testing, adapted from Debian xterm package. -- Thomas E. Dickey Fri, 22 Oct 2010 17:15:59 -0400 xterm-330/package/debian/compat0000644000175100001440000000000211363402276015256 0ustar tomusers5 xterm-330/package/debian/xterm-dev.docs0000644000175100001440000000011213112654503016633 0ustar tomusersREADME.i18n THANKS ctlseqs.ms ctlseqs.txt termcap terminfo xterm.log.html xterm-330/package/debian/copyright0000644000175100001440000002274413032534435016022 0ustar tomusersUpstream source http://invisible-island.net/xterm/xterm.html ------------------------------------------------------------------------------- Except as noted below, all copyrights use the same wording, denoted MIT-X11. That is not in Debian's list under /usr/share/licenses. Here is the common wording: All Rights Reserved Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name(s) of the above copyright holders shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization. ------------------------------------------------------------------------------- Files: * */* License: MIT-X11 Copyright 1996-2016,2017 by Thomas E. Dickey (date ranges vary, depending on when the respective files were first changed significantly, and run through the most recent change date). ------------------------------------------------------------------------------- Files: 88colres.pl License: MIT-X11 Copyright 1999-2005,2007 by Thomas E. Dickey Copyright 1999-2000 by Steve Wall ------------------------------------------------------------------------------- Files: vttests/88colors2.pl License: MIT-X11 Copyright 1999-2007,2009 by Thomas E. Dickey Copyright 1999 by Steve Wall ------------------------------------------------------------------------------- Files: vttests/256colors2.pl License: MIT-X11 Copyright 1999-2007,2009 by Thomas E. Dickey Copyright 2002 by Steve Wall Copyright 1999 by Todd Larason ------------------------------------------------------------------------------- Files: xcharmouse.h Copyright 1998 by Jason Bacon All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of the above listed copyright holder(s) not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ------------------------------------------------------------------------------- Files: xutf8.* License: MIT-X11 Copyright (C) 2001 by Juliusz Chroboczek Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------- Files: ctlseqs.ms install-sh License: MIT-X11 Copyright 1984-1994 X Consortium ------------------------------------------------------------------------------- Copyright 1987,1988 by Digital Equipment Corporation, Maynard, Massachusetts. All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Digital Equipment Corporation not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ------------------------------------------------------------------------------- Copyright 1988,1989 The Open Group Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. ------------------------------------------------------------------------------- Files: koi8rxterm.man uxterm.man License: MIT-X11 Copyright 2001, 2004 Branden Robinson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL SOFTWARE IN THE PUBLIC INTEREST, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------- Files: charclass.* Markus Kuhn -- 2000-07-03 Permission to use, copy, modify, and distribute this software for any purpose and without fee is hereby granted. The author disclaims all warranties with regard to this software. ------------------------------------------------------------------------------- Files: wcwidth.* Markus Kuhn -- 2007-05-25 Permission to use, copy, modify, and distribute this software for any purpose and without fee is hereby granted. The author disclaims all warranties with regard to this software. ------------------------------------------------------------------------------- Files: config.guess config.sub License: GPL-2+ Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. ------------------------------------------------------------------------------- Files: configure License: GPL-2+ Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. ------------------------------------------------------------------------------- xterm-330/package/xterm.spec0000644000175100001440000001534513117604373014662 0ustar tomusers# $XTermId: xterm.spec,v 1.96 2017/06/12 21:34:51 tom Exp $ Summary: X terminal emulator (development version) %global my_middle xterm %global my_suffix -dev %global fullname %{my_middle}%{my_suffix} %global my_class XTermDev Name: %{fullname} Version: 330 Release: 1 License: X11 Group: User Interface/X Source: xterm-%{version}.tgz URL: ftp://invisible-island.net/xterm/ Provides: x-terminal-emulator # This part (the build-requires) would be useful if the various distributions # had provided stable package-naming, or virtual packages to cover transitions. # However, they have not done this in the past. %define use_x_manpage %(test "x$_use_x_manpage" = xyes && echo 1 || echo 0) %if "%{use_x_manpage}" %global is_mandriva %(test -f /etc/mandriva-release && echo %{use_x_manpage} || echo 0) %global is_redhat %(test -f /etc/redhat-release && echo %{use_x_manpage} || echo 0) %global is_suse %(test -f /etc/SuSE-release && echo %{use_x_manpage} || echo 0) %if %{is_mandriva} BuildRequires: x11-docs %else %if %{is_redhat} BuildRequires: xorg-x11-docs %else %if %{is_suse} BuildRequires: xorg-docs %endif %endif %endif %endif %description xterm is the standard terminal emulator for the X Window System. It provides DEC VT102 and Tektronix 4014 compatible terminals for programs that cannot use the window system directly. This version implements ISO/ANSI colors, Unicode, and most of the control sequences used by DEC VT220 terminals. This package provides four commands: a) %{fullname}, which is the actual terminal emulator b) u%{fullname}, which is a wrapper around %{fullname} which sets %{fullname} to use UTF-8 encoding when the user's locale supports this, c) koi8r%{fullname}, a wrapper similar to u%{fullname} for locales that use the KOI8-R character set, and d) resize%{my_suffix}. A complete list of control sequences supported by the X terminal emulator is provided in /usr/share/doc/%{fullname}. The %{fullname} program uses bitmap images provided by the xbitmaps package. Those interested in using koi8r%{fullname} will likely want to install the xfonts-cyrillic package as well. This package is configured to use "%{fullname}" and "%{my_class}" for the program and its resource class, to avoid conflict with other packages. %prep %global desktop_vendor dickey %define desktop_utils %(if which desktop-file-install 2>&1 >/dev/null ; then echo 1 || echo 0 ; fi) %define icon_theme %(test -d /usr/share/icons/hicolor && echo 1 || echo 0) %define apps_x11r6 %(test -d /usr/X11R6/lib/X11/app-defaults && echo 1 || echo 0) %define apps_shared %(test -d /usr/share/X11/app-defaults && echo 1 || echo 0) %define apps_syscnf %(test -d /etc/X11/app-defaults && echo 1 || echo 0) %if %{apps_x11r6} %define _xresdir %{_prefix}/X11R6/lib/X11/app-defaults %else %if %{apps_shared} %define _xresdir %{_datadir}/X11/app-defaults %else %define _xresdir %{_sysconfdir}/X11/app-defaults %endif %endif %define _iconsdir %{_datadir}/icons %define _pixmapsdir %{_datadir}/pixmaps %define my_docdir %{_datadir}/doc/%{fullname} # no need for debugging symbols... %define debug_package %{nil} %setup -q -n xterm-%{version} %build CPPFLAGS="-DMISC_EXP -DEXP_HTTP_HEADERS" \ %configure \ --target %{_target_platform} \ --prefix=%{_prefix} \ --bindir=%{_bindir} \ --datadir=%{_datadir} \ --mandir=%{_mandir} \ %if "%{my_suffix}" != "" --program-suffix=%{my_suffix} \ --without-xterm-symlink \ %endif %if "%{icon_theme}" --with-icon-symlink \ --with-icon-theme \ --with-icondir=%{_iconsdir} \ %endif --with-app-class=%{my_class} \ --disable-imake \ --enable-256-color \ --enable-88-color \ --enable-dabbrev \ --enable-dec-locator \ --enable-exec-xterm \ --enable-hp-fkeys \ --enable-load-vt-fonts \ --enable-logfile-exec \ --enable-logging \ --enable-mini-luit \ --enable-paste64 \ --enable-regis-graphics \ --enable-sco-fkeys \ --enable-screen-dumps \ --enable-sixel-graphics \ --enable-tcap-fkeys \ --enable-tcap-query \ --enable-toolbar \ --enable-wide-chars \ --enable-xmc-glitch \ --with-app-defaults=%{_xresdir} \ --with-pixmapdir=%{_pixmapsdir} \ --with-own-terminfo=%{_datadir}/terminfo \ --with-terminal-type=xterm-new \ --with-utempter \ --with-icon-name=mini.xterm \ --with-xpm make chmod u+w XTerm.ad cat >>XTerm.ad <\*('' to hint that it is private. .RE .TP 8 .B "modifyFunctionKeys\fP (class\fB ModifyFunctionKeys\fP)" Tells how to handle the special case where Control-, Shift-, Alt- or Meta-modifiers are used to add a parameter to the escape sequence returned by a (numbered) function-key. The default is \*(``2\*(''. The resource values are similar to \fBmodifyCursorKeys\fP: .RS .TP 5 \-1 permits the user to use shift- and control-modifiers to construct function-key strings using the normal encoding scheme. .TP 5 0 uses the old/obsolete behavior, i.e., the modifier is the first parameter. .TP 5 1 prefixes modified sequences with CSI. .TP 5 2 forces the modifier to be the second parameter if it would otherwise be the first. .TP 5 3 marks the sequence with a \*(``>\*('' to hint that it is private. .RE .IP If \fBmodifyFunctionKeys\fP is zero, \fI\*n\fP uses Control- and Shift-modifiers to allow the user to construct numbered function-keys beyond the set provided by the keyboard: .RS .TP 5 Control adds the value given by the \fBctrlFKeys\fP resource. .TP 5 Shift adds twice the value given by the \fBctrlFKeys\fP resource. .TP 5 Control/Shift adds three times the value given by the \fBctrlFKeys\fP resource. .RE .IP .TP 8 .B "modifyKeyboard\fP (class\fB ModifyKeyboard\fP)" Normally \fI\*n\fP makes a special case regarding modifiers (shift, control, etc.) to handle special keyboard layouts (\fBlegacy\fP and \fBvt220\fP). This is done to provide compatible keyboards for DEC VT220 and related terminals that implement user-defined keys (UDK). .IP The bits of the resource value selectively enable modification of the given category when these keyboards are selected. The default is \*(``0\*('': .RS .TP 5 0 The legacy/vt220 keyboards interpret only the Control-modifier when constructing numbered function-keys. Other special keys are not modified. .TP 5 1 allows modification of the numeric keypad .TP 5 2 allows modification of the editing keypad .TP 5 4 allows modification of function-keys, overrides use of Shift-modifier for UDK. .TP 5 8 allows modification of other special keys .RE .TP 8 .B "modifyOtherKeys\fP (class\fB ModifyOtherKeys\fP)" Like \fBmodifyCursorKeys\fP, tells \fI\*n\fP to construct an escape sequence for other keys (such as \*(``2\*('') when modified by Control-, Alt- or Meta-modifiers. This feature does not apply to function keys and well-defined keys such as ESC or the control keys. The default is \*(``0\*('': .RS .TP 5 0 disables this feature. .TP 5 1 enables this feature for keys except for those with well-known behavior, e.g., Tab, Backarrow and some special control character cases, e.g., Control-Space to make a NUL. .TP 5 2 enables this feature for keys including the exceptions listed. .RE .TP 8 .B "multiClickTime\fP (class\fB MultiClickTime\fP)" Specifies the maximum time in milliseconds between multi-click select events. The default is \*(``250\*('' milliseconds. .TP 8 .B "multiScroll\fP (class\fB MultiScroll\fP)" Specifies whether or not scrolling should be done asynchronously. The default is \*(``false\*(''. .TP 8 .B "nMarginBell\fP (class\fB Column\fP)" Specifies the number of characters from the right margin at which the margin bell should be rung, when enabled by the \fBmarginBell\fP resource. The default is \*(``10\*(''. .TP 8 .B "numColorRegisters\fP (class\fB NumColorRegisters\fP)" If \fI\*n\fR is configured to support ReGIS or SIXEL graphics, this specifies the number of color-registers which are available. .IP If this resource is not specified, \fI\*n\fR uses a value determined by the \fBdecTerminalID\fP resource: .TS l l _ _ r r. \fBResult\fR \fBdecTerminalID\fR 4 125 4 240 4 241 4 330 16 340 2 382 1024 \fIother\fP .TE .TP 8 .B "numLock\fP (class\fB NumLock\fP)" If \*(``true\*('', \fI\*n\fR checks if NumLock is used as a modifier (see \fIxmodmap\fP(__mansuffix__)). If so, this modifier is used to simplify the logic when implementing special NumLock for the \fBsunKeyboard\fP resource. Also (when \fBsunKeyboard\fP is false), similar logic is used to find the modifier associated with the left and right Alt keys. The default is \*(``true\*(''. .TP 8 .B "oldXtermFKeys\fP (class\fB OldXtermFKeys\fP)" If \*(``true\*('', \fI\*n\fR will use old-style (X11R5) escape sequences for function keys F1 to F4, for compatibility with X Consortium \fI\*n\fR. Otherwise, it uses the VT100 codes for PF1 to PF4. The default is \*(``false\*(''. .IP Setting this resource has the same effect as setting the \fBkeyboardType\fP to \fBlegacy\fP. The \fBkeyboardType\fP resource is the preferred mechanism for selecting this mode. .IP The old-style escape sequences resemble VT220 keys, but appear to have been invented for \fI\*n\fP in X11R4. .TP 8 .B "on2Clicks\fP (class\fB On2Clicks\fP)" .TP .B "on3Clicks\fP (class\fB On3Clicks\fP)" .TP .B "on4Clicks\fP (class\fB On4Clicks\fP)" .TP .B "on5Clicks\fP (class\fB On5Clicks\fP)" Specify selection behavior in response to multiple mouse clicks. A single mouse click is always interpreted as described in the \fBSelection Functions\fP section (see \fBPOINTER USAGE\fP). Multiple mouse clicks (using the button which activates the \fBselect-start\fP action) are interpreted according to the resource values of \fBon2Clicks\fP, etc. The resource value can be one of these: .RS .TP 3 word Select a \*(``word\*('' as determined by the \fBcharClass\fP resource. See the \fBCHARACTER CLASSES\fP section. .TP line Select a line (counting wrapping). .TP group Select a group of adjacent lines (counting wrapping). The selection stops on a blank line, and does not extend outside the current page. .TP page Select all visible lines, i.e., the page. .TP all Select all lines, i.e., including the saved lines. .TP regex Select a \*(``word\*('' as determined by the regular expression which follows in the resource value. .TP none No selection action is associated with this resource. \fI\*N\fP interprets it as the end of the list. For example, you may use it to disable triple (and higher) clicking by setting \fBon3Clicks\fP to \*(``none\*(''. .RE .IP The default values for \fBon2Clicks\fP and \fBon3Clicks\fP are \*(``word\*('' and \*(``line\*('', respectively. There is no default value for \fBon4Clicks\fP or \fBon5Clicks\fP, making those inactive. On startup, \fI\*n\fP determines the maximum number of clicks by the \fBon\fP\fIX\fP\fBClicks\fP resource values which are set. .TP 8 .B "openIm\fP (class\fB OpenIm\fP)" Tells \fI\*n\fP whether to open the input method at startup. The default is \*(``true\*(''. .TP 8 .B "pointerColor\fP (class\fB PointerColor\fP)" Specifies the foreground color of the pointer. The default is \*(``XtDefaultForeground\*(''. .TP 8 .B "pointerColorBackground\fP (class\fB PointerColorBackground\fP)" Specifies the background color of the pointer. The default is \*(``XtDefaultBackground\*(''. .TP 8 .B "pointerMode\fP (class\fB PointerMode\fP)" Specifies when the pointer may be hidden as the user types. It will be redisplayed if the user moves the mouse, or clicks one of its buttons. .RS .TP 3 0 never .TP 3 1 the application running in \fI\*n\fP has not activated mouse mode. This is the default. .TP 3 2 always. .RE .TP 8 .B "pointerShape\fP (class\fB Cursor\fP)" Specifies the name of the shape of the pointer. The default is \*(``xterm\*(''. .TP 8 .B "popOnBell\fP (class\fB PopOnBell\fP)" Specifies whether the window would be raised when Control-G is received. The default is \*(``false\*(''. .IP If the window is iconified, this has no effect. However, the \fBzIconBeep\fP resource provides you with the ability to see which iconified windows have sounded a bell. .TP 8 .B "precompose\fP (class\fB Precompose\fP)" Tells \fI\*n\fP whether to precompose UTF-8 data into Normalization Form C, which combines commonly-used accents onto base characters. If it does not do this, accents are left as separatate characters. The default is \*(``true\*(''. .TP 8 .B "preeditType\fP (class\fB PreeditType\fP)" Tells \fI\*n\fP which types of preedit (preconversion) string to display. The default is \*(``OverTheSpot,Root\*(''. .TP 8 .B "printAttributes\fP (class\fB PrintAttributes\fP)" Specifies whether to print graphic attributes along with the text. A real DEC VT\fIxxx\fP terminal will print the underline, highlighting codes but your printer may not handle these. .RS .bP \*(``0\*('' disables the attributes. .bP \*(``1\*('' prints the normal set of attributes (bold, underline, inverse and blink) as VT100-style control sequences. .bP \*(``2\*('' prints ANSI color attributes as well. .RE .IP The default is \*(``1\*(''. .TP 8 .B "printFileImmediate\fP (class \fBPrintFileImmediate\fP)" When the \fBprint-immediate\fP action is invoked, \fI\*n\fP prints the screen contents directly to a file. Set this resource to the prefix of the filename (a timestamp will be appended to the actual name). .IP The default is an empty string, i.e., \*(``\*('', However, when the \fBprint-immediate\fP action is invoked, if the string is empty, then \*(``__default_class__\*('' is used. .TP 8 .B "printFileOnXError\fP (class \fBPrintFileOnXError\fP)" If \fI\*n\fP exits with an X error, e.g., your connection is broken when the server crashes, it can be told to write the contents of the screen to a file. To enable the feature, set this resource to the prefix of the filename (a timestamp will be appended to the actual name). .IP The default is an empty string, i.e., \*(``\*('', which disables this feature. However, when the \fBprint-on-error\fP action is invoked, if the string is empty, then \*(``XTermError\*('' is used. .IP These error codes are handled: ERROR_XERROR, ERROR_XIOERROR and ERROR_ICEERROR. .TP 8 .B "printModeImmediate\fP (class \fBPrintModeImmediate\fP)" When the \fBprint-immediate\fP action is invoked, \fI\*n\fP prints the screen contents directly to a file. You can use the \fBprintModeImmediate\fP resource to tell it to use escape sequences to reconstruct the video attributes and colors. This uses the same values as the \fBprintAttributes\fP resource. The default is \*(``0\*(''. .TP 8 .B "printModeOnXError\fP (class \fBPrintModeOnXError\fP)" \fI\*N\fP implements the \fBprintFileOnXError\fP feature using the printer feature, although the output is written directly to a file. You can use the \fBprintModeOnXError\fP resource to tell it to use escape sequences to reconstruct the video attributes and colors. This uses the same values as the \fBprintAttributes\fP resource. The default is \*(``0\*(''. .TP 8 .B "printOptsImmediate\fP (class \fBPrintOptsImmediate\fP)" Specify the range of text which is printed to a file when the \fBprint-immediate\fP action is invoked. .RS .bP If zero (0), then this selects the current (visible screen) plus the saved lines, except if the alternate screen is being used. In that case, only the alternate screen is selectd. .bP If nonzero, the bits of this resource value (checked in descending order) select the range: .RS .TP 3 8 selects the saved lines. .TP 3 4 selects the alternate screen. .TP 3 2 selects the normal screen. .TP 3 1 selects the current screen, which can be either the normal or alternate screen. .RE .RE .IP The default is \*(``9\*('', which selects the current visible screen plus saved lines, with no special case for the alternated screen. .TP 8 .B "printOptsOnXError\fP (class \fBPrintOptsOnXError\fP)" Specify the range of text which is printed to a file when the \fBprint-on-error\fP action is invoked. The resource value is interpreted the same as in \fBprintOptsImmediate\fP. .IP The default is \*(``9\*('', which selects the current visible screen plus saved lines, with no special case for the alternated screen. .TP 8 .B "printerAutoClose\fP (class\fB PrinterAutoClose\fP)" If \*(``true\*('', \fI\*n\fR will close the printer (a pipe) when the application switches the printer offline with a Media Copy command. The default is \*(``false\*(''. .TP 8 .B "printerCommand\fP (class\fB PrinterCommand\fP)" Specifies a shell command to which .I \*n will open a pipe when the first MC (Media Copy) command is initiated. The default is an empty string, i.e., \*(``\*(''. If the resource value is given as an empty string, the printer is disabled. .TP 8 .B "printerControlMode\fP (class\fB PrinterControlMode\fP)" Specifies the printer control mode. A \*(``1\*('' selects autoprint mode, which causes .I \*n to print a line from the screen when you move the cursor off that line with a line feed, form feed or vertical tab character, or an autowrap occurs. Autoprint mode is overridden by printer controller mode (a \*(``2\*(''), which causes all of the output to be directed to the printer. The default is \*(``0\*(''. .TP 8 .B "printerExtent\fP (class\fB PrinterExtent\fP)" Controls whether a print page function will print the entire page (true), or only the portion within the scrolling margins (false). The default is \*(``false\*(''. .TP 8 .B "printerFormFeed\fP (class\fB PrinterFormFeed\fP)" Controls whether a form feed is sent to the printer at the end of a print page function. The default is \*(``false\*(''. .TP 8 .B "printerNewLine\fP (class\fB PrinterNewLine\fP)" Controls whether a newline is sent to the printer at the end of a print page function. The default is \*(``true\*(''. .TP 8 .B "privateColorRegisters\fP (class\fB PrivateColorRegisters\fP)" If \fI\*n\fR is configured to support ReGIS or SIXEL graphics, this controls whether \fI\*n\fR allocates separate color registers for each sixel device control string, e.g., for DECGCI. If not true, color registers are allocated only once, when the terminal is reset, and color changes in any graphic affect all graphics. The default is \*(``true\*(''. .TP 8 .B "quietGrab\fP (class\fB QuietGrab\fP)" Controls whether the cursor is repainted when \fINotifyGrab\fP and \fINotifyUngrab\fP event types are received during change of focus. The default is \*(``false\*(''. .TP 8 .B "regisDefaultFont\fP (class\fB RegisDefaultFont\fP)" If \fI\*n\fR is configured to support ReGIS graphics, this resource tells \fI\*n\fR which font to use if the ReGIS data does not specify one. No default value is specified; \fI\*n\fR accepts a TrueType font specification as in the \fBfaceName\fP resource. .IP If no value is specified, \fI\*n\fR draws a bitmap indicating a missing character. .TP 8 .B "regisScreenSize\fP (class\fB RegisScreenSize\fP)" If \fI\*n\fR is configured to support ReGIS graphics, this resource tells \fI\*n\fR the default size (in pixels) for these graphics, which also sets the default coordinate space to [0,0] (upper-left) and [\fIwidth\fP,\fIheight\fP] (lower-right). .IP The application using ReGIS may use the \*(``A\*('' option of the \*(``S\*('' command to adjust the coordinate space or change the addressable portion of the screen. .IP The default is \*(``1000x1000\*('' (given as \fIwidth\fP by \fIheight\fP). .IP \fI\*N\fR accepts a special resource value \*(``auto\*('', which tells \fI\*n\fR to use the \fBdecTerminalID\fP resource to set the default size based on the hardware terminal's limits. Those limits are the same as for the \fBmaxGraphicSize\fP resource. .TP 8 .B "renderFont\fP (class\fB RenderFont\fP)" If \fI\*n\fR is built with the Xft library, this controls whether the \fBfaceName\fR resource is used. The default is \*(``default\*(''. .IP The resource values are strings, evaluated as booleans after startup. .RS .TP 5 false .br disable the feature and use the normal (bitmap) font. .TP 5 true .br startup using the TrueType font specified by the \fBfaceName\fP and \fBfaceSize\fP resource settings. If there is no value for \fBfaceName\fP, disable the feature and use the normal (bitmap) font. .IP After startup, you can still switch to/from the bitmap font using the \*(``TrueType Fonts\*('' menu entry. .TP 5 default .br startup using the normal (bitmap) font, but enable the \*(``TrueType Fonts\*('' menu entry to allow runtime switching to/from TrueType fonts. .IP If there is no \fBfaceName\fP resource set, then runtime switching to TrueType fonts is disabled. \fI\*N\fP has a separate compiled-in value for \fBfaceName\fP for the special case where \fBrenderFont\fP is \*(``default\*(''. That is normally \*(``mono\*(''. .RE .TP 8 .B "resizeGravity\fP (class\fB ResizeGravity\fP)" Affects the behavior when the window is resized to be taller or shorter. \fBNorthWest\fP specifies that the top line of text on the screen stay fixed. If the window is made shorter, lines are dropped from the bottom; if the window is made taller, blank lines are added at the bottom. This is compatible with the behavior in R4. \fBSouthWest\fP (the default) specifies that the bottom line of text on the screen stay fixed. If the window is made taller, additional saved lines will be scrolled down onto the screen; if the window is made shorter, lines will be scrolled off the top of the screen, and the top saved lines will be dropped. .TP 8 .B "retryInputMethod\fP (class\fB RetryInputMethod\fP)" Tells \fI\*n\fP how many times to retry, in case the input-method server is not responding. This is a different issue than unsupported preedit type, etc. You may encounter retries if your X configuration (and its libraries) are missing pieces. Setting this resource to zero ``0'' will cancel the retrying. The default is ``3''. .TP 8 .B "reverseVideo\fP (class\fB ReverseVideo\fP)" Specifies whether or not reverse video should be simulated. The default is \*(``false\*(''. .IP There are several aspects to reverse video in \fI\*n\fP: .RS .bP The command-line \fB\-rv\fP option tells the X libraries to reverse the foreground and background colors. \fI\*N\fP's command-line options set resource values. In particular, the X Toolkit sets the \fBreverseVideo\fP resource when the \fB\-rv\fP option is used. .bP If the user has also used command-line options \fB\-fg\fP or \fB\-bg\fP to set the foreground and background colors, \fI\*n\fP does not see these options directly. Instead, it examines the resource values to reconstruct the command-line options, and determine which of the colors is the user's intended foreground, etc. Their actual values are irrelevant to the reverse video function; some users prefer the X defaults (black text on a white background), others prefer white text on a black background. .bP After startup, the user can toggle the \*(``Enable Reverse Video\*('' menu entry. This exchanges the current foreground and background colors of the VT100 widget, and repaints the screen. Because of the X resource hierarchy, the \fBreverseVideo\fP resource applies to more than the VT100 widget. .RE .IP Programs running in an \fI\*n\fP can also use control sequences to enable the VT100 reverse video mode. These are independent of the \fBreverseVideo\fP resource and the menu entry. \fI\*N\fP exchanges the current foreground and background colors when drawing text affected by these control sequences. .IP Other control sequences can alter the foreground and background colors which are used: .RS .bP Programs can also use the ANSI color control sequences to set the foreground and background colors. .bP Extensions to the ANSI color controls (such as 16-, 88- or 256-colors) are treated similarly to the ANSI control. .bP Using other control sequences (the \*(``\fIdynamic colors\fR\*('' feature), a program can change the foreground and background colors. .RE .TP 8 .B "reverseWrap\fP (class\fB ReverseWrap\fP)" Specifies whether or not reverse-wraparound should be enabled. This corresponds to \fI\*n\fP's private mode 45. The default is \*(``false\*(''. .TP 8 .B "rightScrollBar\fP (class\fB RightScrollBar\fP)" Specifies whether or not the scrollbar should be displayed on the right rather than the left. The default is \*(``false\*(''. .TP 8 .B "saveLines\fP (class\fB SaveLines\fP)" Specifies the number of lines to save beyond the top of the screen when a scrollbar is turned on. The default is \*(``64\*(''. .TP 8 .B "scrollBar\fP (class\fB ScrollBar\fP)" Specifies whether or not the scrollbar should be displayed. The default is \*(``false\*(''. .TP 8 .B "scrollBarBorder\fP (class\fB ScrollBarBorder\fP)" Specifies the width of the scrollbar border. Note that this is drawn to overlap the border of the \fI\*n\fP window. Modifying the scrollbar's border affects only the line between the VT100 widget and the scrollbar. The default value is 1. .TP 8 .B "scrollKey\fP (class\fB ScrollCond\fP)" Specifies whether or not pressing a key should automatically cause the scrollbar to go to the bottom of the scrolling region. This corresponds to \fI\*n\fP's private mode 1011. The default is \*(``false\*(''. .TP 8 .B "scrollLines\fP (class\fB ScrollLines\fP)" Specifies the number of lines that the \fBscroll-back\fP and \fBscroll-forw\fP actions should use as a default. The default value is 1. .TP 8 .B "scrollTtyOutput\fP (class\fB ScrollCond\fP)" Specifies whether or not output to the terminal should automatically cause the scrollbar to go to the bottom of the scrolling region. The default is \*(``true\*(''. .TP .B "selectToClipboard\fP (class\fB SelectToClipboard\fP)" Tells \fI\*n\fP whether to use the \fBPRIMARY\fP or \fBCLIPBOARD\fP for \fBSELECT\fP tokens in the selection mechanism. The \fBset-select\fP action can change this at runtime, allowing the user to work with programs that handle only one of these mechanisms. The default is \*(``false\*('', which tells it to use \fBPRIMARY\fP. .TP 8 .B "shiftFonts\fP (class\fB ShiftFonts\fP)" Specifies whether to enable the actions \fBlarger-vt-font()\fP and \fBsmaller-vt-font()\fP, which are normally bound to the shifted KP_Add and KP_Subtract. The default is \*(``true\*(''. .TP 8 .B "showBlinkAsBold\fP (class\fB ShowBlinkAsBold\fP)" Tells \fI\*n\fP whether to display text with blink-attribute the same as bold. If \fI\*n\fP has not been configured to support blinking text, the default is \*(``true\*('', which corresponds to older versions of \fI\*n\fP, otherwise the default is \*(``false\*(''. .TP 8 .B "showMissingGlyphs\fP (class\fB ShowMissingGlyphs\fP)" Tells \fI\*n\fP whether to display a box outlining places where a character has been used that the font does not represent. The default is \*(``false\*(''. .TP 8 .B "showWrapMarks\fP (class\fB ShowWrapMarks\fP)" For debugging \fI\*n\fP and applications that may manipulate the wrapped-line flag by writing text at the right margin, show a mark on the right inner-border of the window. The mark shows which lines have the flag set. .TP 8 .B "signalInhibit\fP (class\fB SignalInhibit\fP)" Specifies whether or not the entries in the \fBMain Options\fP menu for sending signals to \fI\*n\fP should be disallowed. The default is \*(``false\*(''. .TP 8 .B "sixelScrolling\fP (class\fB SixelScrolling\fP)" If \fI\*n\fR is configured to support SIXEL graphics, this resource tells it whether to scroll up one line at a time when sixels would be written past the bottom line on the window. The default is \*(``false\*(''. .TP 8 .B "sixelScrollsRight\fP (class\fB SixelScrollsRight\fP)" If \fI\*n\fR is configured to support SIXEL graphics, this resource tells it whether to scroll to the right as needed to keep the current position visible rather than truncate the plot on the on the right. The default is \*(``false\*(''. .TP 8 .B "tekGeometry\fP (class\fB Geometry\fP)" Specifies the preferred size and position of the Tektronix window. There is no default for this resource. .TP 8 .B "tekInhibit\fP (class\fB TekInhibit\fP)" Specifies whether or not the escape sequence to enter Tektronix mode should be ignored. The default is \*(``false\*(''. .TP 8 .B "tekSmall\fP (class\fB TekSmall\fP)" Specifies whether or not the Tektronix mode window should start in its smallest size if no explicit geometry is given. This is useful when running \fI\*n\fP on displays with small screens. The default is \*(``false\*(''. .TP 8 .B "tekStartup\fP (class\fB TekStartup\fP)" Specifies whether or not \fI\*n\fP should start up in Tektronix mode. The default is \*(``false\*(''. .TP 8 .B "tiXtraScroll\fP (class\fB TiXtraScroll\fP)" Specifies whether \fI\*n\fP should scroll to a new page when processing the \fIti\fP termcap entry, i.e., the private modes 47, 1047 or 1049. This is only in effect if \fBtiteInhibit\fP is \*(``true\*('', because the intent of this option is to provide a picture of the full-screen application's display on the scrollback without wiping out the text that would be shown before the application was initialized. The default for this resource is \*(``false\*(''. .TP 8 .B "titeInhibit\fP (class\fB TiteInhibit\fP)" Originally specified whether or not \fI\*n\fP should remove \fIti\fP and \fIte\fP termcap entries (used to switch between alternate screens on startup of many screen-oriented programs) from the TERMCAP string. .IP TERMCAP is used rarely now, but \fI\*n\fP supports the feature on modern systems: .RS .bP If set, \fI\*n\fP also ignores the escape sequence to switch to the alternate screen. .bP \fI\*N\fP supports terminfo in a different way, supporting composite control sequences (also known as private modes) 1047, 1048 and 1049 which have the same effect as the original 47 control sequence. .RE .IP The default for this resource is \*(``false\*(''. .TP 8 .B "titleModes\fP (class\fB TitleModes\fP)" Tells \fI\*n\fP whether to accept or return window- and icon-labels in ISO-8859-1 (the default) or UTF-8. Either can be encoded in hexadecimal. The default for this resource is \*(``0\*(''. .IP Each bit (bit \*(``0\*('' is 1, bit \*(``1\*('' is 2, etc.) corresponds to one of the parameters set by the title modes control sequence: .RS .TP 5 0 Set window/icon labels using hexadecimal .TP 5 1 Query window/icon labels using hexadecimal .TP 5 2 Set window/icon labels using UTF-8 (overrides \fButf8Title\fP resource). .TP 5 3 Query window/icon labels using UTF-8 .RE .TP 8 .B "translations\fP (class\fB Translations\fP)" Specifies the key and button bindings for menus, selections, \*(``programmed strings\*('', etc. The \fBtranslations\fP resource, which provides much of \fI\*n\fP's configurability, is a feature of the X Toolkit Intrinsics library (Xt). See the \fBActions\fP section. .TP 8 .B "trimSelection\fP (class\fB TrimSelection\fP)" If you set \fBhighlightSelection\fP, you can see the text which is selected, including any trailing spaces. Clearing the screen (or a line) resets it to a state containing no spaces. Some lines may contain trailing spaces when an application writes them to the screen. However, you may not wish to paste lines with trailing spaces. If this resource is true, \fI\*n\fP will trim trailing spaces from text which is selected. It does not affect spaces which result in a wrapped line, nor will it trim the trailing newline from your selection. The default is \*(``false\*(''. .TP 8 .B "underLine\fP (class\fB UnderLine\fP)" This specifies whether or not text with the underline attribute should be underlined. It may be desirable to disable underlining when color is being used for the underline attribute. The default is \*(``true\*(''. .TP 8 .B "useClipping\fP (class\fB UseClipping\fP)" Tell \fI\*n\fP whether to use clipping to keep from producing dots outside the text drawing area. Originally used to work around for overstriking effects, this is also needed to work with some incorrectly-sized fonts. The default is \*(``true\*(''. .TP 8 .B "utf8\fP (class\fB Utf8\fP)" This specifies whether \fI\*n\fP will run in UTF-8 mode. If you set this resource, \fI\*n\fP also sets the \fBwideChars\fP resource as a side-effect. The resource can be set via the menu entry \*(``UTF-8 Encoding\*(''. The default is \*(``default\*(''. .IP \fI\*N\fP accepts either a keyword (ignoring case) or the number shown in parentheses: .RS .TP 3 false (0) UTF-8 mode is initially off. The command-line option \fB+u8\fP sets the resource to this value. Escape sequences for turning UTF-8 mode on/off are allowed. .TP true (1) UTF-8 mode is initially on. Escape sequences for turning UTF-8 mode on/off are allowed. .TP always (2) The command-line option \fB\-u8\fP sets the resource to this value. Escape sequences for turning UTF-8 mode on/off are ignored. .TP default (3) This is the default value of the resource. It is changed during initialization depending on whether the \fBlocale\fP resource was set, to false (0) or always (2). See the \fBlocale\fR resource for additional discussion of non-UTF-8 locales. .RE .IP If you want to set the value of \fButf8\fP, it should be in this range. Other nonzero values are treated the same as \*(``1\*('', i.e., UTF-8 mode is initially on, and escape sequences for turning UTF-8 mode on/off are allowed. .TP 8 .B "utf8Fonts\fP (class\fB Utf8Fonts\fP)" See the discussion of the \fBlocale\fP resource. This specifies whether \fI\*n\fP will use UTF-8 fonts specified via resource patterns such as \*(``\fB*vt100.utf8Fonts.font\fP\*('' or normal (ISO-8859-1) fonts via patterns such as \*(``\fB*vt100.font\fP\*(''. The resource can be set via the menu entry \*(``\fBUTF-8 Fonts\fP\*(''. The default is \*(``default\*(''. .IP \fI\*N\fP accepts either a keyword (ignoring case) or the number shown in parentheses: .RS .TP false (0) Use the ISO-8859-1 fonts. The menu entry is enabled, allowing the choice of fonts to be changed at runtime. .TP true (1) Use the UTF-8 fonts. The menu entry is enabled, allowing the choice of fonts to be changed at runtime. .TP always (2) Always use the UTF-8 fonts. This also disables the menu entry. .TP default (3) At startup, the resource is set to true or false, according to the effective value of the \fButf8\fP resource. .RE .TP 8 .B "utf8Latin1\fP (class\fB Utf8Latin1\fP)" If true, allow an ISO-8859-1 \fInormal\fP font to be combined with an ISO-10646-1 font if the latter is given via the \fB\-fw\fP option or its corresponding resource value. The default is \*(``false\*(''. .TP 8 .B "utf8SelectTypes\fP (class\fB Utf8SelectTypes\fP)" Override \fI\*n\fP's default selection target list (see \fBSELECT/PASTE\fP) for selections in wide-character (UTF-8) mode. The default is an empty string, i.e., \*(``\*('', which does not override anything. .TP 8 .B "utf8Title\fP (class\fB Utf8Title\fP)" Applications can set \fI\*n\fP's title by writing a control sequence. Normally this control sequence follows the VT220 convention, which encodes the string in ISO-8859-1 and allows for an 8-bit string terminator. If \fI\*n\fP is started in a UTF-8 locale, it translates the ISO-8859-1 string to UTF-8 to work with the X libraries which assume the string is UTF-8. .IP However, some users may wish to write a title string encoded in UTF-8. The window manager is responsible for drawing window titles. Some window managers (not all) support UTF-8 encoding of window titles. Set this resource to \*(``true\*('' to allow UTF-8 encoded title strings. That cancels the translation to UTF-8, allowing UTF-8 strings to be displayed as is. .IP This feature is available as a menu entry, since it is related to the particular applications you are running within \fI\*n\fP. You can also use a control sequence (see the discussion of \*(``Title Modes\*('' in \fI\*N Control Sequences\fP), to set an equivalent flag. The \fBtitleModes\fP resource sets the same value, which overrides this resource. .IP The default is \*(``false\*(''. .TP 8 .B "veryBoldColors\fP (class\fB VeryBoldColors\fP)" Specifies whether to combine video attributes with colors specified by \fBcolorBD\fR, \fBcolorBL\fR, \fBcolorIT\fR, \fBcolorRV\fR, and \fBcolorUL\fR. The resource value is the sum of values for each attribute: .RS 10 .nf 1 for reverse, 2 for underline, 4 for bold, 8 for blink, and 512 for italic .fi .RE .IP The default is \*(``0\*(''. .TP 8 .B "visualBell\fP (class\fB VisualBell\fP)" Specifies whether or not a visible bell (i.e., flashing) should be used instead of an audible bell when Control-G is received. The default is \*(``false\*('', which tells \fI\*n\fP to use an audible bell. .TP 8 .B "visualBellDelay\fP (class\fB VisualBellDelay\fP)" Number of milliseconds to delay when displaying a visual bell. Default is 100. If set to zero, no visual bell is displayed. This is useful for very slow displays, e.g., an LCD display on a laptop. .TP 8 .B "visualBellLine\fP (class\fB VisualBellLine\fP)" Specifies whether to flash only the current line when displaying a visual bell rather than flashing the entire screen: The default is \*(``false\*('', which tells \fI\*n\fP to flash the entire screen. .TP 8 .B "vt100Graphics\fP (class\fB VT100Graphics\fP)" This specifies whether \fI\*n\fP will interpret VT100 graphic character escape sequences while in UTF-8 mode. The default is \*(``true\*('', to provide support for various legacy applications. .TP 8 .B "wideBoldFont\fP (class\fB WideBoldFont\fP)" This option specifies the font to be used for displaying bold wide text. By default, it will attempt to use a font twice as wide as the font that will be used to draw bold text. If no double-width font is found, it will improvise, by stretching the bold font. .TP 8 .B "wideChars\fP (class\fB WideChars\fP)" Specifies if \fI\*n\fP should respond to control sequences that process 16-bit characters. The default is \*(``false\*(''. .TP 8 .B "wideFont\fP (class\fB WideFont\fP)" This option specifies the font to be used for displaying wide text. By default, it will attempt to use a font twice as wide as the font that will be used to draw normal text. If no double-width font is found, it will improvise, by stretching the normal font. .TP 8 .B "ximFont\fP (class\fB XimFont\fP)" This option specifies the font to be used for displaying the preedit string in the \*(``OverTheSpot\*('' input method. .IP In \*(``OverTheSpot\*('' preedit type, the preedit (preconversion) string is displayed at the position of the cursor. It is the XIM server's responsibility to display the preedit string. The XIM client must inform the XIM server of the cursor position. For best results, the preedit string must be displayed with a proper font. Therefore, \fI\*n\fP informs the XIM server of the proper font. The font is be supplied by a "fontset", whose default value is \*(``*\*(''. This matches every font, the X library automatically chooses fonts with proper charsets. The \fBximFont\fP resource is provided to override this default font setting. .\" .SS Tek4014 Widget Resources .PP The following resources are specified as part of the \fItek4014\fP widget (class \fITek4014\fP). These are specified by patterns such as \*(``\fB__default_class__.tek4014.\fP\fINAME\fP\*('': .TP 8 .B "font2\fP (class\fB Font\fP)" Specifies font number 2 to use in the Tektronix window. .TP 8 .B "font3\fP (class\fB Font\fP)" Specifies font number 3 to use in the Tektronix window. .TP 8 .B "fontLarge\fP (class\fB Font\fP)" Specifies the large font to use in the Tektronix window. .TP 8 .B "fontSmall\fP (class\fB Font\fP)" Specifies the small font to use in the Tektronix window. .TP 8 .B "ginTerminator\fP (class\fB GinTerminator\fP)" Specifies what character(s) should follow a GIN report or status report. The possibilities are \*(``none\*('', which sends no terminating characters, \*(``CRonly\*('', which sends CR, and \*(``CR&EOT\*('', which sends both CR and EOT. The default is \*(``none\*(''. .TP 8 .B "height\fP (class\fB Height\fP)" Specifies the height of the Tektronix window in pixels. .TP 8 .B "initialFont\fP (class\fB InitialFont\fP)" Specifies which of the four Tektronix fonts to use initially. Values are the same as for the \fBset-tek-text\fP action. The default is \*(``large\*(''. .TP 8 .B "width\fP (class\fB Width\fP)" Specifies the width of the Tektronix window in pixels. .\" .SS Menu Resources .PP The resources that may be specified for the various menus are described in the documentation for the Athena \fBSimpleMenu\fP widget. The name and classes of the entries in each of the menus are listed below. Resources named \*(``\fBline\fR\fIN\fR\*('' where \fIN\fR is a number are separators with class \fBSmeLine\fR. .PP As with all X resource-based widgets, the labels mentioned are customary defaults for the application. . .PP The \fBMain Options\fP menu (widget name \fImainMenu\fP) has the following entries: .TP 8 .B "toolbar\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-toolbar(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "securekbd\fP (class\fB SmeBSB\fP)" This entry invokes the \fBsecure()\fP action. .TP 8 .B "allowsends\fP (class\fB SmeBSB\fP)" This entry invokes the \fBallow-send-events(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "redraw\fP (class\fB SmeBSB\fP)" This entry invokes the \fBredraw()\fP action. .TP 8 .B "logging\fP (class\fB SmeBSB\fP)" This entry invokes the \fBlogging(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "print-immediate\fP (class\fB SmeBSB\fP)" This entry invokes the \fBprint-immediate()\fP action. .TP 8 .B "print-on-error\fP (class\fB SmeBSB\fP)" This entry invokes the \fBprint-on-error()\fP action. .TP 8 .B "print\fP (class\fB SmeBSB\fP)" This entry invokes the \fBprint()\fP action. .TP 8 .B "print-redir\fP (class\fB SmeBSB\fP)" This entry invokes the \fBprint-redir()\fP action. .TP 8 .B "dump-html\fP (class\fB SmeBSB\fP)" This entry invokes the \fBdump-html()\fP action. .TP 8 .B "dump-svg\fP (class\fB SmeBSB\fP)" This entry invokes the \fBdump-svg()\fP action. .TP 8 .B "8-bit-control\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-8-bit-control(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "backarrow\ key\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-backarrow(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "num-lock\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-num-lock(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "alt-esc\fP (class\fB SmeBSB\fP)" This entry invokes the \fBalt-sends-escape(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "meta-esc\fP (class\fB SmeBSB\fP)" This entry invokes the \fBmeta-sends-escape(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "delete-is-del\fP (class\fB SmeBSB\fP)" This entry invokes the \fBdelete-is-del(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "oldFunctionKeys\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-old-function-keys(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "hpFunctionKeys\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-hp-function-keys(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "scoFunctionKeys\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-sco-function-keys(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "sunFunctionKeys\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-sun-function-keys(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "sunKeyboard\fP (class\fB SmeBSB\fP)" This entry invokes the \fBsunKeyboard(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "suspend\fP (class\fB SmeBSB\fP)" This entry invokes the \fBsend-signal(\fP\fItstp\fP\fB)\fP action on systems that support job control. .TP 8 .B "continue\fP (class\fB SmeBSB\fP)" This entry invokes the \fBsend-signal(\fP\fIcont\fP\fB)\fP action on systems that support job control. .TP 8 .B "interrupt\fP (class\fB SmeBSB\fP)" This entry invokes the \fBsend-signal(\fP\fIint\fP\fB)\fP action. .TP 8 .B "hangup\fP (class\fB SmeBSB\fP)" This entry invokes the \fBsend-signal(\fP\fIhup\fP\fB)\fP action. .TP 8 .B "terminate\fP (class\fB SmeBSB\fP)" This entry invokes the \fBsend-signal(\fP\fIterm\fP\fB)\fP action. .TP 8 .B "kill\fP (class\fB SmeBSB\fP)" This entry invokes the \fBsend-signal(\fP\fIkill\fP\fB)\fP action. .TP 8 .B "quit\fP (class\fB SmeBSB\fP)" This entry invokes the \fBquit()\fP action. . .PP The \fBVT Options\fP menu (widget name \fIvtMenu\fP) has the following entries: .TP 8 .B "scrollbar\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-scrollbar(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "jumpscroll\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-jumpscroll(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "reversevideo\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-reverse-video(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "autowrap\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-autowrap(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "reversewrap\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-reversewrap(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "autolinefeed\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-autolinefeed(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "appcursor\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-appcursor(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "appkeypad\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-appkeypad(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "scrollkey\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-scroll-on-key(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "scrollttyoutput\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-scroll-on-tty-output(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "allow132\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-allow132(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "cursesemul\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-cursesemul(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "keepSelection\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-keep-selection(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "selectToClipboard\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-keep-clipboard(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "visualbell\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-visual-bell(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "bellIsUrgent\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-bellIsUrgent(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "poponbell\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-pop-on-bell(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "cursorblink\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-cursorblink(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "titeInhibit\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-titeInhibit(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "activeicon\fP (class\fB SmeBSB\fP)" This entry toggles active icons on and off if this feature was compiled into \fI\*n\fP. It is enabled only if \fI\*n\fP was started with the command line option +ai or the \fBactiveIcon\fP resource is set to \*(``true\*(''. .TP 8 .B "softreset\fP (class\fB SmeBSB\fP)" This entry invokes the \fBsoft-reset()\fP action. .TP 8 .B "hardreset\fP (class\fB SmeBSB\fP)" This entry invokes the \fBhard-reset()\fP action. .TP 8 .B "clearsavedlines\fP (class\fB SmeBSB\fP)" This entry invokes the \fBclear-saved-lines()\fP action. .TP 8 .B "tekshow\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-visibility(\fP\fItek,toggle\fP\fB)\fP action. .TP 8 .B "tekmode\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-terminal-type(\fP\fItek\fP\fB)\fP action. .TP 8 .B "vthide\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-visibility(\fP\fIvt,off\fP\fB)\fP action. .TP 8 .B "altscreen\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-altscreen(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "sixelScrolling\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-sixel-scrolling(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "privateColorRegisters\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-private-colors(\fP\fItoggle\fP\fB)\fP action. . .PP The \fBVT Fonts\fP menu (widget name \fIfontMenu\fP) has the following entries: .TP 8 .B "fontdefault\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-vt-font(\fP\fId\fP\fB)\fP action, setting the font using the \fBfont\fP (default) resource, e.g., \*(``Default\*('' in the menu. .TP 8 .B "font1\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-vt-font(\fP\fI1\fP\fB)\fP action, setting the font using the \fBfont1\fP resource, e.g., \*(``Unreadable\*('' in the menu. .TP 8 .B "font2\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-vt-font(\fP\fI2\fP\fB)\fP action, setting the font using the \fBfont2\fP resource, e.g., \*(``Tiny\*('' in the menu. .TP 8 .B "font3\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-vt-font(\fP\fI3\fP\fB)\fP action, setting the font using the \fBfont3\fP resource, e.g., \*(``Small\*('' in the menu. .TP 8 .B "font4\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-vt-font(\fP\fI4\fP\fB)\fP action, letting the font using the \fBfont4\fP resource, e.g., \*(``Medium\*('' in the menu. .TP 8 .B "font5\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-vt-font(\fP\fI5\fP\fB)\fP action, letting the font using the \fBfont5\fP resource, e.g., \*(``Large\*('' in the menu. .TP 8 .B "font6\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-vt-font(\fP\fI6\fP\fB)\fP action, letting the font using the \fBfont6\fP resource, e.g., \*(``Huge\*('' in the menu. .TP 8 .B "fontescape\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-vt-font(\fP\fIe\fP\fB)\fP action. .TP 8 .B "fontsel\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-vt-font(\fP\fIs\fP\fB)\fP action. .TP 8 .B "allow-bold-fonts\fP (class\fB SmeBSB\fP)" This entry invokes the \fBallow-bold-fonts(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "font-linedrawing\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-font-linedrawing(\fP\fIs\fP\fB)\fP action. .TP 8 .B "font-packed\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-font-packed(\fP\fIs\fP\fB)\fP action. .TP 8 .B "font-doublesize\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-font-doublesize(\fP\fIs\fP\fB)\fP action. .TP 8 .B "render-font\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-render-font(\fP\fIs\fP\fB)\fP action. .TP 8 .B "utf8-fonts\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-utf8-fonts(\fP\fIs\fP\fB)\fP action. .TP 8 .B "utf8-mode\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-utf8-mode(\fP\fIs\fP\fB)\fP action. .TP 8 .B "utf8-title\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-utf8-title(\fP\fIs\fP\fB)\fP action. .TP 8 .B "allow-color-ops\fP (class\fB SmeBSB\fP)" This entry invokes the \fBallow-color-ops(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "allow-font-ops\fP (class\fB SmeBSB\fP)" This entry invokes the \fBallow-fonts-ops(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "allow-tcap-ops\fP (class\fB SmeBSB\fP)" This entry invokes the \fBallow-tcap-ops(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "allow-title-ops\fP (class\fB SmeBSB\fP)" This entry invokes the \fBallow-title-ops(\fP\fItoggle\fP\fB)\fP action. .TP 8 .B "allow-window-ops\fP (class\fB SmeBSB\fP)" This entry invokes the \fBallow-window-ops(\fP\fItoggle\fP\fB)\fP action. . .PP The \fBTek Options\fP menu (widget name \fItekMenu\fP) has the following entries: .TP 8 .B "tektextlarge\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-tek-text(\fP\fIlarge\fP\fB)\fP action. .TP 8 .B "tektext2\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-tek-text(\fP\fI2\fP\fB)\fP action. .TP 8 .B "tektext3\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-tek-text(\fP\fI3\fP\fB)\fP action. .TP 8 .B "tektextsmall\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-tek-text(\fP\fIsmall\fP\fB)\fP action. .TP 8 .B "tekpage\fP (class\fB SmeBSB\fP)" This entry invokes the \fBtek-page()\fP action. .TP 8 .B "tekreset\fP (class\fB SmeBSB\fP)" This entry invokes the \fBtek-reset()\fP action. .TP 8 .B "tekcopy\fP (class\fB SmeBSB\fP)" This entry invokes the \fBtek-copy()\fP action. .TP 8 .B "vtshow\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-visibility(\fP\fIvt,toggle\fP\fB)\fP action. .TP 8 .B "vtmode\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-terminal-type(\fP\fIvt\fP\fB)\fP action. .TP 8 .B "tekhide\fP (class\fB SmeBSB\fP)" This entry invokes the \fBset-visibility(\fP\fItek,toggle\fP\fB)\fP action. .\" .SS Scrollbar Resources .PP The following resources are useful when specified for the Athena Scrollbar widget: .TP 8 .B "thickness\fP (class\fB Thickness\fP)" Specifies the width in pixels of the scrollbar. .TP 8 .B "background\fP (class\fB Background\fP)" Specifies the color to use for the background of the scrollbar. .TP 8 .B "foreground\fP (class\fB Foreground\fP)" Specifies the color to use for the foreground of the scrollbar. The \*(``thumb\*('' of the scrollbar is a simple checkerboard pattern alternating pixels for foreground and background color. . . .SH "POINTER USAGE" . .PP Once the VT\fIxxx\fP window is created, .I \*n allows you to select text and copy it within the same or other windows using the \fIpointer\fP or the keyboard. . .PP A \*(``pointer\*('' could be a mouse, touchpad or similar device. X applications generally do not care, since they see only \fIbutton events\fP which have .bP position and .bP button up/down state .PP \fI\*N\fP can see these events as long as it has \fIfocus\fP. .PP The keyboard also supplies events, but it is less flexible than the pointer for selecting/copying text. .PP \fIEvents\fP are applied to \fIactions\fP using the \fBtranslations\fP resource. See \fBActions\fP for a complete list, and \fBDefault Key Bindings\fP for the built-in set of \fBtranslations\fP resources. . .SS "Selection Functions" .PP The selection functions are invoked when the pointer buttons are used with no modifiers, and when they are used with the \*(``shift\*('' key. The assignment of the functions described below to keys and buttons may be changed through the resource database; see \fBActions\fP below. . .TP 5 Pointer button one (usually left) is used to save text into the cut buffer: .NS ~Meta :\fBselect-start\fP() .NE .IP Move the cursor to beginning of the text, and then hold the button down while moving the cursor to the end of the region and releasing the button. The selected text is highlighted and is saved in the global \fIcut buffer\fP and made the selection when the button is released: .NS :\fBselect-end\fP(\fBSELECT\fP, CUT_BUFFER0) \n\ .NE .IP Normally (but see the discussion of \fBon2Clicks\fP, etc): .RS .bP Double-clicking selects by words. .bP Triple-clicking selects by lines. .bP Quadruple-clicking goes back to characters, etc. .RE .IP Multiple-click is determined by the time from button up to button down, so you can change the selection unit in the middle of a selection. Logical words and lines selected by double- or triple-clicking may wrap across more than one screen line if lines were wrapped by \fI\*n\fP itself rather than by the application running in the window. If the key/button bindings specify that an X selection is to be made, \fI\*n\fP will leave the selected text highlighted for as long as it is the selection owner. . .TP 5 Pointer button two (usually middle) \*(``types\*('' (\fIpastes\fP) the text from the given selection, if any, otherwise from the cut buffer, inserting it as keyboard input: .NS ~Ctrl ~Meta :\fB\fBinsert-selection\fP\fP(\fBSELECT\fP, CUT_BUFFER0) .NE . .TP 5 Pointer button three (usually right) \fIextends\fP the current selection. .NS ~Ctrl ~Meta :\fB\fBstart-extend\fP\fP() .NE .IP (Without loss of generality, you can swap \*(``right\*('' and \*(``left\*('' everywhere in the rest of this paragraph.) If pressed while closer to the right edge of the selection than the left, it extends/contracts the right edge of the selection. If you contract the selection past the left edge of the selection, .I \*n assumes you really meant the left edge, restores the original selection, then extends/contracts the left edge of the selection. Extension starts in the selection unit mode that the last selection or extension was performed in; you can multiple-click to cycle through them. . .PP By cutting and pasting pieces of text without trailing new lines, you can take text from several places in different windows and form a command to the shell, for example, or take output from a program and insert it into your favorite editor. Since cut buffers are globally shared among different applications, you may regard each as a \*(``file\*('' whose contents you know. The terminal emulator and other text programs should be treating it as if it were a text file, i.e., the text is delimited by new lines. . .SS "Scrolling" .PP The scroll region displays the position and amount of text currently showing in the window (highlighted) relative to the amount of text actually saved. As more text is saved (up to the maximum), the size of the highlighted area decreases. . .PP Clicking button one with the pointer in the scroll region moves the adjacent line to the top of the display window. . .PP Clicking button three moves the top line of the display window down to the pointer position. . .PP Clicking button two moves the display to a position in the saved text that corresponds to the pointer's position in the scrollbar. . .SS "Tektronix Pointer" .PP Unlike the VT\fIxxx\fP window, the Tektronix window does not allow the copying of text. It does allow Tektronix GIN mode, and in this mode the cursor will change from an arrow to a cross. Pressing any key will send that key and the current coordinate of the cross cursor. Pressing button one, two, or three will return the letters \*(``l\*('', \*(``m\*('', and \*(``r\*('', respectively. If the \*(``shift\*('' key is pressed when a pointer button is pressed, the corresponding upper case letter is sent. To distinguish a pointer button from a key, the high bit of the character is set (but this is bit is normally stripped unless the terminal mode is RAW; see .IR tty (4) for details). . . .SH SELECT/PASTE X clients provide select and paste support by responding to requests conveyed by the server. .SS PRIMARY When configured to use the primary selection, (the default) \fI\*n\fP can provide the selection data in ways which help to retain character encoding information as it is pasted. .PP A user \*(``selects\*('' text on \*n, which highlights the selected text. A subsequent \*(``paste\*('' to another client forwards a request to the client owning the selection. If \fI\*n\fP owns the primary selection, it makes the data available in the form of one or more \*(``selection targets\*(''. If it does not own the primary selection, e.g., if it has released it or another client has asserted ownership, it relies on cut-buffers to pass the data. But cut-buffers handle only ISO-8859-1 data (officially \- some clients ignore the rules). . .SS CLIPBOARD When configured to use the clipboard (using the \fBselectToClipboard\fP resource), the problem with persistence of ownership is bypassed. Otherwise, there is no difference regarding the data which can be passed via selection. .PP The \fBPRIMARY\fP token is a standard X feature, documented in the ICCCM (\fIInter-Client Communication Conventions Manual\fR), which states .RS .PP The selection named by the atom \fBPRIMARY\fP is used for all commands that take only a single argument and is the principal means of communication between clients that use the selection mechanism. .RE .SS SELECT .PP However, many applications use \fBCLIPBOARD\fP in imitation of other windowing systems. The \fBselectToClipboard\fP resource (and corresponding menu entry \fBSelect to Clipboard\fP) introduce the SELECT token (known only to \fI\*n\fP) which chooses between the \fBPRIMARY\fP and \fBCLIPBOARD\fP tokens. .PP Without using this feature, one can use workarounds such as the \fIxclip\fP program to show the contents of the X clipboard within an \fI\*n\fP window. . .SS Selection Targets The different types of data which are passed depend on what the receiving client asks for. These are termed \fIselection targets\fP. .PP When asking for the selection data, \fI\*n\fP tries the following types in this order: .RS 5 .TP 5 UTF8_STRING This is an XFree86 extension, which denotes that the data is encoded in UTF-8. When \fI\*n\fP is built with wide-character support, it both accepts and provides this type. .TP 5 TEXT the text is in the encoding which corresponds to your current locale. .TP 5 .\" see xc/doc/specs/CTEXT/ctext.tbl.ms .\" (it says the data is stored as a type of ISO 2022) COMPOUND_TEXT this is a format for multiple character set data, such as multi-lingual text. It can store UTF-8 data as a special case. .TP 5 STRING This is Latin 1 (ISO-8859-1) data. .RE .PP The middle two (TEXT and COMPOUND_TEXT) are added if \fI\*n\fP is configured with the \fBi18nSelections\fP resource set to \*(``true\*(''. .PP UTF8_STRING is preferred (therefore first in the list) since \fI\*n\fP stores text as Unicode data when running in wide-character mode, and no translation is needed. On the other hand, TEXT and COMPOUND_TEXT may require translation. If the translation is incomplete, they will insert X's \*(``defaultString\*('' whose value cannot be set, and may simply be empty. \fI\*N\fP's \fBdefaultString\fP resource specifies the string to use for incomplete translations of the UTF8_STRING. .PP You can alter the types which \fI\*n\fP tries using the \fBeightBitSelectTypes\fP or \fButf8SelectTypes\fP resources. For instance, you might have some specific locale setting which does not use UTF-8 encoding. The resource value is a comma-separated list of the selection targets, which consist of the names shown. You can use the special name I18N to denote the optional inclusion of TEXT and COMPOUND_TEXT. The names are matched ignoring case, and can be abbreviated. The default list can be expressed in several ways, e.g., .sp .RS .nf UTF8_STRING,I18N,STRING utf8,i18n,string u,i,s .fi .RE . .SS Mouse Protocol .PP Applications can send escape sequences to \fI\*n\fP to cause it to send escape sequences back to the computer when you press a pointer button, or even (depending on which escape sequence) send escape sequences back to the computer as you move the pointer. .PP These escape sequences and the responses, called the \fImouse protocol\fP, are documented in \fIXTerm Control Sequences\fP. They do not appear in the \fIactions\fP invoked by the \fBtranslations\fP resource because the resource does not change while you run \fI\*n\fP, whereas applications can change the mouse prototol (i.e., enable, disable, use different modes). .PP However, the mouse protocol is interpreted within the \fIactions\fP that are usually associated with the pointer buttons. \fI\*N\fP ignores the mouse protocol in the \fBinsert-selection\fP action if the shift-key is pressed at the same time. It also modifies a few other actions if the shift-key is pressed, e.g., suppressing the response with the pointer position, though not eliminating changes to the selected text. . .SH MENUS . .PP \fI\*N\fP has four menus, named .IR mainMenu , .IR vtMenu , .IR fontMenu , and .IR tekMenu . Each menu pops up under the correct combinations of key and button presses. Each menu is divided into sections, separated by a horizontal line. Some menu entries correspond to modes that can be altered. A check mark appears next to a mode that is currently active. Selecting one of these modes toggles its state. Other menu entries are commands; selecting one of these performs the indicated function. .PP All of the menu entries correspond to X actions. In the list below, the menu label is shown followed by the action's name in parenthesis. . .\" ************************************************************************ .SS "Main Options" .PP The \fI\*n\fP \fImainMenu\fP pops up when the \*(``control\*('' key and pointer button one are pressed in a window. This menu contains items that apply to both the VT\fIxxx\fP and Tektronix windows. There are several sections: .TP Commands for managing X events: .RS .TP .B Toolbar\fP (resource \fBtoolbar\fP) Clicking on the \*(``Toolbar\*('' menu entry hides the toolbar if it is visible, and shows it if it is not. .TP .B Secure Keyboard\fP (resource \fBsecurekbd\fP) The \fBSecure Keyboard\fP mode is helpful when typing in passwords or other sensitive data in an unsecure environment (see \fBSECURITY\fP below, but read the limitations carefully). .TP .B Allow SendEvents\fP (resource \fBallowsends\fP) Specifies whether or not synthetic key and button events generated using the X protocol SendEvent request should be interpreted or discarded. This corresponds to the \fBallowSendEvents\fP resource. .TP .B Redraw Window\fP (resource \fBredraw\fP) Forces the X display to repaint; useful in some environments. .RE .TP Commands for capturing output: .RS .TP .B Log to File\fP (resource \fBlogging\fP) Captures text sent to the screen in a logfile, as in the \fB\-l\fP logging option. .TP .B Print-All Immediately\fP (resource \fBprint-immediate\fP) Invokes the \fBprint-immediate\fP action, sending the text of the current window directly to a file, as specified by the \fBprintFileImmediate\fP, \fBprintModeImmediate\fP and \fBprintOptsImmediate\fP resources. .TP .B Print-All on Error\fP (resource \fBprint-on-error\fP) Invokes the \fBprint-on-error\fP action, which toggles a flag telling \fI\*n\fP that if it exits with an X error, to send the text of the current window directly to a file, as specified by the \fBprintFileOnXError\fP, \fBprintModeOnXError\fP and \fBprintOptsOnXError\fP resources. .TP .B Print Window\fP (resource \fBprint\fP) Sends the text of the current window to the program given in the \fBprinterCommand\fP resource. .TP .B Redirect to Printer\fP (resource \fBprint-redir\fP) This sets the \fBprinterControlMode\fR to 0 or 2. You can use this to turn the printer on as if an application had sent the appropriate control sequence. It is also useful for switching the printer off if an application turns it on without resetting the print control mode. .TP .B XHTML Screen Dump\fP (resource \fBdump-html\fP) Available only when compiled with screen dump support. Invokes the \fBdump-html\fP action. This creates an XHTML file matching the contents of the current screen, including the border, internal border, colors and most attributes: bold, italic, underline, faint, strikeout, reverse; blink is rendered as white-on-red; double underline is rendered the same as underline since there is no portable equivalent in CSS 2.2. .IP The font is whatever your browser uses for preformatted (
)
elements. The XHTML file references a cascading style sheet (CSS)
named \*(``\fBxterm.css\fP\*('' that you can create to select a font or
override properties.
.RS
.LP
The following CSS selectors are used with
the expected default behavior in the XHTML file:
.sp
\fI.ul\fP for underline,
.br
\fI.bd\fP for bold,
.br
\fI.it\fP for italic,
.br
\fI.st\fP for strikeout,
.br
\fI.lu\fP for strikeout combined with underline.
.LP
In addition you may use
.sp
\fI.ev\fP to affect even numbered lines and
.br
\fI.od\fP to affect odd numbered lines.
.RE
.IP
Attributes faint, reverse and blink are implemented as \fIstyle\fP attributes
setting color properties. All colors are specified as RGB percentages
in order to support displays with 10 bits per RGB.
.IP
The name of the file will be
.NS
\fBxterm.\fIyyyy\fB\.\fIMM\fB\.\fIdd\fB.\fIhh\fB.\fImm\fB.\fIss\fR\.xhtml
.NE
.IP
where
.IR yyyy ,
.IR MM ,
.IR dd ,
.IR hh ,
.I mm
and
.I ss
are the year, month, day, hour, minute and second when the screen dump was performed
(the file is created in the directory
.I \*n
is started in, or the home directory for a login
.IR \*n ).
.IP
The \fBdump-html\fP action can also be triggered using the Media Copy
control sequence CSI 1 0 i, for example from a shell script with
.NS
printf '\\033[10i'
.NE
.sp
Only the UTF-8 encoding is supported.
.TP
.B SVG Screen Dump\fP (resource \fBdump-svg\fP)
Available only when compiled with screen dump support.
Invokes the \fBdump-svg\fP action.
This creates a Scalable Vector Graphics (SVG) file matching
the contents of the current screen, including the border,
internal border, colors and most attributes: bold, italic,
underline, double underline, faint, strikeout, reverse;
blink is rendered as white-on-red.
The font is whatever your renderer uses for the \fImonospace\fP font-family.
All colors are specified as RGB percentages
in order to support displays with 10 bits per RGB.
.IP
The name of the file will be
.NS
\fBxterm.\fIyyyy\fB\.\fIMM\fB\.\fIdd\fB.\fIhh\fB.\fImm\fB.\fIss\fR\.svg
.NE
.IP
where
.IR yyyy ,
.IR MM ,
.IR dd ,
.IR hh ,
.I mm
and
.I ss
are the year, month, day, hour, minute and second when the screen dump was performed
(the file is created in the directory
.I \*n
is started in, or the home directory for a login
.IR \*n ).
.IP
The \fBdump-svg\fP action can also be triggered using the Media Copy
control sequence CSI 1 1 i, for example from a shell script with
.NS
printf '\\033[11i'
.NE
.sp
Only the UTF-8 encoding is supported.
.RE
.TP
Modes for setting keyboard style:
.RS
.TP
.B 8-Bit Controls\fP (resource \fB8-bit-control\fP)
Enabled for VT220 emulation, this controls whether \fI\*n\fP will send
8-bit control sequences rather than using 7-bit (ASCII) controls,
e.g., sending a byte in the range 128-159 rather than the escape character
followed by a second byte.
\fI\*N\fP always interprets both 8-bit and 7-bit control sequences
(see \fI\*N Control Sequences\fP).
This corresponds to the \fBeightBitControl\fP resource.
.TP
.B Backarrow Key (BS/DEL)\fP (resource \fBbackarrow\ key\fP)
Modifies the behavior of the backarrow key, making it transmit
either a backspace (8)
or delete (127) character.
This corresponds to the \fBbackarrowKey\fP resource.
.TP
.B Alt/NumLock Modifiers\fP (resource \fBnum-lock\fP)
Controls the treatment of Alt- and NumLock-key modifiers.
This corresponds to the \fBnumLock\fP resource.
.TP
.B Meta Sends Escape\fP (resource \fBmeta-esc\fP)
Controls whether \fIMeta\fP keys are converted into a two-character
sequence with the character itself preceded by ESC.
This corresponds to the \fBmetaSendsEscape\fP resource.
.TP
.B Delete is DEL\fP (resource \fBdelete-is-del\fP)
Controls whether the Delete key on the editing keypad should send DEL (127)
or the VT220-style Remove escape sequence.
This corresponds to the \fBdeleteIsDEL\fP resource.
.TP
.B Old Function-Keys\fP (resource \fBoldFunctionKeys\fP)
.TP
.B HP Function-Keys\fP (resource \fBhpFunctionKeys\fP)
.TP
.B SCO Function-Keys\fP (resource \fBscoFunctionKeys\fP)
.TP
.B Sun Function-Keys\fP (resource \fBsunFunctionKeys\fP)
.TP
.B VT220 Keyboard\fP (resource \fBsunKeyboard\fP)
These act as a radio-button, selecting one style for the keyboard layout.
The layout corresponds to more than one resource setting:
\fBsunKeyboard\fP,
\fBsunFunctionKeys\fP,
\fBscoFunctionKeys\fP and
\fBhpFunctionKeys\fP.
.RE
.TP
Commands for process signalling:
.RS
.TP
.B Send STOP Signal\fP (resource \fBsuspend\fP)
.TP
.B Send CONT Signal\fP (resource \fBcontinue\fP)
.TP
.B Send INT Signal\fP (resource \fBinterrupt\fP)
.TP
.B Send HUP Signal\fP (resource \fBhangup\fP)
.TP
.B Send TERM Signal\fP (resource \fBterminate\fP)
.TP
.B Send KILL Signal\fP (resource \fBkill\fP)
These send the SIGTSTP, SIGCONT, SIGINT, SIGHUP, SIGTERM and SIGKILL
signals respectively, to the process group of the process running under
.I \*n
(usually the shell).
The \fBSIGCONT\fP
function is especially useful if the user has accidentally typed CTRL-Z,
suspending the process.
.TP
.B Quit\fP (resource \fBquit\fP)
Stop processing X events except to support the \fB-hold\fP option,
and then send a SIGHUP signal to the
process group of the process running under
.I \*n
(usually the shell).
.RE
.PP
.
.\" ************************************************************************
.SS "VT Options"
.PP
The
.I \*n
.I vtMenu
sets various modes in the VT\fIxxx\fP emulation, and is popped up when the
\*(``control\*('' key and pointer button two are pressed in the VT\fIxxx\fP window.
.TP
VT\fIxxx\fP Modes:
.RS
.
.TP
.B Enable Scrollbar\fP (resource \fBscrollbar\fP)
Enable (or disable) the scrollbar.
This corresponds to the \fB\-sb\fP option and the \fBscrollBar\fP resource.
.
.TP
.B Enable Jump Scroll\fP (resource \fBjumpscroll\fP)
Enable (or disable) jump scrolling.
This corresponds to the \fB\-j\fP option and the \fBjumpScroll\fP resource.
.
.TP
.B Enable Reverse Video\fP (resource \fBreversevideo\fP)
Enable (or disable) reverse-video.
This corresponds to the \fB\-rv\fP option and the \fBreverseVideo\fP resource.
.
.TP
.B Enable Auto Wraparound\fP (resource \fBautowrap\fP)
Enable (or disable) auto-wraparound.
This corresponds to the \fB\-aw\fP option and the \fBautoWrap\fP resource.
.
.TP
.B Enable Reverse Wraparound\fP (resource \fBreversewrap\fP)
Enable (or disable) reverse wraparound.
This corresponds to the \fB\-rw\fP option and the \fBreverseWrap\fP resource.
.
.TP
.B Enable Auto Linefeed\fP (resource \fBautolinefeed\fP)
Enable (or disable) auto-linefeed.
This is the VT102 NEL function,
which causes the emulator to emit a linefeed after each carriage return.
There is no corresponding command-line option or resource setting.
.
.TP
.B Enable Application Cursor Keys\fP (resource \fBappcursor\fP)
Enable (or disable) application cursor keys.
This corresponds to the \fBappcursorDefault\fP resource.
There is no corresponding command-line option.
.
.TP
.B Enable Application Keypad\fP (resource \fBappkeypad\fP)
Enable (or disable) application keypad keys.
This corresponds to the \fBappkeypadDefault\fP resource.
There is no corresponding command-line option.
.
.TP
.B Scroll to Bottom on Key Press\fP (resource \fBscrollkey\fP)
Enable (or disable) scrolling to the bottom of the scrolling region on a keypress.
This corresponds to the \fB\-sk\fP option and the \fBscrollKey\fP resource.
.IP
As a special case, the XON / XOFF keys (control/S and control/Q) are ignored.
.
.TP
.B Scroll to Bottom on Tty Output\fP (resource \fBscrollttyoutput\fP)
Enable (or disable) scrolling to the bottom of the scrolling region on output to the terminal.
This corresponds to the \fB\-si\fP option and the \fBscrollTtyOutput\fP resource.
.
.TP
.B Allow 80/132 Column Switching\fP (resource \fBallow132\fP)
Enable (or disable) switching between 80 and 132 columns.
This corresponds to the \fB\-132\fP option and the \fBc132\fP resource.
.
.TP
.B Keep Selection\fP (resource \fBkeepSelection\fP)
Tell \fI\*n\fP whether to disown the selection when it stops highlighting it,
e.g., when an application modifies the display so that it no longer matches
the text which has been highlighted.
As long as \fI\*n\fP continues to own the selection,
it can provide the corresponding text to other clients via cut/paste.
This corresponds to the \fBkeepSelection\fP resource.
There is no corresponding command-line option.
.
.TP
.B Select to Clipboard\fP (resource \fBselectToClipboard\fP)
Tell \fI\*n\fP whether to use the \fBPRIMARY\fP or \fBCLIPBOARD\fP
for \fBSELECT\fP tokens in the \fBtranslations\fP resource which
maps keyboard and mouse actions to select/paste actions.
This corresponds to the \fBselectToClipboard\fP resource.
There is no corresponding command-line option.
.
.TP
.B Enable Visual Bell\fP (resource \fBvisualbell\fP)
Enable (or disable) visible bell (i.e., flashing) instead of an audible bell.
This corresponds to the \fB\-vb\fP option and the \fBvisualBell\fP resource.
.
.TP
.B Enable Bell Urgency\fP (resource \fBbellIsUrgent\fP)
Enable (or disable) Urgency window manager hint when Control-G is received.
This corresponds to the \fBbellIsUrgent\fP resource.
.
.TP
.B Enable Pop on Bell\fP (resource \fBpoponbell\fP)
Enable (or disable) raising of the window when Control-G is received.
This corresponds to the \fB\-pop\fP option and the \fBpopOnBell\fP resource.
.
.TP
.B Enable Blinking Cursor\fP (resource \fBcursorblink\fP)
Enable (or disable) the blinking-cursor feature.
This corresponds to the \fB\-bc\fP option and the \fBcursorBlink\fP resource.
There is also an escape sequence
(see \fI\*N Control Sequences\fP).
The menu entry and the escape sequence states are XOR'd:
if both are enabled, the cursor will not blink,
if only one is enabled, the cursor will blink.
.
.TP
.B Enable Alternate Screen Switching\fP (resource \fBtiteInhibit\fP)
Enable (or disable) switching between the normal and alternate screens.
This corresponds to the \fBtiteInhibit\fP resource.
There is no corresponding command-line option.
.
.TP
.B Enable Active Icon\fP (resource \fBactiveicon\fP)
Enable (or disable) the active-icon feature.
This corresponds to the \fB\-ai\fP option and the \fBactiveIcon\fP resource.
.
.TP
.B Sixel Scrolling\fP (resource \fBsixelScrolling\fP)
When enabled,
sixel graphics are positioned at the current text cursor location, scroll
the image vertically if larger than the screen, and leave the text cursor
at the start of the next complete line after the image when returning to text
mode (this is the default).
When disabled,
sixel graphics are positioned at the upper left of the screen, are
cropped to fit the screen, and do not affect the text cursor location.
This corresponds to the \fBsixelScrolling\fP resource.
There is no corresponding command-line option.
.
.TP
.B Private Color Registers\fP (resource \fBprivateColorRegisters\fP)
If \fI\*n\fR is configured to support ReGIS graphics,
this controls whether a private color palette can be used.
.IP
When enabled,
each graphic image uses a separate set of color registers, so that it
essentially has a private palette (this is the default).  If it is not set,
all graphics images share a common set of registers which is how sixel and
ReGIS graphics worked on actual hardware.  The default is likely a more
useful mode on modern TrueColor hardware.
.IP
This corresponds to the \fBprivateColorRegisters\fP resource.
There is no corresponding command-line option.
.RE
.
.TP
VT\fIxxx\fP Commands:
.RS
.TP
.B Do Soft Reset\fP (resource \fBsoftreset\fP)
Reset scroll regions.
This can be convenient when some program has left the scroll regions
set incorrectly (often a problem when using VMS or TOPS-20).
This corresponds to the VT220 DECSTR control sequence.
.
.TP
.B Do Full Reset\fP (resource \fBhardreset\fP)
The full reset entry will clear the screen, reset tabs to every
eight columns, and reset the terminal modes (such as wrap and smooth scroll)
to their initial states just after
.I \*n
has finished processing the command line options.
This corresponds to the VT102 RIS control sequence,
with a few obvious differences.
For example, your session is not disconnected as a real VT102 would do.
.
.TP
.B Reset and Clear Saved Lines\fP (resource \fBclearsavedlines\fP)
Perform a full reset,
and also clear the saved lines.
.RE
.
.TP
Commands for setting the current screen:
.RS
.
.TP
.B Show Tek Window\fP (resource \fBtekshow\fP)
When enabled,
pops the Tektronix 4014 window up (makes it visible).
When disabled,
hides the Tektronix 4014 window.
.
.TP
.B Switch to Tek Mode\fP (resource \fBtekmode\fP)
When enabled,
pops the Tektronix 4014 window up if it is not already visible,
and switches the input stream to that window.
When disabled,
hides the Tektronix 4014 window and
switches input back to the VT\fIxxx\fP window.
.
.TP
.B Hide VT Window\fP (resource \fBvthide\fP)
When enabled,
hides the VT\fIxxx\fP window,
shows the Tektronix 4014 window if
it was not already visible
and switches the input stream to that window.
When disabled,
shows the VT\fIxxx\fP window,
and switches the input stream to that window.
.
.TP
.B Show Alternate Screen\fP (resource \fBaltscreen\fP)
When enabled,
shows the alternate screen.
When disabled,
shows the normal screen.
Note that the normal screen may have saved lines;
the alternate screen does not.
.RE
.PP
.
.SS "VT Fonts"
.PP
The \fI\*n\fP \fIfontMenu\fP pops up when
when the \*(``control\*('' key and pointer button three are pressed in a window.
It sets the font used in the VT\fIxxx\fP window,
or modifies the way the font is specified or displayed.
There are several sections.
.PP
The first section allows you to select the font from a set of alternatives:
.RS
.TP
.B Default\fP (resource \fBfontdefault\fP)
Set the font to the default, i.e., that given by the \fB*VT100.font\fP resource.
.TP
.B Unreadable\fP (resource \fBfont1\fP)
Set the font to that given by the \fB*VT100.font1\fP resource.
.TP
.B Tiny\fP (resource \fBfont2\fP)
Set the font to that given by the \fB*VT100.font2\fP resource.
.TP
.B Small\fP (resource \fBfont3\fP)
Set the font to that given by the \fB*VT100.font3\fP resource.
.TP
.B Medium\fP (resource \fBfont4\fP)
Set the font to that given by the \fB*VT100.font4\fP resource.
.TP
.B Large\fP (resource \fBfont5\fP)
Set the font to that given by the \fB*VT100.font5\fP resource.
.TP
.B Huge\fP (resource \fBfont6\fP)
Set the font to that given by the \fB*VT100.font6\fP resource.
.TP
.B Escape Sequence\fP (resource \fBfontescape\fP)
This allows you to set the font last specified by the Set
Font escape sequence (see \fI\*N Control Sequences\fP).
.TP
.B Selection\fP (resource \fBfontsel\fP)
This allows you to set the font specified
the current selection as a font name (if the \fBPRIMARY\fP selection is owned).
.RE
.PP
The second section allows you to modify the way it is displayed:
.RS
.TP
.B Bold Fonts\fP (resource \fBallow-bold-fonts\fP)
This is normally checked (enabled).
When unchecked, \fI\*n\fP will not use bold fonts.
The setting corresponds to the \fBallowBoldFonts\fP resource.
.TP
.B Line-Drawing Characters\fP (resource \fBfont-linedrawing\fP)
When set, tells \fI\*n\fP to draw its own line-drawing characters.
Otherwise it relies on the font containing these.
Compare to the \fBforceBoxChars\fP resource.
.TP
.B Packed Font\fP (resource \fBfont-packed\fP)
When set, tells \fI\*n\fP to use the minimum glyph-width from a font
when displaying characters.
Use the maximum width (unchecked) to help display proportional fonts.
Compare to the \fBforcePackedFont\fP resource.
.TP
.B Doublesized Characters\fP (resource \fBfont-doublesize\fP)
When set, \fI\*n\fP may ask the font server to produce scaled versions
of the normal font, for VT102 double-size characters.
.RE
.PP
The third section allows you to modify the way it is specified:
.RS
.TP
.B TrueType Fonts\fP (resource \fBrender-font\fP)
If the \fBrenderFont\fP and corresponding resources were set,
this is a further control whether \fI\*n\fP will actually use the
Xft library calls to obtain a font.
.TP
.B UTF-8 Encoding\fP (resource \fButf8-mode\fP)
This controls whether \fI\*n\fP uses UTF-8 encoding of input/output.
It is useful for temporarily switching \fI\*n\fP to display
text from an application which does not follow the locale settings.
It corresponds to the \fButf8\fP resource.
.TP
.B UTF-8 Fonts\fP (resource \fButf8-fonts\fP)
This controls whether \fI\*n\fP uses UTF-8 fonts for display.
It is useful for temporarily switching \fI\*n\fP to display
text from an application which does not follow the locale settings.
It combines the \fButf8\fP and \fButf8Fonts\fP resources,
subject to the \fBlocale\fP resource.
.TP
.B UTF-8 Titles\fP (resource \fButf8-title\fP)
This controls whether \fI\*n\fP accepts UTF-8 encoding for
title control sequences.
It corresponds to the \fButf8Fonts\fP resource.
.IP
Initially the checkmark is set according to both the \fButf8\fP
and \fButf8Fonts\fP resource values.
If the latter is set to \*(``always\*('', the checkmark is disabled.
Likewise, if there are no fonts given in the \fButf8Fonts\fP
subresources, then the checkmark also is disabled.
.IP
The standard \fB__default_class__\fP app-defaults file defines both sets of fonts,
while the \fBU__default_class__\fP app-defaults file defines only one set.
Assuming the standard app-defaults files,
this command will launch \fI\*n\fP able to switch between UTF-8
and ISO-8859-1 encoded fonts:
.NS
u\*n -class __default_class__
.NE
.RE
.PP
The fourth section allows you to enable or disable special operations
which can be controlled by writing escape sequences to the terminal.
These are disabled if the SendEvents feature is enabled:
.RS
.TP
.B Allow Color Ops\fP (resource \fBallow-font-ops\fP)
This corresponds to the \fBallowColorOps\fP resource.
Enable or disable control sequences that set/query the colors.
.TP
.B Allow Font Ops\fP (resource \fBallow-font-ops\fP)
This corresponds to the \fBallowFontOps\fP resource.
Enable or disable control sequences that set/query the font.
.TP
.B Allow Mouse Ops\fP (resource \fBallow-mouse-ops\fP)
Enable or disable control sequences that cause the terminal to
send escape sequences on pointer-clicks and movement.
This corresponds to the \fBallowMouseOps\fP resource.
.TP
.B Allow Tcap Ops\fP (resource \fBallow-tcap-ops\fP)
Enable or disable control sequences that query the terminal's
notion of its function-key strings, as termcap or terminfo capabilities.
This corresponds to the \fBallowTcapOps\fP resource.
.TP
.B Allow Title Ops\fP (resource \fBallow-title-ops\fP)
Enable or disable control sequences that modify the window title or icon name.
This corresponds to the \fBallowTitleOps\fP resource.
.TP
.B Allow Window Ops\fP (resource \fBallow-window-ops\fP)
Enable or disable extended window control sequences (as used in dtterm).
This corresponds to the \fBallowWindowOps\fP resource.
.RE
.
.SS "Tek Options"
.PP
The \fI\*n\fP \fItekMenu\fP sets various modes in the Tektronix emulation,
and is popped up when the
\*(``control\*('' key and pointer button two are pressed in the Tektronix window.
The current font size is checked in the modes section of the menu.
.RS
.TP
.B Large Characters\fP (resource \fBtektextlarge\fP)
.TP
.B \ Size Characters\fP (resource \fBtektext2\fP)
.TP
.B \ Size Characters\fP (resource \fBtektext3\fP)
.TP
.B Small Characters\fP (resource \fBtektextsmall\fP)
.RE
.PP
Commands:
.RS
.TP
.B PAGE\fP (resource \fBtekpage\fP)
Clear the Tektronix window.
.TP
.B RESET\fP (resource \fBtekreset\fP)
.TP
.B COPY\fP (resource \fBtekcopy\fP)
.RE
.PP
Windows:
.RS
.TP
.B Show VT Window\fP (resource \fBvtshow\fP)
.TP
.B Switch to VT Mode\fP (resource \fBvtmode\fP)
.TP
.B Hide Tek Window\fP (resource \fBtekhide\fP)
.RE
.
.
.SH SECURITY
.
.PP
X environments differ in their security consciousness.
.bP
Most servers,
run under \fIxdm\fP,
are capable of using a \*(``magic cookie\*('' authorization
scheme that can provide a reasonable level of security for many people.
If your server is only using a host-based mechanism to control access to
the server (see \fIxhost(__mansuffix__)\fP), then if you enable access for a host and
other users are also permitted to run clients on that same host,
it is possible that someone can run an application which uses the
basic services of the X protocol to snoop on your activities,
potentially capturing a transcript of everything you type at the keyboard.
.bP
Any process which has access to your X display can manipulate it
in ways that you might not anticipate,
even redirecting your keyboard to itself
and sending events to your application's windows.
This is true even with the \*(``magic cookie\*('' authorization scheme.
While the \fBallowSendEvents\fP provides some protection against
rogue applications tampering with your programs,
guarding against a snooper is harder.
.
.bP
The X input extension for instance allows an application to bypass
all of the other (limited) authorization and security features,
including the GrabKeyboard protocol.
.
.bP
The possibility of an application spying on your keystrokes
is of particular concern when you want to type in a password
or other sensitive data.
The best solution to this problem is to use a better
authorization mechanism than is provided by X.
.PP
Subject to all of these caveats,
a simple mechanism exists for protecting keyboard input in \fI\*n\fP.
.
.PP
The \fI\*n\fP menu (see \fBMENUS\fP above) contains a \fBSecure Keyboard\fP
entry which, when enabled,
attempts to ensure that all keyboard input is directed
\fIonly\fP to \fI\*n\fP (using the GrabKeyboard protocol request).
When an application prompts you for a password
(or other sensitive data), you can enable \fBSecure Keyboard\fP using the
menu, type in the data, and then disable \fBSecure Keyboard\fP using
the menu again.
.bP
This ensures that you know which window is accepting your keystrokes.
.bP
It cannot ensure that there are no processes which have access to your
X display that might be observing the keystrokes as well.
.
.PP
Only one X client at a time can grab the keyboard,
so when you attempt to enable \fBSecure Keyboard\fP it may fail.
In this case, the bell will sound.
If the \fBSecure Keyboard\fP succeeds,
the foreground and background colors will be exchanged (as if you
selected the \fBEnable Reverse Video\fP entry in the \fBModes\fP menu);
they will be exchanged again when you exit secure mode.
If the colors
do \fInot\fP switch, then
you should be \fIvery\fP suspicious that you are being spoofed.
If the application you are running displays a prompt before asking for
the password, it is safest to enter secure mode \fIbefore\fP the
prompt gets displayed, and to make sure that the prompt gets displayed
correctly (in the new colors), to minimize the probability of
spoofing.
You can also bring up the menu again and make sure that a check
mark appears next to the entry.
.
.PP
\fBSecure Keyboard\fP mode will be disabled automatically if your \fI\*n\fP
window becomes iconified (or otherwise unmapped), or if you start up
a reparenting window manager (that places a title bar or other decoration
around the window) while in \fBSecure Keyboard\fP mode.
(This is a
feature of the X protocol not easily overcome.)  When this happens,
the foreground and background colors will be switched back and the bell
will sound in warning.
.
.
.SH "CHARACTER CLASSES"
Clicking the left pointer button twice in rapid succession
(double-clicking) causes all characters of the same class
(e.g., letters, white space, punctuation) to be selected as a \*(``word\*(''.
Since different people have different preferences for what should
be selected (for example, should filenames be selected as a whole or only
the separate subnames), the default mapping can be overridden through the use
of the \fBcharClass\fP (class \fICharClass\fP) resource.
.
.PP
This resource is a
series of comma-separated
\fIrange\fP:\fIvalue\fP pairs.
.bP
The
\fIrange\fP is either a single number or \fIlow\fP-\fIhigh\fP in the range of 0
to 65535, corresponding to the code for the character or characters to be
set.
.bP
The \fIvalue\fP is arbitrary.  For example, the default table uses the
character number of the first character occurring in the set.
When not in
UTF-8 mode, only the first 256 entries of this table will be used.
.
.PP
The default table starts as follows \-
.NS
static int charClass[256] = {
/\(** NUL  SOH  STX  ETX  EOT  ENQ  ACK  BEL */
    32,   1,   1,   1,   1,   1,   1,   1,
/\(**  BS   HT   NL   VT   NP   CR   SO   SI */
     1,  32,   1,   1,   1,   1,   1,   1,
/\(** DLE  DC1  DC2  DC3  DC4  NAK  SYN  ETB */
     1,   1,   1,   1,   1,   1,   1,   1,
/\(** CAN   EM  SUB  ESC   FS   GS   RS   US */
     1,   1,   1,   1,   1,   1,   1,   1,
/\(**  SP    !    "    #    $    %    &    \*(AQ */
.\"   " <- for emacs autocolor to work well :-)
    32,  33,  34,  35,  36,  37,  38,  39,
/\(**   (    )    *    +    ,    \-    .    / */
    40,  41,  42,  43,  44,  45,  46,  47,
/\(**   0    1    2    3    4    5    6    7 */
    48,  48,  48,  48,  48,  48,  48,  48,
/\(**   8    9    :    ;    <    =    >    ? */
    48,  48,  58,  59,  60,  61,  62,  63,
/\(**   @    A    B    C    D    E    F    G */
    64,  48,  48,  48,  48,  48,  48,  48,
/\(**   H    I    J    K    L    M    N    O */
    48,  48,  48,  48,  48,  48,  48,  48,
/\(**   P    Q    R    S    T    U    V    W */
    48,  48,  48,  48,  48,  48,  48,  48,
/\(**   X    Y    Z    [    \\    ]    ^    _ */
    48,  48,  48,  91,  92,  93,  94,  48,
/\(**   `    a    b    c    d    e    f    g */
    96,  48,  48,  48,  48,  48,  48,  48,
/\(**   h    i    j    k    l    m    n    o */
    48,  48,  48,  48,  48,  48,  48,  48,
/\(**   p    q    r    s    t    u    v    w */
    48,  48,  48,  48,  48,  48,  48,  48,
/\(**   x    y    z    {    |    }    ~  DEL */
    48,  48,  48, 123, 124, 125, 126,   1,
/\(** x80  x81  x82  x83  IND  NEL  SSA  ESA */
     1,   1,   1,   1,   1,   1,   1,   1,
/\(** HTS  HTJ  VTS  PLD  PLU   RI  SS2  SS3 */
     1,   1,   1,   1,   1,   1,   1,   1,
/\(** DCS  PU1  PU2  STS  CCH   MW  SPA  EPA */
     1,   1,   1,   1,   1,   1,   1,   1,
/\(** x98  x99  x9A  CSI   ST  OSC   PM  APC */
     1,   1,   1,   1,   1,   1,   1,   1,
/\(**   \-    i   c/    L   ox   Y\-    |   So */
   160, 161, 162, 163, 164, 165, 166, 167,
/\(**  ..   c0   ip   <<    _        R0    \- */
   168, 169, 170, 171, 172, 173, 174, 175,
/\(**   o   +\-    2    3    \*(AQ    u   q|    . */
   176, 177, 178, 179, 180, 181, 182, 183,
/\(**   ,    1    2   >>  1/4  1/2  3/4    ? */
   184, 185, 186, 187, 188, 189, 190, 191,
/\(**  A`   A\*(AQ   A^   A~   A:   Ao   AE   C, */
    48,  48,  48,  48,  48,  48,  48,  48,
/\(**  E`   E\*(AQ   E^   E:   I`   I\*(AQ   I^   I: */
    48,  48,  48,  48,  48,  48,  48,  48,
/\(**  D\-   N~   O`   O\*(AQ   O^   O~   O:    X */
    48,  48,  48,  48,  48,  48,  48, 215,
/\(**  O/   U`   U\*(AQ   U^   U:   Y\*(AQ    P    B */
    48,  48,  48,  48,  48,  48,  48,  48,
/\(**  a`   a\*(AQ   a^   a~   a:   ao   ae   c, */
    48,  48,  48,  48,  48,  48,  48,  48,
/\(**  e`   e\*(AQ   e^   e:   i`   i\*(AQ   i^   i: */
    48,  48,  48,  48,  48,  48,  48,  48,
/\(**   d   n~   o`   o\*(AQ   o^   o~   o:   \-: */
    48,  48,  48,  48,  48,  48,  48, 247,
/\(**  o/   u`   u\*(AQ   u^   u:   y\*(AQ    P   y: */
    48,  48,  48,  48,  48,  48,  48,  48};
.NE
.IP
For example, the string \*(``33:48,37:48,45\-47:48,38:48\*('' indicates that the
exclamation mark, percent sign, dash, period, slash, and ampersand characters
should be treated the same way as characters and numbers.
This is useful
for cutting and pasting electronic mailing addresses and filenames.
.
.
.SH KEY BINDINGS
.PP
It is possible to rebind keys (or sequences of keys) to arbitrary strings
for input, by changing the \fBtranslations\fP resources
for the vt100 or tek4014 widgets.
Changing the \fBtranslations\fP resource
for events other than key and button events is not expected,
and will cause unpredictable behavior.
.SS Actions
The following
actions are provided for use within the \fIvt100\fP or \fItek4014\fP
\fBtranslations\fP resources:
.TP 8
.B "allow-bold-fonts(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBallowBoldFonts\fP resource and is also
invoked by the \fBallow-bold-fonts\fP entry in \fIfontMenu\fP.
.TP 8
.B "allow-color-ops(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBallowColorOps\fP resource and is also
invoked by the \fBallow-color-ops\fP entry in \fIfontMenu\fP.
.TP 8
.B "allow-font-ops(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBallowFontOps\fP resource and is also
invoked by the \fBallow-font-ops\fP entry in \fIfontMenu\fP.
.TP 8
.B "allow-mouse-ops(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBallowMousepOps\fP resource and is also
invoked by the \fBallow-mouse-ops\fP entry in \fIfontMenu\fP.
.TP 8
.B "allow-send-events(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBallowSendEvents\fP resource and is also
invoked by the \fBallowsends\fP entry in \fImainMenu\fP.
.TP 8
.B "allow-tcap-ops(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBallowTcapOps\fP resource and is also
invoked by the \fBallow-tcap-ops\fP entry in \fIfontMenu\fP.
.TP 8
.B "allow-title-ops(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBallowTitleOps\fP resource and is also
invoked by the \fBallow-title-ops\fP entry in \fIfontMenu\fP.
.TP 8
.B "allow-window-ops(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBallowWindowOps\fP resource and is also
invoked by the \fBallow-window-ops\fP entry in \fIfontMenu\fP.
.TP 8
.B "alt-sends-escape()"
This action toggles the state of the \fBaltSendsEscape\fP resource.
.TP 8
.B "bell([\fIpercent\fP])"
This action rings the keyboard bell at the specified percentage
above or below the base volume.
.TP 8
.B "clear-saved-lines()"
This action does \fBhard-reset()\fP and also clears the history
of lines saved off the top of the screen.
It is also invoked from the \fBclearsavedlines\fP entry in \fIvtMenu\fP.
The effect is identical to a hardware reset (RIS) control sequence.
.TP 8
.B "copy-selection(\fIdestname\fP [, ...])"
This action puts the currently selected text into all of the selections or
cutbuffers specified by \fIdestname\fP.
Unlike \fBselect-end\fP, it does not send a mouse position or otherwise
modify the internal selection state.
.TP 8
.B "create-menu(\fIm/v/f/t\fP)"
This action creates one of the menus used by \fI\*n\fP,
if it has not been previously created.
The parameter values are the menu names:
\fImainMenu\fP, \fIvtMenu\fP, \fIfontMenu\fP, \fItekMenu\fP, respectively.
.TP 8
.B "dabbrev-expand()"
Expands the word before cursor by searching in the preceding text on the
screen and in the scrollback buffer for words starting with that
abbreviation.
Repeating \fBdabbrev-expand()\fP several times in sequence searches for an
alternative expansion by looking farther back.
Lack of more matches is signaled by a bell.
Attempts to expand an empty word
(i.e., when cursor is preceded by a space) yield successively all previous
words.
Consecutive identical expansions are ignored.
The word here is defined as a sequence of non-whitespace characters.
This feature partially emulates the behavior
of \*(``dynamic abbreviation\*('' expansion in Emacs (bound there to M\-/).
Here is a resource setting for \fI\*n\fP which will do the same thing:
.NS
*VT100*translations:    #override \\n\\\&
        Meta  /:\fBdabbrev-expand\fP()
.NE
.TP 8
.B "deiconify()"
Changes the window state back to normal, if it was iconified.
.TP 8
.B "delete-is-del()"
This action toggles the state of the \fBdeleteIsDEL\fP resource.
.TP 8
.B "dired-button()"
Handles a button event (other than press and release)
by echoing the event's position
(i.e., character line and column) in the following format:
.sp
.in +8
^X ESC G  
.in -8
.TP 8
.B "exec-formatted(\fIformat\fP, \fIsourcename\fP [, ...])"
Execute an external command,
using the current selection for part of the command's parameters.
The first parameter, \fIformat\fP gives the basic command.
Succeeding parameters specify the selection source as in \fBinsert-selection\fP.
.IP
The \fIformat\fP parameter allows these substitutions:
.RS
.TP 5
%%
inserts a "%".
.TP 5
%P
the screen-position at the beginning of the highlighted region,
as a semicolon-separated pair of integers using the
values that the CUP control sequence would use.
.TP 5
%p
the screen-position after the beginning of the highlighted region,
using the same convention as \*(``%P\*(''.
.TP 5
%S
the length of the string that \*(``%s\*('' would insert.
.TP 5
%s
the content of the selection, unmodified.
.TP 5
%T
the length of the string that \*(``%t\*('' would insert.
.TP 5
%t
the selection, trimmed of leading/trailing whitespace.
Embedded spaces (and newlines) are copied as is.
.TP 5
%R
the length of the string that \*(``%r\*('' would insert.
.TP 5
%r
the selection, trimmed of trailing whitespace.
.TP 5
%V
the video attributes at the beginning of the highlighted region,
as a semicolon-separated list of integers using the
values that the SGR control sequence would use.
.TP 5
%v
the video attributes after the end of the highlighted region,
using the same convention as \*(``%V\*(''.
.RE
.IP
After constructing the command-string,
\fI\*n\fP forks a subprocess and executes the command,
which completes independently of \fI\*n\fP.
.IP
For example, this translation would invoke a new \fI\*n\fP process
to view a file whose name is selected while holding the shift key down.
The new process is started when the mouse button is released:
.NS
*VT100*translations: #override Shift \\
    :\fBexec-formatted\fP("xterm -e view '%t'", \fBSELECT\fP)
.NE
.TP 8
.B "exec-selectable(\fIformat\fP, \fIonClicks\fP)"
Execute an external command,
using data copied from the screen for part of the command's parameters.
The first parameter, \fIformat\fP gives
the basic command as in \fBexec-formatted\fP.
The second parameter specifies the method for copying
the data as in the \fBon2Clicks\fP resource.
.TP 8
.B "fullscreen(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBfullscreen\fP resource.
.TP 8
.B "iconify()"
Iconifies the window.
.TP 8
.B "hard-reset()"
This action resets the scrolling region, tabs, window size, and cursor keys
and clears the screen.
It is also invoked from the \fBhardreset\fP
entry in \fIvtMenu\fP.
.TP 8
.B "ignore()"
This action ignores the event but checks for special pointer position
escape sequences.
.TP 8
.B "insert()"
This action inserts the character or string associated with
the key that was pressed.
.TP 8
.B "insert-eight-bit()"
This action inserts an eight-bit (Meta) version of the character or string
associated with the key that was pressed.
Only single-byte values are treated specially.
The exact action depends on the value of
the \fBaltSendsEscape\fP and
the \fBmetaSendsEscape\fP and
the \fBeightBitInput\fP resources.
The \fBmetaSendsEscape\fP resource is tested first.
See the \fBeightBitInput\fP resource for a full discussion.
.IP
The term \*(``eight-bit\*('' is misleading:
\fI\*n\fP checks if the key is in the range 128 to 255
(the eighth bit is set).
If the value is in that range,
depending on the resource values,
\fI\*n\fP may then do one of the following:
.RS
.bP
add 128 to the value, setting its eighth bit,
.bP
send an ESC byte before the key, or
.bP
send the key unaltered.
.RE
.TP 8
.B "insert-formatted(\fIformat\fP, \fIsourcename\fP [, ...])"
Insert the current selection or data related to it, formatted.
The first parameter, \fIformat\fP gives the template for the data
as in \fBexec-formatted\fP.
Succeeding parameters specify the selection source as in \fBinsert-selection\fP.
.TP 8
.B "insert-selectable(\fIformat\fP, \fIonClicks\fP)"
Insert data copied from the screen, formatted.
The first parameter, \fIformat\fP gives the template for the data
as in \fBexec-formatted\fP.
The second parameter specifies the method for copying
the data as in the \fBon2Clicks\fP resource.
.TP 8
.B "insert-selection(\fIsourcename\fP [, ...])"
This action inserts the string found in the selection or cutbuffer indicated
by \fIsourcename\fP.
Sources are checked in the order given (case is
significant) until one is found.
Commonly-used selections include:
\fIPRIMARY\fP, \fISECONDARY\fP, and \fICLIPBOARD\fP.
Cut buffers are
typically named \fICUT_BUFFER0\fP through \fICUT_BUFFER7\fP.
.TP 8
.B "insert-seven-bit()"
This action is a synonym for \fBinsert()\fP.
The term \*(``seven-bit\*('' is misleading:
it only implies that \fI\*n\fP does not try to add 128 to the key's value
as in \fBinsert-eight-bit()\fP.
.TP 8
.B "interpret(\fIcontrol-sequence\fP)"
Interpret the given control sequence locally, i.e., without passing it to
the host.
This works by inserting the control sequence at the front
of the input buffer.
Use \*(``\\\*('' to escape octal digits in the string.
Xt does not allow you to put a null character (i.e., \*(``\\000\*('') in the string.
.TP 8
.B "keymap(\fIname\fP)"
This action dynamically defines a new translation table whose resource
name is \fIname\fP with the suffix \*(``\fIKeymap\fP\*(''
(i.e., \fIname\fP\fBKeymap\fP, where case is significant).
The name \fINone\fP restores the original translation table.
.TP 8
.B "larger-vt-font()"
Set the font to the next larger one, based on the font dimensions.
See also \fBset-vt-font()\fP.
.TP 8
.B "load-vt-fonts(\fIname\fP[,\fIclass\fP])"
Load fontnames from the given subresource name and class.
That is, load the \*(``*VT100.\fIname\fP.font\*('',
resource as \*(``*VT100.font\*('' etc.
If no name is given, the original set of fontnames is restored.
.IP
Unlike \fBset-vt-font()\fR, this does not affect the escape- and select-fonts,
since those are not based on resource values.
It does affect the fonts loosely organized under the \*(``Default\*('' menu
entry, including \fBfont\fP, \fBboldFont\fP, \fBwideFont\fP and \fBwideBoldFont\fP.
.TP 8
.B "maximize()"
Resizes the window to fill the screen.
.TP 8
.B "meta-sends-escape()"
This action toggles the state of the \fBmetaSendsEscape\fP resource.
.TP 8
.B "popup-menu(\fImenuname\fP)"
This action displays the specified popup menu.
Valid names (case is
significant) include:  \fImainMenu\fP, \fIvtMenu\fP, \fIfontMenu\fP,
and \fItekMenu\fP.
.TP 8
.B "print(\fIprinter-flags\fP)"
This action prints the window.
It is also invoked by the \fBprint\fP entry in \fImainMenu\fP.
.IP
The action accepts optional parameters, which temporarily override
resource settings.
The parameter values are matched ignoring case:
.RS
.TP 5
noFormFeed
no form feed will be sent at the end of the last line printed
(i.e., \fBprinterFormFeed\fP is ``false'').
.TP 5
FormFeed
a form feed will be sent at the end of the last line printed
(i.e., \fBprinterFormFeed\fP is ``true'').
.TP 5
noNewLine
no newline will be sent at the end of the last line printed,
and wrapped lines will be combined into long lines
(i.e., \fBprinterNewLine\fP is ``false'').
.TP 5
NewLine
a newline will be sent at the end of the last line printed,
and each line will be limited (by adding a newline) to the screen width
(i.e., \fBprinterNewLine\fP is ``true'').
.TP 5
noAttrs
the page is printed without attributes
(i.e., \fBprintAttributes\fP is ``0'').
.TP 5
monoAttrs
the page is printed with monochrome (vt220) attributes
(i.e., \fBprintAttributes\fP is ``1'').
.TP 5
colorAttrs
the page is printed with ANSI color attributes
(i.e., \fBprintAttributes\fP is ``2'').
.RE
.TP 8
.B "print-everything(\fIprinter-flags\fP)"
This action sends the entire text history, in addition to the text
currently visible, to the program given in the \fBprinterCommand\fP resource.
It allows the same optional parameters as the \fBprint\fP action.
With a suitable printer command, the action can be used to load the text
history in an editor.
.TP 8
.B "print-immediate()"
Sends the text of the current window directly to a file,
as specified by the
\fBprintFileImmediate\fP,
\fBprintModeImmediate\fP and
\fBprintOptsImmediate\fP
resources.
.TP 8
.B "print-on-error()"
Toggles a flag telling \fI\*n\fP that if it exits with an X error,
to send the text of the current window directly to a file,
as specified by the
\fBprintFileOnXError\fP,
\fBprintModeOnXError\fP and
\fBprintOptsOnXError\fP
resources.
.TP 8
.B "print-redir()"
This action toggles the \fBprinterControlMode\fR between 0 and 2.
The corresponding popup menu entry is useful for switching the printer
off if you happen to change your mind after deciding to print random
binary files on the terminal.
.TP 8
.B "quit()"
.br
This action sends a SIGHUP to the subprogram and exits.
It is also invoked
by the \fBquit\fP entry in \fImainMenu\fP.
.TP 8
.B "readline-button()"
Supports the optional readline feature by echoing repeated cursor forward
or backward control sequences on button release event,
to request that the host application update its notion of the cursor's
position to match the button event.
.TP 8
.B "redraw()"
This action redraws the window.
It is also invoked by the \fBredraw\fP entry in \fImainMenu\fP.
.TP 8
.B "restore()"
Restores the window to the size before it was last maximized.
.TP 8
.B "scroll-back(\fIcount\fP [,\fIunits\fP [,\fImouse\fP] ])"
This action scrolls the text window backward so that text that had previously
scrolled off the top of the screen is now visible.
.IP
The \fIcount\fP argument
indicates the number of \fIunits\fP (which may be \fIpage\fP, \fIhalfpage\fP,
\fIpixel\fP, or \fIline\fP) by which to scroll.
.IP
An adjustment can be specified for these values
by appending a \*(``+\*('' or \*(``\-\*(''
sign followed by a number,
e.g., \fIpage\-2\fP to specify 2 lines less than a page.
.IP
If the third parameter \fImouse\fP is given, the action is ignored when
mouse reporting is enabled.
.TP 8
.B "scroll-forw(\fIcount\fP [,\fIunits\fP [,\fImouse\fP] ])"
This action is similar to \fBscroll-back\fP except that it scrolls
in the other direction.
.TP 8
.B "secure()"
This action toggles the \fISecure Keyboard\fP mode
(see \fBSECURITY\fP), and is invoked from the \fBsecurekbd\fP
entry in \fImainMenu\fP.
.TP 8
.B "scroll-lock(\fIon/off/toggle\fP)"
This action sets, unsets or toggles internal state which tells
\fI\*n\fP whether Scroll Lock is active,
subject to the \fBallowScrollLock\fP resource.
.TP 8
.B "select-cursor-end(\fIdestname\fP [, ...])"
This action is similar to \fBselect-end\fP except that it should be used
with \fBselect-cursor-start\fP.
.TP 8
.B "select-cursor-extend()"
This action is similar to \fBselect-extend\fP except that it should be used
with \fBselect-cursor-start\fP.
.TP 8
.B "select-cursor-start()"
This action is similar to \fBselect-start\fP except that it begins the
selection at the current text cursor position.
.TP 8
.B "select-end(\fIdestname\fP [, ...])"
This action puts the currently selected text into all of the selections or
cutbuffers specified by \fIdestname\fP.
It also sends a mouse position and updates the internal selection state
to reflect the end of the selection process.
.TP 8
.B "select-extend()"
This action tracks the pointer and extends the selection.
It should only be bound to Motion events.
.TP 8
.B "select-set()"
This action stores text that corresponds to the current selection,
without affecting the selection mode.
.TP 8
.B "select-start()"
This action begins text selection at the current pointer location.
See
the section on \fBPOINTER USAGE\fP for information on making selections.
.TP 8
.B "send-signal(\fIsigname\fP)"
This action sends the signal named by \fIsigname\fP
to the \fI\*n\fP subprocess (the shell or program specified with
the \fI\-e\fP command line option).
It is also invoked by the
\fBsuspend\fP,
\fBcontinue\fP,
\fBinterrupt\fP,
\fBhangup\fP,
\fBterminate\fP,
and
\fBkill\fP
entries in \fImainMenu\fP.
Allowable signal names are (case is
not significant):
\fItstp\fP (if supported by the operating system), \fIsuspend\fP (same
as \fItstp\fP), \fIcont\fP
(if supported by the operating system), \fIint\fP, \fIhup\fP, \fIterm\fP,
\fIquit\fP,
\fIalrm\fP, \fIalarm\fP (same as \fIalrm\fP) and \fIkill\fP.
.TP 8
.B "set-8-bit-control(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBeightBitControl\fP resource.
It is also invoked from the \fB8-bit-control\fP entry in \fIvtMenu\fP.
.TP 8
.B "set-allow132(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBc132\fP resource.
It is also invoked from the \fBallow132\fP entry in \fIvtMenu\fP.
.TP 8
.B "set-altscreen(\fIon/off/toggle\fP)"
This action sets, unsets or toggles between the alternate and current screens.
.TP 8
.B "set-appcursor(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the handling Application Cursor Key mode
and is also invoked by the \fBappcursor\fP entry in \fIvtMenu\fP.
.TP 8
.B "set-appkeypad(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the handling of Application Keypad mode and is also
invoked by the \fBappkeypad\fP entry in \fIvtMenu\fP.
.TP 8
.B "set-autolinefeed(\fIon/off/toggle\fP)"
This action sets, unsets or toggles automatic insertion of linefeeds.
It is also invoked by the \fBautolinefeed\fP entry in \fIvtMenu\fP.
.TP 8
.B "set-autowrap(\fIon/off/toggle\fP)"
This action sets, unsets or toggles automatic wrapping of long lines.
It is also invoked by the \fBautowrap\fP entry in \fIvtMenu\fP.
.TP 8
.B "set-backarrow(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBbackarrowKey\fP resource.
It is also invoked from the \fBbackarrow key\fP entry in \fIvtMenu\fP.
.TP 8
.B "set-bellIsUrgent(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBbellIsUrgent\fP resource.
It is also invoked by the \fBbellIsUrgent\fP entry in \fIvtMenu\fP.
.TP 8
.B "set-cursorblink(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBcursorBlink\fP resource.
It is also invoked from the \fBcursorblink\fP entry in \fIvtMenu\fP.
.TP 8
.B "set-cursesemul(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBcurses\fP resource.
It is also invoked from the \fBcursesemul\fP entry in \fIvtMenu\fP.
.TP 8
.B "set-font-doublesize(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBfontDoublesize\fP resource.
It is also invoked by the \fBfont-doublesize\fP entry in \fIfontMenu\fP.
.TP 8
.B "set-hp-function-keys(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBhpFunctionKeys\fP resource.
It is also invoked by the \fBhpFunctionKeys\fP entry in \fImainMenu\fP.
.TP 8
.B "set-jumpscroll(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBjumpscroll\fP resource.
It is also invoked by the \fBjumpscroll\fP entry in \fIvtMenu\fP.
.TP 8
.B "set-font-linedrawing(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fI\*n\fR's state regarding whether the current font
has line-drawing characters and whether it should draw them directly.
It is also invoked by the \fBfont-linedrawing\fP entry in \fIfontMenu\fP.
.\" .\" not implemented
.\" .TP 8
.\" .B "set-font-loading(\fIon/off/toggle\fP)"
.\" This action sets, unsets or toggles the TBD resource
.\" which controls the ability to load VT220 soft fonts.
.\" It is also invoked by the \fBfont-loadable\fP entry in \fIfontMenu\fP.
.TP 8
.B "set-font-packed(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBforcePackedFont\fR resource
which controls use of the font's minimum or maximum glyph width.
It is also invoked by the \fBfont-packed\fP entry in \fIfontMenu\fP.
.TP 8
.B "set-keep-clipboard(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBkeepClipboard\fP resource.
.TP 8
.B "set-keep-selection(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBkeepSelection\fP resource.
It is also invoked by the \fBkeepSelection\fP entry in \fIvtMenu\fP.
.TP 8
.B "set-logging(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the state of the logging option.
.TP 8
.B "set-old-function-keys(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the state of legacy function keys.
It is also invoked by the \fBoldFunctionKeys\fP entry in \fImainMenu\fP.
.TP 8
.B "set-marginbell(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBmarginBell\fP resource.
.TP 8
.B "set-num-lock(\fIon/off/toggle\fP)"
This action toggles the state of the \fBnumLock\fP resource.
.TP 8
.B "set-pop-on-bell(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBpopOnBell\fP resource.
It is also invoked by the \fBpoponbell\fP entry in \fIvtMenu\fP.
.TP 8
.B "set-private-colors(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBprivateColorRegisters\fP resource.
.TP 8
.B "set-render-font(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBrenderFont\fP resource.
It is also invoked by the \fBrender-font\fP entry in \fIfontMenu\fP.
.TP 8
.B "set-reverse-video(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBreverseVideo\fP resource.
It is also invoked by the \fBreversevideo\fP entry in \fIvtMenu\fP.
.TP 8
.B "set-reversewrap(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBreverseWrap\fP resource.
It is also invoked by the \fBreversewrap\fP entry in \fIvtMenu\fP.
.TP 8
.B "set-scroll-on-key(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBscrollKey\fP resource.
It is also invoked from the \fBscrollkey\fP entry in \fIvtMenu\fP.
.TP 8
.B "set-scroll-on-tty-output(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBscrollTtyOutput\fP resource.
It is also invoked from the \fBscrollttyoutput\fP entry in \fIvtMenu\fP.
.TP 8
.B "set-scrollbar(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBscrollbar\fP resource.
It is also invoked by the \fBscrollbar\fP entry in \fIvtMenu\fP.
.TP 8
.B "set-sco-function-keys(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBscoFunctionKeys\fP resource.
It is also invoked by the \fBscoFunctionKeys\fP entry in \fImainMenu\fP.
.TP 8
.B "set-select(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBselectToClipboard\fP resource.
It is also invoked by the \fBselectToClipboard\fP entry in \fIvtMenu\fP.
.TP 8
.B "set-sixel-scrolling(\fIon/off/toggle\fP)"
This action toggles between inline (sixel scrolling) and absolute positioning.
It can also be controlled via DEC private mode 80 (DECSDM) or from
the \fBsixelScrolling\fP entry in the \fIbtMenu\fP.
.TP 8
.B "set-sun-function-keys(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBsunFunctionKeys\fP resource.
It is also invoked by the \fBsunFunctionKeys\fP entry in \fImainMenu\fP.
.TP 8
.B "set-sun-keyboard(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBsunKeyboard\fP resource.
It is also invoked by the \fBsunKeyboard\fP entry in \fImainMenu\fP.
.TP 8
.B "set-tek-text(\fIlarge/2/3/small\fP)"
This action sets the font used in the Tektronix window to the value of the
selected resource according to the argument.
The argument can be either a keyword or single-letter alias,
as shown in parentheses:
.RS
.TP 5
large (l)
Use resource \fBfontLarge\fP, same as menu entry \fBtektextlarge\fP.
.TP 5
two (2)
Use resource \fBfont2\fP, same as menu entry \fBtektext2\fP.
.TP 5
three (3)
Use resource \fBfont3\fP, same as menu entry \fBtektext3\fP.
.TP 5
small (s)
Use resource \fBfontSmall\fP, same as menu entry \fBtektextsmall\fP.
.RE
.TP 8
.B "set-terminal-type(\fItype\fP)"
This action directs output to either the \fIvt\fP or \fItek\fP windows,
according to the \fItype\fP string.
It is also invoked by the
\fBtekmode\fP entry in \fIvtMenu\fP and the \fBvtmode\fP entry in
\fItekMenu\fP.
.TP 8
.B "set-titeInhibit(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBtiteInhibit\fP resource,
which controls switching between the alternate and current screens.
.TP 8
.B "set-toolbar(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the toolbar feature.
It is also invoked by the \fBtoolbar\fP entry in \fImainMenu\fP.
.TP 8
.B "set-utf8-fonts(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fButf8Fonts\fP resource.
It is also invoked by the \fButf8-fonts\fP entry in \fIfontMenu\fP.
.TP 8
.B "set-utf8-mode(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fButf8\fP resource.
It is also invoked by the \fButf8-mode\fP entry in \fIfontMenu\fP.
.TP 8
.B "set-utf8-title(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fButf8Title\fP resource.
It is also invoked by the \fButf8-title\fP entry in \fIfontMenu\fP.
.TP 8
.B "set-visibility(\fIvt/tek\fP,\fIon/off/toggle\fP)"
This action sets, unsets or toggles whether or not the \fIvt\fP or \fItek\fP windows are
visible.
It is also invoked from the \fBtekshow\fP and \fBvthide\fP entries
in \fIvtMenu\fP and the \fBvtshow\fP and \fBtekhide\fP entries in
\fItekMenu\fP.
.TP 8
.B "set-visual-bell(\fIon/off/toggle\fP)"
This action sets, unsets or toggles the \fBvisualBell\fP resource.
It is also invoked by the \fBvisualbell\fP entry in \fIvtMenu\fP.
.TP 8
.B "set-vt-font(\fId/1/2/3/4/5/6/e/s\fP [,\fInormalfont\fP [, \fIboldfont\fP]])"
This action sets the font or fonts currently being used in the VT\fIxxx\fP window.
The first argument is a single character that specifies the font to be
used:
.RS 8
.HP
\fId\fP or \fID\fP indicate the default font (the font initially
used when
\fI\*n\fP was started),
.HP
\fI1\fP through \fI6\fP indicate the fonts
specified by the \fBfont1\fP through \fBfont6\fP resources,
.HP
\fIe\fP or \fIE\fP
indicate the normal and bold fonts that have been set through escape codes
(or specified as the second and third action arguments, respectively), and
.HP
\fIs\fP or \fIS\fP indicate the font selection (as made by programs such as
\fIxfontsel(__mansuffix__)\fP) indicated by the second action argument.
.RE
.IP
If \fI\*n\fR is configured to support wide characters, an
additional two optional parameters are recognized for the \fIe\fP argument:
wide font and wide bold font.
.TP 8
.B "smaller-vt-font()"
Set the font to the next smaller one, based on the font dimensions.
See also \fBset-vt-font()\fP.
.TP 8
.B "soft-reset()"
This action resets the scrolling region.
It is also invoked from the \fBsoftreset\fP entry in \fIvtMenu\fP.
The effect is identical to a soft reset (DECSTR) control sequence.
.TP 8
.B "spawn-new-terminal(\fIparams\fP)"
Spawn a new \fI\*n\fP process.
This is available on systems which have a modern version of the
process filesystem, e.g., \*(``/proc\*('', which \fI\*n\fP can read.
.IP
Use the \*(``cwd\*('' process entry, e.g., /proc/12345/cwd to obtain the
working directory of the process which is running in the current \fI\*n\fP.
.IP
On systems which have the \*(``exe\*('' process entry, e.g., /proc/12345/exe,
use this to obtain the actual executable.
Otherwise, use the \fB$PATH\fP variable to find \fI\*n\fP.
.IP
If parameters are given in the action,
pass them to the new \fI\*n\fP process.
.TP 8
.B "start-extend()"
This action is similar to \fBselect-start\fP except that the
selection is extended to the current pointer location.
.TP 8
.B "start-cursor-extend()"
This action is similar to \fBselect-extend\fP except that the
selection is extended to the current text cursor position.
.TP 8
.B "string(\fIstring\fP)"
This action inserts the specified text string as if it had been typed.
Quotation is necessary if the string contains whitespace or
non-alphanumeric characters.
If the string argument begins with the
characters \*(``0x\*('', it is interpreted
as a hex character constant.
.TP 8
.B "tek-copy()"
This action copies the escape codes used to generate the current window
contents to a file in the current directory beginning with the name COPY.
It is also invoked from the \fBtekcopy\fP entry in \fItekMenu\fP.
.TP 8
.B "tek-page()"
This action clears the Tektronix window.
It is also invoked by the \fBtekpage\fP entry in \fItekMenu\fP.
.TP 8
.B "tek-reset()"
This action resets the Tektronix window.
It is also invoked by the \fBtekreset\fP entry in \fItekMenu\fP.
.TP 8
.B "vi-button()"
Handles a button event (other than press and release)
by echoing a control sequence computed from the event's line number
in the screen relative to the current line:
.sp
.in +8
ESC ^P
.in -8
or
.in +8
ESC ^N
.in -8
.sp
according to whether the event is before, or after the current line,
respectively.
The ^N (or ^P) is repeated once for each line that the event differs
from the current line.
The control sequence is omitted altogether if the button event is on the
current line.
.TP 8
.B "visual-bell()"
This action flashes the window quickly.
.
.PP
The Tektronix window also has the following action:
.TP 8
.B "gin-press(\fIl/L/m/M/r/R\fP)"
This action sends the indicated graphics input code.
.
.SS Default Key Bindings
.PP
The default bindings in the VT\fIxxx\fP window use the \fBSELECT\fP token,
which is set by the \fBselectToClipboard\fP resource.
These are for the \fIvt100\fP widget:
.NS
          Shift  Prior:\fBscroll-back\fP(1,halfpage) \\n\\\&
           Shift  Next:\fBscroll-forw\fP(1,halfpage) \\n\\\&
         Shift  Select:\fBselect-cursor-start\fP() \\\&
                                 \fBselect-cursor-end\fP(\fBSELECT\fP, CUT_BUFFER0) \\n\\\&
         Shift  Insert:\fBinsert-selection\fP(\fBSELECT\fP, CUT_BUFFER0) \\n\\\&
                 Alt Return:\fBfullscreen\fP() \\n\\\&
         Scroll_Lock:\fBscroll-lock\fP() \\n\\\&
    Shift~Ctrl  KP_Add:\fBlarger-vt-font\fP() \\n\\\&
    Shift Ctrl  KP_Add:\fBsmaller-vt-font\fP() \\n\\\&
    Shift  KP_Subtract:\fBsmaller-vt-font\fP() \\n\\\&
                ~Meta :\fBinsert-seven-bit\fP() \\n\\\&
                 Meta :\fBinsert-eight-bit\fP() \\n\\\&
                !Ctrl :\fBpopup-menu\fP(mainMenu) \\n\\\&
           !Lock Ctrl :\fBpopup-menu\fP(mainMenu) \\n\\\&
 !Lock Ctrl @Num_Lock :\fBpopup-menu\fP(mainMenu) \\n\\\&
     ! @Num_Lock Ctrl :\fBpopup-menu\fP(mainMenu) \\n\\\&
                ~Meta :\fBselect-start\fP() \\n\\\&
              ~Meta :\fBselect-extend\fP() \\n\\\&
                !Ctrl :\fBpopup-menu\fP(vtMenu) \\n\\\&
           !Lock Ctrl :\fBpopup-menu\fP(vtMenu) \\n\\\&
 !Lock Ctrl @Num_Lock :\fBpopup-menu\fP(vtMenu) \\n\\\&
     ! @Num_Lock Ctrl :\fBpopup-menu\fP(vtMenu) \\n\\\&
          ~Ctrl ~Meta :\fBignore\fP() \\n\\\&
                 Meta :\fBclear-saved-lines\fP() \\n\\\&
            ~Ctrl ~Meta :\fBinsert-selection\fP(\fBSELECT\fP, CUT_BUFFER0) \\n\\\&
                !Ctrl :\fBpopup-menu\fP(fontMenu) \\n\\\&
           !Lock Ctrl :\fBpopup-menu\fP(fontMenu) \\n\\\&
 !Lock Ctrl @Num_Lock :\fBpopup-menu\fP(fontMenu) \\n\\\&
     ! @Num_Lock Ctrl :\fBpopup-menu\fP(fontMenu) \\n\\\&
          ~Ctrl ~Meta :\fBstart-extend\fP() \\n\\\&
              ~Meta :\fBselect-extend\fP() \\n\\\&
                 Ctrl :\fBscroll-back\fP(1,halfpage,m) \\n\\\&
            Lock Ctrl :\fBscroll-back\fP(1,halfpage,m) \\n\\\&
  Lock @Num_Lock Ctrl :\fBscroll-back\fP(1,halfpage,m) \\n\\\&
       @Num_Lock Ctrl :\fBscroll-back\fP(1,halfpage,m) \\n\\\&
                      :\fBscroll-back\fP(5,line,m)     \\n\\\&
                 Ctrl :\fBscroll-forw\fP(1,halfpage,m) \\n\\\&
            Lock Ctrl :\fBscroll-forw\fP(1,halfpage,m) \\n\\\&
  Lock @Num_Lock Ctrl :\fBscroll-forw\fP(1,halfpage,m) \\n\\\&
       @Num_Lock Ctrl :\fBscroll-forw\fP(1,halfpage,m) \\n\\\&
                      :\fBscroll-forw\fP(5,line,m)     \\n\\\&
                         :\fBselect-end\fP(\fBSELECT\fP, CUT_BUFFER0) \\n\\\&
                       :\fBignore\fP()
.NE
.PP
The default bindings in the Tektronix window are analogous but less extensive.
These are for the \fItek4014\fP widget:
.NS
                 ~Meta: \fBinsert-seven-bit\fP() \\n\\\&
                  Meta: \fBinsert-eight-bit\fP() \\n\\\&
                !Ctrl : \fBpopup-menu\fP(mainMenu) \\n\\\&
           !Lock Ctrl : \fBpopup-menu\fP(mainMenu) \\n\\\&
 !Lock Ctrl @Num_Lock : \fBpopup-menu\fP(mainMenu) \\n\\\&
      !Ctrl @Num_Lock : \fBpopup-menu\fP(mainMenu) \\n\\\&
                !Ctrl : \fBpopup-menu\fP(tekMenu) \\n\\\&
           !Lock Ctrl : \fBpopup-menu\fP(tekMenu) \\n\\\&
 !Lock Ctrl @Num_Lock : \fBpopup-menu\fP(tekMenu) \\n\\\&
      !Ctrl @Num_Lock : \fBpopup-menu\fP(tekMenu) \\n\\\&
           Shift ~Meta: \fBgin-press\fP(L) \\n\\\&
                 ~Meta: \fBgin-press\fP(l) \\n\\\&
           Shift ~Meta: \fBgin-press\fP(M) \\n\\\&
                 ~Meta: \fBgin-press\fP(m) \\n\\\&
           Shift ~Meta: \fBgin-press\fP(R) \\n\\\&
                 ~Meta: \fBgin-press\fP(r)
.NE
.SS Custom Key Bindings
.PP
You can modify the \fBtranslations\fP resource by overriding parts
of it, or merging your resources with it.
.PP
Here is an example which uses shifted select/paste to copy to the clipboard,
and unshifted select/paste for the primary selection.
In each case, a (different) cut buffer is
also a target or source of the select/paste operation.
It is important to remember however,
that cut buffers store data in ISO-8859-1 encoding,
while selections can store data in a variety of formats and encodings.
While \fI\*n\fP owns the selection, it highlights it.
When it loses the selection, it removes the corresponding highlight.
But you can still paste from the corresponding cut buffer.
.NS
*VT100*translations:    #override \\n\\\&
   ~Shift~Ctrl: \fBinsert-selection\fP(\fBPRIMARY\fP, CUT_BUFFER0) \\n\\\&
    Shift~Ctrl: \fBinsert-selection\fP(\fBCLIPBOARD\fP, CUT_BUFFER1) \\n\\\&
   ~Shift      : \fBselect-end\fP(\fBPRIMARY\fP, CUT_BUFFER0) \\n\\\&
    Shift      : \fBselect-end\fP(\fBCLIPBOARD\fP, CUT_BUFFER1)
.NE
.PP
In the example, the class name \fBVT100\fP is used rather than the widget name.
These are different; a class name could apply to more than one widget.
A leading \*(``*\*('' is used because the widget hierarchy above the
\fIvt100\fP widget depends on
whether the toolbar support is compiled into \fI\*n\fP.
.PP
Not everyone finds the three-button mouse bindings easy to use.
In a wheel mouse, the middle button might be the wheel.
As an alternative, you could add a binding shifted keys:
.NS
*VT100*translations:      #override \\n\\
    Shift Home:    \fBcopy-selection\fP(\fBSELECT\fP) \\n\\
    Shift Insert:  \fBcopy-selection\fP(\fBSELECT\fP) \\n\\
    Ctrl Shift C:  \fBcopy-selection\fP(\fBSELECT\fP) \\n\\
    Ctrl Shift V:  \fBinsert-selection\fP(\fBSELECT\fP)
.NE
.PP
You would still use the left- and right-mouse buttons (typically 1 and 3)
for beginning and extending selections. 
.PP
Besides mouse problems, there are also keyboards with inconvenient layouts.
Some lack a numeric keypad, making it hard to use the shifted keypad plus
and minus bindings for switching between font sizes.
You can work around that by assigning the actions to more readily accessed
keys:
.NS
*VT100*translations:      #override \\n\\
    Ctrl  +:       \fBlarger-vt-font\fP() \\n\\
    Ctrl  -:       \fBsmaller-vt-font\fP()
.NE
.PP
The keymap feature allows you to switch between sets of translations.
The sample below shows
how the \fBkeymap()\fP action may be used to add special
keys for entering commonly-typed words:
.NS
*VT100.Translations: #override F13: keymap(dbx)
*VT100.dbxKeymap.translations: \\\&
        F14:       \fBkeymap\fP(None) \\n\\\&
        F17:       \fBstring\fP("next") \\n\\
                        \fBstring\fP(0x0d) \\n\\\&
        F18:       \fBstring\fP("step") \\n\\
                        \fBstring\fP(0x0d) \\n\\\&
        F19:       \fBstring\fP("continue") \\n\\
                        \fBstring\fP(0x0d) \\n\\\&
        F20:       \fBstring\fP("print ") \\n\\
                        \fBinsert-selection\fP(\fBPRIMARY\fP, CUT_BUFFER0)
.NE
.SS Default Scrollbar Bindings
.PP
Key bindings are normally associated with the \fIvt100\fP or \fItek4014\fP
widgets which act as terminal emulators.
\fI\*N\fP's scrollbar (and toolbar if it is configured) are separate widgets.
Because all of these use the X Toolkit,
they have corresponding \fBtranslations\fP resources.
Those resources are distinct,
and match different patterns, e.g., the differences in widget-name and
number of levels of widgets which they may contain.
.PP
The \fIscrollbar\fP widget is a child of the \fIvt100\fP widget.
It is positioned on top of the \fIvt100\fP widget.
Toggling the scrollbar on and off causes the \fIvt100\fP widget to resize.
.PP
The default bindings for the scrollbar widget use only mouse-button events:
.NS
   : StartScroll(Forward) \\n\\\&
   : StartScroll(Forward) \\n\\\&
   : StartScroll(Continuous) MoveThumb() NotifyThumb() \\n\\\&
   : StartScroll(Backward) \\n\\\&
   : StartScroll(Backward) \\n\\\&
   : MoveThumb() NotifyThumb() \\n\\\&
   :    NotifyScroll(Proportional) EndScroll()
.NE
.PP
Events which the \fIscrollbar\fP widget does not recognize at all are lost.
.PP
However, at startup, \fI\*n\fP augments these translations with the default
translations used for the \fIvt100\fP widget,
together with the resource \*(``actions\*('' which those translations use.
Because the \fIscrollbar\fP (or \fImenubar\fP) widgets do not recognize these
actions (but because it has a corresponding translation),
they are passed on to the \fIvt100\fP widget.
.PP
This augmenting of the scrollbar's translations has a few limitations:
.bP
\fI\*N\fP knows what the default translations are,
but there is no suitable library interface for determining what
customizations a user may have added to the \fIvt100\fP widget.
All that \fI\*n\fP can do is augment the \fIscrollbar\fP widget to
give it the same starting point for further customization by the user.
.bP
Events in the gap between the widgets may be lost.
.bP
Compose sequences begun in one widget cannot be completed in the other,
because the input methods for each widget do not share context information.
.PP
Most customizations of the scrollbar translations do not concern key bindings.
Rather, users are generally more interested in changing the bindings of the
mouse buttons.
For example, some people prefer using the left pointer button
for dragging the scrollbar thumb.
That can be set up by altering the translations resource, e.g.,
.NS
*VT100.scrollbar.translations:  #override \\n\\\&
   :     StartScroll(Forward) \\n\\\&
   :     StartScroll(Continuous) MoveThumb() NotifyThumb() \\n\\\&
   :     StartScroll(Backward) \\n\\\&
   :   MoveThumb() NotifyThumb() \\n\\\&
   :        NotifyScroll(Proportional) EndScroll()
.NE
.SH "CONTROL SEQUENCES AND KEYBOARD"
Applications can send sequences of characters to the terminal to change its
behavior.
Often they are referred to as
\*(``ANSI escape sequences\*('' or just plain
\*(``escape sequences\*('' but both terms are misleading:
.bP
ANSI x3.64 (obsolete) which was replaced by ISO 6429 (ECMA-48) gave rules
for the \fIformat\fP of these sequences of characters.
.bP
While the original VT100 was claimed to be ANSI-compatible (against x3.64),
there is no freely available version of the ANSI standard to show where
the VT100 differs.
Most of the documents which mention the ANSI standard have
additions not found in the original (such as those
based on \fBansi.sys\fP).
So this discussion focuses on the ISO standards.
.bP
The standard describes only sequences sent from the host to the terminal.
There is no standard for sequences sent by special keys from the terminal
to the host.
By convention (and referring to existing terminals), the format of those
sequences usually conforms to the host-to-terminal standard.
.bP
Some of \fI\*n\fP's sequences do not fit into the standard scheme.
Technically those are \*(``unspecified\*(''.
As an example,
DEC Screen Alignment Test (DECALN) is this three-character sequence:
.NS
\fIESC\fP # 8
.NE
.PP
.bP
Some sequences fit into the standard format,
but are not listed in the standard.
These include the sequences used for setting up scrolling margins
and doing forward/reverse scrolling.
.bP
Some of the sequences (in particular, the single-character functions
such as tab and backspace)
do not include the \fIescape\fP character.
.PP
With all of that in mind, the standard refers to these sequences of
characters as \*(``control sequences\*(''.
.PP
\fI\*N Control Sequences\fP lists the control sequences which
an application can send \fI\*n\fP to make it perform various operations.
Most of these operations are standardized, from either the DEC or Tektronix
terminals, or from more widely used standards such as ISO-6429.
.PP
A few examples of usage are given in this section.
.SS Window and Icon Titles
.PP
Some scripts use \fBecho\fP with options \fB\-e\fP and \fB\-n\fP to tell
the shell to interpret the string \*(``\\e\*('' as the \fIescape\fP character and
to suppress a trailing newline on output.
Those are not portable, not recommended.
Instead, use \fBprintf\fP (POSIX).
.PP
For example, to set the \fIwindow title\fP to \*(``Hello world!\*('',
you could use one of these commands in a script:
.NS
printf '\\033]2;Hello world!\\033\\'
printf '\\033]2;Hello world!\\007'
printf '\\033]2;%s\\033\\' "Hello world!"
printf '\\033]2;%s\\007' "Hello world!"
.NE
.PP
The \fBprintf\fP command interprets the octal value \*(``\\033\*('' for
\fIescape\fP, and (since it was not given in the format) omits a trailing
newline from the output.
.PP
Some programs (such as \fBscreen\fP(1)) set both window- and icon-titles
at the same time, using a slightly different control sequence:
.NS
printf '\\033]0;Hello world!\\033\\'
printf '\\033]0;Hello world!\\007'
printf '\\033]0;%s\\033\\' "Hello world!"
printf '\\033]0;%s\\007' "Hello world!"
.NE
.PP
The difference is the \fIparameter\fP \*(``0\*('' in each command.
Most window managers will honor either window title or icon title.
Some will make a distinction and allow you to set just the icon title.
You can tell \fI\*n\fP to ask for this with a different parameter
in the control sequence:
.NS
printf '\\033]1;Hello world!\\033\\'
printf '\\033]1;Hello world!\\007'
printf '\\033]1;%s\\033\\' "Hello world!"
printf '\\033]1;%s\\007' "Hello world!"
.NE
.
.SS Special Keys
.PP
\fI\*N\fP, like any VT100-compatible terminal emulator,
has two modes for the \fIspecial keys\fP (cursor-keys, numeric keypad,
and certain function-keys):
.bP
\fInormal mode\fP, which makes the special keys transmit 
\*(``useful\*('' sequences such as the control sequence for cursor-up
when pressing the up-arrow, and
.bP
\fIapplication mode\fP,
which uses a different control sequence that cannot be mistaken for
the 
\*(``useful\*('' sequences.
.PP
The main difference between the two modes is that normal mode sequences
start with \fICSI\fP (\fIescape\ [\fP) and application mode sequences
start with \fISS3\fP (\fIescape\ O\fP).
.PP
The terminal is initialized into one of these two modes (usually the
normal mode), based on the terminal description (termcap or terminfo).
The terminal description also has capabilities (strings) defined for
the keypad mode used in curses applications.
.PP
There is a problem in using the terminal description for applications
that are not intended to be full-screen curses applications:
the definitions of special keys are only correct for this keypad mode.
For example, some shells
(unlike \fBksh\fP(1), which appears to be hard-coded, not even using termcap)
allow their users to customize key-bindings,
assigning shell actions to special keys.
.bP
\fBbash\fP(1) allows \fIconstant\fP strings to be assigned
to functions.
This is only successful if the terminal is initialized to application
mode by default,
because \fBbash\fP lacks flexibility in this area.
It uses a (less expressive than \fBbash\fP's)
\fBreadline\fP scripting language for setting up key bindings,
which relies upon the user to statically enumerate the possible bindings for
given values of \fB$TERM\fP.
.bP
\fBzsh\fP(1) provides an analogous feature,
but it accepts runtime expressions,
as well as providing a \fB$terminfo\fP array for scripts.
In particular, one can use the terminal database,
transforming when defining a key-binding.
By transforming the output so that \fICSI\fP and \fISS3\fP are equated,
\fBzsh\fP can use the terminal database to obtain useful definitions
for its command-line use regardless of whether the terminal uses
normal or application mode initially.
Here is an example:
.NS
[[ "$terminfo[kcuu1]" == "^[O"* ]] && \\
bindkey -M viins "${terminfo[kcuu1]/O/[}" \\
vi-up-line-or-history
.NE
.
.
.SS Changing Colors
.PP
A few shell programs provide the ability for users to add color and other
video attributes to the shell prompt strings.
Users can do this by setting \fB$PS1\fP (the primary prompt string).
Again, \fBbash\fP and \fBzsh\fP have provided features not found in \fBksh\fP.
There is a problem, however: the prompt's width on the screen will not
necessarily be the same as the number of characters.
Because there is no guidance in the POSIX standard, each shell addresses
the problem in a different way:
.bP
\fBbash\fP treats characters within 
\*(``\\[\*('' and
\*(``\\]\*(''
as nonprinting (using no width on the screen).
.bP
\fBzsh\fP treats characters within 
\*(``%{\*('' and
\*(``%}\*(''
as nonprinting.
.PP
In addition to the difference in syntax,
the shells provide different methods for obtaining useful escape sequences:
.bP
As noted in \fBSpecial Keys\fP, \fBzsh\fP initializes the $terminfo array
with the terminal capabilities.
.IP
It also provides a function \fBechoti\fP which works like \fBtput\fP(1)
to convert a terminal capability with its parameters into a string
that can be written to the terminal.
.bP
Shells lacking a comparable feature (such as \fBbash\fP) can always
use the program \fBtput\fP to do this transformation.
.PP
Hard-coded escape sequences are supported by each shell,
but are not recommended because those rely upon particular configurations
and cannot be easily moved between different user environments.
.
.
.SH ENVIRONMENT
\fI\*N\fP sets several environment variables.
.SS System Independent
.PP
Some variables are used on every system:
.TP 5
.B DISPLAY
is the display name,
pointing to the X server (see \fIDISPLAY NAMES\fP in X(__miscmansuffix__)).
.TP 5
.B TERM
.br
is set according to the terminfo (or termcap) entry which it is using as
a reference.
.IP
On some systems, you may encounter situations where the shell which you
use and \fI\*n\fP are built using libraries with different terminal databases.
In that situation, \fI\*n\fP may choose a terminal description not known
to the shell.
.TP 5
.B WINDOWID
is set to the X window id number of the \fI\*n\fP window.
.TP 5
.B XTERM_FILTER
is set if a locale-filter is used.
The value is the pathname of the filter.
.TP 5
.B XTERM_LOCALE
shows the locale which was used by \fI\*n\fP on startup.
Some shell initialization scripts may set a different locale.
.TP 5
.B XTERM_SHELL
is set to the pathname of the program which is invoked.
Usually that is a shell program, e.g., \fI/bin/sh\fP.
Since it is not necessarily a shell program however,
it is distinct from \*(``SHELL\*(''.
.TP 5
.B XTERM_VERSION
is set to the string displayed by the \fB\-version\fP option.
That is normally an identifier for the X Window libraries used to
build \fI\*n\fP, followed by
\fI\*n\fP's patch number in parenthesis.
The patch number is also part of the response to a Secondary Device Attributes
(DA) control sequence (see \fIXterm Control Sequences\fP).
.
.SS System Dependent
.
.PP
Depending on your system configuration, \fI\*n\fP may also set the
following:
.TP 5
.B COLUMNS
the width of the \fI\*n\fP in characters (cf: \*(``stty columns\*('').
.IP
When this variable is set, \fIcurses\fP applications (and most
terminal programs) will assume that the terminal has this many columns.
.IP
\fI\*N\fP would do this for systems which have no ability
to tell the size of the terminal.
Those are very rare, none newer than the mid 1990s when SVR4 became prevalent.
.TP 5
.B HOME
.br
when \fI\*n\fP is configured (at build-time) to update utmp.
.TP 5
.B LINES
the height of the \fI\*n\fP in characters (cf: \*(``stty rows\*('').
.IP
When this variable is set, \fIcurses\fP applications (and most
terminal programs) will assume that the terminal has this many lines (rows).
.IP
\fI\*N\fP would do this for systems which have no ability
to tell the size of the terminal.
Those are very rare, none newer than the mid 1990s when SVR4 became prevalent.
.TP 5
.B LOGNAME
when \fI\*n\fP is configured (at build-time) to update utmp.
.IP
Your configuration may have set \fBLOGNAME\fP; \fI\*n\fP does not modify that.
If it is unset, \fI\*n\fP will use \fBUSER\fP if it is set.
Finally, if neither is set, \fI\*n\fP will use the \fBgetlogin\fP(2) function.
.TP 5
.B SHELL
when \fI\*n\fP is configured (at build-time) to update utmp.
It is also set if you provide a valid shell name as the optional parameter.
.IP
\fI\*N\fP sets this to an absolute pathname.
If you have set the variable to a relative pathname,
\fI\*n\fP may set it to a different shell pathname.
.IP
If you have set this to an pathname which does not correspond to a valid
shell, \fI\*n\fP may unset it, to avoid confusion.
.TP 5
.B TERMCAP
the contents of the termcap entry corresponding to \fB$TERM\fP,
with lines and columns values substituted
for the actual size window you have created.
.IP
This feature is, like \fBLINES\fP and \fBCOLUMNS\fP, used rarely.
It addresses the same limitation of a few older systems
by providing a way for \fItermcap\fP-based applications to get the initial
screensize.
.TP 5
.B TERMINFO
may be defined to a nonstandard location using the configure script.
.\"
.
.
.SH FILES
The actual pathnames given may differ on your system.
.TP 5
\fI/etc/shells\fP
contains a list of valid shell programs,
used by \fI\*n\fP to decide if the \*(``SHELL\*('' environment
variable should be set for the process started by \fI\*n\fP.
.TP 5
\fI/etc/utmp\fP
the system logfile, which records user logins.
.TP 5
\fI/etc/wtmp\fP
the system logfile, which records user logins and logouts.
.TP 5
.I __apploaddir__/__default_class__
the \fI\*n\fP default application resources.
.TP 5
.I __apploaddir__/__default_class__\-color
the \fI\*n\fP color application resources.
If your display supports color, use this
.in +10
*customization: \-color
.in -10
in your .Xdefaults file to
automatically use this resource file rather than
.IR __apploaddir__/__default_class__ .
If you do not do this,
\fI\*n\fP uses its compiled-in default resource settings for colors.
.TP 5
.I __pixmapsdir__
the directory in which \fI\*n\fP's pixmap icon files are installed.
.
.
.SH ERROR MESSAGES
Most of the fatal error messages from \fI\*n\fP use the following format:
.NS
\*n: Error \fIXXX\fP, errno \fIYYY\fP: \fIZZZ\fR
.NE
.PP
The \fIXXX\fP codes (which are used by \fI\*n\fP as its exit-code)
are listed below, with a brief explanation.
.TP 5
1
is used for miscellaneous errors, usually accompanied by a specific message,
.TP
11
ERROR_FIONBIO
.br
main: ioctl() failed on FIONBIO
.TP
12
ERROR_F_GETFL
.br
main: ioctl() failed on F_GETFL
.TP
13
ERROR_F_SETFL
.br
main: ioctl() failed on F_SETFL
.TP
14
ERROR_OPDEVTTY
.br
spawn: open() failed on /dev/tty
.TP
15
ERROR_TIOCGETP
.br
spawn: ioctl() failed on TIOCGETP
.TP
17
ERROR_PTSNAME
.br
spawn: ptsname() failed
.TP
18
ERROR_OPPTSNAME
.br
spawn: open() failed on ptsname
.TP
19
ERROR_PTEM
.br
spawn: ioctl() failed on I_PUSH/"ptem"
.TP
20
ERROR_CONSEM
.br
spawn: ioctl() failed on I_PUSH/"consem"
.TP
21
ERROR_LDTERM
.br
spawn: ioctl() failed on I_PUSH/"ldterm"
.TP
22
ERROR_TTCOMPAT
.br
spawn: ioctl() failed on I_PUSH/"ttcompat"
.TP
23
ERROR_TIOCSETP
.br
spawn: ioctl() failed on TIOCSETP
.TP
24
ERROR_TIOCSETC
.br
spawn: ioctl() failed on TIOCSETC
.TP
25
ERROR_TIOCSETD
.br
spawn: ioctl() failed on TIOCSETD
.TP
26
ERROR_TIOCSLTC
.br
spawn: ioctl() failed on TIOCSLTC
.TP
27
ERROR_TIOCLSET
.br
spawn: ioctl() failed on TIOCLSET
.TP
28
ERROR_INIGROUPS
.br
spawn: initgroups() failed
.TP
29
ERROR_FORK
.br
spawn: fork() failed
.TP
30
ERROR_EXEC
.br
spawn: exec() failed
.TP
32
ERROR_PTYS
.br
get_pty: not enough ptys
.TP
34
ERROR_PTY_EXEC
.br
waiting for initial map
.TP
35
ERROR_SETUID
.br
spawn: setuid() failed
.TP
36
ERROR_INIT
.br
spawn: can't initialize window
.TP
46
ERROR_TIOCKSET
.br
spawn: ioctl() failed on TIOCKSET
.TP
47
ERROR_TIOCKSETC
.br
spawn: ioctl() failed on TIOCKSETC
.TP
49
ERROR_LUMALLOC
.br
luit: command-line malloc failed
.TP
50
ERROR_SELECT
.br
in_put: select() failed
.TP
54
ERROR_VINIT
.br
VTInit: can't initialize window
.TP
57
ERROR_KMMALLOC1
.br
HandleKeymapChange: malloc failed
.TP
60
ERROR_TSELECT
.br
Tinput: select() failed
.TP
64
ERROR_TINIT
.br
TekInit: can't initialize window
.TP
71
ERROR_BMALLOC2
.br
SaltTextAway: malloc() failed
.TP
80
ERROR_LOGEXEC
.br
StartLog: exec() failed
.TP
83
ERROR_XERROR
.br
xerror: XError event
.TP
84
ERROR_XIOERROR
.br
xioerror: X I/O error
.TP
85
ERROR_ICEERROR
.br
ICE I/O error
.TP
90
ERROR_SCALLOC
.br
Alloc: calloc() failed on base
.TP
91
ERROR_SCALLOC2
.br
Alloc: calloc() failed on rows
.TP
102
ERROR_SAVE_PTR
.br
ScrnPointers: malloc/realloc() failed
.
.
.SH BUGS
.
.PP
Large pastes do not work on some systems.
This is not a bug in
\fI\*n\fP; it is a bug in the pseudo terminal driver of those
systems.
\fI\*N\fP feeds large pastes to the pty only as fast as the pty
will accept data, but some pty drivers do not return enough information
to know if the write has succeeded.
.
.PP
When connected to an input method, it is possible for \*n to hang
if the XIM server is suspended or killed.
.
.PP
Many of the options are not resettable after
.I \*n
starts.
.
.PP
This program still needs to be rewritten.
It should be split into very
modular sections, with the various emulators being completely separate
widgets that do not know about each other.
Ideally, you'd like to be able to
pick and choose emulator widgets and stick them into a single control widget.
.
.PP
There needs to be a dialog box to allow entry of the Tek COPY file name.
.
.
.SH "SEE ALSO"
.na
resize(__mansuffix__),
luit(__mansuffix__),
u\*n(__mansuffix__),
X(__miscmansuffix__),
pty(4),
tty(4)
.ad
.PP
\fIXterm Control Sequences\fP
(this is the file ctlseqs.ms).
.sp
http://invisible-island.net/xterm/xterm.html
.br
http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
.br
http://invisible-island.net/xterm/xterm.faq.html
.
.
.SH AUTHORS
Far too many people, including:
.sp
Loretta Guarino Reid (DEC-UEG-WSL),
Joel McCormack (DEC-UEG-WSL), Terry Weissman (DEC-UEG-WSL),
Edward Moy (Berkeley), Ralph R. Swick (MIT-Athena),
Mark Vandevoorde (MIT-Athena), Bob McNamara (DEC-MAD),
Jim Gettys (MIT-Athena), Bob Scheifler (MIT X Consortium), Doug Mink (SAO),
Steve Pitschke (Stellar), Ron Newman (MIT-Athena), Jim Fulton (MIT X
Consortium), Dave Serisky (HP), Jonathan Kamens (MIT-Athena),
Jason Bacon,
Jens Schweikhardt,
Ross Combs,
Stephen P. Wall,
David Wexelblat, and
Thomas Dickey (invisible-island.net).
xterm-330/data.c0000644000175100001440000000740112723523543012324 0ustar  tomusers/* $XTermId: data.c,v 1.96 2016/06/01 09:14:11 tom Exp $ */

/*
 * Copyright 2002-2013,2016 by Thomas E. Dickey
 *
 *                         All Rights Reserved
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name(s) of the above copyright
 * holders shall not be used in advertising or otherwise to promote the
 * sale, use or other dealings in this Software without prior written
 * authorization.
 *
 * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 *
 *                         All Rights Reserved
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose and without fee is hereby granted,
 * provided that the above copyright notice appear in all copies and that
 * both that copyright notice and this permission notice appear in
 * supporting documentation, and that the name of Digital Equipment
 * Corporation not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 *
 *
 * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */

#include 

Widget toplevel;		/* top-most widget in xterm */

#if OPT_TEK4014
Char *Tpushb;
Char *Tpushback;
TekLink *tekRefreshList;
TekWidget tekWidget;
Widget tekshellwidget;
int T_lastx = -1;
int T_lasty = -1;
int Ttoggled = 0;
jmp_buf Tekend;
#endif

char *ProgramName;

Arg ourTopLevelShellArgs[] =
{
    {XtNallowShellResize, (XtArgVal) True},
    {XtNinput, (XtArgVal) True},
};
Cardinal number_ourTopLevelShellArgs = 2;

Atom wm_delete_window;		/* for ICCCM delete window */

Boolean guard_keyboard_type = False;
XTERM_RESOURCE resource;

PtyData *VTbuffer;

jmp_buf VTend;

#ifdef DEBUG
int debug = 0;			/* true causes error messages to be displayed */
#endif /* DEBUG */

XtAppContext app_con;
XtermWidget term;		/* master data structure for client */

int hold_screen;
SIG_ATOMIC_T need_cleanup = False;
SIG_ATOMIC_T caught_intr = False;

int am_slave = -1;		/* set to file-descriptor if we're a slave process */
int max_plus1;
PtySelect Select_mask;
PtySelect X_mask;
PtySelect pty_mask;
char *ptydev;
char *ttydev;

#if HANDLE_STRUCT_NOTIFY
int mapstate = -1;
#endif /* HANDLE_STRUCT_NOTIFY */

#ifdef HAVE_LIB_XCURSOR
char *xterm_cursor_theme;
#endif

#if OPT_SESSION_MGT
int ice_fd = -1;
#endif

#ifdef USE_IGNORE_RC
int ignore_unused;
#endif
xterm-330/print.c0000644000175100001440000005177113121703441012546 0ustar  tomusers/* $XTermId: print.c,v 1.161 2017/06/19 08:11:13 tom Exp $ */

/*
 * Copyright 1997-2016,2017 by Thomas E. Dickey
 *
 *                         All Rights Reserved
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name(s) of the above copyright
 * holders shall not be used in advertising or otherwise to promote the
 * sale, use or other dealings in this Software without prior written
 * authorization.
 */

#include 
#include 
#include 
#include 
#include 

#include 
#include 

#undef  CTRL
#define	CTRL(c)	((c) & 0x1f)

#define SHIFT_IN  '\017'
#define SHIFT_OUT '\016'

#define CSET_IN   'A'
#define CSET_OUT  '0'

#define isForm(c)      ((c) == '\r' || (c) == '\n' || (c) == '\f')
#define Strlen(a)      strlen((const char *)a)
#define Strcmp(a,b)    strcmp((const char *)a,(const char *)b)
#define Strncmp(a,b,c) strncmp((const char *)a,(const char *)b,c)

#define SPS PrinterOf(screen)

#ifdef VMS
#define VMS_TEMP_PRINT_FILE "sys$scratch:xterm_print.txt"
#endif

static void charToPrinter(XtermWidget /* xw */ ,
			  unsigned /* chr */ );
static void printLine(XtermWidget /* xw */ ,
		      int /* row */ ,
		      unsigned /* chr */ ,
		      PrinterFlags * /* p */ );
static void send_CharSet(XtermWidget /* xw */ ,
			 LineData * /* ld */ );
static void send_SGR(XtermWidget /* xw */ ,
		     unsigned /* attr */ ,
		     unsigned /* fg */ ,
		     unsigned /* bg */ );
static void stringToPrinter(XtermWidget /* xw */ ,
			    const char * /*str */ );

static void
closePrinter(XtermWidget xw GCC_UNUSED)
{
    if (xtermHasPrinter(xw) != 0) {
	TScreen *screen = TScreenOf(xw);
#ifdef VMS
	char pcommand[256];
	(void) sprintf(pcommand, "%s %s;",
		       SPS.printer_command,
		       VMS_TEMP_PRINT_FILE);
#endif

	if (SPS.fp != 0) {
	    DEBUG_MSG("closePrinter\n");
	    pclose(SPS.fp);
	    TRACE(("closed printer, waiting...\n"));
#ifdef VMS			/* This is a quick hack, really should use
				   spawn and check status or system services
				   and go straight to the queue */
	    (void) system(pcommand);
#else /* VMS */
	    while (nonblocking_wait() > 0) {
		;
	    }
#endif /* VMS */
	    SPS.fp = 0;
	    SPS.isOpen = False;
	    TRACE(("closed printer\n"));
	    DEBUG_MSG("...closePrinter (done)\n");
	}
    }
}

static void
printCursorLine(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);

    TRACE(("printCursorLine\n"));
    printLine(xw, screen->cur_row, '\n', getPrinterFlags(xw, NULL, 0));
}

#define NO_COLOR	((unsigned)-1)

/*
 * DEC's manual doesn't document whether trailing blanks are removed, or what
 * happens with a line that is entirely blank.  This function prints the
 * characters that xterm would allow as a selection (which may include blanks).
 */
static void
printLine(XtermWidget xw, int row, unsigned chr, PrinterFlags *p)
{
    TScreen *screen = TScreenOf(xw);
    int inx = ROW2INX(screen, row);
    LineData *ld;
    int last = MaxCols(screen);
#if OPT_ISO_COLORS && OPT_PRINT_COLORS
#define ColorOf(ld,col) (ld->color[col])
#endif
    unsigned fg = NO_COLOR;
    unsigned bg = NO_COLOR;
#if OPT_PRINT_COLORS
    unsigned last_fg = NO_COLOR;
    unsigned last_bg = NO_COLOR;
#endif

    ld = getLineData(screen, inx);
    if (ld == 0)
	return;

    TRACE(("printLine(row=%d/%d, top=%d:%d, chr=%d):%s\n",
	   row, ROW2INX(screen, row), screen->topline, screen->max_row, chr,
	   visibleIChars(ld->charData, (unsigned) last)));

    while (last > 0) {
	if ((ld->attribs[last - 1] & CHARDRAWN) == 0)
	    last--;
	else
	    break;
    }

    if (last) {
	int col;
	int cs = CSET_IN;
	int last_cs = CSET_IN;

	if (p->print_attributes) {
	    send_CharSet(xw, ld);
	    send_SGR(xw, 0, NO_COLOR, NO_COLOR);
	}
	for (col = 0; col < last; col++) {
	    IAttr attr = 0;
	    unsigned ch = ld->charData[col];
#if OPT_PRINT_COLORS
	    if (screen->colorMode) {
		if (p->print_attributes > 1) {
		    fg = (ld->attribs[col] & FG_COLOR)
			? extract_fg(xw, ColorOf(ld, col), ld->attribs[col])
			: NO_COLOR;
		    bg = (ld->attribs[col] & BG_COLOR)
			? extract_bg(xw, ColorOf(ld, col), ld->attribs[col])
			: NO_COLOR;
		}
	    }
#endif
	    if ((((ld->attribs[col] & SGR_MASK) != attr)
#if OPT_PRINT_COLORS
		 || (last_fg != fg) || (last_bg != bg)
#endif
		)
		&& ch) {
		attr = ld->attribs[col] & SGR_MASK;
#if OPT_PRINT_COLORS
		last_fg = fg;
		last_bg = bg;
#endif
		if (p->print_attributes)
		    send_SGR(xw, attr, fg, bg);
	    }

	    if (ch == 0)
		ch = ' ';

#if OPT_WIDE_CHARS
	    if (screen->utf8_mode)
		cs = CSET_IN;
	    else
#endif
		cs = (ch >= ' ' && ch != ANSI_DEL) ? CSET_IN : CSET_OUT;
	    if (last_cs != cs) {
		if (p->print_attributes) {
		    charToPrinter(xw,
				  (unsigned) ((cs == CSET_OUT)
					      ? SHIFT_OUT
					      : SHIFT_IN));
		}
		last_cs = cs;
	    }

	    /* FIXME:  we shouldn't have to map back from the
	     * alternate character set, except that the
	     * corresponding charset information is not encoded
	     * into the CSETS array.
	     */
	    charToPrinter(xw,
			  ((cs == CSET_OUT)
			   ? (ch == ANSI_DEL ? 0x5f : (ch + 0x5f))
			   : ch));
	    if_OPT_WIDE_CHARS(screen, {
		size_t off;
		for_each_combData(off, ld) {
		    ch = ld->combData[off][col];
		    if (ch == 0)
			break;
		    charToPrinter(xw, ch);
		}
	    });
	}
	if (p->print_attributes) {
	    send_SGR(xw, 0, NO_COLOR, NO_COLOR);
	    if (cs != CSET_IN)
		charToPrinter(xw, SHIFT_IN);
	}
    }

    /* finish line (protocol for attributes needs a CR */
    if (p->print_attributes)
	charToPrinter(xw, '\r');

    if (chr && !(p->printer_newline)) {
	if (LineTstWrapped(ld))
	    chr = '\0';
    }

    if (chr)
	charToPrinter(xw, chr);

    return;
}

#define PrintNewLine() (unsigned) (((top < bot) || p->printer_newline) ? '\n' : '\0')

static void
printLines(XtermWidget xw, int top, int bot, PrinterFlags *p)
{
    TRACE(("printLines, rows %d..%d\n", top, bot));
    while (top <= bot) {
	printLine(xw, top, PrintNewLine(), p);
	++top;
    }
}

void
xtermPrintScreen(XtermWidget xw, Bool use_DECPEX, PrinterFlags *p)
{
    if (XtIsRealized((Widget) xw)) {
	TScreen *screen = TScreenOf(xw);
	Bool extent = (use_DECPEX && p->printer_extent);
	Boolean was_open = SPS.isOpen;

	printLines(xw,
		   extent ? 0 : screen->top_marg,
		   extent ? screen->max_row : screen->bot_marg,
		   p);
	if (p->printer_formfeed)
	    charToPrinter(xw, '\f');

	if (!was_open || SPS.printer_autoclose) {
	    closePrinter(xw);
	}
    } else {
	Bell(xw, XkbBI_MinorError, 0);
    }
}

/*
 * If p->print_everything is zero, use this behavior:
 * If the alternate screen is active, we'll print only that.  Otherwise, print
 * the normal screen plus all scrolled-back lines.  The distinction is made
 * because the normal screen's buffer is part of the overall scrollback buffer.
 *
 * Otherwise, decode bits:
 *	1 = current screen
 *	2 = normal screen
 *	4 = alternate screen
 *	8 = saved lines
 */
void
xtermPrintEverything(XtermWidget xw, PrinterFlags *p)
{
    TScreen *screen = TScreenOf(xw);
    Boolean was_open = SPS.isOpen;
    int save_which = screen->whichBuf;

    DEBUG_MSG("xtermPrintEverything\n");

    if (p->print_everything) {
	int done_which = 0;

	if (p->print_everything & 8) {
	    printLines(xw, -screen->savedlines, -(screen->topline + 1), p);
	}
	if (p->print_everything & 4) {
	    screen->whichBuf = 1;
	    done_which |= 2;
	    printLines(xw, 0, screen->max_row, p);
	    screen->whichBuf = save_which;
	}
	if (p->print_everything & 2) {
	    screen->whichBuf = 0;
	    done_which |= 1;
	    printLines(xw, 0, screen->max_row, p);
	    screen->whichBuf = save_which;
	}
	if (p->print_everything & 1) {
	    if (!(done_which & (1 << screen->whichBuf))) {
		printLines(xw, 0, screen->max_row, p);
	    }
	}
    } else {
	int top = 0;
	int bot = screen->max_row;
	if (!screen->whichBuf) {
	    top = -screen->savedlines - screen->topline;
	    bot -= screen->topline;
	}
	printLines(xw, top, bot, p);
    }
    if (p->printer_formfeed)
	charToPrinter(xw, '\f');

    if (!was_open || SPS.printer_autoclose) {
	closePrinter(xw);
    }
}

static void
send_CharSet(XtermWidget xw, LineData *ld)
{
#if OPT_DEC_CHRSET
    const char *msg = 0;

    switch (GetLineDblCS(ld)) {
    case CSET_SWL:
	msg = "\033#5";
	break;
    case CSET_DHL_TOP:
	msg = "\033#3";
	break;
    case CSET_DHL_BOT:
	msg = "\033#4";
	break;
    case CSET_DWL:
	msg = "\033#6";
	break;
    }
    if (msg != 0)
	stringToPrinter(xw, msg);
#else
    (void) xw;
    (void) ld;
#endif /* OPT_DEC_CHRSET */
}

static void
send_SGR(XtermWidget xw, unsigned attr, unsigned fg, unsigned bg)
{
    char msg[80];

    strcpy(msg, "\033[0");
    if (attr & BOLD)
	strcat(msg, ";1");
#if OPT_WIDE_ATTRS
    if (attr & ATR_FAINT)
	strcat(msg, ";2");
    if (attr & ATR_ITALIC)
	strcat(msg, ";3");
#endif
    if (attr & UNDERLINE)
	strcat(msg, ";4");	/* typo? DEC documents this as '2' */
    if (attr & BLINK)
	strcat(msg, ";5");
    if (attr & INVERSE)		/* typo? DEC documents this as invisible */
	strcat(msg, ";7");
#if OPT_PRINT_COLORS
    if (bg != NO_COLOR) {
	sprintf(msg + strlen(msg), ";%u", (bg < 8) ? (40 + bg) : (92 + bg));
    }
    if (fg != NO_COLOR) {
#if OPT_PC_COLORS
	if (TScreenOf(xw)->boldColors
	    && fg > 8
	    && (attr & BOLD) != 0)
	    fg -= 8;
#endif
	sprintf(msg + strlen(msg), ";%u", (fg < 8) ? (30 + fg) : (82 + fg));
    }
#else
    (void) bg;
    (void) fg;
#endif
    strcat(msg, "m");
    stringToPrinter(xw, msg);
}

/*
 * This implementation only knows how to write to a pipe.
 */
static void
charToPrinter(XtermWidget xw, unsigned chr)
{
    TScreen *screen = TScreenOf(xw);

    if (!SPS.isOpen && xtermHasPrinter(xw)) {
	switch (SPS.toFile) {
	    /*
	     * write to a pipe.
	     */
	case False:
#ifdef VMS
	    /*
	     * This implementation only knows how to write to a file.  When the
	     * file is closed the print command executes.  Print command must
	     * be of the form:
	     *   print/que=name/delete [/otherflags].
	     */
	    SPS.fp = fopen(VMS_TEMP_PRINT_FILE, "w");
#else
	    {
		int my_pipe[2];
		pid_t my_pid;

		if (pipe(my_pipe))
		    SysError(ERROR_FORK);
		if ((my_pid = fork()) < 0)
		    SysError(ERROR_FORK);

		if (my_pid == 0) {
		    DEBUG_MSG("charToPrinter: subprocess for printer\n");
		    TRACE_CLOSE();
		    close(my_pipe[1]);	/* printer is silent */
		    close(screen->respond);

		    close(fileno(stdout));
		    dup2(fileno(stderr), 1);

		    if (fileno(stderr) != 2) {
			dup2(fileno(stderr), 2);
			close(fileno(stderr));
		    }

		    /* don't want privileges! */
		    if (xtermResetIds(screen) < 0)
			exit(1);

		    SPS.fp = popen(SPS.printer_command, "w");
		    if (SPS.fp != 0) {
			FILE *input;
			DEBUG_MSG("charToPrinter: opened pipe to printer\n");
			if ((input = fdopen(my_pipe[0], "r")) != 0) {
			    clearerr(input);

			    for (;;) {
				int c;

				if (ferror(input)) {
				    DEBUG_MSG("charToPrinter: break on ferror\n");
				    break;
				} else if (feof(input)) {
				    DEBUG_MSG("charToPrinter: break on feof\n");
				    break;
				} else if ((c = fgetc(input)) == EOF) {
				    DEBUG_MSG("charToPrinter: break on EOF\n");
				    break;
				}
				fputc(c, SPS.fp);
				if (isForm(c))
				    fflush(SPS.fp);
			    }
			}
			DEBUG_MSG("charToPrinter: calling pclose\n");
			pclose(SPS.fp);
			if (input)
			    fclose(input);
		    }
		    exit(0);
		} else {
		    close(my_pipe[0]);	/* won't read from printer */
		    if ((SPS.fp = fdopen(my_pipe[1], "w")) != 0) {
			DEBUG_MSG("charToPrinter: opened printer in parent\n");
			TRACE(("opened printer from pid %d/%d\n",
			       (int) getpid(), (int) my_pid));
		    } else {
			TRACE(("failed to open printer:%s\n", strerror(errno)));
			DEBUG_MSG("charToPrinter: could not open in parent\n");
		    }
		}
	    }
#endif
	    break;
	case True:
	    TRACE(("opening \"%s\" as printer output\n", SPS.printer_command));
	    SPS.fp = fopen(SPS.printer_command, "w");
	    break;
	}
	SPS.isOpen = True;
    }
    if (SPS.fp != 0) {
#if OPT_WIDE_CHARS
	if (chr > 127) {
	    Char temp[10];
	    *convertToUTF8(temp, chr) = 0;
	    fputs((char *) temp, SPS.fp);
	} else
#endif
	    fputc((int) chr, SPS.fp);
	if (isForm(chr))
	    fflush(SPS.fp);
    }
}

static void
stringToPrinter(XtermWidget xw, const char *str)
{
    while (*str)
	charToPrinter(xw, CharOf(*str++));
}

/*
 * This module implements the MC (Media Copy) and related printing control
 * sequences for VTxxx emulation.  This is based on the description in the
 * VT330/VT340 Programmer Reference Manual EK-VT3XX-TP-001 (Digital Equipment
 * Corp., March 1987).
 */
void
xtermMediaControl(XtermWidget xw, int param, int private_seq)
{
    TRACE(("MediaCopy param=%d, private=%d\n", param, private_seq));

    if (private_seq) {
	switch (param) {
	case 1:
	    printCursorLine(xw);
	    break;
	case 4:
	    setPrinterControlMode(xw, 0);
	    break;
	case 5:
	    setPrinterControlMode(xw, 1);
	    break;
	case 10:		/* VT320 */
	    xtermPrintScreen(xw, False, getPrinterFlags(xw, NULL, 0));
	    break;
	case 11:		/* VT320 */
	    xtermPrintEverything(xw, getPrinterFlags(xw, NULL, 0));
	    break;
	}
    } else {
	switch (param) {
	case -1:
	case 0:
	    xtermPrintScreen(xw, True, getPrinterFlags(xw, NULL, 0));
	    break;
	case 4:
	    setPrinterControlMode(xw, 0);
	    break;
	case 5:
	    setPrinterControlMode(xw, 2);
	    break;
#if OPT_SCREEN_DUMPS
	case 10:
	    xtermDumpHtml(xw);
	    break;
	case 11:
	    xtermDumpSvg(xw);
	    break;
#endif
	}
    }
}

/*
 * When in autoprint mode, the printer prints a line from the screen when you
 * move the cursor off that line with an LF, FF, or VT character, or an
 * autowrap occurs.  The printed line ends with a CR and the character (LF, FF
 * or VT) that moved the cursor off the previous line.
 */
void
xtermAutoPrint(XtermWidget xw, unsigned chr)
{
    TScreen *screen = TScreenOf(xw);

    if (SPS.printer_controlmode == 1) {
	TRACE(("AutoPrint %d\n", chr));
	printLine(xw, screen->cursorp.row, chr, getPrinterFlags(xw, NULL, 0));
	if (SPS.fp != 0)
	    fflush(SPS.fp);
    }
}

/*
 * When in printer controller mode, the terminal sends received characters to
 * the printer without displaying them on the screen. The terminal sends all
 * characters and control sequences to the printer, except NUL, XON, XOFF, and
 * the printer controller sequences.
 *
 * This function eats characters, returning 0 as long as it must buffer or
 * divert to the printer.  We're only invoked here when in printer controller
 * mode, and handle the exit from that mode.
 */
#define LB '['

int
xtermPrinterControl(XtermWidget xw, int chr)
{
    TScreen *screen = TScreenOf(xw);
    /* *INDENT-OFF* */
    static const struct {
	const Char seq[5];
	int active;
    } tbl[] = {
	{ { ANSI_CSI, '5', 'i'      }, 2 },
	{ { ANSI_CSI, '4', 'i'      }, 0 },
	{ { ANSI_ESC, LB,  '5', 'i' }, 2 },
	{ { ANSI_ESC, LB,  '4', 'i' }, 0 },
    };
    /* *INDENT-ON* */

    static Char bfr[10];
    static size_t length;
    size_t n;

    TRACE(("In printer:%04X\n", chr));

    switch (chr) {
    case 0:
    case CTRL('Q'):
    case CTRL('S'):
	return 0;		/* ignored by application */

    case ANSI_CSI:
    case ANSI_ESC:
    case '[':
    case '4':
    case '5':
    case 'i':
	bfr[length++] = CharOf(chr);
	for (n = 0; n < sizeof(tbl) / sizeof(tbl[0]); n++) {
	    size_t len = Strlen(tbl[n].seq);

	    if (length == len
		&& Strcmp(bfr, tbl[n].seq) == 0) {
		setPrinterControlMode(xw, tbl[n].active);
		if (SPS.printer_autoclose
		    && SPS.printer_controlmode == 0)
		    closePrinter(xw);
		length = 0;
		return 0;
	    } else if (len > length
		       && Strncmp(bfr, tbl[n].seq, length) == 0) {
		return 0;
	    }
	}
	length--;

	/* FALLTHRU */

    default:
	for (n = 0; n < length; n++)
	    charToPrinter(xw, bfr[n]);
	bfr[0] = CharOf(chr);
	length = 1;
	return 0;
    }
}

/*
 * If there is no printer command, we will ignore printer controls.
 *
 * If we do have a printer command, we still have to verify that it will
 * (perhaps) work if we pass it to popen().  At a minimum, the program
 * must exist and be executable.  If not, warn and disable the feature.
 */
Bool
xtermHasPrinter(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);
    Bool result = SPS.printer_checked;

    if (strlen(SPS.printer_command) != 0 && !result) {
	char **argv = x_splitargs(SPS.printer_command);
	if (argv) {
	    if (argv[0]) {
		char *myShell = xtermFindShell(argv[0], False);
		if (myShell == 0) {
		    xtermWarning("No program found for printerCommand: %s\n", SPS.printer_command);
		    SPS.printer_command = x_strdup("");
		} else {
		    free(myShell);
		    SPS.printer_checked = True;
		    result = True;
		}
	    }
	    x_freeargs(argv);
	}
	TRACE(("xtermHasPrinter:%d\n", result));
    }

    return result;
}

#define showPrinterControlMode(mode) \
		(((mode) == 0) \
		 ? "normal" \
		 : ((mode) == 1 \
		    ? "autoprint" \
		    : "printer controller"))

void
setPrinterControlMode(XtermWidget xw, int mode)
{
    TScreen *screen = TScreenOf(xw);

    if (xtermHasPrinter(xw)
	&& SPS.printer_controlmode != mode) {
	TRACE(("%s %s mode\n",
	       (mode
		? "set"
		: "reset"),
	       (mode
		? showPrinterControlMode(mode)
		: showPrinterControlMode(SPS.printer_controlmode))));
	SPS.printer_controlmode = mode;
	update_print_redir();
    }
}

PrinterFlags *
getPrinterFlags(XtermWidget xw, String *params, Cardinal *param_count)
{
    /* *INDENT-OFF* */
    static const struct {
	const char *name;
	unsigned    offset;
	int	    value;
    } table[] = {
	{ "noFormFeed", XtOffsetOf(PrinterFlags, printer_formfeed), 0 },
	{ "FormFeed",	XtOffsetOf(PrinterFlags, printer_formfeed), 1 },
	{ "noNewLine",	XtOffsetOf(PrinterFlags, printer_newline),  0 },
	{ "NewLine",	XtOffsetOf(PrinterFlags, printer_newline),  1 },
	{ "noAttrs",	XtOffsetOf(PrinterFlags, print_attributes), 0 },
	{ "monoAttrs",	XtOffsetOf(PrinterFlags, print_attributes), 1 },
	{ "colorAttrs", XtOffsetOf(PrinterFlags, print_attributes), 2 },
    };
    /* *INDENT-ON* */

    TScreen *screen = TScreenOf(xw);
    PrinterFlags *result = &(screen->printer_flags);

    TRACE(("getPrinterFlags %d params\n", param_count ? *param_count : 0));

    result->printer_extent = SPS.printer_extent;
    result->printer_formfeed = SPS.printer_formfeed;
    result->printer_newline = SPS.printer_newline;
    result->print_attributes = SPS.print_attributes;
    result->print_everything = SPS.print_everything;

    if (param_count != 0 && *param_count != 0) {
	Cardinal j;
	unsigned k;
	for (j = 0; j < *param_count; ++j) {
	    TRACE(("param%d:%s\n", j, params[j]));
	    for (k = 0; k < XtNumber(table); ++k) {
		if (!x_strcasecmp(params[j], table[k].name)) {
		    int *ptr = (int *) (void *) ((char *) result + table[k].offset);
		    TRACE(("...PrinterFlags(%s) %d->%d\n",
			   table[k].name,
			   *ptr,
			   table[k].value));
		    *ptr = table[k].value;
		    break;
		}
	    }
	}
    }

    return result;
}

/*
 * Print a timestamped copy of everything.
 */
void
xtermPrintImmediately(XtermWidget xw, String filename, int opts, int attrs)
{
    TScreen *screen = TScreenOf(xw);
    PrinterState save_state = screen->printer_state;
    char *my_filename = malloc(TIMESTAMP_LEN + strlen(filename));

    if (my_filename != 0) {
	mode_t save_umask = umask(0177);

	timestamp_filename(my_filename, filename);
	SPS.fp = 0;
	SPS.isOpen = False;
	SPS.toFile = True;
	SPS.printer_command = my_filename;
	SPS.printer_autoclose = True;
	SPS.printer_formfeed = False;
	SPS.printer_newline = True;
	SPS.print_attributes = attrs;
	SPS.print_everything = opts;
	xtermPrintEverything(xw, getPrinterFlags(xw, NULL, 0));

	umask(save_umask);
	screen->printer_state = save_state;
    }
}

void
xtermPrintOnXError(XtermWidget xw, int n)
{
#if OPT_PRINT_ON_EXIT
    /*
     * The user may have requested that the contents of the screen will be
     * written to a file if an X error occurs.
     */
    if (TScreenOf(xw)->write_error && !IsEmpty(resource.printFileOnXError)) {
	Boolean printIt = False;

	switch (n) {
	case ERROR_XERROR:
	    /* FALLTHRU */
	case ERROR_XIOERROR:
	    /* FALLTHRU */
	case ERROR_ICEERROR:
	    printIt = True;
	    break;
	}

	if (printIt) {
	    xtermPrintImmediately(xw,
				  resource.printFileOnXError,
				  resource.printOptsOnXError,
				  resource.printModeOnXError);
	}
    }
#else
    (void) xw;
    (void) n;
#endif
}
xterm-330/fontutils.h0000644000175100001440000001563013121705716013447 0ustar  tomusers/* $XTermId: fontutils.h,v 1.119 2017/06/19 08:31:10 tom Exp $ */

/*
 * Copyright 1998-2016,2017 by Thomas E. Dickey
 *
 *                         All Rights Reserved
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name(s) of the above copyright
 * holders shall not be used in advertising or otherwise to promote the
 * sale, use or other dealings in this Software without prior written
 * authorization.
 */

#ifndef included_fontutils_h
#define included_fontutils_h 1

#include 
/* *INDENT-OFF* */

extern Bool xtermLoadDefaultFonts (XtermWidget /* xw */);
extern Bool xtermOpenFont (XtermWidget /* xw */, const char */* name */, XTermFonts * /* result */, Bool /* force */);
extern XTermFonts * getDoubleFont (TScreen * /* screen */, int /* which */);
extern XTermFonts * getItalicFont (TScreen * /* screen */, int /* which */);
extern XTermFonts * getNormalFont (TScreen * /* screen */, int /* which */);
extern const VTFontNames * defaultVTFontNames(XtermWidget /* xw */);
extern const VTFontNames * xtermFontName (const char */* normal */);
extern const char * whichFontEnum (VTFontEnum /* value */);
extern const char * whichFontList (XtermWidget /* xw */, VTFontList * /* value */);
extern const char * whichFontList2(XtermWidget /* xw */, char ** /* value */);
extern int lookupRelativeFontSize (XtermWidget /* xw */, int /* old */, int /* relative */);
extern int xtermGetFont (const char * /* param */);
extern int xtermLoadFont (XtermWidget /* xw */, const VTFontNames */* fonts */, Bool /* doresize */, int /* fontnum */);
extern void HandleSetFont PROTO_XT_ACTIONS_ARGS;
extern void SetVTFont (XtermWidget /* xw */, int /* i */, Bool /* doresize */, const VTFontNames */* fonts */);
extern void allocFontList (XtermWidget /* xw */, const char * /* name */, XtermFontNames * /* target */, VTFontEnum /* which */, const char * /* source */, Bool /* ttf */);
extern void copyFontList (char *** /* targetp */, char ** /* source */);
extern void initFontLists (XtermWidget /* xw */);
extern void freeFontList (char *** /* targetp */);
extern void freeFontLists (VTFontList * /* lists */);
extern void xtermCloseFont (XtermWidget /* xw */, XTermFonts * /* fnt */);
extern void xtermCloseFonts (XtermWidget /* xw */, XTermFonts * /* fnts[fMAX] */);
extern void xtermComputeFontInfo (XtermWidget /* xw */, VTwin */* win */, XFontStruct */* font */, int /* sbwidth */);
extern void xtermCopyFontInfo (XTermFonts * /* target */, XTermFonts * /* source */);
extern void xtermFreeFontInfo (XTermFonts * /* target */);
extern void xtermSaveFontInfo (TScreen * /* screen */, XFontStruct */* font */);
extern void xtermSetCursorBox (TScreen * /* screen */);
extern void xtermUpdateFontGCs (XtermWidget /* xw */, Bool /* italic */);
extern void xtermUpdateFontInfo (XtermWidget /* xw */, Bool /* doresize */);

#define getIconicFont(screen) (&((screen)->fnt_icon))

#define FirstItemOf(vector) ((vector) ? (vector)[0] : 0)
#define CurrentXftFont(xw)  ((xw)->work.fonts.xft.list_n[0])
#define DefaultFontN(xw)    ((xw)->work.fonts.x11.list_n[0])
#define DefaultFontB(xw)    ((xw)->work.fonts.x11.list_b[0])
#define DefaultFontW(xw)    ((xw)->work.fonts.x11.list_w[0])
#define DefaultFontWB(xw)   ((xw)->work.fonts.x11.list_wb[0])

#if OPT_DEC_CHRSET
extern char *xtermSpecialFont (XtermWidget /* xw */, unsigned /* attr_flags */, unsigned /* draw_flags */, unsigned /* chrset */);
#endif

#define FontLacksMetrics(font) \
	((font)->fs != 0 \
	 && ((font)->fs->per_char == 0))

#define FontIsIncomplete(font) \
	((font)->fs != 0 \
	 && (font)->fs->per_char != 0 \
	 && !(font)->fs->all_chars_exist)

#if OPT_BOX_CHARS

#define ForceBoxChars(screen,ch) \
	(xtermIsDecGraphic(ch) \
	 && (screen)->force_box_chars)

	 /*
	  * Keep track of (some) characters to make the check for missing
	  * characters faster.  If the character is known to be missing,
	  * the cache value is '2'.  If we have checked the character, the
	  * cached value is '1'.
	  */
#if OPT_WIDE_CHARS
#define CheckedKnownMissing(font, ch) \
	 (((ch) < KNOWN_MISSING) && ((font)->known_missing[(Char)(ch)] > 0))
#else
#define CheckedKnownMissing(font, ch) \
	 ((font)->known_missing[(Char)(ch)] > 0)
#endif

#define IsXtermMissingChar(screen, ch, font) \
	 (CheckedKnownMissing(font, ch) \
	  ? ((font)->known_missing[(Char)(ch)] > 1) \
	  : ((FontIsIncomplete(font) && xtermMissingChar(ch, font)) \
	   || ForceBoxChars(screen, ch)))

extern void xtermDrawBoxChar (XtermWidget /* xw */, unsigned /* ch */, unsigned /* attr_flags */, unsigned /* draw_flags */, GC /* gc */, int /* x */, int /* y */, int /* cols */);
#else
#define IsXtermMissingChar(screen, ch, font) False
#endif

#if OPT_BOX_CHARS || OPT_REPORT_FONTS
extern Bool xtermMissingChar (unsigned /* ch */, XTermFonts */* font */);
#endif

#if OPT_LOAD_VTFONTS
extern void HandleLoadVTFonts PROTO_XT_ACTIONS_ARGS;
#endif

#if OPT_LOAD_VTFONTS || OPT_WIDE_CHARS
extern Bool xtermLoadWideFonts (XtermWidget /* w */, Bool /* nullOk */);
extern void xtermSaveVTFonts (XtermWidget /* xw */);
#endif

#define xtermIsDecGraphic(ch)	((ch) > 0 && (ch) < 32)

#if OPT_RENDERFONT
extern Bool xtermXftMissing (XtermWidget /* xw */, XftFont * /* font */, unsigned /* wc */);
extern XTermXftFonts *getMyXftFont (XtermWidget /* xw */, int /* which */, int /* fontnum */);
extern XftFont *getXftFont (XtermWidget /* xw */, VTFontEnum /* which */, int /* fontnum */);
extern void xtermCloseXft (TScreen * /* screen */, XTermXftFonts * /* pub */);
#endif

#if OPT_SHIFT_FONTS
extern String getFaceName (XtermWidget /* xw */, Bool /* wideName */);
extern void HandleLargerFont PROTO_XT_ACTIONS_ARGS;
extern void HandleSmallerFont PROTO_XT_ACTIONS_ARGS;
extern void setFaceName (XtermWidget /* xw */, const char * /*value */);
#endif

#if OPT_WIDE_ATTRS
extern void xtermLoadItalics (XtermWidget /* xw */);
#endif

#if OPT_WIDE_CHARS
extern unsigned ucs2dec (unsigned);
extern unsigned dec2ucs (unsigned);
#endif

/* *INDENT-ON* */

#endif /* included_fontutils_h */
xterm-330/precompose.h0000644000175100001440000000040407152532744013573 0ustar  tomusers/* $XFree86: xc/programs/xterm/precompose.h,v 1.1 2000/08/26 04:33:54 dawes Exp $ */

#ifndef PRECOMPOSE_H
#define PRECOMPOSE_H

int do_precomposition(int base, int comb);

/* returns unicode value if a canonical composition exists,
   otherwise -1 */

#endif
xterm-330/misc.c0000644000175100001440000043741513122161102012341 0ustar  tomusers/* $XTermId: misc.c,v 1.757 2017/06/20 08:52:18 tom Exp $ */

/*
 * Copyright 1999-2016,2017 by Thomas E. Dickey
 *
 *                         All Rights Reserved
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name(s) of the above copyright
 * holders shall not be used in advertising or otherwise to promote the
 * sale, use or other dealings in this Software without prior written
 * authorization.
 *
 *
 * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 *
 *                         All Rights Reserved
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose and without fee is hereby granted,
 * provided that the above copyright notice appear in all copies and that
 * both that copyright notice and this permission notice appear in
 * supporting documentation, and that the name of Digital Equipment
 * Corporation not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 *
 *
 * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */

#include 
#include 
#include 
#include 

#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include 
#include 
#include 
#include 

#include 
#include 
#include 
#include 
#if HAVE_X11_SUNKEYSYM_H
#include 
#endif

#ifdef HAVE_LIBXPM
#include 
#endif

#ifdef HAVE_LANGINFO_CODESET
#include 
#endif

#include 

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include 

#if (XtSpecificationRelease < 6)
#ifndef X_GETTIMEOFDAY
#define X_GETTIMEOFDAY(t) gettimeofday(t,(struct timezone *)0)
#endif
#endif

#ifdef VMS
#define XTERM_VMS_LOGFILE "SYS$SCRATCH:XTERM_LOG.TXT"
#ifdef ALLOWLOGFILEEXEC
#undef ALLOWLOGFILEEXEC
#endif
#endif /* VMS */

#if OPT_TEK4014
#define OUR_EVENT(event,Type) \
		(event.type == Type && \
		  (event.xcrossing.window == XtWindow(XtParent(xw)) || \
		    (tekWidget && \
		     event.xcrossing.window == XtWindow(XtParent(tekWidget)))))
#else
#define OUR_EVENT(event,Type) \
		(event.type == Type && \
		   (event.xcrossing.window == XtWindow(XtParent(xw))))
#endif

static Boolean xtermAllocColor(XtermWidget, XColor *, const char *);
static Cursor make_hidden_cursor(XtermWidget);

static char emptyString[] = "";

#if OPT_EXEC_XTERM
/* Like readlink(2), but returns a malloc()ed buffer, or NULL on
   error; adapted from libc docs */
static char *
Readlink(const char *filename)
{
    char *buf = NULL;
    size_t size = 100;

    for (;;) {
	int n;
	char *tmp = TypeRealloc(char, size, buf);
	if (tmp == NULL) {
	    free(buf);
	    return NULL;
	}
	buf = tmp;
	memset(buf, 0, size);

	n = (int) readlink(filename, buf, size);
	if (n < 0) {
	    free(buf);
	    return NULL;
	}

	if ((unsigned) n < size) {
	    return buf;
	}

	size *= 2;
    }
}
#endif /* OPT_EXEC_XTERM */

static void
Sleep(int msec)
{
    static struct timeval select_timeout;

    select_timeout.tv_sec = 0;
    select_timeout.tv_usec = msec * 1000;
    select(0, 0, 0, 0, &select_timeout);
}

static void
selectwindow(XtermWidget xw, int flag)
{
    TScreen *screen = TScreenOf(xw);

    TRACE(("selectwindow(%d) flag=%d\n", screen->select, flag));

#if OPT_TEK4014
    if (TEK4014_ACTIVE(xw)) {
	if (!Ttoggled)
	    TCursorToggle(tekWidget, TOGGLE);
	screen->select |= flag;
	if (!Ttoggled)
	    TCursorToggle(tekWidget, TOGGLE);
    } else
#endif
    {
#if OPT_I18N_SUPPORT && OPT_INPUT_METHOD
	TInput *input = lookupTInput(xw, (Widget) xw);
	if (input && input->xic)
	    XSetICFocus(input->xic);
#endif

	if (screen->cursor_state && CursorMoved(screen))
	    HideCursor();
	screen->select |= flag;
	if (screen->cursor_state)
	    ShowCursor();
    }
    GetScrollLock(screen);
}

static void
unselectwindow(XtermWidget xw, int flag)
{
    TScreen *screen = TScreenOf(xw);

    TRACE(("unselectwindow(%d) flag=%d\n", screen->select, flag));

    if (screen->hide_pointer && screen->pointer_mode < pFocused) {
	screen->hide_pointer = False;
	xtermDisplayCursor(xw);
    }

    if (!screen->always_highlight) {
#if OPT_TEK4014
	if (TEK4014_ACTIVE(xw)) {
	    if (!Ttoggled)
		TCursorToggle(tekWidget, TOGGLE);
	    screen->select &= ~flag;
	    if (!Ttoggled)
		TCursorToggle(tekWidget, TOGGLE);
	} else
#endif
	{
#if OPT_I18N_SUPPORT && OPT_INPUT_METHOD
	    TInput *input = lookupTInput(xw, (Widget) xw);
	    if (input && input->xic)
		XUnsetICFocus(input->xic);
#endif

	    screen->select &= ~flag;
	    if (screen->cursor_state && CursorMoved(screen))
		HideCursor();
	    if (screen->cursor_state)
		ShowCursor();
	}
    }
}

static void
DoSpecialEnterNotify(XtermWidget xw, XEnterWindowEvent *ev)
{
    TScreen *screen = TScreenOf(xw);

    TRACE(("DoSpecialEnterNotify(%d)\n", screen->select));
    TRACE_FOCUS(xw, ev);
    if (((ev->detail) != NotifyInferior) &&
	ev->focus &&
	!(screen->select & FOCUS))
	selectwindow(xw, INWINDOW);
}

static void
DoSpecialLeaveNotify(XtermWidget xw, XEnterWindowEvent *ev)
{
    TScreen *screen = TScreenOf(xw);

    TRACE(("DoSpecialLeaveNotify(%d)\n", screen->select));
    TRACE_FOCUS(xw, ev);
    if (((ev->detail) != NotifyInferior) &&
	ev->focus &&
	!(screen->select & FOCUS))
	unselectwindow(xw, INWINDOW);
}

#ifndef XUrgencyHint
#define XUrgencyHint (1L << 8)	/* X11R5 does not define */
#endif

static void
setXUrgency(XtermWidget xw, Bool enable)
{
    TScreen *screen = TScreenOf(xw);

    if (screen->bellIsUrgent) {
	XWMHints *h = XGetWMHints(screen->display, VShellWindow(xw));
	if (h != 0) {
	    if (enable && !(screen->select & FOCUS)) {
		h->flags |= XUrgencyHint;
	    } else {
		h->flags &= ~XUrgencyHint;
	    }
	    XSetWMHints(screen->display, VShellWindow(xw), h);
	}
    }
}

void
do_xevents(void)
{
    TScreen *screen = TScreenOf(term);

    if (xtermAppPending()
	||
#if defined(VMS) || defined(__VMS)
	screen->display->qlen > 0
#else
	GetBytesAvailable(ConnectionNumber(screen->display)) > 0
#endif
	)
	xevents();
}

void
xtermDisplayCursor(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);

    if (screen->Vshow) {
	if (screen->hide_pointer) {
	    TRACE(("Display hidden_cursor\n"));
	    XDefineCursor(screen->display, VWindow(screen), screen->hidden_cursor);
	} else {
	    TRACE(("Display pointer_cursor\n"));
	    recolor_cursor(screen,
			   screen->pointer_cursor,
			   T_COLOR(screen, MOUSE_FG),
			   T_COLOR(screen, MOUSE_BG));
	    XDefineCursor(screen->display, VWindow(screen), screen->pointer_cursor);
	}
    }
}

void
xtermShowPointer(XtermWidget xw, Bool enable)
{
    static int tried = -1;
    TScreen *screen = TScreenOf(xw);

#if OPT_TEK4014
    if (TEK4014_SHOWN(xw))
	enable = True;
#endif

    /*
     * Whether we actually hide the pointer depends on the pointer-mode and
     * the mouse-mode:
     */
    if (!enable) {
	switch (screen->pointer_mode) {
	case pNever:
	    enable = True;
	    break;
	case pNoMouse:
	    if (screen->send_mouse_pos != MOUSE_OFF)
		enable = True;
	    break;
	case pAlways:
	case pFocused:
	    break;
	}
    }

    if (enable) {
	if (screen->hide_pointer) {
	    screen->hide_pointer = False;
	    xtermDisplayCursor(xw);
	    switch (screen->send_mouse_pos) {
	    case ANY_EVENT_MOUSE:
		break;
	    default:
		MotionOff(screen, xw);
		break;
	    }
	}
    } else if (!(screen->hide_pointer) && (tried <= 0)) {
	if (screen->hidden_cursor == 0) {
	    screen->hidden_cursor = make_hidden_cursor(xw);
	}
	if (screen->hidden_cursor == 0) {
	    tried = 1;
	} else {
	    tried = 0;
	    screen->hide_pointer = True;
	    xtermDisplayCursor(xw);
	    MotionOn(screen, xw);
	}
    }
}

#if OPT_TRACE
static void
TraceExposeEvent(XEvent *arg)
{
    XExposeEvent *event = (XExposeEvent *) arg;

    TRACE(("pending Expose %ld %d: %d,%d %dx%d %#lx\n",
	   event->serial,
	   event->count,
	   event->y,
	   event->x,
	   event->height,
	   event->width,
	   event->window));
}

#else
#define TraceExposeEvent(event)	/* nothing */
#endif

/* true if p contains q */
#define ExposeContains(p,q) \
	    ((p)->y <= (q)->y \
	  && (p)->x <= (q)->x \
	  && ((p)->y + (p)->height) >= ((q)->y + (q)->height) \
	  && ((p)->x + (p)->width) >= ((q)->x + (q)->width))

static XtInputMask
mergeExposeEvents(XEvent *target)
{
    XEvent next_event;
    XExposeEvent *p;

    TRACE(("pending Expose...?\n"));
    TraceExposeEvent(target);
    XtAppNextEvent(app_con, target);
    p = (XExposeEvent *) target;

    while (XtAppPending(app_con)
	   && XtAppPeekEvent(app_con, &next_event)
	   && next_event.type == Expose) {
	Boolean merge_this = False;
	XExposeEvent *q;

	TraceExposeEvent(&next_event);
	q = (XExposeEvent *) (&next_event);
	XtAppNextEvent(app_con, &next_event);

	/*
	 * If either window is contained within the other, merge the events.
	 * The traces show that there are also cases where a full repaint of
	 * a window is broken into 3 or more rectangles, which do not arrive
	 * in the same instant.  We could merge those if xterm were modified
	 * to skim several events ahead.
	 */
	if (p->window == q->window) {
	    if (ExposeContains(p, q)) {
		TRACE(("pending Expose...merged forward\n"));
		merge_this = True;
		next_event = *target;
	    } else if (ExposeContains(q, p)) {
		TRACE(("pending Expose...merged backward\n"));
		merge_this = True;
	    }
	}
	if (!merge_this) {
	    XtDispatchEvent(target);
	}
	*target = next_event;
    }
    XtDispatchEvent(target);
    return XtAppPending(app_con);
}

#if OPT_TRACE
static void
TraceConfigureEvent(XEvent *arg)
{
    XConfigureEvent *event = (XConfigureEvent *) arg;

    TRACE(("pending Configure %ld %d,%d %dx%d %#lx\n",
	   event->serial,
	   event->y,
	   event->x,
	   event->height,
	   event->width,
	   event->window));
}

#else
#define TraceConfigureEvent(event)	/* nothing */
#endif

/*
 * On entry, we have peeked at the event queue and see a configure-notify
 * event.  Remove that from the queue so we can look further.
 *
 * Then, as long as there is a configure-notify event in the queue, remove
 * that.  If the adjacent events are for different windows, process the older
 * event and update the event used for comparing windows.  If they are for the
 * same window, only the newer event is of interest.
 *
 * Finally, process the (remaining) configure-notify event.
 */
static XtInputMask
mergeConfigureEvents(XEvent *target)
{
    XEvent next_event;
    XConfigureEvent *p;

    XtAppNextEvent(app_con, target);
    p = (XConfigureEvent *) target;

    TRACE(("pending Configure...?%s\n", XtAppPending(app_con) ? "yes" : "no"));
    TraceConfigureEvent(target);

    if (XtAppPending(app_con)
	&& XtAppPeekEvent(app_con, &next_event)
	&& next_event.type == ConfigureNotify) {
	Boolean merge_this = False;
	XConfigureEvent *q;

	TraceConfigureEvent(&next_event);
	XtAppNextEvent(app_con, &next_event);
	q = (XConfigureEvent *) (&next_event);

	if (p->window == q->window) {
	    TRACE(("pending Configure...merged\n"));
	    merge_this = True;
	}
	if (!merge_this) {
	    TRACE(("pending Configure...skipped\n"));
	    XtDispatchEvent(target);
	}
	*target = next_event;
    }
    XtDispatchEvent(target);
    return XtAppPending(app_con);
}

/*
 * Filter redundant Expose- and ConfigureNotify-events.  This is limited to
 * adjacent events because there could be other event-loop processing.  Absent
 * that limitation, it might be possible to scan ahead to find when the screen
 * would be completely updated, skipping unnecessary re-repainting before that
 * point.
 *
 * Note: all cases should allow doing XtAppNextEvent if result is true.
 */
XtInputMask
xtermAppPending(void)
{
    XtInputMask result = XtAppPending(app_con);
    XEvent this_event;
    Boolean found = False;

    while (result && XtAppPeekEvent(app_con, &this_event)) {
	found = True;
	if (this_event.type == Expose) {
	    result = mergeExposeEvents(&this_event);
	    TRACE(("got merged expose events\n"));
	} else if (this_event.type == ConfigureNotify) {
	    result = mergeConfigureEvents(&this_event);
	    TRACE(("got merged configure notify events\n"));
	} else {
	    TRACE(("pending %s\n", visibleEventType(this_event.type)));
	    break;
	}
    }

    /*
     * With NetBSD, closing a shell results in closing the X input event
     * stream, which interferes with the "-hold" option.  Wait a short time in
     * this case, to avoid max'ing the CPU.
     */
    if (hold_screen && caught_intr && !found) {
	Sleep(10);
    }
    return result;
}

void
xevents(void)
{
    XtermWidget xw = term;
    TScreen *screen = TScreenOf(xw);
    XEvent event;
    XtInputMask input_mask;

    if (need_cleanup)
	NormalExit();

    if (screen->scroll_amt)
	FlushScroll(xw);
    /*
     * process timeouts, relying on the fact that XtAppProcessEvent
     * will process the timeout and return without blockng on the
     * XEvent queue.  Other sources i.e., the pty are handled elsewhere
     * with select().
     */
    while ((input_mask = xtermAppPending()) != 0) {
	if (input_mask & XtIMTimer)
	    XtAppProcessEvent(app_con, (XtInputMask) XtIMTimer);
#if OPT_SESSION_MGT
	/*
	 * Session management events are alternative input events. Deal with
	 * them in the same way.
	 */
	else if (input_mask & XtIMAlternateInput)
	    XtAppProcessEvent(app_con, (XtInputMask) XtIMAlternateInput);
#endif
	else
	    break;
    }

    /*
     * If there's no XEvents, don't wait around...
     */
    if ((input_mask & XtIMXEvent) != XtIMXEvent)
	return;
    do {
	/*
	 * This check makes xterm hang when in mouse hilite tracking mode.
	 * We simply ignore all events except for those not passed down to
	 * this function, e.g., those handled in in_put().
	 */
	if (screen->waitingForTrackInfo) {
	    Sleep(10);
	    return;
	}
	XtAppNextEvent(app_con, &event);
	/*
	 * Hack to get around problems with the toolkit throwing away
	 * eventing during the exclusive grab of the menu popup.  By
	 * looking at the event ourselves we make sure that we can
	 * do the right thing.
	 */
	if (OUR_EVENT(event, EnterNotify)) {
	    DoSpecialEnterNotify(xw, &event.xcrossing);
	} else if (OUR_EVENT(event, LeaveNotify)) {
	    DoSpecialLeaveNotify(xw, &event.xcrossing);
	} else if ((screen->send_mouse_pos == ANY_EVENT_MOUSE
#if OPT_DEC_LOCATOR
		    || screen->send_mouse_pos == DEC_LOCATOR
#endif /* OPT_DEC_LOCATOR */
		   )
		   && event.xany.type == MotionNotify
		   && event.xcrossing.window == XtWindow(xw)) {
	    SendMousePosition(xw, &event);
	    xtermShowPointer(xw, True);
	    continue;
	}

	/*
	 * If the event is interesting (and not a keyboard event), turn the
	 * mouse pointer back on.
	 */
	if (screen->hide_pointer) {
	    if (screen->pointer_mode >= pFocused) {
		switch (event.xany.type) {
		case MotionNotify:
		    xtermShowPointer(xw, True);
		    break;
		}
	    } else {
		switch (event.xany.type) {
		case KeyPress:
		case KeyRelease:
		case ButtonPress:
		case ButtonRelease:
		    /* also these... */
		case Expose:
		case GraphicsExpose:
		case NoExpose:
		case PropertyNotify:
		case ClientMessage:
		    break;
		default:
		    xtermShowPointer(xw, True);
		    break;
		}
	    }
	}

	if (!event.xany.send_event ||
	    screen->allowSendEvents ||
	    ((event.xany.type != KeyPress) &&
	     (event.xany.type != KeyRelease) &&
	     (event.xany.type != ButtonPress) &&
	     (event.xany.type != ButtonRelease))) {

	    XtDispatchEvent(&event);
	}
    } while (xtermAppPending() & XtIMXEvent);
}

static Cursor
make_hidden_cursor(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);
    Cursor c;
    Display *dpy = screen->display;
    XFontStruct *fn;

    static XColor dummy;

    /*
     * Prefer nil2 (which is normally available) to "fixed" (which is supposed
     * to be "always" available), since it's a smaller glyph in case the
     * server insists on drawing _something_.
     */
    TRACE(("Ask for nil2 font\n"));
    if ((fn = XLoadQueryFont(dpy, "nil2")) == 0) {
	TRACE(("...Ask for fixed font\n"));
	fn = XLoadQueryFont(dpy, DEFFONT);
    }

    if (fn != 0) {
	/* a space character seems to work as a cursor (dots are not needed) */
	c = XCreateGlyphCursor(dpy, fn->fid, fn->fid, 'X', ' ', &dummy, &dummy);
	XFreeFont(dpy, fn);
    } else {
	c = 0;
    }
    TRACE(("XCreateGlyphCursor ->%#lx\n", c));
    return (c);
}

/*
 * Xlib uses Xcursor to customize cursor coloring, which interferes with
 * xterm's pointerColor resource.  Work around this by providing our own
 * default theme.  Testing seems to show that we only have to provide this
 * until the window is initialized.
 */
void
init_colored_cursor(Display *dpy)
{
#ifdef HAVE_LIB_XCURSOR
    static const char theme[] = "index.theme";
    static const char pattern[] = "xtermXXXXXX";
    char *env = getenv("XCURSOR_THEME");

    xterm_cursor_theme = 0;
    /*
     * The environment variable overrides a (possible) resource Xcursor.theme
     */
    if (IsEmpty(env)) {
	env = XGetDefault(dpy, "Xcursor", "theme");
    }
    /*
     * If neither found, provide our own default theme.
     */
    if (IsEmpty(env)) {
	const char *tmp_dir;
	char *filename;
	size_t needed;

	if ((tmp_dir = getenv("TMPDIR")) == 0) {
	    tmp_dir = P_tmpdir;
	}
	needed = strlen(tmp_dir) + 4 + strlen(theme) + strlen(pattern);
	if ((filename = malloc(needed)) != 0) {
	    sprintf(filename, "%s/%s", tmp_dir, pattern);

#ifdef HAVE_MKDTEMP
	    xterm_cursor_theme = mkdtemp(filename);
#else
	    if (mktemp(filename) != 0
		&& mkdir(filename, 0700) == 0) {
		xterm_cursor_theme = filename;
	    }
#endif
	    /*
	     * Actually, Xcursor does what _we_ want just by steering its
	     * search path away from home.  We are setting up the complete
	     * theme just in case the library ever acquires a maintainer.
	     */
	    if (xterm_cursor_theme != 0) {
		char *leaf = xterm_cursor_theme + strlen(xterm_cursor_theme);
		FILE *fp;

		strcat(leaf, "/");
		strcat(leaf, theme);
		if ((fp = fopen(xterm_cursor_theme, "w")) != 0) {
		    fprintf(fp, "[Icon Theme]\n");
		    fclose(fp);
		    *leaf = '\0';
		    xtermSetenv("XCURSOR_PATH", xterm_cursor_theme);
		    *leaf = '/';
		}
		atexit(cleanup_colored_cursor);
	    }
	}
    }
#else
    (void) dpy;
#endif /* HAVE_LIB_XCURSOR */
}

/*
 * Once done, discard the file and directory holding it.
 */
void
cleanup_colored_cursor(void)
{
#ifdef HAVE_LIB_XCURSOR
    if (xterm_cursor_theme != 0) {
	char *my_path = getenv("XCURSOR_PATH");
	struct stat sb;
	if (!IsEmpty(my_path)
	    && stat(my_path, &sb) == 0
	    && (sb.st_mode & S_IFMT) == S_IFDIR) {
	    unlink(xterm_cursor_theme);
	    rmdir(my_path);
	    free(xterm_cursor_theme);
	    xterm_cursor_theme = 0;
	}
    }
#endif /* HAVE_LIB_XCURSOR */
}

Cursor
make_colored_cursor(unsigned cursorindex,	/* index into font */
		    unsigned long fg,	/* pixel value */
		    unsigned long bg)	/* pixel value */
{
    TScreen *screen = TScreenOf(term);
    Cursor c;
    Display *dpy = screen->display;

    c = XCreateFontCursor(dpy, cursorindex);
    if (c != None) {
	recolor_cursor(screen, c, fg, bg);
    }
    return (c);
}

/* ARGSUSED */
void
HandleKeyPressed(Widget w GCC_UNUSED,
		 XEvent *event,
		 String *params GCC_UNUSED,
		 Cardinal *nparams GCC_UNUSED)
{
    TRACE(("Handle insert-seven-bit for %p\n", (void *) w));
    Input(term, &event->xkey, False);
}

/* ARGSUSED */
void
HandleEightBitKeyPressed(Widget w GCC_UNUSED,
			 XEvent *event,
			 String *params GCC_UNUSED,
			 Cardinal *nparams GCC_UNUSED)
{
    TRACE(("Handle insert-eight-bit for %p\n", (void *) w));
    Input(term, &event->xkey, True);
}

/* ARGSUSED */
void
HandleStringEvent(Widget w GCC_UNUSED,
		  XEvent *event GCC_UNUSED,
		  String *params,
		  Cardinal *nparams)
{

    if (*nparams != 1)
	return;

    if ((*params)[0] == '0' && (*params)[1] == 'x' && (*params)[2] != '\0') {
	const char *abcdef = "ABCDEF";
	const char *xxxxxx;
	Char c;
	UString p;
	unsigned value = 0;

	for (p = (UString) (*params + 2); (c = CharOf(x_toupper(*p))) !=
	     '\0'; p++) {
	    value *= 16;
	    if (c >= '0' && c <= '9')
		value += (unsigned) (c - '0');
	    else if ((xxxxxx = (strchr) (abcdef, c)) != 0)
		value += (unsigned) (xxxxxx - abcdef) + 10;
	    else
		break;
	}
	if (c == '\0') {
	    Char hexval[2];
	    hexval[0] = (Char) value;
	    hexval[1] = 0;
	    StringInput(term, hexval, (size_t) 1);
	}
    } else {
	StringInput(term, (const Char *) *params, strlen(*params));
    }
}

#if OPT_EXEC_XTERM

#ifndef PROCFS_ROOT
#define PROCFS_ROOT "/proc"
#endif

/*
 * Determine the current working directory of the child so that we can
 * spawn a new terminal in the same directory.
 *
 * If we cannot get the CWD of the child, just use our own.
 */
char *
ProcGetCWD(pid_t pid)
{
    char *child_cwd = NULL;

    if (pid) {
	char child_cwd_link[sizeof(PROCFS_ROOT) + 80];
	sprintf(child_cwd_link, PROCFS_ROOT "/%lu/cwd", (unsigned long) pid);
	child_cwd = Readlink(child_cwd_link);
    }
    return child_cwd;
}

/* ARGSUSED */
void
HandleSpawnTerminal(Widget w GCC_UNUSED,
		    XEvent *event GCC_UNUSED,
		    String *params,
		    Cardinal *nparams)
{
    TScreen *screen = TScreenOf(term);
    char *child_cwd = NULL;
    char *child_exe;
    pid_t pid;

    /*
     * Try to find the actual program which is running in the child process.
     * This works for Linux.  If we cannot find the program, fall back to the
     * xterm program (which is usually adequate).  Give up if we are given only
     * a relative path to xterm, since that would not always match $PATH.
     */
    child_exe = Readlink(PROCFS_ROOT "/self/exe");
    if (!child_exe) {
	if (strncmp(ProgramName, "./", (size_t) 2)
	    && strncmp(ProgramName, "../", (size_t) 3)) {
	    child_exe = xtermFindShell(ProgramName, True);
	} else {
	    xtermWarning("Cannot exec-xterm given \"%s\"\n", ProgramName);
	}
	if (child_exe == 0)
	    return;
    }

    child_cwd = ProcGetCWD(screen->pid);

    /* The reaper will take care of cleaning up the child */
    pid = fork();
    if (pid == -1) {
	xtermWarning("Could not fork: %s\n", SysErrorMsg(errno));
    } else if (!pid) {
	/* We are the child */
	if (child_cwd) {
	    IGNORE_RC(chdir(child_cwd));	/* We don't care if this fails */
	}

	if (setuid(screen->uid) == -1
	    || setgid(screen->gid) == -1) {
	    xtermWarning("Cannot reset uid/gid\n");
	} else {
	    unsigned myargc = *nparams + 1;
	    char **myargv = TypeMallocN(char *, myargc + 1);

	    if (myargv != 0) {
		unsigned n = 0;

		myargv[n++] = child_exe;

		while (n < myargc) {
		    myargv[n++] = (char *) *params++;
		}

		myargv[n] = 0;
		execv(child_exe, myargv);
	    }

	    /* If we get here, we've failed */
	    xtermWarning("exec of '%s': %s\n", child_exe, SysErrorMsg(errno));
	}
	_exit(0);
    }

    /* We are the parent; clean up */
    if (child_cwd)
	free(child_cwd);
    free(child_exe);
}
#endif /* OPT_EXEC_XTERM */

/*
 * Rather than sending characters to the host, put them directly into our
 * input queue.  That lets a user have access to any of the control sequences
 * for a key binding.  This is the equivalent of local function key support.
 *
 * NOTE:  This code does not support the hexadecimal kludge used in
 * HandleStringEvent because it prevents us from sending an arbitrary string
 * (but it appears in a lot of examples - so we are stuck with it).  The
 * standard string converter does recognize "\" for newline ("\n") and for
 * octal constants (e.g., "\007" for BEL).  So we assume the user can make do
 * without a specialized converter.  (Don't try to use \000, though).
 */
/* ARGSUSED */
void
HandleInterpret(Widget w GCC_UNUSED,
		XEvent *event GCC_UNUSED,
		String *params,
		Cardinal *param_count)
{
    if (*param_count == 1) {
	const char *value = params[0];
	int need = (int) strlen(value);
	int used = (int) (VTbuffer->next - VTbuffer->buffer);
	int have = (int) (VTbuffer->last - VTbuffer->buffer);

	if (have - used + need < BUF_SIZE) {

	    fillPtyData(term, VTbuffer, value, (int) strlen(value));

	    TRACE(("Interpret %s\n", value));
	    VTbuffer->update++;
	}
    }
}

/*ARGSUSED*/
void
HandleEnterWindow(Widget w GCC_UNUSED,
		  XtPointer eventdata GCC_UNUSED,
		  XEvent *event GCC_UNUSED,
		  Boolean *cont GCC_UNUSED)
{
    /* NOP since we handled it above */
    TRACE(("HandleEnterWindow ignored\n"));
    TRACE_FOCUS(w, event);
}

/*ARGSUSED*/
void
HandleLeaveWindow(Widget w GCC_UNUSED,
		  XtPointer eventdata GCC_UNUSED,
		  XEvent *event GCC_UNUSED,
		  Boolean *cont GCC_UNUSED)
{
    /* NOP since we handled it above */
    TRACE(("HandleLeaveWindow ignored\n"));
    TRACE_FOCUS(w, event);
}

/*ARGSUSED*/
void
HandleFocusChange(Widget w GCC_UNUSED,
		  XtPointer eventdata GCC_UNUSED,
		  XEvent *ev,
		  Boolean *cont GCC_UNUSED)
{
    XFocusChangeEvent *event = (XFocusChangeEvent *) ev;
    XtermWidget xw = term;
    TScreen *screen = TScreenOf(xw);

    TRACE(("HandleFocusChange type=%s, mode=%s, detail=%s\n",
	   visibleEventType(event->type),
	   visibleNotifyMode(event->mode),
	   visibleNotifyDetail(event->detail)));
    TRACE_FOCUS(xw, event);

    if (screen->quiet_grab
	&& (event->mode == NotifyGrab || event->mode == NotifyUngrab)) {
	/* EMPTY */ ;
    } else if (event->type == FocusIn) {
	if (event->detail != NotifyPointer) {
	    setXUrgency(xw, False);
	}

	/*
	 * NotifyNonlinear only happens (on FocusIn) if the pointer was not in
	 * one of our windows.  Use this to reset a case where one xterm is
	 * partly obscuring another, and X gets (us) confused about whether the
	 * pointer was in the window.  In particular, this can happen if the
	 * user is resizing the obscuring window, causing some events to not be
	 * delivered to the obscured window.
	 */
	if (event->detail == NotifyNonlinear
	    && (screen->select & INWINDOW) != 0) {
	    unselectwindow(xw, INWINDOW);
	}
	selectwindow(xw,
		     ((event->detail == NotifyPointer)
		      ? INWINDOW
		      : FOCUS));
	SendFocusButton(xw, event);
    } else {
#if OPT_FOCUS_EVENT
	if (event->type == FocusOut) {
	    SendFocusButton(xw, event);
	}
#endif
	/*
	 * XGrabKeyboard() will generate NotifyGrab event that we want to
	 * ignore.
	 */
	if (event->mode != NotifyGrab) {
	    unselectwindow(xw,
			   ((event->detail == NotifyPointer)
			    ? INWINDOW
			    : FOCUS));
	}
	if (screen->grabbedKbd && (event->mode == NotifyUngrab)) {
	    Bell(xw, XkbBI_Info, 100);
	    ReverseVideo(xw);
	    screen->grabbedKbd = False;
	    update_securekbd();
	}
    }
}

static long lastBellTime;	/* in milliseconds */

#if defined(HAVE_XKB_BELL_EXT)
static Atom
AtomBell(XtermWidget xw, int which)
{
#define DATA(name) { XkbBI_##name, XkbBN_##name }
    static struct {
	int value;
	const char *name;
    } table[] = {
	DATA(Info),
	    DATA(MarginBell),
	    DATA(MinorError),
	    DATA(TerminalBell)
    };
    Cardinal n;
    Atom result = None;

    for (n = 0; n < XtNumber(table); ++n) {
	if (table[n].value == which) {
	    result = XInternAtom(XtDisplay(xw), table[n].name, False);
	    break;
	}
    }
    return result;
}
#endif

void
xtermBell(XtermWidget xw, int which, int percent)
{
    TScreen *screen = TScreenOf(xw);
#if defined(HAVE_XKB_BELL_EXT)
    Atom tony = AtomBell(xw, which);
#endif

    switch (which) {
    case XkbBI_Info:
    case XkbBI_MinorError:
    case XkbBI_MajorError:
    case XkbBI_TerminalBell:
	switch (screen->warningVolume) {
	case bvOff:
	    percent = -100;
	    break;
	case bvLow:
	    break;
	case bvHigh:
	    percent = 100;
	    break;
	}
	break;
    case XkbBI_MarginBell:
	switch (screen->marginVolume) {
	case bvOff:
	    percent = -100;
	    break;
	case bvLow:
	    break;
	case bvHigh:
	    percent = 100;
	    break;
	}
	break;
    default:
	break;
    }

#if defined(HAVE_XKB_BELL_EXT)
    if (tony != None) {
	XkbBell(screen->display, VShellWindow(xw), percent, tony);
    } else
#endif
	XBell(screen->display, percent);
}

void
Bell(XtermWidget xw, int which, int percent)
{
    TScreen *screen = TScreenOf(xw);
    struct timeval curtime;

    TRACE(("BELL %d %d%%\n", which, percent));
    if (!XtIsRealized((Widget) xw)) {
	return;
    }

    setXUrgency(xw, True);

    /* has enough time gone by that we are allowed to ring
       the bell again? */
    if (screen->bellSuppressTime) {
	long now_msecs;

	if (screen->bellInProgress) {
	    do_xevents();
	    if (screen->bellInProgress) {	/* even after new events? */
		return;
	    }
	}
	X_GETTIMEOFDAY(&curtime);
	now_msecs = 1000 * curtime.tv_sec + curtime.tv_usec / 1000;
	if (lastBellTime != 0 && now_msecs - lastBellTime >= 0 &&
	    now_msecs - lastBellTime < screen->bellSuppressTime) {
	    return;
	}
	lastBellTime = now_msecs;
    }

    if (screen->visualbell) {
	VisualBell();
    } else {
	xtermBell(xw, which, percent);
    }

    if (screen->poponbell)
	XRaiseWindow(screen->display, VShellWindow(xw));

    if (screen->bellSuppressTime) {
	/* now we change a property and wait for the notify event to come
	   back.  If the server is suspending operations while the bell
	   is being emitted (problematic for audio bell), this lets us
	   know when the previous bell has finished */
	Widget w = CURRENT_EMU();
	XChangeProperty(XtDisplay(w), XtWindow(w),
			XA_NOTICE, XA_NOTICE, 8, PropModeAppend, NULL, 0);
	screen->bellInProgress = True;
    }
}

#define VB_DELAY screen->visualBellDelay

static void
flashWindow(TScreen *screen, Window window, GC visualGC, unsigned width, unsigned height)
{
    int y = 0;
    int x = 0;

    if (screen->flash_line) {
	y = CursorY(screen, screen->cur_row);
	height = (unsigned) FontHeight(screen);
    }
    XFillRectangle(screen->display, window, visualGC, x, y, width, height);
    XFlush(screen->display);
    Sleep(VB_DELAY);
    XFillRectangle(screen->display, window, visualGC, x, y, width, height);
}

void
VisualBell(void)
{
    TScreen *screen = TScreenOf(term);

    if (VB_DELAY > 0) {
	Pixel xorPixel = (T_COLOR(screen, TEXT_FG) ^
			  T_COLOR(screen, TEXT_BG));
	XGCValues gcval;
	GC visualGC;

	gcval.function = GXxor;
	gcval.foreground = xorPixel;
	visualGC = XtGetGC((Widget) term, GCFunction + GCForeground, &gcval);
#if OPT_TEK4014
	if (TEK4014_ACTIVE(term)) {
	    TekScreen *tekscr = TekScreenOf(tekWidget);
	    flashWindow(screen, TWindow(tekscr), visualGC,
			TFullWidth(tekscr),
			TFullHeight(tekscr));
	} else
#endif
	{
	    flashWindow(screen, VWindow(screen), visualGC,
			FullWidth(screen),
			FullHeight(screen));
	}
	XtReleaseGC((Widget) term, visualGC);
    }
}

/* ARGSUSED */
void
HandleBellPropertyChange(Widget w GCC_UNUSED,
			 XtPointer data GCC_UNUSED,
			 XEvent *ev,
			 Boolean *more GCC_UNUSED)
{
    TScreen *screen = TScreenOf(term);

    if (ev->xproperty.atom == XA_NOTICE) {
	screen->bellInProgress = False;
    }
}

void
xtermWarning(const char *fmt,...)
{
    int save_err = errno;
    va_list ap;

    fflush(stdout);
    TRACE(("xtermWarning fmt='%s'\n", fmt));
    fprintf(stderr, "%s: ", ProgramName);
    va_start(ap, fmt);
    vfprintf(stderr, fmt, ap);
    (void) fflush(stderr);

    va_end(ap);
    errno = save_err;
}

void
xtermPerror(const char *fmt,...)
{
    int save_err = errno;
    char *msg = strerror(errno);
    va_list ap;

    fflush(stdout);
    TRACE(("xtermPerror fmt='%s', msg='%s'\n", fmt, NonNull(msg)));
    fprintf(stderr, "%s: ", ProgramName);
    va_start(ap, fmt);
    vfprintf(stderr, fmt, ap);
    fprintf(stderr, ": %s\n", msg);
    (void) fflush(stderr);

    va_end(ap);
    errno = save_err;
}

Window
WMFrameWindow(XtermWidget xw)
{
    Window win_root, win_current, *children;
    Window win_parent = 0;
    unsigned int nchildren;

    win_current = XtWindow(xw);

    /* find the parent which is child of root */
    do {
	if (win_parent)
	    win_current = win_parent;
	XQueryTree(TScreenOf(xw)->display,
		   win_current,
		   &win_root,
		   &win_parent,
		   &children,
		   &nchildren);
	XFree(children);
    } while (win_root != win_parent);

    return win_current;
}

#if OPT_DABBREV
/*
 * The following code implements `dynamic abbreviation' expansion a la
 * Emacs.  It looks in the preceding visible screen and its scrollback
 * to find expansions of a typed word.  It compares consecutive
 * expansions and ignores one of them if they are identical.
 * (Tomasz J. Cholewo, t.cholewo@ieee.org)
 */

#define IS_WORD_CONSTITUENT(x) ((x) != ' ' && (x) != '\0')

static int
dabbrev_prev_char(TScreen *screen, CELL *cell, LineData **ld)
{
    int result = -1;
    int firstLine = -(screen->savedlines);

    *ld = getLineData(screen, cell->row);
    while (cell->row >= firstLine) {
	if (--(cell->col) >= 0) {
	    result = (int) (*ld)->charData[cell->col];
	    break;
	}
	if (--(cell->row) < firstLine)
	    break;		/* ...there is no previous line */
	*ld = getLineData(screen, cell->row);
	cell->col = MaxCols(screen);
	if (!LineTstWrapped(*ld)) {
	    result = ' ';	/* treat lines as separate */
	    break;
	}
    }
    return result;
}

static char *
dabbrev_prev_word(XtermWidget xw, CELL *cell, LineData **ld)
{
    TScreen *screen = TScreenOf(xw);
    char *abword;
    int c;
    char *ab_end = (xw->work.dabbrev_data + MAX_DABBREV - 1);
    char *result = 0;

    abword = ab_end;
    *abword = '\0';		/* end of string marker */

    while ((c = dabbrev_prev_char(screen, cell, ld)) >= 0 &&
	   IS_WORD_CONSTITUENT(c)) {
	if (abword > xw->work.dabbrev_data)	/* store only the last chars */
	    *(--abword) = (char) c;
    }

    if (c >= 0) {
	result = abword;
    } else if (abword != ab_end) {
	result = abword;
    }

    if (result != 0) {
	while ((c = dabbrev_prev_char(screen, cell, ld)) >= 0 &&
	       !IS_WORD_CONSTITUENT(c)) {
	    ;			/* skip preceding spaces */
	}
	(cell->col)++;		/* can be | > screen->max_col| */
    }
    return result;
}

static int
dabbrev_expand(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);
    int pty = screen->respond;	/* file descriptor of pty */

    static CELL cell;
    static char *dabbrev_hint = 0, *lastexpansion = 0;
    static unsigned int expansions;

    char *expansion;
    size_t hint_len;
    int result = 0;
    LineData *ld;

    if (!screen->dabbrev_working) {	/* initialize */
	expansions = 0;
	cell.col = screen->cur_col;
	cell.row = screen->cur_row;

	if (dabbrev_hint != 0)
	    free(dabbrev_hint);

	if ((dabbrev_hint = dabbrev_prev_word(xw, &cell, &ld)) != 0) {

	    if (lastexpansion != 0)
		free(lastexpansion);

	    if ((lastexpansion = strdup(dabbrev_hint)) != 0) {

		/* make own copy */
		if ((dabbrev_hint = strdup(dabbrev_hint)) != 0) {
		    screen->dabbrev_working = True;
		    /* we are in the middle of dabbrev process */
		}
	    } else {
		return result;
	    }
	} else {
	    return result;
	}
	if (!screen->dabbrev_working) {
	    if (lastexpansion != 0) {
		free(lastexpansion);
		lastexpansion = 0;
	    }
	    return result;
	}
    }

    if (dabbrev_hint == 0)
	return result;

    hint_len = strlen(dabbrev_hint);
    for (;;) {
	if ((expansion = dabbrev_prev_word(xw, &cell, &ld)) == 0) {
	    if (expansions >= 2) {
		expansions = 0;
		cell.col = screen->cur_col;
		cell.row = screen->cur_row;
		continue;
	    }
	    break;
	}
	if (!strncmp(dabbrev_hint, expansion, hint_len) &&	/* empty hint matches everything */
	    strlen(expansion) > hint_len &&	/* trivial expansion disallowed */
	    strcmp(expansion, lastexpansion))	/* different from previous */
	    break;
    }

    if (expansion != 0) {
	Char *copybuffer;
	size_t del_cnt = strlen(lastexpansion) - hint_len;
	size_t buf_cnt = del_cnt + strlen(expansion) - hint_len;

	if ((copybuffer = TypeMallocN(Char, buf_cnt)) != 0) {
	    /* delete previous expansion */
	    memset(copybuffer, screen->dabbrev_erase_char, del_cnt);
	    memmove(copybuffer + del_cnt,
		    expansion + hint_len,
		    strlen(expansion) - hint_len);
	    v_write(pty, copybuffer, (unsigned) buf_cnt);
	    /* v_write() just reset our flag */
	    screen->dabbrev_working = True;
	    free(copybuffer);

	    free(lastexpansion);

	    if ((lastexpansion = strdup(expansion)) != 0) {
		result = 1;
		expansions++;
	    }
	}
    }

    return result;
}

/*ARGSUSED*/
void
HandleDabbrevExpand(Widget w,
		    XEvent *event GCC_UNUSED,
		    String *params GCC_UNUSED,
		    Cardinal *nparams GCC_UNUSED)
{
    XtermWidget xw;

    TRACE(("Handle dabbrev-expand for %p\n", (void *) w));
    if ((xw = getXtermWidget(w)) != 0) {
	if (!dabbrev_expand(xw))
	    Bell(xw, XkbBI_TerminalBell, 0);
    }
}
#endif /* OPT_DABBREV */

#if OPT_MAXIMIZE
/*ARGSUSED*/
void
HandleDeIconify(Widget w,
		XEvent *event GCC_UNUSED,
		String *params GCC_UNUSED,
		Cardinal *nparams GCC_UNUSED)
{
    XtermWidget xw;

    if ((xw = getXtermWidget(w)) != 0) {
	TScreen *screen = TScreenOf(xw);
	XMapWindow(screen->display, VShellWindow(xw));
    }
}

/*ARGSUSED*/
void
HandleIconify(Widget w,
	      XEvent *event GCC_UNUSED,
	      String *params GCC_UNUSED,
	      Cardinal *nparams GCC_UNUSED)
{
    XtermWidget xw;

    if ((xw = getXtermWidget(w)) != 0) {
	TScreen *screen = TScreenOf(xw);
	XIconifyWindow(screen->display,
		       VShellWindow(xw),
		       DefaultScreen(screen->display));
    }
}

int
QueryMaximize(XtermWidget xw, unsigned *width, unsigned *height)
{
    TScreen *screen = TScreenOf(xw);
    XSizeHints hints;
    long supp = 0;
    Window root_win;
    int root_x = -1;		/* saved co-ordinates */
    int root_y = -1;
    unsigned root_border;
    unsigned root_depth;
    int code;

    if (XGetGeometry(screen->display,
		     RootWindowOfScreen(XtScreen(xw)),
		     &root_win,
		     &root_x,
		     &root_y,
		     width,
		     height,
		     &root_border,
		     &root_depth)) {
	TRACE(("QueryMaximize: XGetGeometry position %d,%d size %d,%d border %d\n",
	       root_x,
	       root_y,
	       *width,
	       *height,
	       root_border));

	*width -= (root_border * 2);
	*height -= (root_border * 2);

	hints.flags = PMaxSize;
	if (XGetWMNormalHints(screen->display,
			      VShellWindow(xw),
			      &hints,
			      &supp)
	    && (hints.flags & PMaxSize) != 0) {

	    TRACE(("QueryMaximize: WM hints max_w %#x max_h %#x\n",
		   hints.max_width,
		   hints.max_height));

	    if ((unsigned) hints.max_width < *width)
		*width = (unsigned) hints.max_width;
	    if ((unsigned) hints.max_height < *height)
		*height = (unsigned) hints.max_height;
	}
	code = 1;
    } else {
	*width = 0;
	*height = 0;
	code = 0;
    }
    return code;
}

void
RequestMaximize(XtermWidget xw, int maximize)
{
    TScreen *screen = TScreenOf(xw);
    XWindowAttributes wm_attrs, vshell_attrs;
    unsigned root_width, root_height;
    Boolean success = False;

    TRACE(("RequestMaximize %d:%s\n",
	   maximize,
	   (maximize
	    ? "maximize"
	    : "restore")));

    /*
     * Before any maximize, ensure that we can capture the current screensize
     * as well as the estimated root-window size.
     */
    if (maximize
	&& QueryMaximize(xw, &root_width, &root_height)
	&& xtermGetWinAttrs(screen->display,
			    WMFrameWindow(xw),
			    &wm_attrs)
	&& xtermGetWinAttrs(screen->display,
			    VShellWindow(xw),
			    &vshell_attrs)) {

	if (screen->restore_data != True
	    || screen->restore_width != root_width
	    || screen->restore_height != root_height) {
	    screen->restore_data = True;
	    screen->restore_x = wm_attrs.x + wm_attrs.border_width;
	    screen->restore_y = wm_attrs.y + wm_attrs.border_width;
	    screen->restore_width = (unsigned) vshell_attrs.width;
	    screen->restore_height = (unsigned) vshell_attrs.height;
	    TRACE(("RequestMaximize: save window position %d,%d size %d,%d\n",
		   screen->restore_x,
		   screen->restore_y,
		   screen->restore_width,
		   screen->restore_height));
	}

	/* subtract wm decoration dimensions */
	root_width -= (unsigned) ((wm_attrs.width - vshell_attrs.width)
				  + (wm_attrs.border_width * 2));
	root_height -= (unsigned) ((wm_attrs.height - vshell_attrs.height)
				   + (wm_attrs.border_width * 2));
	success = True;
    } else if (screen->restore_data) {
	success = True;
	maximize = 0;
    }

    if (success) {
	switch (maximize) {
	case 3:
	    FullScreen(xw, 3);	/* depends on EWMH */
	    break;
	case 2:
	    FullScreen(xw, 2);	/* depends on EWMH */
	    break;
	case 1:
	    FullScreen(xw, 0);	/* overrides any EWMH hint */
	    XMoveResizeWindow(screen->display, VShellWindow(xw),
			      0 + wm_attrs.border_width,	/* x */
			      0 + wm_attrs.border_width,	/* y */
			      root_width,
			      root_height);
	    break;

	default:
	    FullScreen(xw, 0);	/* reset any EWMH hint */
	    if (screen->restore_data) {
		screen->restore_data = False;

		TRACE(("HandleRestoreSize: position %d,%d size %d,%d\n",
		       screen->restore_x,
		       screen->restore_y,
		       screen->restore_width,
		       screen->restore_height));

		XMoveResizeWindow(screen->display,
				  VShellWindow(xw),
				  screen->restore_x,
				  screen->restore_y,
				  screen->restore_width,
				  screen->restore_height);
	    }
	    break;
	}
    }
}

/*ARGSUSED*/
void
HandleMaximize(Widget w,
	       XEvent *event GCC_UNUSED,
	       String *params GCC_UNUSED,
	       Cardinal *nparams GCC_UNUSED)
{
    XtermWidget xw;

    if ((xw = getXtermWidget(w)) != 0) {
	RequestMaximize(xw, 1);
    }
}

/*ARGSUSED*/
void
HandleRestoreSize(Widget w,
		  XEvent *event GCC_UNUSED,
		  String *params GCC_UNUSED,
		  Cardinal *nparams GCC_UNUSED)
{
    XtermWidget xw;

    if ((xw = getXtermWidget(w)) != 0) {
	RequestMaximize(xw, 0);
    }
}
#endif /* OPT_MAXIMIZE */

void
Redraw(void)
{
    TScreen *screen = TScreenOf(term);
    XExposeEvent event;

    TRACE(("Redraw\n"));

    event.type = Expose;
    event.display = screen->display;
    event.x = 0;
    event.y = 0;
    event.count = 0;

    if (VWindow(screen)) {
	event.window = VWindow(screen);
	event.width = term->core.width;
	event.height = term->core.height;
	(*term->core.widget_class->core_class.expose) ((Widget) term,
						       (XEvent *) &event,
						       NULL);
	if (ScrollbarWidth(screen)) {
	    (screen->scrollWidget->core.widget_class->core_class.expose)
		(screen->scrollWidget, (XEvent *) &event, NULL);
	}
    }
#if OPT_TEK4014
    if (TEK4014_SHOWN(term)) {
	TekScreen *tekscr = TekScreenOf(tekWidget);
	event.window = TWindow(tekscr);
	event.width = tekWidget->core.width;
	event.height = tekWidget->core.height;
	TekExpose((Widget) tekWidget, (XEvent *) &event, NULL);
    }
#endif
}

#ifdef VMS
#define TIMESTAMP_FMT "%s%d-%02d-%02d-%02d-%02d-%02d"
#else
#define TIMESTAMP_FMT "%s%d-%02d-%02d.%02d:%02d:%02d"
#endif

void
timestamp_filename(char *dst, const char *src)
{
    time_t tstamp;
    struct tm *tstruct;

    tstamp = time((time_t *) 0);
    tstruct = localtime(&tstamp);
    sprintf(dst, TIMESTAMP_FMT,
	    src,
	    (int) tstruct->tm_year + 1900,
	    tstruct->tm_mon + 1,
	    tstruct->tm_mday,
	    tstruct->tm_hour,
	    tstruct->tm_min,
	    tstruct->tm_sec);
}

int
open_userfile(uid_t uid, gid_t gid, char *path, Bool append)
{
    int fd;
    struct stat sb;

#ifdef VMS
    if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644)) < 0) {
	int the_error = errno;
	xtermWarning("cannot open %s: %d:%s\n",
		     path,
		     the_error,
		     SysErrorMsg(the_error));
	return -1;
    }
    chown(path, uid, gid);
#else
    if ((access(path, F_OK) != 0 && (errno != ENOENT))
	|| (creat_as(uid, gid, append, path, 0644) <= 0)
	|| ((fd = open(path, O_WRONLY | O_APPEND)) < 0)) {
	int the_error = errno;
	xtermWarning("cannot open %s: %d:%s\n",
		     path,
		     the_error,
		     SysErrorMsg(the_error));
	return -1;
    }
#endif

    /*
     * Doublecheck that the user really owns the file that we've opened before
     * we do any damage, and that it is not world-writable.
     */
    if (fstat(fd, &sb) < 0
	|| sb.st_uid != uid
	|| (sb.st_mode & 022) != 0) {
	xtermWarning("you do not own %s\n", path);
	close(fd);
	return -1;
    }
    return fd;
}

#ifndef VMS
/*
 * Create a file only if we could with the permissions of the real user id.
 * We could emulate this with careful use of access() and following
 * symbolic links, but that is messy and has race conditions.
 * Forking is messy, too, but we can't count on setreuid() or saved set-uids
 * being available.
 *
 * Note: When called for user logging, we have ensured that the real and
 * effective user ids are the same, so this remains as a convenience function
 * for the debug logs.
 *
 * Returns
 *	 1 if we can proceed to open the file in relative safety,
 *	-1 on error, e.g., cannot fork
 *	 0 otherwise.
 */
int
creat_as(uid_t uid, gid_t gid, Bool append, char *pathname, unsigned mode)
{
    int fd;
    pid_t pid;
    int retval = 0;
    int childstat = 0;
#ifndef HAVE_WAITPID
    int waited;
    void (*chldfunc) (int);

    chldfunc = signal(SIGCHLD, SIG_DFL);
#endif /* HAVE_WAITPID */

    TRACE(("creat_as(uid=%d/%d, gid=%d/%d, append=%d, pathname=%s, mode=%#o)\n",
	   (int) uid, (int) geteuid(),
	   (int) gid, (int) getegid(),
	   append,
	   pathname,
	   mode));

    if (uid == geteuid() && gid == getegid()) {
	fd = open(pathname,
		  O_WRONLY | O_CREAT | (append ? O_APPEND : O_EXCL),
		  mode);
	if (fd >= 0)
	    close(fd);
	return (fd >= 0);
    }

    pid = fork();
    switch (pid) {
    case 0:			/* child */
	if (setgid(gid) == -1
	    || setuid(uid) == -1) {
	    /* we cannot report an error here via stderr, just quit */
	    retval = 1;
	} else {
	    fd = open(pathname,
		      O_WRONLY | O_CREAT | (append ? O_APPEND : O_EXCL),
		      mode);
	    if (fd >= 0) {
		close(fd);
		retval = 0;
	    } else {
		retval = 1;
	    }
	}
	_exit(retval);
	/* NOTREACHED */
    case -1:			/* error */
	return retval;
    default:			/* parent */
#ifdef HAVE_WAITPID
	while (waitpid(pid, &childstat, 0) < 0) {
#ifdef EINTR
	    if (errno == EINTR)
		continue;
#endif /* EINTR */
#ifdef ERESTARTSYS
	    if (errno == ERESTARTSYS)
		continue;
#endif /* ERESTARTSYS */
	    break;
	}
#else /* HAVE_WAITPID */
	waited = wait(&childstat);
	signal(SIGCHLD, chldfunc);
	/*
	   Since we had the signal handler uninstalled for a while,
	   we might have missed the termination of our screen child.
	   If we can check for this possibility without hanging, do so.
	 */
	do
	    if (waited == TScreenOf(term)->pid)
		NormalExit();
	while ((waited = nonblocking_wait()) > 0) ;
#endif /* HAVE_WAITPID */
#ifndef WIFEXITED
#define WIFEXITED(status) ((status & 0xff) != 0)
#endif
	if (WIFEXITED(childstat))
	    retval = 1;
	return retval;
    }
}
#endif /* !VMS */

int
xtermResetIds(TScreen *screen)
{
    int result = 0;
    if (setgid(screen->gid) == -1) {
	xtermWarning("unable to reset group-id\n");
	result = -1;
    }
    if (setuid(screen->uid) == -1) {
	xtermWarning("unable to reset user-id\n");
	result = -1;
    }
    return result;
}

#ifdef ALLOWLOGGING

/*
 * Logging is a security hole, since it allows a setuid program to write
 * arbitrary data to an arbitrary file.  So it is disabled by default.
 */

#ifdef ALLOWLOGFILEEXEC
static void
logpipe(int sig GCC_UNUSED)
{
    XtermWidget xw = term;
    TScreen *screen = TScreenOf(xw);

    DEBUG_MSG("handle:logpipe\n");
#ifdef SYSV
    (void) signal(SIGPIPE, SIG_IGN);
#endif /* SYSV */
    if (screen->logging)
	CloseLog(xw);
}
#endif /* ALLOWLOGFILEEXEC */

void
StartLog(XtermWidget xw)
{
    static char *log_default;
    TScreen *screen = TScreenOf(xw);

    if (screen->logging || (screen->inhibit & I_LOG))
	return;
#ifdef VMS			/* file name is fixed in VMS variant */
    screen->logfd = open(XTERM_VMS_LOGFILE,
			 O_CREAT | O_TRUNC | O_APPEND | O_RDWR,
			 0640);
    if (screen->logfd < 0)
	return;			/* open failed */
#else /*VMS */
    if (screen->logfile == NULL || *screen->logfile == 0) {
	if (screen->logfile)
	    free(screen->logfile);
	if (log_default == NULL) {
#if defined(HAVE_GETHOSTNAME) && defined(HAVE_STRFTIME)
	    const char form[] = "Xterm.log.%s%s.%d";
	    char where[255 + 1];	/* Internet standard limit (RFC 1035):
					   ``To simplify implementations, the
					   total length of a domain name (i.e.,
					   label octets and label length
					   octets) is restricted to 255 octets
					   or less.'' */
	    char when[LEN_TIMESTAMP];
	    char formatted[sizeof(form) + sizeof(where) + sizeof(when) + 9];
	    time_t now;
	    struct tm *ltm;

	    now = time((time_t *) 0);
	    ltm = (struct tm *) localtime(&now);
	    if ((gethostname(where, sizeof(where)) == 0) &&
		(strftime(when, sizeof(when), FMT_TIMESTAMP, ltm) > 0)) {
		(void) sprintf(formatted, form, where, when, (int) getpid());
	    } else {
		return;
	    }
	    if ((log_default = x_strdup(formatted)) == NULL) {
		return;
	    }
#else
	    static const char log_def_name[] = "XtermLog.XXXXXX";
	    if ((log_default = x_strdup(log_def_name)) == NULL) {
		return;
	    }
	    mktemp(log_default);
#endif
	}
	if ((screen->logfile = x_strdup(log_default)) == 0)
	    return;
    }
    if (*screen->logfile == '|') {	/* exec command */
#ifdef ALLOWLOGFILEEXEC
	/*
	 * Warning, enabling this "feature" allows arbitrary programs
	 * to be run.  If ALLOWLOGFILECHANGES is enabled, this can be
	 * done through escape sequences....  You have been warned.
	 */
	int pid;
	int p[2];
	static char *shell;
	struct passwd pw;

	if ((shell = x_getenv("SHELL")) == NULL) {

	    if (x_getpwuid(screen->uid, &pw)) {
		char *name = x_getlogin(screen->uid, &pw);
		if (*(pw.pw_shell)) {
		    shell = pw.pw_shell;
		}
		free(name);
	    }
	}

	if (shell == 0) {
	    static char dummy[] = "/bin/sh";
	    shell = dummy;
	}

	if (access(shell, X_OK) != 0) {
	    xtermPerror("Can't execute `%s'\n", shell);
	    return;
	}

	if (pipe(p) < 0) {
	    xtermPerror("Can't make a pipe connection\n");
	    return;
	} else if ((pid = fork()) < 0) {
	    xtermPerror("Can't fork...\n");
	    return;
	}
	if (pid == 0) {		/* child */
	    /*
	     * Close our output (we won't be talking back to the
	     * parent), and redirect our child's output to the
	     * original stderr.
	     */
	    close(p[1]);
	    dup2(p[0], 0);
	    close(p[0]);
	    dup2(fileno(stderr), 1);
	    dup2(fileno(stderr), 2);

	    close(fileno(stderr));
	    close(ConnectionNumber(screen->display));
	    close(screen->respond);

	    signal(SIGHUP, SIG_DFL);
	    signal(SIGCHLD, SIG_DFL);

	    /* (this is redundant) */
	    if (xtermResetIds(screen) < 0)
		exit(ERROR_SETUID);

	    if (access(shell, X_OK) == 0) {
		execl(shell, shell, "-c", &screen->logfile[1], (void *) 0);
		xtermWarning("Can't exec `%s'\n", &screen->logfile[1]);
	    } else {
		xtermWarning("Can't execute `%s'\n", shell);
	    }
	    exit(ERROR_LOGEXEC);
	}
	close(p[0]);
	screen->logfd = p[1];
	signal(SIGPIPE, logpipe);
#else
	Bell(xw, XkbBI_Info, 0);
	Bell(xw, XkbBI_Info, 0);
	return;
#endif
    } else {
	if ((screen->logfd = open_userfile(screen->uid,
					   screen->gid,
					   screen->logfile,
					   (log_default != 0))) < 0)
	    return;
    }
#endif /*VMS */
    screen->logstart = VTbuffer->next;
    screen->logging = True;
    update_logging();
}

void
CloseLog(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);

    if (!screen->logging || (screen->inhibit & I_LOG))
	return;
    FlushLog(xw);
    close(screen->logfd);
    screen->logging = False;
    update_logging();
}

void
FlushLog(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);

    if (screen->logging && !(screen->inhibit & I_LOG)) {
	Char *cp;
	int i;

#ifdef VMS			/* avoid logging output loops which otherwise occur sometimes
				   when there is no output and cp/screen->logstart are 1 apart */
	if (!tt_new_output)
	    return;
	tt_new_output = False;
#endif /* VMS */
	cp = VTbuffer->next;
	if (screen->logstart != 0
	    && (i = (int) (cp - screen->logstart)) > 0) {
	    IGNORE_RC(write(screen->logfd, screen->logstart, (size_t) i));
	}
	screen->logstart = VTbuffer->next;
    }
}

#endif /* ALLOWLOGGING */

/***====================================================================***/

int
getVisualInfo(XtermWidget xw)
{
#define MYFMT "getVisualInfo \
depth %d, \
type %d (%s), \
size %d \
rgb masks (%04lx/%04lx/%04lx)\n"
#define MYARG \
       vi->depth,\
       vi->class,\
       ((vi->class & 1) ? "dynamic" : "static"),\
       vi->colormap_size,\
       vi->red_mask,\
       vi->green_mask,\
       vi->blue_mask

    TScreen *screen = TScreenOf(xw);
    Display *dpy = screen->display;
    XVisualInfo myTemplate;

    if (xw->visInfo == 0 && xw->numVisuals == 0) {
	myTemplate.visualid = XVisualIDFromVisual(DefaultVisual(dpy,
								XDefaultScreen(dpy)));
	xw->visInfo = XGetVisualInfo(dpy, (long) VisualIDMask,
				     &myTemplate, &xw->numVisuals);

	if ((xw->visInfo != 0) && (xw->numVisuals > 0)) {
	    XVisualInfo *vi = xw->visInfo;
	    if (resource.reportColors) {
		printf(MYFMT, MYARG);
	    }
	    TRACE((MYFMT, MYARG));
	}
    }
    return (xw->visInfo != 0) && (xw->numVisuals > 0);
#undef MYFMT
#undef MYARG
}

#if OPT_ISO_COLORS
static void
ReportAnsiColorRequest(XtermWidget xw, int colornum, int final)
{
    if (AllowColorOps(xw, ecGetAnsiColor)) {
	XColor color;
	Colormap cmap = xw->core.colormap;
	char buffer[80];

	TRACE(("ReportAnsiColorRequest %d\n", colornum));
	color.pixel = GET_COLOR_RES(xw, TScreenOf(xw)->Acolors[colornum]);
	XQueryColor(TScreenOf(xw)->display, cmap, &color);
	sprintf(buffer, "4;%d;rgb:%04x/%04x/%04x",
		colornum,
		color.red,
		color.green,
		color.blue);
	unparseputc1(xw, ANSI_OSC);
	unparseputs(xw, buffer);
	unparseputc1(xw, final);
	unparse_end(xw);
    }
}

static void
getColormapInfo(XtermWidget xw, unsigned *typep, unsigned *sizep)
{
    if (getVisualInfo(xw)) {
	*typep = (unsigned) xw->visInfo->class;
	*sizep = (unsigned) xw->visInfo->colormap_size;
    } else {
	*typep = 0;
	*sizep = 0;
    }
}

#define MAX_COLORTABLE 4096

/*
 * Make only one call to XQueryColors(), since it can be slow.
 */
static Boolean
loadColorTable(XtermWidget xw, unsigned length)
{
    Colormap cmap = xw->core.colormap;
    TScreen *screen = TScreenOf(xw);
    Boolean result = (screen->cmap_data != 0);

    if (!result
	&& length != 0
	&& length < MAX_COLORTABLE) {
	screen->cmap_data = TypeMallocN(XColor, (size_t) length);

	if (screen->cmap_data != 0) {
	    unsigned i;

	    screen->cmap_size = length;

	    for (i = 0; i < screen->cmap_size; i++) {
		screen->cmap_data[i].pixel = (unsigned long) i;
	    }
	    result = (Boolean) (XQueryColors(screen->display,
					     cmap,
					     screen->cmap_data,
					     (int) screen->cmap_size) != 0);
	}
    }
    return result;
}

/*
 * Find closest color for "def" in "cmap".
 * Set "def" to the resulting color.
 *
 * Based on Monish Shah's "find_closest_color()" for Vim 6.0,
 * modified with ideas from David Tong's "noflash" library.
 * The code from Vim in turn was derived from FindClosestColor() in Tcl/Tk.
 *
 * Return False if not able to find or allocate a color.
 */
static Boolean
allocateClosestRGB(XtermWidget xw, Colormap cmap, XColor *def)
{
    TScreen *screen = TScreenOf(xw);
    Boolean result = False;
    unsigned cmap_type;
    unsigned cmap_size;

    getColormapInfo(xw, &cmap_type, &cmap_size);

    if ((cmap_type & 1) != 0) {

	if (loadColorTable(xw, cmap_size)) {
	    char *tried = TypeCallocN(char, (size_t) cmap_size);

	    if (tried != 0) {
		unsigned attempts;

		/*
		 * Try (possibly each entry in the color map) to find the best
		 * approximation to the requested color.
		 */
		for (attempts = 0; attempts < cmap_size; attempts++) {
		    Boolean first = True;
		    double bestRGB = 0.0;
		    unsigned bestInx = 0;
		    unsigned i;

		    for (i = 0; i < cmap_size; i++) {
			if (!tried[bestInx]) {
			    double diff, thisRGB = 0.0;

			    /*
			     * Look for the best match based on luminance.
			     * Measure this by the least-squares difference of
			     * the weighted R/G/B components from the color map
			     * versus the requested color.  Use the Y (luma)
			     * component of the YIQ color space model for
			     * weights that correspond to the luminance.
			     */
#define AddColorWeight(weight, color) \
			    diff = weight * (int) ((def->color) - screen->cmap_data[i].color); \
			    thisRGB += diff * diff

			    AddColorWeight(0.30, red);
			    AddColorWeight(0.61, green);
			    AddColorWeight(0.11, blue);

			    if (first || (thisRGB < bestRGB)) {
				first = False;
				bestInx = i;
				bestRGB = thisRGB;
			    }
			}
		    }
		    if (XAllocColor(screen->display, cmap,
				    &screen->cmap_data[bestInx]) != 0) {
			*def = screen->cmap_data[bestInx];
			TRACE(("...closest %x/%x/%x\n", def->red,
			       def->green, def->blue));
			result = True;
			break;
		    }
		    /*
		     * It failed - either the color map entry was readonly, or
		     * another client has allocated the entry.  Mark the entry
		     * so we will ignore it
		     */
		    tried[bestInx] = True;
		}
		free(tried);
	    }
	}
    }
    return result;
}

#ifndef ULONG_MAX
#define ULONG_MAX (unsigned long)(~(0L))
#endif

#define CheckColor(result, value) \
	    result = 0; \
	    if (value.red) \
		result |= 1; \
	    if (value.green) \
		result |= 2; \
	    if (value.blue) \
		result |= 4

#define SelectColor(state, value, result) \
	switch (state) { \
	default: \
	case 1: \
	    result = value.red; \
	    break; \
	case 2: \
	    result = value.green; \
	    break; \
	case 4: \
	    result = value.blue; \
	    break; \
	}

/*
 * Check if the color map consists of values in exactly one of the red, green
 * or blue columns.  If it is not, we do not know how to use it for the exact
 * match.
 */
static int
simpleColors(XColor *colortable, unsigned length)
{
    unsigned n;
    int state = 0;
    int check;

    for (n = 0; n < length; ++n) {
	if (state > 0) {
	    CheckColor(check, colortable[n]);
	    if (check > 0 && check != state) {
		state = 0;
		break;
	    }
	} else {
	    CheckColor(state, colortable[n]);
	}
    }
    switch (state) {
    case 1:
    case 2:
    case 4:
	break;
    default:
	state = 0;
	break;
    }
    return state;
}

/*
 * Shift the mask left or right to put its most significant bit at the 16-bit
 * mark.
 */
static unsigned
normalizeMask(unsigned mask)
{
    while (mask < 0x8000) {
	mask <<= 1;
    }
    while (mask >= 0x10000) {
	mask >>= 1;
    }
    return mask;
}

static unsigned
searchColors(XColor *colortable, unsigned mask, unsigned length, unsigned
	     color, int state)
{
    unsigned result = 0;
    unsigned n;
    unsigned long best = ULONG_MAX;
    unsigned value;

    mask = normalizeMask(mask);
    for (n = 0; n < length; ++n) {
	unsigned long diff;

	SelectColor(state, colortable[n], value);
	diff = ((color & mask) - (value & mask));
	diff *= diff;
	if (diff < best) {
#if 0
	    TRACE(("...%d:looking for %x, found %x/%x/%x (%lx)\n",
		   n, color,
		   colortable[n].red,
		   colortable[n].green,
		   colortable[n].blue,
		   diff));
#endif
	    result = n;
	    best = diff;
	}
    }
    SelectColor(state, colortable[result], value);
    return value;
}

/*
 * This is a workaround for a longstanding defect in the X libraries.
 *
 * According to
 * http://www.unix.com/man-page/all/3x/XAllocColoA/
 *
 *     XAllocColor() acts differently on static and dynamic visuals.  On Pseu-
 *     doColor, DirectColor, and GrayScale  visuals,  XAllocColor()  fails  if
 *     there  are  no  unallocated  colorcells and no allocated read-only cell
 *     exactly matches the requested RGB values.  On  StaticColor,  TrueColor,
 *     and  StaticGray  visuals,  XAllocColor() returns the closest RGB values
 *     available in the colormap.  The colorcell_in_out structure returns  the
 *     actual RGB values allocated.
 *
 * That is, XAllocColor() should suffice unless the color map is full.  In that
 * case, allocateClosestRGB() is useful for the dynamic display classes such as
 * PseudoColor.  It is not useful for TrueColor, since XQueryColors() does not
 * return regular RGB triples (unless a different scheme was used for
 * specifying the pixel values); only the blue value is filled in.  However, it
 * is filled in with the colors that the server supports.
 *
 * Also (the reason for this function), XAllocColor() does not really work as
 * described.  For some TrueColor configurations it merely returns a close
 * approximation, but not the closest.
 */
static Boolean
allocateExactRGB(XtermWidget xw, Colormap cmap, XColor *def)
{
    XColor save = *def;
    TScreen *screen = TScreenOf(xw);
    Boolean result = (Boolean) (XAllocColor(screen->display, cmap, def) != 0);

    /*
     * If this is a statically allocated display with too many items to store
     * in our array, i.e., TrueColor, see if we can improve on the result by
     * using the color values actually supported by the server.
     */
    if (result) {
	unsigned cmap_type;
	unsigned cmap_size;

	getColormapInfo(xw, &cmap_type, &cmap_size);

	if (cmap_type == TrueColor) {
	    XColor temp = *def;
	    int state;

	    if (loadColorTable(xw, cmap_size)
		&& (state = simpleColors(screen->cmap_data, cmap_size)) > 0) {
#define SearchColors(which) \
	temp.which = (unsigned short) searchColors(screen->cmap_data, \
						   (unsigned) xw->visInfo->which##_mask,\
						   cmap_size, \
						   save.which, \
						   state)
		SearchColors(red);
		SearchColors(green);
		SearchColors(blue);
		if (XAllocColor(screen->display, cmap, &temp) != 0) {
#if OPT_TRACE
		    if (temp.red != save.red
			|| temp.green != save.green
			|| temp.blue != save.blue) {
			TRACE(("...improved %x/%x/%x ->%x/%x/%x\n",
			       save.red, save.green, save.blue,
			       temp.red, temp.green, temp.blue));
		    } else {
			TRACE(("...no improvement for %x/%x/%x\n",
			       save.red, save.green, save.blue));
		    }
#endif
		    *def = temp;
		}
	    }
	}
    }

    return result;
}

/*
 * Allocate a color for the "ANSI" colors.  That actually includes colors up
 * to 256.
 *
 * Returns
 *	-1 on error
 *	0 on no change
 *	1 if a new color was allocated.
 */
static int
AllocateAnsiColor(XtermWidget xw,
		  ColorRes * res,
		  const char *spec)
{
    int result;
    XColor def;

    if (xtermAllocColor(xw, &def, spec)) {
	if (
#if OPT_COLOR_RES
	       res->mode == True &&
#endif
	       EQL_COLOR_RES(res, def.pixel)) {
	    result = 0;
	} else {
	    result = 1;
	    SET_COLOR_RES(res, def.pixel);
	    res->red = def.red;
	    res->green = def.green;
	    res->blue = def.blue;
	    TRACE(("AllocateAnsiColor[%d] %s (rgb:%04x/%04x/%04x, pixel 0x%06lx)\n",
		   (int) (res - TScreenOf(xw)->Acolors), spec,
		   def.red,
		   def.green,
		   def.blue,
		   def.pixel));
#if OPT_COLOR_RES
	    if (!res->mode)
		result = 0;
	    res->mode = True;
#endif
	}
    } else {
	TRACE(("AllocateAnsiColor %s (failed)\n", spec));
	result = -1;
    }
    return (result);
}

#if OPT_COLOR_RES
Pixel
xtermGetColorRes(XtermWidget xw, ColorRes * res)
{
    Pixel result = 0;

    if (res->mode) {
	result = res->value;
    } else {
	TRACE(("xtermGetColorRes for Acolors[%d]\n",
	       (int) (res - TScreenOf(xw)->Acolors)));

	if (res >= TScreenOf(xw)->Acolors) {
	    assert(res - TScreenOf(xw)->Acolors < MAXCOLORS);

	    if (AllocateAnsiColor(xw, res, res->resource) < 0) {
		res->value = TScreenOf(xw)->Tcolors[TEXT_FG].value;
		res->mode = -True;
		xtermWarning("Cannot allocate color \"%s\"\n",
			     NonNull(res->resource));
	    }
	    result = res->value;
	} else {
	    result = 0;
	}
    }
    return result;
}
#endif

static int
ChangeOneAnsiColor(XtermWidget xw, int color, const char *name)
{
    int code;

    if (color < 0 || color >= MAXCOLORS) {
	code = -1;
    } else {
	ColorRes *res = &(TScreenOf(xw)->Acolors[color]);

	TRACE(("ChangeAnsiColor for Acolors[%d]\n", color));
	code = AllocateAnsiColor(xw, res, name);
    }
    return code;
}

/*
 * Set or query entries in the Acolors[] array by parsing pairs of color/name
 * values from the given buffer.
 *
 * The color can be any legal index into Acolors[], which consists of the
 * 16/88/256 "ANSI" colors, followed by special color values for the various
 * colorXX resources.  The indices for the special color values are not
 * simple to work with, so an alternative is to use the calls which pass in
 * 'first' set to the beginning of those indices.
 *
 * If the name is "?", report to the host the current value for the color.
 */
static Bool
ChangeAnsiColorRequest(XtermWidget xw,
		       char *buf,
		       int first,
		       int final)
{
    int repaint = False;
    int code;
    int last = (MAXCOLORS - first);

    TRACE(("ChangeAnsiColorRequest string='%s'\n", buf));

    while (buf && *buf) {
	int color;
	char *name = strchr(buf, ';');

	if (name == NULL)
	    break;
	*name = '\0';
	name++;
	color = atoi(buf);
	if (color < 0 || color >= last)
	    break;		/* quit on any error */
	buf = strchr(name, ';');
	if (buf) {
	    *buf = '\0';
	    buf++;
	}
	if (!strcmp(name, "?")) {
	    ReportAnsiColorRequest(xw, color + first, final);
	} else {
	    code = ChangeOneAnsiColor(xw, color + first, name);
	    if (code < 0) {
		/* stop on any error */
		break;
	    } else if (code > 0) {
		repaint = True;
	    }
	    /* FIXME:  free old color somehow?  We aren't for the other color
	     * change style (dynamic colors).
	     */
	}
    }

    return (repaint);
}

static Bool
ResetOneAnsiColor(XtermWidget xw, int color, int start)
{
    Bool repaint = False;
    int last = MAXCOLORS - start;

    if (color >= 0 && color < last) {
	ColorRes *res = &(TScreenOf(xw)->Acolors[color + start]);

	if (res->mode) {
	    /* a color has been allocated for this slot - test further... */
	    if (ChangeOneAnsiColor(xw, color + start, res->resource) > 0) {
		repaint = True;
	    }
	}
    }
    return repaint;
}

int
ResetAnsiColorRequest(XtermWidget xw, char *buf, int start)
{
    int repaint = 0;
    int color;

    TRACE(("ResetAnsiColorRequest(%s)\n", buf));
    if (*buf != '\0') {
	/* reset specific colors */
	while (!IsEmpty(buf)) {
	    char *next;

	    color = (int) (strtol) (buf, &next, 10);
	    if (!PartS2L(buf, next) || (color < 0))
		break;		/* no number at all */
	    if (next != 0) {
		if (strchr(";", *next) == 0)
		    break;	/* unexpected delimiter */
		++next;
	    }

	    if (ResetOneAnsiColor(xw, color, start)) {
		++repaint;
	    }
	    buf = next;
	}
    } else {
	TRACE(("...resetting all %d colors\n", MAXCOLORS));
	for (color = 0; color < MAXCOLORS; ++color) {
	    if (ResetOneAnsiColor(xw, color, start)) {
		++repaint;
	    }
	}
    }
    TRACE(("...ResetAnsiColorRequest ->%d\n", repaint));
    return repaint;
}
#else
#define allocateClosestRGB(xw, cmap, def) 0
#define allocateExactRGB(xw, cmap, def) XAllocColor(TScreenOf(xw)->display, cmap, def)
#endif /* OPT_ISO_COLORS */

Boolean
allocateBestRGB(XtermWidget xw, XColor *def)
{
    Colormap cmap = xw->core.colormap;

    return allocateExactRGB(xw, cmap, def) || allocateClosestRGB(xw, cmap, def);
}

static Boolean
xtermAllocColor(XtermWidget xw, XColor *def, const char *spec)
{
    Boolean result = False;
    TScreen *screen = TScreenOf(xw);
    Colormap cmap = xw->core.colormap;

    if (XParseColor(screen->display, cmap, spec, def)) {
	XColor save_def = *def;
	if (resource.reportColors) {
	    printf("color  %04x/%04x/%04x = \"%s\"\n",
		   def->red, def->green, def->blue,
		   spec);
	}
	if (allocateBestRGB(xw, def)) {
	    if (resource.reportColors) {
		if (def->red != save_def.red ||
		    def->green != save_def.green ||
		    def->blue != save_def.blue) {
		    printf("color  %04x/%04x/%04x ~ \"%s\"\n",
			   def->red, def->green, def->blue,
			   spec);
		}
	    }
	    TRACE(("xtermAllocColor -> %x/%x/%x\n",
		   def->red, def->green, def->blue));
	    result = True;
	}
    }
    return result;
}

/*
 * This provides an approximation (the closest color from xterm's palette)
 * rather than the "exact" color (whatever the display could provide, actually)
 * because of the context in which it is used.
 */
#define ColorDiff(given,cache) ((long) ((cache) >> 8) - (long) (given))
int
xtermClosestColor(XtermWidget xw, int find_red, int find_green, int find_blue)
{
    int result = -1;
#if OPT_COLOR_RES && OPT_ISO_COLORS
    int n;
    int best_index = -1;
    unsigned long best_value = 0;
    unsigned long this_value;
    long diff_red, diff_green, diff_blue;

    TRACE(("xtermClosestColor(%x/%x/%x)\n", find_red, find_green, find_blue));

    for (n = NUM_ANSI_COLORS - 1; n >= 0; --n) {
	ColorRes *res = &(TScreenOf(xw)->Acolors[n]);

	/* ensure that we have a value for each of the colors */
	if (!res->mode) {
	    (void) AllocateAnsiColor(xw, res, res->resource);
	}

	/* find the closest match */
	if (res->mode == True) {
	    TRACE2(("...lookup %lx -> %x/%x/%x\n",
		    res->value, res->red, res->green, res->blue));
	    diff_red = ColorDiff(find_red, res->red);
	    diff_green = ColorDiff(find_green, res->green);
	    diff_blue = ColorDiff(find_blue, res->blue);
	    this_value = (unsigned long) ((diff_red * diff_red)
					  + (diff_green * diff_green)
					  + (diff_blue * diff_blue));
	    if (best_index < 0 || this_value < best_value) {
		best_index = n;
		best_value = this_value;
	    }
	}
    }
    TRACE(("...best match at %d with diff %lx\n", best_index, best_value));
    result = best_index;
#else
    (void) xw;
    (void) find_red;
    (void) find_green;
    (void) find_blue;
#endif
    return result;
}

#if OPT_PASTE64
static void
ManipulateSelectionData(XtermWidget xw, TScreen *screen, char *buf, int final)
{
#define PDATA(a,b) { a, #b }
    static struct {
	char given;
	String result;
    } table[] = {
	PDATA('s', SELECT),
	    PDATA('p', PRIMARY),
	    PDATA('c', CLIPBOARD),
	    PDATA('0', CUT_BUFFER0),
	    PDATA('1', CUT_BUFFER1),
	    PDATA('2', CUT_BUFFER2),
	    PDATA('3', CUT_BUFFER3),
	    PDATA('4', CUT_BUFFER4),
	    PDATA('5', CUT_BUFFER5),
	    PDATA('6', CUT_BUFFER6),
	    PDATA('7', CUT_BUFFER7),
    };

    const char *base = buf;
    Cardinal j, n = 0;

    TRACE(("Manipulate selection data\n"));

    while (*buf != ';' && *buf != '\0') {
	++buf;
    }

    if (*buf == ';') {
	char *used;

	*buf++ = '\0';

	if (*base == '\0')
	    base = "s0";

	if ((used = x_strdup(base)) != 0) {
	    String *select_args;

	    if ((select_args = TypeCallocN(String, 2 + strlen(base))) != 0) {
		while (*base != '\0') {
		    for (j = 0; j < XtNumber(table); ++j) {
			if (*base == table[j].given) {
			    used[n] = *base;
			    select_args[n++] = table[j].result;
			    TRACE(("atom[%d] %s\n", n, table[j].result));
			    break;
			}
		    }
		    ++base;
		}
		used[n] = 0;

		if (!strcmp(buf, "?")) {
		    if (AllowWindowOps(xw, ewGetSelection)) {
			TRACE(("Getting selection\n"));
			unparseputc1(xw, ANSI_OSC);
			unparseputs(xw, "52");
			unparseputc(xw, ';');

			unparseputs(xw, used);
			unparseputc(xw, ';');

			/* Tell xtermGetSelection data is base64 encoded */
			screen->base64_paste = n;
			screen->base64_final = final;

			screen->selection_time =
			    XtLastTimestampProcessed(TScreenOf(xw)->display);

			/* terminator will be written in this call */
			xtermGetSelection((Widget) xw,
					  screen->selection_time,
					  select_args, n,
					  NULL);
			/*
			 * select_args is used via SelectionReceived, cannot
			 * free it here.
			 */
		    } else {
			free(select_args);
		    }
		} else {
		    if (AllowWindowOps(xw, ewSetSelection)) {
			TRACE(("Setting selection with %s\n", buf));
			screen->selection_time =
			    XtLastTimestampProcessed(TScreenOf(xw)->display);
			ClearSelectionBuffer(screen);
			while (*buf != '\0')
			    AppendToSelectionBuffer(screen, CharOf(*buf++));
			CompleteSelection(xw, select_args, n);
		    }
		    free(select_args);
		}
	    }
	    free(used);
	}
    }
}
#endif /* OPT_PASTE64 */

/***====================================================================***/

#define IsSetUtf8Title(xw) (IsTitleMode(xw, tmSetUtf8) || (xw->screen.utf8_title))

static Bool
xtermIsPrintable(XtermWidget xw, Char **bufp, Char *last)
{
    TScreen *screen = TScreenOf(xw);
    Bool result = False;
    Char *cp = *bufp;
    Char *next = cp;

    (void) screen;
    (void) last;

#if OPT_WIDE_CHARS
    if (xtermEnvUTF8() && IsSetUtf8Title(xw)) {
	PtyData data;

	if (decodeUtf8(screen, fakePtyData(&data, cp, last))) {
	    if (data.utf_data != UCS_REPL
		&& (data.utf_data >= 128 ||
		    ansi_table[data.utf_data] == CASE_PRINT)) {
		next += (data.utf_size - 1);
		result = True;
	    } else {
		result = False;
	    }
	} else {
	    result = False;
	}
    } else
#endif
#if OPT_C1_PRINT
	if (screen->c1_printable
	    && (*cp >= 128 && *cp < 160)) {
	result = True;
    } else
#endif
    if (ansi_table[*cp] == CASE_PRINT) {
	result = True;
    }
    *bufp = next;
    return result;
}

/***====================================================================***/

/*
 * Enum corresponding to the actual OSC codes rather than the internal
 * array indices.  Compare with TermColors.
 */
typedef enum {
    OSC_TEXT_FG = 10
    ,OSC_TEXT_BG
    ,OSC_TEXT_CURSOR
    ,OSC_MOUSE_FG
    ,OSC_MOUSE_BG
#if OPT_TEK4014
    ,OSC_TEK_FG = 15
    ,OSC_TEK_BG
#endif
#if OPT_HIGHLIGHT_COLOR
    ,OSC_HIGHLIGHT_BG = 17
#endif
#if OPT_TEK4014
    ,OSC_TEK_CURSOR = 18
#endif
#if OPT_HIGHLIGHT_COLOR
    ,OSC_HIGHLIGHT_FG = 19
#endif
    ,OSC_NCOLORS
} OscTextColors;

/*
 * Map codes to OSC controls that can reset colors.
 */
#define OSC_RESET 100
#define OSC_Reset(code) (code) + OSC_RESET

static Bool
GetOldColors(XtermWidget xw)
{
    if (xw->work.oldColors == NULL) {
	int i;

	xw->work.oldColors = TypeXtMalloc(ScrnColors);
	if (xw->work.oldColors == NULL) {
	    xtermWarning("allocation failure in GetOldColors\n");
	    return (False);
	}
	xw->work.oldColors->which = 0;
	for (i = 0; i < NCOLORS; i++) {
	    xw->work.oldColors->colors[i] = 0;
	    xw->work.oldColors->names[i] = NULL;
	}
	GetColors(xw, xw->work.oldColors);
    }
    return (True);
}

static int
oppositeColor(int n)
{
    switch (n) {
    case TEXT_FG:
	n = TEXT_BG;
	break;
    case TEXT_BG:
	n = TEXT_FG;
	break;
    case MOUSE_FG:
	n = MOUSE_BG;
	break;
    case MOUSE_BG:
	n = MOUSE_FG;
	break;
#if OPT_TEK4014
    case TEK_FG:
	n = TEK_BG;
	break;
    case TEK_BG:
	n = TEK_FG;
	break;
#endif
#if OPT_HIGHLIGHT_COLOR
    case HIGHLIGHT_FG:
	n = HIGHLIGHT_BG;
	break;
    case HIGHLIGHT_BG:
	n = HIGHLIGHT_FG;
	break;
#endif
    default:
	break;
    }
    return n;
}

static void
ReportColorRequest(XtermWidget xw, int ndx, int final)
{
    if (AllowColorOps(xw, ecGetColor)) {
	XColor color;
	Colormap cmap = xw->core.colormap;
	char buffer[80];

	/*
	 * ChangeColorsRequest() has "always" chosen the opposite color when
	 * reverse-video is set.  Report this as the original color index, but
	 * reporting the opposite color which would be used.
	 */
	int i = (xw->misc.re_verse) ? oppositeColor(ndx) : ndx;

	GetOldColors(xw);
	color.pixel = xw->work.oldColors->colors[ndx];
	XQueryColor(TScreenOf(xw)->display, cmap, &color);
	sprintf(buffer, "%d;rgb:%04x/%04x/%04x", i + 10,
		color.red,
		color.green,
		color.blue);
	TRACE(("ReportColorRequest #%d: 0x%06lx as %s\n",
	       ndx, xw->work.oldColors->colors[ndx], buffer));
	unparseputc1(xw, ANSI_OSC);
	unparseputs(xw, buffer);
	unparseputc1(xw, final);
	unparse_end(xw);
    }
}

static Bool
UpdateOldColors(XtermWidget xw GCC_UNUSED, ScrnColors * pNew)
{
    int i;

    /* if we were going to free old colors, this would be the place to
     * do it.   I've decided not to (for now), because it seems likely
     * that we'd have a small set of colors we use over and over, and that
     * we could save some overhead this way.   The only case in which this
     * (clearly) fails is if someone is trying a boatload of colors, in
     * which case they can restart xterm
     */
    for (i = 0; i < NCOLORS; i++) {
	if (COLOR_DEFINED(pNew, i)) {
	    if (xw->work.oldColors->names[i] != NULL) {
		XtFree(xw->work.oldColors->names[i]);
		xw->work.oldColors->names[i] = NULL;
	    }
	    if (pNew->names[i]) {
		xw->work.oldColors->names[i] = pNew->names[i];
	    }
	    xw->work.oldColors->colors[i] = pNew->colors[i];
	}
    }
    return (True);
}

/*
 * OSC codes are constant, but the indices for the color arrays depend on how
 * xterm is compiled.
 */
static int
OscToColorIndex(OscTextColors mode)
{
    int result = 0;

#define CASE(name) case OSC_##name: result = name; break
    switch (mode) {
	CASE(TEXT_FG);
	CASE(TEXT_BG);
	CASE(TEXT_CURSOR);
	CASE(MOUSE_FG);
	CASE(MOUSE_BG);
#if OPT_TEK4014
	CASE(TEK_FG);
	CASE(TEK_BG);
#endif
#if OPT_HIGHLIGHT_COLOR
	CASE(HIGHLIGHT_BG);
	CASE(HIGHLIGHT_FG);
#endif
#if OPT_TEK4014
	CASE(TEK_CURSOR);
#endif
    case OSC_NCOLORS:
	break;
    }
    return result;
}

static Bool
ChangeColorsRequest(XtermWidget xw,
		    int start,
		    char *names,
		    int final)
{
    Bool result = False;
    ScrnColors newColors;

    TRACE(("ChangeColorsRequest start=%d, names='%s'\n", start, names));

    if (GetOldColors(xw)) {
	int i;

	newColors.which = 0;
	for (i = 0; i < NCOLORS; i++) {
	    newColors.names[i] = NULL;
	}
	for (i = start; i < OSC_NCOLORS; i++) {
	    int ndx = OscToColorIndex((OscTextColors) i);
	    if (xw->misc.re_verse)
		ndx = oppositeColor(ndx);

	    if (IsEmpty(names)) {
		newColors.names[ndx] = NULL;
	    } else {
		char *thisName = ((names[0] == ';') ? NULL : names);

		names = strchr(names, ';');
		if (names != NULL) {
		    *names++ = '\0';
		}
		if (thisName != 0) {
		    if (!strcmp(thisName, "?")) {
			ReportColorRequest(xw, ndx, final);
		    } else if (!xw->work.oldColors->names[ndx]
			       || strcmp(thisName, xw->work.oldColors->names[ndx])) {
			AllocateTermColor(xw, &newColors, ndx, thisName, False);
		    }
		}
	    }
	}

	if (newColors.which != 0) {
	    ChangeColors(xw, &newColors);
	    UpdateOldColors(xw, &newColors);
	}
	result = True;
    }
    return result;
}

static Bool
ResetColorsRequest(XtermWidget xw,
		   int code)
{
    Bool result = False;

    (void) xw;
    (void) code;

    TRACE(("ResetColorsRequest code=%d\n", code));

#if OPT_COLOR_RES
    if (GetOldColors(xw)) {
	ScrnColors newColors;
	const char *thisName;
	int ndx = OscToColorIndex((OscTextColors) (code - OSC_RESET));

	if (xw->misc.re_verse)
	    ndx = oppositeColor(ndx);

	thisName = xw->screen.Tcolors[ndx].resource;

	newColors.which = 0;
	newColors.names[ndx] = NULL;

	if (thisName != 0
	    && xw->work.oldColors->names[ndx] != 0
	    && strcmp(thisName, xw->work.oldColors->names[ndx])) {
	    AllocateTermColor(xw, &newColors, ndx, thisName, False);

	    if (newColors.which != 0) {
		ChangeColors(xw, &newColors);
		UpdateOldColors(xw, &newColors);
	    }
	}
	result = True;
    }
#endif
    return result;
}

#if OPT_SHIFT_FONTS
/*
 * Initially, 'source' points to '#' or '?'.
 *
 * Look for an optional sign and optional number.  If those are found, lookup
 * the corresponding menu font entry.
 */
static int
ParseShiftedFont(XtermWidget xw, String source, String *target)
{
    TScreen *screen = TScreenOf(xw);
    int num = screen->menu_font_number;
    int rel = 0;

    if (*++source == '+') {
	rel = 1;
	source++;
    } else if (*source == '-') {
	rel = -1;
	source++;
    }

    if (isdigit(CharOf(*source))) {
	int val = atoi(source);
	if (rel > 0)
	    rel = val;
	else if (rel < 0)
	    rel = -val;
	else
	    num = val;
    }

    if (rel != 0) {
	num = lookupRelativeFontSize(xw,
				     screen->menu_font_number, rel);

    }
    TRACE(("ParseShiftedFont(%s) ->%d (%s)\n", *target, num, source));
    *target = source;
    return num;
}

static void
QueryFontRequest(XtermWidget xw, String buf, int final)
{
    if (AllowFontOps(xw, efGetFont)) {
	TScreen *screen = TScreenOf(xw);
	Bool success = True;
	int num;
	String base = buf + 1;
	const char *name = 0;

	num = ParseShiftedFont(xw, buf, &buf);
	if (num < 0
	    || num > fontMenu_lastBuiltin) {
	    Bell(xw, XkbBI_MinorError, 0);
	    success = False;
	} else {
#if OPT_RENDERFONT
	    if (UsingRenderFont(xw)) {
		name = getFaceName(xw, False);
	    } else
#endif
	    if ((name = screen->MenuFontName(num)) == 0) {
		success = False;
	    }
	}

	unparseputc1(xw, ANSI_OSC);
	unparseputs(xw, "50");

	if (success) {
	    unparseputc(xw, ';');
	    if (buf >= base) {
		/* identify the font-entry, unless it is the current one */
		if (*buf != '\0') {
		    char temp[10];

		    unparseputc(xw, '#');
		    sprintf(temp, "%d", num);
		    unparseputs(xw, temp);
		    if (*name != '\0')
			unparseputc(xw, ' ');
		}
	    }
	    unparseputs(xw, name);
	}

	unparseputc1(xw, final);
	unparse_end(xw);
    }
}

static void
ChangeFontRequest(XtermWidget xw, String buf)
{
    if (AllowFontOps(xw, efSetFont)) {
	TScreen *screen = TScreenOf(xw);
	Bool success = True;
	int num;
	VTFontNames fonts;
	char *name;

	/*
	 * If the font specification is a "#", followed by an optional sign and
	 * optional number, lookup the corresponding menu font entry.
	 *
	 * Further, if the "#", etc., is followed by a font name, use that
	 * to load the font entry.
	 */
	if (*buf == '#') {
	    num = ParseShiftedFont(xw, buf, &buf);

	    if (num < 0
		|| num > fontMenu_lastBuiltin) {
		Bell(xw, XkbBI_MinorError, 0);
		success = False;
	    } else {
		/*
		 * Skip past the optional number, and any whitespace to look
		 * for a font specification within the control.
		 */
		while (isdigit(CharOf(*buf))) {
		    ++buf;
		}
		while (isspace(CharOf(*buf))) {
		    ++buf;
		}
#if OPT_RENDERFONT
		if (UsingRenderFont(xw)) {
		    /* EMPTY */
		    /* there is only one font entry to load */
		    ;
		} else
#endif
		{
		    /*
		     * Normally there is no font specified in the control.
		     * But if there is, simply overwrite the font entry.
		     */
		    if (*buf == '\0') {
			if ((buf = screen->MenuFontName(num)) == 0) {
			    success = False;
			}
		    }
		}
	    }
	} else {
	    num = screen->menu_font_number;
	}
	name = x_strtrim(buf);
	if (screen->EscapeFontName()) {
	    FREE_STRING(screen->EscapeFontName());
	    screen->EscapeFontName() = 0;
	}
	if (success && !IsEmpty(name)) {
#if OPT_RENDERFONT
	    if (UsingRenderFont(xw)) {
		setFaceName(xw, name);
		xtermUpdateFontInfo(xw, True);
	    } else
#endif
	    {
		memset(&fonts, 0, sizeof(fonts));
		fonts.f_n = name;
		SetVTFont(xw, num, True, &fonts);
		if (num == screen->menu_font_number &&
		    num != fontMenu_fontescape) {
		    screen->EscapeFontName() = x_strdup(name);
		}
	    }
	} else {
	    Bell(xw, XkbBI_MinorError, 0);
	}
	update_font_escape();
	free(name);
    }
}
#endif /* OPT_SHIFT_FONTS */

/***====================================================================***/

void
do_osc(XtermWidget xw, Char *oscbuf, size_t len, int final)
{
    TScreen *screen = TScreenOf(xw);
    int mode;
    Char *cp;
    int state = 0;
    char *buf = 0;
    char temp[2];
#if OPT_ISO_COLORS
    int ansi_colors = 0;
#endif
    Bool need_data = True;
    Bool optional_data = False;

    TRACE(("do_osc %s\n", oscbuf));

    (void) screen;

    /*
     * Lines should be of the form  number ; string , however
     * older xterms can accept  as a final character.  We will respond
     * with the same final character as the application sends to make this
     * work better with shell scripts, which may have trouble reading an
     * , which is the 7-bit equivalent to .
     */
    mode = 0;
    for (cp = oscbuf; *cp != '\0'; cp++) {
	switch (state) {
	case 0:
	    if (isdigit(*cp)) {
		mode = 10 * mode + (*cp - '0');
		if (mode > 65535) {
		    TRACE(("do_osc found unknown mode %d\n", mode));
		    return;
		}
		break;
	    }
	    /* FALLTHRU */
	case 1:
	    if (*cp != ';') {
		TRACE(("do_osc did not find semicolon offset %d\n",
		       (int) (cp - oscbuf)));
		return;
	    }
	    state = 2;
	    break;
	case 2:
	    buf = (char *) cp;
	    state = 3;
	    /* FALLTHRU */
	default:
	    if (!xtermIsPrintable(xw, &cp, oscbuf + len)) {
		switch (mode) {
		case 0:
		case 1:
		case 2:
		    break;
		default:
		    TRACE(("do_osc found nonprinting char %02X offset %d\n",
			   CharOf(*cp),
			   (int) (cp - oscbuf)));
		    return;
		}
	    }
	}
    }

    /*
     * Check if the palette changed and there are no more immediate changes
     * that could be deferred to the next repaint.
     */
    if (xw->work.palette_changed) {
	switch (mode) {
	case 3:		/* change X property */
	case 30:		/* Konsole (unused) */
	case 31:		/* Konsole (unused) */
	case 50:		/* font operations */
	case 51:		/* Emacs (unused) */
#if OPT_PASTE64
	case 52:		/* selection data */
#endif
	    TRACE(("forced repaint after palette changed\n"));
	    xw->work.palette_changed = False;
	    xtermRepaint(xw);
	    break;
	}
    }

    /*
     * Most OSC controls other than resets require data.  Handle the others as
     * a special case.
     */
    switch (mode) {
    case 50:
#if OPT_ISO_COLORS
    case OSC_Reset(4):
    case OSC_Reset(5):
	need_data = False;
	optional_data = True;
	break;
    case OSC_Reset(OSC_TEXT_FG):
    case OSC_Reset(OSC_TEXT_BG):
    case OSC_Reset(OSC_TEXT_CURSOR):
    case OSC_Reset(OSC_MOUSE_FG):
    case OSC_Reset(OSC_MOUSE_BG):
#if OPT_HIGHLIGHT_COLOR
    case OSC_Reset(OSC_HIGHLIGHT_BG):
    case OSC_Reset(OSC_HIGHLIGHT_FG):
#endif
#if OPT_TEK4014
    case OSC_Reset(OSC_TEK_FG):
    case OSC_Reset(OSC_TEK_BG):
    case OSC_Reset(OSC_TEK_CURSOR):
#endif
	need_data = False;
	break;
#endif
    default:
	break;
    }

    /*
     * Check if we have data when we want, and not when we do not want it.
     * Either way, that is a malformed control sequence, and will be ignored.
     */
    if (IsEmpty(buf)) {
	if (need_data) {
	    TRACE(("do_osc found no data\n"));
	    return;
	}
	temp[0] = '\0';
	buf = temp;
    } else if (!need_data && !optional_data) {
	TRACE(("do_osc found unwanted data\n"));
	return;
    }

    switch (mode) {
    case 0:			/* new icon name and title */
	ChangeIconName(xw, buf);
	ChangeTitle(xw, buf);
	break;

    case 1:			/* new icon name only */
	ChangeIconName(xw, buf);
	break;

    case 2:			/* new title only */
	ChangeTitle(xw, buf);
	break;

    case 3:			/* change X property */
	if (AllowWindowOps(xw, ewSetXprop))
	    ChangeXprop(buf);
	break;
#if OPT_ISO_COLORS
    case 5:
	ansi_colors = NUM_ANSI_COLORS;
	/* FALLTHRU */
    case 4:
	if (ChangeAnsiColorRequest(xw, buf, ansi_colors, final))
	    xw->work.palette_changed = True;
	break;
    case 6:
	/* FALLTHRU */
    case OSC_Reset(6):
	TRACE(("parse colorXXMode:%s\n", buf));
	while (*buf != '\0') {
	    long which = 0;
	    long value = 0;
	    char *next;
	    if (*buf == ';') {
		++buf;
	    } else {
		which = strtol(buf, &next, 10);
		if (!PartS2L(buf, next) || (which < 0))
		    break;
		buf = next;
		if (*buf == ';')
		    ++buf;
	    }
	    if (*buf == ';') {
		++buf;
	    } else {
		value = strtol(buf, &next, 10);
		if (!PartS2L(buf, next) || (value < 0))
		    break;
		buf = next;
		if (*buf == ';')
		    ++buf;
	    }
	    TRACE(("updating colorXXMode which=%ld, value=%ld\n", which, value));
	    switch (which) {
	    case 0:
		screen->colorBDMode = (value != 0);
		break;
	    case 1:
		screen->colorULMode = (value != 0);
		break;
	    case 2:
		screen->colorBLMode = (value != 0);
		break;
	    case 3:
		screen->colorRVMode = (value != 0);
		break;
#if OPT_WIDE_ATTRS
	    case 4:
		screen->colorITMode = (value != 0);
		break;
#endif
	    default:
		TRACE(("...unknown colorXXMode\n"));
		break;
	    }
	}
	break;
    case OSC_Reset(5):
	ansi_colors = NUM_ANSI_COLORS;
	/* FALLTHRU */
    case OSC_Reset(4):
	if (ResetAnsiColorRequest(xw, buf, ansi_colors))
	    xw->work.palette_changed = True;
	break;
#endif
    case OSC_TEXT_FG:
    case OSC_TEXT_BG:
    case OSC_TEXT_CURSOR:
    case OSC_MOUSE_FG:
    case OSC_MOUSE_BG:
#if OPT_HIGHLIGHT_COLOR
    case OSC_HIGHLIGHT_BG:
    case OSC_HIGHLIGHT_FG:
#endif
#if OPT_TEK4014
    case OSC_TEK_FG:
    case OSC_TEK_BG:
    case OSC_TEK_CURSOR:
#endif
	if (xw->misc.dynamicColors) {
	    ChangeColorsRequest(xw, mode, buf, final);
	}
	break;
    case OSC_Reset(OSC_TEXT_FG):
    case OSC_Reset(OSC_TEXT_BG):
    case OSC_Reset(OSC_TEXT_CURSOR):
    case OSC_Reset(OSC_MOUSE_FG):
    case OSC_Reset(OSC_MOUSE_BG):
#if OPT_HIGHLIGHT_COLOR
    case OSC_Reset(OSC_HIGHLIGHT_BG):
    case OSC_Reset(OSC_HIGHLIGHT_FG):
#endif
#if OPT_TEK4014
    case OSC_Reset(OSC_TEK_FG):
    case OSC_Reset(OSC_TEK_BG):
    case OSC_Reset(OSC_TEK_CURSOR):
#endif
	if (xw->misc.dynamicColors) {
	    ResetColorsRequest(xw, mode);
	}
	break;

    case 30:
    case 31:
	/* reserved for Konsole (Stephan Binner ) */
	break;

#ifdef ALLOWLOGGING
    case 46:			/* new log file */
#ifdef ALLOWLOGFILECHANGES
	/*
	 * Warning, enabling this feature allows people to overwrite
	 * arbitrary files accessible to the person running xterm.
	 */
	if (strcmp(buf, "?")) {
	    char *bp;
	    if ((bp = x_strdup(buf)) != NULL) {
		if (screen->logfile)
		    free(screen->logfile);
		screen->logfile = bp;
		break;
	    }
	}
#endif
	Bell(xw, XkbBI_Info, 0);
	Bell(xw, XkbBI_Info, 0);
	break;
#endif /* ALLOWLOGGING */

    case 50:
#if OPT_SHIFT_FONTS
	if (*buf == '?') {
	    QueryFontRequest(xw, buf, final);
	} else if (xw->misc.shift_fonts) {
	    ChangeFontRequest(xw, buf);
	}
#endif /* OPT_SHIFT_FONTS */
	break;
    case 51:
	/* reserved for Emacs shell (Rob Mayoff ) */
	break;

#if OPT_PASTE64
    case 52:
	ManipulateSelectionData(xw, screen, buf, final);
	break;
#endif
	/*
	 * One could write code to send back the display and host names,
	 * but that could potentially open a fairly nasty security hole.
	 */
    default:
	TRACE(("do_osc - unrecognized code\n"));
	break;
    }
    unparse_end(xw);
}

/*
 * Parse one nibble of a hex byte from the OSC string.  We have removed the
 * string-terminator (replacing it with a null), so the only other delimiter
 * that is expected is semicolon.  Ignore other characters (Ray Neuman says
 * "real" terminals accept commas in the string definitions).
 */
static int
udk_value(const char **cp)
{
    int result = -1;

    for (;;) {
	int c;

	if ((c = **cp) != '\0')
	    *cp = *cp + 1;
	if (c == ';' || c == '\0')
	    break;
	if ((result = x_hex2int(c)) >= 0)
	    break;
    }

    return result;
}

void
reset_decudk(XtermWidget xw)
{
    int n;
    for (n = 0; n < MAX_UDK; n++) {
	if (xw->work.user_keys[n].str != 0) {
	    free(xw->work.user_keys[n].str);
	    xw->work.user_keys[n].str = 0;
	    xw->work.user_keys[n].len = 0;
	}
    }
}

/*
 * Parse the data for DECUDK (user-defined keys).
 */
static void
parse_decudk(XtermWidget xw, const char *cp)
{
    while (*cp) {
	const char *base = cp;
	char *str = TextAlloc(strlen(cp) + 2);
	unsigned key = 0;
	int len = 0;

	if (str == NULL)
	    break;

	while (isdigit(CharOf(*cp)))
	    key = (key * 10) + (unsigned) (*cp++ - '0');

	if (*cp == '/') {
	    int lo, hi;

	    cp++;
	    while ((hi = udk_value(&cp)) >= 0
		   && (lo = udk_value(&cp)) >= 0) {
		str[len++] = (char) ((hi << 4) | lo);
	    }
	}
	if (len > 0 && key < MAX_UDK) {
	    str[len] = '\0';
	    if (xw->work.user_keys[key].str != 0)
		free(xw->work.user_keys[key].str);
	    xw->work.user_keys[key].str = str;
	    xw->work.user_keys[key].len = len;
	} else {
	    free(str);
	}
	if (*cp == ';')
	    cp++;
	if (cp == base)		/* badly-formed sequence - bail out */
	    break;
    }
}

/*
 * Parse numeric parameters.  Normally we use a state machine to simplify
 * interspersing with control characters, but have the string already.
 */
static void
parse_ansi_params(ANSI *params, const char **string)
{
    const char *cp = *string;
    ParmType nparam = 0;
    int last_empty = 1;

    memset(params, 0, sizeof(*params));
    while (*cp != '\0') {
	Char ch = CharOf(*cp++);

	if (isdigit(ch)) {
	    last_empty = 0;
	    if (nparam < NPARAM) {
		params->a_param[nparam] =
		    (ParmType) ((params->a_param[nparam] * 10)
				+ (ch - '0'));
	    }
	} else if (ch == ';') {
	    last_empty = 1;
	    nparam++;
	} else if (ch < 32) {
	    /* EMPTY */ ;
	} else {
	    /* should be 0x30 to 0x7e */
	    params->a_final = ch;
	    break;
	}
    }

    *string = cp;
    if (!last_empty)
	nparam++;
    if (nparam > NPARAM)
	params->a_nparam = NPARAM;
    else
	params->a_nparam = nparam;
}

#if OPT_TRACE
#define SOFT_WIDE 10
#define SOFT_HIGH 20

static void
parse_decdld(ANSI *params, const char *string)
{
    char DscsName[8];
    int len;
    int Pfn = params->a_param[0];
    int Pcn = params->a_param[1];
    int Pe = params->a_param[2];
    int Pcmw = params->a_param[3];
    int Pw = params->a_param[4];
    int Pt = params->a_param[5];
    int Pcmh = params->a_param[6];
    int Pcss = params->a_param[7];

    int start_char = Pcn + 0x20;
    int char_wide = ((Pcmw == 0)
		     ? (Pcss ? 6 : 10)
		     : (Pcmw > 4
			? Pcmw
			: (Pcmw + 3)));
    int char_high = ((Pcmh == 0)
		     ? ((Pcmw >= 2 && Pcmw <= 4)
			? 10
			: 20)
		     : Pcmh);
    Char ch;
    Char bits[SOFT_HIGH][SOFT_WIDE];
    Bool first = True;
    Bool prior = False;
    int row = 0, col = 0;

    TRACE(("Parsing DECDLD\n"));
    TRACE(("  font number   %d\n", Pfn));
    TRACE(("  starting char %d\n", Pcn));
    TRACE(("  erase control %d\n", Pe));
    TRACE(("  char-width    %d\n", Pcmw));
    TRACE(("  font-width    %d\n", Pw));
    TRACE(("  text/full     %d\n", Pt));
    TRACE(("  char-height   %d\n", Pcmh));
    TRACE(("  charset-size  %d\n", Pcss));

    if (Pfn > 1
	|| Pcn > 95
	|| Pe > 2
	|| Pcmw > 10
	|| Pcmw == 1
	|| Pt > 2
	|| Pcmh > 20
	|| Pcss > 1
	|| char_wide > SOFT_WIDE
	|| char_high > SOFT_HIGH) {
	TRACE(("DECDLD illegal parameter\n"));
	return;
    }

    len = 0;
    while (*string != '\0') {
	ch = CharOf(*string++);
	if (ch >= ANSI_SPA && ch <= 0x2f) {
	    if (len < 2)
		DscsName[len++] = (char) ch;
	} else if (ch >= 0x30 && ch <= 0x7e) {
	    DscsName[len++] = (char) ch;
	    break;
	}
    }
    DscsName[len] = 0;
    TRACE(("  Dscs name     '%s'\n", DscsName));

    TRACE(("  character matrix %dx%d\n", char_high, char_wide));
    while (*string != '\0') {
	if (first) {
	    TRACE(("Char %d:\n", start_char));
	    if (prior) {
		for (row = 0; row < char_high; ++row) {
		    TRACE(("%.*s\n", char_wide, bits[row]));
		}
	    }
	    prior = False;
	    first = False;
	    for (row = 0; row < char_high; ++row) {
		for (col = 0; col < char_wide; ++col) {
		    bits[row][col] = '.';
		}
	    }
	    row = col = 0;
	}
	ch = CharOf(*string++);
	if (ch >= 0x3f && ch <= 0x7e) {
	    int n;

	    ch = CharOf(ch - 0x3f);
	    for (n = 0; n < 6; ++n) {
		bits[row + n][col] = CharOf((ch & (1 << n)) ? '*' : '.');
	    }
	    col += 1;
	    prior = True;
	} else if (ch == '/') {
	    row += 6;
	    col = 0;
	} else if (ch == ';') {
	    first = True;
	    ++start_char;
	}
    }
}
#else
#define parse_decdld(p,q)	/* nothing */
#endif

void
do_dcs(XtermWidget xw, Char *dcsbuf, size_t dcslen)
{
    TScreen *screen = TScreenOf(xw);
    char reply[BUFSIZ];
    const char *cp = (const char *) dcsbuf;
    Bool okay;
    ANSI params;

    TRACE(("do_dcs(%s:%lu)\n", (char *) dcsbuf, (unsigned long) dcslen));

    if (dcslen != strlen(cp))
	/* shouldn't have nulls in the string */
	return;

    switch (*cp) {		/* intermediate character, or parameter */
    case '$':			/* DECRQSS */
	okay = True;

	cp++;
	if (*cp++ == 'q') {
	    if (!strcmp(cp, "\"q")) {	/* DECSCA */
		sprintf(reply, "%d%s",
			(screen->protected_mode == DEC_PROTECT)
			&& (xw->flags & PROTECTED) ? 1 : 0,
			cp);
	    } else if (!strcmp(cp, "\"p")) {	/* DECSCL */
		if (screen->vtXX_level < 2) {
		    /* actually none of DECRQSS is valid for vt100's */
		    break;
		}
		sprintf(reply, "%d%s%s",
			(screen->vtXX_level ?
			 screen->vtXX_level : 1) + 60,
			(screen->vtXX_level >= 2)
			? (screen->control_eight_bits
			   ? ";0" : ";1")
			: "",
			cp);
	    } else if (!strcmp(cp, "r")) {	/* DECSTBM */
		sprintf(reply, "%d;%dr",
			screen->top_marg + 1,
			screen->bot_marg + 1);
	    } else if (!strcmp(cp, "s")) {	/* DECSLRM */
		if (screen->vtXX_level >= 4) {	/* VT420 */
		    sprintf(reply, "%d;%ds",
			    screen->lft_marg + 1,
			    screen->rgt_marg + 1);
		} else {
		    okay = False;
		}
	    } else if (!strcmp(cp, "m")) {	/* SGR */
		strcpy(reply, "0");
		if (xw->flags & BOLD)
		    strcat(reply, ";1");
		if (xw->flags & UNDERLINE)
		    strcat(reply, ";4");
		if (xw->flags & BLINK)
		    strcat(reply, ";5");
		if (xw->flags & INVERSE)
		    strcat(reply, ";7");
		if (xw->flags & INVISIBLE)
		    strcat(reply, ";8");
#if OPT_256_COLORS || OPT_88_COLORS
		if_OPT_ISO_COLORS(screen, {
		    if (xw->flags & FG_COLOR) {
			if (xw->cur_foreground >= 16)
			    sprintf(reply + strlen(reply),
				    ";38;5;%d", xw->cur_foreground);
			else
			    sprintf(reply + strlen(reply),
				    ";%d%d",
				    xw->cur_foreground >= 8 ? 9 : 3,
				    xw->cur_foreground >= 8 ?
				    xw->cur_foreground - 8 :
				    xw->cur_foreground);
		    }
		    if (xw->flags & BG_COLOR) {
			if (xw->cur_background >= 16)
			    sprintf(reply + strlen(reply),
				    ";48;5;%d", xw->cur_foreground);
			else
			    sprintf(reply + strlen(reply),
				    ";%d%d",
				    xw->cur_background >= 8 ? 10 : 4,
				    xw->cur_background >= 8 ?
				    xw->cur_background - 8 :
				    xw->cur_background);
		    }
		});
#elif OPT_ISO_COLORS
		if_OPT_ISO_COLORS(screen, {
		    if (xw->flags & FG_COLOR)
			sprintf(reply + strlen(reply),
				";%d%d",
				xw->cur_foreground >= 8 ? 9 : 3,
				xw->cur_foreground >= 8 ?
				xw->cur_foreground - 8 :
				xw->cur_foreground);
		    if (xw->flags & BG_COLOR)
			sprintf(reply + strlen(reply),
				";%d%d",
				xw->cur_background >= 8 ? 10 : 4,
				xw->cur_background >= 8 ?
				xw->cur_background - 8 :
				xw->cur_background);
		});
#endif
		strcat(reply, "m");
	    } else if (!strcmp(cp, " q")) {	/* DECSCUSR */
		int code = STEADY_BLOCK;
		if (isCursorUnderline(screen))
		    code = STEADY_UNDERLINE;
		else if (isCursorBar(screen))
		    code = STEADY_BAR;
#if OPT_BLINK_CURS
		if (screen->cursor_blink_esc != 0)
		    code -= 1;
#endif
		sprintf(reply, "%d%s", code, cp);
	    } else
		okay = False;

	    if (okay) {
		unparseputc1(xw, ANSI_DCS);
		unparseputc(xw, '1');
		unparseputc(xw, '$');
		unparseputc(xw, 'r');
		cp = reply;
		unparseputs(xw, cp);
		unparseputc1(xw, ANSI_ST);
	    } else {
		unparseputc(xw, ANSI_CAN);
	    }
	} else {
	    unparseputc(xw, ANSI_CAN);
	}
	break;
#if OPT_TCAP_QUERY
    case '+':
	cp++;
	switch (*cp) {
	case 'p':
	    if (AllowTcapOps(xw, etSetTcap)) {
		set_termcap(xw, cp + 1);
	    }
	    break;
	case 'q':
	    if (AllowTcapOps(xw, etGetTcap)) {
		Bool fkey;
		unsigned state;
		int code;
		const char *tmp;
		const char *parsed = ++cp;

		code = xtermcapKeycode(xw, &parsed, &state, &fkey);

		unparseputc1(xw, ANSI_DCS);

		unparseputc(xw, code >= 0 ? '1' : '0');

		unparseputc(xw, '+');
		unparseputc(xw, 'r');

		while (*cp != 0 && (code >= -1)) {
		    if (cp == parsed)
			break;	/* no data found, error */

		    for (tmp = cp; tmp != parsed; ++tmp)
			unparseputc(xw, *tmp);

		    if (code >= 0) {
			unparseputc(xw, '=');
			screen->tc_query_code = code;
			screen->tc_query_fkey = fkey;
#if OPT_ISO_COLORS
			/* XK_COLORS is a fake code for the "Co" entry (maximum
			 * number of colors) */
			if (code == XK_COLORS) {
			    unparseputn(xw, NUM_ANSI_COLORS);
			} else
#endif
			if (code == XK_TCAPNAME) {
			    unparseputs(xw, resource.term_name);
			} else {
			    XKeyEvent event;
			    event.state = state;
			    Input(xw, &event, False);
			}
			screen->tc_query_code = -1;
		    } else {
			break;	/* no match found, error */
		    }

		    cp = parsed;
		    if (*parsed == ';') {
			unparseputc(xw, *parsed++);
			cp = parsed;
			code = xtermcapKeycode(xw, &parsed, &state, &fkey);
		    }
		}
		unparseputc1(xw, ANSI_ST);
	    }
	    break;
	}
	break;
#endif
    default:
	if (screen->terminal_id == 125 ||
	    screen->vtXX_level >= 2) {	/* VT220 */
	    parse_ansi_params(¶ms, &cp);
	    switch (params.a_final) {
	    case 'p':
#if OPT_REGIS_GRAPHICS
		if (screen->terminal_id == 125 ||
		    screen->terminal_id == 240 ||
		    screen->terminal_id == 241 ||
		    screen->terminal_id == 330 ||
		    screen->terminal_id == 340) {
		    parse_regis(xw, ¶ms, cp);
		}
#else
		TRACE(("ignoring ReGIS graphic (compilation flag not enabled)\n"));
#endif
		break;
	    case 'q':
#if OPT_SIXEL_GRAPHICS
		if (screen->terminal_id == 125 ||
		    screen->terminal_id == 240 ||
		    screen->terminal_id == 241 ||
		    screen->terminal_id == 330 ||
		    screen->terminal_id == 340 ||
		    screen->terminal_id == 382) {
		    (void) parse_sixel(xw, ¶ms, cp);
		}
#else
		TRACE(("ignoring sixel graphic (compilation flag not enabled)\n"));
#endif
		break;
	    case '|':		/* DECUDK */
		if (screen->vtXX_level >= 2) {	/* VT220 */
		    if (params.a_param[0] == 0)
			reset_decudk(xw);
		    parse_decudk(xw, cp);
		}
		break;
	    case L_CURL:	/* DECDLD */
		if (screen->vtXX_level >= 2) {	/* VT220 */
		    parse_decdld(¶ms, cp);
		}
		break;
	    }
	}
	break;
    }
    unparse_end(xw);
}

#if OPT_DEC_RECTOPS
enum {
    mdUnknown = 0,
    mdMaybeSet = 1,
    mdMaybeReset = 2,
    mdAlwaysSet = 3,
    mdAlwaysReset = 4
};

#define MdBool(bool)      ((bool) ? mdMaybeSet : mdMaybeReset)
#define MdFlag(mode,flag) MdBool((mode) & (flag))

/*
 * Reply is the same format as the query, with pair of mode/value:
 * 0 - not recognized
 * 1 - set
 * 2 - reset
 * 3 - permanently set
 * 4 - permanently reset
 * Only one mode can be reported at a time.
 */
void
do_rpm(XtermWidget xw, int nparams, int *params)
{
    ANSI reply;
    int count = 0;

    TRACE(("do_rpm %d:%d\n", nparams, params[0]));
    memset(&reply, 0, sizeof(reply));

    if (nparams >= 1) {
	int result = 0;

	switch (params[0]) {
	case 1:		/* GATM */
	    result = mdAlwaysReset;
	    break;
	case 2:
	    result = MdFlag(xw->keyboard.flags, MODE_KAM);
	    break;
	case 3:		/* CRM */
	    result = mdMaybeReset;
	    break;
	case 4:
	    result = MdFlag(xw->flags, INSERT);
	    break;
	case 5:		/* SRTM */
	case 7:		/* VEM */
	case 10:		/* HEM */
	case 11:		/* PUM */
	    result = mdAlwaysReset;
	    break;
	case 12:
	    result = MdFlag(xw->keyboard.flags, MODE_SRM);
	    break;
	case 13:		/* FEAM */
	case 14:		/* FETM */
	case 15:		/* MATM */
	case 16:		/* TTM */
	case 17:		/* SATM */
	case 18:		/* TSM */
	case 19:		/* EBM */
	    result = mdAlwaysReset;
	    break;
	case 20:
	    result = MdFlag(xw->flags, LINEFEED);
	    break;
	}
	reply.a_param[count++] = (ParmType) params[0];
	reply.a_param[count++] = (ParmType) result;
    }
    reply.a_type = ANSI_CSI;
    reply.a_nparam = (ParmType) count;
    reply.a_inters = '$';
    reply.a_final = 'y';
    unparseseq(xw, &reply);
}

void
do_decrpm(XtermWidget xw, int nparams, int *params)
{
    ANSI reply;
    int count = 0;

    TRACE(("do_decrpm %d:%d\n", nparams, params[0]));
    memset(&reply, 0, sizeof(reply));

    if (nparams >= 1) {
	TScreen *screen = TScreenOf(xw);
	int result = 0;

	switch (params[0]) {
	case srm_DECCKM:
	    result = MdFlag(xw->keyboard.flags, MODE_DECCKM);
	    break;
	case srm_DECANM:	/* ANSI/VT52 mode      */
#if OPT_VT52_MODE
	    result = MdBool(screen->vtXX_level >= 1);
#else
	    result = mdMaybeSet;
#endif
	    break;
	case srm_DECCOLM:
	    result = MdFlag(xw->flags, IN132COLUMNS);
	    break;
	case srm_DECSCLM:	/* (slow scroll)        */
	    result = MdFlag(xw->flags, SMOOTHSCROLL);
	    break;
	case srm_DECSCNM:
	    result = MdFlag(xw->flags, REVERSE_VIDEO);
	    break;
	case srm_DECOM:
	    result = MdFlag(xw->flags, ORIGIN);
	    break;
	case srm_DECAWM:
	    result = MdFlag(xw->flags, WRAPAROUND);
	    break;
	case srm_DECARM:
	    result = mdAlwaysReset;
	    break;
	case srm_X10_MOUSE:	/* X10 mouse                    */
	    result = MdBool(screen->send_mouse_pos == X10_MOUSE);
	    break;
#if OPT_TOOLBAR
	case srm_RXVT_TOOLBAR:
	    result = MdBool(resource.toolBar);
	    break;
#endif
#if OPT_BLINK_CURS
	case srm_ATT610_BLINK:	/* att610: Start/stop blinking cursor */
	    result = MdBool(screen->cursor_blink_res);
	    break;
#endif
	case srm_DECPFF:	/* print form feed */
	    result = MdBool(PrinterOf(screen).printer_formfeed);
	    break;
	case srm_DECPEX:	/* print extent */
	    result = MdBool(PrinterOf(screen).printer_extent);
	    break;
	case srm_DECTCEM:	/* Show/hide cursor (VT200) */
	    result = MdBool(screen->cursor_set);
	    break;
	case srm_RXVT_SCROLLBAR:
	    result = MdBool(screen->fullVwin.sb_info.width != OFF);
	    break;
#if OPT_SHIFT_FONTS
	case srm_RXVT_FONTSIZE:
	    result = MdBool(xw->misc.shift_fonts);
	    break;
#endif
#if OPT_TEK4014
	case srm_DECTEK:
	    result = MdBool(TEK4014_ACTIVE(xw));
	    break;
#endif
	case srm_132COLS:
	    result = MdBool(screen->c132);
	    break;
	case srm_CURSES_HACK:
	    result = MdBool(screen->curses);
	    break;
	case srm_DECNRCM:	/* national charset (VT220) */
	    result = MdFlag(xw->flags, NATIONAL);
	    break;
	case srm_MARGIN_BELL:	/* margin bell                  */
	    result = MdBool(screen->marginbell);
	    break;
	case srm_REVERSEWRAP:	/* reverse wraparound   */
	    result = MdFlag(xw->flags, REVERSEWRAP);
	    break;
#ifdef ALLOWLOGGING
	case srm_ALLOWLOGGING:	/* logging              */
#ifdef ALLOWLOGFILEONOFF
	    result = MdBool(screen->logging);
#endif /* ALLOWLOGFILEONOFF */
	    break;
#endif
	case srm_OPT_ALTBUF_CURSOR:	/* alternate buffer & cursor */
	    /* FALLTHRU */
	case srm_OPT_ALTBUF:
	    /* FALLTHRU */
	case srm_ALTBUF:
	    result = MdBool(screen->whichBuf);
	    break;
	case srm_DECNKM:
	    result = MdFlag(xw->keyboard.flags, MODE_DECKPAM);
	    break;
	case srm_DECBKM:
	    result = MdFlag(xw->keyboard.flags, MODE_DECBKM);
	    break;
	case srm_DECLRMM:
	    result = MdFlag(xw->flags, LEFT_RIGHT);
	    break;
#if OPT_SIXEL_GRAPHICS
	case srm_DECSDM:
	    result = MdFlag(xw->keyboard.flags, MODE_DECSDM);
	    break;
#endif
	case srm_DECNCSM:
	    result = MdFlag(xw->flags, NOCLEAR_COLM);
	    break;
	case srm_VT200_MOUSE:	/* xterm bogus sequence         */
	    result = MdBool(screen->send_mouse_pos == VT200_MOUSE);
	    break;
	case srm_VT200_HIGHLIGHT_MOUSE:	/* xterm sequence w/hilite tracking */
	    result = MdBool(screen->send_mouse_pos == VT200_HIGHLIGHT_MOUSE);
	    break;
	case srm_BTN_EVENT_MOUSE:
	    result = MdBool(screen->send_mouse_pos == BTN_EVENT_MOUSE);
	    break;
	case srm_ANY_EVENT_MOUSE:
	    result = MdBool(screen->send_mouse_pos == ANY_EVENT_MOUSE);
	    break;
#if OPT_FOCUS_EVENT
	case srm_FOCUS_EVENT_MOUSE:
	    result = MdBool(screen->send_focus_pos);
	    break;
#endif
	case srm_EXT_MODE_MOUSE:
	    /* FALLTHRU */
	case srm_SGR_EXT_MODE_MOUSE:
	    /* FALLTHRU */
	case srm_URXVT_EXT_MODE_MOUSE:
	    result = MdBool(screen->extend_coords == params[0]);
	    break;
	case srm_ALTERNATE_SCROLL:
	    result = MdBool(screen->alternateScroll);
	    break;
	case srm_RXVT_SCROLL_TTY_OUTPUT:
	    result = MdBool(screen->scrollttyoutput);
	    break;
	case srm_RXVT_SCROLL_TTY_KEYPRESS:
	    result = MdBool(screen->scrollkey);
	    break;
	case srm_EIGHT_BIT_META:
	    result = MdBool(screen->eight_bit_meta);
	    break;
#if OPT_NUM_LOCK
	case srm_REAL_NUMLOCK:
	    result = MdBool(xw->misc.real_NumLock);
	    break;
	case srm_META_SENDS_ESC:
	    result = MdBool(screen->meta_sends_esc);
	    break;
#endif
	case srm_DELETE_IS_DEL:
	    result = MdBool(screen->delete_is_del);
	    break;
#if OPT_NUM_LOCK
	case srm_ALT_SENDS_ESC:
	    result = MdBool(screen->alt_sends_esc);
	    break;
#endif
	case srm_KEEP_SELECTION:
	    result = MdBool(screen->keepSelection);
	    break;
	case srm_SELECT_TO_CLIPBOARD:
	    result = MdBool(screen->selectToClipboard);
	    break;
	case srm_BELL_IS_URGENT:
	    result = MdBool(screen->bellIsUrgent);
	    break;
	case srm_POP_ON_BELL:
	    result = MdBool(screen->poponbell);
	    break;
	case srm_TITE_INHIBIT:
	    result = MdBool(screen->sc[screen->whichBuf].saved);
	    break;
#if OPT_TCAP_FKEYS
	case srm_TCAP_FKEYS:
	    result = MdBool(xw->keyboard.type == keyboardIsTermcap);
	    break;
#endif
#if OPT_SUN_FUNC_KEYS
	case srm_SUN_FKEYS:
	    result = MdBool(xw->keyboard.type == keyboardIsSun);
	    break;
#endif
#if OPT_HP_FUNC_KEYS
	case srm_HP_FKEYS:
	    result = MdBool(xw->keyboard.type == keyboardIsHP);
	    break;
#endif
#if OPT_SCO_FUNC_KEYS
	case srm_SCO_FKEYS:
	    result = MdBool(xw->keyboard.type == keyboardIsSCO);
	    break;
#endif
	case srm_LEGACY_FKEYS:
	    result = MdBool(xw->keyboard.type == keyboardIsLegacy);
	    break;
#if OPT_SUNPC_KBD
	case srm_VT220_FKEYS:
	    result = MdBool(xw->keyboard.type == keyboardIsVT220);
	    break;
#endif
#if OPT_READLINE
	case srm_BUTTON1_MOVE_POINT:
	    result = MdBool(screen->click1_moves);
	    break;
	case srm_BUTTON2_MOVE_POINT:
	    result = MdBool(screen->paste_moves);
	    break;
	case srm_DBUTTON3_DELETE:
	    result = MdBool(screen->dclick3_deletes);
	    break;
	case srm_PASTE_IN_BRACKET:
	    result = MdBool(screen->paste_brackets);
	    break;
	case srm_PASTE_QUOTE:
	    result = MdBool(screen->paste_quotes);
	    break;
	case srm_PASTE_LITERAL_NL:
	    result = MdBool(screen->paste_literal_nl);
	    break;
#endif /* OPT_READLINE */
#if OPT_SIXEL_GRAPHICS
	case srm_PRIVATE_COLOR_REGISTERS:
	    result = MdBool(screen->privatecolorregisters);
	    break;
#endif
#if OPT_SIXEL_GRAPHICS
	case srm_SIXEL_SCROLLS_RIGHT:
	    result = MdBool(screen->sixel_scrolls_right);
	    break;
#endif
	default:
	    TRACE(("DATA_ERROR: requested report for unknown private mode %d\n",
		   params[0]));
	}
	reply.a_param[count++] = (ParmType) params[0];
	reply.a_param[count++] = (ParmType) result;
    }
    reply.a_type = ANSI_CSI;
    reply.a_pintro = '?';
    reply.a_nparam = (ParmType) count;
    reply.a_inters = '$';
    reply.a_final = 'y';
    unparseseq(xw, &reply);
}
#endif /* OPT_DEC_RECTOPS */

char *
udk_lookup(XtermWidget xw, int keycode, int *len)
{
    if (keycode >= 0 && keycode < MAX_UDK) {
	*len = xw->work.user_keys[keycode].len;
	return xw->work.user_keys[keycode].str;
    }
    return 0;
}

#ifdef HAVE_LIBXPM

#ifndef PIXMAP_ROOTDIR
#define PIXMAP_ROOTDIR "/usr/share/pixmaps/"
#endif

typedef struct {
    const char *name;
    const char *const *data;
} XPM_DATA;

static char *
x_find_icon(char **work, int *state, const char *suffix)
{
    const char *filename = resource.icon_hint;
    const char *prefix = PIXMAP_ROOTDIR;
    const char *larger = "_48x48";
    char *result = 0;

    if (*state >= 0) {
	if ((*state & 1) == 0)
	    suffix = "";
	if ((*state & 2) == 0)
	    larger = "";
	if ((*state & 4) == 0) {
	    prefix = "";
	} else if (!strncmp(filename, "/", (size_t) 1) ||
		   !strncmp(filename, "./", (size_t) 2) ||
		   !strncmp(filename, "../", (size_t) 3)) {
	    *state = -1;
	} else if (*state >= 8) {
	    *state = -1;
	}
    }

    if (*state >= 0) {
	size_t length;

	if (*work) {
	    free(*work);
	    *work = 0;
	}
	length = 3 + strlen(prefix) + strlen(filename) + strlen(larger) +
	    strlen(suffix);
	if ((result = malloc(length)) != 0) {
	    sprintf(result, "%s%s%s%s", prefix, filename, larger, suffix);
	    *work = result;
	}
	*state += 1;
	TRACE(("x_find_icon %d:%s\n", *state, result));
    }
    return result;
}

#if OPT_BUILTIN_XPMS
static const XPM_DATA *
BuiltInXPM(const XPM_DATA * table, Cardinal length)
{
    const char *find = resource.icon_hint;
    const XPM_DATA *result = 0;
    if (!IsEmpty(find)) {
	Cardinal n;
	for (n = 0; n < length; ++n) {
	    if (!x_strcasecmp(find, table[n].name)) {
		result = table + n;
		break;
	    }
	}

	/*
	 * As a fallback, check if the icon name matches without the lengths,
	 * which are all _HHxWW format.
	 */
	if (result == 0) {
	    const char *base = table[0].name;
	    const char *last = strchr(base, '_');
	    if (last != 0
		&& !x_strncasecmp(find, base, (unsigned) (last - base))) {
		result = table + length - 1;
	    }
	}
    }
    return result;
}
#endif /* OPT_BUILTIN_XPMS */

typedef enum {
    eHintDefault = 0		/* use the largest builtin-icon */
    ,eHintNone
    ,eHintSearch
} ICON_HINT;

static ICON_HINT
which_icon_hint(void)
{
    ICON_HINT result = eHintDefault;
    if (!IsEmpty(resource.icon_hint)) {
	if (!x_strcasecmp(resource.icon_hint, "none")) {
	    result = eHintNone;
	} else {
	    result = eHintSearch;
	}
    }
    return result;
}
#endif /* HAVE_LIBXPM */

int
getVisualDepth(XtermWidget xw)
{
    int result = 0;

    if (getVisualInfo(xw)) {
	result = xw->visInfo->depth;
    }
    return result;
}

/*
 * WM_ICON_SIZE should be honored if possible.
 */
void
xtermLoadIcon(XtermWidget xw)
{
#ifdef HAVE_LIBXPM
    Display *dpy = XtDisplay(xw);
    Pixmap myIcon = 0;
    Pixmap myMask = 0;
    char *workname = 0;
    ICON_HINT hint = which_icon_hint();
#include 

    TRACE(("xtermLoadIcon %p:%s\n", (void *) xw, NonNull(resource.icon_hint)));

    if (hint == eHintSearch) {
	int state = 0;
	while (x_find_icon(&workname, &state, ".xpm") != 0) {
	    Pixmap resIcon = 0;
	    Pixmap shapemask = 0;
	    XpmAttributes attributes;

	    attributes.depth = (unsigned) getVisualDepth(xw);
	    attributes.valuemask = XpmDepth;

	    if (XpmReadFileToPixmap(dpy,
				    DefaultRootWindow(dpy),
				    workname,
				    &resIcon,
				    &shapemask,
				    &attributes) == XpmSuccess) {
		myIcon = resIcon;
		myMask = shapemask;
		TRACE(("...success\n"));
		break;
	    }
	}
    }

    /*
     * If no external file was found, look for the name in the built-in table.
     * If that fails, just use the biggest mini-icon.
     */
    if (myIcon == 0 && hint != eHintNone) {
	char **data;
#if OPT_BUILTIN_XPMS
	const XPM_DATA *myData = 0;
	myData = BuiltInXPM(mini_xterm_xpms, XtNumber(mini_xterm_xpms));
	if (myData == 0)
	    myData = BuiltInXPM(filled_xterm_xpms, XtNumber(filled_xterm_xpms));
	if (myData == 0)
	    myData = BuiltInXPM(xterm_color_xpms, XtNumber(xterm_color_xpms));
	if (myData == 0)
	    myData = BuiltInXPM(xterm_xpms, XtNumber(xterm_xpms));
	if (myData == 0)
	    myData = &mini_xterm_xpms[XtNumber(mini_xterm_xpms) - 1];
	data = (char **) myData->data;
#else
	data = (char **) &mini_xterm_48x48_xpm;
#endif
	if (XpmCreatePixmapFromData(dpy,
				    DefaultRootWindow(dpy),
				    data,
				    &myIcon, &myMask, 0) != 0) {
	    myIcon = 0;
	    myMask = 0;
	}
    }

    if (myIcon != 0) {
	XWMHints *hints = XGetWMHints(dpy, VShellWindow(xw));
	if (!hints)
	    hints = XAllocWMHints();

	if (hints) {
	    hints->flags |= IconPixmapHint;
	    hints->icon_pixmap = myIcon;
	    if (myMask) {
		hints->flags |= IconMaskHint;
		hints->icon_mask = myMask;
	    }

	    XSetWMHints(dpy, VShellWindow(xw), hints);
	    XFree(hints);
	    TRACE(("...loaded icon\n"));
	}
    }

    if (workname != 0)
	free(workname);

#else
    (void) xw;
#endif
}

void
ChangeGroup(XtermWidget xw, const char *attribute, char *value)
{
#if OPT_WIDE_CHARS
    static Char *converted;	/* NO_LEAKS */
#endif

    Arg args[1];
    Boolean changed = True;
    Widget w = CURRENT_EMU();
    Widget top = SHELL_OF(w);

    char *my_attr;
    char *name;
    size_t limit;
    Char *c1;
    Char *cp;

    if (!AllowTitleOps(xw))
	return;

    if (value == 0)
	value = emptyString;
    if (IsTitleMode(xw, tmSetBase16)) {
	const char *temp;
	char *test;

	value = x_decode_hex(value, &temp);
	if (*temp != '\0') {
	    free(value);
	    return;
	}
	for (test = value; *test != '\0'; ++test) {
	    if (CharOf(*test) < 32) {
		*test = '\0';
		break;
	    }
	}
    }

    c1 = (Char *) value;
    name = value;
    limit = strlen(name);
    my_attr = x_strdup(attribute);

    TRACE(("ChangeGroup(attribute=%s, value=%s)\n", my_attr, name));

    /*
     * Ignore titles that are too long to be plausible requests.
     */
    if (limit > 0 && limit < 1024) {

	/*
	 * After all decoding, overwrite nonprintable characters with '?'.
	 */
	for (cp = c1; *cp != 0; ++cp) {
	    Char *c2 = cp;
	    if (!xtermIsPrintable(xw, &cp, c1 + limit)) {
		memset(c2, '?', (size_t) (cp + 1 - c2));
	    }
	}

#if OPT_WIDE_CHARS
	/*
	 * If we're running in UTF-8 mode, and have not been told that the
	 * title string is in UTF-8, it is likely that non-ASCII text in the
	 * string will be rejected because it is not printable in the current
	 * locale.  So we convert it to UTF-8, allowing the X library to
	 * convert it back.
	 */
	if (xtermEnvUTF8() && !IsSetUtf8Title(xw)) {
	    int n;

	    for (n = 0; name[n] != '\0'; ++n) {
		if (CharOf(name[n]) > 127) {
		    if (converted != 0)
			free(converted);
		    if ((converted = TypeMallocN(Char, 1 + (6 * limit))) != 0) {
			Char *temp = converted;
			while (*name != 0) {
			    temp = convertToUTF8(temp, CharOf(*name));
			    ++name;
			}
			*temp = 0;
			name = (char *) converted;
			TRACE(("...converted{%s}\n", name));
		    }
		    break;
		}
	    }
	}
#endif

#if OPT_SAME_NAME
	/* If the attribute isn't going to change, then don't bother... */

	if (resource.sameName) {
	    char *buf = 0;
	    XtSetArg(args[0], my_attr, &buf);
	    XtGetValues(top, args, 1);
	    TRACE(("...comparing{%s}\n", buf));
	    if (buf != 0 && strcmp(name, buf) == 0)
		changed = False;
	}
#endif /* OPT_SAME_NAME */

	if (changed) {
	    TRACE(("...updating %s\n", my_attr));
	    TRACE(("...value is %s\n", name));
	    XtSetArg(args[0], my_attr, name);
	    XtSetValues(top, args, 1);

#if OPT_WIDE_CHARS
	    if (xtermEnvUTF8()) {
		Display *dpy = XtDisplay(xw);
		Atom my_atom;

		const char *propname = (!strcmp(my_attr, XtNtitle)
					? "_NET_WM_NAME"
					: "_NET_WM_ICON_NAME");
		if ((my_atom = XInternAtom(dpy, propname, False)) != None) {
		    if (IsSetUtf8Title(xw)) {
			TRACE(("...updating %s\n", propname));
			TRACE(("...value is %s\n", value));
			XChangeProperty(dpy, VShellWindow(xw), my_atom,
					XA_UTF8_STRING(dpy), 8,
					PropModeReplace,
					(Char *) value,
					(int) strlen(value));
		    } else {
			TRACE(("...deleting %s\n", propname));
			XDeleteProperty(dpy, VShellWindow(xw), my_atom);
		    }
		}
	    }
#endif
	}
    }
    if (IsTitleMode(xw, tmSetBase16) && (value != emptyString)) {
	free(value);
    }
    free(my_attr);

    return;
}

void
ChangeIconName(XtermWidget xw, char *name)
{
    if (name == 0) {
	name = emptyString;
    }
    if (!showZIconBeep(xw, name))
	ChangeGroup(xw, XtNiconName, name);
}

void
ChangeTitle(XtermWidget xw, char *name)
{
    ChangeGroup(xw, XtNtitle, name);
}

#define Strlen(s) strlen((const char *)(s))

void
ChangeXprop(char *buf)
{
    Display *dpy = XtDisplay(toplevel);
    Window w = XtWindow(toplevel);
    XTextProperty text_prop;
    Atom aprop;
    Char *pchEndPropName = (Char *) strchr(buf, '=');

    if (pchEndPropName)
	*pchEndPropName = '\0';
    aprop = XInternAtom(dpy, buf, False);
    if (pchEndPropName == NULL) {
	/* no "=value" given, so delete the property */
	XDeleteProperty(dpy, w, aprop);
    } else {
	text_prop.value = pchEndPropName + 1;
	text_prop.encoding = XA_STRING;
	text_prop.format = 8;
	text_prop.nitems = Strlen(text_prop.value);
	XSetTextProperty(dpy, w, &text_prop, aprop);
    }
}

/***====================================================================***/

/*
 * This is part of ReverseVideo().  It reverses the data stored for the old
 * "dynamic" colors that might have been retrieved using OSC 10-18.
 */
void
ReverseOldColors(XtermWidget xw)
{
    ScrnColors *pOld = xw->work.oldColors;
    Pixel tmpPix;
    char *tmpName;

    if (pOld) {
	/* change text cursor, if necesary */
	if (pOld->colors[TEXT_CURSOR] == pOld->colors[TEXT_FG]) {
	    pOld->colors[TEXT_CURSOR] = pOld->colors[TEXT_BG];
	    if (pOld->names[TEXT_CURSOR]) {
		XtFree(xw->work.oldColors->names[TEXT_CURSOR]);
		pOld->names[TEXT_CURSOR] = NULL;
	    }
	    if (pOld->names[TEXT_BG]) {
		if ((tmpName = x_strdup(pOld->names[TEXT_BG])) != 0) {
		    pOld->names[TEXT_CURSOR] = tmpName;
		}
	    }
	}

	EXCHANGE(pOld->colors[TEXT_FG], pOld->colors[TEXT_BG], tmpPix);
	EXCHANGE(pOld->names[TEXT_FG], pOld->names[TEXT_BG], tmpName);

	EXCHANGE(pOld->colors[MOUSE_FG], pOld->colors[MOUSE_BG], tmpPix);
	EXCHANGE(pOld->names[MOUSE_FG], pOld->names[MOUSE_BG], tmpName);

#if OPT_TEK4014
	EXCHANGE(pOld->colors[TEK_FG], pOld->colors[TEK_BG], tmpPix);
	EXCHANGE(pOld->names[TEK_FG], pOld->names[TEK_BG], tmpName);
#endif
    }
    return;
}

Bool
AllocateTermColor(XtermWidget xw,
		  ScrnColors * pNew,
		  int ndx,
		  const char *name,
		  Bool always)
{
    Bool result = False;

    if (always || AllowColorOps(xw, ecSetColor)) {
	XColor def;
	char *newName;

	result = True;
	if (!x_strcasecmp(name, XtDefaultForeground)) {
	    def.pixel = xw->old_foreground;
	} else if (!x_strcasecmp(name, XtDefaultBackground)) {
	    def.pixel = xw->old_background;
	} else if (!xtermAllocColor(xw, &def, name)) {
	    result = False;
	}

	if (result
	    && (newName = x_strdup(name)) != 0) {
	    if (COLOR_DEFINED(pNew, ndx)) {
		free(pNew->names[ndx]);
	    }
	    SET_COLOR_VALUE(pNew, ndx, def.pixel);
	    SET_COLOR_NAME(pNew, ndx, newName);
	    TRACE(("AllocateTermColor #%d: %s (pixel 0x%06lx)\n",
		   ndx, newName, def.pixel));
	} else {
	    TRACE(("AllocateTermColor #%d: %s (failed)\n", ndx, name));
	    result = False;
	}
    }
    return result;
}
/***====================================================================***/

/* ARGSUSED */
void
Panic(const char *s GCC_UNUSED, int a GCC_UNUSED)
{
    if_DEBUG({
	xtermWarning(s, a);
    });
}

const char *
SysErrorMsg(int code)
{
    static const char unknown[] = "unknown error";
    char *s = strerror(code);
    return s ? s : unknown;
}

const char *
SysReasonMsg(int code)
{
    /* *INDENT-OFF* */
    static const struct {
	int code;
	const char *name;
    } table[] = {
	{ ERROR_FIONBIO,	"main:  ioctl() failed on FIONBIO" },
	{ ERROR_F_GETFL,	"main: ioctl() failed on F_GETFL" },
	{ ERROR_F_SETFL,	"main: ioctl() failed on F_SETFL", },
	{ ERROR_OPDEVTTY,	"spawn: open() failed on /dev/tty", },
	{ ERROR_TIOCGETP,	"spawn: ioctl() failed on TIOCGETP", },
	{ ERROR_PTSNAME,	"spawn: ptsname() failed", },
	{ ERROR_OPPTSNAME,	"spawn: open() failed on ptsname", },
	{ ERROR_PTEM,		"spawn: ioctl() failed on I_PUSH/\"ptem\"" },
	{ ERROR_CONSEM,		"spawn: ioctl() failed on I_PUSH/\"consem\"" },
	{ ERROR_LDTERM,		"spawn: ioctl() failed on I_PUSH/\"ldterm\"" },
	{ ERROR_TTCOMPAT,	"spawn: ioctl() failed on I_PUSH/\"ttcompat\"" },
	{ ERROR_TIOCSETP,	"spawn: ioctl() failed on TIOCSETP" },
	{ ERROR_TIOCSETC,	"spawn: ioctl() failed on TIOCSETC" },
	{ ERROR_TIOCSETD,	"spawn: ioctl() failed on TIOCSETD" },
	{ ERROR_TIOCSLTC,	"spawn: ioctl() failed on TIOCSLTC" },
	{ ERROR_TIOCLSET,	"spawn: ioctl() failed on TIOCLSET" },
	{ ERROR_INIGROUPS,	"spawn: initgroups() failed" },
	{ ERROR_FORK,		"spawn: fork() failed" },
	{ ERROR_EXEC,		"spawn: exec() failed" },
	{ ERROR_PTYS,		"get_pty: not enough ptys" },
	{ ERROR_PTY_EXEC,	"waiting for initial map" },
	{ ERROR_SETUID,		"spawn: setuid() failed" },
	{ ERROR_INIT,		"spawn: can't initialize window" },
	{ ERROR_TIOCKSET,	"spawn: ioctl() failed on TIOCKSET" },
	{ ERROR_TIOCKSETC,	"spawn: ioctl() failed on TIOCKSETC" },
	{ ERROR_LUMALLOC,	"luit: command-line malloc failed" },
	{ ERROR_SELECT,		"in_put: select() failed" },
	{ ERROR_VINIT,		"VTInit: can't initialize window" },
	{ ERROR_KMMALLOC1,	"HandleKeymapChange: malloc failed" },
	{ ERROR_TSELECT,	"Tinput: select() failed" },
	{ ERROR_TINIT,		"TekInit: can't initialize window" },
	{ ERROR_BMALLOC2,	"SaltTextAway: malloc() failed" },
	{ ERROR_LOGEXEC,	"StartLog: exec() failed" },
	{ ERROR_XERROR,		"xerror: XError event" },
	{ ERROR_XIOERROR,	"xioerror: X I/O error" },
	{ ERROR_SCALLOC,	"Alloc: calloc() failed on base" },
	{ ERROR_SCALLOC2,	"Alloc: calloc() failed on rows" },
	{ ERROR_SAVE_PTR,	"ScrnPointers: malloc/realloc() failed" },
    };
    /* *INDENT-ON* */

    Cardinal n;
    const char *result = "?";

    for (n = 0; n < XtNumber(table); ++n) {
	if (code == table[n].code) {
	    result = table[n].name;
	    break;
	}
    }
    return result;
}

void
SysError(int code)
{
    int oerrno = errno;

    fprintf(stderr, "%s: Error %d, errno %d: ", ProgramName, code, oerrno);
    fprintf(stderr, "%s\n", SysErrorMsg(oerrno));
    fprintf(stderr, "Reason: %s\n", SysReasonMsg(code));

    Cleanup(code);
}

void
NormalExit(void)
{
    static Bool cleaning;

    /*
     * Process "-hold" and session cleanup only for a normal exit.
     */
    if (cleaning) {
	hold_screen = 0;
	return;
    }

    cleaning = True;
    need_cleanup = False;

    if (hold_screen) {
	hold_screen = 2;
	while (hold_screen) {
	    xevents();
	    Sleep(10);
	}
    }
#if OPT_SESSION_MGT
    if (resource.sessionMgt) {
	XtVaSetValues(toplevel,
		      XtNjoinSession, False,
		      (void *) 0);
    }
#endif
    Cleanup(0);
}

/*
 * cleanup by sending SIGHUP to client processes
 */
void
Cleanup(int code)
{
    TScreen *screen = TScreenOf(term);

    TRACE(("Cleanup %d\n", code));

    if (screen->pid > 1) {
	(void) kill_process_group(screen->pid, SIGHUP);
    }
    Exit(code);
}

#ifndef S_IXOTH
#define S_IXOTH 1
#endif

Boolean
validProgram(const char *pathname)
{
    Boolean result = False;
    struct stat sb;

    if (!IsEmpty(pathname)
	&& *pathname == '/'
	&& strstr(pathname, "/..") == 0
	&& stat(pathname, &sb) == 0
	&& (sb.st_mode & S_IFMT) == S_IFREG
	&& (sb.st_mode & S_IXOTH) != 0) {
	result = True;
    }
    return result;
}

#ifndef VMS
#ifndef PATH_MAX
#define PATH_MAX 512		/* ... is not defined consistently in Xos.h */
#endif
char *
xtermFindShell(char *leaf, Bool warning)
{
    char *s0;
    char *s;
    char *d;
    char *tmp;
    char *result = leaf;
    Bool allocated = False;

    TRACE(("xtermFindShell(%s)\n", leaf));

    if (!strncmp("./", result, (size_t) 2)
	|| !strncmp("../", result, (size_t) 3)) {
	size_t need = PATH_MAX;
	size_t used = strlen(result) + 2;
	char *buffer = malloc(used + need);
	if (buffer != 0) {
	    if (getcwd(buffer, need) != 0) {
		sprintf(buffer + strlen(buffer), "/%s", result);
		result = buffer;
		allocated = True;
	    } else {
		free(buffer);
	    }
	}
    } else if (*result != '\0' && strchr("+/-", *result) == 0) {
	/* find it in $PATH */
	if ((s = s0 = x_getenv("PATH")) != 0) {
	    if ((tmp = TypeMallocN(char, strlen(leaf) + strlen(s) + 2)) != 0) {
		Bool found = False;
		while (*s != '\0') {
		    strcpy(tmp, s);
		    for (d = tmp;; ++d) {
			if (*d == ':' || *d == '\0') {
			    int skip = (*d != '\0');
			    *d = '/';
			    strcpy(d + 1, leaf);
			    if (skip)
				++d;
			    s += (d - tmp);
			    if (validProgram(tmp)) {
				result = x_strdup(tmp);
				found = True;
				allocated = True;
			    }
			    break;
			}
		    }
		    if (found)
			break;
		}
		free(tmp);
	    }
	    free(s0);
	}
    }
    TRACE(("...xtermFindShell(%s)\n", result));
    if (!validProgram(result)) {
	if (warning)
	    xtermWarning("No absolute path found for shell: %s\n", result);
	if (allocated)
	    free(result);
	result = 0;
    }
    /* be consistent, so that caller can always free the result */
    if (result != 0 && !allocated)
	result = x_strdup(result);
    return result;
}
#endif /* VMS */

#define ENV_HUNK(n)	(unsigned) ((((n) + 1) | 31) + 1)

/*
 * If we do not have unsetenv(), make consistent updates for environ[].
 * This could happen on some older machines due to the uneven standardization
 * process for the two functions.
 *
 * That is, putenv() makes a copy of environ, and some implementations do not
 * update the environ pointer, so the fallback when unsetenv() is missing would
 * not work as intended.  Likewise, the reverse could be true, i.e., unsetenv
 * could copy environ.
 */
#if defined(HAVE_PUTENV) && !defined(HAVE_UNSETENV)
#undef HAVE_PUTENV
#elif !defined(HAVE_PUTENV) && defined(HAVE_UNSETENV)
#undef HAVE_UNSETENV
#endif

/*
 * copy the environment before Setenv'ing.
 */
void
xtermCopyEnv(char **oldenv)
{
#ifdef HAVE_PUTENV
    (void) oldenv;
#else
    unsigned size;
    char **newenv;

    for (size = 0; oldenv[size] != NULL; size++) {
	;
    }

    newenv = TypeCallocN(char *, ENV_HUNK(size));
    memmove(newenv, oldenv, size * sizeof(char *));
    environ = newenv;
#endif
}

#if !defined(HAVE_PUTENV) || !defined(HAVE_UNSETENV)
static int
findEnv(const char *var, int *lengthp)
{
    char *test;
    int envindex = 0;
    size_t len = strlen(var);
    int found = -1;

    TRACE(("findEnv(%s=..)\n", var));

    while ((test = environ[envindex]) != NULL) {
	if (strncmp(test, var, len) == 0 && test[len] == '=') {
	    found = envindex;
	    break;
	}
	envindex++;
    }
    *lengthp = envindex;
    return found;
}
#endif

/*
 * sets the value of var to be arg in the Unix 4.2 BSD environment env.
 * Var should end with '=' (bindings are of the form "var=value").
 * This procedure assumes the memory for the first level of environ
 * was allocated using calloc, with enough extra room at the end so not
 * to have to do a realloc().
 */
void
xtermSetenv(const char *var, const char *value)
{
    if (value != 0) {
#ifdef HAVE_PUTENV
	char *both = malloc(2 + strlen(var) + strlen(value));
	TRACE(("xtermSetenv(%s=%s)\n", var, value));
	if (both) {
	    sprintf(both, "%s=%s", var, value);
	    putenv(both);
	}
#else
	size_t len = strlen(var);
	int envindex;
	int found = findEnv(var, &envindex);

	TRACE(("xtermSetenv(%s=%s)\n", var, value));

	if (found < 0) {
	    unsigned need = ENV_HUNK(envindex + 1);
	    unsigned have = ENV_HUNK(envindex);

	    if (need > have) {
		char **newenv;
		newenv = TypeMallocN(char *, need);
		if (newenv == 0) {
		    xtermWarning("Cannot increase environment\n");
		    return;
		}
		memmove(newenv, environ, have * sizeof(*newenv));
		free(environ);
		environ = newenv;
	    }

	    found = envindex;
	    environ[found + 1] = NULL;
	    environ = environ;
	}

	environ[found] = TextAlloc(1 + len + strlen(value));
	if (environ[found] == 0) {
	    xtermWarning("Cannot allocate environment %s\n", var);
	    return;
	}
	sprintf(environ[found], "%s=%s", var, value);
#endif
    }
}

void
xtermUnsetenv(const char *var)
{
    TRACE(("xtermUnsetenv(%s)\n", var));
#ifdef HAVE_UNSETENV
    unsetenv(var);
#else
    {
	int ignore;
	int item = findEnv(var, &ignore);
	if (item >= 0) {
	    while ((environ[item] = environ[item + 1]) != 0) {
		++item;
	    }
	}
    }
#endif
}

/*ARGSUSED*/
int
xerror(Display *d, XErrorEvent *ev)
{
    xtermWarning("warning, error event received:\n");
    (void) XmuPrintDefaultErrorMessage(d, ev, stderr);
    Exit(ERROR_XERROR);
    return 0;			/* appease the compiler */
}

void
ice_error(IceConn iceConn)
{
    (void) iceConn;

    xtermWarning("ICE IO error handler doing an exit(), pid = %ld, errno = %d\n",
		 (long) getpid(), errno);

    Exit(ERROR_ICEERROR);
}

/*ARGSUSED*/
int
xioerror(Display *dpy)
{
    int the_error = errno;

    xtermWarning("fatal IO error %d (%s) or KillClient on X server \"%s\"\r\n",
		 the_error, SysErrorMsg(the_error),
		 DisplayString(dpy));

    Exit(ERROR_XIOERROR);
    return 0;			/* appease the compiler */
}

void
xt_error(String message)
{
    xtermWarning("Xt error: %s\n", message);

    /*
     * Check for the obvious - Xt does a poor job of reporting this.
     */
    if (x_getenv("DISPLAY") == 0) {
	xtermWarning("DISPLAY is not set\n");
    }
    exit(1);
}

int
XStrCmp(char *s1, char *s2)
{
    if (s1 && s2)
	return (strcmp(s1, s2));
    if (s1 && *s1)
	return (1);
    if (s2 && *s2)
	return (-1);
    return (0);
}

#if OPT_TEK4014
static void
withdraw_window(Display *dpy, Window w, int scr)
{
    TRACE(("withdraw_window %#lx\n", (long) w));
    (void) XmuUpdateMapHints(dpy, w, NULL);
    XWithdrawWindow(dpy, w, scr);
    return;
}
#endif

void
set_vt_visibility(Bool on)
{
    XtermWidget xw = term;
    TScreen *screen = TScreenOf(xw);

    TRACE(("set_vt_visibility(%d)\n", on));
    if (on) {
	if (!screen->Vshow && xw) {
	    VTInit(xw);
	    XtMapWidget(XtParent(xw));
#if OPT_TOOLBAR
	    /* we need both of these during initialization */
	    XtMapWidget(SHELL_OF(xw));
	    ShowToolbar(resource.toolBar);
#endif
	    screen->Vshow = True;
	}
    }
#if OPT_TEK4014
    else {
	if (screen->Vshow && xw) {
	    withdraw_window(XtDisplay(xw),
			    VShellWindow(xw),
			    XScreenNumberOfScreen(XtScreen(xw)));
	    screen->Vshow = False;
	}
    }
    set_vthide_sensitivity();
    set_tekhide_sensitivity();
    update_vttekmode();
    update_tekshow();
    update_vtshow();
#endif
    return;
}

#if OPT_TEK4014
void
set_tek_visibility(Bool on)
{
    TRACE(("set_tek_visibility(%d)\n", on));

    if (on) {
	if (!TEK4014_SHOWN(term)) {
	    if (tekWidget == 0) {
		TekInit();	/* will exit on failure */
	    }
	    if (tekWidget != 0) {
		Widget tekParent = SHELL_OF(tekWidget);
		XtRealizeWidget(tekParent);
		XtMapWidget(XtParent(tekWidget));
#if OPT_TOOLBAR
		/* we need both of these during initialization */
		XtMapWidget(tekParent);
		XtMapWidget(tekWidget);
#endif
		XtOverrideTranslations(tekParent,
				       XtParseTranslationTable
				       ("WM_PROTOCOLS: DeleteWindow()"));
		(void) XSetWMProtocols(XtDisplay(tekParent),
				       XtWindow(tekParent),
				       &wm_delete_window, 1);
		TEK4014_SHOWN(term) = True;
	    }
	}
    } else {
	if (TEK4014_SHOWN(term) && tekWidget) {
	    withdraw_window(XtDisplay(tekWidget),
			    TShellWindow,
			    XScreenNumberOfScreen(XtScreen(tekWidget)));
	    TEK4014_SHOWN(term) = False;
	}
    }
    set_tekhide_sensitivity();
    set_vthide_sensitivity();
    update_vtshow();
    update_tekshow();
    update_vttekmode();
    return;
}

void
end_tek_mode(void)
{
    XtermWidget xw = term;

    if (TEK4014_ACTIVE(xw)) {
	FlushLog(xw);
	TEK4014_ACTIVE(xw) = False;
	xtermSetWinSize(xw);
	longjmp(Tekend, 1);
    }
    return;
}

void
end_vt_mode(void)
{
    XtermWidget xw = term;

    if (!TEK4014_ACTIVE(xw)) {
	FlushLog(xw);
	TEK4014_ACTIVE(xw) = True;
	TekSetWinSize(tekWidget);
	longjmp(VTend, 1);
    }
    return;
}

void
switch_modes(Bool tovt)		/* if true, then become vt mode */
{
    if (tovt) {
	if (tekRefreshList)
	    TekRefresh(tekWidget);
	end_tek_mode();		/* WARNING: this does a longjmp... */
    } else {
	end_vt_mode();		/* WARNING: this does a longjmp... */
    }
}

void
hide_vt_window(void)
{
    set_vt_visibility(False);
    if (!TEK4014_ACTIVE(term))
	switch_modes(False);	/* switch to tek mode */
}

void
hide_tek_window(void)
{
    set_tek_visibility(False);
    tekRefreshList = (TekLink *) 0;
    if (TEK4014_ACTIVE(term))
	switch_modes(True);	/* does longjmp to vt mode */
}
#endif /* OPT_TEK4014 */

static const char *
skip_punct(const char *s)
{
    while (*s == '-' || *s == '/' || *s == '+' || *s == '#' || *s == '%') {
	++s;
    }
    return s;
}

static int
cmp_options(const void *a, const void *b)
{
    const char *s1 = skip_punct(((const OptionHelp *) a)->opt);
    const char *s2 = skip_punct(((const OptionHelp *) b)->opt);
    return strcmp(s1, s2);
}

static int
cmp_resources(const void *a, const void *b)
{
    return strcmp(((const XrmOptionDescRec *) a)->option,
		  ((const XrmOptionDescRec *) b)->option);
}

XrmOptionDescRec *
sortedOptDescs(XrmOptionDescRec * descs, Cardinal res_count)
{
    static XrmOptionDescRec *res_array = 0;

#ifdef NO_LEAKS
    if (descs == 0) {
	if (res_array != 0) {
	    free(res_array);
	    res_array = 0;
	}
    } else
#endif
    if (res_array == 0) {
	Cardinal j;

	/* make a sorted index to 'resources' */
	res_array = TypeCallocN(XrmOptionDescRec, res_count);
	if (res_array != 0) {
	    for (j = 0; j < res_count; j++)
		res_array[j] = descs[j];
	    qsort(res_array, (size_t) res_count, sizeof(*res_array), cmp_resources);
	}
    }
    return res_array;
}

/*
 * The first time this is called, construct sorted index to the main program's
 * list of options, taking into account the on/off options which will be
 * compressed into one token.  It's a lot simpler to do it this way than
 * maintain the list in sorted form with lots of ifdef's.
 */
OptionHelp *
sortedOpts(OptionHelp * options, XrmOptionDescRec * descs, Cardinal numDescs)
{
    static OptionHelp *opt_array = 0;

#ifdef NO_LEAKS
    if (descs == 0 && opt_array != 0) {
	sortedOptDescs(descs, numDescs);
	free(opt_array);
	opt_array = 0;
	return 0;
    } else if (options == 0 || descs == 0) {
	return 0;
    }
#endif

    if (opt_array == 0) {
	size_t opt_count, j;
#if OPT_TRACE
	Cardinal k;
	XrmOptionDescRec *res_array = sortedOptDescs(descs, numDescs);
	int code;
	const char *mesg;
#else
	(void) descs;
	(void) numDescs;
#endif

	/* count 'options' and make a sorted index to it */
	for (opt_count = 0; options[opt_count].opt != 0; ++opt_count) {
	    ;
	}
	opt_array = TypeCallocN(OptionHelp, opt_count + 1);
	for (j = 0; j < opt_count; j++)
	    opt_array[j] = options[j];
	qsort(opt_array, opt_count, sizeof(OptionHelp), cmp_options);

	/* supply the "turn on/off" strings if needed */
#if OPT_TRACE
	for (j = 0; j < opt_count; j++) {
	    if (!strncmp(opt_array[j].opt, "-/+", (size_t) 3)) {
		char temp[80];
		const char *name = opt_array[j].opt + 3;
		for (k = 0; k < numDescs; ++k) {
		    const char *value = res_array[k].value;
		    if (res_array[k].option[0] == '-') {
			code = -1;
		    } else if (res_array[k].option[0] == '+') {
			code = 1;
		    } else {
			code = 0;
		    }
		    sprintf(temp, "%.*s",
			    (int) sizeof(temp) - 2,
			    opt_array[j].desc);
		    if (x_strindex(temp, "inhibit") != 0)
			code = -code;
		    if (code != 0
			&& res_array[k].value != 0
			&& !strcmp(name, res_array[k].option + 1)) {
			if (((code < 0) && !strcmp(value, "on"))
			    || ((code > 0) && !strcmp(value, "off"))
			    || ((code > 0) && !strcmp(value, "0"))) {
			    mesg = "turn on/off";
			} else {
			    mesg = "turn off/on";
			}
			if (strncmp(mesg, opt_array[j].desc, strlen(mesg))) {
			    if (strncmp(opt_array[j].desc, "turn ", (size_t) 5)) {
				char *s = TextAlloc(strlen(mesg)
						    + 1
						    + strlen(opt_array[j].desc));
				if (s != 0) {
				    sprintf(s, "%s %s", mesg, opt_array[j].desc);
				    opt_array[j].desc = s;
				}
			    } else {
				TRACE(("OOPS "));
			    }
			}
			TRACE(("%s: %s %s: %s (%s)\n",
			       mesg,
			       res_array[k].option,
			       res_array[k].value,
			       opt_array[j].opt,
			       opt_array[j].desc));
			break;
		    }
		}
	    }
	}
#endif
    }
    return opt_array;
}

/*
 * Report the character-type locale that xterm was started in.
 */
String
xtermEnvLocale(void)
{
    static String result;

    if (result == 0) {
	if ((result = x_nonempty(setlocale(LC_CTYPE, 0))) == 0) {
	    result = x_strdup("C");
	} else {
	    result = x_strdup(result);
	}
	TRACE(("xtermEnvLocale ->%s\n", result));
    }
    return result;
}

char *
xtermEnvEncoding(void)
{
    static char *result;

    if (result == 0) {
#ifdef HAVE_LANGINFO_CODESET
	result = nl_langinfo(CODESET);
#else
	char *locale = xtermEnvLocale();
	if (!strcmp(locale, "C") || !strcmp(locale, "POSIX")) {
	    result = "ASCII";
	} else {
	    result = "ISO-8859-1";
	}
#endif
	TRACE(("xtermEnvEncoding ->%s\n", result));
    }
    return result;
}

#if OPT_WIDE_CHARS
/*
 * Tell whether xterm was started in a locale that uses UTF-8 encoding for
 * characters.  That environment is inherited by subprocesses and used in
 * various library calls.
 */
Bool
xtermEnvUTF8(void)
{
    static Bool init = False;
    static Bool result = False;

    if (!init) {
	init = True;
#ifdef HAVE_LANGINFO_CODESET
	result = (strcmp(xtermEnvEncoding(), "UTF-8") == 0);
#else
	{
	    char *locale = x_strdup(xtermEnvLocale());
	    int n;
	    for (n = 0; locale[n] != 0; ++n) {
		locale[n] = x_toupper(locale[n]);
	    }
	    if (strstr(locale, "UTF-8") != 0)
		result = True;
	    else if (strstr(locale, "UTF8") != 0)
		result = True;
	    free(locale);
	}
#endif
	TRACE(("xtermEnvUTF8 ->%s\n", BtoS(result)));
    }
    return result;
}
#endif /* OPT_WIDE_CHARS */

/*
 * Check if the current widget, or any parent, is the VT100 "xterm" widget.
 */
XtermWidget
getXtermWidget(Widget w)
{
    XtermWidget xw;

    if (w == 0) {
	xw = (XtermWidget) CURRENT_EMU();
	if (!IsXtermWidget(xw)) {
	    xw = 0;
	}
    } else if (IsXtermWidget(w)) {
	xw = (XtermWidget) w;
    } else {
	xw = getXtermWidget(XtParent(w));
    }
    TRACE2(("getXtermWidget %p -> %p\n", w, xw));
    return xw;
}

#if OPT_SESSION_MGT
static void
die_callback(Widget w GCC_UNUSED,
	     XtPointer client_data GCC_UNUSED,
	     XtPointer call_data GCC_UNUSED)
{
    NormalExit();
}

static void
save_callback(Widget w GCC_UNUSED,
	      XtPointer client_data GCC_UNUSED,
	      XtPointer call_data)
{
    XtCheckpointToken token = (XtCheckpointToken) call_data;
    /* we have nothing to save */
    token->save_success = True;
}

static void
icewatch(IceConn iceConn,
	 IcePointer clientData GCC_UNUSED,
	 Bool opening,
	 IcePointer * watchData GCC_UNUSED)
{
    if (opening) {
	ice_fd = IceConnectionNumber(iceConn);
	TRACE(("got IceConnectionNumber %d\n", ice_fd));
    } else {
	ice_fd = -1;
	TRACE(("reset IceConnectionNumber\n"));
    }
}

void
xtermOpenSession(void)
{
    if (resource.sessionMgt) {
	TRACE(("Enabling session-management callbacks\n"));
	XtAddCallback(toplevel, XtNdieCallback, die_callback, NULL);
	XtAddCallback(toplevel, XtNsaveCallback, save_callback, NULL);
    }
}

void
xtermCloseSession(void)
{
    IceRemoveConnectionWatch(icewatch, NULL);
}
#endif /* OPT_SESSION_MGT */

Widget
xtermOpenApplication(XtAppContext * app_context_return,
		     String my_class,
		     XrmOptionDescRec * options,
		     Cardinal num_options,
		     int *argc_in_out,
		     String *argv_in_out,
		     String *fallback_resources,
		     WidgetClass widget_class,
		     ArgList args,
		     Cardinal num_args)
{
    Widget result;

    XtSetErrorHandler(xt_error);
#if OPT_SESSION_MGT
    result = XtOpenApplication(app_context_return,
			       my_class,
			       options,
			       num_options,
			       argc_in_out,
			       argv_in_out,
			       fallback_resources,
			       widget_class,
			       args,
			       num_args);
    IceAddConnectionWatch(icewatch, NULL);
#else
    (void) widget_class;
    (void) args;
    (void) num_args;
    result = XtAppInitialize(app_context_return,
			     my_class,
			     options,
			     num_options,
			     argc_in_out,
			     argv_in_out,
			     fallback_resources,
			     NULL, 0);
#endif /* OPT_SESSION_MGT */
    init_colored_cursor(XtDisplay(result));

    XtSetErrorHandler((XtErrorHandler) 0);

    return result;
}

static int x11_errors;

static int
catch_x11_error(Display *display, XErrorEvent *error_event)
{
    (void) display;
    (void) error_event;
    ++x11_errors;
    return 0;
}

Boolean
xtermGetWinAttrs(Display *dpy, Window win, XWindowAttributes * attrs)
{
    Boolean result = False;
    Status code;

    memset(attrs, 0, sizeof(*attrs));
    if (win != None) {
	XErrorHandler save = XSetErrorHandler(catch_x11_error);
	x11_errors = 0;
	code = XGetWindowAttributes(dpy, win, attrs);
	XSetErrorHandler(save);
	result = (Boolean) ((code != 0) && !x11_errors);
	if (result) {
	    TRACE_WIN_ATTRS(attrs);
	} else {
	    xtermWarning("invalid window-id %ld\n", (long) win);
	}
    }
    return result;
}

Boolean
xtermGetWinProp(Display *display,
		Window win,
		Atom property,
		long long_offset,
		long long_length,
		Atom req_type,
		Atom *actual_type_return,
		int *actual_format_return,
		unsigned long *nitems_return,
		unsigned long *bytes_after_return,
		unsigned char **prop_return)
{
    Boolean result = True;

    if (win != None) {
	XErrorHandler save = XSetErrorHandler(catch_x11_error);
	x11_errors = 0;
	if (XGetWindowProperty(display,
			       win,
			       property,
			       long_offset,
			       long_length,
			       False,
			       req_type,
			       actual_type_return,
			       actual_format_return,
			       nitems_return,
			       bytes_after_return,
			       prop_return) == Success
	    && x11_errors == 0) {
	    result = True;
	}
	XSetErrorHandler(save);
    }
    return result;
}

void
xtermEmbedWindow(Window winToEmbedInto)
{
    Display *dpy = XtDisplay(toplevel);
    XWindowAttributes attrs;

    TRACE(("checking winToEmbedInto %#lx\n", winToEmbedInto));
    if (xtermGetWinAttrs(dpy, winToEmbedInto, &attrs)) {
	XtermWidget xw = term;
	TScreen *screen = TScreenOf(xw);

	XtRealizeWidget(toplevel);

	TRACE(("...reparenting toplevel %#lx into %#lx\n",
	       XtWindow(toplevel),
	       winToEmbedInto));
	XReparentWindow(dpy,
			XtWindow(toplevel),
			winToEmbedInto, 0, 0);

	screen->embed_high = (Dimension) attrs.height;
	screen->embed_wide = (Dimension) attrs.width;
    }
}

void
free_string(String value)
{
    free((void *) value);
}

/* Set tty's idea of window size, using the given file descriptor 'fd'. */
void
update_winsize(int fd, int rows, int cols, int height, int width)
{
#ifdef TTYSIZE_STRUCT
    TTYSIZE_STRUCT ts;
    int code;

    setup_winsize(ts, rows, cols, height, width);
    TRACE_RC(code, SET_TTYSIZE(fd, ts));
    trace_winsize(ts, "from SET_TTYSIZE");
    (void) code;
#endif

    (void) rows;
    (void) cols;
    (void) height;
    (void) width;
}

/*
 * Update stty settings to match the values returned by dtterm window
 * manipulation 18 and 19.
 */
void
xtermSetWinSize(XtermWidget xw)
{
#if OPT_TEK4014
    if (!TEK4014_ACTIVE(xw))
#endif
	if (XtIsRealized((Widget) xw)) {
	    TScreen *screen = TScreenOf(xw);

	    TRACE(("xtermSetWinSize\n"));
	    update_winsize(screen->respond,
			   MaxRows(screen),
			   MaxCols(screen),
			   Height(screen),
			   Width(screen));
	}
}
xterm-330/xterm.desktop0000644000175100001440000000360112667426452014007 0ustar  tomusers# $XTermId: xterm.desktop,v 1.15 2016/03/08 01:38:50 tom Exp $
# -----------------------------------------------------------------------------
# this file is part of xterm
#
# Copyright 2006-2012,2016 by Thomas E. Dickey
# 
#                         All Rights Reserved
# 
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
# 
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# 
# Except as contained in this notice, the name(s) of the above copyright
# holders shall not be used in advertising or otherwise to promote the
# sale, use or other dealings in this Software without prior written
# authorization.
# -----------------------------------------------------------------------------
[Desktop Entry]
Name=XTerm
#GenericName=Terminal
Comment=standard terminal emulator for the X window system
Exec=xterm
Terminal=false
Type=Application
Encoding=UTF-8
Icon=xterm-color_48x48
Categories=System;TerminalEmulator;
Keywords=shell;prompt;command;commandline;cmd;
xterm-330/precompose.c0000644000175100001440000007002412720331574013566 0ustar  tomusers/*
 * Canonical Compositions
 *
 * DO NOT EDIT BY HAND! This is generated by the script
 * unicode/make-precompose.sh
 */
/* $XTermId: precompose.c,v 1.11 2016/05/22 13:26:20 tom Exp $ */

#include 

static struct {
  int replacement;
  int base;
  int comb; 
} precompositions[] = {
{ 0x226E, 0x003C, 0x0338},
{ 0x2260, 0x003D, 0x0338},
{ 0x226F, 0x003E, 0x0338},
{ 0x00C0, 0x0041, 0x0300},
{ 0x00C1, 0x0041, 0x0301},
{ 0x00C2, 0x0041, 0x0302},
{ 0x00C3, 0x0041, 0x0303},
{ 0x0100, 0x0041, 0x0304},
{ 0x0102, 0x0041, 0x0306},
{ 0x0226, 0x0041, 0x0307},
{ 0x00C4, 0x0041, 0x0308},
{ 0x1EA2, 0x0041, 0x0309},
{ 0x00C5, 0x0041, 0x030A},
{ 0x01CD, 0x0041, 0x030C},
{ 0x0200, 0x0041, 0x030F},
{ 0x0202, 0x0041, 0x0311},
{ 0x1EA0, 0x0041, 0x0323},
{ 0x1E00, 0x0041, 0x0325},
{ 0x0104, 0x0041, 0x0328},
{ 0x1E02, 0x0042, 0x0307},
{ 0x1E04, 0x0042, 0x0323},
{ 0x1E06, 0x0042, 0x0331},
{ 0x0106, 0x0043, 0x0301},
{ 0x0108, 0x0043, 0x0302},
{ 0x010A, 0x0043, 0x0307},
{ 0x010C, 0x0043, 0x030C},
{ 0x00C7, 0x0043, 0x0327},
{ 0x1E0A, 0x0044, 0x0307},
{ 0x010E, 0x0044, 0x030C},
{ 0x1E0C, 0x0044, 0x0323},
{ 0x1E10, 0x0044, 0x0327},
{ 0x1E12, 0x0044, 0x032D},
{ 0x1E0E, 0x0044, 0x0331},
{ 0x00C8, 0x0045, 0x0300},
{ 0x00C9, 0x0045, 0x0301},
{ 0x00CA, 0x0045, 0x0302},
{ 0x1EBC, 0x0045, 0x0303},
{ 0x0112, 0x0045, 0x0304},
{ 0x0114, 0x0045, 0x0306},
{ 0x0116, 0x0045, 0x0307},
{ 0x00CB, 0x0045, 0x0308},
{ 0x1EBA, 0x0045, 0x0309},
{ 0x011A, 0x0045, 0x030C},
{ 0x0204, 0x0045, 0x030F},
{ 0x0206, 0x0045, 0x0311},
{ 0x1EB8, 0x0045, 0x0323},
{ 0x0228, 0x0045, 0x0327},
{ 0x0118, 0x0045, 0x0328},
{ 0x1E18, 0x0045, 0x032D},
{ 0x1E1A, 0x0045, 0x0330},
{ 0x1E1E, 0x0046, 0x0307},
{ 0x01F4, 0x0047, 0x0301},
{ 0x011C, 0x0047, 0x0302},
{ 0x1E20, 0x0047, 0x0304},
{ 0x011E, 0x0047, 0x0306},
{ 0x0120, 0x0047, 0x0307},
{ 0x01E6, 0x0047, 0x030C},
{ 0x0122, 0x0047, 0x0327},
{ 0x0124, 0x0048, 0x0302},
{ 0x1E22, 0x0048, 0x0307},
{ 0x1E26, 0x0048, 0x0308},
{ 0x021E, 0x0048, 0x030C},
{ 0x1E24, 0x0048, 0x0323},
{ 0x1E28, 0x0048, 0x0327},
{ 0x1E2A, 0x0048, 0x032E},
{ 0x00CC, 0x0049, 0x0300},
{ 0x00CD, 0x0049, 0x0301},
{ 0x00CE, 0x0049, 0x0302},
{ 0x0128, 0x0049, 0x0303},
{ 0x012A, 0x0049, 0x0304},
{ 0x012C, 0x0049, 0x0306},
{ 0x0130, 0x0049, 0x0307},
{ 0x00CF, 0x0049, 0x0308},
{ 0x1EC8, 0x0049, 0x0309},
{ 0x01CF, 0x0049, 0x030C},
{ 0x0208, 0x0049, 0x030F},
{ 0x020A, 0x0049, 0x0311},
{ 0x1ECA, 0x0049, 0x0323},
{ 0x012E, 0x0049, 0x0328},
{ 0x1E2C, 0x0049, 0x0330},
{ 0x0134, 0x004A, 0x0302},
{ 0x1E30, 0x004B, 0x0301},
{ 0x01E8, 0x004B, 0x030C},
{ 0x1E32, 0x004B, 0x0323},
{ 0x0136, 0x004B, 0x0327},
{ 0x1E34, 0x004B, 0x0331},
{ 0x0139, 0x004C, 0x0301},
{ 0x013D, 0x004C, 0x030C},
{ 0x1E36, 0x004C, 0x0323},
{ 0x013B, 0x004C, 0x0327},
{ 0x1E3C, 0x004C, 0x032D},
{ 0x1E3A, 0x004C, 0x0331},
{ 0x1E3E, 0x004D, 0x0301},
{ 0x1E40, 0x004D, 0x0307},
{ 0x1E42, 0x004D, 0x0323},
{ 0x01F8, 0x004E, 0x0300},
{ 0x0143, 0x004E, 0x0301},
{ 0x00D1, 0x004E, 0x0303},
{ 0x1E44, 0x004E, 0x0307},
{ 0x0147, 0x004E, 0x030C},
{ 0x1E46, 0x004E, 0x0323},
{ 0x0145, 0x004E, 0x0327},
{ 0x1E4A, 0x004E, 0x032D},
{ 0x1E48, 0x004E, 0x0331},
{ 0x00D2, 0x004F, 0x0300},
{ 0x00D3, 0x004F, 0x0301},
{ 0x00D4, 0x004F, 0x0302},
{ 0x00D5, 0x004F, 0x0303},
{ 0x014C, 0x004F, 0x0304},
{ 0x014E, 0x004F, 0x0306},
{ 0x022E, 0x004F, 0x0307},
{ 0x00D6, 0x004F, 0x0308},
{ 0x1ECE, 0x004F, 0x0309},
{ 0x0150, 0x004F, 0x030B},
{ 0x01D1, 0x004F, 0x030C},
{ 0x020C, 0x004F, 0x030F},
{ 0x020E, 0x004F, 0x0311},
{ 0x01A0, 0x004F, 0x031B},
{ 0x1ECC, 0x004F, 0x0323},
{ 0x01EA, 0x004F, 0x0328},
{ 0x1E54, 0x0050, 0x0301},
{ 0x1E56, 0x0050, 0x0307},
{ 0x0154, 0x0052, 0x0301},
{ 0x1E58, 0x0052, 0x0307},
{ 0x0158, 0x0052, 0x030C},
{ 0x0210, 0x0052, 0x030F},
{ 0x0212, 0x0052, 0x0311},
{ 0x1E5A, 0x0052, 0x0323},
{ 0x0156, 0x0052, 0x0327},
{ 0x1E5E, 0x0052, 0x0331},
{ 0x015A, 0x0053, 0x0301},
{ 0x015C, 0x0053, 0x0302},
{ 0x1E60, 0x0053, 0x0307},
{ 0x0160, 0x0053, 0x030C},
{ 0x1E62, 0x0053, 0x0323},
{ 0x0218, 0x0053, 0x0326},
{ 0x015E, 0x0053, 0x0327},
{ 0x1E6A, 0x0054, 0x0307},
{ 0x0164, 0x0054, 0x030C},
{ 0x1E6C, 0x0054, 0x0323},
{ 0x021A, 0x0054, 0x0326},
{ 0x0162, 0x0054, 0x0327},
{ 0x1E70, 0x0054, 0x032D},
{ 0x1E6E, 0x0054, 0x0331},
{ 0x00D9, 0x0055, 0x0300},
{ 0x00DA, 0x0055, 0x0301},
{ 0x00DB, 0x0055, 0x0302},
{ 0x0168, 0x0055, 0x0303},
{ 0x016A, 0x0055, 0x0304},
{ 0x016C, 0x0055, 0x0306},
{ 0x00DC, 0x0055, 0x0308},
{ 0x1EE6, 0x0055, 0x0309},
{ 0x016E, 0x0055, 0x030A},
{ 0x0170, 0x0055, 0x030B},
{ 0x01D3, 0x0055, 0x030C},
{ 0x0214, 0x0055, 0x030F},
{ 0x0216, 0x0055, 0x0311},
{ 0x01AF, 0x0055, 0x031B},
{ 0x1EE4, 0x0055, 0x0323},
{ 0x1E72, 0x0055, 0x0324},
{ 0x0172, 0x0055, 0x0328},
{ 0x1E76, 0x0055, 0x032D},
{ 0x1E74, 0x0055, 0x0330},
{ 0x1E7C, 0x0056, 0x0303},
{ 0x1E7E, 0x0056, 0x0323},
{ 0x1E80, 0x0057, 0x0300},
{ 0x1E82, 0x0057, 0x0301},
{ 0x0174, 0x0057, 0x0302},
{ 0x1E86, 0x0057, 0x0307},
{ 0x1E84, 0x0057, 0x0308},
{ 0x1E88, 0x0057, 0x0323},
{ 0x1E8A, 0x0058, 0x0307},
{ 0x1E8C, 0x0058, 0x0308},
{ 0x1EF2, 0x0059, 0x0300},
{ 0x00DD, 0x0059, 0x0301},
{ 0x0176, 0x0059, 0x0302},
{ 0x1EF8, 0x0059, 0x0303},
{ 0x0232, 0x0059, 0x0304},
{ 0x1E8E, 0x0059, 0x0307},
{ 0x0178, 0x0059, 0x0308},
{ 0x1EF6, 0x0059, 0x0309},
{ 0x1EF4, 0x0059, 0x0323},
{ 0x0179, 0x005A, 0x0301},
{ 0x1E90, 0x005A, 0x0302},
{ 0x017B, 0x005A, 0x0307},
{ 0x017D, 0x005A, 0x030C},
{ 0x1E92, 0x005A, 0x0323},
{ 0x1E94, 0x005A, 0x0331},
{ 0x00E0, 0x0061, 0x0300},
{ 0x00E1, 0x0061, 0x0301},
{ 0x00E2, 0x0061, 0x0302},
{ 0x00E3, 0x0061, 0x0303},
{ 0x0101, 0x0061, 0x0304},
{ 0x0103, 0x0061, 0x0306},
{ 0x0227, 0x0061, 0x0307},
{ 0x00E4, 0x0061, 0x0308},
{ 0x1EA3, 0x0061, 0x0309},
{ 0x00E5, 0x0061, 0x030A},
{ 0x01CE, 0x0061, 0x030C},
{ 0x0201, 0x0061, 0x030F},
{ 0x0203, 0x0061, 0x0311},
{ 0x1EA1, 0x0061, 0x0323},
{ 0x1E01, 0x0061, 0x0325},
{ 0x0105, 0x0061, 0x0328},
{ 0x1E03, 0x0062, 0x0307},
{ 0x1E05, 0x0062, 0x0323},
{ 0x1E07, 0x0062, 0x0331},
{ 0x0107, 0x0063, 0x0301},
{ 0x0109, 0x0063, 0x0302},
{ 0x010B, 0x0063, 0x0307},
{ 0x010D, 0x0063, 0x030C},
{ 0x00E7, 0x0063, 0x0327},
{ 0x1E0B, 0x0064, 0x0307},
{ 0x010F, 0x0064, 0x030C},
{ 0x1E0D, 0x0064, 0x0323},
{ 0x1E11, 0x0064, 0x0327},
{ 0x1E13, 0x0064, 0x032D},
{ 0x1E0F, 0x0064, 0x0331},
{ 0x00E8, 0x0065, 0x0300},
{ 0x00E9, 0x0065, 0x0301},
{ 0x00EA, 0x0065, 0x0302},
{ 0x1EBD, 0x0065, 0x0303},
{ 0x0113, 0x0065, 0x0304},
{ 0x0115, 0x0065, 0x0306},
{ 0x0117, 0x0065, 0x0307},
{ 0x00EB, 0x0065, 0x0308},
{ 0x1EBB, 0x0065, 0x0309},
{ 0x011B, 0x0065, 0x030C},
{ 0x0205, 0x0065, 0x030F},
{ 0x0207, 0x0065, 0x0311},
{ 0x1EB9, 0x0065, 0x0323},
{ 0x0229, 0x0065, 0x0327},
{ 0x0119, 0x0065, 0x0328},
{ 0x1E19, 0x0065, 0x032D},
{ 0x1E1B, 0x0065, 0x0330},
{ 0x1E1F, 0x0066, 0x0307},
{ 0x01F5, 0x0067, 0x0301},
{ 0x011D, 0x0067, 0x0302},
{ 0x1E21, 0x0067, 0x0304},
{ 0x011F, 0x0067, 0x0306},
{ 0x0121, 0x0067, 0x0307},
{ 0x01E7, 0x0067, 0x030C},
{ 0x0123, 0x0067, 0x0327},
{ 0x0125, 0x0068, 0x0302},
{ 0x1E23, 0x0068, 0x0307},
{ 0x1E27, 0x0068, 0x0308},
{ 0x021F, 0x0068, 0x030C},
{ 0x1E25, 0x0068, 0x0323},
{ 0x1E29, 0x0068, 0x0327},
{ 0x1E2B, 0x0068, 0x032E},
{ 0x1E96, 0x0068, 0x0331},
{ 0x00EC, 0x0069, 0x0300},
{ 0x00ED, 0x0069, 0x0301},
{ 0x00EE, 0x0069, 0x0302},
{ 0x0129, 0x0069, 0x0303},
{ 0x012B, 0x0069, 0x0304},
{ 0x012D, 0x0069, 0x0306},
{ 0x00EF, 0x0069, 0x0308},
{ 0x1EC9, 0x0069, 0x0309},
{ 0x01D0, 0x0069, 0x030C},
{ 0x0209, 0x0069, 0x030F},
{ 0x020B, 0x0069, 0x0311},
{ 0x1ECB, 0x0069, 0x0323},
{ 0x012F, 0x0069, 0x0328},
{ 0x1E2D, 0x0069, 0x0330},
{ 0x0135, 0x006A, 0x0302},
{ 0x01F0, 0x006A, 0x030C},
{ 0x1E31, 0x006B, 0x0301},
{ 0x01E9, 0x006B, 0x030C},
{ 0x1E33, 0x006B, 0x0323},
{ 0x0137, 0x006B, 0x0327},
{ 0x1E35, 0x006B, 0x0331},
{ 0x013A, 0x006C, 0x0301},
{ 0x013E, 0x006C, 0x030C},
{ 0x1E37, 0x006C, 0x0323},
{ 0x013C, 0x006C, 0x0327},
{ 0x1E3D, 0x006C, 0x032D},
{ 0x1E3B, 0x006C, 0x0331},
{ 0x1E3F, 0x006D, 0x0301},
{ 0x1E41, 0x006D, 0x0307},
{ 0x1E43, 0x006D, 0x0323},
{ 0x01F9, 0x006E, 0x0300},
{ 0x0144, 0x006E, 0x0301},
{ 0x00F1, 0x006E, 0x0303},
{ 0x1E45, 0x006E, 0x0307},
{ 0x0148, 0x006E, 0x030C},
{ 0x1E47, 0x006E, 0x0323},
{ 0x0146, 0x006E, 0x0327},
{ 0x1E4B, 0x006E, 0x032D},
{ 0x1E49, 0x006E, 0x0331},
{ 0x00F2, 0x006F, 0x0300},
{ 0x00F3, 0x006F, 0x0301},
{ 0x00F4, 0x006F, 0x0302},
{ 0x00F5, 0x006F, 0x0303},
{ 0x014D, 0x006F, 0x0304},
{ 0x014F, 0x006F, 0x0306},
{ 0x022F, 0x006F, 0x0307},
{ 0x00F6, 0x006F, 0x0308},
{ 0x1ECF, 0x006F, 0x0309},
{ 0x0151, 0x006F, 0x030B},
{ 0x01D2, 0x006F, 0x030C},
{ 0x020D, 0x006F, 0x030F},
{ 0x020F, 0x006F, 0x0311},
{ 0x01A1, 0x006F, 0x031B},
{ 0x1ECD, 0x006F, 0x0323},
{ 0x01EB, 0x006F, 0x0328},
{ 0x1E55, 0x0070, 0x0301},
{ 0x1E57, 0x0070, 0x0307},
{ 0x0155, 0x0072, 0x0301},
{ 0x1E59, 0x0072, 0x0307},
{ 0x0159, 0x0072, 0x030C},
{ 0x0211, 0x0072, 0x030F},
{ 0x0213, 0x0072, 0x0311},
{ 0x1E5B, 0x0072, 0x0323},
{ 0x0157, 0x0072, 0x0327},
{ 0x1E5F, 0x0072, 0x0331},
{ 0x015B, 0x0073, 0x0301},
{ 0x015D, 0x0073, 0x0302},
{ 0x1E61, 0x0073, 0x0307},
{ 0x0161, 0x0073, 0x030C},
{ 0x1E63, 0x0073, 0x0323},
{ 0x0219, 0x0073, 0x0326},
{ 0x015F, 0x0073, 0x0327},
{ 0x1E6B, 0x0074, 0x0307},
{ 0x1E97, 0x0074, 0x0308},
{ 0x0165, 0x0074, 0x030C},
{ 0x1E6D, 0x0074, 0x0323},
{ 0x021B, 0x0074, 0x0326},
{ 0x0163, 0x0074, 0x0327},
{ 0x1E71, 0x0074, 0x032D},
{ 0x1E6F, 0x0074, 0x0331},
{ 0x00F9, 0x0075, 0x0300},
{ 0x00FA, 0x0075, 0x0301},
{ 0x00FB, 0x0075, 0x0302},
{ 0x0169, 0x0075, 0x0303},
{ 0x016B, 0x0075, 0x0304},
{ 0x016D, 0x0075, 0x0306},
{ 0x00FC, 0x0075, 0x0308},
{ 0x1EE7, 0x0075, 0x0309},
{ 0x016F, 0x0075, 0x030A},
{ 0x0171, 0x0075, 0x030B},
{ 0x01D4, 0x0075, 0x030C},
{ 0x0215, 0x0075, 0x030F},
{ 0x0217, 0x0075, 0x0311},
{ 0x01B0, 0x0075, 0x031B},
{ 0x1EE5, 0x0075, 0x0323},
{ 0x1E73, 0x0075, 0x0324},
{ 0x0173, 0x0075, 0x0328},
{ 0x1E77, 0x0075, 0x032D},
{ 0x1E75, 0x0075, 0x0330},
{ 0x1E7D, 0x0076, 0x0303},
{ 0x1E7F, 0x0076, 0x0323},
{ 0x1E81, 0x0077, 0x0300},
{ 0x1E83, 0x0077, 0x0301},
{ 0x0175, 0x0077, 0x0302},
{ 0x1E87, 0x0077, 0x0307},
{ 0x1E85, 0x0077, 0x0308},
{ 0x1E98, 0x0077, 0x030A},
{ 0x1E89, 0x0077, 0x0323},
{ 0x1E8B, 0x0078, 0x0307},
{ 0x1E8D, 0x0078, 0x0308},
{ 0x1EF3, 0x0079, 0x0300},
{ 0x00FD, 0x0079, 0x0301},
{ 0x0177, 0x0079, 0x0302},
{ 0x1EF9, 0x0079, 0x0303},
{ 0x0233, 0x0079, 0x0304},
{ 0x1E8F, 0x0079, 0x0307},
{ 0x00FF, 0x0079, 0x0308},
{ 0x1EF7, 0x0079, 0x0309},
{ 0x1E99, 0x0079, 0x030A},
{ 0x1EF5, 0x0079, 0x0323},
{ 0x017A, 0x007A, 0x0301},
{ 0x1E91, 0x007A, 0x0302},
{ 0x017C, 0x007A, 0x0307},
{ 0x017E, 0x007A, 0x030C},
{ 0x1E93, 0x007A, 0x0323},
{ 0x1E95, 0x007A, 0x0331},
{ 0x1FED, 0x00A8, 0x0300},
{ 0x0385, 0x00A8, 0x0301},
{ 0x1FC1, 0x00A8, 0x0342},
{ 0x1EA6, 0x00C2, 0x0300},
{ 0x1EA4, 0x00C2, 0x0301},
{ 0x1EAA, 0x00C2, 0x0303},
{ 0x1EA8, 0x00C2, 0x0309},
{ 0x01DE, 0x00C4, 0x0304},
{ 0x01FA, 0x00C5, 0x0301},
{ 0x01FC, 0x00C6, 0x0301},
{ 0x01E2, 0x00C6, 0x0304},
{ 0x1E08, 0x00C7, 0x0301},
{ 0x1EC0, 0x00CA, 0x0300},
{ 0x1EBE, 0x00CA, 0x0301},
{ 0x1EC4, 0x00CA, 0x0303},
{ 0x1EC2, 0x00CA, 0x0309},
{ 0x1E2E, 0x00CF, 0x0301},
{ 0x1ED2, 0x00D4, 0x0300},
{ 0x1ED0, 0x00D4, 0x0301},
{ 0x1ED6, 0x00D4, 0x0303},
{ 0x1ED4, 0x00D4, 0x0309},
{ 0x1E4C, 0x00D5, 0x0301},
{ 0x022C, 0x00D5, 0x0304},
{ 0x1E4E, 0x00D5, 0x0308},
{ 0x022A, 0x00D6, 0x0304},
{ 0x01FE, 0x00D8, 0x0301},
{ 0x01DB, 0x00DC, 0x0300},
{ 0x01D7, 0x00DC, 0x0301},
{ 0x01D5, 0x00DC, 0x0304},
{ 0x01D9, 0x00DC, 0x030C},
{ 0x1EA7, 0x00E2, 0x0300},
{ 0x1EA5, 0x00E2, 0x0301},
{ 0x1EAB, 0x00E2, 0x0303},
{ 0x1EA9, 0x00E2, 0x0309},
{ 0x01DF, 0x00E4, 0x0304},
{ 0x01FB, 0x00E5, 0x0301},
{ 0x01FD, 0x00E6, 0x0301},
{ 0x01E3, 0x00E6, 0x0304},
{ 0x1E09, 0x00E7, 0x0301},
{ 0x1EC1, 0x00EA, 0x0300},
{ 0x1EBF, 0x00EA, 0x0301},
{ 0x1EC5, 0x00EA, 0x0303},
{ 0x1EC3, 0x00EA, 0x0309},
{ 0x1E2F, 0x00EF, 0x0301},
{ 0x1ED3, 0x00F4, 0x0300},
{ 0x1ED1, 0x00F4, 0x0301},
{ 0x1ED7, 0x00F4, 0x0303},
{ 0x1ED5, 0x00F4, 0x0309},
{ 0x1E4D, 0x00F5, 0x0301},
{ 0x022D, 0x00F5, 0x0304},
{ 0x1E4F, 0x00F5, 0x0308},
{ 0x022B, 0x00F6, 0x0304},
{ 0x01FF, 0x00F8, 0x0301},
{ 0x01DC, 0x00FC, 0x0300},
{ 0x01D8, 0x00FC, 0x0301},
{ 0x01D6, 0x00FC, 0x0304},
{ 0x01DA, 0x00FC, 0x030C},
{ 0x1EB0, 0x0102, 0x0300},
{ 0x1EAE, 0x0102, 0x0301},
{ 0x1EB4, 0x0102, 0x0303},
{ 0x1EB2, 0x0102, 0x0309},
{ 0x1EB1, 0x0103, 0x0300},
{ 0x1EAF, 0x0103, 0x0301},
{ 0x1EB5, 0x0103, 0x0303},
{ 0x1EB3, 0x0103, 0x0309},
{ 0x1E14, 0x0112, 0x0300},
{ 0x1E16, 0x0112, 0x0301},
{ 0x1E15, 0x0113, 0x0300},
{ 0x1E17, 0x0113, 0x0301},
{ 0x1E50, 0x014C, 0x0300},
{ 0x1E52, 0x014C, 0x0301},
{ 0x1E51, 0x014D, 0x0300},
{ 0x1E53, 0x014D, 0x0301},
{ 0x1E64, 0x015A, 0x0307},
{ 0x1E65, 0x015B, 0x0307},
{ 0x1E66, 0x0160, 0x0307},
{ 0x1E67, 0x0161, 0x0307},
{ 0x1E78, 0x0168, 0x0301},
{ 0x1E79, 0x0169, 0x0301},
{ 0x1E7A, 0x016A, 0x0308},
{ 0x1E7B, 0x016B, 0x0308},
{ 0x1E9B, 0x017F, 0x0307},
{ 0x1EDC, 0x01A0, 0x0300},
{ 0x1EDA, 0x01A0, 0x0301},
{ 0x1EE0, 0x01A0, 0x0303},
{ 0x1EDE, 0x01A0, 0x0309},
{ 0x1EE2, 0x01A0, 0x0323},
{ 0x1EDD, 0x01A1, 0x0300},
{ 0x1EDB, 0x01A1, 0x0301},
{ 0x1EE1, 0x01A1, 0x0303},
{ 0x1EDF, 0x01A1, 0x0309},
{ 0x1EE3, 0x01A1, 0x0323},
{ 0x1EEA, 0x01AF, 0x0300},
{ 0x1EE8, 0x01AF, 0x0301},
{ 0x1EEE, 0x01AF, 0x0303},
{ 0x1EEC, 0x01AF, 0x0309},
{ 0x1EF0, 0x01AF, 0x0323},
{ 0x1EEB, 0x01B0, 0x0300},
{ 0x1EE9, 0x01B0, 0x0301},
{ 0x1EEF, 0x01B0, 0x0303},
{ 0x1EED, 0x01B0, 0x0309},
{ 0x1EF1, 0x01B0, 0x0323},
{ 0x01EE, 0x01B7, 0x030C},
{ 0x01EC, 0x01EA, 0x0304},
{ 0x01ED, 0x01EB, 0x0304},
{ 0x01E0, 0x0226, 0x0304},
{ 0x01E1, 0x0227, 0x0304},
{ 0x1E1C, 0x0228, 0x0306},
{ 0x1E1D, 0x0229, 0x0306},
{ 0x0230, 0x022E, 0x0304},
{ 0x0231, 0x022F, 0x0304},
{ 0x01EF, 0x0292, 0x030C},
{ 0x0344, 0x0308, 0x0301},
{ 0x1FBA, 0x0391, 0x0300},
{ 0x0386, 0x0391, 0x0301},
{ 0x1FB9, 0x0391, 0x0304},
{ 0x1FB8, 0x0391, 0x0306},
{ 0x1F08, 0x0391, 0x0313},
{ 0x1F09, 0x0391, 0x0314},
{ 0x1FBC, 0x0391, 0x0345},
{ 0x1FC8, 0x0395, 0x0300},
{ 0x0388, 0x0395, 0x0301},
{ 0x1F18, 0x0395, 0x0313},
{ 0x1F19, 0x0395, 0x0314},
{ 0x1FCA, 0x0397, 0x0300},
{ 0x0389, 0x0397, 0x0301},
{ 0x1F28, 0x0397, 0x0313},
{ 0x1F29, 0x0397, 0x0314},
{ 0x1FCC, 0x0397, 0x0345},
{ 0x1FDA, 0x0399, 0x0300},
{ 0x038A, 0x0399, 0x0301},
{ 0x1FD9, 0x0399, 0x0304},
{ 0x1FD8, 0x0399, 0x0306},
{ 0x03AA, 0x0399, 0x0308},
{ 0x1F38, 0x0399, 0x0313},
{ 0x1F39, 0x0399, 0x0314},
{ 0x1FF8, 0x039F, 0x0300},
{ 0x038C, 0x039F, 0x0301},
{ 0x1F48, 0x039F, 0x0313},
{ 0x1F49, 0x039F, 0x0314},
{ 0x1FEC, 0x03A1, 0x0314},
{ 0x1FEA, 0x03A5, 0x0300},
{ 0x038E, 0x03A5, 0x0301},
{ 0x1FE9, 0x03A5, 0x0304},
{ 0x1FE8, 0x03A5, 0x0306},
{ 0x03AB, 0x03A5, 0x0308},
{ 0x1F59, 0x03A5, 0x0314},
{ 0x1FFA, 0x03A9, 0x0300},
{ 0x038F, 0x03A9, 0x0301},
{ 0x1F68, 0x03A9, 0x0313},
{ 0x1F69, 0x03A9, 0x0314},
{ 0x1FFC, 0x03A9, 0x0345},
{ 0x1FB4, 0x03AC, 0x0345},
{ 0x1FC4, 0x03AE, 0x0345},
{ 0x1F70, 0x03B1, 0x0300},
{ 0x03AC, 0x03B1, 0x0301},
{ 0x1FB1, 0x03B1, 0x0304},
{ 0x1FB0, 0x03B1, 0x0306},
{ 0x1F00, 0x03B1, 0x0313},
{ 0x1F01, 0x03B1, 0x0314},
{ 0x1FB6, 0x03B1, 0x0342},
{ 0x1FB3, 0x03B1, 0x0345},
{ 0x1F72, 0x03B5, 0x0300},
{ 0x03AD, 0x03B5, 0x0301},
{ 0x1F10, 0x03B5, 0x0313},
{ 0x1F11, 0x03B5, 0x0314},
{ 0x1F74, 0x03B7, 0x0300},
{ 0x03AE, 0x03B7, 0x0301},
{ 0x1F20, 0x03B7, 0x0313},
{ 0x1F21, 0x03B7, 0x0314},
{ 0x1FC6, 0x03B7, 0x0342},
{ 0x1FC3, 0x03B7, 0x0345},
{ 0x1F76, 0x03B9, 0x0300},
{ 0x03AF, 0x03B9, 0x0301},
{ 0x1FD1, 0x03B9, 0x0304},
{ 0x1FD0, 0x03B9, 0x0306},
{ 0x03CA, 0x03B9, 0x0308},
{ 0x1F30, 0x03B9, 0x0313},
{ 0x1F31, 0x03B9, 0x0314},
{ 0x1FD6, 0x03B9, 0x0342},
{ 0x1F78, 0x03BF, 0x0300},
{ 0x03CC, 0x03BF, 0x0301},
{ 0x1F40, 0x03BF, 0x0313},
{ 0x1F41, 0x03BF, 0x0314},
{ 0x1FE4, 0x03C1, 0x0313},
{ 0x1FE5, 0x03C1, 0x0314},
{ 0x1F7A, 0x03C5, 0x0300},
{ 0x03CD, 0x03C5, 0x0301},
{ 0x1FE1, 0x03C5, 0x0304},
{ 0x1FE0, 0x03C5, 0x0306},
{ 0x03CB, 0x03C5, 0x0308},
{ 0x1F50, 0x03C5, 0x0313},
{ 0x1F51, 0x03C5, 0x0314},
{ 0x1FE6, 0x03C5, 0x0342},
{ 0x1F7C, 0x03C9, 0x0300},
{ 0x03CE, 0x03C9, 0x0301},
{ 0x1F60, 0x03C9, 0x0313},
{ 0x1F61, 0x03C9, 0x0314},
{ 0x1FF6, 0x03C9, 0x0342},
{ 0x1FF3, 0x03C9, 0x0345},
{ 0x1FD2, 0x03CA, 0x0300},
{ 0x0390, 0x03CA, 0x0301},
{ 0x1FD7, 0x03CA, 0x0342},
{ 0x1FE2, 0x03CB, 0x0300},
{ 0x03B0, 0x03CB, 0x0301},
{ 0x1FE7, 0x03CB, 0x0342},
{ 0x1FF4, 0x03CE, 0x0345},
{ 0x03D3, 0x03D2, 0x0301},
{ 0x03D4, 0x03D2, 0x0308},
{ 0x0407, 0x0406, 0x0308},
{ 0x04D0, 0x0410, 0x0306},
{ 0x04D2, 0x0410, 0x0308},
{ 0x0403, 0x0413, 0x0301},
{ 0x0400, 0x0415, 0x0300},
{ 0x04D6, 0x0415, 0x0306},
{ 0x0401, 0x0415, 0x0308},
{ 0x04C1, 0x0416, 0x0306},
{ 0x04DC, 0x0416, 0x0308},
{ 0x04DE, 0x0417, 0x0308},
{ 0x040D, 0x0418, 0x0300},
{ 0x04E2, 0x0418, 0x0304},
{ 0x0419, 0x0418, 0x0306},
{ 0x04E4, 0x0418, 0x0308},
{ 0x040C, 0x041A, 0x0301},
{ 0x04E6, 0x041E, 0x0308},
{ 0x04EE, 0x0423, 0x0304},
{ 0x040E, 0x0423, 0x0306},
{ 0x04F0, 0x0423, 0x0308},
{ 0x04F2, 0x0423, 0x030B},
{ 0x04F4, 0x0427, 0x0308},
{ 0x04F8, 0x042B, 0x0308},
{ 0x04EC, 0x042D, 0x0308},
{ 0x04D1, 0x0430, 0x0306},
{ 0x04D3, 0x0430, 0x0308},
{ 0x0453, 0x0433, 0x0301},
{ 0x0450, 0x0435, 0x0300},
{ 0x04D7, 0x0435, 0x0306},
{ 0x0451, 0x0435, 0x0308},
{ 0x04C2, 0x0436, 0x0306},
{ 0x04DD, 0x0436, 0x0308},
{ 0x04DF, 0x0437, 0x0308},
{ 0x045D, 0x0438, 0x0300},
{ 0x04E3, 0x0438, 0x0304},
{ 0x0439, 0x0438, 0x0306},
{ 0x04E5, 0x0438, 0x0308},
{ 0x045C, 0x043A, 0x0301},
{ 0x04E7, 0x043E, 0x0308},
{ 0x04EF, 0x0443, 0x0304},
{ 0x045E, 0x0443, 0x0306},
{ 0x04F1, 0x0443, 0x0308},
{ 0x04F3, 0x0443, 0x030B},
{ 0x04F5, 0x0447, 0x0308},
{ 0x04F9, 0x044B, 0x0308},
{ 0x04ED, 0x044D, 0x0308},
{ 0x0457, 0x0456, 0x0308},
{ 0x0476, 0x0474, 0x030F},
{ 0x0477, 0x0475, 0x030F},
{ 0x04DA, 0x04D8, 0x0308},
{ 0x04DB, 0x04D9, 0x0308},
{ 0x04EA, 0x04E8, 0x0308},
{ 0x04EB, 0x04E9, 0x0308},
{ 0xFB2E, 0x05D0, 0x05B7},
{ 0xFB2F, 0x05D0, 0x05B8},
{ 0xFB30, 0x05D0, 0x05BC},
{ 0xFB31, 0x05D1, 0x05BC},
{ 0xFB4C, 0x05D1, 0x05BF},
{ 0xFB32, 0x05D2, 0x05BC},
{ 0xFB33, 0x05D3, 0x05BC},
{ 0xFB34, 0x05D4, 0x05BC},
{ 0xFB4B, 0x05D5, 0x05B9},
{ 0xFB35, 0x05D5, 0x05BC},
{ 0xFB36, 0x05D6, 0x05BC},
{ 0xFB38, 0x05D8, 0x05BC},
{ 0xFB1D, 0x05D9, 0x05B4},
{ 0xFB39, 0x05D9, 0x05BC},
{ 0xFB3A, 0x05DA, 0x05BC},
{ 0xFB3B, 0x05DB, 0x05BC},
{ 0xFB4D, 0x05DB, 0x05BF},
{ 0xFB3C, 0x05DC, 0x05BC},
{ 0xFB3E, 0x05DE, 0x05BC},
{ 0xFB40, 0x05E0, 0x05BC},
{ 0xFB41, 0x05E1, 0x05BC},
{ 0xFB43, 0x05E3, 0x05BC},
{ 0xFB44, 0x05E4, 0x05BC},
{ 0xFB4E, 0x05E4, 0x05BF},
{ 0xFB46, 0x05E6, 0x05BC},
{ 0xFB47, 0x05E7, 0x05BC},
{ 0xFB48, 0x05E8, 0x05BC},
{ 0xFB49, 0x05E9, 0x05BC},
{ 0xFB2A, 0x05E9, 0x05C1},
{ 0xFB2B, 0x05E9, 0x05C2},
{ 0xFB4A, 0x05EA, 0x05BC},
{ 0xFB1F, 0x05F2, 0x05B7},
{ 0x0622, 0x0627, 0x0653},
{ 0x0623, 0x0627, 0x0654},
{ 0x0625, 0x0627, 0x0655},
{ 0x0624, 0x0648, 0x0654},
{ 0x0626, 0x064A, 0x0654},
{ 0x06C2, 0x06C1, 0x0654},
{ 0x06D3, 0x06D2, 0x0654},
{ 0x06C0, 0x06D5, 0x0654},
{ 0x0958, 0x0915, 0x093C},
{ 0x0959, 0x0916, 0x093C},
{ 0x095A, 0x0917, 0x093C},
{ 0x095B, 0x091C, 0x093C},
{ 0x095C, 0x0921, 0x093C},
{ 0x095D, 0x0922, 0x093C},
{ 0x0929, 0x0928, 0x093C},
{ 0x095E, 0x092B, 0x093C},
{ 0x095F, 0x092F, 0x093C},
{ 0x0931, 0x0930, 0x093C},
{ 0x0934, 0x0933, 0x093C},
{ 0x09DC, 0x09A1, 0x09BC},
{ 0x09DD, 0x09A2, 0x09BC},
{ 0x09DF, 0x09AF, 0x09BC},
{ 0x09CB, 0x09C7, 0x09BE},
{ 0x09CC, 0x09C7, 0x09D7},
{ 0x0A59, 0x0A16, 0x0A3C},
{ 0x0A5A, 0x0A17, 0x0A3C},
{ 0x0A5B, 0x0A1C, 0x0A3C},
{ 0x0A5E, 0x0A2B, 0x0A3C},
{ 0x0A33, 0x0A32, 0x0A3C},
{ 0x0A36, 0x0A38, 0x0A3C},
{ 0x0B5C, 0x0B21, 0x0B3C},
{ 0x0B5D, 0x0B22, 0x0B3C},
{ 0x0B4B, 0x0B47, 0x0B3E},
{ 0x0B48, 0x0B47, 0x0B56},
{ 0x0B4C, 0x0B47, 0x0B57},
{ 0x0B94, 0x0B92, 0x0BD7},
{ 0x0BCA, 0x0BC6, 0x0BBE},
{ 0x0BCC, 0x0BC6, 0x0BD7},
{ 0x0BCB, 0x0BC7, 0x0BBE},
{ 0x0C48, 0x0C46, 0x0C56},
{ 0x0CC0, 0x0CBF, 0x0CD5},
{ 0x0CCA, 0x0CC6, 0x0CC2},
{ 0x0CC7, 0x0CC6, 0x0CD5},
{ 0x0CC8, 0x0CC6, 0x0CD6},
{ 0x0CCB, 0x0CCA, 0x0CD5},
{ 0x0D4A, 0x0D46, 0x0D3E},
{ 0x0D4C, 0x0D46, 0x0D57},
{ 0x0D4B, 0x0D47, 0x0D3E},
{ 0x0DDA, 0x0DD9, 0x0DCA},
{ 0x0DDC, 0x0DD9, 0x0DCF},
{ 0x0DDE, 0x0DD9, 0x0DDF},
{ 0x0DDD, 0x0DDC, 0x0DCA},
{ 0x0F69, 0x0F40, 0x0FB5},
{ 0x0F43, 0x0F42, 0x0FB7},
{ 0x0F4D, 0x0F4C, 0x0FB7},
{ 0x0F52, 0x0F51, 0x0FB7},
{ 0x0F57, 0x0F56, 0x0FB7},
{ 0x0F5C, 0x0F5B, 0x0FB7},
{ 0x0F73, 0x0F71, 0x0F72},
{ 0x0F75, 0x0F71, 0x0F74},
{ 0x0F81, 0x0F71, 0x0F80},
{ 0x0FB9, 0x0F90, 0x0FB5},
{ 0x0F93, 0x0F92, 0x0FB7},
{ 0x0F9D, 0x0F9C, 0x0FB7},
{ 0x0FA2, 0x0FA1, 0x0FB7},
{ 0x0FA7, 0x0FA6, 0x0FB7},
{ 0x0FAC, 0x0FAB, 0x0FB7},
{ 0x0F76, 0x0FB2, 0x0F80},
{ 0x0F78, 0x0FB3, 0x0F80},
{ 0x1026, 0x1025, 0x102E},
{ 0x1B06, 0x1B05, 0x1B35},
{ 0x1B08, 0x1B07, 0x1B35},
{ 0x1B0A, 0x1B09, 0x1B35},
{ 0x1B0C, 0x1B0B, 0x1B35},
{ 0x1B0E, 0x1B0D, 0x1B35},
{ 0x1B12, 0x1B11, 0x1B35},
{ 0x1B3B, 0x1B3A, 0x1B35},
{ 0x1B3D, 0x1B3C, 0x1B35},
{ 0x1B40, 0x1B3E, 0x1B35},
{ 0x1B41, 0x1B3F, 0x1B35},
{ 0x1B43, 0x1B42, 0x1B35},
{ 0x1E38, 0x1E36, 0x0304},
{ 0x1E39, 0x1E37, 0x0304},
{ 0x1E5C, 0x1E5A, 0x0304},
{ 0x1E5D, 0x1E5B, 0x0304},
{ 0x1E68, 0x1E62, 0x0307},
{ 0x1E69, 0x1E63, 0x0307},
{ 0x1EAC, 0x1EA0, 0x0302},
{ 0x1EB6, 0x1EA0, 0x0306},
{ 0x1EAD, 0x1EA1, 0x0302},
{ 0x1EB7, 0x1EA1, 0x0306},
{ 0x1EC6, 0x1EB8, 0x0302},
{ 0x1EC7, 0x1EB9, 0x0302},
{ 0x1ED8, 0x1ECC, 0x0302},
{ 0x1ED9, 0x1ECD, 0x0302},
{ 0x1F02, 0x1F00, 0x0300},
{ 0x1F04, 0x1F00, 0x0301},
{ 0x1F06, 0x1F00, 0x0342},
{ 0x1F80, 0x1F00, 0x0345},
{ 0x1F03, 0x1F01, 0x0300},
{ 0x1F05, 0x1F01, 0x0301},
{ 0x1F07, 0x1F01, 0x0342},
{ 0x1F81, 0x1F01, 0x0345},
{ 0x1F82, 0x1F02, 0x0345},
{ 0x1F83, 0x1F03, 0x0345},
{ 0x1F84, 0x1F04, 0x0345},
{ 0x1F85, 0x1F05, 0x0345},
{ 0x1F86, 0x1F06, 0x0345},
{ 0x1F87, 0x1F07, 0x0345},
{ 0x1F0A, 0x1F08, 0x0300},
{ 0x1F0C, 0x1F08, 0x0301},
{ 0x1F0E, 0x1F08, 0x0342},
{ 0x1F88, 0x1F08, 0x0345},
{ 0x1F0B, 0x1F09, 0x0300},
{ 0x1F0D, 0x1F09, 0x0301},
{ 0x1F0F, 0x1F09, 0x0342},
{ 0x1F89, 0x1F09, 0x0345},
{ 0x1F8A, 0x1F0A, 0x0345},
{ 0x1F8B, 0x1F0B, 0x0345},
{ 0x1F8C, 0x1F0C, 0x0345},
{ 0x1F8D, 0x1F0D, 0x0345},
{ 0x1F8E, 0x1F0E, 0x0345},
{ 0x1F8F, 0x1F0F, 0x0345},
{ 0x1F12, 0x1F10, 0x0300},
{ 0x1F14, 0x1F10, 0x0301},
{ 0x1F13, 0x1F11, 0x0300},
{ 0x1F15, 0x1F11, 0x0301},
{ 0x1F1A, 0x1F18, 0x0300},
{ 0x1F1C, 0x1F18, 0x0301},
{ 0x1F1B, 0x1F19, 0x0300},
{ 0x1F1D, 0x1F19, 0x0301},
{ 0x1F22, 0x1F20, 0x0300},
{ 0x1F24, 0x1F20, 0x0301},
{ 0x1F26, 0x1F20, 0x0342},
{ 0x1F90, 0x1F20, 0x0345},
{ 0x1F23, 0x1F21, 0x0300},
{ 0x1F25, 0x1F21, 0x0301},
{ 0x1F27, 0x1F21, 0x0342},
{ 0x1F91, 0x1F21, 0x0345},
{ 0x1F92, 0x1F22, 0x0345},
{ 0x1F93, 0x1F23, 0x0345},
{ 0x1F94, 0x1F24, 0x0345},
{ 0x1F95, 0x1F25, 0x0345},
{ 0x1F96, 0x1F26, 0x0345},
{ 0x1F97, 0x1F27, 0x0345},
{ 0x1F2A, 0x1F28, 0x0300},
{ 0x1F2C, 0x1F28, 0x0301},
{ 0x1F2E, 0x1F28, 0x0342},
{ 0x1F98, 0x1F28, 0x0345},
{ 0x1F2B, 0x1F29, 0x0300},
{ 0x1F2D, 0x1F29, 0x0301},
{ 0x1F2F, 0x1F29, 0x0342},
{ 0x1F99, 0x1F29, 0x0345},
{ 0x1F9A, 0x1F2A, 0x0345},
{ 0x1F9B, 0x1F2B, 0x0345},
{ 0x1F9C, 0x1F2C, 0x0345},
{ 0x1F9D, 0x1F2D, 0x0345},
{ 0x1F9E, 0x1F2E, 0x0345},
{ 0x1F9F, 0x1F2F, 0x0345},
{ 0x1F32, 0x1F30, 0x0300},
{ 0x1F34, 0x1F30, 0x0301},
{ 0x1F36, 0x1F30, 0x0342},
{ 0x1F33, 0x1F31, 0x0300},
{ 0x1F35, 0x1F31, 0x0301},
{ 0x1F37, 0x1F31, 0x0342},
{ 0x1F3A, 0x1F38, 0x0300},
{ 0x1F3C, 0x1F38, 0x0301},
{ 0x1F3E, 0x1F38, 0x0342},
{ 0x1F3B, 0x1F39, 0x0300},
{ 0x1F3D, 0x1F39, 0x0301},
{ 0x1F3F, 0x1F39, 0x0342},
{ 0x1F42, 0x1F40, 0x0300},
{ 0x1F44, 0x1F40, 0x0301},
{ 0x1F43, 0x1F41, 0x0300},
{ 0x1F45, 0x1F41, 0x0301},
{ 0x1F4A, 0x1F48, 0x0300},
{ 0x1F4C, 0x1F48, 0x0301},
{ 0x1F4B, 0x1F49, 0x0300},
{ 0x1F4D, 0x1F49, 0x0301},
{ 0x1F52, 0x1F50, 0x0300},
{ 0x1F54, 0x1F50, 0x0301},
{ 0x1F56, 0x1F50, 0x0342},
{ 0x1F53, 0x1F51, 0x0300},
{ 0x1F55, 0x1F51, 0x0301},
{ 0x1F57, 0x1F51, 0x0342},
{ 0x1F5B, 0x1F59, 0x0300},
{ 0x1F5D, 0x1F59, 0x0301},
{ 0x1F5F, 0x1F59, 0x0342},
{ 0x1F62, 0x1F60, 0x0300},
{ 0x1F64, 0x1F60, 0x0301},
{ 0x1F66, 0x1F60, 0x0342},
{ 0x1FA0, 0x1F60, 0x0345},
{ 0x1F63, 0x1F61, 0x0300},
{ 0x1F65, 0x1F61, 0x0301},
{ 0x1F67, 0x1F61, 0x0342},
{ 0x1FA1, 0x1F61, 0x0345},
{ 0x1FA2, 0x1F62, 0x0345},
{ 0x1FA3, 0x1F63, 0x0345},
{ 0x1FA4, 0x1F64, 0x0345},
{ 0x1FA5, 0x1F65, 0x0345},
{ 0x1FA6, 0x1F66, 0x0345},
{ 0x1FA7, 0x1F67, 0x0345},
{ 0x1F6A, 0x1F68, 0x0300},
{ 0x1F6C, 0x1F68, 0x0301},
{ 0x1F6E, 0x1F68, 0x0342},
{ 0x1FA8, 0x1F68, 0x0345},
{ 0x1F6B, 0x1F69, 0x0300},
{ 0x1F6D, 0x1F69, 0x0301},
{ 0x1F6F, 0x1F69, 0x0342},
{ 0x1FA9, 0x1F69, 0x0345},
{ 0x1FAA, 0x1F6A, 0x0345},
{ 0x1FAB, 0x1F6B, 0x0345},
{ 0x1FAC, 0x1F6C, 0x0345},
{ 0x1FAD, 0x1F6D, 0x0345},
{ 0x1FAE, 0x1F6E, 0x0345},
{ 0x1FAF, 0x1F6F, 0x0345},
{ 0x1FB2, 0x1F70, 0x0345},
{ 0x1FC2, 0x1F74, 0x0345},
{ 0x1FF2, 0x1F7C, 0x0345},
{ 0x1FB7, 0x1FB6, 0x0345},
{ 0x1FCD, 0x1FBF, 0x0300},
{ 0x1FCE, 0x1FBF, 0x0301},
{ 0x1FCF, 0x1FBF, 0x0342},
{ 0x1FC7, 0x1FC6, 0x0345},
{ 0x1FF7, 0x1FF6, 0x0345},
{ 0x1FDD, 0x1FFE, 0x0300},
{ 0x1FDE, 0x1FFE, 0x0301},
{ 0x1FDF, 0x1FFE, 0x0342},
{ 0x219A, 0x2190, 0x0338},
{ 0x219B, 0x2192, 0x0338},
{ 0x21AE, 0x2194, 0x0338},
{ 0x21CD, 0x21D0, 0x0338},
{ 0x21CF, 0x21D2, 0x0338},
{ 0x21CE, 0x21D4, 0x0338},
{ 0x2204, 0x2203, 0x0338},
{ 0x2209, 0x2208, 0x0338},
{ 0x220C, 0x220B, 0x0338},
{ 0x2224, 0x2223, 0x0338},
{ 0x2226, 0x2225, 0x0338},
{ 0x2241, 0x223C, 0x0338},
{ 0x2244, 0x2243, 0x0338},
{ 0x2247, 0x2245, 0x0338},
{ 0x2249, 0x2248, 0x0338},
{ 0x226D, 0x224D, 0x0338},
{ 0x2262, 0x2261, 0x0338},
{ 0x2270, 0x2264, 0x0338},
{ 0x2271, 0x2265, 0x0338},
{ 0x2274, 0x2272, 0x0338},
{ 0x2275, 0x2273, 0x0338},
{ 0x2278, 0x2276, 0x0338},
{ 0x2279, 0x2277, 0x0338},
{ 0x2280, 0x227A, 0x0338},
{ 0x2281, 0x227B, 0x0338},
{ 0x22E0, 0x227C, 0x0338},
{ 0x22E1, 0x227D, 0x0338},
{ 0x2284, 0x2282, 0x0338},
{ 0x2285, 0x2283, 0x0338},
{ 0x2288, 0x2286, 0x0338},
{ 0x2289, 0x2287, 0x0338},
{ 0x22E2, 0x2291, 0x0338},
{ 0x22E3, 0x2292, 0x0338},
{ 0x22AC, 0x22A2, 0x0338},
{ 0x22AD, 0x22A8, 0x0338},
{ 0x22AE, 0x22A9, 0x0338},
{ 0x22AF, 0x22AB, 0x0338},
{ 0x22EA, 0x22B2, 0x0338},
{ 0x22EB, 0x22B3, 0x0338},
{ 0x22EC, 0x22B4, 0x0338},
{ 0x22ED, 0x22B5, 0x0338},
{ 0x2ADC, 0x2ADD, 0x0338},
{ 0x3094, 0x3046, 0x3099},
{ 0x304C, 0x304B, 0x3099},
{ 0x304E, 0x304D, 0x3099},
{ 0x3050, 0x304F, 0x3099},
{ 0x3052, 0x3051, 0x3099},
{ 0x3054, 0x3053, 0x3099},
{ 0x3056, 0x3055, 0x3099},
{ 0x3058, 0x3057, 0x3099},
{ 0x305A, 0x3059, 0x3099},
{ 0x305C, 0x305B, 0x3099},
{ 0x305E, 0x305D, 0x3099},
{ 0x3060, 0x305F, 0x3099},
{ 0x3062, 0x3061, 0x3099},
{ 0x3065, 0x3064, 0x3099},
{ 0x3067, 0x3066, 0x3099},
{ 0x3069, 0x3068, 0x3099},
{ 0x3070, 0x306F, 0x3099},
{ 0x3071, 0x306F, 0x309A},
{ 0x3073, 0x3072, 0x3099},
{ 0x3074, 0x3072, 0x309A},
{ 0x3076, 0x3075, 0x3099},
{ 0x3077, 0x3075, 0x309A},
{ 0x3079, 0x3078, 0x3099},
{ 0x307A, 0x3078, 0x309A},
{ 0x307C, 0x307B, 0x3099},
{ 0x307D, 0x307B, 0x309A},
{ 0x309E, 0x309D, 0x3099},
{ 0x30F4, 0x30A6, 0x3099},
{ 0x30AC, 0x30AB, 0x3099},
{ 0x30AE, 0x30AD, 0x3099},
{ 0x30B0, 0x30AF, 0x3099},
{ 0x30B2, 0x30B1, 0x3099},
{ 0x30B4, 0x30B3, 0x3099},
{ 0x30B6, 0x30B5, 0x3099},
{ 0x30B8, 0x30B7, 0x3099},
{ 0x30BA, 0x30B9, 0x3099},
{ 0x30BC, 0x30BB, 0x3099},
{ 0x30BE, 0x30BD, 0x3099},
{ 0x30C0, 0x30BF, 0x3099},
{ 0x30C2, 0x30C1, 0x3099},
{ 0x30C5, 0x30C4, 0x3099},
{ 0x30C7, 0x30C6, 0x3099},
{ 0x30C9, 0x30C8, 0x3099},
{ 0x30D0, 0x30CF, 0x3099},
{ 0x30D1, 0x30CF, 0x309A},
{ 0x30D3, 0x30D2, 0x3099},
{ 0x30D4, 0x30D2, 0x309A},
{ 0x30D6, 0x30D5, 0x3099},
{ 0x30D7, 0x30D5, 0x309A},
{ 0x30D9, 0x30D8, 0x3099},
{ 0x30DA, 0x30D8, 0x309A},
{ 0x30DC, 0x30DB, 0x3099},
{ 0x30DD, 0x30DB, 0x309A},
{ 0x30F7, 0x30EF, 0x3099},
{ 0x30F8, 0x30F0, 0x3099},
{ 0x30F9, 0x30F1, 0x3099},
{ 0x30FA, 0x30F2, 0x3099},
{ 0x30FE, 0x30FD, 0x3099},
{ 0xFB2C, 0xFB49, 0x05C1},
{ 0xFB2D, 0xFB49, 0x05C2},
{ 0x1109A, 0x11099, 0x110BA},
{ 0x1109C, 0x1109B, 0x110BA},
{ 0x110AB, 0x110A5, 0x110BA},
{ 0x1112E, 0x11131, 0x11127},
{ 0x1112F, 0x11132, 0x11127},
{ 0x1134B, 0x11347, 0x1133E},
{ 0x1134C, 0x11347, 0x11357},
{ 0x114BC, 0x114B9, 0x114B0},
{ 0x114BB, 0x114B9, 0x114BA},
{ 0x114BE, 0x114B9, 0x114BD},
{ 0x115BA, 0x115B8, 0x115AF},
{ 0x115BB, 0x115B9, 0x115AF},
{ 0x1D15E, 0x1D157, 0x1D165},
{ 0x1D15F, 0x1D158, 0x1D165},
{ 0x1D160, 0x1D15F, 0x1D16E},
{ 0x1D161, 0x1D15F, 0x1D16F},
{ 0x1D162, 0x1D15F, 0x1D170},
{ 0x1D163, 0x1D15F, 0x1D171},
{ 0x1D164, 0x1D15F, 0x1D172},
{ 0x1D1BB, 0x1D1B9, 0x1D165},
{ 0x1D1BC, 0x1D1BA, 0x1D165},
{ 0x1D1BD, 0x1D1BB, 0x1D16E},
{ 0x1D1BF, 0x1D1BB, 0x1D16F},
{ 0x1D1BE, 0x1D1BC, 0x1D16E},
{ 0x1D1C0, 0x1D1BC, 0x1D16F},
};

#define UNICODE_SHIFT 21

int do_precomposition(int base, int comb) {
  int min = 0;
  int max = sizeof(precompositions) / sizeof(precompositions[0]) - 1;
  unsigned long sought = ((unsigned) base << UNICODE_SHIFT) | (unsigned) comb;

  /* binary search */
  while (max >= min) {
    int mid = (min + max) / 2;
    unsigned long that = ((unsigned long) precompositions[mid].base << UNICODE_SHIFT) | ((unsigned) precompositions[mid].comb);
    if (that < sought) {
      min = mid + 1;
    } else if (that > sought) {
      max = mid - 1;
    } else {
      return precompositions[mid].replacement;
    }
  }
  /* no match */
  return -1;
}
xterm-330/main.h0000644000175100001440000001315313027062462012341 0ustar  tomusers/* $XTermId: main.h,v 1.63 2016/12/22 23:43:46 tom Exp $ */

/*
 * Copyright 2000-2013,2016 by Thomas E. Dickey
 *
 *                         All Rights Reserved
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name(s) of the above copyright
 * holders shall not be used in advertising or otherwise to promote the
 * sale, use or other dealings in this Software without prior written
 * authorization.
 *
 * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 *
 *                         All Rights Reserved
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose and without fee is hereby granted,
 * provided that the above copyright notice appear in all copies and that
 * both that copyright notice and this permission notice appear in
 * supporting documentation, and that the name of Digital Equipment
 * Corporation not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 *
 *
 * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */
#ifndef included_main_h
#define included_main_h

#include 

#ifndef DEFCLASS
#define DEFCLASS		"XTerm"
#endif

#ifndef DEFFONT
#define DEFFONT			"fixed"
#endif

#ifndef DEFWIDEFONT
#define DEFWIDEFONT		NULL	/* grab one which is 2x as wide */
#endif

#ifndef DEFWIDEBOLDFONT
#define DEFWIDEBOLDFONT		NULL
#endif

#ifndef DEFXIMFONT
#define DEFXIMFONT		"fixed"
#endif

#ifndef DEFBOLDFONT
#define DEFBOLDFONT		NULL	/* no bold font uses overstriking */
#endif

#ifndef DEFBORDER
#define DEFBORDER		2
#endif

#ifndef DEFFACENAME
#define DEFFACENAME		NULL
#endif

#ifndef DEFFACENAME_AUTO
#define DEFFACENAME_AUTO	"mono"
#endif

#ifndef DEFFACESIZE
#define DEFFACESIZE		"14.0"
#endif

#ifndef DEF_ALLOW_COLOR
#define DEF_ALLOW_COLOR		True
#endif

#ifndef DEF_ALLOW_FONT
#define DEF_ALLOW_FONT		True
#endif

#ifndef DEF_ALLOW_MOUSE
#define DEF_ALLOW_MOUSE		True
#endif

#ifndef DEF_ALLOW_TCAP
#define DEF_ALLOW_TCAP		True
#endif

#ifndef DEF_ALLOW_TITLE
#define DEF_ALLOW_TITLE		True
#endif

#ifndef DEF_ALLOW_WINDOW
#define DEF_ALLOW_WINDOW	False
#endif

#ifndef DEF_DISALLOWED_COLOR
#define DEF_DISALLOWED_COLOR	"SetColor,GetColor,GetAnsiColor"
#endif

#ifndef DEF_DISALLOWED_FONT
#define DEF_DISALLOWED_FONT	"SetFont,GetFont"
#endif

#ifndef DEF_DISALLOWED_MOUSE
#define DEF_DISALLOWED_MOUSE	"*"
#endif

#ifndef DEF_DISALLOWED_TCAP
#define DEF_DISALLOWED_TCAP	"SetTcap,GetTcap"
#endif

#ifndef DEF_DISALLOWED_WINDOW
#define DEF_DISALLOWED_WINDOW	"20,21,SetXprop,SetSelection"
#endif

#if OPT_BLINK_TEXT
#define DEFBLINKASBOLD		False
#else
#define DEFBLINKASBOLD		True
#endif

#ifndef DEFDELETE_DEL
#define DEFDELETE_DEL		Maybe
#endif

#ifndef DEF_BACKARO_ERASE
#define DEF_BACKARO_ERASE	False
#endif

#ifndef DEF_BACKARO_BS
#define DEF_BACKARO_BS		True
#endif

#ifndef DEF_ALT_SENDS_ESC
#define DEF_ALT_SENDS_ESC	False
#endif

#ifndef DEF_META_SENDS_ESC
#define DEF_META_SENDS_ESC	False
#endif

#ifndef DEF_8BIT_META
#define DEF_8BIT_META		"true"	/* eightBitMeta */
#endif

#ifndef DEF_COLOR4
#define DEF_COLOR4		"blue2"		/* see XTerm-col.ad */
#endif

#ifndef DEF_COLOR12
#define DEF_COLOR12		"rgb:5c/5c/ff"	/* see XTerm-col.ad */
#endif

#ifndef DEF_INITIAL_ERASE
#define DEF_INITIAL_ERASE	False
#endif

#ifndef DEF_MENU_LOCALE
#define DEF_MENU_LOCALE		"C"
#endif

#ifndef DEF_POINTER_MODE
#define DEF_POINTER_MODE	pNoMouse
#endif

#ifndef DEF_PTY_STTY_SIZE
#if defined(linux) || defined(__APPLE__)
#define DEF_PTY_STTY_SIZE	False
#else
#define DEF_PTY_STTY_SIZE	True
#endif
#endif

#ifndef DEF_TITLE_MODES
#define DEF_TITLE_MODES		0
#endif

#ifndef PROJECTROOT
#define PROJECTROOT		"/usr/X11R6"
#endif

/*
 * The configure script quotes PROJECTROOT's value.
 * imake does not quote PROJECTROOT's value.
 */
#ifdef HAVE_CONFIG_H
#define DEFLOCALEFILTER2(x)	x
#else
#define DEFLOCALEFILTER2(x)	#x
#endif

/*
 * If the configure script finds luit, we have the path directly.
 */
#ifdef LUIT_PATH
#define DEFLOCALEFILTER		LUIT_PATH
#else
#define DEFLOCALEFILTER1(x)	DEFLOCALEFILTER2(x)
#define DEFLOCALEFILTER		DEFLOCALEFILTER1(PROJECTROOT) "/bin/luit"
#endif

/*
 * See lib/Xt/Resources.c
 */
#define MAXRESOURCES            400

#endif /* included_main_h */
xterm-330/keysym2ucs.c0000644000175100001440000020540612720412435013530 0ustar  tomusers/* $XTermId: keysym2ucs.c,v 1.16 2016/05/22 20:22:53 tom Exp $
 * This module converts keysym values into the corresponding ISO 10646
 * (UCS, Unicode) values.
 *
 * The array keysymtab[] contains pairs of X11 keysym values for graphical
 * characters and the corresponding Unicode value. The function
 * keysym2ucs() maps a keysym onto a Unicode value using a binary search,
 * therefore keysymtab[] must remain SORTED by keysym value.
 *
 * The keysym -> UTF-8 conversion will hopefully one day be provided
 * by Xlib via XmbLookupString() and should ideally not have to be
 * done in X applications. But we are not there yet.
 *
 * We allow to represent any UCS character in the range U-00000000 to
 * U-00FFFFFF by a keysym value in the range 0x01000000 to 0x01ffffff.
 * This admittedly does not cover the entire 31-bit space of UCS, but
 * it does cover all of the characters up to U-10FFFF, which can be
 * represented by UTF-16, and more, and it is very unlikely that higher
 * UCS codes will ever be assigned by ISO. So to get Unicode character
 * U+ABCD you can directly use keysym 0x0100abcd.
 *
 * NOTE: The comments in the table below contain the actual character
 * encoded in UTF-8, so for viewing and editing best use an editor in
 * UTF-8 mode.
 *
 * Author: Markus G. Kuhn , University of Cambridge, April 2001
 *
 * Special thanks to Richard Verhoeven  for preparing
 * an initial draft of the mapping table.
 *
 * This software is in the public domain. Share and enjoy!
 *
 * AUTOMATICALLY GENERATED FILE, DO NOT EDIT !!! (unicode/convmap.pl)
 */

#ifndef KEYSYM2UCS_INCLUDED
  
#include "keysym2ucs.h"
#define VISIBLE /* */

#else

#define VISIBLE static

#endif

static struct codepair {
  unsigned short keysym;
  unsigned short ucs;
} keysymtab[] = {
  { 0x01a1, 0x0104 }, /*                     Aogonek Ä„ LATIN CAPITAL LETTER A WITH OGONEK */
  { 0x01a2, 0x02d8 }, /*                       breve ˘ BREVE */
  { 0x01a3, 0x0141 }, /*                     Lstroke Å LATIN CAPITAL LETTER L WITH STROKE */
  { 0x01a5, 0x013d }, /*                      Lcaron Ľ LATIN CAPITAL LETTER L WITH CARON */
  { 0x01a6, 0x015a }, /*                      Sacute Åš LATIN CAPITAL LETTER S WITH ACUTE */
  { 0x01a9, 0x0160 }, /*                      Scaron Å  LATIN CAPITAL LETTER S WITH CARON */
  { 0x01aa, 0x015e }, /*                    Scedilla Åž LATIN CAPITAL LETTER S WITH CEDILLA */
  { 0x01ab, 0x0164 }, /*                      Tcaron Ť LATIN CAPITAL LETTER T WITH CARON */
  { 0x01ac, 0x0179 }, /*                      Zacute Ź LATIN CAPITAL LETTER Z WITH ACUTE */
  { 0x01ae, 0x017d }, /*                      Zcaron Ž LATIN CAPITAL LETTER Z WITH CARON */
  { 0x01af, 0x017b }, /*                   Zabovedot Å» LATIN CAPITAL LETTER Z WITH DOT ABOVE */
  { 0x01b1, 0x0105 }, /*                     aogonek Ä… LATIN SMALL LETTER A WITH OGONEK */
  { 0x01b2, 0x02db }, /*                      ogonek Ë› OGONEK */
  { 0x01b3, 0x0142 }, /*                     lstroke Å‚ LATIN SMALL LETTER L WITH STROKE */
  { 0x01b5, 0x013e }, /*                      lcaron ľ LATIN SMALL LETTER L WITH CARON */
  { 0x01b6, 0x015b }, /*                      sacute Å› LATIN SMALL LETTER S WITH ACUTE */
  { 0x01b7, 0x02c7 }, /*                       caron ˇ CARON */
  { 0x01b9, 0x0161 }, /*                      scaron Å¡ LATIN SMALL LETTER S WITH CARON */
  { 0x01ba, 0x015f }, /*                    scedilla ÅŸ LATIN SMALL LETTER S WITH CEDILLA */
  { 0x01bb, 0x0165 }, /*                      tcaron ť LATIN SMALL LETTER T WITH CARON */
  { 0x01bc, 0x017a }, /*                      zacute ź LATIN SMALL LETTER Z WITH ACUTE */
  { 0x01bd, 0x02dd }, /*                 doubleacute Ë DOUBLE ACUTE ACCENT */
  { 0x01be, 0x017e }, /*                      zcaron ž LATIN SMALL LETTER Z WITH CARON */
  { 0x01bf, 0x017c }, /*                   zabovedot ż LATIN SMALL LETTER Z WITH DOT ABOVE */
  { 0x01c0, 0x0154 }, /*                      Racute Å” LATIN CAPITAL LETTER R WITH ACUTE */
  { 0x01c3, 0x0102 }, /*                      Abreve Ä‚ LATIN CAPITAL LETTER A WITH BREVE */
  { 0x01c5, 0x0139 }, /*                      Lacute Ĺ LATIN CAPITAL LETTER L WITH ACUTE */
  { 0x01c6, 0x0106 }, /*                      Cacute Ć LATIN CAPITAL LETTER C WITH ACUTE */
  { 0x01c8, 0x010c }, /*                      Ccaron Č LATIN CAPITAL LETTER C WITH CARON */
  { 0x01ca, 0x0118 }, /*                     Eogonek Ę LATIN CAPITAL LETTER E WITH OGONEK */
  { 0x01cc, 0x011a }, /*                      Ecaron Äš LATIN CAPITAL LETTER E WITH CARON */
  { 0x01cf, 0x010e }, /*                      Dcaron ÄŽ LATIN CAPITAL LETTER D WITH CARON */
  { 0x01d0, 0x0110 }, /*                     Dstroke Ä LATIN CAPITAL LETTER D WITH STROKE */
  { 0x01d1, 0x0143 }, /*                      Nacute Ń LATIN CAPITAL LETTER N WITH ACUTE */
  { 0x01d2, 0x0147 }, /*                      Ncaron Ň LATIN CAPITAL LETTER N WITH CARON */
  { 0x01d5, 0x0150 }, /*                Odoubleacute Å LATIN CAPITAL LETTER O WITH DOUBLE ACUTE */
  { 0x01d8, 0x0158 }, /*                      Rcaron Ř LATIN CAPITAL LETTER R WITH CARON */
  { 0x01d9, 0x016e }, /*                       Uring Å® LATIN CAPITAL LETTER U WITH RING ABOVE */
  { 0x01db, 0x0170 }, /*                Udoubleacute Ű LATIN CAPITAL LETTER U WITH DOUBLE ACUTE */
  { 0x01de, 0x0162 }, /*                    Tcedilla Ţ LATIN CAPITAL LETTER T WITH CEDILLA */
  { 0x01e0, 0x0155 }, /*                      racute Å• LATIN SMALL LETTER R WITH ACUTE */
  { 0x01e3, 0x0103 }, /*                      abreve ă LATIN SMALL LETTER A WITH BREVE */
  { 0x01e5, 0x013a }, /*                      lacute ĺ LATIN SMALL LETTER L WITH ACUTE */
  { 0x01e6, 0x0107 }, /*                      cacute ć LATIN SMALL LETTER C WITH ACUTE */
  { 0x01e8, 0x010d }, /*                      ccaron Ä LATIN SMALL LETTER C WITH CARON */
  { 0x01ea, 0x0119 }, /*                     eogonek Ä™ LATIN SMALL LETTER E WITH OGONEK */
  { 0x01ec, 0x011b }, /*                      ecaron Ä› LATIN SMALL LETTER E WITH CARON */
  { 0x01ef, 0x010f }, /*                      dcaron Ä LATIN SMALL LETTER D WITH CARON */
  { 0x01f0, 0x0111 }, /*                     dstroke Ä‘ LATIN SMALL LETTER D WITH STROKE */
  { 0x01f1, 0x0144 }, /*                      nacute Å„ LATIN SMALL LETTER N WITH ACUTE */
  { 0x01f2, 0x0148 }, /*                      ncaron ň LATIN SMALL LETTER N WITH CARON */
  { 0x01f5, 0x0151 }, /*                odoubleacute Å‘ LATIN SMALL LETTER O WITH DOUBLE ACUTE */
  { 0x01f8, 0x0159 }, /*                      rcaron Å™ LATIN SMALL LETTER R WITH CARON */
  { 0x01f9, 0x016f }, /*                       uring ů LATIN SMALL LETTER U WITH RING ABOVE */
  { 0x01fb, 0x0171 }, /*                udoubleacute ű LATIN SMALL LETTER U WITH DOUBLE ACUTE */
  { 0x01fe, 0x0163 }, /*                    tcedilla ţ LATIN SMALL LETTER T WITH CEDILLA */
  { 0x01ff, 0x02d9 }, /*                    abovedot Ë™ DOT ABOVE */
  { 0x02a1, 0x0126 }, /*                     Hstroke Ħ LATIN CAPITAL LETTER H WITH STROKE */
  { 0x02a6, 0x0124 }, /*                 Hcircumflex Ĥ LATIN CAPITAL LETTER H WITH CIRCUMFLEX */
  { 0x02a9, 0x0130 }, /*                   Iabovedot İ LATIN CAPITAL LETTER I WITH DOT ABOVE */
  { 0x02ab, 0x011e }, /*                      Gbreve Äž LATIN CAPITAL LETTER G WITH BREVE */
  { 0x02ac, 0x0134 }, /*                 Jcircumflex Ä´ LATIN CAPITAL LETTER J WITH CIRCUMFLEX */
  { 0x02b1, 0x0127 }, /*                     hstroke ħ LATIN SMALL LETTER H WITH STROKE */
  { 0x02b6, 0x0125 }, /*                 hcircumflex ĥ LATIN SMALL LETTER H WITH CIRCUMFLEX */
  { 0x02b9, 0x0131 }, /*                    idotless ı LATIN SMALL LETTER DOTLESS I */
  { 0x02bb, 0x011f }, /*                      gbreve ÄŸ LATIN SMALL LETTER G WITH BREVE */
  { 0x02bc, 0x0135 }, /*                 jcircumflex ĵ LATIN SMALL LETTER J WITH CIRCUMFLEX */
  { 0x02c5, 0x010a }, /*                   Cabovedot ÄŠ LATIN CAPITAL LETTER C WITH DOT ABOVE */
  { 0x02c6, 0x0108 }, /*                 Ccircumflex Ĉ LATIN CAPITAL LETTER C WITH CIRCUMFLEX */
  { 0x02d5, 0x0120 }, /*                   Gabovedot Ä  LATIN CAPITAL LETTER G WITH DOT ABOVE */
  { 0x02d8, 0x011c }, /*                 Gcircumflex Ĝ LATIN CAPITAL LETTER G WITH CIRCUMFLEX */
  { 0x02dd, 0x016c }, /*                      Ubreve Ŭ LATIN CAPITAL LETTER U WITH BREVE */
  { 0x02de, 0x015c }, /*                 Scircumflex Ŝ LATIN CAPITAL LETTER S WITH CIRCUMFLEX */
  { 0x02e5, 0x010b }, /*                   cabovedot Ä‹ LATIN SMALL LETTER C WITH DOT ABOVE */
  { 0x02e6, 0x0109 }, /*                 ccircumflex ĉ LATIN SMALL LETTER C WITH CIRCUMFLEX */
  { 0x02f5, 0x0121 }, /*                   gabovedot Ä¡ LATIN SMALL LETTER G WITH DOT ABOVE */
  { 0x02f8, 0x011d }, /*                 gcircumflex Ä LATIN SMALL LETTER G WITH CIRCUMFLEX */
  { 0x02fd, 0x016d }, /*                      ubreve Å­ LATIN SMALL LETTER U WITH BREVE */
  { 0x02fe, 0x015d }, /*                 scircumflex Å LATIN SMALL LETTER S WITH CIRCUMFLEX */
  { 0x03a2, 0x0138 }, /*                         kra ĸ LATIN SMALL LETTER KRA */
  { 0x03a3, 0x0156 }, /*                    Rcedilla Å– LATIN CAPITAL LETTER R WITH CEDILLA */
  { 0x03a5, 0x0128 }, /*                      Itilde Ĩ LATIN CAPITAL LETTER I WITH TILDE */
  { 0x03a6, 0x013b }, /*                    Lcedilla Ä» LATIN CAPITAL LETTER L WITH CEDILLA */
  { 0x03aa, 0x0112 }, /*                     Emacron Ä’ LATIN CAPITAL LETTER E WITH MACRON */
  { 0x03ab, 0x0122 }, /*                    Gcedilla Ģ LATIN CAPITAL LETTER G WITH CEDILLA */
  { 0x03ac, 0x0166 }, /*                      Tslash Ŧ LATIN CAPITAL LETTER T WITH STROKE */
  { 0x03b3, 0x0157 }, /*                    rcedilla Å— LATIN SMALL LETTER R WITH CEDILLA */
  { 0x03b5, 0x0129 }, /*                      itilde Ä© LATIN SMALL LETTER I WITH TILDE */
  { 0x03b6, 0x013c }, /*                    lcedilla ļ LATIN SMALL LETTER L WITH CEDILLA */
  { 0x03ba, 0x0113 }, /*                     emacron Ä“ LATIN SMALL LETTER E WITH MACRON */
  { 0x03bb, 0x0123 }, /*                    gcedilla ģ LATIN SMALL LETTER G WITH CEDILLA */
  { 0x03bc, 0x0167 }, /*                      tslash ŧ LATIN SMALL LETTER T WITH STROKE */
  { 0x03bd, 0x014a }, /*                         ENG ÅŠ LATIN CAPITAL LETTER ENG */
  { 0x03bf, 0x014b }, /*                         eng Å‹ LATIN SMALL LETTER ENG */
  { 0x03c0, 0x0100 }, /*                     Amacron Ā LATIN CAPITAL LETTER A WITH MACRON */
  { 0x03c7, 0x012e }, /*                     Iogonek Ä® LATIN CAPITAL LETTER I WITH OGONEK */
  { 0x03cc, 0x0116 }, /*                   Eabovedot Ä– LATIN CAPITAL LETTER E WITH DOT ABOVE */
  { 0x03cf, 0x012a }, /*                     Imacron Ī LATIN CAPITAL LETTER I WITH MACRON */
  { 0x03d1, 0x0145 }, /*                    Ncedilla Å… LATIN CAPITAL LETTER N WITH CEDILLA */
  { 0x03d2, 0x014c }, /*                     Omacron Ō LATIN CAPITAL LETTER O WITH MACRON */
  { 0x03d3, 0x0136 }, /*                    Kcedilla Ķ LATIN CAPITAL LETTER K WITH CEDILLA */
  { 0x03d9, 0x0172 }, /*                     Uogonek Ų LATIN CAPITAL LETTER U WITH OGONEK */
  { 0x03dd, 0x0168 }, /*                      Utilde Ũ LATIN CAPITAL LETTER U WITH TILDE */
  { 0x03de, 0x016a }, /*                     Umacron Ū LATIN CAPITAL LETTER U WITH MACRON */
  { 0x03e0, 0x0101 }, /*                     amacron Ä LATIN SMALL LETTER A WITH MACRON */
  { 0x03e7, 0x012f }, /*                     iogonek į LATIN SMALL LETTER I WITH OGONEK */
  { 0x03ec, 0x0117 }, /*                   eabovedot Ä— LATIN SMALL LETTER E WITH DOT ABOVE */
  { 0x03ef, 0x012b }, /*                     imacron Ä« LATIN SMALL LETTER I WITH MACRON */
  { 0x03f1, 0x0146 }, /*                    ncedilla ņ LATIN SMALL LETTER N WITH CEDILLA */
  { 0x03f2, 0x014d }, /*                     omacron Å LATIN SMALL LETTER O WITH MACRON */
  { 0x03f3, 0x0137 }, /*                    kcedilla Ä· LATIN SMALL LETTER K WITH CEDILLA */
  { 0x03f9, 0x0173 }, /*                     uogonek ų LATIN SMALL LETTER U WITH OGONEK */
  { 0x03fd, 0x0169 }, /*                      utilde Å© LATIN SMALL LETTER U WITH TILDE */
  { 0x03fe, 0x016b }, /*                     umacron Å« LATIN SMALL LETTER U WITH MACRON */
  { 0x047e, 0x203e }, /*                    overline ‾ OVERLINE */
  { 0x04a1, 0x3002 }, /*               kana_fullstop 。 IDEOGRAPHIC FULL STOP */
  { 0x04a2, 0x300c }, /*         kana_openingbracket 「 LEFT CORNER BRACKET */
  { 0x04a3, 0x300d }, /*         kana_closingbracket 〠RIGHT CORNER BRACKET */
  { 0x04a4, 0x3001 }, /*                  kana_comma 〠IDEOGRAPHIC COMMA */
  { 0x04a5, 0x30fb }, /*            kana_conjunctive ・ KATAKANA MIDDLE DOT */
  { 0x04a6, 0x30f2 }, /*                     kana_WO ヲ KATAKANA LETTER WO */
  { 0x04a7, 0x30a1 }, /*                      kana_a ã‚¡ KATAKANA LETTER SMALL A */
  { 0x04a8, 0x30a3 }, /*                      kana_i ã‚£ KATAKANA LETTER SMALL I */
  { 0x04a9, 0x30a5 }, /*                      kana_u ã‚¥ KATAKANA LETTER SMALL U */
  { 0x04aa, 0x30a7 }, /*                      kana_e ã‚§ KATAKANA LETTER SMALL E */
  { 0x04ab, 0x30a9 }, /*                      kana_o ã‚© KATAKANA LETTER SMALL O */
  { 0x04ac, 0x30e3 }, /*                     kana_ya ャ KATAKANA LETTER SMALL YA */
  { 0x04ad, 0x30e5 }, /*                     kana_yu ュ KATAKANA LETTER SMALL YU */
  { 0x04ae, 0x30e7 }, /*                     kana_yo ョ KATAKANA LETTER SMALL YO */
  { 0x04af, 0x30c3 }, /*                    kana_tsu ッ KATAKANA LETTER SMALL TU */
  { 0x04b0, 0x30fc }, /*              prolongedsound ー KATAKANA-HIRAGANA PROLONGED SOUND MARK */
  { 0x04b1, 0x30a2 }, /*                      kana_A ã‚¢ KATAKANA LETTER A */
  { 0x04b2, 0x30a4 }, /*                      kana_I イ KATAKANA LETTER I */
  { 0x04b3, 0x30a6 }, /*                      kana_U ウ KATAKANA LETTER U */
  { 0x04b4, 0x30a8 }, /*                      kana_E エ KATAKANA LETTER E */
  { 0x04b5, 0x30aa }, /*                      kana_O オ KATAKANA LETTER O */
  { 0x04b6, 0x30ab }, /*                     kana_KA ã‚« KATAKANA LETTER KA */
  { 0x04b7, 0x30ad }, /*                     kana_KI ã‚­ KATAKANA LETTER KI */
  { 0x04b8, 0x30af }, /*                     kana_KU ク KATAKANA LETTER KU */
  { 0x04b9, 0x30b1 }, /*                     kana_KE ケ KATAKANA LETTER KE */
  { 0x04ba, 0x30b3 }, /*                     kana_KO コ KATAKANA LETTER KO */
  { 0x04bb, 0x30b5 }, /*                     kana_SA サ KATAKANA LETTER SA */
  { 0x04bc, 0x30b7 }, /*                    kana_SHI ã‚· KATAKANA LETTER SI */
  { 0x04bd, 0x30b9 }, /*                     kana_SU ス KATAKANA LETTER SU */
  { 0x04be, 0x30bb }, /*                     kana_SE ã‚» KATAKANA LETTER SE */
  { 0x04bf, 0x30bd }, /*                     kana_SO ソ KATAKANA LETTER SO */
  { 0x04c0, 0x30bf }, /*                     kana_TA ã‚¿ KATAKANA LETTER TA */
  { 0x04c1, 0x30c1 }, /*                    kana_CHI ムKATAKANA LETTER TI */
  { 0x04c2, 0x30c4 }, /*                    kana_TSU ツ KATAKANA LETTER TU */
  { 0x04c3, 0x30c6 }, /*                     kana_TE テ KATAKANA LETTER TE */
  { 0x04c4, 0x30c8 }, /*                     kana_TO ト KATAKANA LETTER TO */
  { 0x04c5, 0x30ca }, /*                     kana_NA ナ KATAKANA LETTER NA */
  { 0x04c6, 0x30cb }, /*                     kana_NI ニ KATAKANA LETTER NI */
  { 0x04c7, 0x30cc }, /*                     kana_NU ヌ KATAKANA LETTER NU */
  { 0x04c8, 0x30cd }, /*                     kana_NE ムKATAKANA LETTER NE */
  { 0x04c9, 0x30ce }, /*                     kana_NO ノ KATAKANA LETTER NO */
  { 0x04ca, 0x30cf }, /*                     kana_HA ムKATAKANA LETTER HA */
  { 0x04cb, 0x30d2 }, /*                     kana_HI ヒ KATAKANA LETTER HI */
  { 0x04cc, 0x30d5 }, /*                     kana_FU フ KATAKANA LETTER HU */
  { 0x04cd, 0x30d8 }, /*                     kana_HE ヘ KATAKANA LETTER HE */
  { 0x04ce, 0x30db }, /*                     kana_HO ホ KATAKANA LETTER HO */
  { 0x04cf, 0x30de }, /*                     kana_MA マ KATAKANA LETTER MA */
  { 0x04d0, 0x30df }, /*                     kana_MI ミ KATAKANA LETTER MI */
  { 0x04d1, 0x30e0 }, /*                     kana_MU ム KATAKANA LETTER MU */
  { 0x04d2, 0x30e1 }, /*                     kana_ME メ KATAKANA LETTER ME */
  { 0x04d3, 0x30e2 }, /*                     kana_MO モ KATAKANA LETTER MO */
  { 0x04d4, 0x30e4 }, /*                     kana_YA ヤ KATAKANA LETTER YA */
  { 0x04d5, 0x30e6 }, /*                     kana_YU ユ KATAKANA LETTER YU */
  { 0x04d6, 0x30e8 }, /*                     kana_YO ヨ KATAKANA LETTER YO */
  { 0x04d7, 0x30e9 }, /*                     kana_RA ラ KATAKANA LETTER RA */
  { 0x04d8, 0x30ea }, /*                     kana_RI リ KATAKANA LETTER RI */
  { 0x04d9, 0x30eb }, /*                     kana_RU ル KATAKANA LETTER RU */
  { 0x04da, 0x30ec }, /*                     kana_RE レ KATAKANA LETTER RE */
  { 0x04db, 0x30ed }, /*                     kana_RO ロ KATAKANA LETTER RO */
  { 0x04dc, 0x30ef }, /*                     kana_WA ワ KATAKANA LETTER WA */
  { 0x04dd, 0x30f3 }, /*                      kana_N ン KATAKANA LETTER N */
  { 0x04de, 0x309b }, /*                 voicedsound ã‚› KATAKANA-HIRAGANA VOICED SOUND MARK */
  { 0x04df, 0x309c }, /*             semivoicedsound ゜ KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK */
  { 0x05ac, 0x060c }, /*                Arabic_comma ، ARABIC COMMA */
  { 0x05bb, 0x061b }, /*            Arabic_semicolon Ø› ARABIC SEMICOLON */
  { 0x05bf, 0x061f }, /*        Arabic_question_mark ØŸ ARABIC QUESTION MARK */
  { 0x05c1, 0x0621 }, /*                Arabic_hamza Ø¡ ARABIC LETTER HAMZA */
  { 0x05c2, 0x0622 }, /*          Arabic_maddaonalef آ ARABIC LETTER ALEF WITH MADDA ABOVE */
  { 0x05c3, 0x0623 }, /*          Arabic_hamzaonalef أ ARABIC LETTER ALEF WITH HAMZA ABOVE */
  { 0x05c4, 0x0624 }, /*           Arabic_hamzaonwaw ؤ ARABIC LETTER WAW WITH HAMZA ABOVE */
  { 0x05c5, 0x0625 }, /*       Arabic_hamzaunderalef إ ARABIC LETTER ALEF WITH HAMZA BELOW */
  { 0x05c6, 0x0626 }, /*           Arabic_hamzaonyeh ئ ARABIC LETTER YEH WITH HAMZA ABOVE */
  { 0x05c7, 0x0627 }, /*                 Arabic_alef ا ARABIC LETTER ALEF */
  { 0x05c8, 0x0628 }, /*                  Arabic_beh ب ARABIC LETTER BEH */
  { 0x05c9, 0x0629 }, /*           Arabic_tehmarbuta Ø© ARABIC LETTER TEH MARBUTA */
  { 0x05ca, 0x062a }, /*                  Arabic_teh ت ARABIC LETTER TEH */
  { 0x05cb, 0x062b }, /*                 Arabic_theh Ø« ARABIC LETTER THEH */
  { 0x05cc, 0x062c }, /*                 Arabic_jeem ج ARABIC LETTER JEEM */
  { 0x05cd, 0x062d }, /*                  Arabic_hah Ø­ ARABIC LETTER HAH */
  { 0x05ce, 0x062e }, /*                 Arabic_khah Ø® ARABIC LETTER KHAH */
  { 0x05cf, 0x062f }, /*                  Arabic_dal د ARABIC LETTER DAL */
  { 0x05d0, 0x0630 }, /*                 Arabic_thal ذ ARABIC LETTER THAL */
  { 0x05d1, 0x0631 }, /*                   Arabic_ra ر ARABIC LETTER REH */
  { 0x05d2, 0x0632 }, /*                 Arabic_zain ز ARABIC LETTER ZAIN */
  { 0x05d3, 0x0633 }, /*                 Arabic_seen س ARABIC LETTER SEEN */
  { 0x05d4, 0x0634 }, /*                Arabic_sheen Ø´ ARABIC LETTER SHEEN */
  { 0x05d5, 0x0635 }, /*                  Arabic_sad ص ARABIC LETTER SAD */
  { 0x05d6, 0x0636 }, /*                  Arabic_dad ض ARABIC LETTER DAD */
  { 0x05d7, 0x0637 }, /*                  Arabic_tah Ø· ARABIC LETTER TAH */
  { 0x05d8, 0x0638 }, /*                  Arabic_zah ظ ARABIC LETTER ZAH */
  { 0x05d9, 0x0639 }, /*                  Arabic_ain ع ARABIC LETTER AIN */
  { 0x05da, 0x063a }, /*                Arabic_ghain غ ARABIC LETTER GHAIN */
  { 0x05e0, 0x0640 }, /*              Arabic_tatweel Ù€ ARABIC TATWEEL */
  { 0x05e1, 0x0641 }, /*                  Arabic_feh Ù ARABIC LETTER FEH */
  { 0x05e2, 0x0642 }, /*                  Arabic_qaf Ù‚ ARABIC LETTER QAF */
  { 0x05e3, 0x0643 }, /*                  Arabic_kaf Ùƒ ARABIC LETTER KAF */
  { 0x05e4, 0x0644 }, /*                  Arabic_lam Ù„ ARABIC LETTER LAM */
  { 0x05e5, 0x0645 }, /*                 Arabic_meem Ù… ARABIC LETTER MEEM */
  { 0x05e6, 0x0646 }, /*                 Arabic_noon Ù† ARABIC LETTER NOON */
  { 0x05e7, 0x0647 }, /*                   Arabic_ha Ù‡ ARABIC LETTER HEH */
  { 0x05e8, 0x0648 }, /*                  Arabic_waw Ùˆ ARABIC LETTER WAW */
  { 0x05e9, 0x0649 }, /*          Arabic_alefmaksura Ù‰ ARABIC LETTER ALEF MAKSURA */
  { 0x05ea, 0x064a }, /*                  Arabic_yeh ÙŠ ARABIC LETTER YEH */
  { 0x05eb, 0x064b }, /*             Arabic_fathatan Ù‹ ARABIC FATHATAN */
  { 0x05ec, 0x064c }, /*             Arabic_dammatan ٌ ARABIC DAMMATAN */
  { 0x05ed, 0x064d }, /*             Arabic_kasratan Ù ARABIC KASRATAN */
  { 0x05ee, 0x064e }, /*                Arabic_fatha ÙŽ ARABIC FATHA */
  { 0x05ef, 0x064f }, /*                Arabic_damma Ù ARABIC DAMMA */
  { 0x05f0, 0x0650 }, /*                Arabic_kasra Ù ARABIC KASRA */
  { 0x05f1, 0x0651 }, /*               Arabic_shadda Ù‘ ARABIC SHADDA */
  { 0x05f2, 0x0652 }, /*                Arabic_sukun Ù’ ARABIC SUKUN */
  { 0x06a1, 0x0452 }, /*                 Serbian_dje Ñ’ CYRILLIC SMALL LETTER DJE */
  { 0x06a2, 0x0453 }, /*               Macedonia_gje Ñ“ CYRILLIC SMALL LETTER GJE */
  { 0x06a3, 0x0451 }, /*                 Cyrillic_io Ñ‘ CYRILLIC SMALL LETTER IO */
  { 0x06a4, 0x0454 }, /*                Ukrainian_ie Ñ” CYRILLIC SMALL LETTER UKRAINIAN IE */
  { 0x06a5, 0x0455 }, /*               Macedonia_dse Ñ• CYRILLIC SMALL LETTER DZE */
  { 0x06a6, 0x0456 }, /*                 Ukrainian_i Ñ– CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I */
  { 0x06a7, 0x0457 }, /*                Ukrainian_yi Ñ— CYRILLIC SMALL LETTER YI */
  { 0x06a8, 0x0458 }, /*                 Cyrillic_je ј CYRILLIC SMALL LETTER JE */
  { 0x06a9, 0x0459 }, /*                Cyrillic_lje Ñ™ CYRILLIC SMALL LETTER LJE */
  { 0x06aa, 0x045a }, /*                Cyrillic_nje Ñš CYRILLIC SMALL LETTER NJE */
  { 0x06ab, 0x045b }, /*                Serbian_tshe Ñ› CYRILLIC SMALL LETTER TSHE */
  { 0x06ac, 0x045c }, /*               Macedonia_kje ќ CYRILLIC SMALL LETTER KJE */
  { 0x06ad, 0x0491 }, /*   Ukrainian_ghe_with_upturn Ò‘ CYRILLIC SMALL LETTER GHE WITH UPTURN */
  { 0x06ae, 0x045e }, /*         Byelorussian_shortu Ñž CYRILLIC SMALL LETTER SHORT U */
  { 0x06af, 0x045f }, /*               Cyrillic_dzhe ÑŸ CYRILLIC SMALL LETTER DZHE */
  { 0x06b0, 0x2116 }, /*                  numerosign â„– NUMERO SIGN */
  { 0x06b1, 0x0402 }, /*                 Serbian_DJE Ђ CYRILLIC CAPITAL LETTER DJE */
  { 0x06b2, 0x0403 }, /*               Macedonia_GJE Ѓ CYRILLIC CAPITAL LETTER GJE */
  { 0x06b3, 0x0401 }, /*                 Cyrillic_IO Ð CYRILLIC CAPITAL LETTER IO */
  { 0x06b4, 0x0404 }, /*                Ukrainian_IE Є CYRILLIC CAPITAL LETTER UKRAINIAN IE */
  { 0x06b5, 0x0405 }, /*               Macedonia_DSE Ð… CYRILLIC CAPITAL LETTER DZE */
  { 0x06b6, 0x0406 }, /*                 Ukrainian_I І CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I */
  { 0x06b7, 0x0407 }, /*                Ukrainian_YI Ї CYRILLIC CAPITAL LETTER YI */
  { 0x06b8, 0x0408 }, /*                 Cyrillic_JE Ј CYRILLIC CAPITAL LETTER JE */
  { 0x06b9, 0x0409 }, /*                Cyrillic_LJE Љ CYRILLIC CAPITAL LETTER LJE */
  { 0x06ba, 0x040a }, /*                Cyrillic_NJE Њ CYRILLIC CAPITAL LETTER NJE */
  { 0x06bb, 0x040b }, /*                Serbian_TSHE Ћ CYRILLIC CAPITAL LETTER TSHE */
  { 0x06bc, 0x040c }, /*               Macedonia_KJE Ќ CYRILLIC CAPITAL LETTER KJE */
  { 0x06bd, 0x0490 }, /*   Ukrainian_GHE_WITH_UPTURN Ò CYRILLIC CAPITAL LETTER GHE WITH UPTURN */
  { 0x06be, 0x040e }, /*         Byelorussian_SHORTU ÐŽ CYRILLIC CAPITAL LETTER SHORT U */
  { 0x06bf, 0x040f }, /*               Cyrillic_DZHE Ð CYRILLIC CAPITAL LETTER DZHE */
  { 0x06c0, 0x044e }, /*                 Cyrillic_yu ÑŽ CYRILLIC SMALL LETTER YU */
  { 0x06c1, 0x0430 }, /*                  Cyrillic_a а CYRILLIC SMALL LETTER A */
  { 0x06c2, 0x0431 }, /*                 Cyrillic_be б CYRILLIC SMALL LETTER BE */
  { 0x06c3, 0x0446 }, /*                Cyrillic_tse ц CYRILLIC SMALL LETTER TSE */
  { 0x06c4, 0x0434 }, /*                 Cyrillic_de д CYRILLIC SMALL LETTER DE */
  { 0x06c5, 0x0435 }, /*                 Cyrillic_ie е CYRILLIC SMALL LETTER IE */
  { 0x06c6, 0x0444 }, /*                 Cyrillic_ef Ñ„ CYRILLIC SMALL LETTER EF */
  { 0x06c7, 0x0433 }, /*                Cyrillic_ghe г CYRILLIC SMALL LETTER GHE */
  { 0x06c8, 0x0445 }, /*                 Cyrillic_ha Ñ… CYRILLIC SMALL LETTER HA */
  { 0x06c9, 0x0438 }, /*                  Cyrillic_i и CYRILLIC SMALL LETTER I */
  { 0x06ca, 0x0439 }, /*             Cyrillic_shorti й CYRILLIC SMALL LETTER SHORT I */
  { 0x06cb, 0x043a }, /*                 Cyrillic_ka к CYRILLIC SMALL LETTER KA */
  { 0x06cc, 0x043b }, /*                 Cyrillic_el л CYRILLIC SMALL LETTER EL */
  { 0x06cd, 0x043c }, /*                 Cyrillic_em м CYRILLIC SMALL LETTER EM */
  { 0x06ce, 0x043d }, /*                 Cyrillic_en н CYRILLIC SMALL LETTER EN */
  { 0x06cf, 0x043e }, /*                  Cyrillic_o о CYRILLIC SMALL LETTER O */
  { 0x06d0, 0x043f }, /*                 Cyrillic_pe п CYRILLIC SMALL LETTER PE */
  { 0x06d1, 0x044f }, /*                 Cyrillic_ya Ñ CYRILLIC SMALL LETTER YA */
  { 0x06d2, 0x0440 }, /*                 Cyrillic_er р CYRILLIC SMALL LETTER ER */
  { 0x06d3, 0x0441 }, /*                 Cyrillic_es Ñ CYRILLIC SMALL LETTER ES */
  { 0x06d4, 0x0442 }, /*                 Cyrillic_te Ñ‚ CYRILLIC SMALL LETTER TE */
  { 0x06d5, 0x0443 }, /*                  Cyrillic_u у CYRILLIC SMALL LETTER U */
  { 0x06d6, 0x0436 }, /*                Cyrillic_zhe ж CYRILLIC SMALL LETTER ZHE */
  { 0x06d7, 0x0432 }, /*                 Cyrillic_ve в CYRILLIC SMALL LETTER VE */
  { 0x06d8, 0x044c }, /*           Cyrillic_softsign ь CYRILLIC SMALL LETTER SOFT SIGN */
  { 0x06d9, 0x044b }, /*               Cyrillic_yeru Ñ‹ CYRILLIC SMALL LETTER YERU */
  { 0x06da, 0x0437 }, /*                 Cyrillic_ze з CYRILLIC SMALL LETTER ZE */
  { 0x06db, 0x0448 }, /*                Cyrillic_sha ш CYRILLIC SMALL LETTER SHA */
  { 0x06dc, 0x044d }, /*                  Cyrillic_e Ñ CYRILLIC SMALL LETTER E */
  { 0x06dd, 0x0449 }, /*              Cyrillic_shcha щ CYRILLIC SMALL LETTER SHCHA */
  { 0x06de, 0x0447 }, /*                Cyrillic_che ч CYRILLIC SMALL LETTER CHE */
  { 0x06df, 0x044a }, /*           Cyrillic_hardsign ÑŠ CYRILLIC SMALL LETTER HARD SIGN */
  { 0x06e0, 0x042e }, /*                 Cyrillic_YU Ю CYRILLIC CAPITAL LETTER YU */
  { 0x06e1, 0x0410 }, /*                  Cyrillic_A Ð CYRILLIC CAPITAL LETTER A */
  { 0x06e2, 0x0411 }, /*                 Cyrillic_BE Б CYRILLIC CAPITAL LETTER BE */
  { 0x06e3, 0x0426 }, /*                Cyrillic_TSE Ц CYRILLIC CAPITAL LETTER TSE */
  { 0x06e4, 0x0414 }, /*                 Cyrillic_DE Д CYRILLIC CAPITAL LETTER DE */
  { 0x06e5, 0x0415 }, /*                 Cyrillic_IE Е CYRILLIC CAPITAL LETTER IE */
  { 0x06e6, 0x0424 }, /*                 Cyrillic_EF Ф CYRILLIC CAPITAL LETTER EF */
  { 0x06e7, 0x0413 }, /*                Cyrillic_GHE Г CYRILLIC CAPITAL LETTER GHE */
  { 0x06e8, 0x0425 }, /*                 Cyrillic_HA Х CYRILLIC CAPITAL LETTER HA */
  { 0x06e9, 0x0418 }, /*                  Cyrillic_I И CYRILLIC CAPITAL LETTER I */
  { 0x06ea, 0x0419 }, /*             Cyrillic_SHORTI Й CYRILLIC CAPITAL LETTER SHORT I */
  { 0x06eb, 0x041a }, /*                 Cyrillic_KA К CYRILLIC CAPITAL LETTER KA */
  { 0x06ec, 0x041b }, /*                 Cyrillic_EL Л CYRILLIC CAPITAL LETTER EL */
  { 0x06ed, 0x041c }, /*                 Cyrillic_EM М CYRILLIC CAPITAL LETTER EM */
  { 0x06ee, 0x041d }, /*                 Cyrillic_EN Ð CYRILLIC CAPITAL LETTER EN */
  { 0x06ef, 0x041e }, /*                  Cyrillic_O О CYRILLIC CAPITAL LETTER O */
  { 0x06f0, 0x041f }, /*                 Cyrillic_PE П CYRILLIC CAPITAL LETTER PE */
  { 0x06f1, 0x042f }, /*                 Cyrillic_YA Я CYRILLIC CAPITAL LETTER YA */
  { 0x06f2, 0x0420 }, /*                 Cyrillic_ER Р CYRILLIC CAPITAL LETTER ER */
  { 0x06f3, 0x0421 }, /*                 Cyrillic_ES С CYRILLIC CAPITAL LETTER ES */
  { 0x06f4, 0x0422 }, /*                 Cyrillic_TE Т CYRILLIC CAPITAL LETTER TE */
  { 0x06f5, 0x0423 }, /*                  Cyrillic_U У CYRILLIC CAPITAL LETTER U */
  { 0x06f6, 0x0416 }, /*                Cyrillic_ZHE Ж CYRILLIC CAPITAL LETTER ZHE */
  { 0x06f7, 0x0412 }, /*                 Cyrillic_VE Ð’ CYRILLIC CAPITAL LETTER VE */
  { 0x06f8, 0x042c }, /*           Cyrillic_SOFTSIGN Ь CYRILLIC CAPITAL LETTER SOFT SIGN */
  { 0x06f9, 0x042b }, /*               Cyrillic_YERU Ы CYRILLIC CAPITAL LETTER YERU */
  { 0x06fa, 0x0417 }, /*                 Cyrillic_ZE З CYRILLIC CAPITAL LETTER ZE */
  { 0x06fb, 0x0428 }, /*                Cyrillic_SHA Ш CYRILLIC CAPITAL LETTER SHA */
  { 0x06fc, 0x042d }, /*                  Cyrillic_E Э CYRILLIC CAPITAL LETTER E */
  { 0x06fd, 0x0429 }, /*              Cyrillic_SHCHA Щ CYRILLIC CAPITAL LETTER SHCHA */
  { 0x06fe, 0x0427 }, /*                Cyrillic_CHE Ч CYRILLIC CAPITAL LETTER CHE */
  { 0x06ff, 0x042a }, /*           Cyrillic_HARDSIGN Ъ CYRILLIC CAPITAL LETTER HARD SIGN */
  { 0x07a1, 0x0386 }, /*           Greek_ALPHAaccent Ά GREEK CAPITAL LETTER ALPHA WITH TONOS */
  { 0x07a2, 0x0388 }, /*         Greek_EPSILONaccent Έ GREEK CAPITAL LETTER EPSILON WITH TONOS */
  { 0x07a3, 0x0389 }, /*             Greek_ETAaccent Ή GREEK CAPITAL LETTER ETA WITH TONOS */
  { 0x07a4, 0x038a }, /*            Greek_IOTAaccent Ί GREEK CAPITAL LETTER IOTA WITH TONOS */
  { 0x07a5, 0x03aa }, /*         Greek_IOTAdiaeresis Ϊ GREEK CAPITAL LETTER IOTA WITH DIALYTIKA */
  { 0x07a7, 0x038c }, /*         Greek_OMICRONaccent Ό GREEK CAPITAL LETTER OMICRON WITH TONOS */
  { 0x07a8, 0x038e }, /*         Greek_UPSILONaccent ÎŽ GREEK CAPITAL LETTER UPSILON WITH TONOS */
  { 0x07a9, 0x03ab }, /*       Greek_UPSILONdieresis Ϋ GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA */
  { 0x07ab, 0x038f }, /*           Greek_OMEGAaccent Î GREEK CAPITAL LETTER OMEGA WITH TONOS */
  { 0x07ae, 0x0385 }, /*        Greek_accentdieresis Î… GREEK DIALYTIKA TONOS */
  { 0x07af, 0x2015 }, /*              Greek_horizbar ― HORIZONTAL BAR */
  { 0x07b1, 0x03ac }, /*           Greek_alphaaccent ά GREEK SMALL LETTER ALPHA WITH TONOS */
  { 0x07b2, 0x03ad }, /*         Greek_epsilonaccent έ GREEK SMALL LETTER EPSILON WITH TONOS */
  { 0x07b3, 0x03ae }, /*             Greek_etaaccent ή GREEK SMALL LETTER ETA WITH TONOS */
  { 0x07b4, 0x03af }, /*            Greek_iotaaccent ί GREEK SMALL LETTER IOTA WITH TONOS */
  { 0x07b5, 0x03ca }, /*          Greek_iotadieresis ÏŠ GREEK SMALL LETTER IOTA WITH DIALYTIKA */
  { 0x07b6, 0x0390 }, /*    Greek_iotaaccentdieresis Î GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS */
  { 0x07b7, 0x03cc }, /*         Greek_omicronaccent ό GREEK SMALL LETTER OMICRON WITH TONOS */
  { 0x07b8, 0x03cd }, /*         Greek_upsilonaccent Ï GREEK SMALL LETTER UPSILON WITH TONOS */
  { 0x07b9, 0x03cb }, /*       Greek_upsilondieresis Ï‹ GREEK SMALL LETTER UPSILON WITH DIALYTIKA */
  { 0x07ba, 0x03b0 }, /* Greek_upsilonaccentdieresis ΰ GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS */
  { 0x07bb, 0x03ce }, /*           Greek_omegaaccent ÏŽ GREEK SMALL LETTER OMEGA WITH TONOS */
  { 0x07c1, 0x0391 }, /*                 Greek_ALPHA Α GREEK CAPITAL LETTER ALPHA */
  { 0x07c2, 0x0392 }, /*                  Greek_BETA Î’ GREEK CAPITAL LETTER BETA */
  { 0x07c3, 0x0393 }, /*                 Greek_GAMMA Γ GREEK CAPITAL LETTER GAMMA */
  { 0x07c4, 0x0394 }, /*                 Greek_DELTA Δ GREEK CAPITAL LETTER DELTA */
  { 0x07c5, 0x0395 }, /*               Greek_EPSILON Ε GREEK CAPITAL LETTER EPSILON */
  { 0x07c6, 0x0396 }, /*                  Greek_ZETA Ζ GREEK CAPITAL LETTER ZETA */
  { 0x07c7, 0x0397 }, /*                   Greek_ETA Η GREEK CAPITAL LETTER ETA */
  { 0x07c8, 0x0398 }, /*                 Greek_THETA Θ GREEK CAPITAL LETTER THETA */
  { 0x07c9, 0x0399 }, /*                  Greek_IOTA Ι GREEK CAPITAL LETTER IOTA */
  { 0x07ca, 0x039a }, /*                 Greek_KAPPA Κ GREEK CAPITAL LETTER KAPPA */
  { 0x07cb, 0x039b }, /*                Greek_LAMBDA Λ GREEK CAPITAL LETTER LAMDA */
  { 0x07cc, 0x039c }, /*                    Greek_MU Μ GREEK CAPITAL LETTER MU */
  { 0x07cd, 0x039d }, /*                    Greek_NU Î GREEK CAPITAL LETTER NU */
  { 0x07ce, 0x039e }, /*                    Greek_XI Ξ GREEK CAPITAL LETTER XI */
  { 0x07cf, 0x039f }, /*               Greek_OMICRON Ο GREEK CAPITAL LETTER OMICRON */
  { 0x07d0, 0x03a0 }, /*                    Greek_PI Π GREEK CAPITAL LETTER PI */
  { 0x07d1, 0x03a1 }, /*                   Greek_RHO Ρ GREEK CAPITAL LETTER RHO */
  { 0x07d2, 0x03a3 }, /*                 Greek_SIGMA Σ GREEK CAPITAL LETTER SIGMA */
  { 0x07d4, 0x03a4 }, /*                   Greek_TAU Τ GREEK CAPITAL LETTER TAU */
  { 0x07d5, 0x03a5 }, /*               Greek_UPSILON Υ GREEK CAPITAL LETTER UPSILON */
  { 0x07d6, 0x03a6 }, /*                   Greek_PHI Φ GREEK CAPITAL LETTER PHI */
  { 0x07d7, 0x03a7 }, /*                   Greek_CHI Χ GREEK CAPITAL LETTER CHI */
  { 0x07d8, 0x03a8 }, /*                   Greek_PSI Ψ GREEK CAPITAL LETTER PSI */
  { 0x07d9, 0x03a9 }, /*                 Greek_OMEGA Ω GREEK CAPITAL LETTER OMEGA */
  { 0x07e1, 0x03b1 }, /*                 Greek_alpha α GREEK SMALL LETTER ALPHA */
  { 0x07e2, 0x03b2 }, /*                  Greek_beta β GREEK SMALL LETTER BETA */
  { 0x07e3, 0x03b3 }, /*                 Greek_gamma γ GREEK SMALL LETTER GAMMA */
  { 0x07e4, 0x03b4 }, /*                 Greek_delta δ GREEK SMALL LETTER DELTA */
  { 0x07e5, 0x03b5 }, /*               Greek_epsilon ε GREEK SMALL LETTER EPSILON */
  { 0x07e6, 0x03b6 }, /*                  Greek_zeta ζ GREEK SMALL LETTER ZETA */
  { 0x07e7, 0x03b7 }, /*                   Greek_eta η GREEK SMALL LETTER ETA */
  { 0x07e8, 0x03b8 }, /*                 Greek_theta θ GREEK SMALL LETTER THETA */
  { 0x07e9, 0x03b9 }, /*                  Greek_iota ι GREEK SMALL LETTER IOTA */
  { 0x07ea, 0x03ba }, /*                 Greek_kappa κ GREEK SMALL LETTER KAPPA */
  { 0x07eb, 0x03bb }, /*                Greek_lambda λ GREEK SMALL LETTER LAMDA */
  { 0x07ec, 0x03bc }, /*                    Greek_mu μ GREEK SMALL LETTER MU */
  { 0x07ed, 0x03bd }, /*                    Greek_nu ν GREEK SMALL LETTER NU */
  { 0x07ee, 0x03be }, /*                    Greek_xi ξ GREEK SMALL LETTER XI */
  { 0x07ef, 0x03bf }, /*               Greek_omicron ο GREEK SMALL LETTER OMICRON */
  { 0x07f0, 0x03c0 }, /*                    Greek_pi π GREEK SMALL LETTER PI */
  { 0x07f1, 0x03c1 }, /*                   Greek_rho Ï GREEK SMALL LETTER RHO */
  { 0x07f2, 0x03c3 }, /*                 Greek_sigma σ GREEK SMALL LETTER SIGMA */
  { 0x07f3, 0x03c2 }, /*       Greek_finalsmallsigma Ï‚ GREEK SMALL LETTER FINAL SIGMA */
  { 0x07f4, 0x03c4 }, /*                   Greek_tau Ï„ GREEK SMALL LETTER TAU */
  { 0x07f5, 0x03c5 }, /*               Greek_upsilon Ï… GREEK SMALL LETTER UPSILON */
  { 0x07f6, 0x03c6 }, /*                   Greek_phi φ GREEK SMALL LETTER PHI */
  { 0x07f7, 0x03c7 }, /*                   Greek_chi χ GREEK SMALL LETTER CHI */
  { 0x07f8, 0x03c8 }, /*                   Greek_psi ψ GREEK SMALL LETTER PSI */
  { 0x07f9, 0x03c9 }, /*                 Greek_omega ω GREEK SMALL LETTER OMEGA */
  { 0x08a1, 0x23b7 }, /*                 leftradical ⎷ RADICAL SYMBOL BOTTOM */
  { 0x08a2, 0x250c }, /*              topleftradical ┌ BOX DRAWINGS LIGHT DOWN AND RIGHT */
  { 0x08a3, 0x2500 }, /*              horizconnector ─ BOX DRAWINGS LIGHT HORIZONTAL */
  { 0x08a4, 0x2320 }, /*                 topintegral ⌠ TOP HALF INTEGRAL */
  { 0x08a5, 0x2321 }, /*                 botintegral ⌡ BOTTOM HALF INTEGRAL */
  { 0x08a6, 0x2502 }, /*               vertconnector │ BOX DRAWINGS LIGHT VERTICAL */
  { 0x08a7, 0x23a1 }, /*            topleftsqbracket ⎡ LEFT SQUARE BRACKET UPPER CORNER */
  { 0x08a8, 0x23a3 }, /*            botleftsqbracket ⎣ LEFT SQUARE BRACKET LOWER CORNER */
  { 0x08a9, 0x23a4 }, /*           toprightsqbracket ⎤ RIGHT SQUARE BRACKET UPPER CORNER */
  { 0x08aa, 0x23a6 }, /*           botrightsqbracket ⎦ RIGHT SQUARE BRACKET LOWER CORNER */
  { 0x08ab, 0x239b }, /*               topleftparens ⎛ LEFT PARENTHESIS UPPER HOOK */
  { 0x08ac, 0x239d }, /*               botleftparens ⎠LEFT PARENTHESIS LOWER HOOK */
  { 0x08ad, 0x239e }, /*              toprightparens ⎞ RIGHT PARENTHESIS UPPER HOOK */
  { 0x08ae, 0x23a0 }, /*              botrightparens ⎠ RIGHT PARENTHESIS LOWER HOOK */
  { 0x08af, 0x23a8 }, /*        leftmiddlecurlybrace ⎨ LEFT CURLY BRACKET MIDDLE PIECE */
  { 0x08b0, 0x23ac }, /*       rightmiddlecurlybrace ⎬ RIGHT CURLY BRACKET MIDDLE PIECE */
/*  0x08b1                          topleftsummation ? ??? */
/*  0x08b2                          botleftsummation ? ??? */
/*  0x08b3                 topvertsummationconnector ? ??? */
/*  0x08b4                 botvertsummationconnector ? ??? */
/*  0x08b5                         toprightsummation ? ??? */
/*  0x08b6                         botrightsummation ? ??? */
/*  0x08b7                      rightmiddlesummation ? ??? */
  { 0x08bc, 0x2264 }, /*               lessthanequal ≤ LESS-THAN OR EQUAL TO */
  { 0x08bd, 0x2260 }, /*                    notequal ≠ NOT EQUAL TO */
  { 0x08be, 0x2265 }, /*            greaterthanequal ≥ GREATER-THAN OR EQUAL TO */
  { 0x08bf, 0x222b }, /*                    integral ∫ INTEGRAL */
  { 0x08c0, 0x2234 }, /*                   therefore ∴ THEREFORE */
  { 0x08c1, 0x221d }, /*                   variation ∠PROPORTIONAL TO */
  { 0x08c2, 0x221e }, /*                    infinity ∞ INFINITY */
  { 0x08c5, 0x2207 }, /*                       nabla ∇ NABLA */
  { 0x08c8, 0x223c }, /*                 approximate ∼ TILDE OPERATOR */
  { 0x08c9, 0x2243 }, /*                similarequal ≃ ASYMPTOTICALLY EQUAL TO */
  { 0x08cd, 0x21d4 }, /*                    ifonlyif ⇔ LEFT RIGHT DOUBLE ARROW */
  { 0x08ce, 0x21d2 }, /*                     implies ⇒ RIGHTWARDS DOUBLE ARROW */
  { 0x08cf, 0x2261 }, /*                   identical ≡ IDENTICAL TO */
  { 0x08d6, 0x221a }, /*                     radical √ SQUARE ROOT */
  { 0x08da, 0x2282 }, /*                  includedin ⊂ SUBSET OF */
  { 0x08db, 0x2283 }, /*                    includes ⊃ SUPERSET OF */
  { 0x08dc, 0x2229 }, /*                intersection ∩ INTERSECTION */
  { 0x08dd, 0x222a }, /*                       union ∪ UNION */
  { 0x08de, 0x2227 }, /*                  logicaland ∧ LOGICAL AND */
  { 0x08df, 0x2228 }, /*                   logicalor ∨ LOGICAL OR */
  { 0x08ef, 0x2202 }, /*           partialderivative ∂ PARTIAL DIFFERENTIAL */
  { 0x08f6, 0x0192 }, /*                    function Æ’ LATIN SMALL LETTER F WITH HOOK */
  { 0x08fb, 0x2190 }, /*                   leftarrow ↠LEFTWARDS ARROW */
  { 0x08fc, 0x2191 }, /*                     uparrow ↑ UPWARDS ARROW */
  { 0x08fd, 0x2192 }, /*                  rightarrow → RIGHTWARDS ARROW */
  { 0x08fe, 0x2193 }, /*                   downarrow ↓ DOWNWARDS ARROW */
  { 0x09df, 0x2422 }, /*                       blank ⢠BLANK SYMBOL */
  { 0x09e0, 0x25c6 }, /*                soliddiamond â—† BLACK DIAMOND */
  { 0x09e1, 0x2592 }, /*                checkerboard â–’ MEDIUM SHADE */
  { 0x09e2, 0x2409 }, /*                          ht ≠SYMBOL FOR HORIZONTAL TABULATION */
  { 0x09e3, 0x240c }, /*                          ff ⌠SYMBOL FOR FORM FEED */
  { 0x09e4, 0x240d }, /*                          cr â SYMBOL FOR CARRIAGE RETURN */
  { 0x09e5, 0x240a }, /*                          lf ⊠SYMBOL FOR LINE FEED */
  { 0x09e8, 0x2424 }, /*                          nl ⤠SYMBOL FOR NEWLINE */
  { 0x09e9, 0x240b }, /*                          vt â‹ SYMBOL FOR VERTICAL TABULATION */
  { 0x09ea, 0x2518 }, /*              lowrightcorner ┘ BOX DRAWINGS LIGHT UP AND LEFT */
  { 0x09eb, 0x2510 }, /*               uprightcorner â” BOX DRAWINGS LIGHT DOWN AND LEFT */
  { 0x09ec, 0x250c }, /*                upleftcorner ┌ BOX DRAWINGS LIGHT DOWN AND RIGHT */
  { 0x09ed, 0x2514 }, /*               lowleftcorner â”” BOX DRAWINGS LIGHT UP AND RIGHT */
  { 0x09ee, 0x253c }, /*               crossinglines ┼ BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL */
  { 0x09ef, 0x23ba }, /*              horizlinescan1 ⎺ HORIZONTAL SCAN LINE-1 */
  { 0x09f0, 0x23bb }, /*              horizlinescan3 ⎻ HORIZONTAL SCAN LINE-3 */
  { 0x09f1, 0x2500 }, /*              horizlinescan5 ─ BOX DRAWINGS LIGHT HORIZONTAL */
  { 0x09f2, 0x23bc }, /*              horizlinescan7 ⎼ HORIZONTAL SCAN LINE-7 */
  { 0x09f3, 0x23bd }, /*              horizlinescan9 ⎽ HORIZONTAL SCAN LINE-9 */
  { 0x09f4, 0x251c }, /*                       leftt ├ BOX DRAWINGS LIGHT VERTICAL AND RIGHT */
  { 0x09f5, 0x2524 }, /*                      rightt ┤ BOX DRAWINGS LIGHT VERTICAL AND LEFT */
  { 0x09f6, 0x2534 }, /*                        bott â”´ BOX DRAWINGS LIGHT UP AND HORIZONTAL */
  { 0x09f7, 0x252c }, /*                        topt ┬ BOX DRAWINGS LIGHT DOWN AND HORIZONTAL */
  { 0x09f8, 0x2502 }, /*                     vertbar │ BOX DRAWINGS LIGHT VERTICAL */
  { 0x0aa1, 0x2003 }, /*                     emspace   EM SPACE */
  { 0x0aa2, 0x2002 }, /*                     enspace   EN SPACE */
  { 0x0aa3, 0x2004 }, /*                    em3space   THREE-PER-EM SPACE */
  { 0x0aa4, 0x2005 }, /*                    em4space   FOUR-PER-EM SPACE */
  { 0x0aa5, 0x2007 }, /*                  digitspace   FIGURE SPACE */
  { 0x0aa6, 0x2008 }, /*                  punctspace   PUNCTUATION SPACE */
  { 0x0aa7, 0x2009 }, /*                   thinspace   THIN SPACE */
  { 0x0aa8, 0x200a }, /*                   hairspace   HAIR SPACE */
  { 0x0aa9, 0x2014 }, /*                      emdash — EM DASH */
  { 0x0aaa, 0x2013 }, /*                      endash – EN DASH */
  { 0x0aac, 0x2423 }, /*                 signifblank ⣠OPEN BOX */
  { 0x0aae, 0x2026 }, /*                    ellipsis … HORIZONTAL ELLIPSIS */
  { 0x0aaf, 0x2025 }, /*             doubbaselinedot ‥ TWO DOT LEADER */
  { 0x0ab0, 0x2153 }, /*                    onethird â…“ VULGAR FRACTION ONE THIRD */
  { 0x0ab1, 0x2154 }, /*                   twothirds â…” VULGAR FRACTION TWO THIRDS */
  { 0x0ab2, 0x2155 }, /*                    onefifth â…• VULGAR FRACTION ONE FIFTH */
  { 0x0ab3, 0x2156 }, /*                   twofifths â…– VULGAR FRACTION TWO FIFTHS */
  { 0x0ab4, 0x2157 }, /*                 threefifths â…— VULGAR FRACTION THREE FIFTHS */
  { 0x0ab5, 0x2158 }, /*                  fourfifths â…˜ VULGAR FRACTION FOUR FIFTHS */
  { 0x0ab6, 0x2159 }, /*                    onesixth â…™ VULGAR FRACTION ONE SIXTH */
  { 0x0ab7, 0x215a }, /*                  fivesixths â…š VULGAR FRACTION FIVE SIXTHS */
  { 0x0ab8, 0x2105 }, /*                      careof â„… CARE OF */
  { 0x0abb, 0x2012 }, /*                     figdash ‒ FIGURE DASH */
  { 0x0abc, 0x2329 }, /*            leftanglebracket 〈 LEFT-POINTING ANGLE BRACKET */
  { 0x0abd, 0x002e }, /*                decimalpoint . FULL STOP */
  { 0x0abe, 0x232a }, /*           rightanglebracket 〉 RIGHT-POINTING ANGLE BRACKET */
/*  0x0abf                                    marker ? ??? */
  { 0x0ac3, 0x215b }, /*                   oneeighth â…› VULGAR FRACTION ONE EIGHTH */
  { 0x0ac4, 0x215c }, /*                threeeighths ⅜ VULGAR FRACTION THREE EIGHTHS */
  { 0x0ac5, 0x215d }, /*                 fiveeighths â… VULGAR FRACTION FIVE EIGHTHS */
  { 0x0ac6, 0x215e }, /*                seveneighths â…ž VULGAR FRACTION SEVEN EIGHTHS */
  { 0x0ac9, 0x2122 }, /*                   trademark â„¢ TRADE MARK SIGN */
  { 0x0aca, 0x2613 }, /*               signaturemark ☓ SALTIRE */
/*  0x0acb                         trademarkincircle ? ??? */
  { 0x0acc, 0x25c1 }, /*            leftopentriangle â— WHITE LEFT-POINTING TRIANGLE */
  { 0x0acd, 0x25b7 }, /*           rightopentriangle â–· WHITE RIGHT-POINTING TRIANGLE */
  { 0x0ace, 0x25cb }, /*                emopencircle â—‹ WHITE CIRCLE */
  { 0x0acf, 0x25af }, /*             emopenrectangle â–¯ WHITE VERTICAL RECTANGLE */
  { 0x0ad0, 0x2018 }, /*         leftsinglequotemark ‘ LEFT SINGLE QUOTATION MARK */
  { 0x0ad1, 0x2019 }, /*        rightsinglequotemark ’ RIGHT SINGLE QUOTATION MARK */
  { 0x0ad2, 0x201c }, /*         leftdoublequotemark “ LEFT DOUBLE QUOTATION MARK */
  { 0x0ad3, 0x201d }, /*        rightdoublequotemark †RIGHT DOUBLE QUOTATION MARK */
  { 0x0ad4, 0x211e }, /*                prescription ℞ PRESCRIPTION TAKE */
  { 0x0ad5, 0x2030 }, /*                    permille ‰ PER MILLE SIGN */
  { 0x0ad6, 0x2032 }, /*                     minutes ′ PRIME */
  { 0x0ad7, 0x2033 }, /*                     seconds ″ DOUBLE PRIME */
  { 0x0ad9, 0x271d }, /*                  latincross ✠LATIN CROSS */
/*  0x0ada                                  hexagram ? ??? */
  { 0x0adb, 0x25ac }, /*            filledrectbullet â–¬ BLACK RECTANGLE */
  { 0x0adc, 0x25c0 }, /*         filledlefttribullet â—€ BLACK LEFT-POINTING TRIANGLE */
  { 0x0add, 0x25b6 }, /*        filledrighttribullet â–¶ BLACK RIGHT-POINTING TRIANGLE */
  { 0x0ade, 0x25cf }, /*              emfilledcircle â— BLACK CIRCLE */
  { 0x0adf, 0x25ae }, /*                emfilledrect â–® BLACK VERTICAL RECTANGLE */
  { 0x0ae0, 0x25e6 }, /*            enopencircbullet â—¦ WHITE BULLET */
  { 0x0ae1, 0x25ab }, /*          enopensquarebullet â–« WHITE SMALL SQUARE */
  { 0x0ae2, 0x25ad }, /*              openrectbullet â–­ WHITE RECTANGLE */
  { 0x0ae3, 0x25b3 }, /*             opentribulletup â–³ WHITE UP-POINTING TRIANGLE */
  { 0x0ae4, 0x25bd }, /*           opentribulletdown â–½ WHITE DOWN-POINTING TRIANGLE */
  { 0x0ae5, 0x2606 }, /*                    openstar ☆ WHITE STAR */
  { 0x0ae6, 0x2022 }, /*          enfilledcircbullet • BULLET */
  { 0x0ae7, 0x25aa }, /*            enfilledsqbullet â–ª BLACK SMALL SQUARE */
  { 0x0ae8, 0x25b2 }, /*           filledtribulletup â–² BLACK UP-POINTING TRIANGLE */
  { 0x0ae9, 0x25bc }, /*         filledtribulletdown â–¼ BLACK DOWN-POINTING TRIANGLE */
  { 0x0aea, 0x261c }, /*                 leftpointer ☜ WHITE LEFT POINTING INDEX */
  { 0x0aeb, 0x261e }, /*                rightpointer ☞ WHITE RIGHT POINTING INDEX */
  { 0x0aec, 0x2663 }, /*                        club ♣ BLACK CLUB SUIT */
  { 0x0aed, 0x2666 }, /*                     diamond ♦ BLACK DIAMOND SUIT */
  { 0x0aee, 0x2665 }, /*                       heart ♥ BLACK HEART SUIT */
  { 0x0af0, 0x2720 }, /*                maltesecross ✠ MALTESE CROSS */
  { 0x0af1, 0x2020 }, /*                      dagger † DAGGER */
  { 0x0af2, 0x2021 }, /*                doubledagger ‡ DOUBLE DAGGER */
  { 0x0af3, 0x2713 }, /*                   checkmark ✓ CHECK MARK */
  { 0x0af4, 0x2717 }, /*                 ballotcross ✗ BALLOT X */
  { 0x0af5, 0x266f }, /*                musicalsharp ♯ MUSIC SHARP SIGN */
  { 0x0af6, 0x266d }, /*                 musicalflat â™­ MUSIC FLAT SIGN */
  { 0x0af7, 0x2642 }, /*                  malesymbol ♂ MALE SIGN */
  { 0x0af8, 0x2640 }, /*                femalesymbol ♀ FEMALE SIGN */
  { 0x0af9, 0x260e }, /*                   telephone ☎ BLACK TELEPHONE */
  { 0x0afa, 0x2315 }, /*           telephonerecorder ⌕ TELEPHONE RECORDER */
  { 0x0afb, 0x2117 }, /*         phonographcopyright â„— SOUND RECORDING COPYRIGHT */
  { 0x0afc, 0x2038 }, /*                       caret ‸ CARET */
  { 0x0afd, 0x201a }, /*          singlelowquotemark ‚ SINGLE LOW-9 QUOTATION MARK */
  { 0x0afe, 0x201e }, /*          doublelowquotemark „ DOUBLE LOW-9 QUOTATION MARK */
/*  0x0aff                                    cursor ? ??? */
  { 0x0ba3, 0x003c }, /*                   leftcaret < LESS-THAN SIGN */
  { 0x0ba6, 0x003e }, /*                  rightcaret > GREATER-THAN SIGN */
  { 0x0ba8, 0x2228 }, /*                   downcaret ∨ LOGICAL OR */
  { 0x0ba9, 0x2227 }, /*                     upcaret ∧ LOGICAL AND */
  { 0x0bc0, 0x00af }, /*                     overbar ¯ MACRON */
  { 0x0bc2, 0x22a5 }, /*                    downtack ⊥ UP TACK */
  { 0x0bc3, 0x2229 }, /*                      upshoe ∩ INTERSECTION */
  { 0x0bc4, 0x230a }, /*                   downstile ⌊ LEFT FLOOR */
  { 0x0bc6, 0x005f }, /*                    underbar _ LOW LINE */
  { 0x0bca, 0x2218 }, /*                         jot ∘ RING OPERATOR */
  { 0x0bcc, 0x2395 }, /*                        quad ⎕ APL FUNCTIONAL SYMBOL QUAD */
  { 0x0bce, 0x22a4 }, /*                      uptack ⊤ DOWN TACK */
  { 0x0bcf, 0x25cb }, /*                      circle â—‹ WHITE CIRCLE */
  { 0x0bd3, 0x2308 }, /*                     upstile ⌈ LEFT CEILING */
  { 0x0bd6, 0x222a }, /*                    downshoe ∪ UNION */
  { 0x0bd8, 0x2283 }, /*                   rightshoe ⊃ SUPERSET OF */
  { 0x0bda, 0x2282 }, /*                    leftshoe ⊂ SUBSET OF */
  { 0x0bdc, 0x22a2 }, /*                    lefttack ⊢ RIGHT TACK */
  { 0x0bfc, 0x22a3 }, /*                   righttack ⊣ LEFT TACK */
  { 0x0cdf, 0x2017 }, /*        hebrew_doublelowline ‗ DOUBLE LOW LINE */
  { 0x0ce0, 0x05d0 }, /*                hebrew_aleph × HEBREW LETTER ALEF */
  { 0x0ce1, 0x05d1 }, /*                  hebrew_bet ב HEBREW LETTER BET */
  { 0x0ce2, 0x05d2 }, /*                hebrew_gimel ×’ HEBREW LETTER GIMEL */
  { 0x0ce3, 0x05d3 }, /*                hebrew_dalet ד HEBREW LETTER DALET */
  { 0x0ce4, 0x05d4 }, /*                   hebrew_he ×” HEBREW LETTER HE */
  { 0x0ce5, 0x05d5 }, /*                  hebrew_waw ו HEBREW LETTER VAV */
  { 0x0ce6, 0x05d6 }, /*                 hebrew_zain ×– HEBREW LETTER ZAYIN */
  { 0x0ce7, 0x05d7 }, /*                 hebrew_chet ×— HEBREW LETTER HET */
  { 0x0ce8, 0x05d8 }, /*                  hebrew_tet ט HEBREW LETTER TET */
  { 0x0ce9, 0x05d9 }, /*                  hebrew_yod ×™ HEBREW LETTER YOD */
  { 0x0cea, 0x05da }, /*            hebrew_finalkaph ך HEBREW LETTER FINAL KAF */
  { 0x0ceb, 0x05db }, /*                 hebrew_kaph ×› HEBREW LETTER KAF */
  { 0x0cec, 0x05dc }, /*                hebrew_lamed ל HEBREW LETTER LAMED */
  { 0x0ced, 0x05dd }, /*             hebrew_finalmem × HEBREW LETTER FINAL MEM */
  { 0x0cee, 0x05de }, /*                  hebrew_mem מ HEBREW LETTER MEM */
  { 0x0cef, 0x05df }, /*             hebrew_finalnun ן HEBREW LETTER FINAL NUN */
  { 0x0cf0, 0x05e0 }, /*                  hebrew_nun ×  HEBREW LETTER NUN */
  { 0x0cf1, 0x05e1 }, /*               hebrew_samech ס HEBREW LETTER SAMEKH */
  { 0x0cf2, 0x05e2 }, /*                 hebrew_ayin ×¢ HEBREW LETTER AYIN */
  { 0x0cf3, 0x05e3 }, /*              hebrew_finalpe ×£ HEBREW LETTER FINAL PE */
  { 0x0cf4, 0x05e4 }, /*                   hebrew_pe פ HEBREW LETTER PE */
  { 0x0cf5, 0x05e5 }, /*            hebrew_finalzade ×¥ HEBREW LETTER FINAL TSADI */
  { 0x0cf6, 0x05e6 }, /*                 hebrew_zade צ HEBREW LETTER TSADI */
  { 0x0cf7, 0x05e7 }, /*                 hebrew_qoph ×§ HEBREW LETTER QOF */
  { 0x0cf8, 0x05e8 }, /*                 hebrew_resh ר HEBREW LETTER RESH */
  { 0x0cf9, 0x05e9 }, /*                 hebrew_shin ש HEBREW LETTER SHIN */
  { 0x0cfa, 0x05ea }, /*                  hebrew_taw ת HEBREW LETTER TAV */
  { 0x0da1, 0x0e01 }, /*                  Thai_kokai ภTHAI CHARACTER KO KAI */
  { 0x0da2, 0x0e02 }, /*                Thai_khokhai ข THAI CHARACTER KHO KHAI */
  { 0x0da3, 0x0e03 }, /*               Thai_khokhuat ฃ THAI CHARACTER KHO KHUAT */
  { 0x0da4, 0x0e04 }, /*               Thai_khokhwai ค THAI CHARACTER KHO KHWAI */
  { 0x0da5, 0x0e05 }, /*                Thai_khokhon ฅ THAI CHARACTER KHO KHON */
  { 0x0da6, 0x0e06 }, /*             Thai_khorakhang ฆ THAI CHARACTER KHO RAKHANG */
  { 0x0da7, 0x0e07 }, /*                 Thai_ngongu ง THAI CHARACTER NGO NGU */
  { 0x0da8, 0x0e08 }, /*                Thai_chochan จ THAI CHARACTER CHO CHAN */
  { 0x0da9, 0x0e09 }, /*               Thai_choching ฉ THAI CHARACTER CHO CHING */
  { 0x0daa, 0x0e0a }, /*               Thai_chochang ช THAI CHARACTER CHO CHANG */
  { 0x0dab, 0x0e0b }, /*                   Thai_soso ซ THAI CHARACTER SO SO */
  { 0x0dac, 0x0e0c }, /*                Thai_chochoe ฌ THAI CHARACTER CHO CHOE */
  { 0x0dad, 0x0e0d }, /*                 Thai_yoying ภTHAI CHARACTER YO YING */
  { 0x0dae, 0x0e0e }, /*                Thai_dochada ฎ THAI CHARACTER DO CHADA */
  { 0x0daf, 0x0e0f }, /*                Thai_topatak ภTHAI CHARACTER TO PATAK */
  { 0x0db0, 0x0e10 }, /*                Thai_thothan ภTHAI CHARACTER THO THAN */
  { 0x0db1, 0x0e11 }, /*          Thai_thonangmontho ฑ THAI CHARACTER THO NANGMONTHO */
  { 0x0db2, 0x0e12 }, /*             Thai_thophuthao ฒ THAI CHARACTER THO PHUTHAO */
  { 0x0db3, 0x0e13 }, /*                  Thai_nonen ณ THAI CHARACTER NO NEN */
  { 0x0db4, 0x0e14 }, /*                  Thai_dodek ด THAI CHARACTER DO DEK */
  { 0x0db5, 0x0e15 }, /*                  Thai_totao ต THAI CHARACTER TO TAO */
  { 0x0db6, 0x0e16 }, /*               Thai_thothung ถ THAI CHARACTER THO THUNG */
  { 0x0db7, 0x0e17 }, /*              Thai_thothahan ท THAI CHARACTER THO THAHAN */
  { 0x0db8, 0x0e18 }, /*               Thai_thothong ธ THAI CHARACTER THO THONG */
  { 0x0db9, 0x0e19 }, /*                   Thai_nonu น THAI CHARACTER NO NU */
  { 0x0dba, 0x0e1a }, /*               Thai_bobaimai บ THAI CHARACTER BO BAIMAI */
  { 0x0dbb, 0x0e1b }, /*                  Thai_popla ป THAI CHARACTER PO PLA */
  { 0x0dbc, 0x0e1c }, /*               Thai_phophung ผ THAI CHARACTER PHO PHUNG */
  { 0x0dbd, 0x0e1d }, /*                   Thai_fofa ภTHAI CHARACTER FO FA */
  { 0x0dbe, 0x0e1e }, /*                Thai_phophan พ THAI CHARACTER PHO PHAN */
  { 0x0dbf, 0x0e1f }, /*                  Thai_fofan ฟ THAI CHARACTER FO FAN */
  { 0x0dc0, 0x0e20 }, /*             Thai_phosamphao ภ THAI CHARACTER PHO SAMPHAO */
  { 0x0dc1, 0x0e21 }, /*                   Thai_moma ม THAI CHARACTER MO MA */
  { 0x0dc2, 0x0e22 }, /*                  Thai_yoyak ย THAI CHARACTER YO YAK */
  { 0x0dc3, 0x0e23 }, /*                  Thai_rorua ร THAI CHARACTER RO RUA */
  { 0x0dc4, 0x0e24 }, /*                     Thai_ru ฤ THAI CHARACTER RU */
  { 0x0dc5, 0x0e25 }, /*                 Thai_loling ล THAI CHARACTER LO LING */
  { 0x0dc6, 0x0e26 }, /*                     Thai_lu ฦ THAI CHARACTER LU */
  { 0x0dc7, 0x0e27 }, /*                 Thai_wowaen ว THAI CHARACTER WO WAEN */
  { 0x0dc8, 0x0e28 }, /*                 Thai_sosala ศ THAI CHARACTER SO SALA */
  { 0x0dc9, 0x0e29 }, /*                 Thai_sorusi ษ THAI CHARACTER SO RUSI */
  { 0x0dca, 0x0e2a }, /*                  Thai_sosua ส THAI CHARACTER SO SUA */
  { 0x0dcb, 0x0e2b }, /*                  Thai_hohip ห THAI CHARACTER HO HIP */
  { 0x0dcc, 0x0e2c }, /*                Thai_lochula ฬ THAI CHARACTER LO CHULA */
  { 0x0dcd, 0x0e2d }, /*                   Thai_oang อ THAI CHARACTER O ANG */
  { 0x0dce, 0x0e2e }, /*               Thai_honokhuk ฮ THAI CHARACTER HO NOKHUK */
  { 0x0dcf, 0x0e2f }, /*              Thai_paiyannoi ฯ THAI CHARACTER PAIYANNOI */
  { 0x0dd0, 0x0e30 }, /*                  Thai_saraa ะ THAI CHARACTER SARA A */
  { 0x0dd1, 0x0e31 }, /*             Thai_maihanakat ั THAI CHARACTER MAI HAN-AKAT */
  { 0x0dd2, 0x0e32 }, /*                 Thai_saraaa า THAI CHARACTER SARA AA */
  { 0x0dd3, 0x0e33 }, /*                 Thai_saraam ำ THAI CHARACTER SARA AM */
  { 0x0dd4, 0x0e34 }, /*                  Thai_sarai ิ THAI CHARACTER SARA I */
  { 0x0dd5, 0x0e35 }, /*                 Thai_saraii ี THAI CHARACTER SARA II */
  { 0x0dd6, 0x0e36 }, /*                 Thai_saraue ึ THAI CHARACTER SARA UE */
  { 0x0dd7, 0x0e37 }, /*                Thai_sarauee ื THAI CHARACTER SARA UEE */
  { 0x0dd8, 0x0e38 }, /*                  Thai_sarau ุ THAI CHARACTER SARA U */
  { 0x0dd9, 0x0e39 }, /*                 Thai_sarauu ู THAI CHARACTER SARA UU */
  { 0x0dda, 0x0e3a }, /*                Thai_phinthu ฺ THAI CHARACTER PHINTHU */
  { 0x0dde, 0x0e3e }, /*      Thai_maihanakat_maitho ฾ ??? */
  { 0x0ddf, 0x0e3f }, /*                   Thai_baht ฿ THAI CURRENCY SYMBOL BAHT */
  { 0x0de0, 0x0e40 }, /*                  Thai_sarae เ THAI CHARACTER SARA E */
  { 0x0de1, 0x0e41 }, /*                 Thai_saraae ๠THAI CHARACTER SARA AE */
  { 0x0de2, 0x0e42 }, /*                  Thai_sarao โ THAI CHARACTER SARA O */
  { 0x0de3, 0x0e43 }, /*          Thai_saraaimaimuan ใ THAI CHARACTER SARA AI MAIMUAN */
  { 0x0de4, 0x0e44 }, /*         Thai_saraaimaimalai ไ THAI CHARACTER SARA AI MAIMALAI */
  { 0x0de5, 0x0e45 }, /*            Thai_lakkhangyao ๅ THAI CHARACTER LAKKHANGYAO */
  { 0x0de6, 0x0e46 }, /*               Thai_maiyamok ๆ THAI CHARACTER MAIYAMOK */
  { 0x0de7, 0x0e47 }, /*              Thai_maitaikhu ็ THAI CHARACTER MAITAIKHU */
  { 0x0de8, 0x0e48 }, /*                  Thai_maiek ่ THAI CHARACTER MAI EK */
  { 0x0de9, 0x0e49 }, /*                 Thai_maitho ้ THAI CHARACTER MAI THO */
  { 0x0dea, 0x0e4a }, /*                 Thai_maitri ๊ THAI CHARACTER MAI TRI */
  { 0x0deb, 0x0e4b }, /*            Thai_maichattawa ๋ THAI CHARACTER MAI CHATTAWA */
  { 0x0dec, 0x0e4c }, /*            Thai_thanthakhat ์ THAI CHARACTER THANTHAKHAT */
  { 0x0ded, 0x0e4d }, /*               Thai_nikhahit ๠THAI CHARACTER NIKHAHIT */
  { 0x0df0, 0x0e50 }, /*                 Thai_leksun ๠THAI DIGIT ZERO */
  { 0x0df1, 0x0e51 }, /*                Thai_leknung ๑ THAI DIGIT ONE */
  { 0x0df2, 0x0e52 }, /*                Thai_leksong ๒ THAI DIGIT TWO */
  { 0x0df3, 0x0e53 }, /*                 Thai_leksam ๓ THAI DIGIT THREE */
  { 0x0df4, 0x0e54 }, /*                  Thai_leksi ๔ THAI DIGIT FOUR */
  { 0x0df5, 0x0e55 }, /*                  Thai_lekha ๕ THAI DIGIT FIVE */
  { 0x0df6, 0x0e56 }, /*                 Thai_lekhok ๖ THAI DIGIT SIX */
  { 0x0df7, 0x0e57 }, /*                Thai_lekchet ๗ THAI DIGIT SEVEN */
  { 0x0df8, 0x0e58 }, /*                Thai_lekpaet ๘ THAI DIGIT EIGHT */
  { 0x0df9, 0x0e59 }, /*                 Thai_lekkao ๙ THAI DIGIT NINE */
  { 0x0ea1, 0x3131 }, /*               Hangul_Kiyeog ㄱ HANGUL LETTER KIYEOK */
  { 0x0ea2, 0x3132 }, /*          Hangul_SsangKiyeog ㄲ HANGUL LETTER SSANGKIYEOK */
  { 0x0ea3, 0x3133 }, /*           Hangul_KiyeogSios ㄳ HANGUL LETTER KIYEOK-SIOS */
  { 0x0ea4, 0x3134 }, /*                Hangul_Nieun ã„´ HANGUL LETTER NIEUN */
  { 0x0ea5, 0x3135 }, /*           Hangul_NieunJieuj ㄵ HANGUL LETTER NIEUN-CIEUC */
  { 0x0ea6, 0x3136 }, /*           Hangul_NieunHieuh ã„¶ HANGUL LETTER NIEUN-HIEUH */
  { 0x0ea7, 0x3137 }, /*               Hangul_Dikeud ã„· HANGUL LETTER TIKEUT */
  { 0x0ea8, 0x3138 }, /*          Hangul_SsangDikeud ㄸ HANGUL LETTER SSANGTIKEUT */
  { 0x0ea9, 0x3139 }, /*                Hangul_Rieul ㄹ HANGUL LETTER RIEUL */
  { 0x0eaa, 0x313a }, /*          Hangul_RieulKiyeog ㄺ HANGUL LETTER RIEUL-KIYEOK */
  { 0x0eab, 0x313b }, /*           Hangul_RieulMieum ã„» HANGUL LETTER RIEUL-MIEUM */
  { 0x0eac, 0x313c }, /*           Hangul_RieulPieub ㄼ HANGUL LETTER RIEUL-PIEUP */
  { 0x0ead, 0x313d }, /*            Hangul_RieulSios ㄽ HANGUL LETTER RIEUL-SIOS */
  { 0x0eae, 0x313e }, /*           Hangul_RieulTieut ㄾ HANGUL LETTER RIEUL-THIEUTH */
  { 0x0eaf, 0x313f }, /*          Hangul_RieulPhieuf ã„¿ HANGUL LETTER RIEUL-PHIEUPH */
  { 0x0eb0, 0x3140 }, /*           Hangul_RieulHieuh ã…€ HANGUL LETTER RIEUL-HIEUH */
  { 0x0eb1, 0x3141 }, /*                Hangul_Mieum ã… HANGUL LETTER MIEUM */
  { 0x0eb2, 0x3142 }, /*                Hangul_Pieub ã…‚ HANGUL LETTER PIEUP */
  { 0x0eb3, 0x3143 }, /*           Hangul_SsangPieub ã…ƒ HANGUL LETTER SSANGPIEUP */
  { 0x0eb4, 0x3144 }, /*            Hangul_PieubSios ã…„ HANGUL LETTER PIEUP-SIOS */
  { 0x0eb5, 0x3145 }, /*                 Hangul_Sios ã…… HANGUL LETTER SIOS */
  { 0x0eb6, 0x3146 }, /*            Hangul_SsangSios ã…† HANGUL LETTER SSANGSIOS */
  { 0x0eb7, 0x3147 }, /*                Hangul_Ieung ã…‡ HANGUL LETTER IEUNG */
  { 0x0eb8, 0x3148 }, /*                Hangul_Jieuj ã…ˆ HANGUL LETTER CIEUC */
  { 0x0eb9, 0x3149 }, /*           Hangul_SsangJieuj ã…‰ HANGUL LETTER SSANGCIEUC */
  { 0x0eba, 0x314a }, /*                Hangul_Cieuc ã…Š HANGUL LETTER CHIEUCH */
  { 0x0ebb, 0x314b }, /*               Hangul_Khieuq ã…‹ HANGUL LETTER KHIEUKH */
  { 0x0ebc, 0x314c }, /*                Hangul_Tieut ㅌ HANGUL LETTER THIEUTH */
  { 0x0ebd, 0x314d }, /*               Hangul_Phieuf ã… HANGUL LETTER PHIEUPH */
  { 0x0ebe, 0x314e }, /*                Hangul_Hieuh ã…Ž HANGUL LETTER HIEUH */
  { 0x0ebf, 0x314f }, /*                    Hangul_A ã… HANGUL LETTER A */
  { 0x0ec0, 0x3150 }, /*                   Hangul_AE ã… HANGUL LETTER AE */
  { 0x0ec1, 0x3151 }, /*                   Hangul_YA ã…‘ HANGUL LETTER YA */
  { 0x0ec2, 0x3152 }, /*                  Hangul_YAE ã…’ HANGUL LETTER YAE */
  { 0x0ec3, 0x3153 }, /*                   Hangul_EO ã…“ HANGUL LETTER EO */
  { 0x0ec4, 0x3154 }, /*                    Hangul_E ã…” HANGUL LETTER E */
  { 0x0ec5, 0x3155 }, /*                  Hangul_YEO ã…• HANGUL LETTER YEO */
  { 0x0ec6, 0x3156 }, /*                   Hangul_YE ã…– HANGUL LETTER YE */
  { 0x0ec7, 0x3157 }, /*                    Hangul_O ã…— HANGUL LETTER O */
  { 0x0ec8, 0x3158 }, /*                   Hangul_WA ã…˜ HANGUL LETTER WA */
  { 0x0ec9, 0x3159 }, /*                  Hangul_WAE ã…™ HANGUL LETTER WAE */
  { 0x0eca, 0x315a }, /*                   Hangul_OE ã…š HANGUL LETTER OE */
  { 0x0ecb, 0x315b }, /*                   Hangul_YO ã…› HANGUL LETTER YO */
  { 0x0ecc, 0x315c }, /*                    Hangul_U ㅜ HANGUL LETTER U */
  { 0x0ecd, 0x315d }, /*                  Hangul_WEO ã… HANGUL LETTER WEO */
  { 0x0ece, 0x315e }, /*                   Hangul_WE ã…ž HANGUL LETTER WE */
  { 0x0ecf, 0x315f }, /*                   Hangul_WI ã…Ÿ HANGUL LETTER WI */
  { 0x0ed0, 0x3160 }, /*                   Hangul_YU ã…  HANGUL LETTER YU */
  { 0x0ed1, 0x3161 }, /*                   Hangul_EU ã…¡ HANGUL LETTER EU */
  { 0x0ed2, 0x3162 }, /*                   Hangul_YI ã…¢ HANGUL LETTER YI */
  { 0x0ed3, 0x3163 }, /*                    Hangul_I ã…£ HANGUL LETTER I */
  { 0x0ed4, 0x11a8 }, /*             Hangul_J_Kiyeog ᆨ HANGUL JONGSEONG KIYEOK */
  { 0x0ed5, 0x11a9 }, /*        Hangul_J_SsangKiyeog ᆩ HANGUL JONGSEONG SSANGKIYEOK */
  { 0x0ed6, 0x11aa }, /*         Hangul_J_KiyeogSios ᆪ HANGUL JONGSEONG KIYEOK-SIOS */
  { 0x0ed7, 0x11ab }, /*              Hangul_J_Nieun ᆫ HANGUL JONGSEONG NIEUN */
  { 0x0ed8, 0x11ac }, /*         Hangul_J_NieunJieuj ᆬ HANGUL JONGSEONG NIEUN-CIEUC */
  { 0x0ed9, 0x11ad }, /*         Hangul_J_NieunHieuh ᆭ HANGUL JONGSEONG NIEUN-HIEUH */
  { 0x0eda, 0x11ae }, /*             Hangul_J_Dikeud ᆮ HANGUL JONGSEONG TIKEUT */
  { 0x0edb, 0x11af }, /*              Hangul_J_Rieul ᆯ HANGUL JONGSEONG RIEUL */
  { 0x0edc, 0x11b0 }, /*        Hangul_J_RieulKiyeog ᆰ HANGUL JONGSEONG RIEUL-KIYEOK */
  { 0x0edd, 0x11b1 }, /*         Hangul_J_RieulMieum ᆱ HANGUL JONGSEONG RIEUL-MIEUM */
  { 0x0ede, 0x11b2 }, /*         Hangul_J_RieulPieub ᆲ HANGUL JONGSEONG RIEUL-PIEUP */
  { 0x0edf, 0x11b3 }, /*          Hangul_J_RieulSios ᆳ HANGUL JONGSEONG RIEUL-SIOS */
  { 0x0ee0, 0x11b4 }, /*         Hangul_J_RieulTieut ᆴ HANGUL JONGSEONG RIEUL-THIEUTH */
  { 0x0ee1, 0x11b5 }, /*        Hangul_J_RieulPhieuf ᆵ HANGUL JONGSEONG RIEUL-PHIEUPH */
  { 0x0ee2, 0x11b6 }, /*         Hangul_J_RieulHieuh ᆶ HANGUL JONGSEONG RIEUL-HIEUH */
  { 0x0ee3, 0x11b7 }, /*              Hangul_J_Mieum ᆷ HANGUL JONGSEONG MIEUM */
  { 0x0ee4, 0x11b8 }, /*              Hangul_J_Pieub ᆸ HANGUL JONGSEONG PIEUP */
  { 0x0ee5, 0x11b9 }, /*          Hangul_J_PieubSios ᆹ HANGUL JONGSEONG PIEUP-SIOS */
  { 0x0ee6, 0x11ba }, /*               Hangul_J_Sios ᆺ HANGUL JONGSEONG SIOS */
  { 0x0ee7, 0x11bb }, /*          Hangul_J_SsangSios ᆻ HANGUL JONGSEONG SSANGSIOS */
  { 0x0ee8, 0x11bc }, /*              Hangul_J_Ieung ᆼ HANGUL JONGSEONG IEUNG */
  { 0x0ee9, 0x11bd }, /*              Hangul_J_Jieuj ᆽ HANGUL JONGSEONG CIEUC */
  { 0x0eea, 0x11be }, /*              Hangul_J_Cieuc ᆾ HANGUL JONGSEONG CHIEUCH */
  { 0x0eeb, 0x11bf }, /*             Hangul_J_Khieuq ᆿ HANGUL JONGSEONG KHIEUKH */
  { 0x0eec, 0x11c0 }, /*              Hangul_J_Tieut ᇀ HANGUL JONGSEONG THIEUTH */
  { 0x0eed, 0x11c1 }, /*             Hangul_J_Phieuf ᇠHANGUL JONGSEONG PHIEUPH */
  { 0x0eee, 0x11c2 }, /*              Hangul_J_Hieuh ᇂ HANGUL JONGSEONG HIEUH */
  { 0x0eef, 0x316d }, /*     Hangul_RieulYeorinHieuh ã…­ HANGUL LETTER RIEUL-YEORINHIEUH */
  { 0x0ef0, 0x3171 }, /*    Hangul_SunkyeongeumMieum ã…± HANGUL LETTER KAPYEOUNMIEUM */
  { 0x0ef1, 0x3178 }, /*    Hangul_SunkyeongeumPieub ã…¸ HANGUL LETTER KAPYEOUNPIEUP */
  { 0x0ef2, 0x317f }, /*              Hangul_PanSios ã…¿ HANGUL LETTER PANSIOS */
  { 0x0ef3, 0x3181 }, /*    Hangul_KkogjiDalrinIeung ㆠHANGUL LETTER YESIEUNG */
  { 0x0ef4, 0x3184 }, /*   Hangul_SunkyeongeumPhieuf ㆄ HANGUL LETTER KAPYEOUNPHIEUPH */
  { 0x0ef5, 0x3186 }, /*          Hangul_YeorinHieuh ㆆ HANGUL LETTER YEORINHIEUH */
  { 0x0ef6, 0x318d }, /*                Hangul_AraeA ㆠHANGUL LETTER ARAEA */
  { 0x0ef7, 0x318e }, /*               Hangul_AraeAE ㆎ HANGUL LETTER ARAEAE */
  { 0x0ef8, 0x11eb }, /*            Hangul_J_PanSios ᇫ HANGUL JONGSEONG PANSIOS */
  { 0x0ef9, 0x11f0 }, /*  Hangul_J_KkogjiDalrinIeung ᇰ HANGUL JONGSEONG YESIEUNG */
  { 0x0efa, 0x11f9 }, /*        Hangul_J_YeorinHieuh ᇹ HANGUL JONGSEONG YEORINHIEUH */
  { 0x0eff, 0x20a9 }, /*                  Korean_Won â‚© WON SIGN */
  { 0x13a4, 0x20ac }, /*                        Euro € EURO SIGN */
  { 0x13bc, 0x0152 }, /*                          OE Å’ LATIN CAPITAL LIGATURE OE */
  { 0x13bd, 0x0153 }, /*                          oe Å“ LATIN SMALL LIGATURE OE */
  { 0x13be, 0x0178 }, /*                  Ydiaeresis Ÿ LATIN CAPITAL LETTER Y WITH DIAERESIS */
  { 0x20a0, 0x20a0 }, /*                     EcuSign â‚  EURO-CURRENCY SIGN */
  { 0x20a1, 0x20a1 }, /*                   ColonSign â‚¡ COLON SIGN */
  { 0x20a2, 0x20a2 }, /*                CruzeiroSign â‚¢ CRUZEIRO SIGN */
  { 0x20a3, 0x20a3 }, /*                  FFrancSign â‚£ FRENCH FRANC SIGN */
  { 0x20a4, 0x20a4 }, /*                    LiraSign ₤ LIRA SIGN */
  { 0x20a5, 0x20a5 }, /*                    MillSign â‚¥ MILL SIGN */
  { 0x20a6, 0x20a6 }, /*                   NairaSign ₦ NAIRA SIGN */
  { 0x20a7, 0x20a7 }, /*                  PesetaSign â‚§ PESETA SIGN */
  { 0x20a8, 0x20a8 }, /*                   RupeeSign ₨ RUPEE SIGN */
  { 0x20a9, 0x20a9 }, /*                     WonSign â‚© WON SIGN */
  { 0x20aa, 0x20aa }, /*               NewSheqelSign ₪ NEW SHEQEL SIGN */
  { 0x20ab, 0x20ab }, /*                    DongSign â‚« DONG SIGN */
  { 0x20ac, 0x20ac }, /*                    EuroSign € EURO SIGN */
};

VISIBLE
long keysym2ucs(KeySym keysym)
{
    int min = 0;
    int max = sizeof(keysymtab) / sizeof(struct codepair) - 1;

    /* first check for Latin-1 characters (1:1 mapping) */
    if ((keysym >= 0x0020 && keysym <= 0x007e) ||
        (keysym >= 0x00a0 && keysym <= 0x00ff))
        return keysym;

    /* also check for directly encoded 24-bit UCS characters */
    if ((keysym & 0xff000000) == 0x01000000)
	return keysym & 0x00ffffff;

    /* binary search in table */
    while (max >= min) {
	int mid = (min + max) / 2;
	if (keysymtab[mid].keysym < keysym)
	    min = mid + 1;
	else if (keysymtab[mid].keysym > keysym)
	    max = mid - 1;
	else {
	    /* found it */
	    return keysymtab[mid].ucs;
	}
    }

    /* no matching Unicode value found */
    return -1;
}
xterm-330/trace.c0000644000175100001440000006221613121703456012512 0ustar  tomusers/* $XTermId: trace.c,v 1.171 2017/06/19 08:11:26 tom Exp $ */

/*
 * Copyright 1997-2016,2017 by Thomas E. Dickey
 *
 *                         All Rights Reserved
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name(s) of the above copyright
 * holders shall not be used in advertising or otherwise to promote the
 * sale, use or other dealings in this Software without prior written
 * authorization.
 */

/*
 * debugging support via TRACE macro.
 */

#include 		/* for definition of GCC_UNUSED */
#include 

#if OPT_TRACE

#include 
#include 

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include 
#include 

#ifdef HAVE_X11_TRANSLATEI_H
#include 
#include 
#else
#ifdef __cplusplus
extern "C" {
#endif

    extern String _XtPrintXlations(Widget w,
				   XtTranslations xlations,
				   Widget accelWidget,
				   _XtBoolean includeRHS);
#ifdef __cplusplus
}
#endif
#endif
const char *trace_who = "parent";

static FILE *trace_fp;

void
Trace(const char *fmt,...)
{
    static const char *trace_out;
    va_list ap;

    if (trace_fp != 0
	&& trace_who != trace_out) {
	fclose(trace_fp);
	trace_fp = 0;
    }
    trace_out = trace_who;

    if (!trace_fp) {
	mode_t oldmask = umask(077);
	char name[BUFSIZ];
#if 0				/* usually I do not want unique names */
	int unique;
	for (unique = 0;; ++unique) {
	    if (unique)
		sprintf(name, "Trace-%s.out-%d", trace_who, unique);
	    else
		sprintf(name, "Trace-%s.out", trace_who);
	    if ((trace_fp = fopen(name, "r")) == 0) {
		break;
	    }
	    fclose(trace_fp);
	}
#else
	sprintf(name, "Trace-%s.out", trace_who);
#endif
	trace_fp = fopen(name, "w");
	/*
	 * Try to put the trace-file in user's home-directory if the current
	 * directory is not writable.
	 */
	if (trace_fp == 0) {
	    char *home = getenv("HOME");
	    if (home != 0) {
		sprintf(name, "%.*s/Trace-%.8s.out",
			(BUFSIZ - 21), home,
			trace_who);
		trace_fp = fopen(name, "w");
	    }
	}
	if (trace_fp != 0) {
	    fprintf(trace_fp, "%s\n", xtermVersion());
	    TraceIds(NULL, 0);
	}
	if (!trace_fp) {
	    xtermWarning("Cannot open \"%s\"\n", name);
	    exit(EXIT_FAILURE);
	}
	(void) umask(oldmask);
    }

    va_start(ap, fmt);
    vfprintf(trace_fp, fmt, ap);
    (void) fflush(trace_fp);
    va_end(ap);
}

void
TraceClose(void)
{
    if (trace_fp != 0) {
	(void) fclose(trace_fp);
	(void) fflush(stdout);
	(void) fflush(stderr);
	(void) visibleChars(NULL, 0);
	(void) visibleIChars(NULL, 0);
	trace_fp = 0;
    }
}

void
TraceIds(const char *fname, int lnum)
{
    Trace("process %d ", (int) getpid());
#ifdef HAVE_UNISTD_H
    Trace("real (%u/%u) effective (%u/%u)",
	  (unsigned) getuid(), (unsigned) getgid(),
	  (unsigned) geteuid(), (unsigned) getegid());
#endif
    if (fname != 0) {
	Trace(" (%s@%d)\n", fname, lnum);
    } else {
	time_t now = time((time_t *) 0);
	Trace("-- %s", ctime(&now));
    }
}

void
TraceTime(const char *fname, int lnum)
{
    time_t now;
    if (fname != 0) {
	Trace("datetime (%s@%d) ", fname, lnum);
    }
    now = time((time_t *) 0);
    Trace("-- %s", ctime(&now));
}

static void
formatAscii(char *dst, unsigned value)
{
    switch (value) {
    case '\\':
	sprintf(dst, "\\\\");
	break;
    case '\b':
	sprintf(dst, "\\b");
	break;
    case '\n':
	sprintf(dst, "\\n");
	break;
    case '\r':
	sprintf(dst, "\\r");
	break;
    case '\t':
	sprintf(dst, "\\t");
	break;
    default:
	if (E2A(value) < 32 || (E2A(value) >= 127 && E2A(value) < 160))
	    sprintf(dst, "\\%03o", value & 0xff);
	else
	    sprintf(dst, "%c", CharOf(value));
	break;
    }
}

#if OPT_DEC_CHRSET

const char *
visibleDblChrset(unsigned chrset)
{
    const char *result = "?";
    switch (chrset) {
    case CSET_SWL:
	result = "CSET_SWL";
	break;
    case CSET_DHL_TOP:
	result = "CSET_DHL_TOP";
	break;
    case CSET_DHL_BOT:
	result = "CSET_DHL_BOT";
	break;
    case CSET_DWL:
	result = "CSET_DWL";
	break;
    }
    return result;
}
#endif

const char *
visibleScsCode(int chrset)
{
#define MAP(to,from) case from: result = to; break
    const char *result = "";
    switch ((DECNRCM_codes) chrset) {
	MAP("B", nrc_ASCII);
	MAP("A", nrc_British);
	MAP("A", nrc_British_Latin_1);
	MAP("&4", nrc_Cyrillic);
	MAP("0", nrc_DEC_Spec_Graphic);
	MAP("1", nrc_DEC_Alt_Chars);
	MAP("2", nrc_DEC_Alt_Graphics);
	MAP("<", nrc_DEC_Supp);
	MAP("%5", nrc_DEC_Supp_Graphic);
	MAP(">", nrc_DEC_Technical);
	MAP("4", nrc_Dutch);
	MAP("5", nrc_Finnish);
	MAP("C", nrc_Finnish2);
	MAP("R", nrc_French);
	MAP("f", nrc_French2);
	MAP("Q", nrc_French_Canadian);
	MAP("9", nrc_French_Canadian2);
	MAP("K", nrc_German);
	MAP("\"?", nrc_Greek);
	MAP("F", nrc_Greek_Supp);
	MAP("\"4", nrc_Hebrew);
	MAP("%=", nrc_Hebrew2);
	MAP("H", nrc_Hebrew_Supp);
	MAP("Y", nrc_Italian);
	MAP("M", nrc_Latin_5_Supp);
	MAP("L", nrc_Latin_Cyrillic);
	MAP("`", nrc_Norwegian_Danish);
	MAP("E", nrc_Norwegian_Danish2);
	MAP("6", nrc_Norwegian_Danish3);
	MAP("%6", nrc_Portugese);
	MAP("&5", nrc_Russian);
	MAP("%3", nrc_SCS_NRCS);
	MAP("Z", nrc_Spanish);
	MAP("7", nrc_Swedish);
	MAP("H", nrc_Swedish2);
	MAP("=", nrc_Swiss);
	MAP("%0", nrc_Turkish);
	MAP("%2", nrc_Turkish2);
	MAP("", nrc_Unknown);
    }
#undef MAP
    return result;
}

const char *
visibleChars(const Char *buf, unsigned len)
{
    static char *result;
    static unsigned used;

    if (buf != 0) {
	unsigned limit = ((len + 1) * 8) + 1;

	if (limit > used) {
	    used = limit;
	    result = XtRealloc(result, used);
	}
	if (result != 0) {
	    char *dst = result;
	    *dst = '\0';
	    while (len--) {
		unsigned value = *buf++;
		formatAscii(dst, value);
		dst += strlen(dst);
	    }
	}
    } else if (result != 0) {
	free(result);
	result = 0;
	used = 0;
    }
    return NonNull(result);
}

const char *
visibleIChars(const IChar *buf, unsigned len)
{
    static char *result;
    static unsigned used;

    if (buf != 0) {
	unsigned limit = ((len + 1) * 8) + 1;

	if (limit > used) {
	    used = limit;
	    result = XtRealloc(result, used);
	}
	if (result != 0) {
	    char *dst = result;
	    *dst = '\0';
	    while (len--) {
		unsigned value = *buf++;
#if OPT_WIDE_CHARS
		if (value > 255)
		    sprintf(dst, "\\u+%04X", value);
		else
#endif
		    formatAscii(dst, value);
		dst += strlen(dst);
	    }
	}
    } else if (result != 0) {
	free(result);
	result = 0;
	used = 0;
    }
    return NonNull(result);
}

const char *
visibleUChar(unsigned chr)
{
    IChar buf[1];
    buf[0] = chr;
    return visibleIChars(buf, 1);
}

const char *
visibleEventType(int type)
{
    const char *result = "?";
    switch (type) {
	CASETYPE(KeyPress);
	CASETYPE(KeyRelease);
	CASETYPE(ButtonPress);
	CASETYPE(ButtonRelease);
	CASETYPE(MotionNotify);
	CASETYPE(EnterNotify);
	CASETYPE(LeaveNotify);
	CASETYPE(FocusIn);
	CASETYPE(FocusOut);
	CASETYPE(KeymapNotify);
	CASETYPE(Expose);
	CASETYPE(GraphicsExpose);
	CASETYPE(NoExpose);
	CASETYPE(VisibilityNotify);
	CASETYPE(CreateNotify);
	CASETYPE(DestroyNotify);
	CASETYPE(UnmapNotify);
	CASETYPE(MapNotify);
	CASETYPE(MapRequest);
	CASETYPE(ReparentNotify);
	CASETYPE(ConfigureNotify);
	CASETYPE(ConfigureRequest);
	CASETYPE(GravityNotify);
	CASETYPE(ResizeRequest);
	CASETYPE(CirculateNotify);
	CASETYPE(CirculateRequest);
	CASETYPE(PropertyNotify);
	CASETYPE(SelectionClear);
	CASETYPE(SelectionRequest);
	CASETYPE(SelectionNotify);
	CASETYPE(ColormapNotify);
	CASETYPE(ClientMessage);
	CASETYPE(MappingNotify);
    }
    return result;
}

const char *
visibleNotifyMode(int code)
{
    const char *result = "?";
    switch (code) {
	CASETYPE(NotifyNormal);
	CASETYPE(NotifyGrab);
	CASETYPE(NotifyUngrab);
	CASETYPE(NotifyWhileGrabbed);
    }
    return result;
}

const char *
visibleNotifyDetail(int code)
{
    const char *result = "?";
    switch (code) {
	CASETYPE(NotifyAncestor);
	CASETYPE(NotifyVirtual);
	CASETYPE(NotifyInferior);
	CASETYPE(NotifyNonlinear);
	CASETYPE(NotifyNonlinearVirtual);
	CASETYPE(NotifyPointer);
	CASETYPE(NotifyPointerRoot);
	CASETYPE(NotifyDetailNone);
    }
    return result;
}

const char *
visibleSelectionTarget(Display *d, Atom a)
{
    const char *result = "?";

    if (a == XA_STRING) {
	result = "XA_STRING";
    } else if (a == XA_TEXT(d)) {
	result = "XA_TEXT()";
    } else if (a == XA_COMPOUND_TEXT(d)) {
	result = "XA_COMPOUND_TEXT()";
    } else if (a == XA_UTF8_STRING(d)) {
	result = "XA_UTF8_STRING()";
    } else if (a == XA_TARGETS(d)) {
	result = "XA_TARGETS()";
    }

    return result;
}

const char *
visibleTekparse(int code)
{
    static const struct {
	int code;
	const char *name;
    } table[] = {
#include "Tekparse.cin"
    };
    const char *result = "?";
    Cardinal n;
    for (n = 0; n < XtNumber(table); ++n) {
	if (table[n].code == code) {
	    result = table[n].name;
	    break;
	}
    }
    return result;
}

const char *
visibleVTparse(int code)
{
    static const struct {
	int code;
	const char *name;
    } table[] = {
#include "VTparse.cin"
    };
    const char *result = "?";
    Cardinal n;
    for (n = 0; n < XtNumber(table); ++n) {
	if (table[n].code == code) {
	    result = table[n].name;
	    break;
	}
    }
    return result;
}

const char *
visibleXError(int code)
{
    static char temp[80];
    const char *result = "?";
    switch (code) {
	CASETYPE(Success);
	CASETYPE(BadRequest);
	CASETYPE(BadValue);
	CASETYPE(BadWindow);
	CASETYPE(BadPixmap);
	CASETYPE(BadAtom);
	CASETYPE(BadCursor);
	CASETYPE(BadFont);
	CASETYPE(BadMatch);
	CASETYPE(BadDrawable);
	CASETYPE(BadAccess);
	CASETYPE(BadAlloc);
	CASETYPE(BadColor);
	CASETYPE(BadGC);
	CASETYPE(BadIDChoice);
	CASETYPE(BadName);
	CASETYPE(BadLength);
	CASETYPE(BadImplementation);
    default:
	sprintf(temp, "%d", code);
	result = temp;
	break;
    }
    return result;
}

#if OPT_TRACE_FLAGS
#define isScrnFlag(flag) ((flag) == LINEWRAPPED)

static char *
ScrnText(LineData *ld)
{
    return visibleIChars(ld->charData, ld->lineSize);
}

#define SHOW_BAD_LINE(name, ld) \
	Trace("OOPS " #name " bad row\n")

#define SHOW_SCRN_FLAG(name,code) \
	Trace(#name " %s:%s\n", \
	      code ? "*" : "", \
	      ScrnText(ld))

void
LineClrFlag(LineData *ld, int flag)
{
    if (ld == 0) {
	SHOW_BAD_LINE(LineClrFlag, ld);
	assert(0);
    } else if (isScrnFlag(flag)) {
	SHOW_SCRN_FLAG(LineClrFlag, 0);
    }

    LineFlags(ld) &= ~flag;
}

void
LineSetFlag(LineData *ld, int flag)
{
    if (ld == 0) {
	SHOW_BAD_LINE(LineSetFlag, ld);
	assert(0);
    } else if (isScrnFlag(flag)) {
	SHOW_SCRN_FLAG(LineSetFlag, 1);
    }

    LineFlags(ld) |= flag;
}

int
LineTstFlag(LineData ld, int flag)
{
    int code = 0;
    if (ld == 0) {
	SHOW_BAD_LINE(LineTstFlag, ld);
    } else {
	code = LineFlags(ld);

	if (isScrnFlag(flag)) {
	    SHOW_SCRN_FLAG(LineTstFlag, code);
	}
    }
    return code;
}
#endif /* OPT_TRACE_FLAGS */

const char *
TraceAtomName(Display *dpy, Atom atom)
{
    static char *result;
    free(result);
    result = XGetAtomName(dpy, atom);
    return result;
}

/*
 * Trace the normal or alternate screen, showing color values up to 16, e.g.,
 * for debugging with vttest.
 */
void
TraceScreen(XtermWidget xw, int whichBuf)
{
    TScreen *screen = TScreenOf(xw);

    if (screen->editBuf_index[whichBuf]) {
	int row;

	TRACE(("TraceScreen %d:\n", whichBuf));
	for (row = 0; row <= screen->max_row; ++row) {
	    LineData *ld = getLineData(screen, row);

	    TRACE((" %3d:", row));
	    if (ld != 0) {
		int col;

		for (col = 0; col < ld->lineSize; ++col) {
		    int ch = (int) ld->charData[col];
		    if (ch < ' ')
			ch = ' ';
		    if (ch >= 127)
			ch = '#';
		    TRACE(("%c", ch));
		}
		TRACE((":\n"));

		TRACE(("  xx:"));
		for (col = 0; col < ld->lineSize; ++col) {
		    unsigned attrs = ld->attribs[col];
		    char ch;
		    if (attrs & PROTECTED) {
			ch = '*';
		    } else if (attrs & BLINK) {
			ch = 'B';
		    } else if (attrs & CHARDRAWN) {
			ch = '+';
		    } else {
			ch = ' ';
		    }
		    TRACE(("%c", ch));
		}
		TRACE((":\n"));

#if 0
		TRACE(("  fg:"));
		for (col = 0; col < ld->lineSize; ++col) {
		    unsigned fg = extract_fg(xw, ld->color[col], ld->attribs[col]);
		    if (fg > 15)
			fg = 15;
		    TRACE(("%1x", fg));
		}
		TRACE((":\n"));

		TRACE(("  bg:"));
		for (col = 0; col < ld->lineSize; ++col) {
		    unsigned bg = extract_bg(xw, ld->color[col], ld->attribs[col]);
		    if (bg > 15)
			bg = 15;
		    TRACE(("%1x", bg));
		}
		TRACE((":\n"));
#endif
	    } else {
		TRACE(("null lineData\n"));
	    }
	}
    } else {
	TRACE(("TraceScreen %d is nil\n", whichBuf));
    }
}

void
TraceFocus(Widget w, XEvent *ev)
{
    TRACE(("trace_focus event type %d:%s\n",
	   ev->type, visibleEventType(ev->type)));
    switch (ev->type) {
    case FocusIn:
    case FocusOut:
	{
	    XFocusChangeEvent *event = (XFocusChangeEvent *) ev;
	    TRACE(("\tdetail: %s\n", visibleNotifyDetail(event->detail)));
	    TRACE(("\tmode:   %s\n", visibleNotifyMode(event->mode)));
	    TRACE(("\twindow: %#lx\n", event->window));
	}
	break;
    case EnterNotify:
    case LeaveNotify:
	{
	    XCrossingEvent *event = (XCrossingEvent *) ev;
	    TRACE(("\tdetail:    %s\n", visibleNotifyDetail(event->detail)));
	    TRACE(("\tmode:      %s\n", visibleNotifyMode(event->mode)));
	    TRACE(("\twindow:    %#lx\n", event->window));
	    TRACE(("\tfocus:     %d\n", event->focus));
	    TRACE(("\troot:      %#lx\n", event->root));
	    TRACE(("\tsubwindow: %#lx\n", event->subwindow));
	}
	break;
    }
    while (w != 0) {
	TRACE(("w %p -> %#lx\n", (void *) w, XtWindow(w)));
	w = XtParent(w);
    }
}

void
TraceSizeHints(XSizeHints * hints)
{
    TRACE(("size hints:\n"));
    if (hints->flags & (USPosition | PPosition))
	TRACE(("   position   %d,%d%s%s\n", hints->y, hints->x,
	       (hints->flags & USPosition) ? " user" : "",
	       (hints->flags & PPosition) ? " prog" : ""));
    if (hints->flags & (USSize | PSize))
	TRACE(("   size       %d,%d%s%s\n", hints->height, hints->width,
	       (hints->flags & USSize) ? " user" : "",
	       (hints->flags & PSize) ? " prog" : ""));
    if (hints->flags & PMinSize)
	TRACE(("   min        %d,%d\n", hints->min_height, hints->min_width));
    if (hints->flags & PMaxSize)
	TRACE(("   max        %d,%d\n", hints->max_height, hints->max_width));
    if (hints->flags & PResizeInc)
	TRACE(("   inc        %d,%d\n", hints->height_inc, hints->width_inc));
    else
	TRACE(("   inc        NONE!\n"));
    if (hints->flags & PAspect)
	TRACE(("   min aspect %d/%d\n", hints->min_aspect.y, hints->min_aspect.y));
    if (hints->flags & PAspect)
	TRACE(("   max aspect %d/%d\n", hints->max_aspect.y, hints->max_aspect.y));
    if (hints->flags & PBaseSize)
	TRACE(("   base       %d,%d\n", hints->base_height, hints->base_width));
    if (hints->flags & PWinGravity)
	TRACE(("   gravity    %d\n", hints->win_gravity));
}

static void
TraceEventMask(const char *tag, long mask)
{
#define DATA(name) { name##Mask, #name }
    /* *INDENT-OFF* */
    static struct {
	long mask;
	const char *name;
    } table[] = {
	DATA(KeyPress),
	DATA(KeyRelease),
	DATA(ButtonPress),
	DATA(ButtonRelease),
	DATA(EnterWindow),
	DATA(LeaveWindow),
	DATA(PointerMotion),
	DATA(PointerMotionHint),
	DATA(Button1Motion),
	DATA(Button2Motion),
	DATA(Button3Motion),
	DATA(Button4Motion),
	DATA(Button5Motion),
	DATA(ButtonMotion),
	DATA(KeymapState),
	DATA(Exposure),
	DATA(VisibilityChange),
	DATA(StructureNotify),
	DATA(ResizeRedirect),
	DATA(SubstructureNotify),
	DATA(SubstructureRedirect),
	DATA(FocusChange),
	DATA(PropertyChange),
	DATA(ColormapChange),
	DATA(OwnerGrabButton),
    };
#undef DATA
    Cardinal n;
    /* *INDENT-ON* */

    for (n = 0; n < XtNumber(table); ++n) {
	if (table[n].mask & mask) {
	    TRACE(("%s %s\n", tag, table[n].name));
	}
    }
}

void
TraceWindowAttributes(XWindowAttributes * attrs)
{
    TRACE(("window attributes:\n"));
    TRACE(("   position     %d,%d\n", attrs->y, attrs->x));
    TRACE(("   size         %dx%d\n", attrs->height, attrs->width));
    TRACE(("   border       %d\n", attrs->border_width));
    TRACE(("   depth        %d\n", attrs->depth));
    TRACE(("   bit_gravity  %d\n", attrs->bit_gravity));
    TRACE(("   win_gravity  %d\n", attrs->win_gravity));
    TRACE(("   root         %#lx\n", (long) attrs->root));
    TRACE(("   class        %s\n", ((attrs->class == InputOutput)
				    ? "InputOutput"
				    : ((attrs->class == InputOnly)
				       ? "InputOnly"
				       : "unknown"))));
    TRACE(("   map_state    %s\n", ((attrs->map_state == IsUnmapped)
				    ? "IsUnmapped"
				    : ((attrs->map_state == IsUnviewable)
				       ? "IsUnviewable"
				       : ((attrs->map_state == IsViewable)
					  ? "IsViewable"
					  : "unknown")))));
    TRACE(("   all_events\n"));
    TraceEventMask("        ", attrs->all_event_masks);
    TRACE(("   your_events\n"));
    TraceEventMask("        ", attrs->your_event_mask);
    TRACE(("   no_propagate\n"));
    TraceEventMask("        ", attrs->do_not_propagate_mask);
}

void
TraceWMSizeHints(XtermWidget xw)
{
    XSizeHints sizehints = xw->hints;

    getXtermSizeHints(xw);
    TraceSizeHints(&xw->hints);
    xw->hints = sizehints;
}

/*
 * Some calls to XGetAtom() will fail, and we don't want to stop.  So we use
 * our own error-handler.
 */
/* ARGSUSED */
static int
no_error(Display *dpy GCC_UNUSED, XErrorEvent *event GCC_UNUSED)
{
    return 1;
}

const char *
ModifierName(unsigned modifier)
{
    const char *s = "";
    if (modifier & ShiftMask)
	s = " Shift";
    else if (modifier & LockMask)
	s = " Lock";
    else if (modifier & ControlMask)
	s = " Control";
    else if (modifier & Mod1Mask)
	s = " Mod1";
    else if (modifier & Mod2Mask)
	s = " Mod2";
    else if (modifier & Mod3Mask)
	s = " Mod3";
    else if (modifier & Mod4Mask)
	s = " Mod4";
    else if (modifier & Mod5Mask)
	s = " Mod5";
    return s;
}

void
TraceTranslations(const char *name, Widget w)
{
    String result;
    XErrorHandler save = XSetErrorHandler(no_error);
    XtTranslations xlations;
    Widget xcelerat;

    TRACE(("TraceTranslations for %s (widget %#lx) {{\n", name, (long) w));
    if (w) {
	XtVaGetValues(w,
		      XtNtranslations, &xlations,
		      XtNaccelerators, &xcelerat,
		      (XtPointer) 0);
	TRACE(("... xlations %#08lx\n", (long) xlations));
	TRACE(("... xcelerat %#08lx\n", (long) xcelerat));
	result = _XtPrintXlations(w, xlations, xcelerat, True);
	TRACE(("%s\n", NonNull(result)));
	if (result)
	    XFree((char *) result);
    } else {
	TRACE(("none (widget is null)\n"));
    }
    TRACE(("}}\n"));
    XSetErrorHandler(save);
}

XtGeometryResult
TraceResizeRequest(const char *fn, int ln, Widget w,
		   unsigned reqwide,
		   unsigned reqhigh,
		   Dimension *gotwide,
		   Dimension *gothigh)
{
    XtGeometryResult rc;

    TRACE(("%s@%d ResizeRequest %ux%u\n", fn, ln, reqhigh, reqwide));
    rc = XtMakeResizeRequest((Widget) w,
			     (Dimension) reqwide,
			     (Dimension) reqhigh,
			     gotwide, gothigh);
    TRACE(("... ResizeRequest -> "));
    if (gothigh && gotwide)
	TRACE(("%dx%d ", *gothigh, *gotwide));
    TRACE(("(%d)\n", rc));
    return rc;
}

#define XRES_S(name) Trace(#name " = %s\n", NonNull(resp->name))
#define XRES_B(name) Trace(#name " = %s\n", MtoS(resp->name))
#define XRES_I(name) Trace(#name " = %d\n", resp->name)

void
TraceXtermResources(void)
{
    XTERM_RESOURCE *resp = &resource;

    Trace("XTERM_RESOURCE settings:\n");
    XRES_S(icon_geometry);
    XRES_S(title);
    XRES_S(icon_hint);
    XRES_S(icon_name);
    XRES_S(term_name);
    XRES_S(tty_modes);
    XRES_I(minBufSize);
    XRES_I(maxBufSize);
    XRES_B(hold_screen);
    XRES_B(utmpInhibit);
    XRES_B(utmpDisplayId);
    XRES_B(messages);
    XRES_S(menuLocale);
    XRES_S(omitTranslation);
    XRES_S(keyboardType);
#if OPT_PRINT_ON_EXIT
    XRES_I(printModeNow);
    XRES_I(printModeOnXError);
    XRES_I(printOptsNow);
    XRES_I(printOptsOnXError);
    XRES_S(printFileNow);
    XRES_S(printFileOnXError);
#endif
#if OPT_SUNPC_KBD
    XRES_B(sunKeyboard);
#endif
#if OPT_HP_FUNC_KEYS
    XRES_B(hpFunctionKeys);
#endif
#if OPT_SCO_FUNC_KEYS
    XRES_B(scoFunctionKeys);
#endif
#if OPT_SUN_FUNC_KEYS
    XRES_B(sunFunctionKeys);
#endif
#if OPT_INITIAL_ERASE
    XRES_B(ptyInitialErase);
    XRES_B(backarrow_is_erase);
#endif
    XRES_B(useInsertMode);
#if OPT_ZICONBEEP
    XRES_I(zIconBeep);
    XRES_S(zIconFormat);
#endif
#if OPT_PTY_HANDSHAKE
    XRES_B(wait_for_map);
    XRES_B(ptyHandshake);
    XRES_B(ptySttySize);
#endif
#if OPT_REPORT_CCLASS
    XRES_B(reportCClass);
#endif
#if OPT_REPORT_COLORS
    XRES_B(reportColors);
#endif
#if OPT_REPORT_FONTS
    XRES_B(reportFonts);
#endif
#if OPT_SAME_NAME
    XRES_B(sameName);
#endif
#if OPT_SESSION_MGT
    XRES_B(sessionMgt);
#endif
#if OPT_TOOLBAR
    XRES_B(toolBar);
#endif
#if OPT_MAXIMIZE
    XRES_B(maximized);
    XRES_S(fullscreen_s);
#endif
}

void
TraceArgv(const char *tag, char **argv)
{
    TRACE(("%s:\n", tag));
    if (argv != 0) {
	int n = 0;

	while (*argv != 0) {
	    TRACE(("  %d:%s\n", n++, *argv++));
	}
    }
}

static char *
parse_option(char *dst, String src, int first)
{
    char *s;

    if (!strncmp(src, "-/+", (size_t) 3)) {
	dst[0] = (char) first;
	strcpy(dst + 1, src + 3);
    } else {
	strcpy(dst, src);
    }
    for (s = dst; *s != '\0'; s++) {
	if (*s == '#' || *s == '%' || *s == 'S') {
	    s[1] = '\0';
	} else if (*s == ' ') {
	    *s = '\0';
	    break;
	}
    }
    return dst;
}

static Bool
same_option(OptionHelp * opt, XrmOptionDescRec * res)
{
    char temp[BUFSIZ];
    return !strcmp(parse_option(temp, opt->opt, res->option[0]), res->option);
}

static Bool
standard_option(String opt)
{
    static const char *table[] =
    {
	"+rv",
	"+synchronous",
	"-background",
	"-bd",
	"-bg",
	"-bordercolor",
	"-borderwidth",
	"-bw",
	"-display",
	"-fg",
	"-fn",
	"-font",
	"-foreground",
	"-geometry",
	"-iconic",
	"-name",
	"-reverse",
	"-rv",
	"-selectionTimeout",
	"-synchronous",
	"-title",
	"-xnllanguage",
	"-xrm",
	"-xtsessionID",
    };
    Cardinal n;
    char temp[BUFSIZ];

    opt = parse_option(temp, opt, '-');
    for (n = 0; n < XtNumber(table); n++) {
	if (!strcmp(opt, table[n]))
	    return True;
    }
    return False;
}

/*
 * Analyse the options/help messages for inconsistencies.
 */
void
TraceOptions(OptionHelp * options, XrmOptionDescRec * resources, Cardinal res_count)
{
    OptionHelp *opt_array = sortedOpts(options, resources, res_count);
    size_t j, k;
    XrmOptionDescRec *res_array = sortedOptDescs(resources, res_count);
    Bool first, found;

    TRACE(("Checking options-tables for inconsistencies:\n"));

#if 0
    TRACE(("Options listed in help-message:\n"));
    for (j = 0; options[j].opt != 0; j++)
	TRACE(("%5d %-28s %s\n", j, opt_array[j].opt, opt_array[j].desc));
    TRACE(("Options listed in resource-table:\n"));
    for (j = 0; j < res_count; j++)
	TRACE(("%5d %-28s %s\n", j, res_array[j].option, res_array[j].specifier));
#endif

    /* list all options[] not found in resources[] */
    for (j = 0, first = True; options[j].opt != 0; j++) {
	found = False;
	for (k = 0; k < res_count; k++) {
	    if (same_option(&opt_array[j], &res_array[k])) {
		found = True;
		break;
	    }
	}
	if (!found) {
	    if (first) {
		TRACE(("Options listed in help, not found in resource list:\n"));
		first = False;
	    }
	    TRACE(("  %-28s%s\n", opt_array[j].opt,
		   standard_option(opt_array[j].opt) ? " (standard)" : ""));
	}
    }

    /* list all resources[] not found in options[] */
    for (j = 0, first = True; j < res_count; j++) {
	found = False;
	for (k = 0; options[k].opt != 0; k++) {
	    if (same_option(&opt_array[k], &res_array[j])) {
		found = True;
		break;
	    }
	}
	if (!found) {
	    if (first) {
		TRACE(("Resource list items not found in options-help:\n"));
		first = False;
	    }
	    TRACE(("  %s\n", res_array[j].option));
	}
    }

    TRACE(("Resource list items that will be ignored by XtOpenApplication:\n"));
    for (j = 0; j < res_count; j++) {
	switch (res_array[j].argKind) {
	case XrmoptionSkipArg:
	    TRACE(("  %-28s {param}\n", res_array[j].option));
	    break;
	case XrmoptionSkipNArgs:
	    TRACE(("  %-28s {%ld params}\n", res_array[j].option, (long)
		   res_array[j].value));
	    break;
	case XrmoptionSkipLine:
	    TRACE(("  %-28s {remainder of line}\n", res_array[j].option));
	    break;
	case XrmoptionIsArg:
	case XrmoptionNoArg:
	case XrmoptionResArg:
	case XrmoptionSepArg:
	case XrmoptionStickyArg:
	default:
	    break;
	}
    }
}
#else
extern void empty_trace(void);
void
empty_trace(void)
{
}
#endif
xterm-330/error.h0000644000175100001440000000717212033423457012553 0ustar  tomusers/* $XTermId: error.h,v 1.25 2012/10/05 00:17:51 tom Exp $ */

/*
 * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 *
 *                         All Rights Reserved
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose and without fee is hereby granted,
 * provided that the above copyright notice appear in all copies and that
 * both that copyright notice and this permission notice appear in
 * supporting documentation, and that the name of Digital Equipment
 * Corporation not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 *
 *
 * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */

/* @(#)error.h	X10/6.6	11/6/86 */

/* main.c */
#define	ERROR_FIONBIO	11	/* main: ioctl() failed on FIONBIO */
#define	ERROR_F_GETFL	12	/* main: ioctl() failed on F_GETFL */
#define	ERROR_F_SETFL	13	/* main: ioctl() failed on F_SETFL */
#define	ERROR_OPDEVTTY	14	/* spawn: open() failed on /dev/tty */
#define	ERROR_TIOCGETP	15	/* spawn: ioctl() failed on TIOCGETP */
#define ERROR_PTSNAME   17	/* spawn: ptsname() failed */
#define ERROR_OPPTSNAME 18	/* spawn: open() failed on ptsname */
#define ERROR_PTEM      19	/* spawn: ioctl() failed on I_PUSH/"ptem" */
#define ERROR_CONSEM    20	/* spawn: ioctl() failed on I_PUSH/"consem" */
#define ERROR_LDTERM    21	/* spawn: ioctl() failed on I_PUSH/"ldterm" */
#define ERROR_TTCOMPAT  22	/* spawn: ioctl() failed on I_PUSH/"ttcompat" */
#define	ERROR_TIOCSETP	23	/* spawn: ioctl() failed on TIOCSETP */
#define	ERROR_TIOCSETC	24	/* spawn: ioctl() failed on TIOCSETC */
#define	ERROR_TIOCSETD	25	/* spawn: ioctl() failed on TIOCSETD */
#define	ERROR_TIOCSLTC	26	/* spawn: ioctl() failed on TIOCSLTC */
#define	ERROR_TIOCLSET	27	/* spawn: ioctl() failed on TIOCLSET */
#define	ERROR_INIGROUPS 28	/* spawn: initgroups() failed */
#define	ERROR_FORK	29	/* spawn: fork() failed */
#define	ERROR_EXEC	30	/* spawn: exec() failed */
#define	ERROR_PTYS	32	/* get_pty: not enough ptys */
#define ERROR_PTY_EXEC	34	/* waiting for initial map */
#define	ERROR_SETUID	35	/* spawn: setuid() failed */
#define	ERROR_INIT	36	/* spawn: can't initialize window */
#define	ERROR_TIOCKSET	46	/* spawn: ioctl() failed on TIOCKSET */
#define	ERROR_TIOCKSETC	47	/* spawn: ioctl() failed on TIOCKSETC */
#define	ERROR_LUMALLOC  49	/* luit: command-line malloc failed */

/* charproc.c */
#define	ERROR_SELECT	50	/* in_put: select() failed */
#define	ERROR_VINIT	54	/* VTInit: can't initialize window */
#define	ERROR_KMMALLOC1 57	/* HandleKeymapChange: malloc failed */

/* Tekproc.c */
#define	ERROR_TSELECT	60	/* Tinput: select() failed */
#define	ERROR_TINIT	64	/* TekInit: can't initialize window */

/* button.c */
#define	ERROR_BMALLOC2	71	/* SaltTextAway: malloc() failed */

/* misc.c */
#define	ERROR_LOGEXEC	80	/* StartLog: exec() failed */
#define	ERROR_XERROR	83	/* xerror: XError event */
#define	ERROR_XIOERROR	84	/* xioerror: X I/O error */
#define	ERROR_ICEERROR	85	/* ice_error: ICE I/O error */

/* screen.c */
#define	ERROR_SCALLOC	90	/* Alloc: calloc() failed on base */
#define	ERROR_SCALLOC2	91	/* Alloc: calloc() failed on rows */
#define	ERROR_SAVE_PTR	102	/* ScrnPointers: malloc/realloc() failed */
xterm-330/version.c0000644000175100001440000000511613027232431013070 0ustar  tomusers/* $XTermId: version.c,v 1.4 2016/12/23 14:30:49 tom Exp $ */

/*
 * Copyright 2013-2015,2016 by Thomas E. Dickey
 *
 *                         All Rights Reserved
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name(s) of the above copyright
 * holders shall not be used in advertising or otherwise to promote the
 * sale, use or other dealings in this Software without prior written
 * authorization.
 */

#include 
#include 
#include 

/*
 * Returns the version-string used in the "-v' message as well as a few other
 * places.  It is derived (when possible) from the __vendorversion__ symbol
 * that some newer imake configurations define.
 */
const char *
xtermVersion(void)
{
    static const char vendor_version[] = __vendorversion__;
    static char *buffer;
    const char *result;

    if (buffer == 0) {
	const char *vendor = vendor_version;

	buffer = TextAlloc(strlen(vendor) + 9);
	if (buffer == 0) {
	    result = vendor;
	} else {
	    char first[BUFSIZ];
	    char second[BUFSIZ];

	    /* some vendors leave trash in this string */
	    for (;;) {
		if (!strncmp(vendor, "Version ", (size_t) 8))
		    vendor += 8;
		else if (isspace(CharOf(*vendor)))
		    ++vendor;
		else
		    break;
	    }
	    if (strlen(vendor) < BUFSIZ &&
		sscanf(vendor, "%[0-9.] %[A-Za-z_0-9.]", first, second) == 2) {
		sprintf(buffer, "%s %s(%d)", second, first, XTERM_PATCH);
	    } else {
		sprintf(buffer, "%s(%d)", vendor, XTERM_PATCH);
	    }
	    result = buffer;
	}
    } else {
	result = buffer;
    }
    return result;
}
xterm-330/tabs.c0000644000175100001440000001207011765150447012346 0ustar  tomusers/* $XTermId: tabs.c,v 1.43 2012/06/10 16:53:59 tom Exp $ */

/*
 * Copyright 2000-2011,2012 by Thomas E. Dickey
 *
 *                         All Rights Reserved
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name(s) of the above copyright
 * holders shall not be used in advertising or otherwise to promote the
 * sale, use or other dealings in this Software without prior written
 * authorization.
 *
 *
 * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 *
 *                         All Rights Reserved
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose and without fee is hereby granted,
 * provided that the above copyright notice appear in all copies and that
 * both that copyright notice and this permission notice appear in
 * supporting documentation, and that the name of Digital Equipment
 * Corporation not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 *
 *
 * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */

/* tabs.c */

#include 
#include 

#define TAB_INDEX(n) ((n) >> TAB_BITS_SHIFT)
#define TAB_MASK(n)  (1 << ((n) & (TAB_BITS_WIDTH-1)))

#define SET_TAB(tabs,n) UIntSet(tabs[TAB_INDEX(n)], TAB_MASK(n))
#define CLR_TAB(tabs,n) UIntClr(tabs[TAB_INDEX(n)], TAB_MASK(n))
#define TST_TAB(tabs,n) (tabs[TAB_INDEX(n)] & (unsigned) TAB_MASK(n))

/*
 * places tabstops at only every 8 columns
 */
void
TabReset(Tabs tabs)
{
    int i;

    TabZonk(tabs);

    for (i = 0; i < MAX_TABS; i += 8)
	TabSet(tabs, i);
}

/*
 * places a tabstop at col
 */
void
TabSet(Tabs tabs, int col)
{
    if (col >= 0 && col < MAX_TABS) {
	SET_TAB(tabs, col);
    }
}

/*
 * clears a tabstop at col
 */
void
TabClear(Tabs tabs, int col)
{
    if (col >= 0 && col < MAX_TABS) {
	CLR_TAB(tabs, col);
    }
}

/*
 * returns the column of the next tabstop
 * (or MAX_TABS - 1 if there are no more).
 * A tabstop at col is ignored.
 */
static int
TabNext(XtermWidget xw, Tabs tabs, int col)
{
    TScreen *screen = TScreenOf(xw);

    if (screen->curses && screen->do_wrap && (xw->flags & WRAPAROUND)) {
	xtermIndex(xw, 1);
	set_cur_col(screen, 0);
	col = 0;
	ResetWrap(screen);
    }
    for (++col; col < MAX_TABS; ++col)
	if (TST_TAB(tabs, col))
	    return (col);

    return (MAX_TABS - 1);
}

/*
 * returns the column of the previous tabstop
 * (or 0 if there are no more).
 * A tabstop at col is ignored.
 */
static int
TabPrev(Tabs tabs, int col)
{
    for (--col; col >= 0; --col)
	if ((col < MAX_TABS) && TST_TAB(tabs, col))
	    return (col);

    return (0);
}

/*
 * Tab to the next stop, returning true if the cursor moved
 */
Bool
TabToNextStop(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);
    int saved_column = screen->cur_col;
    int next = TabNext(xw, xw->tabs, screen->cur_col);
    int max = LineMaxCol(screen, getLineData(screen, screen->cur_row));

    if (IsLeftRightMode(xw))
	max = TScreenOf(xw)->rgt_marg;
    if (next > max)
	next = max;
    set_cur_col(screen, next);

    return (screen->cur_col > saved_column);
}

/*
 * Tab to the previous stop, returning true if the cursor moved
 */
Bool
TabToPrevStop(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);
    int saved_column = screen->cur_col;
    int next_column = TabPrev(xw->tabs, screen->cur_col);

    if (xw->flags & ORIGIN) {
	int left = ScrnLeftMargin(xw);
	if (next_column < left)
	    next_column = left;
    }

    set_cur_col(screen, next_column);

    return (screen->cur_col < saved_column);
}

/*
 * clears all tabs
 */
void
TabZonk(Tabs tabs)
{
    memset(tabs, 0, sizeof(*tabs) * TAB_ARRAY_SIZE);
}
xterm-330/tektests/0000755000175100001440000000000006130426730013106 5ustar  tomusersxterm-330/tektests/imtest.tek0000644000175100001440000000011004211201137015076 0ustar  tomusers ` @ `?_ `?_8m?_8m?_8m @8m @ ` @!r#D(0,0) ` @8m?_ `?_8m @,p @
xterm-330/tektests/aitest.tek0000644000175100001440000004022706130426723015113 0ustar  tomusers1,`g ],`g?C3`t0@$`z0@,cg-F,cj-F,`m-G,lo-G,lr-G,lu-G,mx-G,m{-G,j~-G-ka-G-kd-G-hg-H-ej-H-fm-H-gp-H-as-I-bv-I-cy-I-m{-J-n~-J.la-K.id-K.kg-K.ej-L.gm-L.ep-M.cs-M.av-N.lx-O.j{-O.h~-P/ga-P/bd-Q/`g-R/oi-R/jl-S/eo-T/dr-U/cu-U/nw-V/jz-W/e}-X0``-Y0lb-Z0he-[0gh-[0ck-\0km-]0gp-^0cs-_0hu.A0dx.B0`{.C0i}.D1e`.E1nb.F1ge.G1`h.I1hj.J1bm.K1ko.L1`r.N1it.O1cw.P1hy.R1b|.S1h~.U2ba.V2gc.W2ne.Y2`h.[2jj.\2ll.^2go._2jq/A2ls/C2cv/D2fx/F2iz/H2l|/J2`/L3ga/M3gc/O3je/Q3ng/S3ni/U3nk/W3bn/Y3cp/[3cr/]3`t0@,cg-F,cd-F,`a-G+d~-G+d{-G+dx-G+eu-G+er-G+jo-G+kl-G+ki-G+hf-H+mc-H+n`-H*o}-H*a{-I*bx-I*cu-I*er-J*fo-J*dl-K*ii-K*kf-K*mc-L*o`-L)m}-M)c{-M)ax-N)du-O)jr-O)ho-P)ol-P)bj-Q)`g-R)gd-R)ja-S(m~-T(l{-U(cy-U(fv-V(js-W(mp-X(`n-Y(dk-Z(hh-[(oe-[(cc-\(k`-]'o}-^'c{-_'hx.A'lu.B'`s.C'ip.D'mm.E'fk.F'oh.G'`f.I'hc.J'ba.K&k~.L&`|.N&iy.O&cw.P&ht.R&br.S&ho.U&bm.V&oj.W&fh.Y&`f.[&jc.\&da.^%o~._%j|/A%dz/C%cx/D%nu/F%is/H%dq/J%`o/L%ol/M%oj/O%jh/Q%ff/S%fd/U%fb/W%b`/Y$c~/[$c|/]$`z0@,ag2Y,ad2Y,`a2Y+d~2Y+d{2Y+dx2Y+gu2X+gr2X+jo2X+il2X+ii2X+hf2X+oc2W+n`2W*m}2W*c{2V*bx2V*au2V*gr2U*fo2U*dl2U*ki2T*if2T*oc2S*m`2S)o}2R)a{2R)cx2Q)du2Q)jr2P)ho2P)ml2O)bj2N)`g2N)ed2M)ja2L(o~2K(l{2K(ay2J(fv2I(js2H(op2G(`n2G(dk2F(hh2E(me2D(ac2C(i`2B'm}2A'a{2@'hx1_'lu1^'`s1]'kp1['om1Z'fk1Y'mh1X'`f1W'hc1V'ba1T&i~1S&`|1R&ky1P&aw1O&ht1N&br1L&ho1K&bm1I&mj1H&fh1F&`f1E&jc1C&da1B%m~1@%j|0^%dz0]%ax0[%nu0Y%ks0W%dq0V%`o0T%ml0R%mj0P%jh0N%ff0L%fd0J%fb0H%b`0F$a~0D$a|0B$`z0@,ag2Y,aj2Y,`m2Y,lo2Y,lr2Y,lu2Y,ox2X,o{2X,j~2X-ia2X-id2X-hg2X-gj2W-fm2W-ep2W-cs2V-bv2V-ay2V-o{2U-n~2U.la2U.kd2T.ig2T.gj2S.em2S.gp2R.as2R.cv2Q.lx2Q.j{2P.h~2P/ea2O/bd2N/`g2N/mi2M/jl2L/go2K/dr2K/au2J/nw2I/jz2H/g}2G0``2G0lb2F0he2E0eh2D0ak2C0im2B0ep2A0as2@0hu1_0dx1^0`{1]0k}1[1g`1Z1nb1Y1ee1X1`h1W1hj1V1bm1T1io1S1`r1R1kt1P1aw1O1hy1N1b|1L1h~1K2ba1I2ec1H2ne1F2`h1E2jj1C2ll1B2eo1@2jq0^2ls0]2av0[2fx0Y2kz0W2l|0V2`0T3ea0R3ec0P3je0N3ng0L3ni0J3nk0H3bn0F3ap0D3ar0B3`t0@,ag*O,aj*O,am*O,bp*O,bs*O,gv*O,dy*P,e|*P,f*P-db*Q-ee*Q-gh*Q-ek*R-gn*R-eq*S-gt*S-fw*T-ez*U-d}*V.g`*V.fc*W.ef*X.ai*Y.al*Z.ao*[.ar*\.au*].mw*^.nz*_.o}+@/h`+B/ic+C/ff+D/gi+E/al+G/co+H/mq+J/ot+K/iw+M/dz+O/b}+P0a`+R0lb+T0ke+U0gh+W0bk+Y0nm+[0jp+]0fs+_0nu,A0jx,C0g{,E0l},H1i`,J1bc,L1oe,N1eh,Q1nj,S1hm,V1bp,X1ir,[1cu,]1jw-@1`z-C1g|-E1o~-H2fa-K2jc-N2bf-Q2fh-T2jj-W2bm-Z2go-]2hq.A2ms.D2bv.G2`x.K2ez.N2k|.Q2i~.U3h`.Y3nb.\3md/@3lf/D3oh/G3oj/K3kl/O3kn/S3gp/W3gr/[3`t0@,ag*O,ad*O,aa*O+b~*O+b{*O+ow*O+lt*P+mq*P+nn*P+lk*Q+mh*Q+oe*Q+mb*R*o*R*m|*S*oy*S*nv*T*ms*U*lp*V*om*V*nj*W*mg*X*ae*Y*ab*Z)a*[)a|*\)ay*])ev*^)fs*_)gp+@)hm+B)ij+C)ng+D)od+E)ab+G(c+H(e|+J(gy+K(iv+M(ls+O(bq+P(an+R(dk+T(kh+U(oe+W(bc+Y(f`+['j}+]'nz+_'fx,A'ju,C'or,E'dp,H'im,J'bk,L'gh,N'me,Q'fc,S'h`,V&b~,X&i{,[&cy,]&jv-@&`t-C&oq-E&go-H&nl-K&jj-N&bh-Q&ne-T&jc-W&ba-Z%o~-]%h|.A%ez.D%bx.G%`v.K%ms.N%kq.Q%io.U%hm.Y%fk.\%ei/@%dg/D%ge/G%gc/K%ka/O$k/S$o}/W$o{/[$`z0@,cg5P,cd5P,ca5P+b~5P+b{5P+mw5P+lt5P+oq5O+nn5O+lk5O+oh5N+me5N+ob5M*m5M*o|5L*my5L*nv5K*os5J*lp5J*mm5I*nj5H*og5G*ce5F*cb5E)c5D)c|5C)cy5B)gv5A)fs5@)ep4_)hm4^)kj4\)ng4[)md4Z)cb4X(a4W(g|4U(ey4T(kv4R(ls4Q(bq4O(cn4M(dk4L(ih4J(me4H(bc4F(f`4D'j}4B'nz4@'fx3^'ju3\'mr3Z'dp3X'km3U'bk3S'eh3Q'oe3N'fc3L'h`3J&b~3G&k{3D&ay3B&jv2_&`t2]&mq2Z&eo2W&nl2T&jj2Q&bh2N&ne2K&jc2H&ba2E%m~2B%h|1_%gz1[%bx1X%`v1U%os1Q%iq1N%ko1J%hm1G%fk1C%gi0_%dg0\%ee0X%ec0T%ia0P$i0L$m}0H$m{0D$`z0@,cg5P,cj5P,cm5P,bp5P,bs5P,ev5P,dy5P,g|5O,f5O-db5O-ge5N-eh5N-gk5M-en5M-gq5L-et5L-fw5K-gz5J-d}5J.e`5I.fc5H.gf5G.ci5F.cl5E.co5D.cr5C.cu5B.ow5A.nz5@.m}4_/h`4^/kc4\/ff4[/ei4Z/cl4X/ao4W/oq4U/mt4T/kw4R/dz4Q/b}4O0c`4M0lb4L0ie4J0eh4H0bk4F0nm4D0jp4B0fs4@0nu3^0jx3\0e{3Z0l}3X1k`3U1bc3S1me3Q1gh3N1nj3L1hm3J1bp3G1kr3D1au3B1jw2_1`z2]1e|2Z1m~2W2fa2T2jc2Q2bf2N2fh2K2jj2H2bm2E2eo2B2hq1_2os1[2bv1X2`x1U2gz1Q2i|1N2k~1J3h`1G3nb1C3od0_3lf0\3mh0X3mj0T3il0P3in0L3ep0H3er0D3`t0@,bg'Z,gj'Z,gm'Z,hp'[,ls'[,nv'[,cz'[,e}'\-f`'\-ic']-kf']-ni'^-am'_-`p(@-gs(@-gv(A-ky(B-k|(C-o(D.lb(F.me(G.bi(H.`l(J.ao(K.gr(L.eu(N.dx(P.g{(Q.f~(S/ea(U/dd(W/dg(Y/dj([/dm(]/ep(_/es)A/cv)C/`y)F/a|)H/o~)J0ma)M0kd)O0jg)R0ej)U0`m)X0oo)Z0kr)]0gu*@0cx*C0oz*F0h}*J1e`*M1bc*P1ke*S1eh*W1oj*Z1em*^1`p+B1kr+E1bu+I1iw+M1`z+Q1d|+U1l~+Y2aa+]2ic,A2ne,E2`h,J2ij,N2ol,R2mn,W2cq,[2fs-@2du-E2hw-J2ky-N2k{-S2k}-X2k-]3ka.B3dc.H3ae.M3cg.R3lh.X3jj.]3dl/C3om/H3jo/N3aq/T3hr/Z3`t0@,bg'Z,oc'Z,o`'Z+h}'[+dz'[+fw'[+ct'[+mp'\+nm'\+ij']+kg']+fd'^+aa'_*`~(@*oz(@*ow(A*kt(B*kq(C*gn(D*dk(F*eh(G*be(H*`b(J)a(K)o{(L)mx(N)lu(P)or(Q)no(S)ml(U)li(W)lf(Y)lc([)l`(](m}(_(mz)A(cx)C(`u)F(ar)H(go)J(el)M(ki)O(jf)R(mc)U(`a)X'g~)Z'k{)]'ox*@'cv*C'gs*F'hp*J'mm*M'bk*P'kh*S'me*W'gc*Z'm`*^&`~+B&k{+E&by+I&iv+M&`t+Q&lq+U&do+Y&am+]&ij,A&fh,E&`f,J&ic,N&ga,R%e,W%c},[%nz-@%lx-E%hv-J%kt-N%kr-S%kp-X%kn-]%kl.B%lj.H%ai.M%cg.R%de.X%jc.]%la/C%g`/H$j~/N$a}/T$h{/Z$`z0@,bg8E,mc8E,m`8E+h}8E+dz8E+fw8D+at8D+op8C+nm8C+kj8B+ig8B+fd8A+ca8@*`~8@*mz7_*mw7^*it7]*iq7\*en7[*dk7Z*gh7X*be7W*`b7V)c7T)m{7S)ox7Q)lu7P)mr7N)no7L)ol7J)li7I)lf7G)lc7E)l`7C(o}7@(oz6^(ax6\(`u6Z(cr6W(eo6U(gl6R(ii6P(jf6M(oc6J(`a6H'e~6E'i{6B'mx5_'av5\'es5Y'hp5V'om5R'bk5O'ih5L'oe5H'ec5E'o`5A&`~4^&i{4Z&by4V&kv4R&`t4O&lq4K&do4G&cm4B&kj3^&fh3Z&`f3V&kc3Q&ea3M%g3H%a}3D%nz2_%lx2[%hv2V%it2Q%ir2L%ip2G%in2B%il1]%lj1X%ci1R%ag1M%de1H%jc1B%la0]%e`0W$j~0Q$c}0K$h{0F$`z0@,bg8E,ej8E,em8E,hp8E,ls8E,nv8D,az8D,g}8C-f`8C-kc8B-if8B-ni8A-cm8@-`p8@-es7_-ev7^-iy7]-i|7\-m7[.lb7Z.oe7X.bi7W.`l7V.co7T.er7S.gu7Q.dx7P.e{7N.f~7L/ga7J/dd7I/dg7G/dj7E/dm7C/gp7@/gs6^/av6\/`y6Z/c|6W/m~6U0oa6R0id6P0jg6M0gj6J0`m6H0mo6E0ir6B0eu5_0ax5\0mz5Y0h}5V1g`5R1bc5O1ie5L1gh5H1mj5E1gm5A1`p4^1ir4Z1bu4V1kw4R1`z4O1d|4K1l~4G2ca4B2kc3^2ne3Z2`h3V2kj3Q2ml3M2on3H2aq3D2fs2_2du2[2hw2V2iy2Q2i{2L2i}2G2i2B3ia1]3dc1X3ce1R3ag1M3lh1H3jj1B3dl0]3mm0W3jo0Q3cq0K3hr0F3`t0@,bg%J,jj%J,om%J,gq%J,it%K,bx%K,d{%L,j~%L-ab%M-de%N-oh%N-cl%O-ko%P-or%Q-`v%S-ey%T-n|%U.``%W.fc%X.hf%Z.oi%[.fm%].jp%_.ms&A.nv&C.bz&E.g}&G/h`&J/nc&L/of&N/bj&Q/dm&T/gp&V/fs&Y/jv&\/jy&_/j|'B/j'E0kb'H0ie'L0jh'O0hk'S0jn'V0eq'Z0dt'^0cw(A0oy(E0o|(I0k(M1gb(Q1`e(V1ng(Z1gj(^1am)C1ko)G1fr)L1mt)Q1dw)V1ly)[1d|*@1h~*E2`a*J2ec*O2ne*T2`h*Z2fj*_2dl+E2jn+J2mp+P2lr+V2ot+[2ov,A2ox,G2oz,M2h|,T2i~,Z3f`-@3cb-F3mc-M3ge-S3ag-Z3hh.A3cj.G3jk.N3nl.U3an.\3io/C3np/J3nq/Q3cs/X3`t0@,bg%J,jc%J,g`%J+o|%J+iy%K+bv%K+lr%L+jo%L+al%M+lh%N+ge%N+cb%O*k~%P*g{%Q*`x%S*mt%T*fq%U*`n%W*nj%X*hg%Z*gd%[*n`%])j}%_)ez&A)fw&C)bt&E)op&G)hm&J)fj&L)gg&N)bd&Q)l`&T(o}&V(nz&Y(jw&\(jt&_(jq'B(jn'E(kk'H(ih'L(je'O(hb'S'j'V'm|'Z'ly'^'cw(A'gt(E'gq(I'kn(M'ok(Q'`i(V'ff(Z'oc(^'aa)C&k~)G&n{)L&ey)Q&lv)V&dt)[&lq*@&ho*E&`m*J&mj*O&fh*T&`f*Z&nc*_&la+E%j+J%e}+P%d{+V%gy+[%gw,A%gu,G%gs,M%hq,T%io,Z%nm-@%cl-F%ej-M%oh-S%ag-Z%he.A%cd.G%jb.N%fa.U%a`.\$i~/C$f}/J$f|/Q$c{/X$`z0@,bg:U,jc:U,e`:U+m|:U+ky:T+bv:T+lr:T+jo:S+cl:R+lh:R+ee:Q+ab:P*i~:O*e{:N*`x:M*ot:K*fq:J*`n:I*nj:G*hg:F*ed:D*n`:B)j}:@)gz9^)fw9\)bt9Z)mp9X)hm9V)fj9S)eg9Q)bd9N)l`9L(m}9I(nz9F(jw9C(jt9@(jq8](jn8Z(ik8W(kh8S(je8P(hb8M'j8I'o|8E'ly8B'aw7^'et7Z'eq7V'in7R'mk7N'`i7J'ff7E'mc7A'ca6\&i~6X&n{6S&gy6N&lv6J&dt6E&lq6@&ho5[&`m5V&oj5P&fh5K&`f5F&nc5@&la4[%j4U%g}4O%d{4J%ey4D%ew3^%eu3X%es3R%hq3L%ko3E%nm2_%al2Y%gj2R%mh2L%cg2E%he1_%ad1X%jb1Q%fa1J%c`1C$k~0\$f}0U$f|0N$a{0G$`z0@,bg:U,jj:U,mm:U,eq:U,kt:T,bx:T,d{:T,j~:S-cb:R-de:R-mh:Q-al:P-io:O-mr:N-`v:M-gy:K-n|:J.``:I.fc:G.hf:F.mi:D.fm:B.jp:@.os9^.nv9\.bz9Z.e}9X/h`9V/nc9S/mf9Q/bj9N/dm9L/ep9I/fs9F/jv9C/jy9@/j|8]/j8Z0ib8W0ke8S0jh8P0hk8M0jn8I0gq8E0dt8B0aw7^0my7Z0m|7V0i7R1eb7N1`e7J1ng7E1ej7A1cm6\1io6X1fr6S1ot6N1dw6J1ly6E1d|6@1h~5[2`a5V2gc5P2ne5K2`h5F2fj5@2dl4[2jn4U2op4O2lr4J2mt4D2mv3^2mx3X2mz3R2h|3L2k~3E3f`2_3ab2Y3oc2R3ee2L3cg2E3hh1_3aj1X3jk1Q3nl1J3cn1C3ko0\3np0U3nq0N3as0G3`t0@,ag#@,mj#@,fn#@,cr#@,lu#A,jy#A,a}#B-l`#C-kd#C-ch#D-ok#E-ho#G-as#H-ov#I-ez#K-l}#M.ka#N.be#P.jh#R.fl#T.oo#V.ds#Y.nv#[.dz#^.o}$@/fa$C/id$F/ah$I/ik$L/nn$O/cr$R/iu$V/ox$Y/a|$]/d%A0kb%D0oe%H0oh%L0`l%Q0ao%U0fr%Y0du%^0fx&B0d{&G0g~&K1ca&P1cd&U1of&Z1ki&_1hl'E1ao'J1oq'O1it'U1cw'Z1ny(@1e|(F1m~(L2`a(R2ic(X2me(^2fh)D2kj)J2il)Q2on)W2mp)^2cs*D2bu*K2aw*R2mx*Y2lz+@2h|+G2e~+N3a`+U3ja+\3cc,C3hd,K3bf,R3hg,Z3nh-A3`j-I3gk-P3jl-X3im.@3hn.H3ho.P3kp.W3gq._3cr/G3or/O3hs/X3`t0@,ag#@,ec#@+n#@+c|#@+dx#A+jt#A+aq#B+dm#C+ki#C+cf#D+gb#E*h~#G*a{#H*gw#I*ms#K*dp#M*kl#N*bi#P*je#R*na#T)g~#V)lz#Y)fw#[)ls#^)gp$@)nl$C)ii$F)af$I)ib$L(f$O(c|$R(ix$V(gu$Y(ar$](ln%A(kk%D(gh%H(ge%L(`b%Q'a%U'n{%Y'lx%^'nu&B'lr&G'oo&K'cm&P'cj&U'gg&Z'kd&_'ha'E&a'J&g|'O&iy'U&cw'Z&ft(@&mq(F&eo(L&`m(R&ij(X&eh(^&ne)D&kc)J&ia)Q%g)W%e})^%c{*D%by*K%aw*R%eu*Y%ds+@%hq+G%mo+N%an+U%jl+\%ck,C%hi,K%bh,R%hf,Z%fe-A%`d-I%ob-P%ja-X%i`.@$h.H$h~.P$k}.W$o|._$c|/G$g{/O$hz/X$`z0@,cg<_,gc<_+n<_+a|<_+dx<_+jt<^+cq<]+dm<]+ii<\+af<[+eb_+af>^+`b>]*o}>[*my>Z*nu>X*nq>V*om>T*ni>R*me>P*la>N)m}>K)oy>H)cv>E)`r>C)gn=_)jj=\)if=Y)ob=U(`=R(i{=N(nw=J(bt=F(ip=B(`m<^(ji_-ah>^-`l>]-gp>[-et>Z-fx>X-f|>V.g`>T.fd>R.eh>P.dl>N.ep>K.gt>H.cx>E.`|>C.o=_/jc=\/ig=Y/gk=U/`o=R/ir=N/fv=J/bz=F/i}=B0`a<^0jdI+fi>I*f>I+fd>I+dd?H+di?H*d?H+dd?H+dd?H+gd5U,cc5U,cc5Z,cc5P,cc5U-ka5U-ka5Z-ka5P-ka5U.g`5U.g`5Z.g`5P.g`5U.o~5U.o~5Z.o~5P.o~5U/k}5U/k}5Z/k}5P/k}5U0c|5U0c|5Z0c|5P0c|5U1oz5U1oz5Z1oz5P1oz5U2gy5U2gy5Z2gy5P2gy5U3cx5U3cx5Z3cx5P3cx5U4kv5U4kv5Z4kv5P4kv5U4kv5U+gd5U+ed4W*e4W+ei4W+ed4W+fd3X*f3X+fi3X+fd3X+dd2Z*d2Z+di2Z+dd2Z+ed1[*e1[+ei1[+ed1[+gd0\*g0\+gi0\+gd0\+dd/^*d/^+di/^+dd/^+fd._*f._+fi._+fd._+gd.@*g.@+gi.@+gd.@+ed-B*e-B+ei-B+ed-B+fd,C*f,C+fi,C+fd,C+fd,C+gd5U*oe5U*oe5P*oe5Z*oe5U)cg5U)cg5P)cg5Z)cg5U(kh5U(kh5P(kh5Z(kh5U'oi5U'oi5P'oi5Z'oi5U&gk5U&gk5P&gk5Z&gk5U%kl5U%kl5P%kl5Z%kl5U$cn5U$cn5P$cn5Z$cn5U#go5U#go5P#go5Z#go5U"op5U"op5P"op5Z"op5U!cr5U!cr5P!cr5Z!cr5U!cr5U4kv5U4k{5PN+fd,C*hl,FE!cr5U cy5PS+dd?H*hl>YW%`o @,cc5U,nb5T,nb5S,mb5R,ib5Q,db5P,`b5O,oa5M,ka5L,fa5K,o`5J,k`5I,``5I+h5H+`5G+h~5F+a~5E+j}5D+c}5C+g|5B+h{5B+a{5A+fz5@+ky4_+lx4_+bx4^+gw4]+iv4]+ju4\+lt4\+bt4[+ds4[+fr4Z+dq4Z+fp4Y+eo4Y+kn4X+fm4X+el4X+`k4X+cj4W+nh4W+mg4W+if4W+ie4W+ed4W+ac4W+ab4W+m`4W*n4W*k~4W*h}4X*e|4X*f{4X*cz4X*ey4Y*fx4Y*hw4Z*jv4Z*hu4[*jt4[*ls4\*bs4\*dr4]*gq4]*jp4^*lo4_*co4_*fn5@*im5A*`m5B*gl5B*nk5C*bk5D*ij5E*`j5F*ki5F*ci5G*kh5H*ch5I*og5J*fg5K*cg5L*of5M*hf5O*df5P*af5Q*me5R*ne5S*ne5T*oe5U*le5W*le5X*me5Y*af5Z*ff5[*jf5\*of5]*cg5^*dg6@*og6@*og6@*ch6A*jh6B*bi6C*ji6D*bj6E*ij6F*`k6G*kk6G*gl6H*bm6I*im6J*dn6K*co6K*no6L*hp6M*gq6M*ar6N*`s6O*ns6O*ht6P*fu6P*dv6Q*fw6Q*dx6R*ey6R*cz6R*d{6S*e|6S*j}6S*k~6S*l6T+m`6T+ab6T+ac6T+fd6T+ie6T+if6T+mg6T+lh6T+cj6S+bk6S+el6S+dm6S+kn6R+eo6R+dp6R+bq6Q+`r6Q+bs6P+`t6P+nt6O+hu6O+fv6N+gw6M+`x6M+nx6L+ky6K+dz6K+a{6J+j{6I+g|6H+l|6H+h}6G+a~6F+j~6E+c6D+k6C,c`6B,k`6A,o`6@,da6@,ka5^,oa5],bb5\,fb5[,ib5Z,mb5Y,lb5X,lb5W,cc5U$`l?@$`l?J$`l?E%`u?E%`u?@%`u?J%`j9Y        0.1"$`t9Y     2148 km#`v9YStar position#``9Yin sky plane"`j9YFrom  2:40: 0!`t9YEach  0: 1: 0+fd,C+fi,RSUN->.ke7[.di7[.na7\.ke7[-k{8@SAA.ke7[.`b7L.me7K-g~7L.`b7L-h~6\.eb6[-oz6\-h~6\-lz6L-i~6K-cw6L-lz6L-dw5\-a{5[-ks5\-dw5\-ms5L-jw5K-`p5M-ms5L-ap4\-ns4[-dl4]-ap4\-il4L-fp4K-lh4M-il4L-ai3\-nl3[-de3]-ai3\-fe3L-ci3K-ia3M-fe3L-na2\-ke2[,a~2]-na2\,b~2L-oa2K,ez2M,b~2L,kz1\,d~1\,nv1],kz1\,cw1L,lz1L,fs1M,cw1L,ds0],aw0\,ko0],ds0],lo0M,is0L,cl0M,lo0M,dl/],ap/\,kh/],dl/],ih/M,fl/L,ld/N,ih/M,ae.],nh.\,da.^,ae.],fa.M,ce.L+i}.N,fa.M+n}-],ka-\+az-^+n}-]+gz-M+`~-M+jv-N+gz-M+kv,]+dz,]+nr,^+kv,]+`s,N+mv,M+go,N+`s,N7lv @May  4 1986 Occultation of nepklem 1026 by Triton (N1)7h` @Observed from SAAO Sutherland 74" Long= -20 48 44.3  Lat= -32 22 43.46dj @13.11-magnitude    star at RA= 18h 24m 16.1231s  Dec=-22d 13' 22.807" 

5`t @                    (1950) RA= 18h 22m  5.3070s  Dec=-22d 14' 27.910" 

4l} @Closest at  2:45:30 U.T. 4hg @ Radial=   4158.7 km =   0.19"3dq @ Planet=   1600.0 km =   0.07"2`{ @ ET - UT = 56.1709 sec  DE-1182ld @ P.A.=  12.7 deg.1hn @ Phase =   1.5 deg = 100.0%0dx @ Alt= 75 d, Az= -36 d0`b @ Sun alt=-30 d, Az=  90 d/lk @ Sun:127.8 d, Moon: 11.9 d.hu @ V =0.0007 "/s = 14.22 km/s-d @ D = 29.619079 A.U.-`i @Doug Mink 16: 4 Nov 11 1985-`i @
xterm-330/tektests/dmerc.tek0000644000175100001440000007037506130426724014724 0ustar  tomusers*hi?H*hi T*hl [-60-``?H-`` T-`c [-40.d?H.d T/db [-200lv?H0lv T0ly [ 02dn?H2dn T2dq [204hm?H4hm T4hp [407`d?H7`d T6`p [60*hi?H7`d?H7`g>Y180*ji=Q7bd=Q7bg=B200*hi;[7`d;[7`g;L220*ji:D7bd:D7bg9U240*hi8N7`d8N7`g7_260*ki6W7cd6W7cg6H280*ii5A7ad5A7ag4R300*ki3J7cd3J7cg2[320*ii1T7ad1T7ag1E340*hi/^7`d/^7`g/O 0*ki.G7cd.G7cg-X20*ii,Q7ad,Q7ag,B40*ki*Z7cd*Z7cg*K60*ii)D7ad)D7ag(U80*hi'N7`d'N7`g&_100*ji%W7bd%W7bg%H120*hi$A7`d$A7`g#R140*ji"J7bd"J7bg![160*hi T7`d T7`g E1800d.BP0f|4@0fh1PP+200f|4@1ga4@1kf4@1kk4@1lp4A1cv4@1g{4@2j`4@2me4@2dk4@2kp3_2av3_2k{3^3da3^3bg3]3nl3\3or3[3ox3Z3n~3Y4ae3X4hk3W4ar3U4ox3S4k3Q5jf3O5mm3M5cu3J5o|3G6jd3D6kl3@6cu2\6i}2X6i})K6cu)F6kl)B6hd(_5o|([5`u(Y5mm(V5hf(T4h(R4lx(P4ar(N4kk(L4ae(K3l~(J3lx(I3lr(H3ll(G3ag(F3fa(E2h{(E2av(D2hp(D2fk(C2me(C2h`(C1g{(B1cv(B1op(B1kk(B1kf(B1da(C0e|(C0bw(C0gr(C0am(D0bh(D0lb(E/o}(E/ix(F/ds(G/gn(G/ci(H/kc(I.g~(J.cy(K.hs(M.bn(N.kh(O.mb(Q-d}(S-kw(T-kq(V-hk(Y-ie([,k(],ey)@,mr)C,jl)F,cf)I+f)M+jx)Q+lq)V+oj)Z+lc*@*o|*E*`v*L*co*R*co1P*bv1W*o|1]+nc2C+oj2H+oq2M+hx2R+d2V,cf2Y,il2],mr3@,ey3C,h3F-je3H-kk3J-kq3L-kw3N-f}3P.mb3R.kh3S.an3U.js3V.cy3W.d~3Y/hc3Z/ci3Z/gn3[/fs3\/ix3]/l}3^0nb3^0`h3_0bm3_0gr3_0aw4@0f|4@/gt7US0js>O/j;_S-100js>O0jx>N0m}>M1`c>L1gh>J1im>I1lr>H1bx>F1d}>E2nb>C2ch>A2im>@2bs=^2kx=\2c~=Z3kc=X3gi=V3bo=T3`u=R3b{=O4`a=M4ag=J4em=G4ls=D4cz=@5l`<]5eg_.hf>^.hl>].dr>\.ax>[.m}>Z/ec>Y/mh>X/en>W/ms>V/dy>U/h~>T0lc>S0ci>Q0gn>P0js>O+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+ge*C+mr*B,kb*K,ih*F,mv*Q,iy*M,e|*U-gd*T-fd*_-gk+C-js*_-cr+G-lr+K.fe+Y.`o+Z.gw,K/l`,R/at,U/o,^0oe,^0jh,]0ln,R0lp,I0ln,E0mr,D0ot+\0dr+X0er+S0or+X0dv+Z0gv+T0ft+P0az+U0i{+U0h+R1be+N1ef+F1oi*^1om*Z1gm*X1`p*X1ds*T1`t*V1at*O1mr*Q1es*K1es*D1dv*A1dx)_1dv)_1ot)\1fo)[1do)Z1gv)Z1kw)\1ay)\1fx)Y1nt)P1kl)M1kp)G1gq)E+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+i`*M+ob*E+ad*@+ma)^+ge)Z+lh)V+em)S+ls)R+fy)P,hb)P,hc)T,hg)T,jg)P,hj)R,ki)V,`v)X,lx)X,hy)V-m`)U-dd)V-ii)U-lm)X-j|)Y.be)[.jm)[.nu)].l{)_/ic)^/jh)Y/dl)R/jp)N/aq)M/c})I0fe)P0if)O0ek)O0`n)R0ho)R0ap)O0et)O0lx)R0oz)G0b~)H1f`)J1cg)K1hl)I1hn)G1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1gq)E1ap)D1hn)A1hn(_1nt(Y2b`([2cb(X2ob(T2bb(L2hj(P2dn(P2ip(Q2ir(Q2kr(I2kp(G2ll(G2bj']2jj'Y2fn'W2kr'T2lz'T2n}'U3fb'U3jg'Y3fi'[3nj'[3oj'\3cj'\3jk'_3lj(C3kk(C3oj(E3gi(E3fi(H3gi(K3nj(J3bm(H3am(M3ln(N3fl(N3am(Q3am(U3oj(V3gl(X3ei(\3kd(\3eb(^2n})A2l})C3ia)D3lj)A3ep)@3et)B3hw)G3gy)I3k{)K3k|)M3f})L3e})O3a)O4n`)L4n`)N4gb)M4gc)M4ae)M4oe)M4gh)K4ig)M4ol)M4gh)M4me)O4dc)P4hg)R4ak)S4ko)T4ko)X4dp)Z4gp)T4br)Y4cr)Z4bt)[4bs)]4bs)]4`s)_4lt)_4at)^4nu)]4iz)^4f~*H5ba*H5bd*N5cb*M5ab*Q5ca*M4g~*I4e{*K4e~*O5b`*W5ca*V5bd*[5cf*Z5bf*Y5bh*Y5bf*W5bb*W5`b*V5`c*V5`d*P5`e*P5ah*M5ch*K5bk*N5ak*M5cj*K5`l*I5bm*J5cl*K5`n*P5`p*P5aq*M5bp*H5an*D5`l*A5bf)[5bk)_5ao*B5`q*E5`q*G5du*I5fu*N5et*Q5eu*U5gt*V5gt*Z5ly+C5o{+E5e+F6ib+F6oc+G6od+C6nc+A6`f+C6bf*_6kb*\6kb*X6cf*\6fg*_6eh+B6nk*Y6dn*Z6lp*V6br*W6jt*W6ou*T6dx*V7ea*O7`d*P7lc*M7gc*L7cc*L7kb*L7gb*L7na*L7fa*L7ba*L7i`*L7e`*L6m*L6e*L6`*L6h~*L6d~*L6l}*L6g}*K6nz*H6m~*B6e*B6i*B7b`*B7j`*B7ba*B7ja*B7bb*B7jb*B7bc*B7gc*B7oc*B7bd)L7nc)L7jc)L7fc)L7bc)L7bc)L7nb)L7fb)N7fb)L7ga)I7c`)I6o~)G6ky)K6kt)M6io)M6gk)I6nj)H6dh)E6he)G6ha)G5b~)H5d{)G5ly)G5cz)E5oz)E5my)D5ly)C5m{)B5b}(_5b~)@6n`(]6ed(^6dk(_6hl(V6`m(V6ho(P6np(N6fs(J6kt(E6gs(A6iy(B6e~(@6f}']6m~']6m~'Z7a`'\7ad'\7bd!_7lb!_7mb"B7mb"B7ac"B7ac"B7ec"B7ec"B7jc"B7nc"B7nc"B7bd"B7cd"C7oc"C7nc"C7jc"C7fc"C7fc"C7bc"C7mb"C7mb"C7ib"C7eb"C7eb"C7ab"C7la"C7da"C6k"B6h}"C6`|"E6a|"F6e}"G6n~"I6j}"I6`}"K6e~"L6a}"L6e{"M6d{"N6b}"M6`"O6g}"N6i|"O6g~"R6iy"P6`v"P6es"M6fp"I6io"I6gn"I6`n"H6eo"G6km"C6`l"C6gk"@6gj"@6fk"D6`m"F6kl"F6fk"F6jl"I6cn"J6il"K6kn"L6ko"N6ip"O6op"N6as"R6et"T6iu"T6iu"S6kv"V6iy"Z6a{"Z6k|"\6k}"\6e"Z7l`"\7j`"\7ad"^7cd#A7nc#A7jc#A7jc#A7ec#A7ec#A7ac#A7lb#A7lb#A7hb#A7hb#A7ja#A7ha#C6e#@6a#B6o#C7l`#D7da#F7ic#H7kc#I7oc#I7oc#I7`d#J7cd#V7jc#Y7bd#[7ob#_7`d$C7kb$C7da$C7lb$B7c`$A6j$D6c}$G6i{$I6b{$J6j|$J6e}$I6n~$I6e}$J6d}$L6b{$L6mz$N6n{$N6f$M7``$L7e`$M6n~$N6b|$O6iz$O6hz$Q6i|$R6j}$R6m~$S6k~$S6c}$R6f}$R6bw$S6dx$R6ou$R6du$R6ds$T6mp$W6ap$V6mm$U6jm$V6bo$W6ko$X6dn$Z6il$Z6lk$Y6nj$Y6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6jb$W6ja$U5j}$W5o|$X5g}$Y5n}$Y5i~$X5g$X5h$X6ba$W6ia$X6jb$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6fg$W6mf$V6`d$U6nf$U6lf$S6ke$R6be$S6`c$S6hb$U6bb$U6fc$W6fg$W6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6on$X6kn$W6ml$W6al$X6fm$Y6on$X6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6`p$S6ho$R6cm$R6gi$T6di$V6lj$V6`n$T6`p$S6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6ds$R6gs$P6cq$P6aq$Q6ko$P6io$Q6hp$R6ds$R6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6bz$O6kt$O6aw$Q6nw$P6ex$Q6bz$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6mu$O6hv$N6mu$M6ht$N6es$M6`q$N6cp$O6ht$P6it$O6mu$O6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6`|"_6ky"\6dz#A6b{#@6nz"_6`|"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6dx"_6`y"]6bx"\6ix"[6ev"[6ew"Z6ou"X6gs"X6at"Z6hr"Z6iu"]6mu"]6nu"^6`w#@6aw"^6dx"_6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6`h!]6mg!^6fi!_6hh"A6oj!_6mj!^6`h!]6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6od!Y6`f!X6ke!V6jd!W6gb!T6fc!U6od!Y6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6`d!T6kc!T6`a!R6kc!R6`d!T6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P6k`!P5e~!O6a`!O6c`!P6k`!P6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6c`!N6d`!N5e!M5g!M6c`!N5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5f~!H5a~!G5i}!H5a~!I5f~!H5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5g}!F5k|!F5i|!E5b}!D5g}!F5f!D5f!D5f!D5f!D5f!D5f!D5f!D5f!D5f!D5f!D5f!D5f!D5f!D5f!D5f!D5f!D5f!D5f!D5f!D5f!D5g!C5k|!A5k|!C5f!D5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5h| ]5fz [5k{ ]5h| ]5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5m{ [5`{ Z5hz Z5j{ [5m{ [5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5m{ Y5e{ X5dz Y5m{ Y5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5oz?E5fz?E5oy?F5my?G5oz?E5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5c|?@5n{?@5k{>]5mz>_5j{?@5c|?@7ad!V7bd!V7nc!V7oc!V7lc!W7lc!W7ic!W7jc!W7jc!W7gc!W7gc!W7dc!X7ec!X7ac!X7bc!X7cc!X7cc!X7lb!Y7mb!Y7mb!Y7`d![6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6jy$N6gy$L6kz$L6gz$J6`y$K6cy$I6lv$K6`v$R6ex$L6mv$O6jy$N5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5lz+G5my+D5iv+B5er+@5an*\5an*^5ak*\5aj*\5`j+E5`i+E5ai+F5`j+G5bj+H5cg+E5`g+G5bj+J5cf+K5cf+M5ak+O5cm+M5`k+K5co+M5`o+K5er+M5fs+H5gr+E5dt+G5du+E5ds+C5lz+G5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5`h*P5af*O5ae*Q5be*R5`d*T5`f*V5af*Q5`h*P2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2ct(V2bt(Y2nt(Y2gv(\2iu(^2hr)G2bq)H2no)L2gn)I2`o)T2aq)O2mq)O2nw)A2nw([2ct(V2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2bg)H2ff)H2ie)K2je)N2ff)N2ng)L2ng)J2bg)H2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2cj*G2kh*G2og*I2ei*K2aj*K2jj*J2cj*G2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2gk)R2cj)R2kh)T2hh)Z2cg)Z2ih)\2aj)\2jj)]2ei)^2di*C2gk*C2gn)\2gn)V2ll)X2hj)X2kj)V2gk)R1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1hn)G1go)E1em)B1ck)C1jj)A1hl)A1nk(_1fm(]1kl(\1mm(\1gm(Z1mm(Z1in(Z1lr(V1gq(V1or(T1ct(T1`t(T1hu(T1jy(N1ez(O1n{(N1`{(N1l{(I1`}(G1h|(E2ic'^2nb']2ic'\2fd'[2nb'Y2lb'T2ke'K2ih'I2kh'G2kj'C2dk'C2`l'A2bo&]2fs&_2`t&_2dv&_2g|&X2d|&X2l}&X2j~&U2f&U2g&T3``&T3ka&T3ha&T3eb&S3cc&R3id&Q3af&O3nj&L3fp&J3bq&H3oq&G3oq&E3dl&G3ig&K3kd&K3`c&N3ha&N3ja&N2i~&O2o}&P2mz&Q2h{&R2ey&S2ow&R2lw&R2c}&K3o`&K3cc&I3eb&I3fe&D3de&G3bf&F3hg&G3gi&E3gi&E3ik&B3am&B3lr%_3av%^3dx%]3oz%X3lz%V3d}%V4o`%R4gb%R4ec%Q4oe%P4`e%R4hf%R4kg%R4ig%Q4kf%P4dh%N4ak%M4im%M4jn%L4fp%L4`r%N4iw%K4e}%M5`d%N5ae%M5bf%N5bi%L5`m%L5bm%N5bk%N5ak%O5ai%O5cj%P5ao%Q5ap%O5er%O5bq%N5bq%L5dr%N5du%N5eu%M5es%M5ds%L5du%L5jw%J5gu%I5jv%F5iw%I5kw%C5oy%C5m{%B5f%D5d%A6lc$_6jb$]6af$\6fg$]6gg$Z6eh$Z6bm$]6nj$Y5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5bn%N5an%M5bp%H5bq%F5fr%F5hv%A5hw%A5iw%B5fu%F5et%I5fr%J5ap%M5bn%N4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4fq&L4gp&K4fq&J4br&J4cs&I4ct&I4bs&J4ct&K4fq&L4d})P4d})P4d})P4d})P4d})P4d})P4d})P4d})P4d})P4d})P4d})P4d})P4d})P4d})P4d})P4d})P4d})P4d})P4d})P4d})P4jz)N4ky)I4hy)E4kz)E4f|)H4g|)I4e{)K4f})L4d~)P4d})P4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4cw)E4mt)B4bt)A4as)@4ar(\4as(\4bs([4ct(Z4mt(\4bt(]4nt(_4lv)A4`v)C4lv)C4cw)E5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5cg(I5lf(G5ch(G5hg(G5cg(E5gg(C5ci(E5bj(F5`k(I5al(J5cn(J5jn(L5cm(K5cn(L5am(M5hn(N5mo(M5`p(N5kn(P5ao(Q5bo(R5bl(S5kk(T5`l(V5bj(W5kf(V5ce(X5be(_5bd(_5bd)A5bb)A5`b)C4d~)C4f~)A5`a)@5`a(_4e~(_4ky(^4kx(\4g|(\4f|([4g{(Z4e{(Z4f~([5b`([5ba(Z5ia(Y5kb(V5ab(U5ca(U4h(T5h`(T4g}(R4lv(S4at(Q4`t(P4nv(N4d{(P4e|(O5aa(Q4h}(N5a`(O5jc(P5hc(R5hb(R5ad(S5ed(U5gc(V5ed(X5ke(V5ae(U5ef(U5if(S5`f(R5ff(O5eg(M5ii(O5ei(M5bh(K5cg(I5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5gu'V5hv'X5k{'W5b}'V6e`'U6kb'T6dc'T6ld'T6be'U6jf'U6af'S6bg'S6gg'T6fh'S6gg'R6ge'R6af'P6ia'O6da'R6f`'P6a`'Q5j{'S5i}'T5b{'U5oy'T5mz'V5oy'V5hx'V5gw'V5gu'V6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6cb'J6`a'K5k'K6i`'L5d~'M5e'N5j}'N5e}'M5a{'M5gz'O5jy'P5mw'P5`v'R5ot'Q5lt'S5mu'S5ow'R5nw'Q5kx'Q5mz'P5h}'P5e{'O5d}'O5f~'O6d`'O6ma'M6cb'J7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7m`&]7jb&W7fa&W7o`&U7hb&V7nb&T7a`&Q6c&P6`~&N6e}&R6i~&R6o&T6f&U6n&X7f`&X7g`&[6m&\7m`&]2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2ik"V2bl"W2cl"X2ao"W2`o"V2dn"V2im"U2bl"U2ik"V2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2mo"T2jp"S2bq"S2`q"T2kp"T2mo"U2mo"T2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2mq"R2jq"R2hq"T2lq"T2br"R2mq"R2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2`r"O2lr"O2nr"P2fr"P2`r"O2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2gt"J2lt"K2ht"L2ct"K2gt"J/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/hg?D/kg?C/`g?C/jg?B/eg?A/de?@/fd?@/ed?A/ed?C/me?D/bg?D/hg?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-bi?D-li?C-ji?A-kg>_-`h>_-ch>]-`l>]-ol>[-dj>\-mj>[-cl>Z-om>Y-fp>Y-`q>X-as>V-cs>T-op>U-oo>U-el>X-nl>Y-ok>Y-ek>Y-lh>Z-bg>Y-ad>Y-eb>W-ba>W-o`>X,c>Z,h{>Z,hz>[,f|>]-`a?@-fa>_-ac?@-mb?A-`d?B-nd?A-de?C-eg?D-ah?D-bi?D,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,cy>W,j{>W,k{>V,c}>V,c|>T,g}>T,j}>S,l~>T,c~>R,g|>R,iz>P,mx>P,gt>L,fr>I,mp>G,io>G,lm>F,il>D,kj>B,lh>C,mh>E,ji>E,fh>F,nh>G,bh>J,hi>N,en>P,mo>P,gq>Q,fr>T,cs>T,ds>T,`t>T,mv>V,cy>W,kw

#define REAL_ROW(screen, row) ((row) + (screen)->saved_fifo)
#define ROW2FIFO(screen, row) \
	(unsigned) (REAL_ROW(screen, row) % (screen)->savelines)

/*
 * Given a row-number, find the corresponding data for the line in the VT100
 * widget's saved-line FIFO.  The row-number (from getLineData) is negative.
 * So we just count backwards from the last saved line.
 */
LineData *
getScrollback(TScreen *screen, int row)
{
    LineData *result = 0;

    if (screen->saved_fifo > 0 && REAL_ROW(screen, row) >= 0) {
	unsigned which = ROW2FIFO(screen, row);
	ScrnBuf where = scrnHeadAddr(screen, screen->saveBuf_index, which);
	result = (LineData *) where;
    }

    TRACE(("getScrollback %d -> %d -> %p\n",
	   row, ROW2FIFO(screen, row),
	   (void *) result));
    return result;
}

/*
 * Allocate a new row in the scrollback FIFO, returning a pointer to it.
 */
LineData *
addScrollback(TScreen *screen)
{
    ScrnBuf where = 0;
    unsigned ncols = (unsigned) MaxCols(screen);

    if (screen->saveBuf_index != 0) {
	unsigned which;
	Char *block;

	TRACE(("addScrollback %lu\n", screen->saved_fifo));

	/* first, see which index we'll use */
	which = (unsigned) (screen->saved_fifo % screen->savelines);
	where = scrnHeadAddr(screen, screen->saveBuf_index, which);

	/* discard any obsolete index data */
	if (screen->saved_fifo > screen->savelines) {
	    LineData *prior = (LineData *) where;
	    /*
	     * setupLineData uses the attribs as the first address used from the
	     * data block.
	     */
	    if (prior->attribs != 0) {
		TRACE(("...freeing prior FIFO data in slot %d: %p->%p\n",
		       which, (void *) prior, (void *) prior->attribs));
		free(prior->attribs);
		prior->attribs = 0;
	    }
	    if (screen->saved_fifo > 2 * screen->savelines) {
		screen->saved_fifo -= screen->savelines;
	    }
	}

	/* allocate the new data */
	block = allocScrnData(screen, 1, ncols);

	/* record the new data in the index */
	setupLineData(screen, where, (Char *) block, 1, ncols);

	TRACE(("...storing new FIFO data in slot %d: %p->%p\n",
	       which, (void *) where, block));

	screen->saved_fifo++;
    }
    return (LineData *) where;
}

void
deleteScrollback(TScreen *screen)
{
    unsigned which = ROW2FIFO(screen, -1);
    ScrnBuf where = scrnHeadAddr(screen, screen->saveBuf_index, which);
    LineData *prior = (LineData *) where;
    /*
     * setupLineData uses the attribs as the first address used from the
     * data block.
     */
    if (prior->attribs != 0) {
	TRACE(("...freeing prior FIFO data in slot %d: %p->%p\n",
	       which, (void *) prior, (void *) prior->attribs));
	free(prior->attribs);
	prior->attribs = 0;
    }
    screen->saved_fifo--;
}
xterm-330/graphics.c0000644000175100001440000013700613121542146013211 0ustar  tomusers/* $XTermId: graphics.c,v 1.73 2017/06/18 18:20:22 tom Exp $ */

/*
 * Copyright 2013-2016,2017 by Ross Combs
 *
 *                         All Rights Reserved
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name(s) of the above copyright
 * holders shall not be used in advertising or otherwise to promote the
 * sale, use or other dealings in this Software without prior written
 * authorization.
 */

#include 

#include 
#include 
#include 

#include 
#include 

#include 
#include 

#undef DUMP_BITMAP
#undef DUMP_COLORS
#undef DEBUG_PALETTE
#undef DEBUG_PIXEL
#undef DEBUG_REFRESH

/*
 * graphics TODO list
 *
 * ReGIS:
 * - ship a default alphabet zero font instead of scaling Xft fonts
 * - input cursors
 * - output cursors
 * - mouse/tablet/arrow-key input
 * - fix graphic pages for ReGIS -- they should also apply to text and sixel graphics
 * - fix interpolated curves to more closely match implementation (identical despite direction and starting point)
 * - non-ASCII alphabets
 * - enter/leave anywhere in a command
 * - locator key definitions (DECLKD)
 * - command display mode
 * - re-rasterization on window resize
 * - macros
 * - improved fills for narrow angles (track actual lines not just pixels)
 * - hardcopy/screen-capture support (need dialog of some sort for safety)
 * - error reporting
 *
 * sixel:
 * - fix problem where new_row < 0 during sixel parsing (see FIXME)
 * - screen-capture support (need dialog of some sort for safety)
 *
 * VT55/VT105 waveform graphics
 * - everything
 *
 * Tektronix:
 * - color (VT340 4014 emulation, 41xx, IRAF GTERM, and also MS-DOS Kermit color support)
 * - polygon fill (41xx)
 * - clear area extension
 * - area fill extension
 * - pixel operations (RU/RS/RP)
 * - research other 41xx and 42xx extensions
 *
 * common graphics features:
 * - handle light/dark screen modes (CSI?5[hl])
 * - update text fg/bg color which overlaps images
 * - handle graphic updates in scroll regions (verify effect on graphics)
 * - handle rectangular area copies (verify they work with graphics)
 * - invalidate graphics under graphic if same origin, at least as big, and bg not transparent
 * - invalidate graphic if completely scrolled past end of scrollback
 * - invalidate graphic if all pixels are transparent/erased
 * - invalidate graphic if completely scrolled out of alt buffer
 * - posturize requested colors to match hardware palettes (e.g. only four possible shades on VT240)
 * - color register report/restore
 * - ability to select/copy graphics for pasting in other programs
 * - ability to show non-scroll-mode sixel graphics in a separate window
 * - ability to show ReGIS graphics in a separate window
 * - ability to show Tektronix graphics in VT100 window
 * - truncate graphics at bottom edge of terminal?
 * - locator events (DECEFR DECSLE DECELR DECLRP)
 * - locator controller mode (CSI6i / CSI7i)
 *
 * new escape sequences:
 * - way to query text font size without "window ops" (or make "window ops" permissions more fine grained)
 * - way to query and set the number of graphics pages
 *
 * ReGIS extensions:
 * - non-integer text scaling
 * - free distortionless text rotation (vs. simulating the distortion and aligning to 45deg increments)
 * - font characteristics: bold/underline/italic
 * - remove/increase arbitrary limits (pattern size, pages, alphabets, stack size, font names, etc.)
 * - shade/fill with borders
 * - sprites (copy portion of page into/out of buffer with scaling and rotation)
 * - ellipses
 * - 2D patterns
 * - option to set actual graphic size (not just coordinate range)
 * - gradients (for lines and fills)
 * - line width (RLogin has this and it is mentioned in docs for the DEC ReGIS to Postscript converter)
 * - transparency
 * - background color as stackable write control
 * - true color (virtual color registers created upon lookup)
 * - anti-aliasing
 * - variable-width (proportional) text
 */

/* font sizes:
 * VT510:
 *   80 Columns 132 Columns Maximum Number of Lines
 *   10 x 16   6 x 16  26 lines + keyboard indicator line
 *   10 x 13   6 x 13  26 lines + keyboard indicator line
 *   10 x 10   6 x 10  42 lines + keyboard indicator line
 *   10 x 8    6 x 8   53 lines + keyboard indicator line
 */

typedef struct allocated_color_register {
    struct allocated_color_register *next;
    Pixel pix;
    short r, g, b;
} AllocatedColorRegister;

#define LOOKUP_WIDTH 16
static AllocatedColorRegister *allocated_colors[LOOKUP_WIDTH][LOOKUP_WIDTH][LOOKUP_WIDTH];

#define FOR_EACH_SLOT(ii) for (ii = 0U; ii < MAX_GRAPHICS; ii++)

static ColorRegister *shared_color_registers;
static Graphic *displayed_graphics[MAX_GRAPHICS];
static unsigned next_graphic_id = 0U;

static ColorRegister *
allocRegisters(void)
{
    return TypeCallocN(ColorRegister, MAX_COLOR_REGISTERS);
}

static Graphic *
freeGraphic(Graphic *obj)
{
    if (obj) {
	if (obj->pixels)
	    free(obj->pixels);
	if (obj->private_color_registers)
	    free(obj->private_color_registers);
	free(obj);
    }
    return NULL;
}

static Graphic *
allocGraphic(int max_w, int max_h)
{
    Graphic *result = TypeCalloc(Graphic);
    if (result) {
	result->max_width = max_w;
	result->max_height = max_h;
	if (!(result->pixels = TypeCallocN(RegisterNum,
					     (size_t) max_w * (size_t) max_h))) {
	    result = freeGraphic(result);
	} else if (!(result->private_color_registers = allocRegisters())) {
	    result = freeGraphic(result);
	}
    }
    return result;
}

static Graphic *
getActiveSlot(unsigned n)
{
    if (n < MAX_GRAPHICS &&
	displayed_graphics[n] &&
	displayed_graphics[n]->valid) {
	return displayed_graphics[n];
    }
    return NULL;
}

static Graphic *
getInactiveSlot(const TScreen *screen, unsigned n)
{
    if (n < MAX_GRAPHICS &&
	(!displayed_graphics[n] ||
	 !displayed_graphics[n]->valid)) {
	if (!displayed_graphics[n]) {
	    displayed_graphics[n] = allocGraphic(screen->graphics_max_wide,
						 screen->graphics_max_high);
	}
	return displayed_graphics[n];
    }
    return NULL;
}

static ColorRegister *
getSharedRegisters(void)
{
    if (!shared_color_registers)
	shared_color_registers = allocRegisters();
    return shared_color_registers;
}

static void
deactivateSlot(unsigned n)
{
    if (n < MAX_GRAPHICS) {
	displayed_graphics[n] = freeGraphic(displayed_graphics[n]);
    }
}

extern RegisterNum
read_pixel(Graphic *graphic, int x, int y)
{
    if (x < 0 || x >= graphic->actual_width ||
	y < 0 || y >= graphic->actual_height) {
	return COLOR_HOLE;
    }

    return graphic->pixels[y * graphic->max_width + x];
}

#define _draw_pixel(G, X, Y, C) \
    do { \
        (G)->pixels[(Y) * (G)->max_width + (X)] = (RegisterNum) (C); \
    } while (0)

void
draw_solid_pixel(Graphic *graphic, int x, int y, unsigned color)
{
    assert(color <= MAX_COLOR_REGISTERS);

#ifdef DEBUG_PIXEL
    TRACE(("drawing pixel at %d,%d color=%hu (hole=%hu, [%d,%d,%d])\n",
	   x,
	   y,
	   color,
	   COLOR_HOLE,
	   ((color != COLOR_HOLE)
	    ? (unsigned) graphic->color_registers[color].r : 0U),
	   ((color != COLOR_HOLE)
	    ? (unsigned) graphic->color_registers[color].g : 0U),
	   ((color != COLOR_HOLE)
	    ? (unsigned) graphic->color_registers[color].b : 0U)));
#endif
    if (x >= 0 && x < graphic->actual_width &&
	y >= 0 && y < graphic->actual_height) {
	_draw_pixel(graphic, x, y, color);
	if (color < MAX_COLOR_REGISTERS)
	    graphic->color_registers_used[color] = 1;
    }
}

void
draw_solid_rectangle(Graphic *graphic, int x1, int y1, int x2, int y2, unsigned color)
{
    int x, y;
    int tmp;

    assert(color <= MAX_COLOR_REGISTERS);

    if (x1 > x2) {
	EXCHANGE(x1, x2, tmp);
    }
    if (y1 > y2) {
	EXCHANGE(y1, y2, tmp);
    }

    if (x2 < 0 || x1 >= graphic->actual_width ||
	y2 < 0 || y1 >= graphic->actual_height)
	return;

    if (x1 < 0)
	x1 = 0;
    if (x2 >= graphic->actual_width)
	x2 = graphic->actual_width - 1;
    if (y1 < 0)
	y1 = 0;
    if (y2 >= graphic->actual_height)
	y2 = graphic->actual_height - 1;

    if (color < MAX_COLOR_REGISTERS)
	graphic->color_registers_used[color] = 1;
    for (y = y1; y <= y2; y++)
	for (x = x1; x <= x2; x++)
	    _draw_pixel(graphic, x, y, color);
}

void
draw_solid_line(Graphic *graphic, int x1, int y1, int x2, int y2, unsigned color)
{
    int x, y;
    int dx, dy;
    int dir, diff;

    assert(color <= MAX_COLOR_REGISTERS);

    dx = abs(x1 - x2);
    dy = abs(y1 - y2);

    if (dx > dy) {
	if (x1 > x2) {
	    int tmp;
	    EXCHANGE(x1, x2, tmp);
	    EXCHANGE(y1, y2, tmp);
	}
	if (y1 < y2)
	    dir = 1;
	else if (y1 > y2)
	    dir = -1;
	else
	    dir = 0;

	diff = 0;
	y = y1;
	for (x = x1; x <= x2; x++) {
	    if (diff >= dx) {
		diff -= dx;
		y += dir;
	    }
	    diff += dy;
	    draw_solid_pixel(graphic, x, y, color);
	}
    } else {
	if (y1 > y2) {
	    int tmp;
	    EXCHANGE(x1, x2, tmp);
	    EXCHANGE(y1, y2, tmp);
	}
	if (x1 < x2)
	    dir = 1;
	else if (x1 > x2)
	    dir = -1;
	else
	    dir = 0;

	diff = 0;
	x = x1;
	for (y = y1; y <= y2; y++) {
	    if (diff >= dy) {
		diff -= dy;
		x += dir;
	    }
	    diff += dx;
	    draw_solid_pixel(graphic, x, y, color);
	}
    }
}

void
copy_overlapping_area(Graphic *graphic, int src_ul_x, int src_ul_y,
		      int dst_ul_x, int dst_ul_y, unsigned w, unsigned h,
		      unsigned default_color)
{
    int sx, ex, dx;
    int sy, ey, dy;
    int xx, yy;
    RegisterNum color;

    if (dst_ul_x <= src_ul_x) {
	sx = 0;
	ex = (int) w - 1;
	dx = +1;
    } else {
	sx = (int) w - 1;
	ex = 0;
	dx = -1;
    }

    if (dst_ul_y <= src_ul_y) {
	sy = 0;
	ey = (int) h - 1;
	dy = +1;
    } else {
	sy = (int) h - 1;
	ey = 0;
	dy = -1;
    }

    for (yy = sy; yy != ey + dy; yy += dy) {
	int dst_y = dst_ul_y + yy;
	int src_y = src_ul_y + yy;
	if (dst_y < 0 || dst_y >= (int) graphic->actual_height)
	    continue;

	for (xx = sx; xx != ex + dx; xx += dx) {
	    int dst_x = dst_ul_x + xx;
	    int src_x = src_ul_x + xx;
	    if (dst_x < 0 || dst_x >= (int) graphic->actual_width)
		continue;

	    if (src_x < 0 || src_x >= (int) graphic->actual_width ||
		src_y < 0 || src_y >= (int) graphic->actual_height)
		color = (RegisterNum) default_color;
	    else
		color = graphic->pixels[(unsigned) (src_y *
						    graphic->max_width) +
					(unsigned) src_x];

	    graphic->pixels[(unsigned) (dst_y * graphic->max_width) +
			    (unsigned) dst_x] = color;
	}
    }
}

static void
set_color_register(ColorRegister *color_registers,
		   unsigned color,
		   int r,
		   int g,
		   int b)
{
    ColorRegister *reg = &color_registers[color];
    reg->r = (short) r;
    reg->g = (short) g;
    reg->b = (short) b;
}

/* Graphics which don't use private colors will act as if they are using a
 * device-wide color palette.
 */
static void
set_shared_color_register(unsigned color, int r, int g, int b)
{
    unsigned ii;

    assert(color < MAX_COLOR_REGISTERS);

    set_color_register(getSharedRegisters(), color, r, g, b);

    FOR_EACH_SLOT(ii) {
	Graphic *graphic;

	if (!(graphic = getActiveSlot(ii)))
	    continue;
	if (graphic->private_colors)
	    continue;

	if (graphic->color_registers_used[ii]) {
	    graphic->dirty = 1;
	}
    }
}

void
update_color_register(Graphic *graphic,
		      unsigned color,
		      int r,
		      int g,
		      int b)
{
    assert(color < MAX_COLOR_REGISTERS);

    if (graphic->private_colors) {
	set_color_register(graphic->private_color_registers,
			   color, r, g, b);
	if (graphic->color_registers_used[color]) {
	    graphic->dirty = 1;
	}
	graphic->color_registers_used[color] = 1;
    } else {
	set_shared_color_register(color, r, g, b);
    }
}

#define SQUARE(X) ( (X) * (X) )

RegisterNum
find_color_register(ColorRegister const *color_registers, int r, int g, int b)
{
    unsigned i;
    unsigned closest_index;
    unsigned closest_distance;

    /* I have no idea what algorithm DEC used for this.
     * The documentation warns that it is unpredictable, especially with values
     * far away from any allocated color so it is probably a very simple
     * heuristic rather than something fancy like finding the minimum distance
     * in a linear perceptive color space.
     */
    closest_index = MAX_COLOR_REGISTERS;
    closest_distance = 0U;
    for (i = 0U; i < MAX_COLOR_REGISTERS; i++) {
	unsigned d = (unsigned) (SQUARE(2 * (color_registers[i].r - r)) +
				 SQUARE(3 * (color_registers[i].g - g)) +
				 SQUARE(1 * (color_registers[i].b - b)));
	if (closest_index == MAX_COLOR_REGISTERS || d < closest_distance) {
	    closest_index = i;
	    closest_distance = d;
	}
    }

    TRACE(("found closest color register to %d,%d,%d: %u (distance %u value %d,%d,%d)\n",
	   r, g, b,
	   closest_index,
	   closest_distance,
	   color_registers[closest_index].r,
	   color_registers[closest_index].g,
	   color_registers[closest_index].b));
    return (RegisterNum) closest_index;
}

static void
init_color_registers(ColorRegister *color_registers, int terminal_id)
{
    TRACE(("setting initial colors for terminal %d\n", terminal_id));
    {
	unsigned i;

	for (i = 0U; i < MAX_COLOR_REGISTERS; i++) {
	    set_color_register(color_registers, (RegisterNum) i, 0, 0, 0);
	}
    }

    /*
     * default color registers:
     *     (mono) (color)
     * VK100/GIGI (fixed)
     * VT125:
     *   0: 0%      0%
     *   1: 33%     blue
     *   2: 66%     red
     *   3: 100%    green
     * VT240:
     *   0: 0%      0%
     *   1: 33%     blue
     *   2: 66%     red
     *   3: 100%    green
     * VT241:
     *   0: 0%      0%
     *   1: 33%     blue
     *   2: 66%     red
     *   3: 100%    green
     * VT330:
     *   0: 0%      0%              (bg for light on dark mode)
     *   1: 33%     blue (red?)
     *   2: 66%     red (green?)
     *   3: 100%    green (yellow?) (fg for light on dark mode)
     * VT340:
     *   0: 0%      0%              (bg for light on dark mode)
     *   1: 14%     blue
     *   2: 29%     red
     *   3: 43%     green
     *   4: 57%     magenta
     *   5: 71%     cyan
     *   6: 86%     yellow
     *   7: 100%    50%             (fg for light on dark mode)
     *   8: 0%      25%
     *   9: 14%     gray-blue
     *  10: 29%     gray-red
     *  11: 43%     gray-green
     *  12: 57%     gray-magenta
     *  13: 71%     gray-cyan
     *  14: 86%     gray-yellow
     *  15: 100%    75%             ("white")
     * VT382:
     *   ? (FIXME: B&W only?)
     * dxterm:
     *  ?
     */
    switch (terminal_id) {
    case 125:
    case 241:
	set_color_register(color_registers, 0, 0, 0, 0);
	set_color_register(color_registers, 1, 0, 0, 100);
	set_color_register(color_registers, 2, 0, 100, 0);
	set_color_register(color_registers, 3, 100, 0, 0);
	break;
    case 240:
    case 330:
	set_color_register(color_registers, 0, 0, 0, 0);
	set_color_register(color_registers, 1, 33, 33, 33);
	set_color_register(color_registers, 2, 66, 66, 66);
	set_color_register(color_registers, 3, 100, 100, 100);
	break;
    case 340:
    default:
	set_color_register(color_registers, 0, 0, 0, 0);
	set_color_register(color_registers, 1, 20, 20, 80);
	set_color_register(color_registers, 2, 80, 13, 13);
	set_color_register(color_registers, 3, 20, 80, 20);
	set_color_register(color_registers, 4, 80, 20, 80);
	set_color_register(color_registers, 5, 20, 80, 80);
	set_color_register(color_registers, 6, 80, 80, 20);
	set_color_register(color_registers, 7, 53, 53, 53);
	set_color_register(color_registers, 8, 26, 26, 26);
	set_color_register(color_registers, 9, 33, 33, 60);
	set_color_register(color_registers, 10, 60, 26, 26);
	set_color_register(color_registers, 11, 33, 60, 33);
	set_color_register(color_registers, 12, 60, 33, 60);
	set_color_register(color_registers, 13, 33, 60, 60);
	set_color_register(color_registers, 14, 60, 60, 33);
	set_color_register(color_registers, 15, 80, 80, 80);
	break;
    case 382:			/* FIXME: verify */
	set_color_register(color_registers, 0, 0, 0, 0);
	set_color_register(color_registers, 1, 100, 100, 100);
	break;
    }

#ifdef DEBUG_PALETTE
    {
	unsigned i;

	for (i = 0U; i < MAX_COLOR_REGISTERS; i++) {
	    TRACE(("initial value for register %03u: %d,%d,%d\n",
		   i,
		   color_registers[i].r,
		   color_registers[i].g,
		   color_registers[i].b));
	}
    }
#endif
}

unsigned
get_color_register_count(TScreen const *screen)
{
    unsigned num_color_registers;

    if (screen->numcolorregisters >= 0) {
	num_color_registers = (unsigned) screen->numcolorregisters;
    } else {
	num_color_registers = 0U;
    }

    if (num_color_registers > 1U) {
	if (num_color_registers > MAX_COLOR_REGISTERS)
	    return MAX_COLOR_REGISTERS;
	return num_color_registers;
    }

    /*
     * color capabilities:
     * VK100/GIGI  1 plane (12x1 pixel attribute blocks) colorspace is 8 fixed colors (black, white, red, green, blue, cyan, yellow, magenta)
     * VT125       2 planes (4 registers) colorspace is (64?) (color), ? (grayscale)
     * VT240       2 planes (4 registers) colorspace is 4 shades (grayscale)
     * VT241       2 planes (4 registers) colorspace is ? (color), ? shades (grayscale)
     * VT330       2 planes (4 registers) colorspace is 4 shades (grayscale)
     * VT340       4 planes (16 registers) colorspace is r16g16b16 (color), 16 shades (grayscale)
     * VT382       1 plane (two fixed colors: black and white)  FIXME: verify
     * dxterm      ?
     */
    switch (screen->terminal_id) {
    case 125:
	return 4U;
    case 240:
	return 4U;
    case 241:
	return 4U;
    case 330:
	return 4U;
    case 340:
	return 16U;
    case 382:
	return 2U;
    default:
	/* unknown graphics model -- might as well be generous */
	return MAX_COLOR_REGISTERS;
    }
}

static void
init_graphic(Graphic *graphic,
	     unsigned type,
	     int terminal_id,
	     int charrow,
	     int charcol,
	     unsigned num_color_registers,
	     int private_colors)
{
    const unsigned max_pixels = (unsigned) (graphic->max_width *
					    graphic->max_height);
    unsigned i;

    TRACE(("initializing graphic object\n"));

    graphic->hidden = 0;
    graphic->dirty = 1;
    for (i = 0U; i < max_pixels; i++)
	graphic->pixels[i] = COLOR_HOLE;
    memset(graphic->color_registers_used, 0, sizeof(graphic->color_registers_used));

    /*
     * text and graphics interactions:
     * VK100/GIGI                text writes on top of graphics buffer, color attribute shared with text
     * VT240,VT241,VT330,VT340   text writes on top of graphics buffer
     * VT382                     text writes on top of graphics buffer FIXME: verify
     * VT125                     graphics buffer overlaid on top of text in B&W display, text not present in color display
     */

    /*
     * dimensions (ReGIS logical, physical):
     * VK100/GIGI  768x4??  768x240(status?)
     * VT125       768x460  768x230(+10status) (1:2 aspect ratio, ReGIS halves vertical addresses through "odd y emulation")
     * VT240       800x460  800x230(+10status) (1:2 aspect ratio, ReGIS halves vertical addresses through "odd y emulation")
     * VT241       800x460  800x230(+10status) (1:2 aspect ratio, ReGIS halves vertical addresses through "odd y emulation")
     * VT330       800x480  800x480(+?status)
     * VT340       800x480  800x480(+?status)
     * VT382       960x750  sixel only
     * dxterm      ?x? ?x?  variable?
     */

    graphic->actual_width = 0;
    graphic->actual_height = 0;

    graphic->pixw = 1;
    graphic->pixh = 1;

    graphic->valid_registers = num_color_registers;
    TRACE(("%d color registers\n", graphic->valid_registers));

    graphic->private_colors = private_colors;
    if (graphic->private_colors) {
	TRACE(("using private color registers\n"));
	init_color_registers(graphic->private_color_registers, terminal_id);
	graphic->color_registers = graphic->private_color_registers;
    } else {
	TRACE(("using shared color registers\n"));
	graphic->color_registers = getSharedRegisters();
    }

    graphic->charrow = charrow;
    graphic->charcol = charcol;
    graphic->type = type;
    graphic->valid = 0;
}

Graphic *
get_new_graphic(XtermWidget xw, int charrow, int charcol, unsigned type)
{
    TScreen const *screen = TScreenOf(xw);
    int bufferid = screen->whichBuf;
    int terminal_id = screen->terminal_id;
    Graphic *graphic;
    unsigned ii;

    FOR_EACH_SLOT(ii) {
	if ((graphic = getInactiveSlot(screen, ii))) {
	    TRACE(("using fresh graphic index=%u id=%u\n", ii, next_graphic_id));
	    break;
	}
    }

    /* if none are free, recycle the graphic scrolled back the farthest */
    if (!graphic) {
	int min_charrow = 0;
	Graphic *min_graphic = NULL;

	FOR_EACH_SLOT(ii) {
	    if (!(graphic = getActiveSlot(ii)))
		continue;
	    if (!min_graphic || graphic->charrow < min_charrow) {
		min_charrow = graphic->charrow;
		min_graphic = graphic;
	    }
	}
	TRACE(("recycling old graphic index=%u id=%u\n", ii, next_graphic_id));
	graphic = min_graphic;
    }

    if (graphic) {
	unsigned num_color_registers;
	num_color_registers = get_color_register_count(screen);
	graphic->xw = xw;
	graphic->bufferid = bufferid;
	graphic->id = next_graphic_id++;
	init_graphic(graphic,
		     type,
		     terminal_id,
		     charrow,
		     charcol,
		     num_color_registers,
		     screen->privatecolorregisters);
    }
    return graphic;
}

Graphic *
get_new_or_matching_graphic(XtermWidget xw,
			    int charrow,
			    int charcol,
			    int actual_width,
			    int actual_height,
			    unsigned type)
{
    TScreen const *screen = TScreenOf(xw);
    int bufferid = screen->whichBuf;
    Graphic *graphic;
    unsigned ii;

    FOR_EACH_SLOT(ii) {
	TRACE(("checking slot=%u for graphic at %d,%d %dx%d bufferid=%d type=%u\n", ii,
	       charrow, charcol,
	       actual_width, actual_height,
	       bufferid, type));
	if ((graphic = getActiveSlot(ii))) {
	    if (graphic->type == type &&
		graphic->bufferid == bufferid &&
		graphic->charrow == charrow &&
		graphic->charcol == charcol &&
		graphic->actual_width == actual_width &&
		graphic->actual_height == actual_height) {
		TRACE(("found existing graphic slot=%u id=%u\n", ii, graphic->id));
		return graphic;
	    }
	    TRACE(("not a match: graphic at %d,%d %dx%d bufferid=%d type=%u\n",
		   graphic->charrow, graphic->charcol,
		   graphic->actual_width, graphic->actual_height,
		   graphic->bufferid, graphic->type));
	}
    }

    /* if no match get a new graphic */
    if ((graphic = get_new_graphic(xw, charrow, charcol, type))) {
	graphic->actual_width = actual_width;
	graphic->actual_height = actual_height;
	TRACE(("no match; created graphic at %d,%d %dx%d bufferid=%d type=%u\n",
	       graphic->charrow, graphic->charcol,
	       graphic->actual_width, graphic->actual_height,
	       graphic->bufferid, graphic->type));
    }
    return graphic;
}

static int
lookup_allocated_color(const ColorRegister *reg, Pixel *pix)
{
    unsigned const rr = ((unsigned) reg->r * (LOOKUP_WIDTH - 1)) / CHANNEL_MAX;
    unsigned const gg = ((unsigned) reg->g * (LOOKUP_WIDTH - 1)) / CHANNEL_MAX;
    unsigned const bb = ((unsigned) reg->b * (LOOKUP_WIDTH - 1)) / CHANNEL_MAX;
    const AllocatedColorRegister *search;

    for (search = allocated_colors[rr][gg][bb]; search; search = search->next) {
	if (search->r == reg->r &&
	    search->g == reg->g &&
	    search->b == reg->b) {
	    *pix = search->pix;
	    return 1;
	}
    }

    *pix = 0UL;
    return 0;
}

#define ScaleForXColor(s) (unsigned short) ((long)(s) * 65535 / CHANNEL_MAX)

static int
save_allocated_color(const ColorRegister *reg, XtermWidget xw, Pixel *pix)
{
    unsigned const rr = ((unsigned) reg->r * (LOOKUP_WIDTH - 1)) / CHANNEL_MAX;
    unsigned const gg = ((unsigned) reg->g * (LOOKUP_WIDTH - 1)) / CHANNEL_MAX;
    unsigned const bb = ((unsigned) reg->b * (LOOKUP_WIDTH - 1)) / CHANNEL_MAX;
    XColor xcolor;
    AllocatedColorRegister *new_color;

    xcolor.pixel = 0UL;
    xcolor.red = ScaleForXColor(reg->r);
    xcolor.green = ScaleForXColor(reg->g);
    xcolor.blue = ScaleForXColor(reg->b);
    xcolor.flags = DoRed | DoGreen | DoBlue;
    if (!allocateBestRGB(xw, &xcolor)) {
	TRACE(("unable to allocate xcolor\n"));
	*pix = 0UL;
	return 0;
    }

    *pix = xcolor.pixel;

    if (!(new_color = malloc(sizeof(*new_color)))) {
	TRACE(("unable to save pixel %lu\n", (unsigned long) *pix));
	return 0;
    }
    new_color->r = reg->r;
    new_color->g = reg->g;
    new_color->b = reg->b;
    new_color->pix = *pix;
    new_color->next = allocated_colors[rr][gg][bb];

    allocated_colors[rr][gg][bb] = new_color;

    return 1;
}

static Pixel
color_register_to_xpixel(const ColorRegister *reg, XtermWidget xw)
{
    Pixel pix;

    if (!lookup_allocated_color(reg, &pix))
	save_allocated_color(reg, xw, &pix);

    /* FIXME: with so many possible colors we need to determine
     * when to free them to be nice to PseudoColor displays
     */
    return pix;
}

static void
refresh_graphic(TScreen const *screen,
		Graphic const *graphic,
		ColorRegister *buffer,
		int refresh_x,
		int refresh_y,
		int refresh_w,
		int refresh_h,
		int draw_x,
		int draw_y,
		int draw_w,
		int draw_h)
{
    int const pw = graphic->pixw;
    int const ph = graphic->pixh;
    int const graph_x = graphic->charcol * FontWidth(screen);
    int const graph_y = graphic->charrow * FontHeight(screen);
    int const graph_w = graphic->actual_width;
    int const graph_h = graphic->actual_height;
    int const mw = graphic->max_width;
    int r, c;
    int fillx, filly;
    int holes, total, out_of_range;
    RegisterNum regnum;

    TRACE(("refreshing graphic %u from %d,%d %dx%d (valid=%d, size=%dx%d, scale=%dx%d max=%dx%d)\n",
	   graphic->id,
	   graph_x, graph_y, draw_w, draw_h,
	   graphic->valid,
	   graphic->actual_width,
	   graphic->actual_height,
	   pw, ph,
	   graphic->max_width,
	   graphic->max_height));

    TRACE(("refresh pixmap starts at %d,%d\n", refresh_x, refresh_y));

    holes = total = 0;
    out_of_range = 0;
    for (r = 0; r < graph_h; r++) {
	int pmy = graph_y + r * ph;

	if (pmy + ph - 1 < draw_y)
	    continue;
	if (pmy > draw_y + draw_h - 1)
	    break;

	for (c = 0; c < graph_w; c++) {
	    int pmx = graph_x + c * pw;

	    if (pmx + pw - 1 < draw_x)
		continue;
	    if (pmx > draw_x + draw_w - 1)
		break;

	    total++;
	    regnum = graphic->pixels[r * mw + c];
	    if (regnum == COLOR_HOLE) {
		holes++;
		continue;
	    }

	    for (fillx = 0; fillx < pw; fillx++) {
		for (filly = 0; filly < ph; filly++) {
		    if (pmx < draw_x || pmx > draw_x + draw_w - 1 ||
			pmy < draw_y || pmy > draw_y + draw_h - 1) {
			out_of_range++;
			continue;
		    }

		    /* this shouldn't happen, but it doesn't hurt to check */
		    if (pmx < refresh_x || pmx > refresh_x + refresh_w - 1 ||
			pmy < refresh_y || pmy > refresh_y + refresh_h - 1) {
			TRACE(("OUT OF RANGE: %d,%d (%d,%d)\n", pmx, pmy, r, c));
			out_of_range++;
			continue;
		    }

		    buffer[(pmy - refresh_y) * refresh_w +
			   (pmx - refresh_x)] =
			graphic->color_registers[regnum];
		}
	    }
	}
    }

    TRACE(("done refreshing graphic: %d of %d refreshed pixels were holes; %d were out of pixmap range\n",
	   holes, total, out_of_range));
}

#ifdef DEBUG_REFRESH

#define BASEX(X) ( (draw_x - base_x) + (X) )
#define BASEY(Y) ( (draw_y - base_y) + (Y) )

static void
outline_refresh(TScreen const *screen,
		Graphic const *graphic,
		Pixmap output_pm,
		GC graphics_gc,
		int base_x,
		int base_y,
		int draw_x,
		int draw_y,
		int draw_w,
		int draw_h)
{
    Display *const display = screen->display;
    int const pw = graphic->pixw;
    int const ph = graphic->pixh;
    XGCValues xgcv;
    XColor def;

    def.red = (unsigned short) ((1.0 - 0.1 * (rand() / (double)
					      RAND_MAX) * 65535.0));
    def.green = (unsigned short) ((0.7 + 0.2 * (rand() / (double)
						RAND_MAX)) * 65535.0);
    def.blue = (unsigned short) ((0.1 + 0.1 * (rand() / (double)
					       RAND_MAX)) * 65535.0);
    def.flags = DoRed | DoGreen | DoBlue;
    if (allocateBestRGB(graphic->xw, &def)) {
	xgcv.foreground = def.pixel;
	XChangeGC(display, graphics_gc, GCForeground, &xgcv);
    }

    XDrawLine(display, output_pm, graphics_gc,
	      BASEX(0), BASEY(0),
	      BASEX(draw_w - 1), BASEY(0));
    XDrawLine(display, output_pm, graphics_gc,
	      BASEX(0), BASEY(draw_h - 1),
	      BASEX(draw_w - 1), BASEY(draw_h - 1));

    XDrawLine(display, output_pm, graphics_gc,
	      BASEX(0), BASEY(0),
	      BASEX(0), BASEY(draw_h - 1));
    XDrawLine(display, output_pm, graphics_gc,
	      BASEX(draw_w - 1), BASEY(0),
	      BASEX(draw_w - 1), BASEY(draw_h - 1));

    XDrawLine(display, output_pm, graphics_gc,
	      BASEX(draw_w - 1), BASEY(0),
	      BASEX(0), BASEY(draw_h - 1));
    XDrawLine(display, output_pm, graphics_gc,
	      BASEX(draw_w - 1), BASEY(draw_h - 1),
	      BASEX(0), BASEY(0));

    def.red = (short) (0.7 * 65535.0);
    def.green = (short) (0.1 * 65535.0);
    def.blue = (short) (1.0 * 65535.0);
    def.flags = DoRed | DoGreen | DoBlue;
    if (allocateBestRGB(graphic->xw, &def)) {
	xgcv.foreground = def.pixel;
	XChangeGC(display, graphics_gc, GCForeground, &xgcv);
    }
    XFillRectangle(display, output_pm, graphics_gc,
		   BASEX(0),
		   BASEY(0),
		   (unsigned) pw, (unsigned) ph);
    XFillRectangle(display, output_pm, graphics_gc,
		   BASEX(draw_w - 1 - pw),
		   BASEY(draw_h - 1 - ph),
		   (unsigned) pw, (unsigned) ph);
}
#endif

/*
 * Primary color hues:
 *  blue:    0 degrees
 *  red:   120 degrees
 *  green: 240 degrees
 */
void
hls2rgb(int h, int l, int s, short *r, short *g, short *b)
{
    const int hs = ((h + 240) / 60) % 6;
    const double lv = l / 100.0;
    const double sv = s / 100.0;
    double c, x, m, c2;
    double r1, g1, b1;

    if (s == 0) {
	*r = *g = *b = (short) l;
	return;
    }

    c2 = (2.0 * lv) - 1.0;
    if (c2 < 0.0)
	c2 = -c2;
    c = (1.0 - c2) * sv;
    x = (hs & 1) ? c : 0.0;
    m = lv - 0.5 * c;

    switch (hs) {
    case 0:
	r1 = c;
	g1 = x;
	b1 = 0.0;
	break;
    case 1:
	r1 = x;
	g1 = c;
	b1 = 0.0;
	break;
    case 2:
	r1 = 0.0;
	g1 = c;
	b1 = x;
	break;
    case 3:
	r1 = 0.0;
	g1 = x;
	b1 = c;
	break;
    case 4:
	r1 = x;
	g1 = 0.0;
	b1 = c;
	break;
    case 5:
	r1 = c;
	g1 = 0.0;
	b1 = x;
	break;
    default:
	TRACE(("Bad HLS input: [%d,%d,%d], returning white\n", h, l, s));
	*r = (short) 100;
	*g = (short) 100;
	*b = (short) 100;
	return;
    }

    *r = (short) ((r1 + m) * 100.0 + 0.5);
    *g = (short) ((g1 + m) * 100.0 + 0.5);
    *b = (short) ((b1 + m) * 100.0 + 0.5);

    if (*r < 0)
	*r = 0;
    else if (*r > 100)
	*r = 100;
    if (*g < 0)
	*g = 0;
    else if (*g > 100)
	*g = 100;
    if (*b < 0)
	*b = 0;
    else if (*b > 100)
	*b = 100;
}

void
dump_graphic(Graphic const *graphic)
{
#if defined(DUMP_COLORS) || defined(DUMP_BITMAP)
    RegisterNum color;
#endif
#ifdef DUMP_BITMAP
    int r, c;
    ColorRegister const *reg;
#endif

    (void) graphic;

    TRACE(("graphic stats: id=%u charrow=%d charcol=%d actual_width=%d actual_height=%d pixw=%d pixh=%d\n",
	   graphic->id,
	   graphic->charrow,
	   graphic->charcol,
	   graphic->actual_width,
	   graphic->actual_height,
	   graphic->pixw,
	   graphic->pixh));

#ifdef DUMP_COLORS
    TRACE(("graphic colors:\n"));
    for (color = 0; color < graphic->valid_registers; color++) {
	TRACE(("%03u: %d,%d,%d\n",
	       color,
	       graphic->color_registers[color].r,
	       graphic->color_registers[color].g,
	       graphic->color_registers[color].b));
    }
#endif

#ifdef DUMP_BITMAP
    TRACE(("graphic pixels:\n"));
    for (r = 0; r < graphic->actual_height; r++) {
	for (c = 0; c < graphic->actual_width; c++) {
	    color = graphic->pixels[r * graphic->max_width + c];
	    if (color == COLOR_HOLE) {
		TRACE(("?"));
	    } else {
		reg = &graphic->color_registers[color];
		if (reg->r + reg->g + reg->b > 200) {
		    TRACE(("#"));
		} else if (reg->r + reg->g + reg->b > 150) {
		    TRACE(("%%"));
		} else if (reg->r + reg->g + reg->b > 100) {
		    TRACE((":"));
		} else if (reg->r + reg->g + reg->b > 80) {
		    TRACE(("."));
		} else {
		    TRACE((" "));
		}
	    }
	}
	TRACE(("\n"));
    }

    TRACE(("\n"));
#endif
}

/* Erase the portion of any displayed graphic overlapping with a rectangle
 * of the given size and location in pixels relative to the start of the
 * graphic.  This is used to allow text to "erase" graphics underneath it.
 */
static void
erase_graphic(Graphic *graphic, int x, int y, int w, int h)
{
    RegisterNum hole = COLOR_HOLE;
    int pw, ph;
    int r, c;
    int rbase, cbase;

    pw = graphic->pixw;
    ph = graphic->pixh;

    TRACE(("erasing graphic %d,%d %dx%d\n", x, y, w, h));

    rbase = 0;
    for (r = 0; r < graphic->actual_height; r++) {
	if (rbase + ph - 1 >= y
	    && rbase <= y + h - 1) {
	    cbase = 0;
	    for (c = 0; c < graphic->actual_width; c++) {
		if (cbase + pw - 1 >= x
		    && cbase <= x + w - 1) {
		    graphic->pixels[r * graphic->max_width + c] = hole;
		}
		cbase += pw;
	    }
	}
	rbase += ph;
    }
}

static int
compare_graphic_ids(const void *left, const void *right)
{
    const Graphic *l = *(const Graphic *const *) left;
    const Graphic *r = *(const Graphic *const *) right;

    if (!l->valid || !r->valid)
	return 0;

    if (l->bufferid < r->bufferid)
	return -1;
    else if (l->bufferid > r->bufferid)
	return 1;

    if (l->id < r->id)
	return -1;
    else
	return 1;
}

static void
clip_area(int *orig_x, int *orig_y, int *orig_w, int *orig_h,
	  int clip_x, int clip_y, int clip_w, int clip_h)
{
    if (*orig_x < clip_x) {
	const int diff = clip_x - *orig_x;
	*orig_x += diff;
	*orig_w -= diff;
    }
    if (*orig_w > 0 && *orig_x + *orig_w > clip_x + clip_w) {
	*orig_w -= (*orig_x + *orig_w) - (clip_x + clip_w);
    }

    if (*orig_y < clip_y) {
	const int diff = clip_y - *orig_y;
	*orig_y += diff;
	*orig_h -= diff;
    }
    if (*orig_h > 0 && *orig_y + *orig_h > clip_y + clip_h) {
	*orig_h -= (*orig_y + *orig_h) - (clip_y + clip_h);
    }
}

/* the coordinates are relative to the screen */
static void
refresh_graphics(XtermWidget xw,
		 int leftcol,
		 int toprow,
		 int ncols,
		 int nrows,
		 int skip_clean)
{
    TScreen *const screen = TScreenOf(xw);
    Display *const display = screen->display;
    Window const drawable = VDrawable(screen);
    int const scroll_y = screen->topline * FontHeight(screen);
    int const refresh_x = leftcol * FontWidth(screen);
    int const refresh_y = toprow * FontHeight(screen) + scroll_y;
    int const refresh_w = ncols * FontWidth(screen);
    int const refresh_h = nrows * FontHeight(screen);
    int draw_x_min, draw_x_max;
    int draw_y_min, draw_y_max;
    Graphic *ordered_graphics[MAX_GRAPHICS];
    unsigned ii, jj;
    unsigned active_count;
    unsigned holes, non_holes;
    int xx, yy;
    ColorRegister *buffer;

    active_count = 0;
    FOR_EACH_SLOT(ii) {
	Graphic *graphic;
	if (!(graphic = getActiveSlot(ii)))
	    continue;
	TRACE(("refreshing graphic %d on buffer %d, current buffer %d\n",
	       graphic->id, graphic->bufferid, screen->whichBuf));
	if (screen->whichBuf == 0) {
	    if (graphic->bufferid != 0) {
		TRACE(("skipping graphic %d from alt buffer (%d) when drawing screen=%d\n",
		       graphic->id, graphic->bufferid, screen->whichBuf));
		continue;
	    }
	} else {
	    if (graphic->bufferid == 0 && graphic->charrow >= 0) {
		TRACE(("skipping graphic %d from normal buffer (%d) when drawing screen=%d because it is not in scrollback area\n",
		       graphic->id, graphic->bufferid, screen->whichBuf));
		continue;
	    }
	    if (graphic->bufferid == 1 &&
		graphic->charrow + (graphic->actual_height +
				    FontHeight(screen) - 1) /
		FontHeight(screen) < 0) {
		TRACE(("skipping graphic %d from alt buffer (%d) when drawing screen=%d because it is completely in scrollback area\n",
		       graphic->id, graphic->bufferid, screen->whichBuf));
		continue;
	    }
	}
	if (graphic->hidden)
	    continue;
	ordered_graphics[active_count++] = graphic;
    }

    if (active_count == 0)
	return;
    if (active_count > 1) {
	qsort(ordered_graphics,
	      (size_t) active_count,
	      sizeof(ordered_graphics[0]),
	      compare_graphic_ids);
    }

    if (skip_clean) {
	unsigned skip_count;

	for (jj = 0; jj < active_count; ++jj) {
	    if (ordered_graphics[jj]->dirty)
		break;
	}
	skip_count = jj;
	if (skip_count == active_count)
	    return;

	active_count -= skip_count;
	for (jj = 0; jj < active_count; ++jj) {
	    ordered_graphics[jj] = ordered_graphics[jj + skip_count];
	}
    }

    if (!(buffer = malloc(sizeof(*buffer) *
			  (unsigned) refresh_w * (unsigned) refresh_h))) {
	TRACE(("unable to allocate %dx%d buffer for graphics refresh\n",
	       refresh_w, refresh_h));
	return;
    }
    for (yy = 0; yy < refresh_h; yy++) {
	for (xx = 0; xx < refresh_w; xx++) {
	    buffer[yy * refresh_w + xx].r = -1;
	    buffer[yy * refresh_w + xx].g = -1;
	    buffer[yy * refresh_w + xx].b = -1;
	}
    }

    TRACE(("refresh: screen->topline=%d leftcol=%d toprow=%d nrows=%d ncols=%d (%d,%d %dx%d)\n",
	   screen->topline,
	   leftcol, toprow,
	   nrows, ncols,
	   refresh_x, refresh_y,
	   refresh_w, refresh_h));

    {
	int const altarea_x = 0;
	int const altarea_y = 0;
	int const altarea_w = Width(screen) * FontWidth(screen);
	int const altarea_h = Height(screen) * FontHeight(screen);

	int const scrollarea_x = 0;
	int const scrollarea_y = scroll_y;
	int const scrollarea_w = Width(screen) * FontWidth(screen);
	int const scrollarea_h = -scroll_y;

	int const mainarea_x = 0;
	int const mainarea_y = scroll_y;
	int const mainarea_w = Width(screen) * FontWidth(screen);
	int const mainarea_h = -scroll_y + Height(screen) * FontHeight(screen);

	draw_x_min = refresh_x + refresh_w;
	draw_x_max = refresh_x - 1;
	draw_y_min = refresh_y + refresh_h;
	draw_y_max = refresh_y - 1;
	for (jj = 0; jj < active_count; ++jj) {
	    Graphic *graphic = ordered_graphics[jj];
	    int draw_x = graphic->charcol * FontWidth(screen);
	    int draw_y = graphic->charrow * FontHeight(screen);
	    int draw_w = graphic->actual_width;
	    int draw_h = graphic->actual_height;

	    if (screen->whichBuf != 0) {
		if (graphic->bufferid != 0) {
		    /* clip to alt buffer */
		    clip_area(&draw_x, &draw_y, &draw_w, &draw_h,
			      altarea_x, altarea_y, altarea_w, altarea_h);
		} else {
		    /* clip to scrollback area */
		    clip_area(&draw_x, &draw_y, &draw_w, &draw_h,
			      scrollarea_x, scrollarea_y,
			      scrollarea_w, scrollarea_h);
		}
	    } else {
		/* clip to scrollback + normal area */
		clip_area(&draw_x, &draw_y, &draw_w, &draw_h,
			  mainarea_x, mainarea_y,
			  mainarea_w, mainarea_h);
	    }

	    clip_area(&draw_x, &draw_y, &draw_w, &draw_h,
		      refresh_x, refresh_y, refresh_w, refresh_h);

	    TRACE(("refresh: graph=%u\n", jj));
	    TRACE(("         refresh_x=%d refresh_y=%d refresh_w=%d refresh_h=%d\n",
		   refresh_x, refresh_y, refresh_w, refresh_h));
	    TRACE(("         draw_x=%d draw_y=%d draw_w=%d draw_h=%d\n",
		   draw_x, draw_y, draw_w, draw_h));

	    if (draw_w > 0 && draw_h > 0) {
		refresh_graphic(screen, graphic, buffer,
				refresh_x, refresh_y,
				refresh_w, refresh_h,
				draw_x, draw_y,
				draw_w, draw_h);
		if (draw_x < draw_x_min)
		    draw_x_min = draw_x;
		if (draw_x + draw_w - 1 > draw_x_max)
		    draw_x_max = draw_x + draw_w - 1;
		if (draw_y < draw_y_min)
		    draw_y_min = draw_y;
		if (draw_y + draw_h - 1 > draw_y_max)
		    draw_y_max = draw_y + draw_h - 1;
	    }
	    graphic->dirty = 0;
	}
    }

    if (draw_x_max < refresh_x ||
	draw_x_min > refresh_x + refresh_w - 1 ||
	draw_y_max < refresh_y ||
	draw_y_min > refresh_y + refresh_h - 1) {
	free(buffer);
	return;
    }

    holes = 0U;
    non_holes = 0U;
    for (yy = draw_y_min - refresh_y; yy <= draw_y_max - refresh_y; yy++) {
	for (xx = draw_x_min - refresh_x; xx <= draw_x_max - refresh_x; xx++) {
	    const ColorRegister color = buffer[yy * refresh_w + xx];
	    if (color.r < 0 || color.g < 0 || color.b < 0) {
		holes++;
	    } else {
		non_holes++;
	    }
	}
    }

    if (non_holes < 1U) {
	TRACE(("refresh: visible graphics areas are erased; nothing to do\n"));
	free(buffer);
	return;
    }

    /*
     * If we have any holes we can't just copy an image rectangle, and masking
     * with bitmaps is very expensive.  This fallback is surprisingly faster
     * than the XPutImage version in some cases, but I don't know why.
     * (This is even though there's no X11 primitive for drawing a horizontal
     * line of height one and no attempt is made to handle multiple lines at
     * once.)
     */
    if (holes > 0U) {
	GC graphics_gc;
	XGCValues xgcv;
	ColorRegister last_color;
	ColorRegister gc_color;
	int run;

	memset(&xgcv, 0, sizeof(xgcv));
	xgcv.graphics_exposures = False;
	graphics_gc = XCreateGC(display, drawable, GCGraphicsExposures, &xgcv);
	if (graphics_gc == None) {
	    TRACE(("unable to allocate GC for graphics refresh\n"));
	    free(buffer);
	    return;
	}

	last_color.r = -1;
	last_color.g = -1;
	last_color.b = -1;
	gc_color.r = -1;
	gc_color.g = -1;
	gc_color.b = -1;
	run = 0;
	for (yy = draw_y_min - refresh_y; yy <= draw_y_max - refresh_y; yy++) {
	    for (xx = draw_x_min - refresh_x; xx <= draw_x_max - refresh_x;
		 xx++) {
		const ColorRegister color = buffer[yy * refresh_w + xx];

		if (color.r < 0 || color.g < 0 || color.b < 0) {
		    last_color = color;
		    if (run > 0) {
			XDrawLine(display, drawable, graphics_gc,
				  OriginX(screen) + refresh_x + xx - run,
				  (OriginY(screen) - scroll_y) + refresh_y + yy,
				  OriginX(screen) + refresh_x + xx - 1,
				  (OriginY(screen) - scroll_y) + refresh_y + yy);
			run = 0;
		    }
		    continue;
		}

		if (color.r != last_color.r ||
		    color.g != last_color.g ||
		    color.b != last_color.b) {
		    last_color = color;
		    if (run > 0) {
			XDrawLine(display, drawable, graphics_gc,
				  OriginX(screen) + refresh_x + xx - run,
				  (OriginY(screen) - scroll_y) + refresh_y + yy,
				  OriginX(screen) + refresh_x + xx - 1,
				  (OriginY(screen) - scroll_y) + refresh_y + yy);
			run = 0;
		    }

		    if (color.r != gc_color.r ||
			color.g != gc_color.g ||
			color.b != gc_color.b) {
			xgcv.foreground =
			    color_register_to_xpixel(&color, xw);
			XChangeGC(display, graphics_gc, GCForeground, &xgcv);
			gc_color = color;
		    }
		}
		run++;
	    }
	    if (run > 0) {
		last_color.r = -1;
		last_color.g = -1;
		last_color.b = -1;
		XDrawLine(display, drawable, graphics_gc,
			  OriginX(screen) + refresh_x + xx - run,
			  (OriginY(screen) - scroll_y) + refresh_y + yy,
			  OriginX(screen) + refresh_x + xx - 1,
			  (OriginY(screen) - scroll_y) + refresh_y + yy);
		run = 0;
	    }
	}

	XFreeGC(display, graphics_gc);
    } else {
	XGCValues xgcv;
	GC graphics_gc;
	ColorRegister old_color;
	Pixel fg;
	XImage *image;
	char *imgdata;
	unsigned image_w, image_h;

	memset(&xgcv, 0, sizeof(xgcv));
	xgcv.graphics_exposures = False;
	graphics_gc = XCreateGC(display, drawable, GCGraphicsExposures, &xgcv);
	if (graphics_gc == None) {
	    TRACE(("unable to allocate GC for graphics refresh\n"));
	    free(buffer);
	    return;
	}

	/* FIXME: is it worth reusing the GC/Image/imagedata across calls? */
	/* FIXME: is it worth using shared memory when available? */
	image_w = (unsigned) draw_x_max + 1U - (unsigned) draw_x_min;
	image_h = (unsigned) draw_y_max + 1U - (unsigned) draw_y_min;
	image = XCreateImage(display, xw->visInfo->visual,
			     (unsigned) xw->visInfo->depth,
			     ZPixmap, 0, NULL,
			     image_w, image_h,
			     sizeof(int) * 8U, 0);
	if (!image) {
	    TRACE(("unable to allocate XImage for graphics refresh\n"));
	    XFreeGC(display, graphics_gc);
	    free(buffer);
	    return;
	}
	imgdata = malloc(image_h * (unsigned) image->bytes_per_line);
	if (!imgdata) {
	    TRACE(("unable to allocate XImage for graphics refresh\n"));
	    XDestroyImage(image);
	    XFreeGC(display, graphics_gc);
	    free(buffer);
	    return;
	}
	image->data = imgdata;

	fg = 0U;
	old_color.r = -1;
	old_color.g = -1;
	old_color.b = -1;
	for (yy = draw_y_min - refresh_y; yy <= draw_y_max - refresh_y; yy++) {
	    for (xx = draw_x_min - refresh_x; xx <= draw_x_max - refresh_x;
		 xx++) {
		const ColorRegister color = buffer[yy * refresh_w + xx];

		if (color.r != old_color.r ||
		    color.g != old_color.g ||
		    color.b != old_color.b) {
		    fg = color_register_to_xpixel(&color, xw);
		    old_color = color;
		}

		XPutPixel(image, xx + refresh_x - draw_x_min,
			  yy + refresh_y - draw_y_min, fg);
	    }
	}

	XPutImage(display, drawable, graphics_gc, image,
		  0, 0,
		  OriginX(screen) + draw_x_min,
		  (OriginY(screen) - scroll_y) + draw_y_min,
		  image_w, image_h);
	free(imgdata);
	image->data = NULL;
	XDestroyImage(image);
	XFreeGC(display, graphics_gc);
    }

    free(buffer);
    XFlush(display);
}

void
refresh_displayed_graphics(XtermWidget xw,
			   int leftcol,
			   int toprow,
			   int ncols,
			   int nrows)
{
    refresh_graphics(xw, leftcol, toprow, ncols, nrows, 0);
}

void
refresh_modified_displayed_graphics(XtermWidget xw)
{
    TScreen const *screen = TScreenOf(xw);
    refresh_graphics(xw, 0, 0, MaxCols(screen), MaxRows(screen), 1);
}

void
scroll_displayed_graphics(XtermWidget xw, int rows)
{
    TScreen const *screen = TScreenOf(xw);
    unsigned ii;

    TRACE(("graphics scroll: moving all up %d rows\n", rows));
    /* FIXME: VT125 ReGIS graphics are fixed at the upper left of the display; need to verify */

    FOR_EACH_SLOT(ii) {
	Graphic *graphic;

	if (!(graphic = getActiveSlot(ii)))
	    continue;
	if (graphic->bufferid != screen->whichBuf)
	    continue;
	if (graphic->hidden)
	    continue;

	graphic->charrow -= rows;
    }
}

void
pixelarea_clear_displayed_graphics(TScreen const *screen,
				   int winx,
				   int winy,
				   int w,
				   int h)
{
    unsigned ii;

    FOR_EACH_SLOT(ii) {
	Graphic *graphic;
	/* FIXME: are these coordinates (scrolled) screen-relative? */
	int const scroll_y = (screen->whichBuf == 0
			      ? screen->topline * FontHeight(screen)
			      : 0);
	int graph_x;
	int graph_y;
	int x, y;

	if (!(graphic = getActiveSlot(ii)))
	    continue;
	if (graphic->bufferid != screen->whichBuf)
	    continue;
	if (graphic->hidden)
	    continue;

	graph_x = graphic->charcol * FontWidth(screen);
	graph_y = graphic->charrow * FontHeight(screen);
	x = winx - graph_x;
	y = (winy - scroll_y) - graph_y;

	TRACE(("pixelarea clear graphics: screen->topline=%d winx=%d winy=%d w=%d h=%d x=%d y=%d\n",
	       screen->topline,
	       winx, winy,
	       w, h,
	       x, y));
	erase_graphic(graphic, x, y, w, h);
    }
}

void
chararea_clear_displayed_graphics(TScreen const *screen,
				  int leftcol,
				  int toprow,
				  int ncols,
				  int nrows)
{
    int const x = leftcol * FontWidth(screen);
    int const y = toprow * FontHeight(screen);
    int const w = ncols * FontWidth(screen);
    int const h = nrows * FontHeight(screen);

    TRACE(("chararea clear graphics: screen->topline=%d leftcol=%d toprow=%d nrows=%d ncols=%d x=%d y=%d w=%d h=%d\n",
	   screen->topline,
	   leftcol, toprow,
	   nrows, ncols,
	   x, y, w, h));
    pixelarea_clear_displayed_graphics(screen, x, y, w, h);
}

void
reset_displayed_graphics(TScreen const *screen)
{
    unsigned ii;

    init_color_registers(getSharedRegisters(), screen->terminal_id);

    TRACE(("resetting all graphics\n"));
    FOR_EACH_SLOT(ii) {
	deactivateSlot(ii);
    }
}

#ifdef NO_LEAKS
void
noleaks_graphics(void)
{
    unsigned ii;

    FOR_EACH_SLOT(ii) {
	deactivateSlot(ii);
    }
}
#endif
xterm-330/ctlseqs.ms0000644000175100001440000026753213117360643013301 0ustar  tomusers.\"#! troff -ms $1		-*- Nroff -*-
.\" "Xterm Control Sequences" document
.\" $XTermId: ctlseqs.ms,v 1.345 2017/06/12 00:34:43 tom Exp $
.\"
.\"
.\" Copyright 1996-2016,2017 by Thomas E. Dickey
.\"
.\"                         All Rights Reserved
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining a
.\" copy of this software and associated documentation files (the
.\" "Software"), to deal in the Software without restriction, including
.\" without limitation the rights to use, copy, modify, merge, publish,
.\" distribute, sublicense, and/or sell copies of the Software, and to
.\" permit persons to whom the Software is furnished to do so, subject to
.\" the following conditions:
.\"
.\" The above copyright notice and this permission notice shall be included
.\" in all copies or substantial portions of the Software.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
.\" IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
.\" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
.\" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
.\" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
.\"
.\" Except as contained in this notice, the name(s) of the above copyright
.\" holders shall not be used in advertising or otherwise to promote the
.\" sale, use or other dealings in this Software without prior written
.\" authorization.
.\"
.\"
.\" Copyright 1991, 1994 X Consortium
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining
.\" a copy of this software and associated documentation files (the
.\" "Software"), to deal in the Software without restriction, including
.\" without limitation the rights to use, copy, modify, merge, publish,
.\" distribute, sublicense, and/or sell copies of the Software, and to
.\" permit persons to whom the Software is furnished to do so, subject to
.\" the following conditions:
.\"
.\" The above copyright notice and this permission notice shall be
.\" included in all copies or substantial portions of the Software.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
.\" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
.\" OTHER DEALINGS IN THE SOFTWARE.
.\"
.\" Except as contained in this notice, the name of the X Consortium shall
.\" not be used in advertising or otherwise to promote the sale, use or
.\" other dealings in this Software without prior written authorization
.\" from the X Consortium.
.\"
.\" X Window System is a trademark of X Consortium, Inc.
.\"
.\" Originally written by Edward Moy, University of California,
.\" Berkeley, edmoy@violet.berkeley.edu, for the X.V10R4 xterm.
.\" The X Consortium staff has since updated it for X11.
.\" Updated by Thomas E. Dickey for XFree86 3.2 - XFree86 4.3, and afterward.
.\"
.\" Run this file through troff and use the -ms macro package.
.\"
.ds XT XTerm
.ds xt xterm
.ds LF Patch #329
.ds RF 2017/06/11
.\"
.if n .pl 9999v		\" no page breaks in nroff
.ND
.\" Start a list of controls
.de St
.sp
.nr PD 0
.nr PI 1.0i
.nr VS 16
..
.\" End a list of controls
.de Ed
.nr PD .3v
.nr VS 12
..
.\" Bulleted paragraph
.de bP
.IP \(bu 0.2i
..
.\" Normal leading paragraph
.de lP
.if n .sp
.LP
..
.\" Normal internal paragraph
.de sP
.if n .sp
.if t .sp 0.5
..
.\" Section header
.de Sh
.ds RH \\$1
.br
.SH
\\$1
..
.\" Subsection header
.de Ss
.LP
.B
\\$*
.br
..
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds AQ \(aq
.el       .ds AQ '
.ie \n(.g .ds `` \(lq
.el       .ds `` ``
.ie \n(.g .ds '' \(rq
.el       .ds '' ''
.ds CH \" as nothing
.ds LH \*(XT Control Sequences
.nr s 6*\n(PS/10
.ds L \s\nsBEL\s0
.ds E \s\nsESC\s0
.ds T \s\nsTAB\s0
.ds X \s\nsETX\s0
.ds N \s\nsENQ\s0
.ds ET \s\nsETB\s0
.ds C \s\nsCAN\s0
.ds S \s\nsSUB\s0
.\" space between chars
.ie t .ds s \|
.el .ds s " \"
.nr [W \w'\*L'u
.nr w \w'\*E'u
.if \nw>\n([W .nr [W \nw
.nr w \w'\*T'u
.if \nw>\n([W .nr [W \nw
.nr w \w'\*X'u
.if \nw>\n([W .nr [W \nw
.nr w \w'\*N'u
.if \nw>\n([W .nr [W \nw
.nr w \w'\*(ET'u
.if \nw>\n([W .nr [W \nw
.nr w \w'\*C'u
.if \nw>\n([W .nr [W \nw
.nr w \w'\*S'u
.if \nw>\n([W .nr [W \nw
.nr [W +\w'\|\|'u
.de []
.nr w \w'\\$2'
.nr H \\n([Wu-\\nwu
.nr h \\nHu/2u
.\" do fancy box in troff
.ie t .ds \\$1 \(br\v'-1p'\(br\v'1p'\h'\\nhu'\\$2\h'\\nHu-\\nhu'\(br\l'-\\n([Wu\(ul'\v'-1p'\(br\l'-\\n([Wu\(rn'\v'1p'\*s
.el .ds \\$1 \\$2\*s
..
.[] Et \v'-1p'\*X\v'1p'
.[] En \v'-1p'\*N\v'1p'
.[] Be \v'-1p'\*L\v'1p'
.[] AP \v'-1p'\s\nsAPC\s0\v'1p'
.[] Bs \v'-1p'\s\nsBS\s0\v'1p'
.[] Cs \v'-1p'\s\nsCSI\s0\v'1p'
.[] S2 \v'-1p'\s\nsSS2\s0\v'1p'
.[] S3 \v'-1p'\s\nsSS3\s0\v'1p'
.[] SS \v'-1p'\s\nsSOS\s0\v'1p'
.[] Eg \v'-1p'\s\nsEPA\s0\v'1p'
.[] Sg \v'-1p'\s\nsSPA\s0\v'1p'
.[] Dc \v'-1p'\s\nsDCS\s0\v'1p'
.[] Ht \v'-1p'\s\nsHTS\s0\v'1p'
.[] Id \v'-1p'\s\nsIND\s0\v'1p'
.[] Nl \v'-1p'\s\nsNEL\s0\v'1p'
.[] Os \v'-1p'\s\nsOSC\s0\v'1p'
.[] RI \v'-1p'\s\nsRI\s0\v'1p'
.[] PM \v'-1p'\s\nsPM\s0\v'1p'
.[] ST \v'-1p'\s\nsST\s0\v'1p'
.[] Ta \v'-1p'\*T\v'1p'
.[] Lf \v'-1p'\s\nsLF\s0\v'1p'
.[] Vt \v'-1p'\s\nsVT\s0\v'1p'
.[] Ff \v'-1p'\s\nsFF\s0\v'1p'
.[] Cr \v'-1p'\s\nsCR\s0\v'1p'
.[] So \v'-1p'\s\nsSO\s0\v'1p'
.[] Sp \v'-1p'\s\nsSP\s0\v'1p'
.[] Si \v'-1p'\s\nsSI\s0\v'1p'
.[] Eb \v'-1p'\*(ET\v'1p'
.[] Ca \v'-1p'\*C\v'1p'
.[] Su \v'-1p'\*S\v'1p'
.[] Es \v'-1p'\*E\v'1p'
.[] Fs \v'-1p'\s\nsFS\s0\v'1p'
.[] Gs \v'-1p'\s\nsGS\s0\v'1p'
.[] Rs \v'-1p'\s\nsRS\s0\v'1p'
.[] Us \v'-1p'\s\nsUS\s0\v'1p'
.[] XX \v'-1p'\s\nsXX\s0\v'1p'
.[] $ $
.[] # #
.[] % %
.[] (( (
.[] ) )
.[] * *
.[] + +
.[] , ,
.[] - -
.[] . .
.[] 0 0
.[] 1 1
.[] 2 2
.[] 3 3
.[] 4 4
.[] 5 5
.[] 6 6
.[] 7 7
.[] 8 8
.[] 9 9
.[] : :
.[] ; ;
.[] = =
.[] / /
.[] < <
.[] > >
.[] ? ?
.[] @ @
.[] A A
.[] cB B
.[] C C
.[] D D
.[] E E
.[] F F
.[] G G
.[] H H
.[] I I
.[] J J
.[] K K
.[] L L
.[] M M
.[] N N
.[] O O
.[] P P
.[] Q Q
.[] R R
.[] S S
.[] T T
.[] V V
.[] W W
.[] XX X
.[] Y Y
.[] Z Z
.[] [[ [
.[] ]] ]
.[] bS \\e
.[] { {
.[] ~ ~
.[] ] ]
.[] & &
.[] ^ ^
.[] _ _
.[] qu \&'
.[] ` \`
.[] a a
.[] b b
.[] c c
.[] d d
.[] e e
.[] f f
.[] g g
.[] h h
.[] i i
.[] j j
.[] k k
.[] l l
.[] m m
.[] n n
.[] o o
.[] p p
.[] q q
.[] r r
.[] cs s
.[] t t
.[] u u
.[] v v
.[] w w
.[] x x
.[] y y
.[] z z
.[] | |
.[] } }
.[] ! !
.[] c" \(lq
.[] c~ ~
.[] Sc \fIc\fP
.ds Cc \fIC\fP
.ds Cb \fIC\v'.3m'\h'-.2m'\s-2b\s0\v'-.3m'\fP
.ds Cx \fIC\v'.3m'\h'-.2m'\s-2x\s0\v'-.3m'\fP
.ds Cy \fIC\v'.3m'\h'-.2m'\s-2y\s0\v'-.3m'\fP
.ds Pa \fIP\v'.3m'\h'-.2m'\s-2a\s0\v'-.3m'\fP
.ds Pb \fIP\v'.3m'\h'-.2m'\s-2b\s0\v'-.3m'\fP
.ds Pc \fIP\v'.3m'\h'-.2m'\s-2c\s0\v'-.3m'\fP
.ds Pd \fIP\v'.3m'\h'-.2m'\s-2d\s0\v'-.3m'\fP
.ds Pe \fIP\v'.3m'\h'-.2m'\s-2e\s0\v'-.3m'\fP
.ds Pg \fIP\v'.3m'\h'-.2m'\s-2g\s0\v'-.3m'\fP
.ds Ph \fIP\v'.3m'\h'-.2m'\s-2h\s0\v'-.3m'\fP
.ds Pi \fIP\v'.3m'\h'-.2m'\s-2i\s0\v'-.3m'\fP
.ds Pl \fIP\v'.3m'\h'-.2m'\s-2l\s0\v'-.3m'\fP
.ds Pm \fIP\v'.3m'\h'-.2m'\s-2m\s0\v'-.3m'\fP
.ds Pn \fIP\v'.3m'\h'-.2m'\s-2n\s0\v'-.3m'\fP
.ds Pp \fIP\v'.3m'\h'-.2m'\s-2p\s0\v'-.3m'\fP
.ds Pr \fIP\v'.3m'\h'-.2m'\s-2r\s0\v'-.3m'\fP
.ds Ps \fIP\v'.3m'\h'-.2m'\s-2s\s0\v'-.3m'\fP
.ds Pt \fIP\v'.3m'\h'-.2m'\s-2t\s0\v'-.3m'\fP
.ds Pu \fIP\v'.3m'\h'-.2m'\s-2u\s0\v'-.3m'\fP
.ds Pv \fIP\v'.3m'\h'-.2m'\s-2v\s0\v'-.3m'\fP
.ds Ix \fIx\fP
.ds Iy \fIy\fP
.ds Iw \fIw\fP
.ds Ih \fIh\fP
.ds Ir \fIr\fP
.ds Ic \fIc\fP
.ie t .nr LL 6.5i
.el .nr LL 72m
.if n .na
.TL
\*(XT Control Sequences
.AU
Edward Moy
.AI
University of California, Berkeley
.sp
Revised by
.AU
Stephen Gildea
.AI
X Consortium (1994)
.AU
Thomas Dickey
.AI
XFree86 Project (1996-2006)
invisible-island.net (2006-2017)
updated for \*(XT \*(LF (\*(RF)
.AU
.
.am BT                  \" add page numbers after first page
.ds CF %
..
.Sh "Definitions"
.IP \*(Sc
The literal character \fIc\fP.
.IP \*(Cc
A single (required) character.
.IP \*(Ps
A single (usually optional) numeric parameter, composed of one of more digits.
.IP \*(Pm
A multiple numeric parameter composed of any number of single numeric
parameters, separated by \*; character(s).
Individual values for the parameters are listed with \*(Ps .
.IP \*(Pt
A text parameter composed of printable characters.
.
.Sh "Control Bytes, Characters, and Sequences"
.LP
ECMA-48 (aka "ISO 6429") documents C1 (8-bit) and C0 (7-bit) codes.
Those are respectively codes 128 to 159 and 0 to 31.
ECMA-48 avoids referring to these codes as characters,
because that term is associated with \fIgraphic characters\fP.
Instead, it uses \*(``bytes\*('' and \*(``codes\*('',
with occasional lapses to \*(``characters\*(''
where the meaning cannot be mistaken.
.LP
Controls (including the escape code 27) are processed once:
.bP
This means that a C1 control can be mistaken for badly-formed UTF-8
when the terminal runs
in UTF-8 mode because C1 controls are valid \fIcontinuation bytes\fP of
a UTF-8 encoded (multibyte) value.
.bP
It is not possible to use a C1 control obtained from decoding the UTF-8 text,
because that would require reprocessing the data.
Consequently there is no ambiguity in the way
this document uses the term \*(``character\*('' to refer to
bytes in a control sequence.
.LP
The order of processing is a necessary consequence of the way ECMA-48
is designed:
.bP
Each byte sent to the terminal can be unambiguously determined to
fall into one of a few categories (C0, C1 and graphic characters).
.bP
ECMA-48 is \fImodal\fP; once it starts processing a control sequence,
the terminal continues until the sequence is complete,
or some byte is found which is not allowed in the sequence.
.bP
Intermediate, parameter and final bytes may
use the same codes as graphic characters,
but they are processed as part of a control sequence and are not actually
graphic characters.
.bP
Eight-bit controls can have intermediate, etc., bytes in the range 160 to 255.
Those can be treated as their counterparts in the range 32 to 127.
.bP
Single-byte controls can be handled separately from multi-byte
control sequences because ECMA-48's rules are unambiguous.
.IP
As a special case, ECMA-48 (section 9) mentions that the control functions
shift-in and shift-out are allowed to occur within a 7-bit multibyte control
sequence because those cannot alter the meaning of the control sequence.
.bP
Some controls (such as \*(Os) introduce a string mode,
which is ended on a \*(ST (string terminator).
.IP
Again, the terminal should accept single-byte controls within the string.
However, \fIxterm\fP has a resource setting \fBbrokenLinuxOSC\fP to allow
recovery from applications which rely upon malformed palette sequences
used by the Linux console.
.
.Sh "C1 (8-Bit) Control Characters"
.LP
The \fIxterm\fP program recognizes both 8-bit and 7-bit control characters.
It generates 7-bit controls (by default) or 8-bit if S8C1T is enabled.
The following pairs of 7-bit and 8-bit control characters are equivalent:
.St
.IP \\*(Es\\*D
Index (\*(Id is 0x84).
.IP \\*(Es\\*E
Next Line (\*(Nl is 0x85).
.IP \\*(Es\\*H
Tab Set (\*(Ht is 0x88).
.IP \\*(Es\\*M
Reverse Index (\*(RI is 0x8d).
.IP \\*(Es\\*N
Single Shift Select of G2 Character Set (\*(S2 is 0x8e).  This affects next character only.
.IP \\*(Es\\*O
Single Shift Select of G3 Character Set (\*(S3 is 0x8f).  This affects next character only.
.IP \\*(Es\\*P
Device Control String (\*(Dc is 0x90).
.IP \\*(Es\\*V
Start of Guarded Area (\*(Sg is 0x96).
.IP \\*(Es\\*W
End of Guarded Area (\*(Eg is 0x97).
.IP \\*(Es\\*(XX
Start of String (\*(SS is 0x98).
.IP \\*(Es\\*Z
Return Terminal ID (DECID is 0x9a).
Obsolete form of \*(Cs\*c (DA).
.IP \\*(Es\\*([[
Control Sequence Introducer (\*(Cs is 0x9b).
.IP \\*(Es\\*(bS
String Terminator (\*(ST is 0x9c).
.IP \\*(Es\\*(]]
Operating System Command (\*(Os is 0x9d).
.IP \\*(Es\\*^
Privacy Message (\*(PM is 0x9e).
.IP \\*(Es\\*_
Application Program Command (\*(AP is 0x9f).
.Ed
.sp
.LP
These control characters are used in the vtXXX emulation.
.
.Sh "VT100 Mode"
.LP
Most of these control sequences are standard VT102 control sequences,
but there is support for later DEC VT terminals
(i.e., VT220, VT320, VT420, VT510),
as well as ISO 6429 and \fIaixterm\fP color controls.
The only VT102 feature not supported is auto-repeat,
since the only way X provides for this will affect all windows.
.LP
There are additional control sequences to provide
\fIxterm-\fPdependent functions, such as the scrollbar or window size.
Where the function is specified by DEC or ISO 6429, the code assigned
to it is given in parentheses.
.LP
The escape codes to designate and invoke
character sets are specified by ISO 2022 (see that document for a
discussion of character sets).
.LP
Many of the features are optional;
\fI\*(xt\fP can be configured and built without support for them.
.
.St
.\"
.Ss Single-character functions
.\"
.IP \\*(Be
Bell (Ctrl-G).
.
.IP \\*(Bs
Backspace (Ctrl-H).
.
.IP \\*(Cr
Carriage Return (Ctrl-M).
.
.IP \\*(En
Return Terminal Status (Ctrl-E).
Default response is an empty string, but may be overridden
by a resource \fBanswerbackString\fP.
.
.IP \\*(Ff
Form Feed or New Page (NP).
(\*(Ff is Ctrl-L).
\*(Ff is treated the same as \*(Lf.
.
.IP \\*(Lf
Line Feed or New Line (NL).
(\*(Lf is Ctrl-J).
.
.IP \\*(Si
Shift In (Ctrl-O) \(-> Switch to Standard Character Set.  This invokes the
G0 character set (the default).
.
.IP \\*(So
Shift Out (Ctrl-N) \(-> Switch to Alternate Character Set.  This invokes the
G1 character set.
.
.IP \\*(Sp
Space.
.
.IP \\*(Ta
Horizontal Tab (HT) (Ctrl-I).
.
.IP \\*(Vt
Vertical Tab (Ctrl-K).  This is treated the same as LF.
.Ed
.\"
.\"
.\"
.St
.Ss Controls beginning with \*(Es
.LP
This excludes controls where \*(Es is part of a 7-bit equivalent to 8-bit C1 controls, ordered by the final character(s).
.\"
.IP \\*(Es\\*(Sp\\*F
7-bit controls (S7C1T).
.
.IP \\*(Es\\*(Sp\\*G
8-bit controls (S8C1T).
.
.IP \\*(Es\\*(Sp\\*L
Set ANSI conformance level 1 (dpANS X3.134.1).
.
.IP \\*(Es\\*(Sp\\*M
Set ANSI conformance level 2 (dpANS X3.134.1).
.
.IP \\*(Es\\*(Sp\\*N
Set ANSI conformance level 3 (dpANS X3.134.1).
.
.IP \\*(Es\\*#\\*3
DEC double-height line, top half (DECDHL).
.
.IP \\*(Es\\*#\\*4
DEC double-height line, bottom half (DECDHL).
.
.IP \\*(Es\\*#\\*5
DEC single-width line (DECSWL).
.
.IP \\*(Es\\*#\\*6
DEC double-width line (DECDWL).
.
.IP \\*(Es\\*#\\*8
DEC Screen Alignment Test (DECALN).
.
.IP \\*(Es\\*%\\*@
Select default character set.  That is ISO 8859-1 (ISO 2022).
.
.IP \\*(Es\\*%\\*G
Select UTF-8 character set (ISO 2022).
.
.IP \\*(Es\\*(((\\*(Cc
Designate G0 Character Set (ISO 2022, VT100).
.br
Final character \*(Cc for designating 94-character sets.
In this list, \*0, \*A and \*(cB apply to VT100 and up, the remainder to VT220 and up.
The VT220 character sets, together with the Portuguese character set are activated by
the National Replacement Character controls.  The \*A is a special case, since it is
also activated by the VT300-control for British Latin-1 separately from the National
Replacement Character controls.
  \*(Cc = \*0 \(-> DEC Special Character and Line Drawing Set.
  \*(Cc = \*< \(-> DEC Supplementary (VT200).
  \*(Cc = \*%\*5 \(-> DEC Supplementary Graphics (VT300).
  \*(Cc = \*> \(-> DEC Technical (VT300).
  \*(Cc = \*A \(-> United Kingdom (UK).
  \*(Cc = \*(cB \(-> United States (USASCII).
  \*(Cc = \*4 \(-> Dutch.
  \*(Cc = \*C or \*5 \(-> Finnish.
  \*(Cc = \*R or \*f \(-> French.
  \*(Cc = \*Q or \*9 \(-> French Canadian (VT200, VT300).
  \*(Cc = \*K \(-> German.
  \*(Cc = \*Y \(-> Italian.
  \*(Cc = \*`, \*E or \*6 \(-> Norwegian/Danish.
  \*(Cc = \*%\*6 \(-> Portuguese (VT300).
  \*(Cc = \*Z \(-> Spanish.
  \*(Cc = \*H or \*7 \(-> Swedish.
  \*(Cc = \*= \(-> Swiss.
.\" VT3xx and VT5xx (see vttest) add more selections, not implemented here.
.IP \\*(Es\\*)\\*(Cc
Designate G1 Character Set (ISO 2022, VT100).
.br
The same character sets apply as for \*(Es\*(((\*(Cc.
.
.IP \\*(Es\\**\\*(Cc
Designate G2 Character Set (ISO 2022, VT220).
.br
The same character sets apply as for \*(Es\*(((\*(Cc.
.
.IP \\*(Es\\*+\\*(Cc
Designate G3 Character Set (ISO 2022, VT220).
.br
The same character sets apply as for \*(Es\*(((\*(Cc.
.
.IP \\*(Es\\*-\\*(Cc
Designate G1 Character Set (VT300).
.br
The same character sets apply as for \*(Es\*(((\*(Cc.
.
.IP \\*(Es\\*.\\*(Cc
Designate G2 Character Set (VT300).
.br
The same character sets apply as for \*(Es\*(((\*(Cc.
.
.IP \\*(Es\\*/\\*(Cc
Designate G3 Character Set (VT300).
.br
These work for 96-character sets only.
  \*(Cc = \*A \(-> ISO Latin-1 Supplemental.
.\" VT5xx would implement these:
.\"  \*(Cc = \*F \(-> ISO Greek Supplemental
.\"  \*(Cc = \*H \(-> ISO Hebrew Supplemental
.\"  \*(Cc = \*M \(-> ISO Latin-5 Supplemental
.\"  \*(Cc = \*L \(-> ISO Latin-Cyrillic
.
.IP \\*(Es\\*6
Back Index (DECBI), VT420 and up.
.
.IP \\*(Es\\*7
Save Cursor (DECSC).
.
.IP \\*(Es\\*8
Restore Cursor (DECRC).
.
.IP \\*(Es\\*9
Forward Index (DECFI), VT420 and up.
.
.IP \\*(Es\\*=
Application Keypad (DECKPAM).
.
.IP \\*(Es\\*>
Normal Keypad (DECKPNM).
.
.IP \\*(Es\\*F
Cursor to lower left corner of screen.  This is
enabled by the \fBhpLowerleftBugCompat\fP resource.
.
.IP \\*(Es\\*c
Full Reset (RIS).
.
.IP \\*(Es\\*l
Memory Lock (per HP terminals).
Locks memory above the cursor.
.
.IP \\*(Es\\*m
Memory Unlock (per HP terminals).
.
.IP \\*(Es\\*n
Invoke the G2 Character Set as GL (LS2).
.
.IP \\*(Es\\*o
Invoke the G3 Character Set as GL (LS3).
.
.IP \\*(Es\\*|
Invoke the G3 Character Set as GR (LS3R).
.
.IP \\*(Es\\*}
Invoke the G2 Character Set as GR (LS2R).
.
.IP \\*(Es\\*(c~
Invoke the G1 Character Set as GR (LS1R).
.Ed
.
.St
.Ss Application Program-Command functions
.IP \\*(AP\\*(Pt\\*s\\*(ST
None.  \fIxterm\fP implements no \*(AP functions; \*(Pt is ignored.
\*(Pt need not be printable characters.
.Ed
.
.St
.Ss Device-Control functions
.IP \\*(Dc\\*(Ps\\*;\\*(Ps\\*|\\*(Pt\\*s\\*(ST
User-Defined Keys (DECUDK).
The first parameter:
  \*(Ps = \*0 \(-> Clear all UDK definitions before starting (default).
  \*(Ps = \*1 \(-> Erase Below (default).
.br
The second parameter:
  \*(Ps = \*0 \(<- Lock the keys (default).
  \*(Ps = \*1 \(<- Do not lock.
.br
The third parameter is a ';'-separated list of strings denoting
the key-code separated by a '/' from the hex-encoded key value.
The key codes correspond to the DEC function-key codes (e.g., F6=17).
.
.IP \\*(Dc\\*$\\*q\\*(Pt\\*s\\*(ST
Request Status String (DECRQSS).
The string following the "q" is one of the following:
  \*(c"\*q	\(-> DECSCA
  \*(c"\*p	\(-> DECSCL
  \*r		\(-> DECSTBM
  \*(cs		\(-> DECSLRM
  \*m		\(-> SGR
  \*(Sp\*q	\(-> DECSCUSR
.br
\fIxterm\fP responds with
\*(Dc\*1\*$\*r\*(Pt\*s\*(ST
for valid requests, replacing the \*(Pt with the corresponding \*(Cs
string,
or
\*(Dc\*0\*$\*r\*(Pt\*s\*(ST
for invalid requests.
.
.IP \\*(Dc\\*+\\*p\\*(Pt\\*s\\*(ST
Set Termcap/Terminfo Data (xterm, experimental).
The string following the "p" is a name to use for retrieving data from
the terminal database.
The data will be used for the "tcap" keyboard
configuration's function- and special-keys, as well as by the
Request Termcap/Terminfo String control.
.
.IP \\*(Dc\\*+\\*q\\*(Pt\\*s\\*(ST
Request Termcap/Terminfo String (xterm, experimental).
The string following the "q" is a list of names
encoded in hexadecimal (2 digits per character)
separated by \*;
which correspond to termcap or terminfo key names.
.br
Two special features are also recognized, which are not key names:
\fICo\fP for termcap colors (or \fIcolors\fP for terminfo colors),
and
\fITN\fP for termcap name (or \fIname\fP for terminfo name).
.br
\fIxterm\fP responds with
\*(Dc\*1\*+\*r\*(Pt\*s\*(ST
for valid requests, adding to \*(Pt an \*=,
and the value of the corresponding string that \fI\*(xt\fP would send,
or
\*(Dc\*0\*+\*r\*(Pt\*s\*(ST
for invalid requests.
The strings are encoded in hexadecimal (2 digits per character).
.Ed
.\"
.St
.Ss Functions using \*(Cs, ordered by the final character(s)
.IP \\*(Cs\\*(Ps\\*s\\*@
Insert \*(Ps (Blank) Character(s) (default = 1) (ICH).
.
.IP \\*(Cs\\*(Ps\\*s\\*A
Cursor Up \*(Ps Times (default = 1) (CUU).
.
.IP \\*(Cs\\*(Ps\\*s\\*(cB
Cursor Down \*(Ps Times (default = 1) (CUD).
.
.IP \\*(Cs\\*(Ps\\*s\\*C
Cursor Forward \*(Ps Times (default = 1) (CUF).
.
.IP \\*(Cs\\*(Ps\\*s\\*D
Cursor Backward \*(Ps Times (default = 1) (CUB).
.
.IP \\*(Cs\\*(Ps\\*s\\*E
Cursor Next Line \*(Ps Times (default = 1) (CNL).
.
.IP \\*(Cs\\*(Ps\\*s\\*F
Cursor Preceding Line \*(Ps Times (default = 1) (CPL).
.
.IP \\*(Cs\\*(Ps\\*s\\*G
Cursor Character Absolute  [column] (default = [row,1]) (CHA).
.
.IP \\*(Cs\\*(Ps\\*s\\*;\\*(Ps\\*s\\*H
Cursor Position [row;column] (default = [1,1]) (CUP).
.
.IP \\*(Cs\\*(Ps\\*s\\*I
Cursor Forward Tabulation \*(Ps tab stops (default = 1) (CHT).
.
.IP \\*(Cs\\*(Ps\\*s\\*J
Erase in Display (ED).
  \*(Ps = \*0 \(-> Erase Below (default).
  \*(Ps = \*1 \(-> Erase Above.
  \*(Ps = \*2 \(-> Erase All.
  \*(Ps = \*3 \(-> Erase Saved Lines (xterm).
.
.IP \\*(Cs\\*?\\*(Ps\\*s\\*J
Erase in Display (DECSED).
  \*(Ps = \*0 \(-> Selective Erase Below (default).
  \*(Ps = \*1 \(-> Selective Erase Above.
  \*(Ps = \*2 \(-> Selective Erase All.
  \*(Ps = \*3 \(-> Selective Erase Saved Lines (xterm).
.
.IP \\*(Cs\\*(Ps\\*s\\*K
Erase in Line (EL).
  \*(Ps = \*0 \(-> Erase to Right (default).
  \*(Ps = \*1 \(-> Erase to Left.
  \*(Ps = \*2 \(-> Erase All.
.
.IP \\*(Cs\\*?\\*(Ps\\*s\\*K
Erase in Line (DECSEL).
  \*(Ps = \*0 \(-> Selective Erase to Right (default).
  \*(Ps = \*1 \(-> Selective Erase to Left.
  \*(Ps = \*2 \(-> Selective Erase All.
.
.IP \\*(Cs\\*(Ps\\*s\\*L
Insert \*(Ps Line(s) (default = 1) (IL).
.
.IP \\*(Cs\\*(Ps\\*s\\*M
Delete \*(Ps Line(s) (default = 1) (DL).
.
.IP \\*(Cs\\*(Ps\\*s\\*P
Delete \*(Ps Character(s) (default = 1) (DCH).
.
.IP \\*(Cs\\*(Ps\\*s\\*S
Scroll up \*(Ps lines (default = 1) (SU).
.
.IP \\*(Cs\\*?\\*(Pi\\*;\\*(Pa\\*;\\*(Pv\\*s\\*S
If configured to support either \fBSixel Graphics\fP or \fBReGIS Graphics\fP,
\fIxterm\fP accepts a three-parameter control sequence, where \*(Pi,
\*(Pa and \*(Pv are the \fIitem\fP, \fIaction\fP and \fIvalue\fP:
 
  \*(Pi = \*1 \(-> item is number of color registers.
  \*(Pi = \*2 \(-> item is Sixel graphics geometry (in pixels).
  \*(Pi = \*3 \(-> item is ReGIS graphics geometry (in pixels).

  \*(Pa = \*1 \(-> read
  \*(Pa = \*2 \(-> reset to default
  \*(Pa = \*3 \(-> set to value in \*(Pv
  \*(Pa = \*4 \(-> read the maximum allowed value

  \*(Pv can be omitted except when setting (\*(Pa == \*3).
  \*(Pv = \fIn\fP \(<- A single integer is used for color registers.
  \*(Pv = \fIwidth\fP\*;\fIheight\fP \(<- Two integers for graphics geometry.
.sp
\fI\*(xt\fP replies with a control sequence of the same form:
.ID
\*(Cs\*?\*(Pi\*;\*(Ps\*;\*(Pv\*s\*S
.DE
.br
where \*(Ps is the status:
  \*(Ps = \*0 \(-> success.
  \*(Ps = \*1 \(-> error in \*(Pi.
  \*(Ps = \*2 \(-> error in \*(Pa.
  \*(Ps = \*3 \(-> failure.
.br

On success, \*(Pv represents the value read or set.
.sp
\fBNotes\fP:
.RS
.bP
The current implementation allows reading the graphics sizes,
but disallows modifying those sizes because that is done once,
using resource-values.
.bP
Graphics geometry is not necessarily the same as "window
size" (see the dtterm window manipulation extensions). For example,
\fIxterm\fP limits the maximum graphics geometry at compile time
(1000x1000 as of version 328)
although the window size can be larger.
.bP
While resizing a window will always change the current
graphics geometry, the reverse is not true.
Setting graphics geometry does not affect the window size.
.RE
.
.IP \\*(Cs\\*(Ps\\*s\\*T
Scroll down \*(Ps lines (default = 1) (SD).
.
.IP \\*(Cs\\*(Ps\\*s\\*;\\*(Ps\\*s\\*;\\*(Ps\\*s\\*;\\*(Ps\\*s\\*;\\*(Ps\\*s\\*T
Initiate highlight mouse tracking.
Parameters are [func;startx;starty;firstrow;lastrow].
See the section \fBMouse Tracking\fP.
.
.IP \\*(Cs\\*>\\*(Ps\\*;\\*(Ps\\*s\\*T
Reset one or more features of the title modes to the default value.
Normally, "reset" disables the feature.
It is possible to disable the ability to reset features
by compiling a different default for the title modes into \fIxterm\fP.
  \*(Ps = \*0 \(-> Do not set window/icon labels using hexadecimal.
  \*(Ps = \*1 \(-> Do not query window/icon labels using hexadecimal.
  \*(Ps = \*2 \(-> Do not set window/icon labels using UTF-8.
  \*(Ps = \*3 \(-> Do not query window/icon labels using UTF-8.
(See discussion of "Title Modes").
.
.IP \\*(Cs\\*(Ps\\*s\\*(XX
Erase \*(Ps Character(s) (default = 1) (ECH).
.
.IP \\*(Cs\\*(Ps\\*s\\*Z
Cursor Backward Tabulation \*(Ps tab stops (default = 1) (CBT).
.
.IP \\*(Cs\\*(Pm\\*s\\*`
Character Position Absolute  [column] (default = [row,1]) (HPA).
.
.IP \\*(Cs\\*(Pm\\*s\\*a
Character Position Relative  [columns] (default = [row,col+1]) (HPR).
.
.IP \\*(Cs\\*(Ps\\*s\\*b
Repeat the preceding graphic character \*(Ps times (REP).
.
.IP \\*(Cs\\*(Ps\\*s\\*c
Send Device Attributes (Primary DA).
  \*(Ps = \*0 or omitted \(-> request attributes from terminal.
The response depends on the \fBdecTerminalID\fP resource setting.
  \(->\ \*(Cs\*?\*1\*;\*2\*c (\*(``VT100 with Advanced Video Option\*('')
  \(->\ \*(Cs\*?\*1\*;\*0\*c (\*(``VT101 with No Options\*('')
  \(->\ \*(Cs\*?\*6\*c (\*(``VT102\*('')
  \(->\ \*(Cs\*?\*6\*2\*;\*(Ps\*c (\*(``VT220\*('')
  \(->\ \*(Cs\*?\*6\*3\*;\*(Ps\*c (\*(``VT320\*('')
  \(->\ \*(Cs\*?\*6\*4\*;\*(Ps\*c (\*(``VT420\*('')
.br
The VT100-style response parameters do not mean anything by themselves.
VT220 (and higher) parameters do, telling the host what features the terminal supports:
  \*(Ps = \*1 \(-> 132-columns.
  \*(Ps = \*2 \(-> Printer.
  \*(Ps = \*3 \(-> ReGIS graphics.
  \*(Ps = \*4 \(-> Sixel graphics.
  \*(Ps = \*6 \(-> Selective erase.
  \*(Ps = \*8 \(-> User-defined keys.
  \*(Ps = \*9 \(-> National Replacement Character sets.
  \*(Ps = \*1\*5 \(-> Technical characters.
  \*(Ps = \*1\*8 \(-> User windows.
  \*(Ps = \*2\*1 \(-> Horizontal scrolling.
  \*(Ps = \*2\*2 \(-> ANSI color, e.g., VT525.
  \*(Ps = \*2\*9 \(-> ANSI text locator (i.e., DEC Locator mode).
.
.IP \\*(Cs\\*>\\*(Ps\\*s\\*c
Send Device Attributes (Secondary DA).
  \*(Ps = \*0 or omitted \(-> request the terminal's identification code.
The response depends on the \fBdecTerminalID\fP resource setting.
It should apply only to VT220 and up, but \fIxterm\fP extends this to VT100.
  \(-> \*(Cs\*s\*>\*(Pp\*s\*;\*(Pv\*s\*;\*(Pc\*s\*c
.br
where \*(Pp denotes the terminal type
  \*(Pp = \*0 \(-> \*(``VT100\*(''.
  \*(Pp = \*1 \(-> \*(``VT220\*(''.
  \*(Pp = \*2 \(-> \*(``VT240\*(''.
  \*(Pp = \*18 \(-> \*(``VT330\*(''.
  \*(Pp = \*19 \(-> \*(``VT340\*(''.
  \*(Pp = \*24 \(-> \*(``VT320\*(''.
  \*(Pp = \*41 \(-> \*(``VT420\*(''.
  \*(Pp = \*61 \(-> \*(``VT510\*(''.
  \*(Pp = \*64 \(-> \*(``VT520\*(''.
  \*(Pp = \*65 \(-> \*(``VT525\*(''.
.br
and \*(Pv is the firmware version (for \fIxterm\fP, this was originally
the XFree86 patch number, starting with 95).
In a DEC terminal, \*(Pc indicates the ROM cartridge
registration number and is always zero.
.
.IP \\*(Cs\\*(Pm\\*s\\*d
Line Position Absolute  [row] (default = [1,column]) (VPA).
.
.IP \\*(Cs\\*(Pm\\*s\\*e
Line Position Relative  [rows] (default = [row+1,column]) (VPR).
.
.IP \\*(Cs\\*(Ps\\*s\\*;\\*(Ps\\*s\\*f
Horizontal and Vertical Position [row;column] (default = [1,1]) (HVP).
.
.IP \\*(Cs\\*(Ps\\*s\\*g
Tab Clear (TBC).
  \*(Ps = \*0 \(-> Clear Current Column (default).
  \*(Ps = \*3 \(-> Clear All.
.
.IP \\*(Cs\\*(Pm\\*s\\*h
Set Mode (SM).
  \*(Ps = \*2 \(-> Keyboard Action Mode (AM).
  \*(Ps = \*4 \(-> Insert Mode (IRM).
  \*(Ps = \*1\*2 \(-> Send/receive (SRM).
  \*(Ps = \*2\*0 \(-> Automatic Newline (LNM).
.
.IP \\*(Cs\\*?\\*(Pm\\*s\\*h
DEC Private Mode Set (DECSET).
  \*(Ps = \*1 \(-> Application Cursor Keys (DECCKM).
  \*(Ps = \*2 \(-> Designate USASCII for character sets G0-G3 (DECANM),
and set VT100 mode.
  \*(Ps = \*3 \(-> 132 Column Mode (DECCOLM).
  \*(Ps = \*4 \(-> Smooth (Slow) Scroll (DECSCLM).
  \*(Ps = \*5 \(-> Reverse Video (DECSCNM).
  \*(Ps = \*6 \(-> Origin Mode (DECOM).
  \*(Ps = \*7 \(-> Wraparound Mode (DECAWM).
  \*(Ps = \*8 \(-> Auto-repeat Keys (DECARM).
  \*(Ps = \*9 \(-> Send Mouse X & Y on button press.
See the section \fBMouse Tracking\fP.  This is the X10 xterm mouse protocol.
  \*(Ps = \*1\*0 \(-> Show toolbar (rxvt).
  \*(Ps = \*1\*2 \(-> Start Blinking Cursor (att610).
  \*(Ps = \*1\*8 \(-> Print form feed (DECPFF).
  \*(Ps = \*1\*9 \(-> Set print extent to full screen (DECPEX).
  \*(Ps = \*2\*5 \(-> Show Cursor (DECTCEM).
  \*(Ps = \*3\*0 \(-> Show scrollbar (rxvt).
  \*(Ps = \*3\*5 \(-> Enable font-shifting functions (rxvt).
  \*(Ps = \*3\*8 \(-> Enter Tektronix Mode (DECTEK).
  \*(Ps = \*4\*0 \(-> Allow 80 \z\(<-\(-> 132 Mode.
  \*(Ps = \*4\*1 \(-> \fImore\fP(1) fix (see \fBcurses\fP resource).
  \*(Ps = \*4\*2 \(-> Enable National Replacement Character sets (DECNRCM).
  \*(Ps = \*4\*4 \(-> Turn On Margin Bell.
  \*(Ps = \*4\*5 \(-> Reverse-wraparound Mode.
  \*(Ps = \*4\*6 \(-> Start Logging.
This is normally disabled by a compile-time option.
  \*(Ps = \*4\*7 \(-> Use Alternate Screen Buffer.
(This may be disabled by the \fBtiteInhibit\fP resource).
  \*(Ps = \*6\*6 \(-> Application keypad (DECNKM).
  \*(Ps = \*6\*7 \(-> Backarrow key sends backspace (DECBKM).
  \*(Ps = \*6\*9 \(-> Enable left and right margin mode (DECLRMM), VT420 and up.
  \*(Ps = \*9\*5 \(-> Do not clear screen when DECCOLM is set/reset (DECNCSM), VT510 and up.
  \*(Ps = \*1\*0\*0\*0 \(-> Send Mouse X & Y on button press and release.
See the section \fBMouse Tracking\fP.  This is the X11 xterm mouse protocol.
  \*(Ps = \*1\*0\*0\*1 \(-> Use Hilite Mouse Tracking.
  \*(Ps = \*1\*0\*0\*2 \(-> Use Cell Motion Mouse Tracking.
  \*(Ps = \*1\*0\*0\*3 \(-> Use All Motion Mouse Tracking.
  \*(Ps = \*1\*0\*0\*4 \(-> Send FocusIn/FocusOut events.
  \*(Ps = \*1\*0\*0\*5 \(-> Enable UTF-8 Mouse Mode.
  \*(Ps = \*1\*0\*0\*6 \(-> Enable SGR Mouse Mode.
  \*(Ps = \*1\*0\*0\*7 \(-> Enable Alternate Scroll Mode, i.e., the \fBalternateScroll\fP resource.
  \*(Ps = \*1\*0\*1\*0 \(-> Scroll to bottom on tty output (rxvt).
  \*(Ps = \*1\*0\*1\*1 \(-> Scroll to bottom on key press (rxvt).
  \*(Ps = \*1\*0\*1\*5 \(-> Enable urxvt Mouse Mode.
  \*(Ps = \*1\*0\*3\*4 \(-> Interpret "meta" key, sets eighth bit.
(enables the \fBeightBitInput\fP resource).
  \*(Ps = \*1\*0\*3\*5 \(-> Enable special modifiers for Alt and NumLock keys.
(This enables the \fBnumLock\fP resource).
  \*(Ps = \*1\*0\*3\*6 \(-> Send \*(Es  when Meta modifies a key.
(This enables the \fBmetaSendsEscape\fP resource).
  \*(Ps = \*1\*0\*3\*7 \(-> Send DEL from the editing-keypad Delete key.
  \*(Ps = \*1\*0\*3\*9 \(-> Send \*(Es when Alt modifies a key.
(This enables the \fBaltSendsEscape\fP resource).
  \*(Ps = \*1\*0\*4\*0 \(-> Keep selection even if not highlighted.
(This enables the \fBkeepSelection\fP resource).
  \*(Ps = \*1\*0\*4\*1 \(-> Use the CLIPBOARD selection.
(This enables the \fBselectToClipboard\fP resource).
  \*(Ps = \*1\*0\*4\*2 \(-> Enable Urgency window manager hint when Control-G is received.
(This enables the \fBbellIsUrgent\fP resource).
  \*(Ps = \*1\*0\*4\*3 \(-> Enable raising of the window when Control-G is received.
(enables the \fBpopOnBell\fP resource).
  \*(Ps = \*1\*0\*4\*4 \(-> Reuse the most recent data copied to CLIPBOARD.
(This enables the \fBkeepClipboard\fP resource).
  \*(Ps = \*1\*0\*4\*7 \(-> Use Alternate Screen Buffer.  (This may be
disabled by the \fBtiteInhibit\fP resource).
  \*(Ps = \*1\*0\*4\*8 \(-> Save cursor as in DECSC.  (This may be
disabled by the \fBtiteInhibit\fP resource).
  \*(Ps = \*1\*0\*4\*9 \(-> Save cursor as in DECSC
and use Alternate Screen Buffer, clearing it first.  (This may be
disabled by the \fBtiteInhibit\fP resource).
This combines the effects of the \*1\*0\*4\*7 and \*1\*0\*4\*8 modes.
Use this with terminfo-based applications rather than the \*4\*7 mode.
  \*(Ps = \*1\*0\*5\*0 \(-> Set terminfo/termcap function-key mode.
  \*(Ps = \*1\*0\*5\*1 \(-> Set Sun function-key mode.
  \*(Ps = \*1\*0\*5\*2 \(-> Set HP function-key mode.
  \*(Ps = \*1\*0\*5\*3 \(-> Set SCO function-key mode.
  \*(Ps = \*1\*0\*6\*0 \(-> Set legacy keyboard emulation (X11R6).
  \*(Ps = \*1\*0\*6\*1 \(-> Set VT220 keyboard emulation.
  \*(Ps = \*2\*0\*0\*4 \(-> Set bracketed paste mode.
.
.IP \\*(Cs\\*(Pm\\*s\\*i
Media Copy (MC).
  \*(Ps = \*0 \(-> Print screen (default).
  \*(Ps = \*4 \(-> Turn off printer controller mode.
  \*(Ps = \*5 \(-> Turn on printer controller mode.
  \*(Ps = \*1 \*0 \(-> HTML screen dump.
  \*(Ps = \*1 \*1 \(-> SVG screen dump.
.
.IP \\*(Cs\\*?\\*(Pm\\*s\\*i
Media Copy (MC, DEC-specific).
  \*(Ps = \*1 \(-> Print line containing cursor.
  \*(Ps = \*4 \(-> Turn off autoprint mode.
  \*(Ps = \*5 \(-> Turn on autoprint mode.
  \*(Ps = \*1 \*0 \(-> Print composed display, ignores DECPEX.
  \*(Ps = \*1 \*1 \(-> Print all pages.
.
.IP \\*(Cs\\*(Pm\\*s\\*l
Reset Mode (RM).
  \*(Ps = \*2 \(-> Keyboard Action Mode (AM).
  \*(Ps = \*4 \(-> Replace Mode (IRM).
  \*(Ps = \*1\*2 \(-> Send/receive (SRM).
  \*(Ps = \*2\*0 \(-> Normal Linefeed (LNM).
.
.IP \\*(Cs\\*?\\*(Pm\\*s\\*l
DEC Private Mode Reset (DECRST).
  \*(Ps = \*1 \(-> Normal Cursor Keys (DECCKM).
  \*(Ps = \*2 \(-> Designate VT52 mode (DECANM).
  \*(Ps = \*3 \(-> 80 Column Mode (DECCOLM).
  \*(Ps = \*4 \(-> Jump (Fast) Scroll (DECSCLM).
  \*(Ps = \*5 \(-> Normal Video (DECSCNM).
  \*(Ps = \*6 \(-> Normal Cursor Mode (DECOM).
  \*(Ps = \*7 \(-> No Wraparound Mode (DECAWM).
  \*(Ps = \*8 \(-> No Auto-repeat Keys (DECARM).
  \*(Ps = \*9 \(-> Don't send Mouse X & Y on button press.
  \*(Ps = \*1\*0 \(-> Hide toolbar (rxvt).
  \*(Ps = \*1\*2 \(-> Stop Blinking Cursor (att610).
  \*(Ps = \*1\*8 \(-> Don't print form feed (DECPFF).
  \*(Ps = \*1\*9 \(-> Limit print to scrolling region (DECPEX).
  \*(Ps = \*2\*5 \(-> Hide Cursor (DECTCEM).
  \*(Ps = \*3\*0 \(-> Don't show scrollbar (rxvt).
  \*(Ps = \*3\*5 \(-> Disable font-shifting functions (rxvt).
  \*(Ps = \*4\*0 \(-> Disallow 80 \z\(<-\(-> 132 Mode.
  \*(Ps = \*4\*1 \(-> No \fImore\fP(1) fix (see \fBcurses\fP resource).
  \*(Ps = \*4\*2 \(-> Disable National Replacement Character sets (DECNRCM).
  \*(Ps = \*4\*4 \(-> Turn Off Margin Bell.
  \*(Ps = \*4\*5 \(-> No Reverse-wraparound Mode.
  \*(Ps = \*4\*6 \(-> Stop Logging.
(This is normally disabled by a compile-time option).
  \*(Ps = \*4\*7 \(-> Use Normal Screen Buffer.
  \*(Ps = \*6\*6 \(-> Numeric keypad (DECNKM).
  \*(Ps = \*6\*7 \(-> Backarrow key sends delete (DECBKM).
  \*(Ps = \*6\*9 \(-> Disable left and right margin mode (DECLRMM), VT420 and up.
  \*(Ps = \*9\*5 \(-> Clear screen when DECCOLM is set/reset (DECNCSM), VT510 and up.
  \*(Ps = \*1\*0\*0\*0 \(-> Don't send Mouse X & Y on button press and
release.
See the section \fBMouse Tracking\fP.
  \*(Ps = \*1\*0\*0\*1 \(-> Don't use Hilite Mouse Tracking.
  \*(Ps = \*1\*0\*0\*2 \(-> Don't use Cell Motion Mouse Tracking.
  \*(Ps = \*1\*0\*0\*3 \(-> Don't use All Motion Mouse Tracking.
  \*(Ps = \*1\*0\*0\*4 \(-> Don't send FocusIn/FocusOut events.
  \*(Ps = \*1\*0\*0\*5 \(-> Disable UTF-8 Mouse Mode.
  \*(Ps = \*1\*0\*0\*6 \(-> Disable SGR Mouse Mode.
  \*(Ps = \*1\*0\*0\*7 \(-> Disable Alternate Scroll Mode, i.e., the \fBalternateScroll\fP resource.
  \*(Ps = \*1\*0\*1\*0 \(-> Don't scroll to bottom on tty output (rxvt).
  \*(Ps = \*1\*0\*1\*1 \(-> Don't scroll to bottom on key press (rxvt).
  \*(Ps = \*1\*0\*1\*5 \(-> Disable urxvt Mouse Mode.
  \*(Ps = \*1\*0\*3\*4 \(-> Don't interpret "meta" key.
(This disables the \fBeightBitInput\fP resource).
  \*(Ps = \*1\*0\*3\*5 \(-> Disable special modifiers for Alt and NumLock keys.
(This disables the \fBnumLock\fP resource).
  \*(Ps = \*1\*0\*3\*6 \(-> Don't send \*(Es when Meta modifies a key.
(This disables the \fBmetaSendsEscape\fP resource).
  \*(Ps = \*1\*0\*3\*7 \(-> Send VT220 Remove from the editing-keypad Delete key.
  \*(Ps = \*1\*0\*3\*9 \(-> Don't send \*(Es when Alt modifies a key.
(This disables the \fBaltSendsEscape\fP resource).
  \*(Ps = \*1\*0\*4\*0 \(-> Do not keep selection when not highlighted.
(This disables the \fBkeepSelection\fP resource).
  \*(Ps = \*1\*0\*4\*1 \(-> Use the PRIMARY selection.
(This disables the \fBselectToClipboard\fP resource).
  \*(Ps = \*1\*0\*4\*2 \(-> Disable Urgency window manager hint when Control-G is received.
(This disables the \fBbellIsUrgent\fP resource).
  \*(Ps = \*1\*0\*4\*3 \(-> Disable raising of the window when Control-G is received.
(This disables the \fBpopOnBell\fP resource).
  \*(Ps = \*1\*0\*4\*7 \(-> Use Normal Screen Buffer, clearing screen
first if in the Alternate Screen.  (This may be
disabled by the \fBtiteInhibit\fP resource).
  \*(Ps = \*1\*0\*4\*8 \(-> Restore cursor as in DECRC.  (This may be
disabled by the \fBtiteInhibit\fP resource).
  \*(Ps = \*1\*0\*4\*9 \(-> Use Normal Screen Buffer and restore cursor
as in DECRC.  (This may be disabled by the \fBtiteInhibit\fP resource).
This combines the effects of the \*1\*0\*4\*7 and \*1\*0\*4\*8 modes.
Use this with terminfo-based applications rather than the \*4\*7 mode.
  \*(Ps = \*1\*0\*5\*0 \(-> Reset terminfo/termcap function-key mode.
  \*(Ps = \*1\*0\*5\*1 \(-> Reset Sun function-key mode.
  \*(Ps = \*1\*0\*5\*2 \(-> Reset HP function-key mode.
  \*(Ps = \*1\*0\*5\*3 \(-> Reset SCO function-key mode.
  \*(Ps = \*1\*0\*6\*0 \(-> Reset legacy keyboard emulation (X11R6).
  \*(Ps = \*1\*0\*6\*1 \(-> Reset keyboard emulation to Sun/PC style.
  \*(Ps = \*2\*0\*0\*4 \(-> Reset bracketed paste mode.
.
.IP \\*(Cs\\*(Pm\\*s\\*m
Character Attributes (SGR).
  \*(Ps = \*0 \(-> Normal (default).
  \*(Ps = \*1 \(-> Bold.
  \*(Ps = \*2 \(-> Faint, decreased intensity (ISO 6429).
  \*(Ps = \*3 \(-> Italicized (ISO 6429).
  \*(Ps = \*4 \(-> Underlined.
  \*(Ps = \*5 \(-> Blink (appears as Bold).
  \*(Ps = \*7 \(-> Inverse.
  \*(Ps = \*8 \(-> Invisible, i.e., hidden (VT300).
  \*(Ps = \*9 \(-> Crossed-out characters (ISO 6429).
  \*(Ps = \*2\*1 \(-> Doubly-underlined (ISO 6429).
  \*(Ps = \*2\*2 \(-> Normal (neither bold nor faint).
  \*(Ps = \*2\*3 \(-> Not italicized (ISO 6429).
  \*(Ps = \*2\*4 \(-> Not underlined.
  \*(Ps = \*2\*5 \(-> Steady (not blinking).
  \*(Ps = \*2\*7 \(-> Positive (not inverse).
  \*(Ps = \*2\*8 \(-> Visible, i.e., not hidden (VT300).
  \*(Ps = \*2\*9 \(-> Not crossed-out (ISO 6429).
  \*(Ps = \*3\*0 \(-> Set foreground color to Black.
  \*(Ps = \*3\*1 \(-> Set foreground color to Red.
  \*(Ps = \*3\*2 \(-> Set foreground color to Green.
  \*(Ps = \*3\*3 \(-> Set foreground color to Yellow.
  \*(Ps = \*3\*4 \(-> Set foreground color to Blue.
  \*(Ps = \*3\*5 \(-> Set foreground color to Magenta.
  \*(Ps = \*3\*6 \(-> Set foreground color to Cyan.
  \*(Ps = \*3\*7 \(-> Set foreground color to White.
  \*(Ps = \*3\*9 \(-> Set foreground color to default (original).
  \*(Ps = \*4\*0 \(-> Set background color to Black.
  \*(Ps = \*4\*1 \(-> Set background color to Red.
  \*(Ps = \*4\*2 \(-> Set background color to Green.
  \*(Ps = \*4\*3 \(-> Set background color to Yellow.
  \*(Ps = \*4\*4 \(-> Set background color to Blue.
  \*(Ps = \*4\*5 \(-> Set background color to Magenta.
  \*(Ps = \*4\*6 \(-> Set background color to Cyan.
  \*(Ps = \*4\*7 \(-> Set background color to White.
  \*(Ps = \*4\*9 \(-> Set background color to default (original).
.sP
If 16-color support is compiled, the following apply.
Assume that \fIxterm\fP's resources
are set so that the ISO color codes are the first 8 of a set of 16.
Then the \fIaixterm\fP colors are the bright versions of the ISO colors:
  \*(Ps = \*9\*0 \(-> Set foreground color to Black.
  \*(Ps = \*9\*1 \(-> Set foreground color to Red.
  \*(Ps = \*9\*2 \(-> Set foreground color to Green.
  \*(Ps = \*9\*3 \(-> Set foreground color to Yellow.
  \*(Ps = \*9\*4 \(-> Set foreground color to Blue.
  \*(Ps = \*9\*5 \(-> Set foreground color to Magenta.
  \*(Ps = \*9\*6 \(-> Set foreground color to Cyan.
  \*(Ps = \*9\*7 \(-> Set foreground color to White.
  \*(Ps = \*1\*0\*0 \(-> Set background color to Black.
  \*(Ps = \*1\*0\*1 \(-> Set background color to Red.
  \*(Ps = \*1\*0\*2 \(-> Set background color to Green.
  \*(Ps = \*1\*0\*3 \(-> Set background color to Yellow.
  \*(Ps = \*1\*0\*4 \(-> Set background color to Blue.
  \*(Ps = \*1\*0\*5 \(-> Set background color to Magenta.
  \*(Ps = \*1\*0\*6 \(-> Set background color to Cyan.
  \*(Ps = \*1\*0\*7 \(-> Set background color to White.
.sP
If \fIxterm\fP is compiled with the 16-color support disabled, it supports
the following, from \fIrxvt\fP:
  \*(Ps = \*1\*0\*0 \(-> Set foreground and background color to default.
.sP
\fIXterm\fP maintains a color palette whose entries are identified by an index beginning with zero.
If 88- or 256-color support is compiled, the following apply:
.RS
.bP
All parameters are decimal integers.
.bP
RGB values range from zero (0) to 255.
.bP
ISO-8613-3 can be interpreted in more than one way;
\fIxterm\fP allows the semicolons in this control to be replaced by colons
(but after the first colon, colons must be used).
.RE
.sP
These ISO-8613-3 controls are supported:
  \*(Pm = \*3\*8\*;\*2\*;\*(Pr\*;\*(Pg\*;\*(Pb \(-> Set foreground color to the closest match in \fIxterm\fP's palette for the given RGB \*(Pr/\*(Pg/\*(Pb.
  \*(Pm = \*3\*8\*;\*5\*;\*(Ps \(-> Set foreground color to \*(Ps.
  \*(Pm = \*4\*8\*;\*2\*;\*(Pr\*;\*(Pg\*;\*(Pb \(-> Set background color to the closest match in \fIxterm\fP's palette for the given RGB \*(Pr/\*(Pg/\*(Pb.
  \*(Pm = \*4\*8\*;\*5\*;\*(Ps \(-> Set background color to \*(Ps.
.sp
.
.IP \\*(Cs\\*>\\*(Ps\\*;\\*(Ps\\*s\\*m
Set or reset resource-values used by \fIxterm\fP to decide whether to
construct escape sequences holding information about the modifiers
pressed with a given key.
The first parameter identifies the resource to set/reset.
The second parameter is the value to assign to the resource.
If the second parameter is omitted, the resource is reset to its initial value.
  \*(Ps = \*0 \(-> modifyKeyboard.
  \*(Ps = \*1 \(-> modifyCursorKeys.
  \*(Ps = \*2 \(-> modifyFunctionKeys.
  \*(Ps = \*4 \(-> modifyOtherKeys.
.br
If no parameters are given, all resources are reset to their initial values.
.
.IP \\*(Cs\\*(Ps\\*s\\*n
Device Status Report (DSR).
  \*(Ps = \*5 \(-> Status Report.
.br
Result (\*(``OK\*('') is
\*(Cs\*0\*n
  \*(Ps = \*6 \(-> Report Cursor Position (CPR) [row;column].
.br
Result is
\*(Cs\*(Ir\*s\*;\*(Ic\*s\*R
.sp
\fBNote\fP:
it is possible for this sequence to be sent by a function key.
For example, with the default keyboard configuration
the shifted F1 key may send (with shift-, control-, alt-modifiers)
.br
  \*(Cs\*1\*s\*;\*2\*s\*R, or
  \*(Cs\*1\*s\*;\*5\*s\*R, or
  \*(Cs\*1\*s\*;\*6\*s\*R, etc.
.br
The second parameter encodes the modifiers; values range from 2 to 16.
See the section \fBPC-Style Function Keys\fP for the codes.
The \fBmodifyFunctionKeys\fP and \fBmodifyKeyboard\fP resources
can change the form of the string sent from the modified F1 key.
.sp
.
.IP \\*(Cs\\*>\\*(Ps\\*s\\*n
Disable modifiers which may be enabled via the
\*(Cs\*>\*(Ps\*;\*(Ps\*s\*m
sequence.
This corresponds to a resource value of "-1", which cannot be set with
the other sequence.
The parameter identifies the resource to be disabled:
  \*(Ps = \*0 \(-> modifyKeyboard.
  \*(Ps = \*1 \(-> modifyCursorKeys.
  \*(Ps = \*2 \(-> modifyFunctionKeys.
  \*(Ps = \*4 \(-> modifyOtherKeys.
.br
If the parameter is omitted, \fBmodifyFunctionKeys\fP is disabled.
When \fBmodifyFunctionKeys\fP is disabled, \fIxterm\fP uses the
modifier keys to make an extended sequence of functions rather
than adding a parameter to each function key to denote the modifiers.
.
.IP \\*(Cs\\*?\\*(Ps\\*s\\*n
Device Status Report (DSR, DEC-specific).
  \*(Ps = \*6 \(-> Report Cursor Position (DECXCPR) [row;column] as
\*(Cs\*?\*(Ir\*s\*;\*(Ic\*s\*R
(assumes the default page, i.e., "1").
  \*(Ps = \*1\*5 \(-> Report Printer status as
\*(Cs\*?\*1\*0\*n (ready).
or
\*(Cs\*?\*1\*1\*n (not ready).
  \*(Ps = \*2\*5 \(-> Report UDK status as
\*(Cs\*?\*2\*0\*n (unlocked)
or
\*(Cs\*?\*2\*1\*n (locked).
  \*(Ps = \*2\*6 \(-> Report Keyboard status as
.br
\*(Cs\*?\*2\*7\*;\*1\*;\*0\*;\*0\*n (North American).
.br
The last two parameters apply to VT400 & up, and denote keyboard ready and LK01 respectively.
  \*(Ps = \*5\*3 \(-> Report Locator status as
\*(Cs\*?\*5\*3\*n Locator available, if compiled-in, or
\*(Cs\*?\*5\*0\*n No Locator, if not.
  \*(Ps = \*5\*5 \(-> Report Locator status as
\*(Cs\*?\*5\*3\*n Locator available, if compiled-in, or
\*(Cs\*?\*5\*0\*n No Locator, if not.
  \*(Ps = \*5\*6 \(-> Report Locator type as
\*(Cs\*?\*5\*7\*;\*1\*n Mouse, if compiled-in, or
\*(Cs\*?\*5\*7\*;\*0\*n Cannot identify, if not.
  \*(Ps = \*6\*2 \(-> Report macro space (DECMSR) as
\*(Cs\*(Pn\*s\\*\*s\*{.
  \*(Ps = \*6\*3 \(-> Report memory checksum (DECCKSR) as
\*(Dc\*(Pt\*s\*!x\*sx\*sx\*sx\*s\*(ST.
.br
    \*(Pt is the request id (from an optional parameter to the request).
    The x's are hexadecimal digits 0-9 and A-F.
  \*(Ps = \*7\*5 \(-> Report data integrity as
\*(Cs\*?\*7\*0\*n (ready, no errors).
  \*(Ps = \*8\*5 \(-> Report multi-session configuration as
\*(Cs\*?\*8\*3\*n (not configured for multiple-session operation).
.
.IP \\*(Cs\\*>\\*(Ps\\*s\\*p
Set resource value \fIpointerMode\fP.
This is used by \fIxterm\fP to decide whether to
hide the pointer cursor as the user types.
Valid values for the parameter:
  \*(Ps = \*0 \(-> never hide the pointer.
  \*(Ps = \*1 \(-> hide if the mouse tracking mode is not enabled.
  \*(Ps = \*2 \(-> always hide the pointer, except when leaving the window.
  \*(Ps = \*3 \(-> always hide the pointer, even if leaving/entering the window.
If no parameter is given, \fIxterm\fP uses the default,
which is \*1.
.
.IP \\*(Cs\\*!\\*p
Soft terminal reset (DECSTR).
.
.IP \\*(Cs\\*(Ps\\*s\\*;\\*(Ps\\*s\\*(c"\\*p
Set conformance level (DECSCL).
Valid values for the first parameter:
  \*(Ps = \*6\*1 \(-> VT100.
  \*(Ps = \*6\*2 \(-> VT200.
  \*(Ps = \*6\*3 \(-> VT300.
.br
Valid values for the second parameter:
  \*(Ps = \*0 \(-> 8-bit controls.
  \*(Ps = \*1 \(-> 7-bit controls (always set for VT100).
  \*(Ps = \*2 \(-> 8-bit controls.
.
.IP \\*(Cs\\*(Ps\\*s\\*$\\*p
.br
Request ANSI mode (DECRQM).
For VT300 and up, reply is
.br
  \*(Cs\*(Ps\*;\*(Pm\*$\*y
.br
where \*(Ps is the mode number as in RM,
and \*(Pm is the mode value:
.br
  0 - not recognized
  1 - set
  2 - reset
  3 - permanently set
  4 - permanently reset
.
.IP \\*(Cs\\*?\\*(Ps\\*$\\*p
Request DEC private mode (DECRQM).
For VT300 and up, reply is
.br
  \*(Cs\*?\*(Ps\*;\*(Pm\*$\*y
.br
where \*(Ps is the mode number as in DECSET,
\*(Pm is the mode value as in the ANSI DECRQM.
.
.IP \\*(Cs\\*(Ps\\*s\\*q
Load LEDs (DECLL).
  \*(Ps = \*0 \(-> Clear all LEDS (default).
  \*(Ps = \*1 \(-> Light Num Lock.
  \*(Ps = \*2 \(-> Light Caps Lock.
  \*(Ps = \*3 \(-> Light Scroll Lock.
  \*(Ps = \*2 \*1 \(-> Extinguish Num Lock.
  \*(Ps = \*2 \*2 \(-> Extinguish Caps Lock.
  \*(Ps = \*2 \*3 \(-> Extinguish Scroll Lock.
.
.IP \\*(Cs\\*(Ps\\*s\\*(Sp\\*q
Set cursor style (DECSCUSR, VT520).
  \*(Ps = \*0 \(-> blinking block.
  \*(Ps = \*1 \(-> blinking block (default).
  \*(Ps = \*2 \(-> steady block.
  \*(Ps = \*3 \(-> blinking underline.
  \*(Ps = \*4 \(-> steady underline.
  \*(Ps = \*5 \(-> blinking bar (xterm).
  \*(Ps = \*6 \(-> steady bar (xterm).
.
.IP \\*(Cs\\*(Ps\\*s\\*(c"\\*q
Select character protection attribute (DECSCA).
Valid values for the parameter:
  \*(Ps = \*0 \(-> DECSED and DECSEL can erase (default).
  \*(Ps = \*1 \(-> DECSED and DECSEL cannot erase.
  \*(Ps = \*2 \(-> DECSED and DECSEL can erase.
.
.IP \\*(Cs\\*(Ps\\*s\\*;\\*(Ps\\*s\\*r
Set Scrolling Region [top;bottom] (default = full size of window) (DECSTBM).
.
.IP \\*(Cs\\*?\\*(Pm\\*s\\*r
Restore DEC Private Mode Values.
The value of \*(Ps previously saved is restored.
\*(Ps values are the same as for DECSET.
.
.IP \\*(Cs\\*(Pt\\*;\\*(Pl\\*;\\*(Pb\\*;\\*(Pr\\*;\\*(Ps\\*$\\*r
Change Attributes in Rectangular Area (DECCARA), VT400 and up.
  \*(Pt\*;\*(Pl\*;\*(Pb\*;\*(Pr denotes the rectangle.
  \*(Ps denotes the SGR attributes to change: 0, 1, 4, 5, 7.
.
.IP \\*(Cs\\*(cs
Save cursor (ANSI.SYS), available only when DECLRMM is disabled.
.
.IP \\*(Cs\\*(Pl\\*;\\*(Pr\\*s\\*(cs
Set left and right margins (DECSLRM), available only when DECLRMM is enabled (VT420 and up).
.
.IP \\*(Cs\\*?\\*(Pm\\*s\\*(cs
Save DEC Private Mode Values.
\*(Ps values are the same as for DECSET.
.
.IP \\*(Cs\\*(Ps\\*s\\*;\\*(Ps\\*s\\*;\\*(Ps\\*s\\*t
Window manipulation (from \fIdtterm\fP, as well as extensions).
These controls may be disabled using the \fIallowWindowOps\fP resource.
Valid values for the first (and any additional parameters) are:
  \*(Ps = \*1 \(-> De-iconify window.
  \*(Ps = \*2 \(-> Iconify window.
  \*(Ps = \*3\*s\*;\*s\fIx\*s\*;\*sy\fP \(-> Move window to [x, y].
  \*(Ps = \*4\*s\*;\*s\fIheight\*s\*;\*swidth\fP \(-> Resize the \fIxterm\fP window to given height and width in pixels.
Omitted parameters reuse the current height or width.
Zero parameters use the display's height or width.
  \*(Ps = \*5 \(-> Raise the \fIxterm\fP window to the front of the stacking order.
  \*(Ps = \*6 \(-> Lower the \fIxterm\fP window to the bottom of the stacking order.
  \*(Ps = \*7 \(-> Refresh the \fIxterm\fP window.
  \*(Ps = \*8\*s\*;\*s\fIheight\*s\*;\*swidth\fP \(-> Resize the text area to given height and width in characters.
Omitted parameters reuse the current height or width.
Zero parameters use the display's height or width.
  \*(Ps = \*9\*s\*;\*s\*0 \(-> Restore maximized window.
  \*(Ps = \*9\*s\*;\*s\*1 \(-> Maximize window (i.e., resize to screen size).
  \*(Ps = \*9\*s\*;\*s\*2 \(-> Maximize window vertically.
  \*(Ps = \*9\*s\*;\*s\*3 \(-> Maximize window horizontally.
  \*(Ps = \*1\*0\*s\*;\*s\*0 \(-> Undo full-screen mode.
  \*(Ps = \*1\*0\*s\*;\*s\*1 \(-> Change to full-screen.
  \*(Ps = \*1\*0\*s\*;\*s\*2 \(-> Toggle full-screen.
  \*(Ps = \*1\*1 \(-> Report \fIxterm\fP window state.
If the \fIxterm\fP window is open (non-iconified), it returns \*(Cs\*1\*t.
If the \fIxterm\fP window is iconified, it returns \*(Cs\*2\*t.
  \*(Ps = \*1\*3 \(-> Report \fIxterm\fP window position.
.br
Result is
\*(Cs\*3\*;\*(Ix\*s\*;\*(Iy\*s\*t
  \*(Ps = \*1\*4 \(-> Report \fIxterm\fP window in pixels.
.br
Result is
\*(Cs\*s\*4\*s\*;\*s\fIheight\fP\*s\*;\*s\fIwidth\fP\*s\*t
  \*(Ps = \*1\*8 \(-> Report the size of the text area in characters.
.br
Result is
\*(Cs\*s\*8\*s\*;\*s\fIheight\fP\*s\*;\*s\fIwidth\fP\*s\*t
  \*(Ps = \*1\*9 \(-> Report the size of the screen in characters.
.br
Result is
\*(Cs\*s\*9\*s\*;\*s\fIheight\fP\*s\*;\*s\fIwidth\fP\*s\*t
  \*(Ps = \*2\*0 \(-> Report \fIxterm\fP window's icon label.
.br
Result is
\*(Os\*s\*L\*s\fIlabel\fP\*s\*(ST
  \*(Ps = \*2\*1 \(-> Report \fIxterm\fP window's title.
.br
Result is
\*(Os\*s\*l\*s\fIlabel\fP\*s\*(ST
  \*(Ps = \*2\*2\*s\*;\*s\*0 \(-> Save \fIxterm\fP icon and window title on stack.
  \*(Ps = \*2\*2\*s\*;\*s\*1 \(-> Save \fIxterm\fP icon title on stack.
  \*(Ps = \*2\*2\*s\*;\*s\*2 \(-> Save \fIxterm\fP window title on stack.
  \*(Ps = \*2\*3\*s\*;\*s\*0 \(-> Restore \fIxterm\fP icon and window title from stack.
  \*(Ps = \*2\*3\*s\*;\*s\*1 \(-> Restore \fIxterm\fP icon title from stack.
  \*(Ps = \*2\*3\*s\*;\*s\*2 \(-> Restore \fIxterm\fP window title from stack.
  \*(Ps >= \*2\*4 \(-> Resize to \*(Ps lines (DECSLPP).
.
.IP \\*(Cs\\*>\\*(Ps\\*;\\*(Ps\\*s\\*t
Set one or more features of the title modes.
Each parameter enables a single feature.
  \*(Ps = \*0 \(-> Set window/icon labels using hexadecimal.
  \*(Ps = \*1 \(-> Query window/icon labels using hexadecimal.
  \*(Ps = \*2 \(-> Set window/icon labels using UTF-8.
  \*(Ps = \*3 \(-> Query window/icon labels using UTF-8.
(See discussion of "Title Modes")
.
.IP \\*(Cs\\*(Ps\\*s\\*(Sp\\*t
Set warning-bell volume (DECSWBV, VT520).
  \*(Ps = \*0 or \*1 \(-> off.
  \*(Ps = \*2, \*3 or \*4 \(-> low.
  \*(Ps = \*5, \*6, \*7, or \*8 \(-> high.
.
.IP \\*(Cs\\*(Pt\\*;\\*(Pl\\*;\\*(Pb\\*;\\*(Pr\\*;\\*(Ps\\*$\\*t
Reverse Attributes in Rectangular Area (DECRARA), VT400 and up.
  \*(Pt\*;\*(Pl\*;\*(Pb\*;\*(Pr denotes the rectangle.
  \*(Ps denotes the attributes to reverse, i.e.,  1, 4, 5, 7.
.
.IP \\*(Cs\\*u
Restore cursor (ANSI.SYS).
.
.IP \\*(Cs\\*(Ps\\*s\\*(Sp\\*u
Set margin-bell volume (DECSMBV, VT520).
  \*(Ps = \*1 \(-> off.
  \*(Ps = \*2, \*3 or \*4 \(-> low.
  \*(Ps = \*0, \*5, \*6, \*7, or \*8 \(-> high.
.
.IP \\*(Cs\\*(Pt\\*;\\*(Pl\\*;\\*(Pb\\*;\\*(Pr\\*;\\*(Pp\\*;\\*(Pt\\*;\\*(Pl\\*;\\*(Pp\\*$\\*v
Copy Rectangular Area (DECCRA, VT400 and up).
  \*(Pt\*;\*(Pl\*;\*(Pb\*;\*(Pr denotes the rectangle.
  \*(Pp denotes the source page.
  \*(Pt\*;\*(Pl denotes the target location.
  \*(Pp denotes the target page.
.
.IP \\*(Cs\\*(Pt\\*s\\*;\\*(Pl\\*s\\*;\\*(Pb\\*s\\*;\\*(Pr\\*s\\*(qu\\*w
Enable Filter Rectangle (DECEFR), VT420 and up.
.br
Parameters are [top;left;bottom;right].
.br
Defines the coordinates of a filter rectangle and activates it.
Anytime the locator is detected outside of the filter rectangle,
an outside rectangle event is generated and the rectangle is disabled.
Filter rectangles are always treated as "one-shot" events.
Any parameters that are omitted default to the current locator position.
If all parameters are omitted, any locator motion will be reported.
DECELR always cancels any prevous rectangle definition.
.
.IP \\*(Cs\\*(Ps\\*s\\*x
Request Terminal Parameters (DECREQTPARM).
.br
if \*(Ps is a "0" (default) or "1", and \fIxterm\fR is emulating VT100,
the control sequence elicits a response of the same form
whose parameters describe the terminal:
  \*(Ps \(-> the given \*(Ps incremented by 2.
  \*(Pn = \*1 \(<- no parity.
  \*(Pn = \*1 \(<- eight bits.
  \*(Pn = \*1 \(<- \*2 \*8 transmit 38.4k baud.
  \*(Pn = \*1 \(<- \*2 \*8 receive 38.4k baud.
  \*(Pn = \*1 \(<- clock multiplier.
  \*(Pn = \*0 \(<- STP flags.
.
.IP \\*(Cs\\*(Ps\\*s\\**\\*x
Select Attribute Change Extent (DECSACE).
  \*(Ps = \*0 \(-> from start to end position, wrapped.
  \*(Ps = \*1 \(-> from start to end position, wrapped.
  \*(Ps = \*2 \(-> rectangle (exact).
.
.IP \\*(Cs\\*(Pc\\*s\\*;\\*(Pt\\*s\\*;\\*(Pl\\*s\\*;\\*(Pb\\*s\\*;\\*(Pr\\*s\\*$\\*x
Fill Rectangular Area (DECFRA), VT420 and up.
  \*(Pc is the character to use.
  \*(Pt\*;\*(Pl\*;\*(Pb\*;\*(Pr denotes the rectangle.
.
.IP \\*(Cs\\*(Pi\\*s\\*;\\*(Pg\\*s\\*;\\*(Pt\\*;\\*(Pl\\*;\\*(Pb\\*;\\*(Pr\\*s\\**\\*y
Request Checksum of Rectangular Area (DECRQCRA), VT420 and up.
Response is
.br
\*(Dc\*(Pi\*s\*!x\*sx\*sx\*sx\*s\*(ST
.br
  \*(Pi is the request id.
  \*(Pg is the page number.
  \*(Pt\*;\*(Pl\*;\*(Pb\*;\*(Pr denotes the rectangle.
  The x's are hexadecimal digits 0-9 and A-F.
.
.IP \\*(Cs\\*(Ps\\*s\\*;\\*(Pu\\*s\\*(qu\\*z
Enable Locator Reporting (DECELR).
.br
Valid values for the first parameter:
  \*(Ps = \*0 \(-> Locator disabled (default).
  \*(Ps = \*1 \(-> Locator enabled.
  \*(Ps = \*2 \(-> Locator enabled for one report, then disabled.
.br
The second parameter specifies the coordinate unit for locator reports.
.br
Valid values for the second parameter:
  \*(Pu = \*0 \(<- or omitted \(-> default to character cells.
  \*(Pu = \*1 \(<- device physical pixels.
  \*(Pu = \*2 \(<- character cells.
.
.IP \\*(Cs\\*(Pt\\*;\\*(Pl\\*;\\*(Pb\\*;\\*(Pr\\*$\\*z
Erase Rectangular Area (DECERA), VT400 and up.
  \*(Pt\*;\*(Pl\*;\*(Pb\*;\*(Pr denotes the rectangle.
.
.IP \\*(Cs\\*(Pm\\*s\\*(qu\\*{
Select Locator Events (DECSLE).
.br
Valid values for the first (and any additional parameters) are:
  \*(Ps = \*0 \(-> only respond to explicit host requests (DECRQLP).
             (This is default).  It also cancels any filter
             rectangle.
  \*(Ps = \*1 \(-> report button down transitions.
  \*(Ps = \*2 \(-> do not report button down transitions.
  \*(Ps = \*3 \(-> report button up transitions.
  \*(Ps = \*4 \(-> do not report button up transitions.
.
.IP \\*(Cs\\*(Pt\\*;\\*(Pl\\*;\\*(Pb\\*;\\*(Pr\\*s\\*$\\*{
Selective Erase Rectangular Area (DECSERA), VT400 and up.
  \*(Pt\*;\*(Pl\*;\*(Pb\*;\*(Pr denotes the rectangle.
.
.IP \\*(Cs\\*(Ps\\*s\\*(qu\\*|
Request Locator Position (DECRQLP).
.br
Valid values for the parameter are:
  \*(Ps = \*0, 1 or omitted \(-> transmit a single DECLRP locator report.
.sP
If Locator Reporting has been enabled by a DECELR, \fI\*(xt\fP will respond
with a DECLRP Locator Report.
This report is also generated on button
up and down events if they have been enabled with a DECSLE, or when
the locator is detected outside of a filter rectangle, if filter rectangles
have been enabled with a DECEFR.
.sP
  \(-> \*(Cs\*(Pe\*s\*;\*(Pb\*s\*;\*(Pr\*s\*;\*(Pc\*s\*;\*(Pp\*s\*&\*s\*w
.sP
Parameters are [\fIevent\fP;\fIbutton\fP;\fIrow\fP;\fIcolumn\fP;\fIpage\fP].
.br
Valid values for the event:
  \*(Pe = \*0 \(-> locator unavailable - no other parameters sent.
  \*(Pe = \*1 \(-> request - \fI\*(xt\fP received a DECRQLP.
  \*(Pe = \*2 \(-> left button down.
  \*(Pe = \*3 \(-> left button up.
  \*(Pe = \*4 \(-> middle button down.
  \*(Pe = \*5 \(-> middle button up.
  \*(Pe = \*6 \(-> right button down.
  \*(Pe = \*7 \(-> right button up.
  \*(Pe = \*8 \(-> M4 button down.
  \*(Pe = \*9 \(-> M4 button up.
  \*(Pe = \*1\*0 \(-> locator outside filter rectangle.
.br
The \*(``\fIbutton\fP\*('' parameter is a bitmask indicating which buttons are pressed:
  \*(Pb = \*0 \(<- no buttons down.
  \*(Pb & \*1 \(<- right button down.
  \*(Pb & \*2 \(<- middle button down.
  \*(Pb & \*4 \(<- left button down.
  \*(Pb & \*8 \(<- M4 button down.
.br
The \*(``\fIrow\fP\*('' and \*(``\fIcolumn\fP\*('' parameters are the coordinates of the locator
position in the \fI\*(xt\fP window, encoded as ASCII decimal.
.br
The \*(``\fIpage\fP\*('' parameter is not used by \*(xt.
.
.IP \\*(Cs\\*(Pm\\*s\\*(qu\\*}
Insert \*(Ps Column(s) (default = 1) (DECIC), VT420 and up.
.
.IP \\*(Cs\\*(Pm\\*s\\*(qu\\*~
Delete \*(Ps Column(s) (default = 1) (DECDC), VT420 and up.
.
.Ed
.
.St
.Ss Operating System Commands
.
.IP \\*(Os\\*(Ps\\*s\\*;\\*(Pt\\*s\\*(Be
.IP \\*(Os\\*(Ps\\*s\\*;\\*(Pt\\*s\\*(ST
Set Text Parameters.
For colors and font,
if \*(Pt is a "?", the control sequence elicits a response which consists
of the control sequence which would set the corresponding value.
The \fIdtterm\fP control sequences allow you to determine the icon name
and window title.
  \*(Ps = \*0 \(-> Change Icon Name and Window Title to \*(Pt.
  \*(Ps = \*1 \(-> Change Icon Name to \*(Pt.
  \*(Ps = \*2 \(-> Change Window Title to \*(Pt.
  \*(Ps = \*3 \(-> Set X property on top-level window.
\*(Pt should be in the form
"\fIprop=value\fP", or just "\fIprop\fP" to delete the property
  \*(Ps = \*4\*;\fIc\fP\*;\fIspec\fP \(-> Change Color Number \fIc\fP to
the color specified by \fIspec\fP.
This can be a name or RGB specification as per \fIXParseColor\fP.
Any number of \fIc\fP/\fIspec\fP pairs may be given.
The color numbers correspond to the ANSI colors 0-7,
their bright versions 8-15,
and if supported, the remainder of the 88-color or 256-color table.
.sP
If a "?" is given rather than a name or RGB specification,
\fI\*(xt\fP replies with a control sequence of the same form which can be used
to set the corresponding color.
Because more than one pair of color number and specification can
be given in one control sequence, \fIxterm\fR can make more than one reply.
.sP
  \*(Ps = \*5\*;\fIc\fP\*;\fIspec\fP \(-> Change Special Color Number \fIc\fP to
the color specified by \fIspec\fP.
This can be a name or RGB specification as per \fIXParseColor\fP.
Any number of \fIc\fP/\fIspec\fP pairs may be given.
The special colors can also be set by adding the maximum number of colors
to these codes in an \*(Os\*4 control:
.sP
.in +2n
  \*(Pc = \*0 \(<- resource \fBcolorBD\fP (BOLD).
  \*(Pc = \*1 \(<- resource \fBcolorUL\fP (UNDERLINE).
  \*(Pc = \*2 \(<- resource \fBcolorBL\fP (BLINK).
  \*(Pc = \*3 \(<- resource \fBcolorRV\fP (REVERSE).
  \*(Pc = \*4 \(<- resource \fBcolorIT\fP (ITALIC).
.in -2n
.sP
  \*(Ps = \*6\*;\fIc\fP\*;\fIf\fP \(-> Enable/disable Special Color Number \fIc\fP.
\*(Os\*6 is the same as \*(Os\*1\*0\*6.
.sP
The 10 colors (below) which may be set or queried
using \*1\*0 through \*1\*9 are
denoted \fIdynamic colors\fR, since the corresponding control sequences
were the first means for setting \fIxterm\fR's colors dynamically,
i.e., after it was started.
They are not the same as the ANSI colors.
These controls may be disabled using the \fIallowColorOps\fP resource.
At least one parameter is expected for \*(Pt.
Each successive parameter changes the next color in the list.
The value of \*(Ps tells the starting point in the list.
The colors are specified by name or RGB specification as per \fIXParseColor\fP.
.sP
If a "?" is given rather than a name or RGB specification,
\fI\*(xt\fP replies with a control sequence of the same form which can be used
to set the corresponding dynamic color.
Because more than one pair of color number and specification can
be given in one control sequence, \fIxterm\fR can make more than one reply.
.sP
  \*(Ps = \*1\*0 \(-> Change VT100 text foreground color to \*(Pt.
  \*(Ps = \*1\*1 \(-> Change VT100 text background color to \*(Pt.
  \*(Ps = \*1\*2 \(-> Change text cursor color to \*(Pt.
  \*(Ps = \*1\*3 \(-> Change mouse foreground color to \*(Pt.
  \*(Ps = \*1\*4 \(-> Change mouse background color to \*(Pt.
  \*(Ps = \*1\*5 \(-> Change Tektronix foreground color to \*(Pt.
  \*(Ps = \*1\*6 \(-> Change Tektronix background color to \*(Pt.
  \*(Ps = \*1\*7 \(-> Change highlight background color to \*(Pt.
  \*(Ps = \*1\*8 \(-> Change Tektronix cursor color to \*(Pt.
  \*(Ps = \*1\*9 \(-> Change highlight foreground color to \*(Pt.
.sP
  \*(Ps = \*4\*6 \(-> Change Log File to \*(Pt.  (This is normally disabled by a
compile-time option).
.sP
  \*(Ps = \*5\*0 \(-> Set Font to \*(Pt.
These controls may be disabled using the \fIallowFontOps\fP resource.
If \*(Pt begins with a "#", index in the font menu, relative (if the
next character is a plus or minus sign) or absolute.
A number is
expected but not required after the sign (the default is the current
entry for relative, zero for absolute indexing).
.br
The same rule (plus or minus sign, optional number) is used when
querying the font.
The remainder of \*(Pt is ignored.
.br
A font can be specified after a "#" index expression,
by adding a space and then the font specifier.
.br
If the "TrueType Fonts" menu entry is set (the \fBrenderFont\fP resource),
then this control sets/queries the \fBfaceName\fP resource.
.sP
  \*(Ps = \*5\*1 \(-> reserved for Emacs shell.
.sP
  \*(Ps = \*5\*2 \(-> Manipulate Selection Data.
These controls may be disabled using the \fIallowWindowOps\fP resource.
The parameter \*(Pt is parsed as
.br
	\*(Pc\*;\*(Pd
.br
The first, \*(Pc, may contain zero or more characters from the
set \*c \*p \*(cs \*0 \*1 \*2 \*3 \*4 \*5 \*6 \*7.
It is used to construct a list of selection parameters for
clipboard,
primary,
select,
or cut buffers 0 through 7 respectively,
in the order given.
If the parameter is empty, \fIxterm\fP uses \*(cs\*0,
to specify the configurable primary/clipboard selection and cut buffer 0.
.br
The second parameter, \*(Pd, gives the selection data.
Normally this is a string encoded in base64.
The data becomes the new selection,
which is then available for pasting by other applications.
.br
If the second parameter is a \*?,
\fIxterm\fP replies to the host with the selection
data encoded using the same protocol.
.br
If the second parameter is neither a base64 string nor \*?,
then the selection is cleared.
.Ed
.sP
  \*(Ps = \*1\*0\*4\*;\fIc\fP \(-> Reset Color Number \fIc\fP.  It is reset to
the color specified by the corresponding X resource.
Any number of \fIc\fP parameters may be given.
These parameters correspond to the ANSI colors 0-7,
their bright versions 8-15,
and if supported, the remainder of the 88-color or 256-color table.
If no parameters are given, the entire table will be reset.
.sP
  \*(Ps = \*1\*0\*5\*;\fIc\fP \(-> Reset Special Color Number \fIc\fP.  It is reset to
the color specified by the corresponding X resource.
Any number of \fIc\fP parameters may be given.
These parameters correspond to the special colors which can be set
using an \*(Os\*5 control (or by adding the maximum number of colors
using an \*(Os\*4 control).
.sP
  \*(Ps = \*1\*0\*6\*;\fIc\fP\*;\fIf\fP \(-> Enable/disable Special Color Number \fIc\fP.
The second parameter tells \fIxterm\fP to enable the corresponding color
mode if nonzero, disable it if zero.
.sP
.in +2n
  \*(Pc = \*0 \(<- resource \fBcolorBDMode\fP (BOLD).
  \*(Pc = \*1 \(<- resource \fBcolorULMode\fP (UNDERLINE).
  \*(Pc = \*2 \(<- resource \fBcolorBLMode\fP (BLINK).
  \*(Pc = \*3 \(<- resource \fBcolorRVMode\fP (REVERSE).
  \*(Pc = \*4 \(<- resource \fBcolorITMode\fP (ITALIC).
  \*(Pc = \*5 \(<- resource \fBcolorAttrMode\fP (Override ANSI).
.in -2n
.sP
The \fIdynamic colors\fR can also be reset to their default (resource) values:
  \*(Ps = \*1\*1\*0 \(-> Reset VT100 text foreground color.
  \*(Ps = \*1\*1\*1 \(-> Reset VT100 text background color.
  \*(Ps = \*1\*1\*2 \(-> Reset text cursor color.
  \*(Ps = \*1\*1\*3 \(-> Reset mouse foreground color.
  \*(Ps = \*1\*1\*4 \(-> Reset mouse background color.
  \*(Ps = \*1\*1\*5 \(-> Reset Tektronix foreground color.
  \*(Ps = \*1\*1\*6 \(-> Reset Tektronix background color.
  \*(Ps = \*1\*1\*7 \(-> Reset highlight color.
  \*(Ps = \*1\*1\*8 \(-> Reset Tektronix cursor color.
  \*(Ps = \*1\*1\*9 \(-> Reset highlight foreground color.
.
.St
.Ss Privacy Message
.IP \\*(PM\\*(Pt\\*s\\*(ST
\fIxterm\fP implements no \*(PM functions; \*(Pt is ignored.
\*(Pt need not be printable characters.
.Ed
.
.Sh "Alt and Meta Keys"
.LP
Many keyboards have keys labeled "Alt".
Few have keys labeled "Meta".
However, \fIxterm\fP's default translations use the \fIMeta\fP modifier.
Common keyboard configurations assign the \fIMeta\fP modifier to an "Alt" key.
By using \fIxmodmap\fP one may have the modifier assigned to a different key,
and have "real" alt and meta keys.
Here is an example:
.ID
.ft CW
! put meta on mod3 to distinguish it from alt
keycode 64 = Alt_L
clear mod1
add mod1 = Alt_L
keycode 115 = Meta_L
clear mod3
add mod3 = Meta_L
.ft 1
.DE
.lP
The \fBmetaSendsEscape\fP resource
(and \fBaltSendsEscape\fP if \fBaltIsNotMeta\fP is set)
can be used to control the way the \fIMeta\fP modifier applies to ordinary
keys unless the \fBmodifyOtherKeys\fP resource is set:
.IP
-
prefix a key with the \*(Es character.
.IP
-
shift the key from codes 0-127 to 128-255 by adding 128.
.lP
The table shows the result for a given character "x" with modifiers
according to the default translations with the resources set on or off.
This assumes \fBaltIsNotMeta\fP is set:
.\" page-eject to work around grohtml bugs
.if t .bp
.TS H
center;
lf3w(2c)	lf3w(2c)	lf3w(2c)	lf3w(2c) .
_
.TH
.T&
l | l | l | l .
key	altSendsEscape	metaSendsEscape	result
_
x	off	off	x
Meta-x	off	off	shift
Alt-x	off	off	shift
Alt+Meta-x	off	off	shift
x	ON	off	x
Meta-x	ON	off	shift
Alt-x	ON	off	\*(Es x
Alt+Meta-x	ON	off	\*(Es shift
x	off	ON	x
Meta-x	off	ON	\*(Es x
Alt-x	off	ON	shift
Alt+Meta-x	off	ON	\*(Es shift
x	ON	ON	x
Meta-x	ON	ON	\*(Es x
Alt-x	ON	ON	\*(Es x
Alt+Meta-x	ON	ON	\*(Es x
_
.TE
.Sh "PC-Style Function Keys"
.LP
If \fIxterm\fP does minimal translation of the function keys, it usually does this
with a PC-style keyboard, so PC-style function keys result.
Sun keyboards are similar to PC keyboards.
Both have cursor and scrolling operations printed on the keypad,
which duplicate the smaller cursor and scrolling keypads.
.lP
X does not predefine NumLock (used for VT220 keyboards) or Alt (used as
an extension for the Sun/PC keyboards) as modifiers.
These keys are recognized as modifiers when enabled
by the \fBnumLock\fP resource,
or by the "DECSET \*1\*0\*3\*5" control sequence.
.lP
The cursor keys transmit the following escape sequences depending on the
mode specified via the \fBDECCKM\fP escape sequence.
.TS H
center;
lf3w(2c)	lf3w(2c)	lf3w(2c) .
Key	Normal	Application
_
.TH
.T&
l | l | l .
Cursor Up	\*(Cs\*A	\*(S3\*A
Cursor Down	\*(Cs\*(cB	\*(S3\*(cB
Cursor Right	\*(Cs\*C	\*(S3\*C
Cursor Left	\*(Cs\*D	\*(S3\*D
_
.TE
The home- and end-keys
(unlike PageUp and other keys also on the 6-key editing keypad)
are considered "cursor keys" by \fIxterm\fP.
Their mode is also controlled by the \fBDECCKM\fP escape sequence:
.TS H
center;
lf3w(2c)	lf3w(2c)	lf3w(2c) .
Key	Normal	Application
_
.TH
.T&
l | l | l .
Home	\*(Cs\*H	\*(S3\*H
End	\*(Cs\*F	\*(S3\*F
_
.TE
.lP
The application keypad transmits the following escape sequences depending on the
mode specified via the \fBDECKPNM\fP and \fBDECKPAM\fP escape sequences.
Use the NumLock key to override the application mode.
.lP
Not all keys are present on the Sun/PC keypad (e.g., PF1, Tab), but are supported by
the program.
.TS H
center;
lf3w(2c)	lf3w(2c)	lf3w(2c)	lf3w(2c)	lf3w(2c) .
Key	Numeric	Application	Terminfo	Termcap
_
.TH
.T&
l | l | l | l | l .
Space	\*(Sp	\*(S3\*(Sp	-	-
Tab	\*(Ta	\*(S3\*I	-	-
Enter	\*(Cr	\*(S3\*M	kent	@8
PF1	\*(S3\*P	\*(S3\*P	kf1	k1
PF2	\*(S3\*Q	\*(S3\*Q	kf2	k2
PF3	\*(S3\*R	\*(S3\*R	kf3	k3
PF4	\*(S3\*S	\*(S3\*S	kf4	k4
* \f1(multiply)\fP	\**	\*(S3\*j	-	-
+ \f1(add)\fP	\*+	\*(S3\*k	-	-
, \f1(comma)\fP	\*,	\*(S3\*l	-	-
- \f1(minus)\fP	\*-	\*(S3\*m	-	-
\&. \f1(Delete)\fP	\*.	\*(Cs\*3\*(c~	-	-
/ \f1(divide)\fP	\*/	\*(S3\*o	-	-
0 \f1(Insert)\fP	\*0	\*(Cs\*2\*(c~	-	-
1 \f1(End)\fP	\*1	\*(S3\*F	kc1	K4
2 \f1(DownArrow)\fP	\*2	\*(Cs\*(cB	-	-
3 \f1(PageDown)\fP	\*3	\*(Cs\*6\*(c~	kc3	K5
4 \f1(LeftArrow)\fP	\*4	\*(Cs\*D	-	-
5 \f1(Begin)\fP	\*5	\*(Cs\*E	kb2	K2
6 \f1(RightArrow)\fP	\*6	\*(Cs\*C	-	-
7 \f1(Home)\fP	\*7	\*(S3\*H	ka1	K1
8 \f1(UpArrow)\fP	\*8	\*(Cs\*A	-	-
9 \f1(PageUp)\fP	\*9	\*(Cs\*5\*(c~	ka3	K3
= (equal)	\*=	\*(S3\*(XX	-	-
_
.TE
.br
They also provide 12 function keys, as well as a few other special-purpose keys:
.TS H
center;
lf3w(2c)	lf3w(2c) .
Key	Escape Sequence
_
.TH
.T&
l | l .
F1	\*(S3\*P
F2	\*(S3\*Q
F3	\*(S3\*R
F4	\*(S3\*S
F5	\*(Cs\*1\*5\*(c~
F6	\*(Cs\*1\*7\*(c~
F7	\*(Cs\*1\*8\*(c~
F8	\*(Cs\*1\*9\*(c~
F9	\*(Cs\*2\*0\*(c~
F10	\*(Cs\*2\*1\*(c~
F11	\*(Cs\*2\*3\*(c~
F12	\*(Cs\*2\*4\*(c~
_
.TE
.sP
Note that F1 through F4 are prefixed with \*(S3,
while the other keys are prefixed with \*(Cs.
Older versions of \fIxterm\fP implement different escape sequences
for F1 through F4, with a \*(Cs prefix.
These can be activated by setting the \fBoldXtermFKeys\fP resource.
However, since they do not correspond to any hardware terminal,
they have been deprecated.
(The DEC VT220 reserves F1 through F5 for local functions such as \fBSetup\fP).
.TS H
center;
lf3w(2c)	lf3w(2c) .
Key	Escape Sequence
_
.TH
.T&
l | l .
F1	\*(Cs\*1\*1\*(c~
F2	\*(Cs\*1\*2\*(c~
F3	\*(Cs\*1\*3\*(c~
F4	\*(Cs\*1\*4\*(c~
_
.TE
In normal mode, i.e., a Sun/PC keyboard
when the \fBsunKeyboard\fP resource is false
(and none of the other keyboard resources
such as \fBoldXtermFKeys\fP resource is set),
\fIxterm\fP encodes function key modifiers
as parameters appended before the \fIfinal\fP character of the control sequence.
As a special case,
the \*(S3 sent before F1 through F4 is altered to \*(Cs when sending
a function key modifier as a parameter.
.TS H
center;
cf3w(2c)	lf3w(2c) .
Code	Modifiers
_
.TH
.T&
c | l .
2	Shift
3	Alt
4	Shift + Alt
5	Control
6	Shift + Control
7	Alt + Control
8	Shift + Alt + Control
9	Meta
10	Meta + Shift
11	Meta + Alt
12	Meta + Alt + Shift
13	Meta + Ctrl
14	Meta + Ctrl + Shift
15	Meta + Ctrl + Alt
16	Meta + Ctrl + Alt + Shift
_
.TE
For example, shift-F5 would be sent as
\*(Cs\*1\*5\*;\*2\*(c~
.lP
If the \fBalwaysUseMods\fP resource is set, the Meta modifier also is
recognized, making parameters 9 through 16.
.Sh "VT220-Style Function Keys"
.LP
However, \fIxterm\fP is most useful as a DEC VT102 or VT220 emulator.
Set the \fBsunKeyboard\fP resource to true to force a Sun/PC keyboard
to act like a VT220 keyboard.
.lP
The VT102/VT220 application keypad transmits unique escape sequences in
application mode, which are distinct from the cursor and scrolling keypad:
.TS H
center;
lf3w(2c)	lf3w(2c)	lf3w(2c) .
Key	Numeric	Application
_
.TH
.T&
l | l | l .
Space	\*(Sp	\*(S3\*(Sp
Tab	\*(Ta	\*(S3\*I
Enter	\*(Cr	\*(S3\*M
PF1	\*(S3\*P	\*(S3\*P
PF2	\*(S3\*Q	\*(S3\*Q
PF3	\*(S3\*R	\*(S3\*R
PF4	\*(S3\*S	\*(S3\*S
* \f1(multiply)\fP	\**	\*(S3\*j
+ \f1(add)\fP	\*+	\*(S3\*k
, \f1(comma)\fP	\*,	\*(S3\*l
- \f1(minus)\fP	\*-	\*(S3\*m
\&. \f1(period)\fP	\*.	\*(S3\*n
/ \f1(divide)\fP	\*/	\*(S3\*o
0	\*0	\*(S3\*p
1	\*1	\*(S3\*q
2	\*2	\*(S3\*r
3	\*3	\*(S3\*(cs
4	\*4	\*(S3\*t
5	\*5	\*(S3\*u
6	\*6	\*(S3\*v
7	\*7	\*(S3\*w
8	\*8	\*(S3\*x
9	\*9	\*(S3\*y
= (equal)	\*=	\*(S3\*(XX
_
.TE
The VT220 provides a 6-key editing keypad,
which is analogous to that on the PC keyboard.
It is not affected by \fBDECCKM\fP or \fBDECKPNM\fP/\fBDECKPAM\fP:
.TS H
center;
lf3w(2c)	lf3w(2c)	lf3w(2c) .
Key	Normal	Application
_
.TH
.T&
l | l | l .
\f1Insert\fP	\*(Cs\*2\*(c~	\*(Cs\*2\*(c~
\f1Delete\fP	\*(Cs\*3\*(c~	\*(Cs\*3\*(c~
\f1Home\fP	\*(Cs\*1\*(c~	\*(Cs\*1\*(c~
\f1End\fP	\*(Cs\*4\*(c~	\*(Cs\*4\*(c~
\f1PageUp\fP	\*(Cs\*5\*(c~	\*(Cs\*5\*(c~
\f1PageDown\fP	\*(Cs\*6\*(c~	\*(Cs\*6\*(c~
_
.TE
.LP
The VT220 provides 8 additional function keys.
With a Sun/PC keyboard, access these keys by Control/F1 for F13, etc.
.TS H
center;
lf3w(2c)	lf3w(2c) .
Key	Escape Sequence
_
.TH
.T&
l | l .
F13	\*(Cs\*2\*5\*(c~
F14	\*(Cs\*2\*6\*(c~
F15	\*(Cs\*2\*8\*(c~
F16	\*(Cs\*2\*9\*(c~
F17	\*(Cs\*3\*1\*(c~
F18	\*(Cs\*3\*2\*(c~
F19	\*(Cs\*3\*3\*(c~
F20	\*(Cs\*3\*4\*(c~
_
.TE
.Sh "VT52-Style Function Keys"
.LP
A VT52 does not have function keys, but it does have a numeric keypad and cursor keys.
They differ from the other emulations by the prefix.
Also, the cursor keys do not change:
.TS H
center;
lf3w(2c)	lf3w(2c) .
Key	Normal/Application
_
.TH
.T&
l | l .
Cursor Up	\*(Es\*A
Cursor Down	\*(Es\*(cB
Cursor Right	\*(Es\*C
Cursor Left	\*(Es\*D
_
.TE
The keypad is similar:
.TS H
center;
lf3w(2c)	lf3w(2c)	lf3w(2c) .
Key	Numeric	Application
_
.TH
.T&
l | l | l .
Space	\*(Sp	\*(Es\*?\*(Sp
Tab	\*(Ta	\*(Es\*?\*I
Enter	\*(Cr	\*(Es\*?\*M
PF1	\*(Es\*P	\*(Es\*P
PF2	\*(Es\*Q	\*(Es\*Q
PF3	\*(Es\*R	\*(Es\*R
PF4	\*(Es\*S	\*(Es\*S
* \f1(multiply)\fP	\**	\*(Es\*?\*j
+ \f1(add)\fP	\*+	\*(Es\*?\*k
, \f1(comma)\fP	\*,	\*(Es\*?\*l
- \f1(minus)\fP	\*-	\*(Es\*?\*m
\&. \f1(period)\fP	\*.	\*(Es\*?\*n
/ \f1(divide)\fP	\*/	\*(Es\*?\*o
0	\*0	\*(Es\*?\*p
1	\*1	\*(Es\*?\*q
2	\*2	\*(Es\*?\*r
3	\*3	\*(Es\*?\*(cs
4	\*4	\*(Es\*?\*t
5	\*5	\*(Es\*?\*u
6	\*6	\*(Es\*?\*v
7	\*7	\*(Es\*?\*w
8	\*8	\*(Es\*?\*x
9	\*9	\*(Es\*?\*y
= (equal)	\*=	\*(Es\*?\*(XX
_
.TE
.Sh "Sun-Style Function Keys"
.LP
The \fIxterm\fP program provides support for Sun keyboards more directly, by
a menu toggle that causes it to send Sun-style function key codes rather than VT220.
Note, however, that the \fIsun\fP and \fIVT100\fP emulations are not really
compatible.
For example, their wrap-margin behavior differs.
.lP
Only function keys are altered; keypad and cursor keys are the same.
The emulation responds identically.
See the xterm-sun terminfo entry for details.
.Sh "HP-Style Function Keys"
.LP
Similarly, \fIxterm\fP can be compiled to support HP keyboards.
See the xterm-hp terminfo entry for details.
.Sh "The Alternate Screen Buffer"
.LP
\fIXterm\fP maintains two screen buffers.
The normal screen buffer allows you to scroll back to view saved lines
of output up to the maximum set by the \fBsaveLines\fP resource.
The alternate screen buffer is exactly as large as the display,
contains no additional saved lines.
When the alternate screen buffer is active,
you cannot scroll back to view saved lines.
\fIXterm\fP provides control sequences and menu entries
for switching between the two.
.lP
Most full-screen applications use terminfo or termcap to obtain
strings used to start/stop full-screen mode,
i.e., \fIsmcup\fP and \fIrmcup\fP for terminfo,
or the corresponding \fIti\fP and \fIte\fP for termcap.
The \fBtiteInhibit\fP resource removes the \fIti\fP and \fIte\fP strings
from the TERMCAP string which is set in the environment for some platforms.
That is not done when \fIxterm\fP is built with terminfo libraries because
terminfo does not provide the whole text of the termcap data in one piece.
It would not work for terminfo anyway, since terminfo data is not passed
in environment variables;
setting an environment variable in this manner would have no effect on
the application's ability to switch between normal and alternate screen
buffers.
Instead, the newer private mode controls
(such as \*1\*0\*4\*9)
for switching between normal
and alternate screen buffers simply disable the switching.
They add other features such as clearing the display for the same reason:
to make the details of switching independent of the application that
requests the switch.
.
.Sh "Bracketed Paste Mode"
.LP
When bracketed paste mode is set,
pasted text is bracketed with control sequences
so that the program can differentiate pasted text from typed-in text.
When bracketed paste mode is set,
the program will receive:
   \*(Es\*([[\*2\*0\*0\*~,
.br
followed by the pasted text, followed by
   \*(Es\*([[\*2\*0\*1\*~.
.
.Sh "Title Modes"
.LP
The window- and icon-labels can be set or queried using control sequences.
As a VT220-emulator, \fIxterm\fP "should" limit the character encoding for
the corresponding strings to ISO-8859-1.
Indeed, it used to be the case (and was documented) that
window titles had to be ISO-8859-1.
This is no longer the case.
However, there are many applications which still assume that titles are
set using ISO-8859-1.
So that is the default behavior.
.lP
If \fIxterm\fP is running with UTF-8 encoding,
it is possible to use window- and icon-labels encoded using UTF-8.
That is because the underlying X libraries (and many, but not all)
window managers support this feature.
.lP
The \fButf8Title\fP X resource setting tells \fIxterm\fP to disable
a reconversion of the title string back to ISO-8859-1,
allowing the title strings to be interpreted as UTF-8.
The same feature can be enabled using the title mode control sequence
described in this summary.
.lP
Separate from the ability to set the titles,
\fIxterm\fP provides the ability to query the titles,
returning them either in ISO-8859-1 or UTF-8.
This choice is available only while \fIxterm\fP is using UTF-8 encoding.
.lP
Finally, the characters sent to, or returned by a title control
are less constrained than the rest of the control sequences.
To make them more manageable (and constrained), for use in shell scripts,
\fIxterm\fP has an optional feature which decodes the string from hexadecimal
(for setting titles) or for encoding the title into hexadecimal when querying
the value.
.
.Sh "Mouse Tracking"
.LP
The VT widget can be set to send the mouse position and other
information on button presses.
These modes are typically used by
editors and other full-screen applications that want to make use of
the mouse.
.lP
There are two sets of mutually exclusive modes:
.bP
mouse protocol
.bP
protocol encoding
.lP
The mouse protocols include
DEC Locator mode, enabled by the
DECELR \*(Cs\*(Ps\*s\*;\*(Ps\*s\*s\*(qu\*s\*z
control sequence, and is not described here
(control sequences are summarized above).
The remaining five modes of the mouse protocols
are each enabled (or disabled) by a different parameter in
the "DECSET \*(Cs\*?\*(Pm\*s\*h"
or
"DECRST \*(Cs\*?\*(Pm\*s\*l"
control sequence.
.lP
Manifest constants for the parameter values
are defined in \fBxcharmouse.h\fP as follows:
.
.ID
.ft CW
#define SET_X10_MOUSE               9
#define SET_VT200_MOUSE             1000
#define SET_VT200_HIGHLIGHT_MOUSE   1001
#define SET_BTN_EVENT_MOUSE         1002
#define SET_ANY_EVENT_MOUSE         1003

#define SET_FOCUS_EVENT_MOUSE       1004

#define SET_EXT_MODE_MOUSE          1005
#define SET_SGR_EXT_MODE_MOUSE      1006
#define SET_URXVT_EXT_MODE_MOUSE    1015

#define SET_ALTERNATE_SCROLL        1007
.ft 1
.DE
.br
The motion reporting modes are strictly \fIxterm\fP extensions, and are not
part of any standard, though they are analogous to the DEC VT200 DECELR
locator reports.
.lP
Normally,
parameters (such as pointer position and button number) for all mouse
tracking escape sequences generated by \fIxterm\fP
encode numeric parameters in a single character as
\fIvalue\fP+32.
For example, \*! specifies the value 1.
The upper left character position on the terminal is denoted as 1,1.
This scheme dates back to X10,
though the normal mouse-tracking (from X11) is more elaborate.
.Ss X10 compatbility mode
.lP
X10 compatibility mode sends an escape sequence only on button press,
encoding the location and the mouse button pressed.
It is enabled by specifying parameter 9 to DECSET.
On button press, \fIxterm\fP sends
\*(Cs\*M\*(Cb\*(Cx\*(Cy (6 characters).
.bP
\*(Cb is button\-1.
.bP
\*(Cx and \*(Cy are the x and y coordinates of the mouse when the
button was pressed.
.Ss Normal tracking mode
.lP
Normal tracking mode sends an escape sequence on both button press and
release.
Modifier key (shift, ctrl, meta) information is also sent.
It is enabled by specifying parameter 1000 to DECSET.
On button press or release, \fIxterm\fP sends
\*(Cs\*M\*(Cb\*(Cx\*(Cy.
.bP
The low two bits of \*(Cb encode button information:
0=MB1 pressed, 1=MB2 pressed, 2=MB3 pressed, 3=release.
.bP
The next three bits encode the modifiers which were down when the button was
pressed and are added together:  4=Shift, 8=Meta, 16=Control.
Note however that the shift and control bits are normally unavailable
because \fIxterm\fP uses the control modifier with mouse for popup menus,
and the shift modifier is used in the default translations for button events.
The \fIMeta\fP modifier recognized by \fIxterm\fP is the \fImod1\fP mask,
and is not necessarily the "Meta" key (see \fIxmodmap\fP).
.bP
\*(Cx and \*(Cy are the x and y coordinates of the mouse event, encoded as
in X10 mode.
.Ss Wheel mice
.lP
Wheel mice may return buttons 4 and 5.
Those buttons are represented by the same event codes
as buttons 1 and 2 respectively,
except that 64 is added to the event code.
Release events for the wheel buttons are not reported.
By default,
the wheel mouse events are translated to \fIscroll-back\fP
and \fIscroll-forw\fP actions.
Those actions normally scroll the whole window,
as if the scrollbar was used.
However if Alternate Scroll mode is set,
then cursor up/down controls are sent when the terminal is displaying
the alternate screen.
The initial state of Alternate Scroll mode is set
using the \fBalternateScroll\fP resource.
.Ss Highlight tracking
.lP
Mouse highlight tracking notifies a program of a button press, receives a
range of lines from the program, highlights the region covered by
the mouse within that range until button release, and then sends the
program the release coordinates.
It is enabled by specifying parameter 1001 to DECSET.
Highlighting is performed only for button 1, though other button events
can be received.
.sP
\fBWarning:\fP use of this mode requires a cooperating program or it will
hang \fIxterm.\fP
.sP
On button press, the same information as for normal tracking is
generated; \fIxterm\fP then waits for the program to send mouse
tracking information.
\fIAll X events are ignored until the proper escape sequence is
received from the pty:\fP
\*(Cs\*(Ps\*s\*;\*(Ps\*s\*;\*(Ps\*s\*;\*(Ps\*s\*;\*(Ps\*s\*T.
The parameters are \fIfunc, startx, starty, firstrow,\fP and \fIlastrow.\fP
\fIfunc\fP is non-zero to initiate highlight tracking and zero to abort.
\fIstartx\fP and \fIstarty\fP give the starting x and y location for
the highlighted region.
The ending location tracks the mouse, but
will never be above row \fIfirstrow\fP and will always be above row
\fIlastrow.\fP
(The top of the screen is row 1.)
When the button is released, \fIxterm\fP reports the ending position
one of two ways:
.bP
if the start and end coordinates are the same locations:
.br
\*(Cs\*t\*(Cx\*(Cy.
.bP
otherwise:
.br
\*(Cs\*T\*(Cx\*(Cy\*(Cx\*(Cy\*(Cx\*(Cy.
.br
The parameters are \fIstartx, starty, endx, endy, mousex,\fP and \fImousey.\fP
.RS
.IP \- 0.2i
\fIstartx, starty, endx, \fPand\fI endy\fP give the starting and
ending character positions of the region.
.IP \- 0.2i
\fImousex\fP and \fImousey\fP
give the location of the mouse at button up, which may not be over a
character.
.RE
.Ss Button-event tracking
.lP
Button-event tracking is essentially the same as normal tracking, but
\fIxterm\fP also reports button-motion events.
Motion events
are reported only if the mouse pointer has moved to a different character
cell.
It is enabled by specifying parameter 1002 to DECSET.
On button press or release, \fIxterm\fP sends the same codes used by normal
tracking mode.
.bP
On button-motion events, \fIxterm\fP adds 32 to the event code
(the third character, \*(Cb).
.bP
The other bits of the event code specify button and modifier keys as in normal mode.
For example, motion into cell x,y with button 1
down is reported as \*(Cs\*M\*@\*(Cx\*(Cy.
(\ \*@ = 32 + 0 (button 1) + 32 (motion indicator)\ ).
Similarly, motion with button 3
down is reported as \*(Cs\*M\*(cB\*(Cx\*(Cy.
(\ \*(cB = 32 + 2 (button 3) + 32 (motion indicator)\ ).
.Ss Any-event tracking
.lP
Any-event mode is the same as button-event mode, except that all motion
events are reported, even if no mouse button is down.
It is enabled by specifying 1003 to DECSET.
.Ss FocusIn/FocusOut
.lP
FocusIn/FocusOut can be combined with any of the mouse events since
it uses a different protocol.
When set, it causes \fIxterm\fP to send
\*(Cs\*I when the terminal gains focus, and
\*(Cs\*O when it loses focus.
.Ss Extended coordinates
.lP
The original X10 mouse protocol limits the \*(Cx and \*(Cy ordinates
to 223 (=255\ -\ 32).
\fIXterm\fP supports more than one scheme for extending this range,
by changing the protocol encoding:
.IP "UTF-8 (1005)"
This enables UTF-8 encoding for \*(Cx and \*(Cy under
all tracking modes, expanding the maximum encodable position from 223 to 2015.
For positions less than 95, the resulting output is identical under both modes.
Under extended mouse mode, positions greater than 95
generate "extra" bytes which will confuse applications which do not treat
their input as a UTF-8 stream.
Likewise, \*(Cb will be UTF-8 encoded,
to reduce confusion with wheel mouse events.
.IP
Under normal mouse mode, positions outside (160,94) result in
byte pairs which can be interpreted as a single UTF-8 character;
applications
which do treat their input as UTF-8 will almost certainly be confused
unless extended mouse mode is active.
.IP
This scheme has the drawback that the encoded coordinates will not
pass through \fIluit\fP unchanged, e.g., for locales using non-UTF-8 encoding.
.IP "SGR (1006)"
The normal mouse response is altered to use \*(Cs\*<
followed by semicolon-separated
encoded button value,
the \*(Cx and \*(Cy ordinates and a final character which
is \*M for button press
and \*m for button release.
.RS
.bP
The encoded button value in this case does not add 32 since
that was useful only in the X10 scheme for ensuring that the
byte containing the button value is a printable code.
.bP
The modifiers are encoded in the same way.
.bP
A different final character is used for button release
to resolve the X10 ambiguity regarding which button was released.
.RE
.IP
The highlight tracking responses are also modified to an SGR-like format,
using the same SGR-style scheme and button-encodings.
.IP "URXVT (1015)"
The normal mouse response is altered to use \*(Cs
followed by semicolon-separated
encoded button value,
the \*(Cx and \*(Cy ordinates and final character \*M.
.IP
This uses the same button encoding as X10, but printing it as
a decimal integer rather than as a single byte.
.IP
However, \*(Cs\*M can be mistaken for DL (delete lines),
while the highlight tracking \*(Cs\*T can be mistaken for SD (scroll down),
and the Window manipulation controls.
For these reasons, the 1015 control is not recommended;
it is not an improvement over 1005.
.
.Sh "Sixel Graphics"
.LP
If \fI\*(xt\fP is configured as
VT240,
VT241,
VT330,
VT340 or
VT382
using the \fBdecTerminalID\fP resource,
it supports Sixel Graphics controls, a palleted bitmap graphics system
using sets of six vertical pixels as the basic element.
.St
.IP \\*(Cs\\*(Ps\\*s\\*c
\fI\*(xt\fP responds to Send Device Attributes (Primary DA) with these
additional codes:
  \*(Ps = \*4 \(-> Sixel graphics.
.IP \\*(Cs\\*?\\*(Pm\\*s\\*h
\fI\*(xt\fP has these additional private Set Mode values:
  \*(Ps = \*8\*0 \(-> Sixel scrolling.
  \*(Ps = \*1\*0\*7\*0 \(-> use private color registers for each graphic.
  \*(Ps = \*8\*4\*5\*2 \(-> Sixel scrolling leaves cursor to right of graphic.
.IP \\*(Dc\\*(Pa\\*;\\*(Pb\\*;\\*(Ph\\*s\\*q\\*s\\*(Ps..\\*(Ps\fP\\*s\\*(ST
See:
.ID
http://vt100.net/docs/vt3xx-gp/chapter14.html
.DE
The sixel data device control string has three positional parameters,
following the \*q with sixel data.
  \*(Pa \(-> pixel aspect ratio
  \*(Pb \(-> background color option
  \*(Ph \(-> horizontal grid size (ignored).
  \*(Ps \(-> sixel data
.Ed
.
.Sh "ReGIS Graphics"
.LP
If \fI\*(xt\fP is configured as
VT125,
VT240,
VT241,
VT330 or
VT340
using the \fBdecTerminalID\fP resource,
it supports Remote Graphic Instruction Set, a graphics description language.
.St
.IP \\*(Cs\\*(Ps\\*s\\*c
\fI\*(xt\fP responds to Send Device Attributes (Primary DA) with these
additional codes:
  \*(Ps = \*3 \(-> ReGIS graphics.
.IP \\*(Cs\\*?\\*(Pm\\*s\\*h
\fI\*(xt\fP has these additional private Set Mode values:
  \*(Ps = \*1\*0\*7\*0 \(-> use private color registers for each graphic.
.IP \\*(Dc\\*(Pm\\*s\\*p\\*(Pr..\\*(Pr\fP\\*s\\*(ST
See:
.ID
http://vt100.net/docs/vt3xx-gp/chapter1.html
.DE
The ReGIS data device control string has one positional parameter
with four possible values:
  \*(Pm = 0 \(-> resume command, use fullscreen mode.
  \*(Pm = 1 \(-> start new command, use fullscreen mode.
  \*(Pm = 2 \(-> resume command, use command display mode.
  \*(Pm = 3 \(-> start new command, use command display mode.
.Ed
.
.Sh "Tektronix 4014 Mode"
.LP
Most of these sequences are standard Tektronix 4014 control sequences.
Graph mode supports the 12-bit addressing of the Tektronix 4014.
The major features missing are
the write-through and defocused modes.
This document does not describe the commands used in the various
Tektronix plotting modes but does describe the commands to switch modes.
.St
.IP \\*(Be
Bell (Ctrl-G).
.IP \\*(Bs
Backspace (Ctrl-H).
.IP \\*(Ta
Horizontal Tab (Ctrl-I).
.IP \\*(Lf
Line Feed or New Line (Ctrl-J).
.IP \\*(Vt
Cursor up (Ctrl-K).
.IP \\*(Ff
Form Feed or New Page (Ctrl-L).
.IP \\*(Cr
Carriage Return (Ctrl-M).
.IP \\*(Es\\*(Et
Switch to VT100 Mode (\*(Es Ctrl-C).
.IP \\*(Es\\*(En
Return Terminal Status (\*(Es Ctrl-E).
.IP \\*(Es\\*(Ff
PAGE (Clear Screen) (\*(Es Ctrl-L).
.IP \\*(Es\\*(So
Begin 4015 APL mode (\*(Es Ctrl-N).  (This is ignored by \fIxterm\fP).
.IP \\*(Es\\*(Si
End 4015 APL mode (\*(Es Ctrl-O).  (This is ignored by \fIxterm\fP).
.IP \\*(Es\\*(Eb
COPY (Save Tektronix Codes to file COPY\fIyyyy-mm-dd.hh:mm:ss\fP).
  \*(Eb (end transmission block) is the same as Ctrl-W.
.IP \\*(Es\\*(Ca
Bypass Condition (\*(Es Ctrl-X).
.IP \\*(Es\\*(Su
GIN mode (\*(Es Ctrl-Z).
.IP \\*(Es\\*(Fs
Special Point Plot Mode (\*(Es Ctrl-\e).
.IP \\*(Es\\*8
Select Large Character Set.
.IP \\*(Es\\*9
Select #2 Character Set.
.IP \\*(Es\\*:
Select #3 Character Set.
.IP \\*(Es\\*;
Select Small Character Set.
.IP \\*(Os\\*(Ps\\*s\\*;\\*(Pt\\*s\\*(Be
Set Text Parameters of VT window.
  \*(Ps = \*0 \(-> Change Icon Name and Window Title to \*(Pt.
  \*(Ps = \*1 \(-> Change Icon Name to \*(Pt.
  \*(Ps = \*2 \(-> Change Window Title to \*(Pt.
  \*(Ps = \*4\*6 \(-> Change Log File to \*(Pt.  (This is normally disabled by a
compile-time option).
.IP \\*(Es\\*`
Normal Z Axis and Normal (solid) Vectors.
.IP \\*(Es\\*a
Normal Z Axis and Dotted Line Vectors.
.IP \\*(Es\\*b
Normal Z Axis and Dot-Dashed Vectors.
.IP \\*(Es\\*c
Normal Z Axis and Short-Dashed Vectors.
.IP \\*(Es\\*d
Normal Z Axis and Long-Dashed Vectors.
.IP \\*(Es\\*h
Defocused Z Axis and Normal (solid) Vectors.
.IP \\*(Es\\*i
Defocused Z Axis and Dotted Line Vectors.
.IP \\*(Es\\*j
Defocused Z Axis and Dot-Dashed Vectors.
.IP \\*(Es\\*k
Defocused Z Axis and Short-Dashed Vectors.
.IP \\*(Es\\*l
Defocused Z Axis and Long-Dashed Vectors.
.IP \\*(Es\\*p
Write-Thru Mode and Normal (solid) Vectors.
.IP \\*(Es\\*q
Write-Thru Mode and Dotted Line Vectors.
.IP \\*(Es\\*r
Write-Thru Mode and Dot-Dashed Vectors.
.IP \\*(Es\\*(cs
Write-Thru Mode and Short-Dashed Vectors.
.IP \\*(Es\\*t
Write-Thru Mode and Long-Dashed Vectors.
.IP \\*(Fs
Point Plot Mode (Ctrl-\e).
.IP \\*(Gs
Graph Mode (Ctrl-]).
.IP \\*(Rs
Incremental Plot Mode (Ctrl-^).
.IP \\*(Us
Alpha Mode (Ctrl-_).
.Ed
.
.
.Sh "VT52 Mode"
.LP
Parameters for cursor movement are at the end of the \*(Es\*Y escape sequence.
Each ordinate is encoded in a single character as \fIvalue\fP+32.
For example, \*! is 1.
The screen coordinate system is 0-based.
.St
.IP \\*(Es\\*<
Exit VT52 mode (Enter VT100 mode).
.IP \\*(Es\\*=
Enter alternate keypad mode.
.IP \\*(Es\\*>
Exit alternate keypad mode.
.IP \\*(Es\\*A
Cursor up.
.IP \\*(Es\\*(cB
Cursor down.
.IP \\*(Es\\*C
Cursor right.
.IP \\*(Es\\*D
Cursor left.
.IP \\*(Es\\*F
Enter graphics mode.
.IP \\*(Es\\*G
Exit graphics mode.
.IP \\*(Es\\*H
Move the cursor to the home position.
.IP \\*(Es\\*I
Reverse line feed.
.IP \\*(Es\\*J
Erase from the cursor to the end of the screen.
.IP \\*(Es\\*K
Erase from the cursor to the end of the line.
.IP \\*(Es\\*Y\\*(Ps\\*s\\*(Ps
Move the cursor to given row and column.
.IP \\*(Es\\*Z
Identify.
  \(-> \*(Es\*s\*/\*s\*Z (\*(``I am a VT52.\*('').
.Ed
.
.if n .pl \n(nlu+1v
xterm-330/version.h0000644000175100001440000000400213122340744013071 0ustar  tomusers/* $XTermId: version.h,v 1.437 2017/06/21 00:46:28 tom Exp $ */

/*
 * Copyright 1998-2016,2017 by Thomas E. Dickey
 *
 *                         All Rights Reserved
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name(s) of the above copyright
 * holders shall not be used in advertising or otherwise to promote the
 * sale, use or other dealings in this Software without prior written
 * authorization.
 */

#ifndef included_version_h
#define included_version_h
/*
 * These definitions are used to build the string that's printed in response to
 * "xterm -version", or embedded in "xterm -help".  It usually indicates the
 * version of X to which this version of xterm has been built.  The resulting
 * number in parentheses is my patch number (Thomas E. Dickey).
 */
#define XTERM_PATCH   330
#define XTERM_DATE    2017-06-20

#ifndef __vendorversion__
#define __vendorversion__ "XTerm"
#endif

extern const char *xtermVersion(void);

#endif /* included_version_h */
xterm-330/koi8rxterm.man0000644000175100001440000000640712070430446014057 0ustar  tomusers.\" $XTermId: koi8rxterm.man,v 1.6 2013/01/01 00:43:18 tom Exp $
.\"
.\" Copyright 2004 Branden Robinson
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining a
.\" copy of this software and associated documentation files (the "Software"),
.\" to deal in the Software without restriction, including without limitation
.\" the rights to use, copy, modify, merge, publish, distribute, sublicense,
.\" and/or sell copies of the Software, and to permit persons to whom the
.\" Software is furnished to do so, subject to the following conditions:
.\"
.\" The above copyright notice and this permission notice shall be included in
.\" all copies or substantial portions of the Software.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
.\" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
.\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
.\" SOFTWARE IN THE PUBLIC INTEREST, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR
.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
.\" DEALINGS IN THE SOFTWARE.
.\"
.ds N Koi8rxterm
.ds n koi8rxterm
.\"
.ie \n(.g .ds AQ \(aq
.el       .ds AQ '
.ie \n(.g .ds `` \(lq
.el       .ds `` ``
.ie \n(.g .ds '' \(rq
.el       .ds '' ''
.\"
.TH KOI8RXTERM 1 "__app_date__" "__app_version__" "X Window System"
.SH NAME
koi8rxterm \- X terminal emulator for KOI8-R environments
.SH SYNOPSIS
.B \*n
[
.I xterm-options
]
.SH DESCRIPTION
.B \*n
is a wrapper around the
.BR xterm(1)
program that invokes the latter program with the \*(``KOI8R__default_class__\*('' X
resource class set.
All arguments to
.B \*n
are passed to
.B xterm
without processing; the
.B \-class
and
.B \-k8
options should not be specified because they are used by the wrapper.
See the
.BR xterm
manual page for more information on
.IR xterm-options .
.PP
The environment's locale settings (see \*(``ENVIRONMENT\*('' below) are
used to discern the locale's character set.
If no current locale can be determined, the locale \*(``ru_RU.KOI8-R\*(''
(the Russian language as used in the territory of Russia, with the KOI8-R
character set) is assumed.
The
.BR locale(1)
utility is used to determine whether the system supports the selected
locale.
If it does not,
.B \*n
will exit with an error and report the output of
.BR locale .
.PP
.B Note: \*n
may produce unexpected results if the current locale is set to one in which
the KOI8-R character encoding is not supported, or if fonts using that
encoding are not available.
In the Debian system, the \*(``xfonts\-cyrillic\*('' package provides the
fonts that
.B \*n
uses by default.
To change the fonts
.B \*n
uses, edit the
.I __apploaddir__/KOI8R__default_class__
file.
.PP
A similar wrapper,
.BR uxterm(1),
is available for Unicode UTF-8 environments.
.SH ENVIRONMENT
.TP
.B LC_ALL\fR, \fBLC_CTYPE\fR, \fBLANG
The values of these variables are checked, in order, to determine the
character set used by the current locale.
.SH AUTHOR
.B \*n
was written by Branden Robinson and is very heavily based on
.BR uxterm ,
by Thomas Dickey.
The assistance of Jurij Smakov was invaluable in sanity-checking its
operation.
.SH "SEE ALSO"
.BR locale(1),
.BR locale(7),
.BR uxterm(1),
.BR xterm(1)
xterm-330/ptydata.c0000644000175100001440000002777113121066144013065 0ustar  tomusers/* $XTermId: ptydata.c,v 1.107 2017/06/16 23:40:20 tom Exp $ */

/*
 * Copyright 1999-2016,2017 by Thomas E. Dickey
 *
 *                         All Rights Reserved
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name(s) of the above copyright
 * holders shall not be used in advertising or otherwise to promote the
 * sale, use or other dealings in this Software without prior written
 * authorization.
 */

#include 

#if OPT_WIDE_CHARS
#include 
#include 
#endif

/*
 * Check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX
 * systems are broken and return EWOULDBLOCK when they should return EAGAIN.
 * Note that this macro may evaluate its argument more than once.
 */
#if defined(EAGAIN) && defined(EWOULDBLOCK)
#define E_TEST(err) ((err) == EAGAIN || (err) == EWOULDBLOCK)
#else
#ifdef EAGAIN
#define E_TEST(err) ((err) == EAGAIN)
#else
#define E_TEST(err) ((err) == EWOULDBLOCK)
#endif
#endif

#if OPT_WIDE_CHARS
/*
 * Convert the 8-bit codes in data->buffer[] into Unicode in data->utf_data.
 * The number of bytes converted will be nonzero iff there is data.
 */
Bool
decodeUtf8(TScreen *screen, PtyData *data)
{
    int i;
    int length = (int) (data->last - data->next);
    int utf_count = 0;
    unsigned utf_char = 0;

    data->utf_size = 0;
    for (i = 0; i < length; i++) {
	unsigned c = data->next[i];

	/* Combine UTF-8 into Unicode */
	if (c < 0x80) {
	    /* We received an ASCII character */
	    if (utf_count > 0) {
		data->utf_data = UCS_REPL;	/* prev. sequence incomplete */
		data->utf_size = i;
	    } else {
		data->utf_data = (IChar) c;
		data->utf_size = 1;
	    }
	    break;
	} else if (c < 0xc0) {
	    /* We received a continuation byte */
	    if (utf_count < 1) {
		/*
		 * We received a continuation byte before receiving a sequence
		 * state.  Or an attempt to use a C1 control string.  Either
		 * way, it is mapped to the replacement character, unless
		 * allowed by optional feature.
		 */
		data->utf_data = (IChar) (screen->c1_printable ? c : UCS_REPL);
		data->utf_size = (i + 1);
		break;
	    } else {
		/* Check for overlong UTF-8 sequences for which a shorter
		 * encoding would exist and replace them with UCS_REPL.
		 * An overlong UTF-8 sequence can have any of the following
		 * forms:
		 *   1100000x 10xxxxxx
		 *   11100000 100xxxxx 10xxxxxx
		 *   11110000 1000xxxx 10xxxxxx 10xxxxxx
		 *   11111000 10000xxx 10xxxxxx 10xxxxxx 10xxxxxx
		 *   11111100 100000xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
		 */
		if (!utf_char && !((c & 0x7f) >> (7 - utf_count))) {
		    utf_char = UCS_REPL;
		}
		utf_char <<= 6;
		utf_char |= (c & 0x3f);
		if ((utf_char >= 0xd800 &&
		     utf_char <= 0xdfff) ||
		    (utf_char == 0xfffe) ||
		    (utf_char == HIDDEN_CHAR)) {
		    utf_char = UCS_REPL;
		}
		utf_count--;
		if (utf_count == 0) {
#if !OPT_WIDER_ICHAR
		    /* characters outside UCS-2 become UCS_REPL */
		    if (utf_char > 0xffff) {
			TRACE(("using replacement for %#x\n", utf_char));
			utf_char = UCS_REPL;
		    }
#endif
		    data->utf_data = (IChar) utf_char;
		    data->utf_size = (i + 1);
		    break;
		}
	    }
	} else {
	    /* We received a sequence start byte */
	    if (utf_count > 0) {
		data->utf_data = UCS_REPL;	/* prev. sequence incomplete */
		data->utf_size = (i + 1);
		break;
	    }
	    if (c < 0xe0) {
		utf_count = 1;
		utf_char = (c & 0x1f);
		if (!(c & 0x1e)) {
		    utf_char = UCS_REPL;	/* overlong sequence */
		}
	    } else if (c < 0xf0) {
		utf_count = 2;
		utf_char = (c & 0x0f);
	    } else if (c < 0xf8) {
		utf_count = 3;
		utf_char = (c & 0x07);
	    } else if (c < 0xfc) {
		utf_count = 4;
		utf_char = (c & 0x03);
	    } else if (c < 0xfe) {
		utf_count = 5;
		utf_char = (c & 0x01);
	    } else {
		data->utf_data = UCS_REPL;
		data->utf_size = (i + 1);
		break;
	    }
	}
    }
#if OPT_TRACE > 1
    TRACE(("UTF-8 char %04X [%d..%d]\n",
	   data->utf_data,
	   (int) (data->next - data->buffer),
	   (int) (data->next - data->buffer + data->utf_size - 1)));
#endif

    return (data->utf_size != 0);
}
#endif

int
readPtyData(XtermWidget xw, PtySelect * select_mask, PtyData *data)
{
    TScreen *screen = TScreenOf(xw);
    int size = 0;

#ifdef VMS
    if (*select_mask & pty_mask) {
	trimPtyData(xw, data);
	if (read_queue.flink != 0) {
	    size = tt_read(data->next);
	    if (size == 0) {
		Panic("input: read returned zero\n", 0);
	    }
	} else {
	    sys$hiber();
	}
    }
#else /* !VMS */
    if (FD_ISSET(screen->respond, select_mask)) {
	int save_err;
	trimPtyData(xw, data);

	size = (int) read(screen->respond, (char *) data->last, (size_t) FRG_SIZE);
	save_err = errno;
#if (defined(i386) && defined(SVR4) && defined(sun)) || defined(__CYGWIN__)
	/*
	 * Yes, I know this is a majorly f*ugly hack, however it seems to
	 * be necessary for Solaris x86.  DWH 11/15/94
	 * Dunno why though..
	 * (and now CYGWIN, alanh@xfree86.org 08/15/01
	 */
	if (size <= 0) {
	    if (save_err == EIO || save_err == 0)
		NormalExit();
	    else if (!E_TEST(save_err))
		Panic("input: read returned unexpected error (%d)\n", save_err);
	    size = 0;
	}
#else /* !f*ugly */
	if (size < 0) {
	    if (save_err == EIO)
		NormalExit();
	    else if (!E_TEST(save_err))
		Panic("input: read returned unexpected error (%d)\n", save_err);
	    size = 0;
	} else if (size == 0) {
#if defined(__FreeBSD__)
	    NormalExit();
#else
	    Panic("input: read returned zero\n", 0);
#endif
	}
#endif /* f*ugly */
    }
#endif /* VMS */

    if (size) {
#if OPT_TRACE
	int i;

	TRACE(("read %d bytes from pty\n", size));
	for (i = 0; i < size; i++) {
	    if (!(i % 16))
		TRACE(("%s", i ? "\n    " : "READ"));
	    TRACE((" %02X", data->last[i]));
	}
	TRACE(("\n"));
#endif
	data->last += size;
#ifdef ALLOWLOGGING
	TScreenOf(term)->logstart = VTbuffer->next;
#endif
    }

    return (size);
}

/*
 * Return the next value from the input buffer.  Note that morePtyData() is
 * always called before this function, so we can do the UTF-8 input conversion
 * in that function and simply return the result here.
 */
#if OPT_WIDE_CHARS
IChar
nextPtyData(TScreen *screen, PtyData *data)
{
    IChar result;
    if (screen->utf8_inparse) {
	result = skipPtyData(data);
    } else {
	result = *((data)->next++);
	if (!screen->output_eight_bits) {
	    result = (IChar) (result & 0x7f);
	}
    }
    TRACE2(("nextPtyData returns %#x\n", result));
    return result;
}

/*
 * Simply return the data and skip past it.
 */
IChar
skipPtyData(PtyData *data)
{
    IChar result = data->utf_data;

    data->next += data->utf_size;
    data->utf_size = 0;

    return result;
}
#endif

#if OPT_WIDE_CHARS
/*
 * Called when UTF-8 mode has been turned on/off.
 */
void
switchPtyData(TScreen *screen, int flag)
{
    if (screen->utf8_mode != flag) {
	screen->utf8_mode = flag;
	screen->utf8_inparse = (Boolean) (flag != 0);
	mk_wcwidth_init(screen->utf8_mode);

	TRACE(("turning UTF-8 mode %s\n", BtoS(flag)));
	update_font_utf8_mode();
    }
}
#endif

/*
 * Allocate a buffer.
 */
void
initPtyData(PtyData **result)
{
    PtyData *data;

    TRACE(("initPtyData given minBufSize %d, maxBufSize %d\n",
	   FRG_SIZE, BUF_SIZE));

    if (FRG_SIZE < 64)
	FRG_SIZE = 64;
    if (BUF_SIZE < FRG_SIZE)
	BUF_SIZE = FRG_SIZE;
    if (BUF_SIZE % FRG_SIZE)
	BUF_SIZE = BUF_SIZE + FRG_SIZE - (BUF_SIZE % FRG_SIZE);

    TRACE(("initPtyData using minBufSize %d, maxBufSize %d\n",
	   FRG_SIZE, BUF_SIZE));

    data = TypeXtMallocX(PtyData, (BUF_SIZE + FRG_SIZE));

    memset(data, 0, sizeof(*data));
    data->next = data->buffer;
    data->last = data->buffer;
    *result = data;
}

/*
 * Initialize a buffer for the caller, using its data in 'next'.
 */
#if OPT_WIDE_CHARS
PtyData *
fakePtyData(PtyData *result, Char *next, Char *last)
{
    PtyData *data = result;

    memset(data, 0, sizeof(*data));
    data->next = next;
    data->last = last;

    return data;
}
#endif

/*
 * Remove used data by shifting the buffer down, to make room for more data,
 * e.g., a continuation-read.
 */
void
trimPtyData(XtermWidget xw GCC_UNUSED, PtyData *data)
{
    FlushLog(xw);

    if (data->next != data->buffer) {
	int i;
	int n = (int) (data->last - data->next);

	TRACE(("shifting buffer down by %d\n", n));
	for (i = 0; i < n; ++i) {
	    data->buffer[i] = data->next[i];
	}
	data->next = data->buffer;
	data->last = data->next + n;
    }

}

/*
 * Insert new data into the input buffer so the next calls to morePtyData()
 * and nextPtyData() will return that.
 */
void
fillPtyData(XtermWidget xw, PtyData *data, const char *value, int length)
{
    int size;
    int n;

    /* remove the used portion of the buffer */
    trimPtyData(xw, data);

    VTbuffer->last += length;
    size = (int) (VTbuffer->last - VTbuffer->next);

    /* shift the unused portion up to make room */
    for (n = size; n >= length; --n)
	VTbuffer->next[n] = VTbuffer->next[n - length];

    /* insert the new bytes to interpret */
    for (n = 0; n < length; n++)
	VTbuffer->next[n] = CharOf(value[n]);
}

#if OPT_WIDE_CHARS
Char *
convertToUTF8(Char *lp, unsigned c)
{
#define CH(n) (Char)((c) >> ((n) * 8))
    if (c < 0x80) {
	/*  0*******  */
	*lp++ = (Char) CH(0);
    } else if (c < 0x800) {
	/*  110***** 10******  */
	*lp++ = (Char) (0xc0 | (CH(0) >> 6) | ((CH(1) & 0x07) << 2));
	*lp++ = (Char) (0x80 | (CH(0) & 0x3f));
    } else if (c < 0x00010000) {
	/*  1110**** 10****** 10******  */
	*lp++ = (Char) (0xe0 | ((int) (CH(1) & 0xf0) >> 4));
	*lp++ = (Char) (0x80 | (CH(0) >> 6) | ((CH(1) & 0x0f) << 2));
	*lp++ = (Char) (0x80 | (CH(0) & 0x3f));
    } else if (c < 0x00200000) {
	*lp++ = (Char) (0xf0 | ((int) (CH(2) & 0x1f) >> 2));
	*lp++ = (Char) (0x80 |
			((int) (CH(1) & 0xf0) >> 4) |
			((int) (CH(2) & 0x03) << 4));
	*lp++ = (Char) (0x80 | (CH(0) >> 6) | ((CH(1) & 0x0f) << 2));
	*lp++ = (Char) (0x80 | (CH(0) & 0x3f));
    } else if (c < 0x04000000) {
	*lp++ = (Char) (0xf8 | (CH(3) & 0x03));
	*lp++ = (Char) (0x80 | (CH(2) >> 2));
	*lp++ = (Char) (0x80 |
			((int) (CH(1) & 0xf0) >> 4) |
			((int) (CH(2) & 0x03) << 4));
	*lp++ = (Char) (0x80 | (CH(0) >> 6) | ((CH(1) & 0x0f) << 2));
	*lp++ = (Char) (0x80 | (CH(0) & 0x3f));
    } else {
	*lp++ = (Char) (0xfc | ((int) (CH(3) & 0x40) >> 6));
	*lp++ = (Char) (0x80 | (CH(3) & 0x3f));
	*lp++ = (Char) (0x80 | (CH(2) >> 2));
	*lp++ = (Char) (0x80 | (CH(1) >> 4) | ((CH(2) & 0x03) << 4));
	*lp++ = (Char) (0x80 | (CH(0) >> 6) | ((CH(1) & 0x0f) << 2));
	*lp++ = (Char) (0x80 | (CH(0) & 0x3f));
    }
    return lp;
#undef CH
}

/*
 * Write data back to the PTY
 */
void
writePtyData(int f, IChar *d, unsigned len)
{
    unsigned n = (len << 1);

    if (VTbuffer->write_len <= len) {
	VTbuffer->write_len = n;
	VTbuffer->write_buf = (Char *) XtRealloc((char *)
						 VTbuffer->write_buf, VTbuffer->write_len);
    }

    for (n = 0; n < len; n++)
	VTbuffer->write_buf[n] = (Char) d[n];

    TRACE(("writePtyData %d:%s\n", n,
	   visibleChars(VTbuffer->write_buf, n)));
    v_write(f, VTbuffer->write_buf, n);
}
#endif /* OPT_WIDE_CHARS */

#ifdef NO_LEAKS
void
noleaks_ptydata(void)
{
    if (VTbuffer != 0) {
#if OPT_WIDE_CHARS
	if (VTbuffer->write_buf != 0)
	    free(VTbuffer->write_buf);
#endif
	free(VTbuffer);
	VTbuffer = 0;
    }
}
#endif
xterm-330/aclocal.m40000644000175100001440000042110313102215030013063 0ustar  tomusersdnl $XTermId: aclocal.m4,v 1.413 2017/05/02 23:45:28 tom Exp $
dnl
dnl ---------------------------------------------------------------------------
dnl
dnl Copyright 1997-2016,2017 by Thomas E. Dickey
dnl
dnl                         All Rights Reserved
dnl
dnl Permission is hereby granted, free of charge, to any person obtaining a
dnl copy of this software and associated documentation files (the
dnl "Software"), to deal in the Software without restriction, including
dnl without limitation the rights to use, copy, modify, merge, publish,
dnl distribute, sublicense, and/or sell copies of the Software, and to
dnl permit persons to whom the Software is furnished to do so, subject to
dnl the following conditions:
dnl
dnl The above copyright notice and this permission notice shall be included
dnl in all copies or substantial portions of the Software.
dnl
dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
dnl IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
dnl CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
dnl TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
dnl SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
dnl
dnl Except as contained in this notice, the name(s) of the above copyright
dnl holders shall not be used in advertising or otherwise to promote the
dnl sale, use or other dealings in this Software without prior written
dnl authorization.
dnl
dnl ---------------------------------------------------------------------------
dnl See
dnl		http://invisible-island.net/autoconf/autoconf.html
dnl ---------------------------------------------------------------------------
dnl ---------------------------------------------------------------------------
dnl AM_LANGINFO_CODESET version: 4 updated: 2015/04/18 08:56:57
dnl -------------------
dnl Inserted as requested by gettext 0.10.40
dnl File from /usr/share/aclocal
dnl codeset.m4
dnl ====================
dnl serial AM1
dnl
dnl From Bruno Haible.
AC_DEFUN([AM_LANGINFO_CODESET],
[
AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
	[AC_TRY_LINK([#include ],
	[char* cs = nl_langinfo(CODESET);],
	am_cv_langinfo_codeset=yes,
	am_cv_langinfo_codeset=no)
	])
	if test $am_cv_langinfo_codeset = yes; then
		AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
		[Define if you have  and nl_langinfo(CODESET).])
	fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_ACVERSION_CHECK version: 5 updated: 2014/06/04 19:11:49
dnl ------------------
dnl Conditionally generate script according to whether we're using a given autoconf.
dnl
dnl $1 = version to compare against
dnl $2 = code to use if AC_ACVERSION is at least as high as $1.
dnl $3 = code to use if AC_ACVERSION is older than $1.
define([CF_ACVERSION_CHECK],
[
ifdef([AC_ACVERSION], ,[ifdef([AC_AUTOCONF_VERSION],[m4_copy([AC_AUTOCONF_VERSION],[AC_ACVERSION])],[m4_copy([m4_PACKAGE_VERSION],[AC_ACVERSION])])])dnl
ifdef([m4_version_compare],
[m4_if(m4_version_compare(m4_defn([AC_ACVERSION]), [$1]), -1, [$3], [$2])],
[CF_ACVERSION_COMPARE(
AC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])),
AC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)), AC_ACVERSION, [$2], [$3])])])dnl
dnl ---------------------------------------------------------------------------
dnl CF_ACVERSION_COMPARE version: 3 updated: 2012/10/03 18:39:53
dnl --------------------
dnl CF_ACVERSION_COMPARE(MAJOR1, MINOR1, TERNARY1,
dnl                      MAJOR2, MINOR2, TERNARY2,
dnl                      PRINTABLE2, not FOUND, FOUND)
define([CF_ACVERSION_COMPARE],
[ifelse(builtin([eval], [$2 < $5]), 1,
[ifelse([$8], , ,[$8])],
[ifelse([$9], , ,[$9])])])dnl
dnl ---------------------------------------------------------------------------
dnl CF_ADD_CFLAGS version: 13 updated: 2017/02/25 18:57:40
dnl -------------
dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
dnl The second parameter if given makes this macro verbose.
dnl
dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
dnl confused by the quotes (which require backslashes to keep them usable).
AC_DEFUN([CF_ADD_CFLAGS],
[
cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $1
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then
				CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then
				CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
				CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
				;;
			esac
			CF_APPEND_TEXT(cf_new_cppflags,$cf_add_cflags)
			;;
		esac
		;;
	(*)
		CF_APPEND_TEXT(cf_new_cflags,$cf_add_cflags)
		;;
	esac
	;;
(yes)
	CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then
	ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
	CF_APPEND_TEXT(CFLAGS,$cf_new_cflags)
fi

if test -n "$cf_new_cppflags" ; then
	ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
	CF_APPEND_TEXT(CPPFLAGS,$cf_new_cppflags)
fi

if test -n "$cf_new_extra_cppflags" ; then
	ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
	CF_APPEND_TEXT(EXTRA_CPPFLAGS,$cf_new_extra_cppflags)
fi

AC_SUBST(EXTRA_CPPFLAGS)

])dnl
dnl ---------------------------------------------------------------------------
dnl CF_ADD_LIB version: 2 updated: 2010/06/02 05:03:05
dnl ----------
dnl Add a library, used to enforce consistency.
dnl
dnl $1 = library to add, without the "-l"
dnl $2 = variable to update (default $LIBS)
AC_DEFUN([CF_ADD_LIB],[CF_ADD_LIBS(-l$1,ifelse($2,,LIBS,[$2]))])dnl
dnl ---------------------------------------------------------------------------
dnl CF_ADD_LIBS version: 2 updated: 2014/07/13 14:33:27
dnl -----------
dnl Add one or more libraries, used to enforce consistency.  Libraries are
dnl prepended to an existing list, since their dependencies are assumed to
dnl already exist in the list.
dnl
dnl $1 = libraries to add, with the "-l", etc.
dnl $2 = variable to update (default $LIBS)
AC_DEFUN([CF_ADD_LIBS],[
cf_add_libs="$1"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in [$]ifelse($2,,LIBS,[$2])
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
ifelse($2,,LIBS,[$2])="$cf_add_libs"
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_ADD_LIB_AFTER version: 3 updated: 2013/07/09 21:27:22
dnl ----------------
dnl Add a given library after another, e.g., following the one it satisfies a
dnl dependency for.
dnl
dnl $1 = the first library
dnl $2 = its dependency
AC_DEFUN([CF_ADD_LIB_AFTER],[
CF_VERBOSE(...before $LIBS)
LIBS=`echo "$LIBS" | sed -e "s/[[ 	]][[ 	]]*/ /g" -e "s%$1 %$1 $2 %" -e 's%  % %g'`
CF_VERBOSE(...after  $LIBS)
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_APPEND_TEXT version: 1 updated: 2017/02/25 18:58:55
dnl --------------
dnl use this macro for appending text without introducing an extra blank at
dnl the beginning
define([CF_APPEND_TEXT],
[
	test -n "[$]$1" && $1="[$]$1 "
	$1="[$]{$1}$2"
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
dnl --------------
dnl Allow user to disable a normally-on option.
AC_DEFUN([CF_ARG_DISABLE],
[CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
dnl ---------------------------------------------------------------------------
dnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
dnl -------------
dnl Allow user to enable a normally-off option.
AC_DEFUN([CF_ARG_ENABLE],
[CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
dnl ---------------------------------------------------------------------------
dnl CF_ARG_OPTION version: 5 updated: 2015/05/10 19:52:14
dnl -------------
dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
dnl values.
dnl
dnl Parameters:
dnl $1 = option name
dnl $2 = help-string
dnl $3 = action to perform if option is not default
dnl $4 = action if perform if option is default
dnl $5 = default option value (either 'yes' or 'no')
AC_DEFUN([CF_ARG_OPTION],
[AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
	if test "$enableval" != "$5" ; then
ifelse([$3],,[    :]dnl
,[    $3]) ifelse([$4],,,[
	else
		$4])
	fi],[enableval=$5 ifelse([$4],,,[
	$4
])dnl
])])dnl
dnl ---------------------------------------------------------------------------
dnl CF_CC_ENV_FLAGS version: 7 updated: 2017/02/25 18:57:40
dnl ---------------
dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
dnl into CC.  This will not help with broken scripts that wrap the compiler
dnl with options, but eliminates a more common category of user confusion.
dnl
dnl In particular, it addresses the problem of being able to run the C
dnl preprocessor in a consistent manner.
dnl
dnl Caveat: this also disallows blanks in the pathname for the compiler, but
dnl the nuisance of having inconsistent settings for compiler and preprocessor
dnl outweighs that limitation.
AC_DEFUN([CF_CC_ENV_FLAGS],
[
# This should have been defined by AC_PROG_CC
: ${CC:=cc}

AC_MSG_CHECKING(\$CC variable)
case "$CC" in
(*[[\ \	]]-*)
	AC_MSG_RESULT(broken)
	AC_MSG_WARN(your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options)
	# humor him...
	cf_prog=`echo "$CC" | sed -e 's/	/ /g' -e 's/[[ ]]* / /g' -e 's/[[ ]]*[[ ]]-[[^ ]].*//'`
	cf_flags=`echo "$CC" | ${AWK:-awk} -v prog="$cf_prog" '{ printf("%s", substr([$]0,1+length(prog))); }'`
	CC="$cf_prog"
	for cf_arg in $cf_flags
	do
		case "x$cf_arg" in
		(x-[[IUDfgOW]]*)
			CF_ADD_CFLAGS($cf_arg)
			;;
		(*)
			CC="$CC $cf_arg"
			;;
		esac
	done
	CF_VERBOSE(resulting CC: '$CC')
	CF_VERBOSE(resulting CFLAGS: '$CFLAGS')
	CF_VERBOSE(resulting CPPFLAGS: '$CPPFLAGS')
	;;
(*)
	AC_MSG_RESULT(ok)
	;;
esac
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_CHECK_CACHE version: 12 updated: 2012/10/02 20:55:03
dnl --------------
dnl Check if we're accidentally using a cache from a different machine.
dnl Derive the system name, as a check for reusing the autoconf cache.
dnl
dnl If we've packaged config.guess and config.sub, run that (since it does a
dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
dnl which is useful in cross-compiles.
dnl
dnl Note: we would use $ac_config_sub, but that is one of the places where
dnl autoconf 2.5x broke compatibility with autoconf 2.13
AC_DEFUN([CF_CHECK_CACHE],
[
if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
	ifelse([$1],,[AC_CANONICAL_HOST],[$1])
	system_name="$host_os"
else
	system_name="`(uname -s -r) 2>/dev/null`"
	if test -z "$system_name" ; then
		system_name="`(hostname) 2>/dev/null`"
	fi
fi
test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.])
AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])

test -z "$system_name" && system_name="$cf_cv_system_name"
test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)

if test ".$system_name" != ".$cf_cv_system_name" ; then
	AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
	AC_MSG_ERROR("Please remove config.cache and try again.")
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_CHECK_CFLAGS version: 3 updated: 2014/07/22 05:32:57
dnl ---------------
dnl Conditionally add to $CFLAGS and $CPPFLAGS values which are derived from
dnl a build-configuration such as imake.  These have the pitfall that they
dnl often contain compiler-specific options which we cannot use, mixed with
dnl preprocessor options that we usually can.
AC_DEFUN([CF_CHECK_CFLAGS],
[
CF_VERBOSE(checking additions to CFLAGS)
cf_check_cflags="$CFLAGS"
cf_check_cppflags="$CPPFLAGS"
CF_ADD_CFLAGS($1,yes)
if test "x$cf_check_cflags" != "x$CFLAGS" ; then
AC_TRY_LINK([#include ],[printf("Hello world");],,
	[CF_VERBOSE(test-compile failed.  Undoing change to \$CFLAGS)
	 if test "x$cf_check_cppflags" != "x$CPPFLAGS" ; then
		 CF_VERBOSE(but keeping change to \$CPPFLAGS)
	 fi
	 CFLAGS="$cf_check_flags"])
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_CHECK_ERRNO version: 12 updated: 2015/04/18 08:56:57
dnl --------------
dnl Check for data that is usually declared in  or , e.g.,
dnl the 'errno' variable.  Define a DECL_xxx symbol if we must declare it
dnl ourselves.
dnl
dnl $1 = the name to check
dnl $2 = the assumed type
AC_DEFUN([CF_CHECK_ERRNO],
[
AC_CACHE_CHECK(if external $1 is declared, cf_cv_dcl_$1,[
	AC_TRY_COMPILE([
#ifdef HAVE_STDLIB_H
#include 
#endif
#include 
#include 
#include  ],
	ifelse([$2],,int,[$2]) x = (ifelse([$2],,int,[$2])) $1,
	[cf_cv_dcl_$1=yes],
	[cf_cv_dcl_$1=no])
])

if test "$cf_cv_dcl_$1" = no ; then
	CF_UPPER(cf_result,decl_$1)
	AC_DEFINE_UNQUOTED($cf_result)
fi

# It's possible (for near-UNIX clones) that the data doesn't exist
CF_CHECK_EXTERN_DATA($1,ifelse([$2],,int,[$2]))
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_CHECK_EXTERN_DATA version: 4 updated: 2015/04/18 08:56:57
dnl --------------------
dnl Check for existence of external data in the current set of libraries.  If
dnl we can modify it, it's real enough.
dnl $1 = the name to check
dnl $2 = its type
AC_DEFUN([CF_CHECK_EXTERN_DATA],
[
AC_CACHE_CHECK(if external $1 exists, cf_cv_have_$1,[
	AC_TRY_LINK([
#undef $1
extern $2 $1;
],
	[$1 = 2],
	[cf_cv_have_$1=yes],
	[cf_cv_have_$1=no])
])

if test "$cf_cv_have_$1" = yes ; then
	CF_UPPER(cf_result,have_$1)
	AC_DEFINE_UNQUOTED($cf_result)
fi

])dnl
dnl ---------------------------------------------------------------------------
dnl CF_CLANG_COMPILER version: 2 updated: 2013/11/19 19:23:35
dnl -----------------
dnl Check if the given compiler is really clang.  clang's C driver defines
dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
dnl not ignore some gcc options.
dnl
dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
dnl the wrappers for gcc and g++ warnings.
dnl
dnl $1 = GCC (default) or GXX
dnl $2 = CLANG_COMPILER (default)
dnl $3 = CFLAGS (default) or CXXFLAGS
AC_DEFUN([CF_CLANG_COMPILER],[
ifelse([$2],,CLANG_COMPILER,[$2])=no

if test "$ifelse([$1],,[$1],GCC)" = yes ; then
	AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler)
	cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
	ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -Qunused-arguments"
	AC_TRY_COMPILE([],[
#ifdef __clang__
#else
make an error
#endif
],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
cf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments"
],[])
	ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
	AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
fi
])
dnl ---------------------------------------------------------------------------
dnl CF_DISABLE_DESKTOP version: 2 updated: 2011/04/22 05:17:37
dnl ------------------
dnl Handle a configure option "--disable-desktop", which sets a shell
dnl variable $desktop_utils to a "#" if the feature is not wanted, or to an
dnl empty string if enabled.  The variable is used to substitute in front of
dnl corresponding makefile-rules.
dnl
dnl It also tells the configure script to substitute the environment variable
dnl $DESKTOP_FLAGS, which can be used by external scripts to customize the
dnl invocation of desktop-file-util.
dnl
dnl $1 = program name
AC_DEFUN([CF_DISABLE_DESKTOP],[
# Comment-out the install-desktop rule if the desktop-utils are not found.
AC_MSG_CHECKING(if you want to install desktop files)
CF_ARG_OPTION(desktop,
	[  --disable-desktop       disable install of $1 desktop files],
	[enable_desktop=$enableval],
	[enable_desktop=$enableval],yes)
AC_MSG_RESULT($enable_desktop)

desktop_utils=
if test "$enable_desktop" = yes ; then
AC_CHECK_PROG(desktop_utils,desktop-file-install,yes,no)
fi

test "$desktop_utils" = yes && desktop_utils= || desktop_utils="#"
AC_SUBST(DESKTOP_FLAGS)
])
dnl ---------------------------------------------------------------------------
dnl CF_DISABLE_ECHO version: 13 updated: 2015/04/18 08:56:57
dnl ---------------
dnl You can always use "make -n" to see the actual options, but it's hard to
dnl pick out/analyze warning messages when the compile-line is long.
dnl
dnl Sets:
dnl	ECHO_LT - symbol to control if libtool is verbose
dnl	ECHO_LD - symbol to prefix "cc -o" lines
dnl	RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
dnl	SHOW_CC - symbol to put before explicit "cc -c" lines
dnl	ECHO_CC - symbol to put before any "cc" line
dnl
AC_DEFUN([CF_DISABLE_ECHO],[
AC_MSG_CHECKING(if you want to see long compiling messages)
CF_ARG_DISABLE(echo,
	[  --disable-echo          do not display "compiling" commands],
	[
	ECHO_LT='--silent'
	ECHO_LD='@echo linking [$]@;'
	RULE_CC='@echo compiling [$]<'
	SHOW_CC='@echo compiling [$]@'
	ECHO_CC='@'
],[
	ECHO_LT=''
	ECHO_LD=''
	RULE_CC=''
	SHOW_CC=''
	ECHO_CC=''
])
AC_MSG_RESULT($enableval)
AC_SUBST(ECHO_LT)
AC_SUBST(ECHO_LD)
AC_SUBST(RULE_CC)
AC_SUBST(SHOW_CC)
AC_SUBST(ECHO_CC)
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_DISABLE_LEAKS version: 7 updated: 2012/10/02 20:55:03
dnl ----------------
dnl Combine no-leak checks with the libraries or tools that are used for the
dnl checks.
AC_DEFUN([CF_DISABLE_LEAKS],[

AC_REQUIRE([CF_WITH_DMALLOC])
AC_REQUIRE([CF_WITH_DBMALLOC])
AC_REQUIRE([CF_WITH_VALGRIND])

AC_MSG_CHECKING(if you want to perform memory-leak testing)
AC_ARG_ENABLE(leaks,
	[  --disable-leaks         test: free permanent memory, analyze leaks],
	[if test "x$enableval" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi],
	: ${with_no_leaks:=no})
AC_MSG_RESULT($with_no_leaks)

if test "$with_no_leaks" = yes ; then
	AC_DEFINE(NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
	AC_DEFINE(YY_NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_DISABLE_RPATH_HACK version: 2 updated: 2011/02/13 13:31:33
dnl ---------------------
dnl The rpath-hack makes it simpler to build programs, particularly with the
dnl *BSD ports which may have essential libraries in unusual places.  But it
dnl can interfere with building an executable for the base system.  Use this
dnl option in that case.
AC_DEFUN([CF_DISABLE_RPATH_HACK],
[
AC_MSG_CHECKING(if rpath-hack should be disabled)
CF_ARG_DISABLE(rpath-hack,
	[  --disable-rpath-hack    don't add rpath options for additional libraries],
	[cf_disable_rpath_hack=yes],
	[cf_disable_rpath_hack=no])
AC_MSG_RESULT($cf_disable_rpath_hack)
if test "$cf_disable_rpath_hack" = no ; then
	CF_RPATH_HACK
fi
])
dnl ---------------------------------------------------------------------------
dnl CF_ENABLE_NARROWPROTO version: 5 updated: 2015/04/12 15:39:00
dnl ---------------------
dnl If this is not set properly, Xaw's scrollbars will not work.
dnl The so-called "modular" configuration for X.org omits most of the
dnl configure checks that would be needed to provide compatibility with
dnl older X builds.  This one breaks things noticeably.
AC_DEFUN([CF_ENABLE_NARROWPROTO],
[
AC_MSG_CHECKING(if you want narrow prototypes for X libraries)

case `$ac_config_guess` in
(*freebsd*|*gnu*|*irix5*|*irix6*|*linux-gnu*|*netbsd*|*openbsd*|*qnx*|*sco*|*sgi*)
	cf_default_narrowproto=yes
	;;
(*)
	cf_default_narrowproto=no
	;;
esac

CF_ARG_OPTION(narrowproto,
	[  --enable-narrowproto    enable narrow prototypes for X libraries],
	[enable_narrowproto=$enableval],
	[enable_narrowproto=$cf_default_narrowproto],
	[$cf_default_narrowproto])
AC_MSG_RESULT($enable_narrowproto)
])
dnl ---------------------------------------------------------------------------
dnl CF_ERRNO version: 5 updated: 1997/11/30 12:44:39
dnl --------
dnl Check if 'errno' is declared in 
AC_DEFUN([CF_ERRNO],
[
CF_CHECK_ERRNO(errno)
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_FUNC_GRANTPT version: 11 updated: 2015/04/12 15:39:00
dnl ---------------
dnl Check for grantpt versus openpty, as well as functions that "should" be
dnl available if grantpt is available.
AC_DEFUN([CF_FUNC_GRANTPT],[

AC_CHECK_HEADERS( \
stropts.h \
)

cf_func_grantpt="grantpt ptsname"
case $host_os in
(darwin[[0-9]].*)
	;;
(*)
	cf_func_grantpt="$cf_func_grantpt posix_openpt"
	;;
esac

AC_CHECK_FUNCS($cf_func_grantpt)

cf_grantpt_opts=
if test "x$ac_cv_func_grantpt" = "xyes" ; then
	AC_MSG_CHECKING(if grantpt really works)
	AC_TRY_LINK(CF__GRANTPT_HEAD,CF__GRANTPT_BODY,[
	AC_TRY_RUN(CF__GRANTPT_HEAD
int main(void)
{
CF__GRANTPT_BODY
}
,
,ac_cv_func_grantpt=no
,ac_cv_func_grantpt=maybe)
	],ac_cv_func_grantpt=no)
	AC_MSG_RESULT($ac_cv_func_grantpt)

	if test "x$ac_cv_func_grantpt" != "xno" ; then

		if test "x$ac_cv_func_grantpt" = "xyes" ; then
			AC_MSG_CHECKING(for pty features)
dnl if we have no stropts.h, skip the checks for streams modules
			if test "x$ac_cv_header_stropts_h" = xyes
			then
				cf_pty_this=0
			else
				cf_pty_this=3
			fi

			cf_pty_defines=
			while test $cf_pty_this != 6
			do

				cf_pty_feature=
				cf_pty_next=`expr $cf_pty_this + 1`
				CF_MSG_LOG(pty feature test $cf_pty_next:5)
				AC_TRY_RUN(#define CONFTEST $cf_pty_this
$cf_pty_defines
CF__GRANTPT_HEAD
int main(void)
{
CF__GRANTPT_BODY
}
,
[
				case $cf_pty_next in
				(1) # - streams
					cf_pty_feature=ptem
					;;
				(2) # - streams
					cf_pty_feature=ldterm
					;;
				(3) # - streams
					cf_pty_feature=ttcompat
					;;
				(4)
					cf_pty_feature=pty_isatty
					;;
				(5)
					cf_pty_feature=pty_tcsetattr
					;;
				(6)
					cf_pty_feature=tty_tcsetattr
					;;
				esac
],[
				case $cf_pty_next in
				(1|2|3)
					CF_MSG_LOG(skipping remaining streams features $cf_pty_this..2)
					cf_pty_next=3
					;;
				esac
])
				if test -n "$cf_pty_feature"
				then
					cf_pty_defines="$cf_pty_defines
#define CONFTEST_$cf_pty_feature 1
"
					cf_grantpt_opts="$cf_grantpt_opts $cf_pty_feature"
				fi

				cf_pty_this=$cf_pty_next
			done
			AC_MSG_RESULT($cf_grantpt_opts)
			cf_grantpt_opts=`echo "$cf_grantpt_opts" | sed -e 's/ isatty//'`
		fi
	fi
fi

dnl If we found grantpt, but no features, e.g., for streams or if we are not
dnl able to use tcsetattr, then give openpty a try.  In particular, Darwin 10.7
dnl has a more functional openpty than posix_openpt.
dnl
dnl There is no configure run-test for openpty, since older implementations do
dnl not always run properly as a non-root user.  For that reason, we also allow
dnl the configure script to suppress this check entirely with $disable_openpty.
if test "x$disable_openpty" != "xyes" || test -z "$cf_grantpt_opts" ; then
	AC_CHECK_LIB(util, openpty, [cf_have_openpty=yes],[cf_have_openpty=no])
	if test "$cf_have_openpty" = yes ; then
		ac_cv_func_grantpt=no
		LIBS="-lutil $LIBS"
		AC_DEFINE(HAVE_OPENPTY,1,[Define to 1 if you have the openpty function])
		AC_CHECK_HEADERS( \
			util.h \
			libutil.h \
			pty.h \
		)
	fi
fi

dnl If we did not settle on using openpty, fill in the definitions for grantpt.
if test "x$ac_cv_func_grantpt" != xno
then
	CF_VERBOSE(will rely upon grantpt)
	AC_DEFINE(HAVE_WORKING_GRANTPT,1,[Define to 1 if the grantpt function seems to work])
	for cf_feature in $cf_grantpt_opts
	do
		cf_feature=`echo "$cf_feature" | sed -e 's/ //g'`
		CF_UPPER(cf_FEATURE,$cf_feature)
		AC_DEFINE_UNQUOTED(HAVE_GRANTPT_$cf_FEATURE)
	done
elif test "x$cf_have_openpty" = xno
then
	CF_VERBOSE(will rely upon BSD-pseudoterminals)
else
	CF_VERBOSE(will rely upon openpty)
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_FUNC_TGETENT version: 21 updated: 2015/09/12 14:59:46
dnl ---------------
dnl Check for tgetent function in termcap library.  If we cannot find this,
dnl we'll use the $LINES and $COLUMNS environment variables to pass screen
dnl size information to subprocesses.  (We cannot use terminfo's compatibility
dnl function, since it cannot provide the termcap-format data).
dnl
dnl If the --disable-full-tgetent option is given, we'll settle for the first
dnl tgetent function we find.  Since the search list in that case does not
dnl include the termcap library, that allows us to default to terminfo.
AC_DEFUN([CF_FUNC_TGETENT],
[
# compute a reasonable value for $TERM to give tgetent(), since we may be
# running in 'screen', which sets $TERMCAP to a specific entry that is not
# necessarily in /etc/termcap - unsetenv is not portable, so we cannot simply
# discard $TERMCAP.
cf_TERMVAR=vt100
if test -n "$TERMCAP"
then
	cf_TERMCAP=`echo "$TERMCAP" | tr '\n' ' ' | sed -e 's/^..|//' -e 's/|.*//'`
	case "$cf_TERMCAP" in
	(screen*.*)
		;;
	(*)
		cf_TERMVAR="$cf_TERMCAP"
		;;
	esac
fi
test -z "$cf_TERMVAR" && cf_TERMVAR=vt100

AC_MSG_CHECKING(if we want full tgetent function)
CF_ARG_DISABLE(full-tgetent,
	[  --disable-full-tgetent  disable check for full tgetent function],
	cf_full_tgetent=no,
	cf_full_tgetent=yes,yes)
AC_MSG_RESULT($cf_full_tgetent)

if test "$cf_full_tgetent" = yes ; then
	cf_test_message="full tgetent"
else
	cf_test_message="tgetent"
fi

AC_CACHE_CHECK(for $cf_test_message function,cf_cv_lib_tgetent,[
cf_save_LIBS="$LIBS"
cf_cv_lib_tgetent=no
if test "$cf_full_tgetent" = yes ; then
	cf_TERMLIB="otermcap termcap termlib ncurses curses"
	cf_TERMTST="buffer[[0]] == 0"
else
	cf_TERMLIB="termlib ncurses curses"
	cf_TERMTST="0"
fi
for cf_termlib in '' $cf_TERMLIB ; do
	LIBS="$cf_save_LIBS"
	test -n "$cf_termlib" && { CF_ADD_LIB($cf_termlib) }
	AC_TRY_RUN([
/* terminfo implementations ignore the buffer argument, making it useless for
 * the xterm application, which uses this information to make a new TERMCAP
 * environment variable.
 */
int main()
{
	char buffer[1024];
	buffer[0] = 0;
	tgetent(buffer, "$cf_TERMVAR");
	${cf_cv_main_return:-return} ($cf_TERMTST); }],
	[echo "yes, there is a termcap/tgetent in $cf_termlib" 1>&AC_FD_CC
	 if test -n "$cf_termlib" ; then
	 	cf_cv_lib_tgetent="-l$cf_termlib"
	 else
	 	cf_cv_lib_tgetent=yes
	 fi
	 break],
	[echo "no, there is no termcap/tgetent in $cf_termlib" 1>&AC_FD_CC],
	[echo "cross-compiling, cannot verify if a termcap/tgetent is present in $cf_termlib" 1>&AC_FD_CC])
done
LIBS="$cf_save_LIBS"
])

# If we found a working tgetent(), set LIBS and check for termcap.h.
# (LIBS cannot be set inside AC_CACHE_CHECK; the commands there should
# not have side effects other than setting the cache variable, because
# they are not executed when a cached value exists.)
if test "x$cf_cv_lib_tgetent" != xno ; then
	test "x$cf_cv_lib_tgetent" != xyes && { CF_ADD_LIBS($cf_cv_lib_tgetent) }
	AC_DEFINE(USE_TERMCAP,1,[Define 1 to indicate that working tgetent is found])
	if test "$cf_full_tgetent" = no ; then
		AC_TRY_COMPILE([
#include ],[
#ifdef NCURSES_VERSION
make an error
#endif],[AC_DEFINE(HAVE_TERMCAP_H)])
	else
		AC_CHECK_HEADERS(termcap.h)
	fi
else
        # If we didn't find a tgetent() that supports the buffer
        # argument, look again to see whether we can find even
        # a crippled one.  A crippled tgetent() is still useful to
        # validate values for the TERM environment variable given to
        # child processes.
	AC_CACHE_CHECK(for partial tgetent function,cf_cv_lib_part_tgetent,[
	cf_cv_lib_part_tgetent=no
	for cf_termlib in $cf_TERMLIB ; do
		LIBS="$cf_save_LIBS -l$cf_termlib"
		AC_TRY_LINK([],[tgetent(0, "$cf_TERMVAR")],
			[echo "there is a terminfo/tgetent in $cf_termlib" 1>&AC_FD_CC
			 cf_cv_lib_part_tgetent="-l$cf_termlib"
			 break])
	done
	LIBS="$cf_save_LIBS"
	])

	if test "$cf_cv_lib_part_tgetent" != no ; then
		CF_ADD_LIBS($cf_cv_lib_part_tgetent)
		AC_CHECK_HEADERS(termcap.h)

                # If this is linking against ncurses, we'll trigger the
                # ifdef in resize.c that turns the termcap stuff back off.
		AC_DEFINE(USE_TERMINFO,1,[Define to 1 to indicate that terminfo provides the tgetent interface])
	fi
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_GCC_ATTRIBUTES version: 17 updated: 2015/04/12 15:39:00
dnl -----------------
dnl Test for availability of useful gcc __attribute__ directives to quiet
dnl compiler warnings.  Though useful, not all are supported -- and contrary
dnl to documentation, unrecognized directives cause older compilers to barf.
AC_DEFUN([CF_GCC_ATTRIBUTES],
[
if test "$GCC" = yes
then
cat > conftest.i < conftest.$ac_ext <&AC_FD_CC

		case $cf_attribute in
		(printf)
			cf_printf_attribute=yes
			cat >conftest.h <conftest.h <conftest.h <>confdefs.h
			case $cf_attribute in
			(noreturn)
				AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
				;;
			(printf)
				cf_value='/* nothing */'
				if test "$cf_printf_attribute" != no ; then
					cf_value='__attribute__((format(printf,fmt,var)))'
					AC_DEFINE(GCC_PRINTF,1,[Define to 1 if the compiler supports gcc-like printf attribute.])
				fi
				AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc])
				;;
			(scanf)
				cf_value='/* nothing */'
				if test "$cf_scanf_attribute" != no ; then
					cf_value='__attribute__((format(scanf,fmt,var)))'
					AC_DEFINE(GCC_SCANF,1,[Define to 1 if the compiler supports gcc-like scanf attribute.])
				fi
				AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc])
				;;
			(unused)
				AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc])
				;;
			esac
		fi
	done
else
	fgrep define conftest.i >>confdefs.h
fi
rm -rf conftest*
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_GCC_VERSION version: 7 updated: 2012/10/18 06:46:33
dnl --------------
dnl Find version of gcc
AC_DEFUN([CF_GCC_VERSION],[
AC_REQUIRE([AC_PROG_CC])
GCC_VERSION=none
if test "$GCC" = yes ; then
	AC_MSG_CHECKING(version of $CC)
	GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC[[^)]]*) //' -e 's/^.*(Debian[[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
	test -z "$GCC_VERSION" && GCC_VERSION=unknown
	AC_MSG_RESULT($GCC_VERSION)
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_GCC_WARNINGS version: 32 updated: 2015/04/12 15:39:00
dnl ---------------
dnl Check if the compiler supports useful warning options.  There's a few that
dnl we don't use, simply because they're too noisy:
dnl
dnl	-Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
dnl	-Wredundant-decls (system headers make this too noisy)
dnl	-Wtraditional (combines too many unrelated messages, only a few useful)
dnl	-Wwrite-strings (too noisy, but should review occasionally).  This
dnl		is enabled for ncurses using "--enable-const".
dnl	-pedantic
dnl
dnl Parameter:
dnl	$1 is an optional list of gcc warning flags that a particular
dnl		application might want to use, e.g., "no-unused" for
dnl		-Wno-unused
dnl Special:
dnl	If $with_ext_const is "yes", add a check for -Wwrite-strings
dnl
AC_DEFUN([CF_GCC_WARNINGS],
[
AC_REQUIRE([CF_GCC_VERSION])
CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)

cat > conftest.$ac_ext <],[
#ifndef _XOPEN_SOURCE
make an error
#endif],
	[cf_cv_gnu_source=no],
	[cf_save="$CPPFLAGS"
	 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
	 AC_TRY_COMPILE([#include ],[
#ifdef _XOPEN_SOURCE
make an error
#endif],
	[cf_cv_gnu_source=no],
	[cf_cv_gnu_source=yes])
	CPPFLAGS="$cf_save"
	])
])

if test "$cf_cv_gnu_source" = yes
then
AC_CACHE_CHECK(if we should also define _DEFAULT_SOURCE,cf_cv_default_source,[
CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
	AC_TRY_COMPILE([#include ],[
#ifdef _DEFAULT_SOURCE
make an error
#endif],
		[cf_cv_default_source=no],
		[cf_cv_default_source=yes])
	])
test "$cf_cv_default_source" = yes && CPPFLAGS="$CPPFLAGS -D_DEFAULT_SOURCE"
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_HELP_MESSAGE version: 3 updated: 1998/01/14 10:56:23
dnl ---------------
dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
AC_DEFUN([CF_HELP_MESSAGE],
[AC_DIVERT_HELP([$1])dnl
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_IMAKE_CFLAGS version: 32 updated: 2015/04/12 15:39:00
dnl ---------------
dnl Use imake to obtain compiler flags.  We could, in principle, write tests to
dnl get these, but if imake is properly configured there is no point in doing
dnl this.
dnl
dnl Parameters (used in constructing a sample Imakefile):
dnl	$1 = optional value to append to $IMAKE_CFLAGS
dnl	$2 = optional value to append to $IMAKE_LOADFLAGS
AC_DEFUN([CF_IMAKE_CFLAGS],
[
AC_PATH_PROGS(IMAKE,xmkmf imake)

if test -n "$IMAKE" ; then

case $IMAKE in
(*/imake)
	cf_imake_opts="-DUseInstalled=YES"
	;;
(*/util/xmkmf)
	# A single parameter tells xmkmf where the config-files are:
	cf_imake_opts="`echo $IMAKE|sed -e s,/config/util/xmkmf,,`"
	;;
(*)
	cf_imake_opts=
	;;
esac

# If it's installed properly, imake (or its wrapper, xmkmf) will point to the
# config directory.
if mkdir conftestdir; then
	CDPATH=; export CDPATH
	cf_makefile=`cd $srcdir;pwd`/Imakefile
	cd conftestdir

	cat >fix_cflags.sed <<'CF_EOF'
s/\\//g
s/[[ 	]][[ 	]]*/ /g
s/"//g
:pack
s/\(=[[^ ]][[^ ]]*\) \([[^-]]\)/\1	\2/g
t pack
s/\(-D[[a-zA-Z0-9_]][[a-zA-Z0-9_]]*\)=\([[^\'0-9 ]][[^ ]]*\)/\1='\\"\2\\"'/g
s/^IMAKE[[ ]]/IMAKE_CFLAGS="/
s/	/ /g
s/$/"/
CF_EOF

	cat >fix_lflags.sed <<'CF_EOF'
s/^IMAKE[[ 	]]*/IMAKE_LOADFLAGS="/
s/$/"/
CF_EOF

	echo >./Imakefile
	test -f $cf_makefile && cat $cf_makefile >>./Imakefile

	cat >> ./Imakefile <<'CF_EOF'
findstddefs:
	@echo IMAKE ${ALLDEFINES}ifelse([$1],,,[ $1])       | sed -f fix_cflags.sed
	@echo IMAKE ${EXTRA_LOAD_FLAGS}ifelse([$2],,,[ $2]) | sed -f fix_lflags.sed
CF_EOF

	if ( $IMAKE $cf_imake_opts 1>/dev/null 2>&AC_FD_CC && test -f Makefile)
	then
		CF_VERBOSE(Using $IMAKE $cf_imake_opts)
	else
		# sometimes imake doesn't have the config path compiled in.  Find it.
		cf_config=
		for cf_libpath in $X_LIBS $LIBS ; do
			case $cf_libpath in
			(-L*)
				cf_libpath=`echo .$cf_libpath | sed -e 's/^...//'`
				cf_libpath=$cf_libpath/X11/config
				if test -d $cf_libpath ; then
					cf_config=$cf_libpath
					break
				fi
				;;
			esac
		done
		if test -z "$cf_config" ; then
			AC_MSG_WARN(Could not find imake config-directory)
		else
			cf_imake_opts="$cf_imake_opts -I$cf_config"
			if ( $IMAKE -v $cf_imake_opts 2>&AC_FD_CC)
			then
				CF_VERBOSE(Using $IMAKE $cf_config)
			else
				AC_MSG_WARN(Cannot run $IMAKE)
			fi
		fi
	fi

	# GNU make sometimes prints "make[1]: Entering...", which
	# would confuse us.
	eval `make findstddefs 2>/dev/null | grep -v make`

	cd ..
	rm -rf conftestdir

	# We use ${ALLDEFINES} rather than ${STD_DEFINES} because the former
	# declares XTFUNCPROTO there.  However, some vendors (e.g., SGI) have
	# modified it to support site.cf, adding a kludge for the /usr/include
	# directory.  Try to filter that out, otherwise gcc won't find its
	# headers.
	if test -n "$GCC" ; then
	    if test -n "$IMAKE_CFLAGS" ; then
		cf_nostdinc=""
		cf_std_incl=""
		cf_cpp_opts=""
		for cf_opt in $IMAKE_CFLAGS
		do
		    case "$cf_opt" in
		    (-nostdinc)
			cf_nostdinc="$cf_opt"
			;;
		    (-I/usr/include)
			cf_std_incl="$cf_opt"
			;;
		    (*)
			cf_cpp_opts="$cf_cpp_opts $cf_opt"
			;;
		    esac
		done
		if test -z "$cf_nostdinc" ; then
		    IMAKE_CFLAGS="$cf_cpp_opts $cf_std_incl"
		elif test -z "$cf_std_incl" ; then
		    IMAKE_CFLAGS="$cf_cpp_opts $cf_nostdinc"
		else
		    CF_VERBOSE(suppressed \"$cf_nostdinc\" and \"$cf_std_incl\")
		    IMAKE_CFLAGS="$cf_cpp_opts"
		fi
	    fi
	fi
fi

# Some imake configurations define PROJECTROOT with an empty value.  Remove
# the empty definition.
case $IMAKE_CFLAGS in
(*-DPROJECTROOT=/*)
	;;
(*)
	IMAKE_CFLAGS=`echo "$IMAKE_CFLAGS" |sed -e "s,-DPROJECTROOT=[[ 	]], ,"`
	;;
esac

fi

CF_VERBOSE(IMAKE_CFLAGS $IMAKE_CFLAGS)
CF_VERBOSE(IMAKE_LOADFLAGS $IMAKE_LOADFLAGS)

AC_SUBST(IMAKE_CFLAGS)
AC_SUBST(IMAKE_LOADFLAGS)
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_INPUT_METHOD version: 3 updated: 2000/04/11 23:46:57
dnl ---------------
dnl Check if the X libraries support input-method
AC_DEFUN([CF_INPUT_METHOD],
[
AC_CACHE_CHECK([if X libraries support input-method],cf_cv_input_method,[
AC_TRY_LINK([
#include 
#include 
#include 
#include 
#include 
#include 
],[
{
	XIM xim;
	XIMStyles *xim_styles = 0;
	XIMStyle input_style;
	Widget w = 0;

	XSetLocaleModifiers("@im=none");
	xim = XOpenIM(XtDisplay(w), NULL, NULL, NULL);
	XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL);
	XCloseIM(xim);
	input_style = (XIMPreeditNothing | XIMStatusNothing);
}
],
[cf_cv_input_method=yes],
[cf_cv_input_method=no])])
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_INTEL_COMPILER version: 7 updated: 2015/04/12 15:39:00
dnl -----------------
dnl Check if the given compiler is really the Intel compiler for Linux.  It
dnl tries to imitate gcc, but does not return an error when it finds a mismatch
dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
dnl
dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
dnl the wrappers for gcc and g++ warnings.
dnl
dnl $1 = GCC (default) or GXX
dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
dnl $3 = CFLAGS (default) or CXXFLAGS
AC_DEFUN([CF_INTEL_COMPILER],[
AC_REQUIRE([AC_CANONICAL_HOST])
ifelse([$2],,INTEL_COMPILER,[$2])=no

if test "$ifelse([$1],,[$1],GCC)" = yes ; then
	case $host_os in
	(linux*|gnu*)
		AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
		cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
		ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
		AC_TRY_COMPILE([],[
#ifdef __INTEL_COMPILER
#else
make an error
#endif
],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
cf_save_CFLAGS="$cf_save_CFLAGS -we147"
],[])
		ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
		AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
		;;
	esac
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_LASTLOG version: 5 updated: 2012/10/04 20:12:20
dnl ----------
dnl Check for header defining _PATH_LASTLOG, or failing that, see if the lastlog
dnl file exists.
AC_DEFUN([CF_LASTLOG],
[
AC_CHECK_HEADERS(lastlog.h paths.h)
AC_CACHE_CHECK(for lastlog path,cf_cv_path_lastlog,[
AC_TRY_COMPILE([
#include 
#ifdef HAVE_LASTLOG_H
#include 
#else
#ifdef HAVE_PATHS_H
#include 
#endif
#endif],[char *path = _PATH_LASTLOG],
	[cf_cv_path_lastlog="_PATH_LASTLOG"],
	[if test -f /usr/adm/lastlog ; then
	 	cf_cv_path_lastlog=/usr/adm/lastlog
	else
		cf_cv_path_lastlog=no
	fi])
])
test $cf_cv_path_lastlog != no && AC_DEFINE(USE_LASTLOG,1,[Define to 1 if we can define lastlog pathname])
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_LD_RPATH_OPT version: 7 updated: 2016/02/20 18:01:19
dnl ---------------
dnl For the given system and compiler, find the compiler flags to pass to the
dnl loader to use the "rpath" feature.
AC_DEFUN([CF_LD_RPATH_OPT],
[
AC_REQUIRE([CF_CHECK_CACHE])

LD_RPATH_OPT=
AC_MSG_CHECKING(for an rpath option)
case $cf_cv_system_name in
(irix*)
	if test "$GCC" = yes; then
		LD_RPATH_OPT="-Wl,-rpath,"
	else
		LD_RPATH_OPT="-rpath "
	fi
	;;
(linux*|gnu*|k*bsd*-gnu|freebsd*)
	LD_RPATH_OPT="-Wl,-rpath,"
	;;
(openbsd[[2-9]].*|mirbsd*)
	LD_RPATH_OPT="-Wl,-rpath,"
	;;
(dragonfly*)
	LD_RPATH_OPT="-rpath "
	;;
(netbsd*)
	LD_RPATH_OPT="-Wl,-rpath,"
	;;
(osf*|mls+*)
	LD_RPATH_OPT="-rpath "
	;;
(solaris2*)
	LD_RPATH_OPT="-R"
	;;
(*)
	;;
esac
AC_MSG_RESULT($LD_RPATH_OPT)

case "x$LD_RPATH_OPT" in
(x-R*)
	AC_MSG_CHECKING(if we need a space after rpath option)
	cf_save_LIBS="$LIBS"
	CF_ADD_LIBS(${LD_RPATH_OPT}$libdir)
	AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
	LIBS="$cf_save_LIBS"
	AC_MSG_RESULT($cf_rpath_space)
	test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
	;;
esac
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
dnl ------------
dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
dnl a monocase filesystem.
AC_DEFUN([CF_MAKE_TAGS],[
AC_REQUIRE([CF_MIXEDCASE_FILENAMES])

AC_CHECK_PROGS(CTAGS, exctags ctags)
AC_CHECK_PROGS(ETAGS, exetags etags)

AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)

if test "$cf_cv_mixedcase" = yes ; then
	AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
else
	MAKE_UPPER_TAGS=no
fi

if test "$MAKE_UPPER_TAGS" = yes ; then
	MAKE_UPPER_TAGS=
else
	MAKE_UPPER_TAGS="#"
fi

if test "$MAKE_LOWER_TAGS" = yes ; then
	MAKE_LOWER_TAGS=
else
	MAKE_LOWER_TAGS="#"
fi

AC_SUBST(CTAGS)
AC_SUBST(ETAGS)

AC_SUBST(MAKE_UPPER_TAGS)
AC_SUBST(MAKE_LOWER_TAGS)
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_MATH_LIB version: 9 updated: 2017/01/21 11:06:25
dnl -----------
dnl Checks for libraries.  At least one UNIX system, Apple Macintosh
dnl Rhapsody 5.5, does not have -lm.  We cannot use the simpler
dnl AC_CHECK_LIB(m,sin), because that fails for C++.
AC_DEFUN([CF_MATH_LIB],
[
AC_CACHE_CHECK(if -lm needed for math functions,
	cf_cv_need_libm,[
	AC_TRY_LINK([
	#include 
	#include 
	#include 
	],
	[double x = rand(); printf("result = %g\n", ]ifelse([$2],,sin(x),$2)[)],
	[cf_cv_need_libm=no],
	[cf_cv_need_libm=yes])])
if test "$cf_cv_need_libm" = yes
then
ifelse($1,,[
	CF_ADD_LIB(m)
],[$1=-lm])
fi
])
dnl ---------------------------------------------------------------------------
dnl CF_MIXEDCASE_FILENAMES version: 7 updated: 2015/04/12 15:39:00
dnl ----------------------
dnl Check if the file-system supports mixed-case filenames.  If we're able to
dnl create a lowercase name and see it as uppercase, it doesn't support that.
AC_DEFUN([CF_MIXEDCASE_FILENAMES],
[
AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
if test "$cross_compiling" = yes ; then
	case $target_alias in
	(*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*)
		cf_cv_mixedcase=no
		;;
	(*)
		cf_cv_mixedcase=yes
		;;
	esac
else
	rm -f conftest CONFTEST
	echo test >conftest
	if test -f CONFTEST ; then
		cf_cv_mixedcase=no
	else
		cf_cv_mixedcase=yes
	fi
	rm -f conftest CONFTEST
fi
])
test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
dnl ----------
dnl Write a debug message to config.log, along with the line number in the
dnl configure script.
AC_DEFUN([CF_MSG_LOG],[
echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_NO_LEAKS_OPTION version: 6 updated: 2015/04/12 15:39:00
dnl ------------------
dnl see CF_WITH_NO_LEAKS
AC_DEFUN([CF_NO_LEAKS_OPTION],[
AC_MSG_CHECKING(if you want to use $1 for testing)
AC_ARG_WITH($1,
	[$2],
	[AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
	 $4
])
	: ${with_cflags:=-g}
	: ${with_no_leaks:=yes}
	 with_$1=yes],
	[with_$1=])
AC_MSG_RESULT(${with_$1:-no})

case .$with_cflags in
(.*-g*)
	case .$CFLAGS in
	(.*-g*)
		;;
	(*)
		CF_ADD_CFLAGS([-g])
		;;
	esac
	;;
esac
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_PATHSEP version: 7 updated: 2015/04/12 15:39:00
dnl ----------
dnl Provide a value for the $PATH and similar separator (or amend the value
dnl as provided in autoconf 2.5x).
AC_DEFUN([CF_PATHSEP],
[
	AC_MSG_CHECKING(for PATH separator)
	case $cf_cv_system_name in
	(os2*)	PATH_SEPARATOR=';'  ;;
	(*)	${PATH_SEPARATOR:=':'}  ;;
	esac
ifelse([$1],,,[$1=$PATH_SEPARATOR])
	AC_SUBST(PATH_SEPARATOR)
	AC_MSG_RESULT($PATH_SEPARATOR)
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_PATH_PROG version: 9 updated: 2012/10/04 20:12:20
dnl ------------
dnl Check for a given program, defining corresponding symbol.
dnl	$1 = environment variable, which is suffixed by "_PATH" in the #define.
dnl	$2 = program name to find.
dnl	$3 = optional list of additional program names to test.
dnl
dnl If there is more than one token in the result, #define the remaining tokens
dnl to $1_ARGS.  We need this for 'install' in particular.
dnl
dnl FIXME: we should allow this to be overridden by environment variables
dnl
AC_DEFUN([CF_PATH_PROG],[
AC_REQUIRE([CF_PATHSEP])
test -z "[$]$1" && $1=$2
AC_PATH_PROGS($1,[$]$1 $2 $3,[$]$1)

cf_path_prog=""
cf_path_args=""
IFS="${IFS:- 	}"; cf_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR"
for cf_temp in $ac_cv_path_$1
do
	if test -z "$cf_path_prog" ; then
		if test "$with_full_paths" = yes ; then
			CF_PATH_SYNTAX(cf_temp,break)
			cf_path_prog="$cf_temp"
		else
			cf_path_prog="`basename $cf_temp`"
		fi
	elif test -z "$cf_path_args" ; then
		cf_path_args="$cf_temp"
	else
		cf_path_args="$cf_path_args $cf_temp"
	fi
done
IFS="$cf_save_ifs"

if test -n "$cf_path_prog" ; then
	CF_MSG_LOG(defining path for ${cf_path_prog})
	AC_DEFINE_UNQUOTED($1_PATH,"$cf_path_prog",Define to pathname $1)
	test -n "$cf_path_args" && AC_DEFINE_UNQUOTED($1_ARGS,"$cf_path_args",Define to provide args for $1)
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_PATH_SYNTAX version: 16 updated: 2015/04/18 08:56:57
dnl --------------
dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
dnl begins with one of the prefix/exec_prefix variables, and then again if the
dnl result begins with 'NONE'.  This is necessary to work around autoconf's
dnl delayed evaluation of those symbols.
AC_DEFUN([CF_PATH_SYNTAX],[
if test "x$prefix" != xNONE; then
	cf_path_syntax="$prefix"
else
	cf_path_syntax="$ac_default_prefix"
fi

case ".[$]$1" in
(.\[$]\(*\)*|.\'*\'*)
	;;
(..|./*|.\\*)
	;;
(.[[a-zA-Z]]:[[\\/]]*) # OS/2 EMX
	;;
(.\[$]{*prefix}*|.\[$]{*dir}*)
	eval $1="[$]$1"
	case ".[$]$1" in
	(.NONE/*)
		$1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
		;;
	esac
	;;
(.no|.NONE/*)
	$1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
	;;
(*)
	ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
	;;
esac
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_PKG_CONFIG version: 10 updated: 2015/04/26 18:06:58
dnl -------------
dnl Check for the package-config program, unless disabled by command-line.
AC_DEFUN([CF_PKG_CONFIG],
[
AC_MSG_CHECKING(if you want to use pkg-config)
AC_ARG_WITH(pkg-config,
	[  --with-pkg-config{=path} enable/disable use of pkg-config],
	[cf_pkg_config=$withval],
	[cf_pkg_config=yes])
AC_MSG_RESULT($cf_pkg_config)

case $cf_pkg_config in
(no)
	PKG_CONFIG=none
	;;
(yes)
	CF_ACVERSION_CHECK(2.52,
		[AC_PATH_TOOL(PKG_CONFIG, pkg-config, none)],
		[AC_PATH_PROG(PKG_CONFIG, pkg-config, none)])
	;;
(*)
	PKG_CONFIG=$withval
	;;
esac

test -z "$PKG_CONFIG" && PKG_CONFIG=none
if test "$PKG_CONFIG" != none ; then
	CF_PATH_SYNTAX(PKG_CONFIG)
elif test "x$cf_pkg_config" != xno ; then
	AC_MSG_WARN(pkg-config is not installed)
fi

AC_SUBST(PKG_CONFIG)
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_POSIX_C_SOURCE version: 9 updated: 2015/04/12 15:39:00
dnl -----------------
dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
dnl
dnl	POSIX.1-1990				_POSIX_SOURCE
dnl	POSIX.1-1990 and			_POSIX_SOURCE and
dnl		POSIX.2-1992 C-Language			_POSIX_C_SOURCE=2
dnl		Bindings Option
dnl	POSIX.1b-1993				_POSIX_C_SOURCE=199309L
dnl	POSIX.1c-1996				_POSIX_C_SOURCE=199506L
dnl	X/Open 2000				_POSIX_C_SOURCE=200112L
dnl
dnl Parameters:
dnl	$1 is the nominal value for _POSIX_C_SOURCE
AC_DEFUN([CF_POSIX_C_SOURCE],
[
cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])

cf_save_CFLAGS="$CFLAGS"
cf_save_CPPFLAGS="$CPPFLAGS"

CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)

AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
	CF_MSG_LOG(if the symbol is already defined go no further)
	AC_TRY_COMPILE([#include ],[
#ifndef _POSIX_C_SOURCE
make an error
#endif],
	[cf_cv_posix_c_source=no],
	[cf_want_posix_source=no
	 case .$cf_POSIX_C_SOURCE in
	 (.[[12]]??*)
		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
		;;
	 (.2)
		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
		cf_want_posix_source=yes
		;;
	 (.*)
		cf_want_posix_source=yes
		;;
	 esac
	 if test "$cf_want_posix_source" = yes ; then
		AC_TRY_COMPILE([#include ],[
#ifdef _POSIX_SOURCE
make an error
#endif],[],
		cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
	 fi
	 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
	 CFLAGS="$cf_trim_CFLAGS"
	 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
	 CF_MSG_LOG(if the second compile does not leave our definition intact error)
	 AC_TRY_COMPILE([#include ],[
#ifndef _POSIX_C_SOURCE
make an error
#endif],,
	 [cf_cv_posix_c_source=no])
	 CFLAGS="$cf_save_CFLAGS"
	 CPPFLAGS="$cf_save_CPPFLAGS"
	])
])

if test "$cf_cv_posix_c_source" != no ; then
	CFLAGS="$cf_trim_CFLAGS"
	CPPFLAGS="$cf_trim_CPPFLAGS"
	CF_ADD_CFLAGS($cf_cv_posix_c_source)
fi

])dnl
dnl ---------------------------------------------------------------------------
dnl CF_POSIX_SAVED_IDS version: 8 updated: 2012/10/04 20:12:20
dnl ------------------
dnl
dnl Check first if saved-ids are always supported.  Some systems
dnl may require runtime checks.
AC_DEFUN([CF_POSIX_SAVED_IDS],
[
AC_CHECK_HEADERS( \
sys/param.h \
)

AC_CACHE_CHECK(if POSIX saved-ids are supported,cf_cv_posix_saved_ids,[
AC_TRY_LINK(
[
#include 
#ifdef HAVE_SYS_PARAM_H
#include 		/* this may define "BSD" */
#endif
],[
#if defined(_POSIX_SAVED_IDS) && (_POSIX_SAVED_IDS > 0)
	void *p = (void *) seteuid;
	int x = seteuid(geteuid());
#elif defined(BSD) && (BSD >= 199103)
/* The BSD's may implement the runtime check - and it fails.
 * However, saved-ids work almost like POSIX (close enough for most uses).
 */
#else
make an error
#endif
],[cf_cv_posix_saved_ids=yes
],[
AC_TRY_RUN([
#ifdef HAVE_STDLIB_H
#include 
#endif
#include 
int main()
{
	void *p = (void *) seteuid;
	long code = sysconf(_SC_SAVED_IDS);
	${cf_cv_main_return:-return}  ((code > 0) ? 0 : 1);
}],
	cf_cv_posix_saved_ids=yes,
	cf_cv_posix_saved_ids=no,
	cf_cv_posix_saved_ids=unknown)
])
])

test "$cf_cv_posix_saved_ids" = yes && AC_DEFINE(HAVE_POSIX_SAVED_IDS,1,[Define to 1 if POSIX saved-ids are supported])
])
dnl ---------------------------------------------------------------------------
dnl CF_POSIX_WAIT version: 3 updated: 2012/10/04 20:12:20
dnl -------------
dnl Check for POSIX wait support
AC_DEFUN([CF_POSIX_WAIT],
[
AC_REQUIRE([AC_HEADER_SYS_WAIT])
AC_CACHE_CHECK(for POSIX wait functions,cf_cv_posix_wait,[
AC_TRY_LINK([
#include 
#include 
#include 
#ifdef HAVE_SYS_WAIT_H
#include 
#endif
],[
	int stat_loc;
	pid_t pid = waitpid(-1, &stat_loc, WNOHANG|WUNTRACED);
	pid_t pid2 = wait(&stat_loc);
],
[cf_cv_posix_wait=yes],
[cf_cv_posix_wait=no])
])
test "$cf_cv_posix_wait" = yes && AC_DEFINE(USE_POSIX_WAIT,1,[Define to 1 if we have POSIX wait functions])
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_PROCFS_CWD version: 2 updated: 2007/03/12 20:39:04
dnl -------------
dnl Find /proc tree (may be in a different place) which implements the "cwd"
dnl link.
AC_DEFUN([CF_PROCFS_CWD],[
AC_CACHE_CHECK(for proc tree with cwd-support,cf_cv_procfs_cwd,[
cf_cv_procfs_cwd=no
for cf_path in /proc /compat/linux/proc /usr/compat/linux/proc
do
	if test -d $cf_path && \
	   test -d $cf_path/$$ && \
	   ( test -d $cf_path/$$/cwd || \
	     test -L $cf_path/$$/cwd ); then
		cf_cv_procfs_cwd=$cf_path
		break
	fi
done
])
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_PROG_CC version: 4 updated: 2014/07/12 18:57:58
dnl ----------
dnl standard check for CC, plus followup sanity checks
dnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
AC_DEFUN([CF_PROG_CC],[
ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
CF_GCC_VERSION
CF_ACVERSION_CHECK(2.52,
	[AC_PROG_CC_STDC],
	[CF_ANSI_CC_REQD])
CF_CC_ENV_FLAGS
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_PROG_GROFF version: 2 updated: 2015/07/04 11:16:27
dnl -------------
dnl Check if groff is available, for cases (such as html output) where nroff
dnl is not enough.
AC_DEFUN([CF_PROG_GROFF],[
AC_PATH_PROG(GROFF_PATH,groff,no)
AC_PATH_PROG(NROFF_PATH,nroff,no)
if test "x$GROFF_PATH" = xno
then
	NROFF_NOTE=
	GROFF_NOTE="#"
else
	NROFF_NOTE="#"
	GROFF_NOTE=
fi
AC_SUBST(GROFF_NOTE)
AC_SUBST(NROFF_NOTE)
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_PROG_LINT version: 3 updated: 2016/05/22 15:25:54
dnl ------------
AC_DEFUN([CF_PROG_LINT],
[
AC_CHECK_PROGS(LINT, lint cppcheck splint)
AC_SUBST(LINT_OPTS)
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_REGEX version: 12 updated: 2015/04/18 08:56:57
dnl --------
dnl Attempt to determine if we've got one of the flavors of regular-expression
dnl code that we can support.
AC_DEFUN([CF_REGEX],
[

cf_regex_func=no

cf_regex_libs="regex re"
case $host_os in
(mingw*)
	cf_regex_libs="gnurx $cf_regex_libs"
	;;
esac

AC_CHECK_FUNC(regcomp,[cf_regex_func=regcomp],[
	for cf_regex_lib in $cf_regex_libs
	do
		AC_CHECK_LIB($cf_regex_lib,regcomp,[
				CF_ADD_LIB($cf_regex_lib)
				cf_regex_func=regcomp
				break])
	done
])

if test "$cf_regex_func" = no ; then
	AC_CHECK_FUNC(compile,[cf_regex_func=compile],[
		AC_CHECK_LIB(gen,compile,[
				CF_ADD_LIB(gen)
				cf_regex_func=compile])])
fi

if test "$cf_regex_func" = no ; then
	AC_MSG_WARN(cannot find regular expression library)
fi

AC_CACHE_CHECK(for regular-expression headers,cf_cv_regex_hdrs,[

cf_cv_regex_hdrs=no
case $cf_regex_func in
(compile)
	for cf_regex_hdr in regexp.h regexpr.h
	do
		AC_TRY_LINK([#include <$cf_regex_hdr>],[
			char *p = compile("", "", "", 0);
			int x = step("", "");
		],[
			cf_cv_regex_hdrs=$cf_regex_hdr
			break
		])
	done
	;;
(*)
	for cf_regex_hdr in regex.h
	do
		AC_TRY_LINK([#include 
#include <$cf_regex_hdr>],[
			regex_t *p;
			int x = regcomp(p, "", 0);
			int y = regexec(p, "", 0, 0, 0);
			regfree(p);
		],[
			cf_cv_regex_hdrs=$cf_regex_hdr
			break
		])
	done
	;;
esac

])

case $cf_cv_regex_hdrs in
	(no)		AC_MSG_WARN(no regular expression header found) ;;
	(regex.h)	AC_DEFINE(HAVE_REGEX_H_FUNCS,1,[Define to 1 to include regex.h for regular expressions]) ;;
	(regexp.h)	AC_DEFINE(HAVE_REGEXP_H_FUNCS,1,[Define to 1 to include regexp.h for regular expressions]) ;;
	(regexpr.h) AC_DEFINE(HAVE_REGEXPR_H_FUNCS,1,[Define to 1 to include regexpr.h for regular expressions]) ;;
esac
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
dnl ----------------
dnl Remove all -U and -D options that refer to the given symbol from a list
dnl of C compiler options.  This works around the problem that not all
dnl compilers process -U and -D options from left-to-right, so a -U option
dnl cannot be used to cancel the effect of a preceding -D option.
dnl
dnl $1 = target (which could be the same as the source variable)
dnl $2 = source (including '$')
dnl $3 = symbol to remove
define([CF_REMOVE_DEFINE],
[
$1=`echo "$2" | \
	sed	-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[[ 	]]/ /g' \
		-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[$]//g'`
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_RPATH_HACK version: 11 updated: 2013/09/01 13:02:00
dnl -------------
AC_DEFUN([CF_RPATH_HACK],
[
AC_REQUIRE([CF_LD_RPATH_OPT])
AC_MSG_CHECKING(for updated LDFLAGS)
if test -n "$LD_RPATH_OPT" ; then
	AC_MSG_RESULT(maybe)

	AC_CHECK_PROGS(cf_ldd_prog,ldd,no)
	cf_rpath_list="/usr/lib /lib"
	if test "$cf_ldd_prog" != no
	then
		cf_rpath_oops=

AC_TRY_LINK([#include ],
		[printf("Hello");],
		[cf_rpath_oops=`$cf_ldd_prog conftest$ac_exeext | fgrep ' not found' | sed -e 's% =>.*$%%' |sort | uniq`
		 cf_rpath_list=`$cf_ldd_prog conftest$ac_exeext | fgrep / | sed -e 's%^.*[[ 	]]/%/%' -e 's%/[[^/]][[^/]]*$%%' |sort | uniq`])

		# If we passed the link-test, but get a "not found" on a given library,
		# this could be due to inept reconfiguration of gcc to make it only
		# partly honor /usr/local/lib (or whatever).  Sometimes this behavior
		# is intentional, e.g., installing gcc in /usr/bin and suppressing the
		# /usr/local libraries.
		if test -n "$cf_rpath_oops"
		then
			for cf_rpath_src in $cf_rpath_oops
			do
				for cf_rpath_dir in \
					/usr/local \
					/usr/pkg \
					/opt/sfw
				do
					if test -f $cf_rpath_dir/lib/$cf_rpath_src
					then
						CF_VERBOSE(...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src)
						LDFLAGS="$LDFLAGS -L$cf_rpath_dir/lib"
						break
					fi
				done
			done
		fi
	fi

	CF_VERBOSE(...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS)

	CF_RPATH_HACK_2(LDFLAGS)
	CF_RPATH_HACK_2(LIBS)

	CF_VERBOSE(...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS)
else
	AC_MSG_RESULT(no)
fi
AC_SUBST(EXTRA_LDFLAGS)
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_RPATH_HACK_2 version: 7 updated: 2015/04/12 15:39:00
dnl ---------------
dnl Do one set of substitutions for CF_RPATH_HACK, adding an rpath option to
dnl EXTRA_LDFLAGS for each -L option found.
dnl
dnl $cf_rpath_list contains a list of directories to ignore.
dnl
dnl $1 = variable name to update.  The LDFLAGS variable should be the only one,
dnl      but LIBS often has misplaced -L options.
AC_DEFUN([CF_RPATH_HACK_2],
[
CF_VERBOSE(...checking $1 [$]$1)

cf_rpath_dst=
for cf_rpath_src in [$]$1
do
	case $cf_rpath_src in
	(-L*)

		# check if this refers to a directory which we will ignore
		cf_rpath_skip=no
		if test -n "$cf_rpath_list"
		then
			for cf_rpath_item in $cf_rpath_list
			do
				if test "x$cf_rpath_src" = "x-L$cf_rpath_item"
				then
					cf_rpath_skip=yes
					break
				fi
			done
		fi

		if test "$cf_rpath_skip" = no
		then
			# transform the option
			if test "$LD_RPATH_OPT" = "-R " ; then
				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%-R %"`
			else
				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%$LD_RPATH_OPT%"`
			fi

			# if we have not already added this, add it now
			cf_rpath_tst=`echo "$EXTRA_LDFLAGS" | sed -e "s%$cf_rpath_tmp %%"`
			if test "x$cf_rpath_tst" = "x$EXTRA_LDFLAGS"
			then
				CF_VERBOSE(...Filter $cf_rpath_src ->$cf_rpath_tmp)
				EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
			fi
		fi
		;;
	esac
	cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
done
$1=$cf_rpath_dst

CF_VERBOSE(...checked $1 [$]$1)
AC_SUBST(EXTRA_LDFLAGS)
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_SIGWINCH version: 1 updated: 2006/04/02 16:41:09
dnl -----------
dnl Use this macro after CF_XOPEN_SOURCE, but do not require it (not all
dnl programs need this test).
dnl
dnl This is really a MacOS X 10.4.3 workaround.  Defining _POSIX_C_SOURCE
dnl forces SIGWINCH to be undefined (breaks xterm, ncurses).  Oddly, the struct
dnl winsize declaration is left alone - we may revisit this if Apple choose to
dnl break that part of the interface as well.
AC_DEFUN([CF_SIGWINCH],
[
AC_CACHE_CHECK(if SIGWINCH is defined,cf_cv_define_sigwinch,[
	AC_TRY_COMPILE([
#include 
#include 
],[int x = SIGWINCH],
	[cf_cv_define_sigwinch=yes],
	[AC_TRY_COMPILE([
#undef _XOPEN_SOURCE
#undef _POSIX_SOURCE
#undef _POSIX_C_SOURCE
#include 
#include 
],[int x = SIGWINCH],
	[cf_cv_define_sigwinch=maybe],
	[cf_cv_define_sigwinch=no])
])
])

if test "$cf_cv_define_sigwinch" = maybe ; then
AC_CACHE_CHECK(for actual SIGWINCH definition,cf_cv_fixup_sigwinch,[
cf_cv_fixup_sigwinch=unknown
cf_sigwinch=32
while test $cf_sigwinch != 1
do
	AC_TRY_COMPILE([
#undef _XOPEN_SOURCE
#undef _POSIX_SOURCE
#undef _POSIX_C_SOURCE
#include 
#include 
],[
#if SIGWINCH != $cf_sigwinch
make an error
#endif
int x = SIGWINCH],
	[cf_cv_fixup_sigwinch=$cf_sigwinch
	 break])

cf_sigwinch=`expr $cf_sigwinch - 1`
done
])

	if test "$cf_cv_fixup_sigwinch" != unknown ; then
		CPPFLAGS="$CPPFLAGS -DSIGWINCH=$cf_cv_fixup_sigwinch"
	fi
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_SIG_ATOMIC_T version: 3 updated: 2012/10/04 20:12:20
dnl ---------------
dnl signal handler, but there are some gcc depedencies in that recommendation.
dnl Try anyway.
AC_DEFUN([CF_SIG_ATOMIC_T],
[
AC_MSG_CHECKING(for signal global datatype)
AC_CACHE_VAL(cf_cv_sig_atomic_t,[
	for cf_type in \
		"volatile sig_atomic_t" \
		"sig_atomic_t" \
		"int"
	do
	AC_TRY_COMPILE([
#include 
#include 
#include 

extern $cf_type x;
$cf_type x;
static void handler(int sig)
{
	x = 5;
}],
		[signal(SIGINT, handler);
		 x = 1],
		[cf_cv_sig_atomic_t=$cf_type],
		[cf_cv_sig_atomic_t=no])
		test "$cf_cv_sig_atomic_t" != no && break
	done
	])
AC_MSG_RESULT($cf_cv_sig_atomic_t)
test "$cf_cv_sig_atomic_t" != no && AC_DEFINE_UNQUOTED(SIG_ATOMIC_T, $cf_cv_sig_atomic_t,[Define to signal global datatype])
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_STRUCT_LASTLOG version: 2 updated: 2012/10/04 20:12:20
dnl -----------------
dnl Check for header defining struct lastlog, ensure that its .ll_time member
dnl is compatible with time().
AC_DEFUN([CF_STRUCT_LASTLOG],
[
AC_CHECK_HEADERS(lastlog.h)
AC_CACHE_CHECK(for struct lastlog,cf_cv_struct_lastlog,[
AC_TRY_RUN([
#include 
#include 
#include 

int main()
{
	struct lastlog data;
	return (sizeof(data.ll_time) != sizeof(time_t));
}],[
cf_cv_struct_lastlog=yes],[
cf_cv_struct_lastlog=no],[
cf_cv_struct_lastlog=unknown])])

test $cf_cv_struct_lastlog != no && AC_DEFINE(USE_STRUCT_LASTLOG,1,[Define to 1 if we have struct lastlog])
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_SVR4 version: 5 updated: 2012/10/04 05:24:07
dnl -------
dnl Check if this is an SVR4 system.  We need the definition for xterm
AC_DEFUN([CF_SVR4],
[
AC_CHECK_LIB(elf, elf_begin,[
AC_CACHE_CHECK(if this is an SVR4 system, cf_cv_svr4,[
AC_TRY_COMPILE([
#if defined(__CYGWIN__)
make an error
#endif
#include 
#include 
],[
static struct termio d_tio;
	d_tio.c_cc[VINTR] = 0;
	d_tio.c_cc[VQUIT] = 0;
	d_tio.c_cc[VERASE] = 0;
	d_tio.c_cc[VKILL] = 0;
	d_tio.c_cc[VEOF] = 0;
	d_tio.c_cc[VEOL] = 0;
	d_tio.c_cc[VMIN] = 0;
	d_tio.c_cc[VTIME] = 0;
	d_tio.c_cc[VLNEXT] = 0;
],
[cf_cv_svr4=yes],
[cf_cv_svr4=no])
])
])
test "$cf_cv_svr4" = yes && AC_DEFINE(SVR4,1,[Define to 1 if this is an SVR4 system])
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_SYSV version: 15 updated: 2012/10/04 05:24:07
dnl -------
dnl Check if this is a SYSV platform, e.g., as used in , and whether
dnl defining it will be helpful.  The following features are used to check:
dnl
dnl a) bona-fide SVSV doesn't use const for sys_errlist[].  Since this is a
dnl legacy (pre-ANSI) feature, const should not apply.  Modern systems only
dnl declare strerror().  Xos.h declares the legacy form of str_errlist[], and
dnl a compile-time error will result from trying to assign to a const array.
dnl
dnl b) compile with headers that exist on SYSV hosts.
dnl
dnl c) compile with type definitions that differ on SYSV hosts from standard C.
AC_DEFUN([CF_SYSV],
[
AC_CHECK_HEADERS( \
termios.h \
stdlib.h \
X11/Intrinsic.h \
)

AC_REQUIRE([CF_SYS_ERRLIST])

AC_CACHE_CHECK(if we should define SYSV,cf_cv_sysv,[
AC_TRY_COMPILE([
#undef  SYSV
#define SYSV 1			/* get Xos.h to declare sys_errlist[] */
#ifdef HAVE_STDLIB_H
#include 		/* look for wchar_t */
#endif
#ifdef HAVE_X11_INTRINSIC_H
#include 	/* Intrinsic.h has other traps... */
#endif
#ifdef HAVE_TERMIOS_H		/* needed for HPUX 10.20 */
#include 
#define STRUCT_TERMIOS struct termios
#else
#define STRUCT_TERMIOS struct termio
#endif
#include 
#include 		/* eliminate most BSD hacks */
#include 		/* declare sys_errlist on older systems */
#include 		/* eliminate most of the remaining ones */
],[
static STRUCT_TERMIOS d_tio;
	d_tio.c_cc[VINTR] = 0;
	d_tio.c_cc[VQUIT] = 0;
	d_tio.c_cc[VERASE] = 0;
	d_tio.c_cc[VKILL] = 0;
	d_tio.c_cc[VEOF] = 0;
	d_tio.c_cc[VEOL] = 0;
	d_tio.c_cc[VMIN] = 0;
	d_tio.c_cc[VTIME] = 0;
#if defined(HAVE_SYS_ERRLIST) && !defined(DECL_SYS_ERRLIST)
sys_errlist[0] = "";		/* Cygwin mis-declares this */
#endif
],
[cf_cv_sysv=yes],
[cf_cv_sysv=no])
])
test "$cf_cv_sysv" = yes && AC_DEFINE(SYSV,1,[Define to 1 if this is an SYSV system])
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_SYSV_UTMP version: 6 updated: 2012/10/04 20:12:20
dnl ------------
dnl Check if this is a SYSV flavor of UTMP
AC_DEFUN([CF_SYSV_UTMP],
[
AC_CACHE_CHECK(if $cf_cv_have_utmp is SYSV flavor,cf_cv_sysv_utmp,[
test "$cf_cv_have_utmp" = "utmp" && cf_prefix="ut" || cf_prefix="utx"
AC_TRY_LINK([
#include 
#include <${cf_cv_have_utmp}.h>],[
struct $cf_cv_have_utmp x;
	set${cf_prefix}ent ();
	get${cf_prefix}id(&x);
	put${cf_prefix}line(&x);
	end${cf_prefix}ent();],
	[cf_cv_sysv_utmp=yes],
	[cf_cv_sysv_utmp=no])
])
test $cf_cv_sysv_utmp = yes && AC_DEFINE(USE_SYSV_UTMP,1,[Define to 1 if utmp is SYSV flavor])
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_SYS_ERRLIST version: 6 updated: 2001/12/30 13:03:23
dnl --------------
dnl Check for declaration of sys_nerr and sys_errlist in one of stdio.h and
dnl errno.h.  Declaration of sys_errlist on BSD4.4 interferes with our
dnl declaration.  Reported by Keith Bostic.
AC_DEFUN([CF_SYS_ERRLIST],
[
    CF_CHECK_ERRNO(sys_nerr)
    CF_CHECK_ERRNO(sys_errlist)
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_TERMIO_C_ISPEED version: 3 updated: 2012/10/04 20:12:20
dnl ------------------
dnl Check for SGI's broken redefinition of baud rates introduced in IRIX 6.5
dnl (there doesn't appear to be a useful predefined symbol).
AC_DEFUN([CF_TERMIO_C_ISPEED],
[
AC_CACHE_CHECK(for IRIX 6.5 baud-rate redefinitions,cf_cv_termio_c_ispeed,[
AC_TRY_COMPILE([
#include 
#include ],[
struct termio foo;
foo.c_ispeed = B38400;
foo.c_ospeed = B9600;
],[cf_cv_termio_c_ispeed=yes
],[cf_cv_termio_c_ispeed=no])
])
test "$cf_cv_termio_c_ispeed" = yes && AC_DEFINE(HAVE_TERMIO_C_ISPEED,1,[define 1 if we have IRIX 6.5 baud-rate redefinitions])
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_TRIM_X_LIBS version: 3 updated: 2015/04/12 15:39:00
dnl --------------
dnl Trim extra base X libraries added as a workaround for inconsistent library
dnl dependencies returned by "new" pkg-config files.
AC_DEFUN([CF_TRIM_X_LIBS],[
	for cf_trim_lib in Xmu Xt X11
	do
		case "$LIBS" in
		(*-l$cf_trim_lib\ *-l$cf_trim_lib*)
			LIBS=`echo "$LIBS " | sed -e 's/  / /g' -e 's%-l'"$cf_trim_lib"' %%' -e 's/ $//'`
			CF_VERBOSE(..trimmed $LIBS)
			;;
		esac
	done
])
dnl ---------------------------------------------------------------------------
dnl CF_TRY_PKG_CONFIG version: 5 updated: 2013/07/06 21:27:06
dnl -----------------
dnl This is a simple wrapper to use for pkg-config, for libraries which may be
dnl available in that form.
dnl
dnl $1 = package name
dnl $2 = extra logic to use, if any, after updating CFLAGS and LIBS
dnl $3 = logic to use if pkg-config does not have the package
AC_DEFUN([CF_TRY_PKG_CONFIG],[
AC_REQUIRE([CF_PKG_CONFIG])

if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists $1; then
	CF_VERBOSE(found package $1)
	cf_pkgconfig_incs="`$PKG_CONFIG --cflags $1 2>/dev/null`"
	cf_pkgconfig_libs="`$PKG_CONFIG --libs   $1 2>/dev/null`"
	CF_VERBOSE(package $1 CFLAGS: $cf_pkgconfig_incs)
	CF_VERBOSE(package $1 LIBS: $cf_pkgconfig_libs)
	CF_ADD_CFLAGS($cf_pkgconfig_incs)
	CF_ADD_LIBS($cf_pkgconfig_libs)
	ifelse([$2],,:,[$2])
else
	cf_pkgconfig_incs=
	cf_pkgconfig_libs=
	ifelse([$3],,:,[$3])
fi
])
dnl ---------------------------------------------------------------------------
dnl CF_TRY_XOPEN_SOURCE version: 1 updated: 2011/10/30 17:09:50
dnl -------------------
dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
dnl can define it successfully.
AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
	AC_TRY_COMPILE([
#include 
#include 
#include 
],[
#ifndef _XOPEN_SOURCE
make an error
#endif],
	[cf_cv_xopen_source=no],
	[cf_save="$CPPFLAGS"
	 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
	 AC_TRY_COMPILE([
#include 
#include 
#include 
],[
#ifdef _XOPEN_SOURCE
make an error
#endif],
	[cf_cv_xopen_source=no],
	[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
	CPPFLAGS="$cf_save"
	])
])

if test "$cf_cv_xopen_source" != no ; then
	CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
	CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
	cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
	CF_ADD_CFLAGS($cf_temp_xopen_source)
fi
])
dnl ---------------------------------------------------------------------------
dnl CF_TTY_GROUP version: 9 updated: 2015/04/12 15:39:00
dnl ------------
dnl Check if the system has a tty-group defined.  This is used in xterm when
dnl setting pty ownership.
AC_DEFUN([CF_TTY_GROUP],
[
AC_MSG_CHECKING(for explicit tty group name)
AC_ARG_WITH(tty-group,
	[  --with-tty-group=XXX    use XXX for the tty-group],
	[cf_tty_group=$withval],
	[cf_tty_group=auto...])
test -z "$cf_tty_group"    && cf_tty_group=auto...
test "$cf_tty_group" = yes && cf_tty_group=auto...
AC_MSG_RESULT($cf_tty_group)

if test "$cf_tty_group" = "auto..." ; then
AC_CACHE_CHECK(for tty group name,cf_cv_tty_group_name,[

# If we are configuring as root, it is hard to get a clue about the tty group.
# But we'll guess based on how our connection is set up - assuming it is done
# properly.

cf_uid=`id | sed -e 's/^[^=]*=//' -e 's/(.*$//'`
# )vi
if test "$cf_uid" != 0 ; then
cf_cv_tty_group_name=
cf_tty_name=`tty`
test "$cf_tty_name" = "not a tty" && cf_tty_name=/dev/tty
test -z "$cf_tty_name" && cf_tty_name=/dev/tty
if test -c "$cf_tty_name"
then
	cf_option="-l -L"

	# Expect listing to have fields like this:
	#-rwxrwxrwx   1 user      group       34293 Jul 18 16:29 pathname
	ls $cf_option $cf_tty_name >conftest.out
	read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest conftest.out
		read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest /dev/null 1>/dev/null ) then
		cf_cv_tty_group_name="tty"
	fi
	;;
esac
fi
])
cf_tty_group="$cf_cv_tty_group_name"
else
	# if configure option, always do this
	AC_DEFINE(USE_TTY_GROUP,1,[Define to 1 if we have a tty groupname])
fi

AC_DEFINE_UNQUOTED(TTY_GROUP_NAME,"$cf_tty_group",[Define to the name use for tty group])

# This is only a double-check that the group-name we obtained above really
# does apply to the device.  We cannot perform this test if we are in batch
# mode, or if we are cross-compiling.

AC_CACHE_CHECK(if we may use the $cf_tty_group group,cf_cv_tty_group,[
cf_tty_name=`tty`
if test "$cf_tty_name" != "not a tty"
then
AC_TRY_RUN([
#include 
#include 
#include 
#include 
int main()
{
	struct stat sb;
	struct group *ttygrp = getgrnam(TTY_GROUP_NAME);
	char *name = ttyname(0);

	endgrent();
	if (ttygrp != 0
	 && name != 0
	 && stat(name, &sb) == 0
	 && sb.st_gid != getgid()
	 && sb.st_gid == ttygrp->gr_gid) {
		${cf_cv_main_return:-return} (0);
	}
	${cf_cv_main_return:-return} (1);
}
	],
	[cf_cv_tty_group=yes],
	[cf_cv_tty_group=no],
	[cf_cv_tty_group=unknown])
elif test "$cross_compiling" = yes; then
	cf_cv_tty_group=unknown
else
	cf_cv_tty_group=yes
fi
])

if test $cf_cv_tty_group = no ; then
	AC_MSG_WARN(Cannot use $cf_tty_group group)
else
	AC_DEFINE(USE_TTY_GROUP)
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_TYPE_CC_T version: 2 updated: 2012/10/04 20:12:20
dnl ------------
dnl	Check for cc_t type, used in termio.
AC_DEFUN([CF_TYPE_CC_T],
[
AC_MSG_CHECKING(for cc_t in  or )
AC_CACHE_VAL(cf_cv_type_cc_t,[
	AC_TRY_COMPILE([
#include 
#if defined(HAVE_TERMIOS_H)
#include 
#else
#include 
#include 
#endif
],
		[cc_t x],
		[cf_cv_type_cc_t=yes],
		[cf_cv_type_cc_t=no])
	])
AC_MSG_RESULT($cf_cv_type_cc_t)
test $cf_cv_type_cc_t = no && AC_DEFINE(cc_t, unsigned char,[Define to cc_t type used in termio])
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_TYPE_FD_MASK version: 3 updated: 2012/10/04 06:57:36
dnl ---------------
dnl Check for the declaration of fd_mask, which is like fd_set, associated
dnl with select().  The check for fd_set should have pulled in this as well,
dnl but there is a special case for Mac OS X, possibly other BSD-derived
dnl platforms.
AC_DEFUN([CF_TYPE_FD_MASK],
[
AC_REQUIRE([CF_TYPE_FD_SET])

AC_CACHE_CHECK(for declaration of fd_mask,cf_cv_type_fd_mask,[
    if test x$cf_cv_type_fd_set = xX11/Xpoll.h ; then
        AC_TRY_COMPILE([
#include ],[fd_mask x],,
        [CF_MSG_LOG(if we must define CSRG_BASED)
# Xosdefs.h on Mac OS X may not define this (but it should).
            AC_TRY_COMPILE([
#define CSRG_BASED
#include ],[fd_mask x],
        cf_cv_type_fd_mask=CSRG_BASED)])
    else
        cf_cv_type_fd_mask=$cf_cv_type_fd_set
    fi
])
if test x$cf_cv_type_fd_mask = xCSRG_BASED ; then
    AC_DEFINE(CSRG_BASED,1,[Define to 1 if needed for declaring fd_mask()])
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_TYPE_FD_SET version: 5 updated: 2012/10/04 20:12:20
dnl --------------
dnl Check for the declaration of fd_set.  Some platforms declare it in
dnl , and some in , which requires .
dnl Finally, if we are using this for an X application, Xpoll.h may include
dnl , so we don't want to do it twice.
AC_DEFUN([CF_TYPE_FD_SET],
[
AC_CHECK_HEADERS(X11/Xpoll.h)

AC_CACHE_CHECK(for declaration of fd_set,cf_cv_type_fd_set,
	[CF_MSG_LOG(sys/types alone)
AC_TRY_COMPILE([
#include ],
	[fd_set x],
	[cf_cv_type_fd_set=sys/types.h],
	[CF_MSG_LOG(X11/Xpoll.h)
AC_TRY_COMPILE([
#ifdef HAVE_X11_XPOLL_H
#include 
#endif],
	[fd_set x],
	[cf_cv_type_fd_set=X11/Xpoll.h],
	[CF_MSG_LOG(sys/select.h)
AC_TRY_COMPILE([
#include 
#include ],
	[fd_set x],
	[cf_cv_type_fd_set=sys/select.h],
	[cf_cv_type_fd_set=unknown])])])])
if test $cf_cv_type_fd_set = sys/select.h ; then
	AC_DEFINE(USE_SYS_SELECT_H,1,[Define to 1 to include sys/select.h to declare fd_set])
fi
])
dnl ---------------------------------------------------------------------------
dnl CF_UNDO_CFLAGS version: 1 updated: 2011/07/02 09:27:51
dnl --------------
dnl Remove flags from $CFLAGS or similar shell variable using sed.
dnl $1 = variable
dnl $2 = message
dnl $3 = pattern to remove
AC_DEFUN([CF_UNDO_CFLAGS],
[
	CF_VERBOSE(removing $2 flags from $1)
	$1=`echo "[$]$1" | sed -e 's/$3//'`
	CF_VERBOSE(...result [$]$1)
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
dnl --------
dnl Make an uppercase version of a variable
dnl $1=uppercase($2)
AC_DEFUN([CF_UPPER],
[
$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_UTEMPTER version: 4 updated: 2012/10/04 20:12:20
dnl -----------
dnl Try to link with utempter library
AC_DEFUN([CF_UTEMPTER],
[
AC_CACHE_CHECK(if we can link with utempter library,cf_cv_have_utempter,[
cf_save_LIBS="$LIBS"
CF_ADD_LIB(utempter)
AC_TRY_LINK([
#include 
],[
	addToUtmp("/dev/tty", 0, 1);
	removeFromUtmp();
],[
	cf_cv_have_utempter=yes],[
	cf_cv_have_utempter=no])
LIBS="$cf_save_LIBS"
])
if test "$cf_cv_have_utempter" = yes ; then
	AC_DEFINE(USE_UTEMPTER,1,[Define to 1 if we can/should link with utempter])
	CF_ADD_LIB(utempter)
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_UTMP version: 10 updated: 2012/10/04 20:12:20
dnl -------
dnl Check for UTMP/UTMPX headers
AC_DEFUN([CF_UTMP],
[
AC_REQUIRE([CF_LASTLOG])

AC_CACHE_CHECK(for utmp implementation,cf_cv_have_utmp,[
	cf_cv_have_utmp=no
for cf_header in utmpx utmp ; do
cf_utmp_includes="
#include 
#include <${cf_header}.h>
#define getutent getutxent
#ifdef USE_LASTLOG
#include 	/* may conflict with utmpx.h on Linux */
#endif
"
	AC_TRY_COMPILE([$cf_utmp_includes],
	[struct $cf_header x;
	 char *name = x.ut_name; /* utmp.h and compatible definitions */
	],
	[cf_cv_have_utmp=$cf_header
	 break],
	[
	AC_TRY_COMPILE([$cf_utmp_includes],
	[struct $cf_header x;
	 char *name = x.ut_user; /* utmpx.h must declare this */
	],
	[cf_cv_have_utmp=$cf_header
	 break
	])])
done
])

if test $cf_cv_have_utmp != no ; then
	AC_DEFINE(HAVE_UTMP,1,[Define to 1 if the utmp interface is available])
	test $cf_cv_have_utmp = utmpx && AC_DEFINE(UTMPX_FOR_UTMP,1,[Define if we have utmpx interface])
	CF_UTMP_UT_HOST
	CF_UTMP_UT_SYSLEN
	CF_UTMP_UT_NAME
	CF_UTMP_UT_XSTATUS
	CF_UTMP_UT_XTIME
	CF_UTMP_UT_SESSION
	CF_SYSV_UTMP
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_UTMP_GROUP version: 1 updated: 2005/10/06 20:29:29
dnl -------------
dnl Find the utmp/utmpx file and determine its group to allow setgid programs
dnl to manipulate it, e.g., when there is no intermediary.
AC_DEFUN([CF_UTMP_GROUP],[
AC_REQUIRE([CF_UTMP])
if test $cf_cv_have_utmp != no ; then
AC_CACHE_CHECK(for utmp/utmpx group,cf_cv_utmp_group,[
for cf_utmp_path in /var/adm /var/run
do
	for cf_utmp_file in utmpx utmp
	do
		if test -f $cf_utmp_path/$cf_utmp_file
		then
			cf_cv_utmp_group=root

			cf_option="-l -L"

			# Expect listing to have fields like this:
			#-r--r--r--   1 user      group       34293 Jul 18 16:29 pathname
			ls $cf_option $cf_utmp_path/$cf_utmp_file >conftest
			read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest conftest
				read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest 
#include <${cf_cv_have_utmp}.h>],
	[struct $cf_cv_have_utmp x; char *y = &x.ut_host[0]],
	[cf_cv_have_utmp_ut_host=yes],
	[cf_cv_have_utmp_ut_host=no])
	])
AC_MSG_RESULT($cf_cv_have_utmp_ut_host)
test $cf_cv_have_utmp_ut_host != no && AC_DEFINE(HAVE_UTMP_UT_HOST,1,[Define to 1 if UTMP/UTMPX struct defines ut_host member])
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_UTMP_UT_NAME version: 6 updated: 2015/04/12 15:39:00
dnl ---------------
dnl Check if UTMP/UTMPX struct defines ut_name member
AC_DEFUN([CF_UTMP_UT_NAME],
[
if test $cf_cv_have_utmp != no ; then
AC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_name is declared,cf_cv_have_utmp_ut_name,[
	cf_cv_have_utmp_ut_name=no
cf_utmp_includes="
#include 
#include <${cf_cv_have_utmp}.h>
#define getutent getutxent
#ifdef USE_LASTLOG
#include 		/* may conflict with utmpx.h on Linux */
#endif
"
for cf_header in ut_name ut_user ; do
	AC_TRY_COMPILE([$cf_utmp_includes],
	[struct $cf_cv_have_utmp x;
	 char *name = x.$cf_header;
	],
	[cf_cv_have_utmp_ut_name=$cf_header
	 break])
done
])

case $cf_cv_have_utmp_ut_name in
(no)
	AC_MSG_ERROR(Cannot find declaration for ut.ut_name)
	;;
(ut_user)
	AC_DEFINE(ut_name,ut_user,[Define to rename UTMP/UTMPX struct ut_name member])
	;;
esac
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_UTMP_UT_SESSION version: 6 updated: 2012/10/04 20:12:20
dnl ------------------
dnl Check if UTMP/UTMPX struct defines ut_session member
AC_DEFUN([CF_UTMP_UT_SESSION],
[
if test $cf_cv_have_utmp != no ; then
AC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_session is declared, cf_cv_have_utmp_ut_session,[
	AC_TRY_COMPILE([
#include 
#include <${cf_cv_have_utmp}.h>],
	[struct $cf_cv_have_utmp x; long y = x.ut_session],
	[cf_cv_have_utmp_ut_session=yes],
	[cf_cv_have_utmp_ut_session=no])
])
if test $cf_cv_have_utmp_ut_session != no ; then
	AC_DEFINE(HAVE_UTMP_UT_SESSION,1,[Define to 1 if UTMP/UTMPX struct defines ut_session member])
fi
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_UTMP_UT_SYSLEN version: 2 updated: 2012/10/04 20:12:20
dnl -----------------
dnl Check if UTMP/UTMPX struct defines ut_syslen member
AC_DEFUN([CF_UTMP_UT_SYSLEN],
[
if test $cf_cv_have_utmp != no ; then
AC_MSG_CHECKING(if ${cf_cv_have_utmp}.ut_syslen is declared)
AC_CACHE_VAL(cf_cv_have_utmp_ut_syslen,[
	AC_TRY_COMPILE([
#include 
#include <${cf_cv_have_utmp}.h>],
	[struct $cf_cv_have_utmp x; int y = x.ut_syslen],
	[cf_cv_have_utmp_ut_syslen=yes],
	[cf_cv_have_utmp_ut_syslen=no])
	])
AC_MSG_RESULT($cf_cv_have_utmp_ut_syslen)
test $cf_cv_have_utmp_ut_syslen != no && AC_DEFINE(HAVE_UTMP_UT_SYSLEN,1,[Define to 1 if UTMP/UTMPX struct defines ut_syslen member])
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_UTMP_UT_XSTATUS version: 4 updated: 2012/10/04 20:12:20
dnl ------------------
dnl Check for known variants on the UTMP/UTMPX struct's exit-status as reported
dnl by various people:
dnl
dnl	ut_exit.__e_exit (HPUX 11 - David Ellement, also in glibc2)
dnl	ut_exit.e_exit (SVR4)
dnl	ut_exit.ut_e_exit (os390 - Greg Smith)
dnl	ut_exit.ut_exit (Tru64 4.0f - Jeremie Petit, 4.0e - Tomas Vanhala)
dnl
dnl Note: utmp_xstatus is not a conventional compatibility definition in the
dnl system header files.
AC_DEFUN([CF_UTMP_UT_XSTATUS],
[
if test $cf_cv_have_utmp != no ; then
AC_CACHE_CHECK(for exit-status in $cf_cv_have_utmp,cf_cv_have_utmp_ut_xstatus,[
for cf_result in \
	ut_exit.__e_exit \
	ut_exit.e_exit \
	ut_exit.ut_e_exit \
	ut_exit.ut_exit
do
AC_TRY_COMPILE([
#include 
#include <${cf_cv_have_utmp}.h>],
	[struct $cf_cv_have_utmp x; long y = x.$cf_result = 0],
	[cf_cv_have_utmp_ut_xstatus=$cf_result
	 break],
	[cf_cv_have_utmp_ut_xstatus=no])
done
])
if test $cf_cv_have_utmp_ut_xstatus != no ; then
	AC_DEFINE(HAVE_UTMP_UT_XSTATUS,1,[Define to 1 if UTMP/UTMPX has exit-status member])
	AC_DEFINE_UNQUOTED(ut_xstatus,$cf_cv_have_utmp_ut_xstatus,[Define if needed to rename member ut_xstatus of UTMP/UTMPX])
fi
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_UTMP_UT_XTIME version: 9 updated: 2012/10/04 20:12:20
dnl ----------------
dnl Check if UTMP/UTMPX struct defines ut_xtime member
AC_DEFUN([CF_UTMP_UT_XTIME],
[
if test $cf_cv_have_utmp != no ; then
AC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_xtime is declared, cf_cv_have_utmp_ut_xtime,[
	AC_TRY_COMPILE([
#include 
#include <${cf_cv_have_utmp}.h>],
	[struct $cf_cv_have_utmp x; long y = x.ut_xtime = 0],
	[cf_cv_have_utmp_ut_xtime=yes],
	[AC_TRY_COMPILE([
#include 
#include <${cf_cv_have_utmp}.h>],
	[struct $cf_cv_have_utmp x; long y = x.ut_tv.tv_sec],
	[cf_cv_have_utmp_ut_xtime=define],
	[cf_cv_have_utmp_ut_xtime=no])
	])
])
if test $cf_cv_have_utmp_ut_xtime != no ; then
	AC_DEFINE(HAVE_UTMP_UT_XTIME,1,[Define to 1 if UTMP/UTMPX struct defines ut_xtime member])
	if test $cf_cv_have_utmp_ut_xtime = define ; then
		AC_DEFINE(ut_xtime,ut_tv.tv_sec,[Define if needed to alternate name for utmpx.ut_xtime member])
	fi
fi
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
dnl ----------
dnl Use AC_VERBOSE w/o the warnings
AC_DEFUN([CF_VERBOSE],
[test -n "$verbose" && echo "	$1" 1>&AC_FD_MSG
CF_MSG_LOG([$1])
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_WITH_APP_CLASS version: 3 updated: 2015/04/12 15:39:00
dnl -----------------
dnl Handle configure option "--with-app-class", setting the $APP_CLASS
dnl variable, used for X resources.
dnl
dnl $1 = default value.
AC_DEFUN([CF_WITH_APP_CLASS],[
AC_MSG_CHECKING(for X applications class)
AC_ARG_WITH(app-class,
	[  --with-app-class=XXX    override X applications class (default $1)],
	[APP_CLASS=$withval],
	[APP_CLASS=$1])

case x$APP_CLASS in
(*[[/@,%]]*)
	AC_MSG_WARN(X applications class cannot contain punctuation)
	APP_CLASS=$1
	;;
(x[[A-Z]]*)
	;;
(*)
	AC_MSG_WARN([X applications class must start with capital, ignoring $APP_CLASS])
	APP_CLASS=$1
	;;
esac

AC_MSG_RESULT($APP_CLASS)

AC_SUBST(APP_CLASS)
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_WITH_APP_DEFAULTS version: 6 updated: 2015/01/02 09:05:50
dnl --------------------
dnl Handle configure option "--with-app-defaults", setting these shell
dnl variables:
dnl
dnl $APPSDIR is the option value, used for installing app-defaults files.
dnl $no_appsdir is a "#" (comment) if "--without-app-defaults" is given.
dnl
dnl Most Linux's use this:
dnl 	/usr/share/X11/app-defaults
dnl Debian uses this:
dnl 	/etc/X11/app-defaults
dnl DragonFlyBSD ports uses this:
dnl 	/usr/pkg/lib/X11/app-defaults
dnl FreeBSD ports use these:
dnl 	/usr/local/lib/X11/app-defaults
dnl 	/usr/local/share/X11/app-defaults
dnl Mandriva has these:
dnl 	/usr/lib/X11/app-defaults
dnl 	/usr/lib64/X11/app-defaults
dnl NetBSD has these
dnl 	/usr/X11R7/lib/X11/app-defaults
dnl OpenSolaris uses
dnl 	32-bit:
dnl 	/usr/X11/etc/X11/app-defaults
dnl 	/usr/X11/share/X11/app-defaults
dnl 	/usr/X11/lib/X11/app-defaults
dnl OSX uses
dnl		/opt/local/share/X11/app-defaults (MacPorts)
dnl		/opt/X11/share/X11/app-defaults (non-ports)
dnl	64-bit:
dnl 	/usr/X11/etc/X11/app-defaults
dnl 	/usr/X11/share/X11/app-defaults (I mkdir'd this)
dnl 	/usr/X11/lib/amd64/X11/app-defaults
dnl Solaris10 uses (in this order):
dnl 	/usr/openwin/lib/X11/app-defaults
dnl 	/usr/X11/lib/X11/app-defaults
AC_DEFUN([CF_WITH_APP_DEFAULTS],[
AC_MSG_CHECKING(for directory to install resource files)
AC_ARG_WITH(app-defaults,
	[  --with-app-defaults=DIR directory in which to install resource files (EPREFIX/lib/X11/app-defaults)],
	[APPSDIR=$withval],
	[APPSDIR='${exec_prefix}/lib/X11/app-defaults'])

if test "x[$]APPSDIR" = xauto
then
	APPSDIR='${exec_prefix}/lib/X11/app-defaults'
	for cf_path in \
		/opt/local/share/X11/app-defaults \
		/opt/X11/share/X11/app-defaults \
		/usr/share/X11/app-defaults \
		/usr/X11/share/X11/app-defaults \
		/usr/X11/lib/X11/app-defaults \
		/usr/lib/X11/app-defaults \
		/etc/X11/app-defaults \
		/usr/pkg/lib/X11/app-defaults \
		/usr/X11R7/lib/X11/app-defaults \
		/usr/X11R6/lib/X11/app-defaults \
		/usr/X11R5/lib/X11/app-defaults \
		/usr/X11R4/lib/X11/app-defaults \
		/usr/local/lib/X11/app-defaults \
		/usr/local/share/X11/app-defaults \
		/usr/lib64/X11/app-defaults
	do
		if test -d "$cf_path" ; then
			APPSDIR="$cf_path"
			break
		fi
	done
else
	cf_path=$APPSDIR
	CF_PATH_SYNTAX(cf_path)
fi

AC_MSG_RESULT($APPSDIR)
AC_SUBST(APPSDIR)

no_appsdir=
if test "$APPSDIR" = no
then
	no_appsdir="#"
else
	EXTRA_INSTALL_DIRS="$EXTRA_INSTALL_DIRS \$(APPSDIR)"
fi
AC_SUBST(no_appsdir)
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
dnl ----------------
dnl Configure-option for dbmalloc.  The optional parameter is used to override
dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
AC_DEFUN([CF_WITH_DBMALLOC],[
CF_NO_LEAKS_OPTION(dbmalloc,
	[  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
	[USE_DBMALLOC])

if test "$with_dbmalloc" = yes ; then
	AC_CHECK_HEADER(dbmalloc.h,
		[AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_WITH_DESKTOP_CATEGORY version: 5 updated: 2015/04/12 15:39:00
dnl ------------------------
dnl Taking into account the absence of standardization of desktop categories
dnl take a look to see whether other applications on the current system are
dnl assigned any/all of a set of suggested categories.
dnl
dnl $1 = program name
dnl $2 = case-pattern to match comparable desktop files to obtain category
dnl      This pattern may contain wildcards.
dnl $3 = suggested categories, also a case-pattern but without wildcards,
dnl      since it doubles as a default value for a shell case-statement.
dnl $4 = categories to use if no match is found on the build-machine for the
dnl      --with-desktop-category "auto" setting.
dnl
dnl The macro tells the configure script to substitute the $DESKTOP_CATEGORY
dnl value.
AC_DEFUN([CF_WITH_DESKTOP_CATEGORY],[
AC_REQUIRE([CF_DISABLE_DESKTOP])

if test -z "$desktop_utils"
then
	AC_MSG_CHECKING(for requested desktop-category)
	AC_ARG_WITH(desktop-category,
		[  --with-desktop-category=XXX  one or more desktop catgories or auto],
		[cf_desktop_want=$withval],
		[cf_desktop_want=auto])
	AC_MSG_RESULT($cf_desktop_want)

	if test "$cf_desktop_want" = auto
	then
		rm -rf conftest*
		cf_desktop_also=
		for cf_desktop_dir in  \
			/usr/share/app-install \
			/usr/share/applications
		do
			if test -d $cf_desktop_dir
			then
				find $cf_desktop_dir -name '*.desktop' | \
				while true
				do
					read cf_desktop_path
					test -z "$cf_desktop_path" && break
					cf_desktop_name=`basename $cf_desktop_path .desktop`
					case $cf_desktop_name in
					($1|*-$1|$2)
						CF_VERBOSE(inspect $cf_desktop_path)
						egrep '^Categories=' $cf_desktop_path | \
							tr ';' '\n' | \
							sed -e 's%^.*=%%' -e '/^$/d' >>conftest.1
						;;
					esac
				done
			fi
		done
		if test -s conftest.1
		then
			cf_desktop_last=
			sort conftest.1 | \
			while true
			do
				read cf_desktop_this
				test -z "$cf_desktop_this" && break
				case $cf_desktop_this in
				(Qt*|GTK*|KDE*|GNOME*|*XFCE*|*Xfce*)
					;;
				($3)
					test "x$cf_desktop_last" != "x$cf_desktop_this" && echo $cf_desktop_this >>conftest.2
					;;
				esac
				cf_desktop_last=$cf_desktop_this
			done
			cf_desktop_want=`cat conftest.2 | tr '\n' ';'`
		fi
		if test -n "$cf_desktop_want"
		then
			if test "$cf_desktop_want" = auto
			then
				cf_desktop_want=
			else
				# do a sanity check on the semicolon-separated list, ignore on failure
				cf_desktop_test=`echo "$cf_desktop_want" | sed -e 's/[[^;]]//g'`
				test -z "$cf_desktop_test" && cf_desktop_want=
				cf_desktop_test=`echo "$cf_desktop_want" | sed -e 's/^.*;$/./g'`
				test -z "$cf_desktop_test" && cf_desktop_want=
			fi
		fi
		if test -z "$cf_desktop_want"
		then
			cf_desktop_want="ifelse([$4],,ifelse([$3],,[Application;],[`echo "$3" | sed -e 's/\*//g' -e 's/|/;/g' -e 's/[[;]]*$/;/g'`]),[$4])"
			CF_VERBOSE(no usable value found for desktop category, using $cf_desktop_want)
		fi
	fi
	DESKTOP_CATEGORY=`echo "$cf_desktop_want" | sed -e 's/[[ ,]]/;/g'`
	CF_VERBOSE(will use Categories=$DESKTOP_CATEGORY)
	AC_SUBST(DESKTOP_CATEGORY)
fi
])
dnl ---------------------------------------------------------------------------
dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
dnl ---------------
dnl Configure-option for dmalloc.  The optional parameter is used to override
dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
AC_DEFUN([CF_WITH_DMALLOC],[
CF_NO_LEAKS_OPTION(dmalloc,
	[  --with-dmalloc          test: use Gray Watson's dmalloc library],
	[USE_DMALLOC])

if test "$with_dmalloc" = yes ; then
	AC_CHECK_HEADER(dmalloc.h,
		[AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_WITH_ICONDIR version: 5 updated: 2012/07/22 09:18:02
dnl ---------------
dnl Handle configure option "--with-icondir", setting these shell variables:
dnl
dnl $ICONDIR is the option value, used for installing icon files.
dnl $no_icondir is a "#" (comment) if "--without-icondir" is given.
AC_DEFUN([CF_WITH_ICONDIR],[
AC_MSG_CHECKING(for directory to install icons)
AC_ARG_WITH(icondir,
	[  --with-icondir=DIR      directory in which to install icons for desktop],
	[ICONDIR=$withval],
	[test -z "$ICONDIR" && ICONDIR=no])

if test "x[$]ICONDIR" = xauto
then
	ICONDIR='${datadir}/icons'
	for cf_path in \
		/usr/share/icons \
		/usr/X11R6/share/icons
	do
		if test -d "$cf_path" ; then
			ICONDIR="$cf_path"
			break
		fi
	done
else
	cf_path=$ICONDIR
	CF_PATH_SYNTAX(cf_path)
fi
AC_MSG_RESULT($ICONDIR)
AC_SUBST(ICONDIR)

no_icondir=
if test "$ICONDIR" = no
then
	no_icondir="#"
else
	EXTRA_INSTALL_DIRS="$EXTRA_INSTALL_DIRS \$(ICONDIR)"
fi
AC_SUBST(no_icondir)
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_WITH_ICON_NAME version: 3 updated: 2015/04/12 15:39:00
dnl -----------------
dnl Allow a default icon-name to be overridden.
dnl $1 = default icon name
AC_DEFUN([CF_WITH_ICON_NAME],[
AC_MSG_CHECKING(for the icon name)
AC_ARG_WITH(icon-name,
	[  --with-icon-name=XXXX   override icon name (default: $1)],
	[ICON_NAME="$withval"],
	[ICON_NAME=$1])
case "x$ICON_NAME" in
(xyes|xno|x)
	ICON_NAME=$1
	;;
esac
AC_SUBST(ICON_NAME)
AC_MSG_RESULT($ICON_NAME)
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_WITH_ICON_SYMLINK version: 2 updated: 2015/04/12 15:39:00
dnl --------------------
dnl Workaround for systems which are (mis)configured to map all icon references
dnl for xterm into "xterm" name.  For instance, recent (2013) KDE ignores both
dnl the name given in the .desktop file (xterm-color) and the application name
dnl (xterm-dev).
dnl
dnl $1 = default icon name to use if symlink is wanted
AC_DEFUN([CF_WITH_ICON_SYMLINK],[
AC_MSG_CHECKING(for icon symlink to use)
AC_ARG_WITH(icon-symlink,
	[  --with-icon-symlink=XXX make symbolic link for icon name (default: $1)],
	[ICON_SYMLINK="$withval"],
	[ICON_SYMLINK=NONE])
case "x$ICON_SYMLINK" in
(xyes)
	ICON_SYMLINK=$1
	;;
(xno|x)
	ICON_SYMLINK=NONE
	;;
esac
AC_SUBST(ICON_SYMLINK)
AC_MSG_RESULT($ICON_SYMLINK)
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_WITH_ICON_THEME version: 11 updated: 2015/04/12 15:39:00
dnl ------------------
dnl If asked, check for prerequisites and setup symbols to permit installing
dnl one or more application icons in the Red Hat icon-theme directory
dnl hierarchy.
dnl
dnl If the prerequisites are missing, give a warning and revert to the long-
dnl standing pixmaps directory.
dnl
dnl Parameters:
dnl
dnl $1 = application icon.  This can be a list, and is not optional.
dnl $2 = default theme (defaults to hicolor)
dnl $3 = formats (defaults to list [.svg .png .xpm])
dnl $4 = alternate icon if no theme is used (defaults to $1).
dnl
dnl Result:
dnl ICON_NAME = basename of first item in $1
dnl ICON_LIST = reprocessed $1
dnl ICON_THEME = reprocessed $2
dnl ICON_FORMAT = reprocessed $3
AC_DEFUN([CF_WITH_ICON_THEME],
[
ifelse([$1],,[
	AC_MSG_ERROR([macro [CF_WITH_ICON_THEME] requires application-icon name])
],[

CF_WITH_PIXMAPDIR
CF_WITH_ICONDIR

AC_MSG_CHECKING(if icon theme should be used)
AC_ARG_WITH(icon-theme,
	[  --with-icon-theme=XXX   install icons into desktop theme (hicolor)],
	[ICON_THEME=$withval],
	[ICON_THEME=no])

case "x$ICON_THEME" in
(xno)
	;;
(x|xyes)
	ICON_THEME=ifelse([$2],,hicolor,$2)
	;;
esac
AC_MSG_RESULT($ICON_THEME)

if test "x$ICON_THEME" = xno
then
	if test "x$ICONDIR" != xno
	then
		CF_VERBOSE(ignoring icondir without theme)
		no_icondir="#"
	fi
else
	if test "x$ICONDIR" = xno
	then
		AC_MSG_ERROR(icondir must be set for icon theme)
	fi
fi

: ${ICON_FORMAT:=ifelse([$3],,[".svg .png .xpm"],[$3])}

# ICON_NAME=
ICON_LIST=

ifelse([$4],,[cf_icon_list=$1],[
if test "x$ICON_THEME" != xno
then
	cf_icon_list="$1"
else
	cf_icon_list="$4"
fi
])

AC_MSG_CHECKING([for icon(s) to install])
for cf_name in $cf_icon_list
do
	CF_VERBOSE(using $ICON_FORMAT)
	for cf_suffix in $ICON_FORMAT
	do
		cf_icon="${cf_name}${cf_suffix}"
		cf_left=`echo "$cf_icon" | sed -e 's/:.*//'`
		if test ! -f "${cf_left}"
		then
			if test "x$srcdir" != "x."
			then
				cf_icon="${srcdir}/${cf_left}"
				cf_left=`echo "$cf_icon" | sed -e 's/:.*//'`
				if test ! -f "${cf_left}"
				then
					continue
				fi
			else
				continue
			fi
		fi
		if test "x$ICON_THEME" != xno
		then
			cf_base=`basename $cf_left`
			cf_trim=`echo "$cf_base" | sed -e 's/_[[0-9]][[0-9]]x[[0-9]][[0-9]]\././'`
			case "x${cf_base}" in
			(*:*)
				cf_next=$cf_base
				# user-defined mapping
				;;
			(*.png)
				cf_size=`file "$cf_left"|sed -e 's/^[[^:]]*://' -e 's/^.*[[^0-9]]\([[0-9]][[0-9]]* x [[0-9]][[0-9]]*\)[[^0-9]].*$/\1/' -e 's/ //g'`
				if test -z "$cf_size"
				then
					AC_MSG_WARN(cannot determine size of $cf_left)
					continue
				fi
				cf_next="$cf_size/apps/$cf_trim"
				;;
			(*.svg)
				cf_next="scalable/apps/$cf_trim"
				;;
			(*.xpm)
				CF_VERBOSE(ignored XPM file in icon theme)
				continue
				;;
			(*_[[0-9]][[0-9]]*x[[0-9]][[0-9]]*.*)
				cf_size=`echo "$cf_left"|sed -e 's/^.*_\([[0-9]][[0-9]]*x[[0-9]][[0-9]]*\)\..*$/\1/'`
				cf_left=`echo "$cf_left"|sed -e 's/^\(.*\)_\([[0-9]][[0-9]]*x[[0-9]][[0-9]]*\)\(\..*\)$/\1\3/'`
				cf_next="$cf_size/apps/$cf_base"
				;;
			esac
			CF_VERBOSE(adding $cf_next)
			cf_icon="${cf_icon}:${cf_next}"
		fi
		test -n "$ICON_LIST" && ICON_LIST="$ICON_LIST "
		ICON_LIST="$ICON_LIST${cf_icon}"
		if test -z "$ICON_NAME"
		then
			ICON_NAME=`basename $cf_icon | sed -e 's/[[.:]].*//'`
		fi
	done
done

if test -n "$verbose"
then
	AC_MSG_CHECKING(result)
fi
AC_MSG_RESULT($ICON_LIST)

if test -z "$ICON_LIST"
then
	AC_MSG_ERROR(no icons found)
fi
])

AC_MSG_CHECKING(for icon name)
AC_MSG_RESULT($ICON_NAME)

AC_SUBST(ICON_FORMAT)
AC_SUBST(ICON_THEME)
AC_SUBST(ICON_LIST)
AC_SUBST(ICON_NAME)
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_WITH_IMAKE_CFLAGS version: 10 updated: 2015/04/12 15:39:00
dnl --------------------
dnl xterm and similar programs build more readily when propped up with imake's
dnl hand-tuned definitions.  If we do not use imake, provide fallbacks for the
dnl most common definitions that we're not likely to do by autoconf tests.
AC_DEFUN([CF_WITH_IMAKE_CFLAGS],[
AC_REQUIRE([CF_ENABLE_NARROWPROTO])

AC_MSG_CHECKING(if we should use imake to help)
CF_ARG_DISABLE(imake,
	[  --disable-imake         disable use of imake for definitions],
	[enable_imake=no],
	[enable_imake=yes])
AC_MSG_RESULT($enable_imake)

if test "$enable_imake" = yes ; then
	CF_IMAKE_CFLAGS(ifelse([$1],,,[$1]))
fi

if test -n "$IMAKE" && test -n "$IMAKE_CFLAGS" ; then
	CF_ADD_CFLAGS($IMAKE_CFLAGS)
else
	IMAKE_CFLAGS=
	IMAKE_LOADFLAGS=
	CF_VERBOSE(make fallback definitions)

	# We prefer config.guess' values when we can get them, to avoid
	# inconsistent results with uname (AIX for instance).  However,
	# config.guess is not always consistent either.
	case $host_os in
	(*[[0-9]].[[0-9]]*)
		UNAME_RELEASE="$host_os"
		;;
	(*)
		UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
		;;
	esac

	case .$UNAME_RELEASE in
	(*[[0-9]].[[0-9]]*)
		OSMAJORVERSION=`echo "$UNAME_RELEASE" |sed -e 's/^[[^0-9]]*//' -e 's/\..*//'`
		OSMINORVERSION=`echo "$UNAME_RELEASE" |sed -e 's/^[[^0-9]]*//' -e 's/^[[^.]]*\.//' -e 's/\..*//' -e 's/[[^0-9]].*//' `
		test -z "$OSMAJORVERSION" && OSMAJORVERSION=1
		test -z "$OSMINORVERSION" && OSMINORVERSION=0
		IMAKE_CFLAGS="-DOSMAJORVERSION=$OSMAJORVERSION -DOSMINORVERSION=$OSMINORVERSION $IMAKE_CFLAGS"
		;;
	esac

	# FUNCPROTO is standard with X11R6, but XFree86 drops it, leaving some
	# fallback/fragments for NeedPrototypes, etc.
	IMAKE_CFLAGS="-DFUNCPROTO=15 $IMAKE_CFLAGS"

	# If this is not set properly, Xaw's scrollbars will not work
	if test "$enable_narrowproto" = yes ; then
		IMAKE_CFLAGS="-DNARROWPROTO=1 $IMAKE_CFLAGS"
	fi

	# Other special definitions:
	case $host_os in
	(aix*)
		# imake on AIX 5.1 defines AIXV3.  really.
		IMAKE_CFLAGS="-DAIXV3 -DAIXV4 $IMAKE_CFLAGS"
		;;
	(irix[[56]].*)
		# these are needed to make SIGWINCH work in xterm
		IMAKE_CFLAGS="-DSYSV -DSVR4 $IMAKE_CFLAGS"
		;;
	esac

	CF_ADD_CFLAGS($IMAKE_CFLAGS)

	AC_SUBST(IMAKE_CFLAGS)
	AC_SUBST(IMAKE_LOADFLAGS)
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_WITH_MAN2HTML version: 5 updated: 2015/08/20 04:51:36
dnl ----------------
dnl Check for man2html and groff.  Optionally prefer man2html over groff.
dnl Generate a shell script which hides the differences between the two.
dnl
dnl We name that "man2html.tmp".
dnl
dnl The shell script can be removed later, e.g., using "make distclean".
AC_DEFUN([CF_WITH_MAN2HTML],[
AC_REQUIRE([CF_PROG_GROFF])

AC_MSG_CHECKING(for program to convert manpage to html)
AC_ARG_WITH(man2html,
	[  --with-man2html=XXX     use XXX rather than groff],
	[cf_man2html=$withval],
	[cf_man2html=$GROFF_PATH])

cf_with_groff=no

case $cf_man2html in
(yes)
	AC_MSG_RESULT(man2html)
	AC_PATH_PROG(cf_man2html,man2html,no)
	;;
(no|groff|*/groff*)
	cf_with_groff=yes
	cf_man2html=$GROFF_PATH
	AC_MSG_RESULT($cf_man2html)
	;;
(*)
	AC_MSG_RESULT($cf_man2html)
	;;
esac

MAN2HTML_TEMP="man2html.tmp"
	cat >$MAN2HTML_TEMP <>$MAN2HTML_TEMP <conftest.in <conftest.out

	cf_man2html_1st=`fgrep -n MARKER conftest.out |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`
	cf_man2html_top=`expr $cf_man2html_1st - 2`
	cf_man2html_bot=`wc -l conftest.out |sed -e 's/[[^0-9]]//g'`
	cf_man2html_bot=`expr $cf_man2html_bot - 2 - $cf_man2html_top`
	cf_man2html_top_bot="-topm=$cf_man2html_top -botm=$cf_man2html_bot"

	AC_MSG_RESULT($cf_man2html_top_bot)

	AC_MSG_CHECKING(for pagesize to use)
	for cf_block in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
	do
	cat >>conftest.in <conftest.out
	cf_man2html_page=`fgrep -n HEAD1 conftest.out |tail -n 1 |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`
	test -z "$cf_man2html_page" && cf_man2html_page=99999
	test "$cf_man2html_page" -gt 100 && cf_man2html_page=99999

	rm -rf conftest*
	AC_MSG_RESULT($cf_man2html_page)

	cat >>$MAN2HTML_TEMP <
#include 		/* has the prototype */
#include 	/* has the XkbBI_xxx definitions */
],[
	int x = (XkbBI_Info |XkbBI_MinorError |XkbBI_MajorError |XkbBI_TerminalBell |XkbBI_MarginBell);
	Atom y;
	XkbBell((Display *)0, (Widget)0, 0, y);
],[cf_cv_xkb_bell_ext=yes],[cf_cv_xkb_bell_ext=no])
])
test "$cf_cv_xkb_bell_ext" = yes && AC_DEFINE(HAVE_XKB_BELL_EXT,1,[Define 1 if we have XKB Bell extension])
])
dnl ---------------------------------------------------------------------------
dnl CF_XKB_KEYCODE_TO_KEYSYM version: 2 updated: 2012/09/28 20:23:33
dnl ------------------------
dnl Some older vendor-unix systems made a practice of delivering fragments of
dnl Xkb, requiring test-compiles.
AC_DEFUN([CF_XKB_KEYCODE_TO_KEYSYM],[
AC_CACHE_CHECK(if we can use XkbKeycodeToKeysym, cf_cv_xkb_keycode_to_keysym,[
AC_TRY_COMPILE([
#include 
#include 
],[
    KeySym keysym = XkbKeycodeToKeysym((Display *)0, 0, 0, 0);
],[
cf_cv_xkb_keycode_to_keysym=yes
],[
cf_cv_xkb_keycode_to_keysym=no
])
])

if test $cf_cv_xkb_keycode_to_keysym = yes
then
	AC_CHECK_FUNCS(XkbKeycodeToKeysym)
fi
])
dnl ---------------------------------------------------------------------------
dnl CF_XKB_QUERY_EXTENSION version: 2 updated: 2012/09/28 20:23:46
dnl ----------------------
dnl see ifdef in scrollbar.c - iron out here
AC_DEFUN([CF_XKB_QUERY_EXTENSION],[
AC_CACHE_CHECK(if we can use XkbQueryExtension, cf_cv_xkb_query_extension,[
AC_TRY_COMPILE([
#include 
#include 
#include 
],[
	int xkbmajor = XkbMajorVersion;
	int xkbminor = XkbMinorVersion;
	int xkbopcode, xkbevent, xkberror;

	if (XkbLibraryVersion(&xkbmajor, &xkbminor)
	    && XkbQueryExtension((Display *)0,
				 &xkbopcode,
				 &xkbevent,
				 &xkberror,
				 &xkbmajor,
				 &xkbminor))
		 return 0;
],[
cf_cv_xkb_query_extension=yes
],[
cf_cv_xkb_query_extension=no
])
])

if test $cf_cv_xkb_query_extension = yes
then
	AC_CHECK_FUNCS(XkbQueryExtension)
fi
])
dnl ---------------------------------------------------------------------------
dnl CF_XOPEN_SOURCE version: 52 updated: 2016/08/27 12:21:42
dnl ---------------
dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
dnl or adapt to the vendor's definitions to get equivalent functionality,
dnl without losing the common non-POSIX features.
dnl
dnl Parameters:
dnl	$1 is the nominal value for _XOPEN_SOURCE
dnl	$2 is the nominal value for _POSIX_C_SOURCE
AC_DEFUN([CF_XOPEN_SOURCE],[
AC_REQUIRE([AC_CANONICAL_HOST])

cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
cf_xopen_source=

case $host_os in
(aix[[4-7]]*)
	cf_xopen_source="-D_ALL_SOURCE"
	;;
(msys)
	cf_XOPEN_SOURCE=600
	;;
(darwin[[0-8]].*)
	cf_xopen_source="-D_APPLE_C_SOURCE"
	;;
(darwin*)
	cf_xopen_source="-D_DARWIN_C_SOURCE"
	cf_XOPEN_SOURCE=
	;;
(freebsd*|dragonfly*)
	# 5.x headers associate
	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
	cf_POSIX_C_SOURCE=200112L
	cf_XOPEN_SOURCE=600
	cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
	;;
(hpux11*)
	cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
	;;
(hpux*)
	cf_xopen_source="-D_HPUX_SOURCE"
	;;
(irix[[56]].*)
	cf_xopen_source="-D_SGI_SOURCE"
	cf_XOPEN_SOURCE=
	;;
(linux*|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin)
	CF_GNU_SOURCE
	;;
(minix*)
	cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
	;;
(mirbsd*)
	# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks  and other headers which use u_int / u_short types
	cf_XOPEN_SOURCE=
	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
	;;
(netbsd*)
	cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
	;;
(openbsd[[4-9]]*)
	# setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
	cf_xopen_source="-D_BSD_SOURCE"
	cf_XOPEN_SOURCE=600
	;;
(openbsd*)
	# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
	;;
(osf[[45]]*)
	cf_xopen_source="-D_OSF_SOURCE"
	;;
(nto-qnx*)
	cf_xopen_source="-D_QNX_SOURCE"
	;;
(sco*)
	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
	;;
(solaris2.*)
	cf_xopen_source="-D__EXTENSIONS__"
	cf_cv_xopen_source=broken
	;;
(sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2)
	cf_XOPEN_SOURCE=
	cf_POSIX_C_SOURCE=
	;;
(*)
	CF_TRY_XOPEN_SOURCE
	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
	;;
esac

if test -n "$cf_xopen_source" ; then
	CF_ADD_CFLAGS($cf_xopen_source,true)
fi

dnl In anything but the default case, we may have system-specific setting
dnl which is still not guaranteed to provide all of the entrypoints that
dnl _XOPEN_SOURCE would yield.
if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
	AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
	AC_TRY_COMPILE([#include ],[
#ifndef _XOPEN_SOURCE
make an error
#endif],
	[cf_XOPEN_SOURCE_set=yes],
	[cf_XOPEN_SOURCE_set=no])
	AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
	if test $cf_XOPEN_SOURCE_set = yes
	then
		AC_TRY_COMPILE([#include ],[
#if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
make an error
#endif],
		[cf_XOPEN_SOURCE_set_ok=yes],
		[cf_XOPEN_SOURCE_set_ok=no])
		if test $cf_XOPEN_SOURCE_set_ok = no
		then
			AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
		fi
	else
		CF_TRY_XOPEN_SOURCE
	fi
fi
])
dnl ---------------------------------------------------------------------------
dnl CF_X_ATHENA version: 23 updated: 2015/04/12 15:39:00
dnl -----------
dnl Check for Xaw (Athena) libraries
dnl
dnl Sets $cf_x_athena according to the flavor of Xaw which is used.
AC_DEFUN([CF_X_ATHENA],
[
cf_x_athena=${cf_x_athena:-Xaw}

AC_MSG_CHECKING(if you want to link with Xaw 3d library)
withval=
AC_ARG_WITH(Xaw3d,
	[  --with-Xaw3d            link with Xaw 3d library])
if test "$withval" = yes ; then
	cf_x_athena=Xaw3d
	AC_MSG_RESULT(yes)
else
	AC_MSG_RESULT(no)
fi

AC_MSG_CHECKING(if you want to link with Xaw 3d xft library)
withval=
AC_ARG_WITH(Xaw3dxft,
	[  --with-Xaw3dxft         link with Xaw 3d xft library])
if test "$withval" = yes ; then
	cf_x_athena=Xaw3dxft
	AC_MSG_RESULT(yes)
else
	AC_MSG_RESULT(no)
fi

AC_MSG_CHECKING(if you want to link with neXT Athena library)
withval=
AC_ARG_WITH(neXtaw,
	[  --with-neXtaw           link with neXT Athena library])
if test "$withval" = yes ; then
	cf_x_athena=neXtaw
	AC_MSG_RESULT(yes)
else
	AC_MSG_RESULT(no)
fi

AC_MSG_CHECKING(if you want to link with Athena-Plus library)
withval=
AC_ARG_WITH(XawPlus,
	[  --with-XawPlus          link with Athena-Plus library])
if test "$withval" = yes ; then
	cf_x_athena=XawPlus
	AC_MSG_RESULT(yes)
else
	AC_MSG_RESULT(no)
fi

cf_x_athena_lib=""

if test "$PKG_CONFIG" != none ; then
	cf_athena_list=
	test "$cf_x_athena" = Xaw && cf_athena_list="xaw8 xaw7 xaw6"
	for cf_athena_pkg in \
		$cf_athena_list \
		${cf_x_athena} \
		${cf_x_athena}-devel \
		lib${cf_x_athena} \
		lib${cf_x_athena}-devel
	do
		CF_TRY_PKG_CONFIG($cf_athena_pkg,[
			cf_x_athena_lib="$cf_pkgconfig_libs"
			CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
			AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)

			CF_TRIM_X_LIBS

AC_CACHE_CHECK(for usable $cf_x_athena/Xmu package,cf_cv_xaw_compat,[
AC_TRY_LINK([
#include 
],[
int check = XmuCompareISOLatin1("big", "small")
],[cf_cv_xaw_compat=yes],[cf_cv_xaw_compat=no])])

			if test "$cf_cv_xaw_compat" = no
			then
				# workaround for broken ".pc" files...
				case "$cf_x_athena_lib" in
				(*-lXmu*)
					;;
				(*)
					CF_VERBOSE(work around broken package)
					cf_save_xmu="$LIBS"
					cf_first_lib=`echo "$cf_save_xmu" | sed -e 's/^[ ][ ]*//' -e 's/ .*//'`
					CF_TRY_PKG_CONFIG(xmu,[
							LIBS="$cf_save_xmu"
							CF_ADD_LIB_AFTER($cf_first_lib,$cf_pkgconfig_libs)
						],[
							CF_ADD_LIB_AFTER($cf_first_lib,-lXmu)
						])
					CF_TRIM_X_LIBS
					;;
				esac
			fi

			break])
	done
fi

if test -z "$cf_x_athena_lib" ; then
	CF_X_EXT
	CF_X_TOOLKIT
	CF_X_ATHENA_CPPFLAGS($cf_x_athena)
	CF_X_ATHENA_LIBS($cf_x_athena)
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_X_ATHENA_CPPFLAGS version: 5 updated: 2010/05/26 17:35:30
dnl --------------------
dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
AC_DEFUN([CF_X_ATHENA_CPPFLAGS],
[
cf_x_athena_root=ifelse([$1],,Xaw,[$1])
cf_x_athena_inc=""

for cf_path in default \
	/usr/contrib/X11R6 \
	/usr/contrib/X11R5 \
	/usr/lib/X11R5 \
	/usr/local
do
	if test -z "$cf_x_athena_inc" ; then
		cf_save="$CPPFLAGS"
		cf_test=X11/$cf_x_athena_root/SimpleMenu.h
		if test $cf_path != default ; then
			CPPFLAGS="$cf_save -I$cf_path/include"
			AC_MSG_CHECKING(for $cf_test in $cf_path)
		else
			AC_MSG_CHECKING(for $cf_test)
		fi
		AC_TRY_COMPILE([
#include 
#include <$cf_test>],[],
			[cf_result=yes],
			[cf_result=no])
		AC_MSG_RESULT($cf_result)
		if test "$cf_result" = yes ; then
			cf_x_athena_inc=$cf_path
			break
		else
			CPPFLAGS="$cf_save"
		fi
	fi
done

if test -z "$cf_x_athena_inc" ; then
	AC_MSG_WARN(
[Unable to successfully find Athena header files with test program])
elif test "$cf_x_athena_inc" != default ; then
	CPPFLAGS="$CPPFLAGS -I$cf_x_athena_inc"
fi
])
dnl ---------------------------------------------------------------------------
dnl CF_X_ATHENA_LIBS version: 12 updated: 2011/07/17 19:55:02
dnl ----------------
dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
AC_DEFUN([CF_X_ATHENA_LIBS],
[AC_REQUIRE([CF_X_TOOLKIT])
cf_x_athena_root=ifelse([$1],,Xaw,[$1])
cf_x_athena_lib=""

for cf_path in default \
	/usr/contrib/X11R6 \
	/usr/contrib/X11R5 \
	/usr/lib/X11R5 \
	/usr/local
do
	for cf_lib in \
		${cf_x_athena_root} \
		${cf_x_athena_root}7 \
		${cf_x_athena_root}6
	do
	for cf_libs in \
		"-l$cf_lib -lXmu" \
		"-l$cf_lib -lXpm -lXmu" \
		"-l${cf_lib}_s -lXmu_s"
	do
		if test -z "$cf_x_athena_lib" ; then
			cf_save="$LIBS"
			cf_test=XawSimpleMenuAddGlobalActions
			if test $cf_path != default ; then
				CF_ADD_LIBS(-L$cf_path/lib $cf_libs)
				AC_MSG_CHECKING(for $cf_libs in $cf_path)
			else
				CF_ADD_LIBS($cf_libs)
				AC_MSG_CHECKING(for $cf_test in $cf_libs)
			fi
			AC_TRY_LINK([
#include 
#include 
],[
$cf_test((XtAppContext) 0)],
				[cf_result=yes],
				[cf_result=no])
			AC_MSG_RESULT($cf_result)
			if test "$cf_result" = yes ; then
				cf_x_athena_lib="$cf_libs"
				break
			fi
			LIBS="$cf_save"
		fi
	done # cf_libs
		test -n "$cf_x_athena_lib" && break
	done # cf_lib
done

if test -z "$cf_x_athena_lib" ; then
	AC_MSG_ERROR(
[Unable to successfully link Athena library (-l$cf_x_athena_root) with test program])
fi

CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
])
dnl ---------------------------------------------------------------------------
dnl CF_X_EXT version: 3 updated: 2010/06/02 05:03:05
dnl --------
AC_DEFUN([CF_X_EXT],[
CF_TRY_PKG_CONFIG(Xext,,[
	AC_CHECK_LIB(Xext,XextCreateExtension,
		[CF_ADD_LIB(Xext)])])
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_X_FONTCONFIG version: 6 updated: 2015/04/12 15:39:00
dnl ---------------
dnl Check for fontconfig library, a dependency of the X FreeType library.
AC_DEFUN([CF_X_FONTCONFIG],
[
AC_REQUIRE([CF_X_FREETYPE])

if test "$cf_cv_found_freetype" = yes ; then
AC_CACHE_CHECK(for usable Xft/fontconfig package,cf_cv_xft_compat,[
AC_TRY_LINK([
#include 
],[
	XftPattern *pat;
	XftPatternBuild(pat,
					XFT_FAMILY, XftTypeString, "mono",
					(void *) 0);
],[cf_cv_xft_compat=yes],[cf_cv_xft_compat=no])
])

if test "$cf_cv_xft_compat" = no
then
	# workaround for broken ".pc" files used for Xft.
	case "$cf_cv_x_freetype_libs" in
	(*-lfontconfig*)
		;;
	(*)
		CF_VERBOSE(work around broken package)
		cf_save_fontconfig="$LIBS"
		CF_TRY_PKG_CONFIG(fontconfig,[
				CF_ADD_CFLAGS($cf_pkgconfig_incs)
				LIBS="$cf_save_fontconfig"
				CF_ADD_LIB_AFTER(-lXft,$cf_pkgconfig_libs)
			],[
				CF_ADD_LIB_AFTER(-lXft,-lfontconfig)
			])
		;;
	esac
fi
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_X_FREETYPE version: 27 updated: 2015/04/12 15:39:00
dnl -------------
dnl Check for X FreeType headers and libraries (XFree86 4.x, etc).
dnl
dnl First check for the appropriate config program, since the developers for
dnl these libraries change their configuration (and config program) more or
dnl less randomly.  If we cannot find the config program, do not bother trying
dnl to guess the latest variation of include/lib directories.
dnl
dnl If either or both of these configure-script options are not given, rely on
dnl the output of the config program to provide the cflags/libs options:
dnl	--with-freetype-cflags
dnl	--with-freetype-libs
AC_DEFUN([CF_X_FREETYPE],
[
AC_REQUIRE([CF_PKG_CONFIG])

cf_cv_x_freetype_incs=no
cf_cv_x_freetype_libs=no
cf_extra_freetype_libs=
FREETYPE_CONFIG=none
FREETYPE_PARAMS=

AC_MSG_CHECKING(for FreeType configuration script)
AC_ARG_WITH(freetype-config,
	[  --with-freetype-config  configure script to use for FreeType],
	[cf_cv_x_freetype_cfgs="$withval"],
	[cf_cv_x_freetype_cfgs=auto])
test -z $cf_cv_x_freetype_cfgs && cf_cv_x_freetype_cfgs=auto
test $cf_cv_x_freetype_cfgs = no && cf_cv_x_freetype_cfgs=none
AC_MSG_RESULT($cf_cv_x_freetype_cfgs)

case $cf_cv_x_freetype_cfgs in
(none)
	AC_MSG_CHECKING(if you specified -D/-I options for FreeType)
	AC_ARG_WITH(freetype-cflags,
		[  --with-freetype-cflags  -D/-I options for compiling with FreeType],
		[cf_cv_x_freetype_incs="$with_freetype_cflags"],
		[cf_cv_x_freetype_incs=no])
	AC_MSG_RESULT($cf_cv_x_freetype_incs)

	AC_MSG_CHECKING(if you specified -L/-l options for FreeType)
	AC_ARG_WITH(freetype-libs,
		[  --with-freetype-libs    -L/-l options to link FreeType],
		[cf_cv_x_freetype_libs="$with_freetype_libs"],
		[cf_cv_x_freetype_libs=no])
	AC_MSG_RESULT($cf_cv_x_freetype_libs)
	;;
(auto)
	if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xft; then
		FREETYPE_CONFIG=$PKG_CONFIG
		FREETYPE_PARAMS=xft
	else
		AC_PATH_PROG(FREETYPE_CONFIG, freetype-config, none)
		if test "$FREETYPE_CONFIG" != none; then
			FREETYPE_CONFIG=$FREETYPE_CONFIG
			cf_extra_freetype_libs="-lXft"
		else
			AC_PATH_PROG(FREETYPE_OLD_CONFIG, xft-config, none)
			if test "$FREETYPE_OLD_CONFIG" != none; then
				FREETYPE_CONFIG=$FREETYPE_OLD_CONFIG
			fi
		fi
	fi
	;;
(pkg*)
	if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xft; then
		FREETYPE_CONFIG=$cf_cv_x_freetype_cfgs
		FREETYPE_PARAMS=xft
	else
		AC_MSG_WARN(cannot find pkg-config for Xft)
	fi
	;;
(*)
	AC_PATH_PROG(FREETYPE_XFT_CONFIG, $cf_cv_x_freetype_cfgs, none)
	if test "$FREETYPE_XFT_CONFIG" != none; then
		FREETYPE_CONFIG=$FREETYPE_XFT_CONFIG
	else
		AC_MSG_WARN(cannot find config script for Xft)
	fi
	;;
esac

if test "$FREETYPE_CONFIG" != none ; then
	AC_MSG_CHECKING(for FreeType config)
	AC_MSG_RESULT($FREETYPE_CONFIG $FREETYPE_PARAMS)

	if test "$cf_cv_x_freetype_incs" = no ; then
		AC_MSG_CHECKING(for $FREETYPE_CONFIG cflags)
		cf_cv_x_freetype_incs="`$FREETYPE_CONFIG $FREETYPE_PARAMS --cflags 2>/dev/null`"
		AC_MSG_RESULT($cf_cv_x_freetype_incs)
	fi

	if test "$cf_cv_x_freetype_libs" = no ; then
		AC_MSG_CHECKING(for $FREETYPE_CONFIG libs)
		cf_cv_x_freetype_libs="$cf_extra_freetype_libs `$FREETYPE_CONFIG $FREETYPE_PARAMS --libs 2>/dev/null`"
		AC_MSG_RESULT($cf_cv_x_freetype_libs)
	fi
fi

if test "$cf_cv_x_freetype_incs" = no ; then
	cf_cv_x_freetype_incs=
fi

if test "$cf_cv_x_freetype_libs" = no ; then
	cf_cv_x_freetype_libs=-lXft
fi

AC_MSG_CHECKING(if we can link with FreeType libraries)

cf_save_LIBS="$LIBS"
cf_save_INCS="$CPPFLAGS"

CF_ADD_LIBS($cf_cv_x_freetype_libs)
CPPFLAGS="$CPPFLAGS $cf_cv_x_freetype_incs"

AC_TRY_LINK([
#include 
#include 
#include ],[
	XftPattern  *pat = XftNameParse ("name");],
	[cf_cv_found_freetype=yes],
	[cf_cv_found_freetype=no])
AC_MSG_RESULT($cf_cv_found_freetype)

LIBS="$cf_save_LIBS"
CPPFLAGS="$cf_save_INCS"

if test "$cf_cv_found_freetype" = yes ; then
	CF_ADD_LIBS($cf_cv_x_freetype_libs)
	CF_ADD_CFLAGS($cf_cv_x_freetype_incs)
	AC_DEFINE(XRENDERFONT,1,[Define to 1 if we can/should link with FreeType libraries])

AC_CHECK_FUNCS( \
	XftDrawCharSpec \
	XftDrawSetClip \
	XftDrawSetClipRectangles \
)

else
	AC_MSG_WARN(No libraries found for FreeType)
	CPPFLAGS=`echo "$CPPFLAGS" | sed -e s/-DXRENDERFONT//`
fi

# FIXME: revisit this if needed
AC_SUBST(HAVE_TYPE_FCCHAR32)
AC_SUBST(HAVE_TYPE_XFTCHARSPEC)
])
dnl ---------------------------------------------------------------------------
dnl CF_X_TOOLKIT version: 23 updated: 2015/04/12 15:39:00
dnl ------------
dnl Check for X Toolkit libraries
AC_DEFUN([CF_X_TOOLKIT],
[
AC_REQUIRE([AC_PATH_XTRA])
AC_REQUIRE([CF_CHECK_CACHE])

# OSX is schizoid about who owns /usr/X11 (old) versus /opt/X11 (new), and (and
# in some cases has installed dummy files in the former, other cases replaced
# it with a link to the new location).  This complicates the configure script.
# Check for that pitfall, and recover using pkg-config
#
# If none of these are set, the configuration is almost certainly broken.
if test -z "${X_CFLAGS}${X_PRE_LIBS}${X_LIBS}${X_EXTRA_LIBS}"
then
	CF_TRY_PKG_CONFIG(x11,,[AC_MSG_WARN(unable to find X11 library)])
	CF_TRY_PKG_CONFIG(ice,,[AC_MSG_WARN(unable to find ICE library)])
	CF_TRY_PKG_CONFIG(sm,,[AC_MSG_WARN(unable to find SM library)])
	CF_TRY_PKG_CONFIG(xt,,[AC_MSG_WARN(unable to find Xt library)])
fi

cf_have_X_LIBS=no

CF_TRY_PKG_CONFIG(xt,[

	case "x$LIBS" in
	(*-lX11*)
		;;
	(*)
# we have an "xt" package, but it may omit Xt's dependency on X11
AC_CACHE_CHECK(for usable X dependency,cf_cv_xt_x11_compat,[
AC_TRY_LINK([
#include 
],[
	int rc1 = XDrawLine((Display*) 0, (Drawable) 0, (GC) 0, 0, 0, 0, 0);
	int rc2 = XClearWindow((Display*) 0, (Window) 0);
	int rc3 = XMoveWindow((Display*) 0, (Window) 0, 0, 0);
	int rc4 = XMoveResizeWindow((Display*)0, (Window)0, 0, 0, 0, 0);
],[cf_cv_xt_x11_compat=yes],[cf_cv_xt_x11_compat=no])])
		if test "$cf_cv_xt_x11_compat" = no
		then
			CF_VERBOSE(work around broken X11 dependency)
			# 2010/11/19 - good enough until a working Xt on Xcb is delivered.
			CF_TRY_PKG_CONFIG(x11,,[CF_ADD_LIB_AFTER(-lXt,-lX11)])
		fi
		;;
	esac

AC_CACHE_CHECK(for usable X Toolkit package,cf_cv_xt_ice_compat,[
AC_TRY_LINK([
#include 
],[int num = IceConnectionNumber(0)
],[cf_cv_xt_ice_compat=yes],[cf_cv_xt_ice_compat=no])])

	if test "$cf_cv_xt_ice_compat" = no
	then
		# workaround for broken ".pc" files used for X Toolkit.
		case "x$X_PRE_LIBS" in
		(*-lICE*)
			case "x$LIBS" in
			(*-lICE*)
				;;
			(*)
				CF_VERBOSE(work around broken ICE dependency)
				CF_TRY_PKG_CONFIG(ice,
					[CF_TRY_PKG_CONFIG(sm)],
					[CF_ADD_LIB_AFTER(-lXt,$X_PRE_LIBS)])
				;;
			esac
			;;
		esac
	fi

	cf_have_X_LIBS=yes
],[

	LDFLAGS="$X_LIBS $LDFLAGS"
	CF_CHECK_CFLAGS($X_CFLAGS)

	AC_CHECK_FUNC(XOpenDisplay,,[
	AC_CHECK_LIB(X11,XOpenDisplay,
		[CF_ADD_LIB(X11)],,
		[$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])

	AC_CHECK_FUNC(XtAppInitialize,,[
	AC_CHECK_LIB(Xt, XtAppInitialize,
		[AC_DEFINE(HAVE_LIBXT,1,[Define to 1 if we can compile with the Xt library])
		 cf_have_X_LIBS=Xt
		 LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"],,
		[$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
])

if test $cf_have_X_LIBS = no ; then
	AC_MSG_WARN(
[Unable to successfully link X Toolkit library (-lXt) with
test program.  You will have to check and add the proper libraries by hand
to makefile.])
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF__GRANTPT_BODY version: 4 updated: 2012/05/07 19:39:45
dnl ----------------
dnl Body for workability check of grantpt.
define([CF__GRANTPT_BODY],[
	int code = 0;
	int rc;
	int pty;
	int tty;
	char *slave;
	struct termios tio;

	signal(SIGALRM, my_timeout);

	if (alarm(2) == 9)
		failed(9);
	else if ((pty = posix_openpt(O_RDWR)) < 0)
		failed(1);
	else if ((rc = grantpt(pty)) < 0)
		failed(2);
	else if ((rc = unlockpt(pty)) < 0)
		failed(3);
	else if ((slave = ptsname(pty)) == 0)
		failed(4);
#if (CONFTEST == 3) || defined(CONFTEST_isatty)
	else if (!isatty(pty))
		failed(4);
#endif
#if CONFTEST >= 4
    else if ((rc = tcgetattr(pty, &tio)) < 0)
		failed(20);
    else if ((rc = tcsetattr(pty, TCSAFLUSH, &tio)) < 0)
		failed(21);
#endif
	/* BSD posix_openpt does not treat pty as a terminal until slave is opened.
	 * Linux does treat it that way.
	 */
	else if ((tty = open(slave, O_RDWR)) < 0)
		failed(5);
#ifdef CONFTEST
#ifdef I_PUSH
#if (CONFTEST == 0) || defined(CONFTEST_ptem)
    else if ((rc = ioctl(tty, I_PUSH, "ptem")) < 0)
		failed(10);
#endif
#if (CONFTEST == 1) || defined(CONFTEST_ldterm)
    else if ((rc = ioctl(tty, I_PUSH, "ldterm")) < 0)
		failed(11);
#endif
#if (CONFTEST == 2) || defined(CONFTEST_ttcompat)
    else if ((rc = ioctl(tty, I_PUSH, "ttcompat")) < 0)
		failed(12);
#endif
#endif /* I_PUSH */
#if CONFTEST >= 5
    else if ((rc = tcgetattr(tty, &tio)) < 0)
		failed(30);
    else if ((rc = tcsetattr(tty, TCSAFLUSH, &tio)) < 0)
		failed(31);
#endif
#endif /* CONFTEST */

	${cf_cv_main_return:-return}(code);
])
dnl ---------------------------------------------------------------------------
dnl CF__GRANTPT_HEAD version: 3 updated: 2012/01/29 17:13:14
dnl ----------------
dnl Headers for workability check of grantpt.
define([CF__GRANTPT_HEAD],[
#include 
#include 
#include 
#include 
#include 
#include 

#ifndef HAVE_POSIX_OPENPT
#undef posix_openpt
#define posix_openpt(mode) open("/dev/ptmx", mode)
#endif

#ifdef HAVE_STROPTS_H
#include 
#endif

static void failed(int code)
{
	perror("conftest");
	exit(code);
}

static void my_timeout(int sig)
{
	exit(99);
}
])
xterm-330/ptyx.h0000644000175100001440000026574313112670007012432 0ustar  tomusers/* $XTermId: ptyx.h,v 1.854 2017/05/29 00:49:11 tom Exp $ */

/*
 * Copyright 1999-2016,2017 by Thomas E. Dickey
 *
 *                         All Rights Reserved
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name(s) of the above copyright
 * holders shall not be used in advertising or otherwise to promote the
 * sale, use or other dealings in this Software without prior written
 * authorization.
 *
 *
 * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 *
 *                         All Rights Reserved
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose and without fee is hereby granted,
 * provided that the above copyright notice appear in all copies and that
 * both that copyright notice and this permission notice appear in
 * supporting documentation, and that the name of Digital Equipment
 * Corporation not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 *
 *
 * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */

#ifndef included_ptyx_h
#define included_ptyx_h 1

#ifdef HAVE_CONFIG_H
#include 
#endif

/* ptyx.h */
/* *INDENT-OFF* */
/* @(#)ptyx.h	X10/6.6	11/10/86 */

#include 
#include 		/* for XtNdieCallback, etc. */
#include 	/* for standard resource names */
#include 	/* For Max() and Min(). */

#undef bcopy
#undef bzero
#include 

#include 
#include 
#ifdef XRENDERFONT
#include 
#endif

#include 

#ifdef HAVE_STDINT_H
#include 
#define DECONST(type,s) ((type *)(intptr_t)(const type *)(s))
#else
#define DECONST(type,s) ((type *)(s))
#endif

/* adapted from IntrinsicI.h */
#define MyStackAlloc(size, stack_cache_array)     \
    ((size) <= sizeof(stack_cache_array)	  \
    ?  (XtPointer)(stack_cache_array)		  \
    :  (XtPointer)malloc((size_t)(size)))

#define MyStackFree(pointer, stack_cache_array) \
    if ((pointer) != ((char *)(stack_cache_array))) free(pointer)

/* adapted from vile (vi-like-emacs) */
#define TypeCallocN(type,n)	(type *)calloc((size_t) (n), sizeof(type))
#define TypeCalloc(type)	TypeCallocN(type, 1)

#define TypeMallocN(type,n)	(type *)malloc(sizeof(type) * (size_t) (n))
#define TypeMalloc(type)	TypeMallocN(type, 1)

#define TypeRealloc(type,n,p)	(type *)realloc(p, (n) * sizeof(type))

#define TypeXtReallocN(t,p,n)	(t *)(void *)XtRealloc((char *)(p), (Cardinal)(sizeof(t) * (size_t) (n)))

#define TypeXtMallocX(type,n)	(type *)(void *)XtMalloc((Cardinal)(sizeof(type) + (size_t) (n)))
#define TypeXtMallocN(type,n)	(type *)(void *)XtMalloc((Cardinal)(sizeof(type) * (size_t) (n)))
#define TypeXtMalloc(type)	TypeXtMallocN(type, 1)

/* use these to allocate partly-structured data */
#define TextAlloc(n)		(char *)malloc(sizeof(char) * (size_t) ((n) + 1))
#define CastMalloc(type)	(type *)malloc(sizeof(type))

#define BumpBuffer(type, buffer, size, want) \
	if (want >= size) { \
	    size = 1 + (want * 2); \
	    buffer = TypeRealloc(type, size, buffer); \
	}

#define BfBuf(type) screen->bf_buf_##type
#define BfLen(type) screen->bf_len_##type

#define TypedBuffer(type) \
	type		*bf_buf_##type; \
	Cardinal	bf_len_##type

#define BumpTypedBuffer(type, want) \
	BumpBuffer(type, BfBuf(type), BfLen(type), want)

#define FreeTypedBuffer(type) \
	if (BfBuf(type) != 0) { \
	    free(BfBuf(type)); \
	    BfBuf(type) = 0; \
	} \
	BfLen(type) = 0

/*
** System V definitions
*/

#ifdef att
#define ATT
#endif

#ifdef SVR4
#undef  SYSV			/* predefined on Solaris 2.4 */
#define SYSV			/* SVR4 is (approx) superset of SVR3 */
#define ATT
#endif

#ifdef SYSV
#ifdef X_NOT_POSIX
#if !defined(CRAY) && !defined(SVR4)
#define	dup2(fd1,fd2)	((fd1 == fd2) ? fd1 : \
				(close(fd2), fcntl(fd1, F_DUPFD, fd2)))
#endif
#endif
#endif /* SYSV */

/*
 * Newer versions of  have a version number.  We use certain
 * features from that.
 */
#if defined(XRENDERFONT) && defined(XFT_VERSION) && XFT_VERSION >= 20100
#define HAVE_TYPE_FCCHAR32	1	/* compatible: XftChar16 */
#define HAVE_TYPE_XFTCHARSPEC	1	/* new type XftCharSpec */
#endif

/*
** Definitions to simplify ifdef's for pty's.
*/
#define USE_PTY_DEVICE 1
#define USE_PTY_SEARCH 1

#if defined(__osf__) || (defined(linux) && defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
#undef USE_PTY_DEVICE
#undef USE_PTY_SEARCH
#define USE_PTS_DEVICE 1
#elif defined(VMS)
#undef USE_PTY_DEVICE
#undef USE_PTY_SEARCH
#elif defined(PUCC_PTYD)
#undef USE_PTY_SEARCH
#elif (defined(sun) && defined(SVR4)) || defined(_ALL_SOURCE) || defined(__CYGWIN__)
#undef USE_PTY_SEARCH
#elif defined(__OpenBSD__)
#undef USE_PTY_SEARCH
#undef USE_PTY_DEVICE
#endif

#if (defined (__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1)))
#define USE_HANDSHAKE 0	/* "recent" Linux systems do not require handshaking */
#endif

#if (defined (__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1)))
#define USE_USG_PTYS
#elif (defined(ATT) && !defined(__sgi)) || defined(__MVS__) || (defined(SYSV) && defined(i386))
#define USE_USG_PTYS
#endif

/*
 * More systems than not require pty-handshaking.
 */
#ifndef USE_HANDSHAKE
#define USE_HANDSHAKE 1
#endif

/*
** allow for mobility of the pty master/slave directories
*/
#ifndef PTYDEV
#if defined(__hpux)
#define	PTYDEV		"/dev/ptym/ptyxx"
#elif defined(__MVS__)
#define	PTYDEV		"/dev/ptypxxxx"
#else
#define	PTYDEV		"/dev/ptyxx"
#endif
#endif	/* !PTYDEV */

#ifndef TTYDEV
#if defined(__hpux)
#define TTYDEV		"/dev/pty/ttyxx"
#elif defined(__MVS__)
#define TTYDEV		"/dev/ptypxxxx"
#elif defined(USE_PTS_DEVICE)
#define TTYDEV		"/dev/pts/0"
#else
#define	TTYDEV		"/dev/ttyxx"
#endif
#endif	/* !TTYDEV */

#ifndef PTYCHAR1
#ifdef __hpux
#define PTYCHAR1	"zyxwvutsrqp"
#else	/* !__hpux */
#define	PTYCHAR1	"pqrstuvwxyzPQRSTUVWXYZ"
#endif	/* !__hpux */
#endif	/* !PTYCHAR1 */

#ifndef PTYCHAR2
#ifdef __hpux
#define	PTYCHAR2	"fedcba9876543210"
#else	/* !__hpux */
#if defined(__DragonFly__) || defined(__FreeBSD__)
#define	PTYCHAR2	"0123456789abcdefghijklmnopqrstuv"
#else /* !__FreeBSD__ */
#define	PTYCHAR2	"0123456789abcdef"
#endif /* !__FreeBSD__ */
#endif	/* !__hpux */
#endif	/* !PTYCHAR2 */

#ifndef TTYFORMAT
#if defined(CRAY)
#define TTYFORMAT "/dev/ttyp%03d"
#elif defined(__MVS__)
#define TTYFORMAT "/dev/ttyp%04d"
#else
#define TTYFORMAT "/dev/ttyp%d"
#endif
#endif /* TTYFORMAT */

#ifndef PTYFORMAT
#ifdef CRAY
#define PTYFORMAT "/dev/pty/%03d"
#elif defined(__MVS__)
#define PTYFORMAT "/dev/ptyp%04d"
#else
#define PTYFORMAT "/dev/ptyp%d"
#endif
#endif /* PTYFORMAT */

#ifndef PTYCHARLEN
#ifdef CRAY
#define PTYCHARLEN 3
#elif defined(__MVS__)
#define PTYCHARLEN 8     /* OS/390 stores, e.g. ut_id="ttyp1234"  */
#else
#define PTYCHARLEN 2
#endif
#endif

#ifndef MAXPTTYS
#ifdef CRAY
#define MAXPTTYS 256
#else
#define MAXPTTYS 2048
#endif
#endif

/* Until the translation manager comes along, I have to do my own translation of
 * mouse events into the proper routines. */

typedef enum {
    NORMAL = 0
    , LEFTEXTENSION
    , RIGHTEXTENSION
} EventMode;

/*
 * The origin of a screen is 0, 0.  Therefore, the number of rows
 * on a screen is screen->max_row + 1, and similarly for columns.
 */
#define MaxCols(screen)		((screen)->max_col + 1)
#define MaxRows(screen)		((screen)->max_row + 1)

typedef unsigned char Char;		/* to support 8 bit chars */
typedef Char *ScrnPtr;
typedef ScrnPtr *ScrnBuf;

/*
 * Declare an X String, but for unsigned chars.
 */
#ifdef _CONST_X_STRING
typedef const Char *UString;
#else
typedef Char *UString;
#endif

#define IsEmpty(s) ((s) == 0 || *(s) == '\0')
#define IsSpace(c) ((c) == ' ' || (c) == '\t' || (c) == '\r' || (c) == '\n')

/*
 * Check strtol result, using "FullS2L" when no more data is expected, and
 * "PartS2L" when more data may follow in the string.
 */
#define FullS2L(s,d) (PartS2L(s,d) && (*(d) == '\0'))
#define PartS2L(s,d) (isdigit(CharOf(*(s))) && (d) != (s) && (d) != 0)

#define CASETYPE(name) case name: result = #name; break

#define CharOf(n) ((Char)(n))

typedef struct {
    int row;
    int col;
} CELL;

#define isSameRow(a,b)		((a)->row == (b)->row)
#define isSameCol(a,b)		((a)->col == (b)->col)
#define isSameCELL(a,b)		(isSameRow(a,b) && isSameCol(a,b))

#define xBIT(n)         (1 << (n))

/*
 * ANSI emulation, special character codes
 */
#define ANSI_EOT	0x04
#define ANSI_BEL	0x07
#define ANSI_BS		0x08
#define ANSI_HT		0x09
#define ANSI_LF		0x0A
#define ANSI_VT		0x0B
#define	ANSI_FF		0x0C		/* C0, C1 control names		*/
#define ANSI_CR		0x0D
#define ANSI_SO		0x0E
#define ANSI_SI		0x0F
#define	ANSI_XON	0x11		/* DC1 */
#define	ANSI_XOFF	0x13		/* DC3 */
#define	ANSI_NAK	0x15
#define	ANSI_CAN	0x18
#define	ANSI_ESC	0x1B
#define	ANSI_SPA	0x20
#define XTERM_POUND	0x1E		/* internal mapping for '#'	*/
#define	ANSI_DEL	0x7F
#define	ANSI_SS2	0x8E
#define	ANSI_SS3	0x8F
#define	ANSI_DCS	0x90
#define	ANSI_SOS	0x98
#define	ANSI_CSI	0x9B
#define	ANSI_ST		0x9C
#define	ANSI_OSC	0x9D
#define	ANSI_PM		0x9E
#define	ANSI_APC	0x9F

#define L_CURL		'{'
#define R_CURL		'}'

#define MIN_DECID  52			/* can emulate VT52 */
#define MAX_DECID 525			/* ...through VT525 */

#ifndef DFT_DECID
#define DFT_DECID "vt420"		/* default VT420 */
#endif

#ifndef DFT_KBD_DIALECT
#define DFT_KBD_DIALECT "B"		/* default USASCII */
#endif

/* constants used for utf8 mode */
#define UCS_REPL	0xfffd
#define UCS_LIMIT	0x80000000U	/* both limit and flag for non-UCS */

#define TERMCAP_SIZE 1500		/* 1023 is standard; 'screen' exceeds */

#define MAX_XLFD_FONTS	1
#define MAX_XFT_FONTS	1
#define NMENUFONTS	9		/* font entries in fontMenu */

#define	NBOX	5			/* Number of Points in box	*/
#define	NPARAM	30			/* Max. parameters		*/

typedef struct {
	String opt;
	String desc;
} OptionHelp;

typedef	struct {
	int	count;			/* number of values in params[]	*/
	int	has_subparams;		/* true if there are any sub's	*/
	int	is_sub[NPARAM];		/* true for subparam		*/
	int	params[NPARAM];		/* parameter value		*/
} PARAMS;

typedef short ParmType;

typedef struct {
	Char		a_type;		/* CSI, etc., see unparseq()	*/
	Char		a_pintro;	/* private-mode char, if any	*/
	const char *	a_delim;	/* between parameters (;)	*/
	Char		a_inters;	/* special (before final-char)	*/
	Char		a_final;	/* final-char			*/
	ParmType	a_nparam;	/* # of parameters		*/
	ParmType	a_param[NPARAM]; /* Parameters			*/
	Char		a_radix[NPARAM]; /* Parameters			*/
} ANSI;

#define TEK_FONT_LARGE 0
#define TEK_FONT_2 1
#define TEK_FONT_3 2
#define TEK_FONT_SMALL 3
#define	TEKNUMFONTS 4

/* Actually there are 5 types of lines, but four are non-solid lines */
#define	TEKNUMLINES	4

typedef struct {
	int	x;
	int	y;
	int	fontsize;
	unsigned linetype;
} Tmodes;

typedef struct {
	int Twidth;
	int Theight;
} T_fontsize;

typedef struct {
	short *bits;
	int x;
	int y;
	int width;
	int height;
} BitmapBits;

#define	SAVELINES		64      /* default # lines to save      */
#define SCROLLLINES 1			/* default # lines to scroll    */

#define EXCHANGE(a,b,tmp) tmp = a; a = b; b = tmp

/***====================================================================***/

#if (XtSpecificationRelease < 6)
#ifndef NO_ACTIVE_ICON
#define NO_ACTIVE_ICON 1 /* Note: code relies on an X11R6 function */
#endif
#endif

#ifndef OPT_AIX_COLORS
#define OPT_AIX_COLORS  1 /* true if xterm is configured with AIX (16) colors */
#endif

#ifndef OPT_ALLOW_XXX_OPS
#define OPT_ALLOW_XXX_OPS 1 /* true if xterm adds "Allow XXX Ops" submenu */
#endif

#ifndef OPT_BLINK_CURS
#define OPT_BLINK_CURS  1 /* true if xterm has blinking cursor capability */
#endif

#ifndef OPT_BLINK_TEXT
#define OPT_BLINK_TEXT  OPT_BLINK_CURS /* true if xterm has blinking text capability */
#endif

#ifndef OPT_BOX_CHARS
#define OPT_BOX_CHARS	1 /* true if xterm can simulate box-characters */
#endif

#ifndef OPT_BUILTIN_XPMS
#define OPT_BUILTIN_XPMS 0 /* true if all xpm data is compiled-in */
#endif

#ifndef OPT_BROKEN_OSC
#ifdef linux
#define OPT_BROKEN_OSC	1 /* man console_codes, 1st paragraph - cf: ECMA-48 */
#else
#define OPT_BROKEN_OSC	0 /* true if xterm allows Linux's broken OSC parsing */
#endif
#endif

#ifndef OPT_BROKEN_ST
#define OPT_BROKEN_ST	1 /* true if xterm allows old/broken OSC parsing */
#endif

#ifndef OPT_C1_PRINT
#define OPT_C1_PRINT	1 /* true if xterm allows C1 controls to be printable */
#endif

#ifndef OPT_CLIP_BOLD
#define OPT_CLIP_BOLD	1 /* true if xterm uses clipping to avoid bold-trash */
#endif

#ifndef OPT_COLOR_CLASS
#define OPT_COLOR_CLASS 1 /* true if xterm uses separate color-resource classes */
#endif

#ifndef OPT_COLOR_RES
#define OPT_COLOR_RES   1 /* true if xterm delays color-resource evaluation */
#endif

#ifndef OPT_DABBREV
#define OPT_DABBREV 0	/* dynamic abbreviations */
#endif

#ifndef OPT_DEC_CHRSET
#define OPT_DEC_CHRSET  1 /* true if xterm is configured for DEC charset */
#endif

#ifndef OPT_DEC_LOCATOR
#define	OPT_DEC_LOCATOR 0 /* true if xterm supports VT220-style mouse events */
#endif

#ifndef OPT_DEC_RECTOPS
#define OPT_DEC_RECTOPS 0 /* true if xterm is configured for VT420 rectangles */
#endif

#ifndef OPT_SIXEL_GRAPHICS
#define OPT_SIXEL_GRAPHICS 0 /* true if xterm supports VT240-style sixel graphics */
#endif

#ifndef OPT_SCREEN_DUMPS
#define OPT_SCREEN_DUMPS 0 /* true if xterm supports screen dumps */
#endif

#ifndef OPT_REGIS_GRAPHICS
#define OPT_REGIS_GRAPHICS 0 /* true if xterm supports VT125/VT240/VT330 ReGIS graphics */
#endif

#ifndef OPT_GRAPHICS
#define OPT_GRAPHICS 0 /* true if xterm is configured for any type of graphics */
#endif

#ifndef OPT_DEC_SOFTFONT
#define OPT_DEC_SOFTFONT 0 /* true if xterm is configured for VT220 softfonts */
#endif

#ifndef OPT_DOUBLE_BUFFER
#define OPT_DOUBLE_BUFFER 0 /* true if using double-buffering */
#endif

#ifndef OPT_EBCDIC
#ifdef __MVS__
#define OPT_EBCDIC 1
#else
#define OPT_EBCDIC 0
#endif
#endif

#ifndef OPT_EXEC_XTERM
#define OPT_EXEC_XTERM 0 /* true if xterm can fork/exec copies of itself */
#endif

#ifndef OPT_EXTRA_PASTE
#define OPT_EXTRA_PASTE 1
#endif

#ifndef OPT_FIFO_LINES
#define OPT_FIFO_LINES 0 /* optimize save-lines feature using FIFO */
#endif

#ifndef OPT_FOCUS_EVENT
#define OPT_FOCUS_EVENT	1 /* focus in/out events */
#endif

#ifndef OPT_HP_FUNC_KEYS
#define OPT_HP_FUNC_KEYS 0 /* true if xterm supports HP-style function keys */
#endif

#ifndef OPT_I18N_SUPPORT
#if (XtSpecificationRelease >= 5)
#define OPT_I18N_SUPPORT 1 /* true if xterm uses internationalization support */
#else
#define OPT_I18N_SUPPORT 0
#endif
#endif

#ifndef OPT_INITIAL_ERASE
#define OPT_INITIAL_ERASE 1 /* use pty's erase character if it's not 128 */
#endif

#ifndef OPT_INPUT_METHOD
#if (XtSpecificationRelease >= 6)
#define OPT_INPUT_METHOD 1 /* true if xterm uses input-method support */
#else
#define OPT_INPUT_METHOD 0
#endif
#endif

#ifndef OPT_ISO_COLORS
#define OPT_ISO_COLORS  1 /* true if xterm is configured with ISO colors */
#endif

#ifndef OPT_256_COLORS
#define OPT_256_COLORS  0 /* true if xterm is configured with 256 colors */
#endif

#ifndef OPT_88_COLORS
#define OPT_88_COLORS	0 /* true if xterm is configured with 88 colors */
#endif

#ifndef OPT_HIGHLIGHT_COLOR
#define OPT_HIGHLIGHT_COLOR 1 /* true if xterm supports color highlighting */
#endif

#ifndef OPT_LOAD_VTFONTS
#define OPT_LOAD_VTFONTS 0 /* true if xterm has load-vt-fonts() action */
#endif

#ifndef OPT_LUIT_PROG
#define OPT_LUIT_PROG   0 /* true if xterm supports luit */
#endif

#ifndef OPT_MAXIMIZE
#define OPT_MAXIMIZE	1 /* add actions for iconify ... maximize */
#endif

#ifndef OPT_MINI_LUIT
#define OPT_MINI_LUIT   0 /* true if xterm supports built-in mini-luit */
#endif

#ifndef OPT_MOD_FKEYS
#define OPT_MOD_FKEYS	1 /* modify cursor- and function-keys in normal mode */
#endif

#ifndef OPT_NUM_LOCK
#define OPT_NUM_LOCK	1 /* use NumLock key only for numeric-keypad */
#endif

#ifndef OPT_PASTE64
#define OPT_PASTE64	0 /* program control of select/paste via base64 */
#endif

#ifndef OPT_PC_COLORS
#define OPT_PC_COLORS   1 /* true if xterm supports PC-style (bold) colors */
#endif

#ifndef OPT_PRINT_ON_EXIT
#define OPT_PRINT_ON_EXIT 1 /* true allows xterm to dump screen on X error */
#endif

#ifndef OPT_PTY_HANDSHAKE
#define OPT_PTY_HANDSHAKE USE_HANDSHAKE	/* avoid pty races on older systems */
#endif

#ifndef OPT_PRINT_COLORS
#define OPT_PRINT_COLORS 1 /* true if we print color information */
#endif

#ifndef OPT_READLINE
#define OPT_READLINE	0 /* mouse-click/paste support for readline */
#endif

#ifndef OPT_RENDERFONT
#ifdef XRENDERFONT
#define OPT_RENDERFONT 1
#else
#define OPT_RENDERFONT 0
#endif
#endif

#ifndef OPT_RENDERWIDE
#if OPT_RENDERFONT && OPT_WIDE_CHARS && defined(HAVE_TYPE_XFTCHARSPEC)
#define OPT_RENDERWIDE 1
#else
#define OPT_RENDERWIDE 0
#endif
#endif

#ifndef OPT_REPORT_CCLASS
#define OPT_REPORT_CCLASS  1 /* provide "-report-charclass" option */
#endif

#ifndef OPT_REPORT_COLORS
#define OPT_REPORT_COLORS  1 /* provide "-report-colors" option */
#endif

#ifndef OPT_REPORT_FONTS
#define OPT_REPORT_FONTS   1 /* provide "-report-fonts" option */
#endif

#ifndef OPT_SAME_NAME
#define OPT_SAME_NAME   1 /* suppress redundant updates of title, icon, etc. */
#endif

#ifndef OPT_SAVE_LINES
#define OPT_SAVE_LINES OPT_FIFO_LINES /* optimize save-lines feature */
#endif

#ifndef OPT_SCO_FUNC_KEYS
#define OPT_SCO_FUNC_KEYS 0 /* true if xterm supports SCO-style function keys */
#endif

#ifndef OPT_SUN_FUNC_KEYS
#define OPT_SUN_FUNC_KEYS 1 /* true if xterm supports Sun-style function keys */
#endif

#ifndef OPT_SCROLL_LOCK
#define OPT_SCROLL_LOCK 1 /* true if xterm interprets fontsize-shifting */
#endif

#ifndef OPT_SELECT_REGEX
#define OPT_SELECT_REGEX 0 /* true if xterm supports regular-expression selects */
#endif

#ifndef OPT_SELECTION_OPS
#define OPT_SELECTION_OPS 1 /* true if xterm supports operations on selection */
#endif

#ifndef OPT_SESSION_MGT
#if defined(XtNdieCallback) && defined(XtNsaveCallback)
#define OPT_SESSION_MGT 1
#else
#define OPT_SESSION_MGT 0
#endif
#endif

#ifndef OPT_SHIFT_FONTS
#define OPT_SHIFT_FONTS 1 /* true if xterm interprets fontsize-shifting */
#endif

#ifndef OPT_SUNPC_KBD
#define OPT_SUNPC_KBD	1 /* true if xterm supports Sun/PC keyboard map */
#endif

#ifndef OPT_TCAP_FKEYS
#define OPT_TCAP_FKEYS	0 /* true for experimental termcap function-keys */
#endif

#ifndef OPT_TCAP_QUERY
#define OPT_TCAP_QUERY	0 /* true for experimental termcap query */
#endif

#ifndef OPT_TEK4014
#define OPT_TEK4014     1 /* true if we're using tek4014 emulation */
#endif

#ifndef OPT_TOOLBAR
#define OPT_TOOLBAR	0 /* true if xterm supports toolbar menus */
#endif

#ifndef OPT_TRACE
#define OPT_TRACE       0 /* true if we're using debugging traces */
#endif

#ifndef OPT_TRACE_FLAGS
#define OPT_TRACE_FLAGS 0 /* additional tracing used for SCRN_BUF_FLAGS */
#endif

#ifndef OPT_VT52_MODE
#define OPT_VT52_MODE   1 /* true if xterm supports VT52 emulation */
#endif

#ifndef OPT_WIDE_ATTRS
#define OPT_WIDE_ATTRS  1 /* true if xterm supports 16-bit attributes */
#endif

#ifndef OPT_WIDE_CHARS
#define OPT_WIDE_CHARS  0 /* true if xterm supports 16-bit characters */
#endif

#ifndef OPT_WIDER_ICHAR
#define OPT_WIDER_ICHAR 1 /* true if xterm uses 32-bits for wide-chars */
#endif

#ifndef OPT_XMC_GLITCH
#define OPT_XMC_GLITCH	0 /* true if xterm supports xmc (magic cookie glitch) */
#endif

#ifndef OPT_ZICONBEEP
#define OPT_ZICONBEEP   1 /* true if xterm supports "-ziconbeep" option */
#endif

/***====================================================================***/

#if OPT_AIX_COLORS && !OPT_ISO_COLORS
/* You must have ANSI/ISO colors to support AIX colors */
#undef  OPT_AIX_COLORS
#define OPT_AIX_COLORS 0
#endif

#if OPT_COLOR_RES && !OPT_ISO_COLORS
/* You must have ANSI/ISO colors to support ColorRes logic */
#undef  OPT_COLOR_RES
#define OPT_COLOR_RES 0
#endif

#if OPT_256_COLORS && (OPT_WIDE_CHARS || OPT_RENDERFONT || OPT_XMC_GLITCH)
/* It's actually more complicated than that - but by trimming options you can
 * have 256 color resources though.
 */
#define OPT_COLOR_RES2 1
#else
#define OPT_COLOR_RES2 0
#endif

#if OPT_PASTE64 && !OPT_READLINE
/* OPT_PASTE64 uses logic from OPT_READLINE */
#undef  OPT_READLINE
#define OPT_READLINE 1
#endif

#if OPT_PC_COLORS && !OPT_ISO_COLORS
/* You must have ANSI/ISO colors to support PC colors */
#undef  OPT_PC_COLORS
#define OPT_PC_COLORS 0
#endif

#if OPT_PRINT_COLORS && !OPT_ISO_COLORS
/* You must have ANSI/ISO colors to be able to print them */
#undef  OPT_PRINT_COLORS
#define OPT_PRINT_COLORS 0
#endif

#if OPT_256_COLORS && !OPT_ISO_COLORS
/* You must have ANSI/ISO colors to support 256 colors */
#undef  OPT_256_COLORS
#define OPT_256_COLORS 0
#endif

#if OPT_88_COLORS && !OPT_ISO_COLORS
/* You must have ANSI/ISO colors to support 88 colors */
#undef  OPT_88_COLORS
#define OPT_88_COLORS 0
#endif

#if OPT_88_COLORS && OPT_256_COLORS
/* 256 colors supersedes 88 colors */
#undef  OPT_88_COLORS
#define OPT_88_COLORS 0
#endif

/***====================================================================***/

/*
 * Indices for menu_font_names[][]
 */
typedef enum {
    fNorm = 0			/* normal font */
    , fBold			/* bold font */
#if OPT_WIDE_ATTRS || OPT_RENDERWIDE
    , fItal			/* italic font */
#endif
#if OPT_WIDE_CHARS
    , fWide			/* double-width font */
    , fWBold			/* double-width bold font */
    , fWItal			/* double-width italic font */
#endif
    , fMAX
} VTFontEnum;

/*
 * Indices for cachedGCs.c (unrelated to VTFontEnum).
 */
typedef enum {
    gcNorm = 0
    , gcBold
    , gcNormReverse
    , gcBoldReverse
#if OPT_BOX_CHARS
    , gcLine
    , gcDots
#endif
#if OPT_DEC_CHRSET
    , gcCNorm
    , gcCBold
#endif
#if OPT_WIDE_CHARS
    , gcWide
    , gcWBold
    , gcWideReverse
    , gcWBoldReverse
#endif
    , gcVTcursNormal
    , gcVTcursFilled
    , gcVTcursReverse
    , gcVTcursOutline
#if OPT_TEK4014
    , gcTKcurs
#endif
    , gcMAX
} CgsEnum;

#define for_each_text_gc(n) for (n = gcNorm; n < gcVTcursNormal; ++n)
#define for_each_curs_gc(n) for (n = gcVTcursNormal; n <= gcVTcursOutline; ++n)
#define for_each_gc(n)      for (n = gcNorm; n < gcMAX; ++n)

/*
 * Indices for the normal terminal colors in screen.Tcolors[].
 * See also OscTextColors, which has corresponding values.
 */
typedef enum {
    TEXT_FG = 0			/* text foreground */
    , TEXT_BG			/* text background */
    , TEXT_CURSOR		/* text cursor */
    , MOUSE_FG			/* mouse foreground */
    , MOUSE_BG			/* mouse background */
#if OPT_TEK4014
    , TEK_FG = 5		/* tektronix foreground */
    , TEK_BG			/* tektronix background */
#endif
#if OPT_HIGHLIGHT_COLOR
    , HIGHLIGHT_BG = 7		/* highlight background */
#endif
#if OPT_TEK4014
    , TEK_CURSOR = 8		/* tektronix cursor */
#endif
#if OPT_HIGHLIGHT_COLOR
    , HIGHLIGHT_FG = 9		/* highlight foreground */
#endif
    , NCOLORS			/* total number of colors */
} TermColors;

/*
 * Definitions for exec-formatted and insert-formatted actions.
 */
typedef void (*FormatSelect) (Widget, char *, char *, CELL *, CELL *);

typedef struct {
    char *format;
    char *buffer;
    FormatSelect format_select;
#if OPT_PASTE64
    Cardinal base64_paste;
#endif
#if OPT_READLINE
    unsigned paste_brackets;
#endif
} InternalSelect;

/*
 * Constants for titleModes resource
 */
typedef enum {
    tmSetBase16 = 1		/* set title using hex-string */
    , tmGetBase16 = 2		/* get title using hex-string */
#if OPT_WIDE_CHARS
    , tmSetUtf8 = 4		/* like utf8Title, but controllable */
    , tmGetUtf8 = 8		/* retrieve title encoded as UTF-8 */
#endif
} TitleModes;

#define IsTitleMode(xw,mode) (((xw)->screen.title_modes & mode) != 0)

#include 

/*
 * For readability...
 */
#define nrc_percent   100
#define nrc_dquote    200
#define nrc_ampersand 300
typedef enum {
    nrc_ASCII = 0
    ,nrc_British		/* vt100 */
    ,nrc_British_Latin_1	/* vt3xx */
    ,nrc_Cyrillic		/* vt5xx */
    ,nrc_DEC_Spec_Graphic	/* vt100 */
    ,nrc_DEC_Alt_Chars		/* vt100 */
    ,nrc_DEC_Alt_Graphics	/* vt100 */
    ,nrc_DEC_Supp		/* vt2xx */
    ,nrc_DEC_Supp_Graphic	/* vt3xx */
    ,nrc_DEC_Technical		/* vt3xx */
    ,nrc_Dutch			/* vt2xx */
    ,nrc_Finnish		/* vt2xx */
    ,nrc_Finnish2		/* vt2xx */
    ,nrc_French			/* vt2xx */
    ,nrc_French2		/* vt2xx */
    ,nrc_French_Canadian	/* vt2xx */
    ,nrc_French_Canadian2	/* vt3xx */
    ,nrc_German			/* vt2xx */
    ,nrc_Greek			/* vt5xx */
    ,nrc_Greek_Supp		/* vt5xx */
    ,nrc_Hebrew			/* vt5xx */
    ,nrc_Hebrew2		/* vt5xx */
    ,nrc_Hebrew_Supp		/* vt5xx */
    ,nrc_Italian		/* vt2xx */
    ,nrc_Latin_5_Supp		/* vt5xx */
    ,nrc_Latin_Cyrillic		/* vt5xx */
    ,nrc_Norwegian_Danish	/* vt3xx */
    ,nrc_Norwegian_Danish2	/* vt2xx */
    ,nrc_Norwegian_Danish3	/* vt2xx */
    ,nrc_Portugese		/* vt3xx */
    ,nrc_Russian		/* vt5xx */
    ,nrc_SCS_NRCS		/* vt5xx - probably Serbo/Croatian */
    ,nrc_Spanish		/* vt2xx */
    ,nrc_Swedish		/* vt2xx */
    ,nrc_Swedish2		/* vt2xx */
    ,nrc_Swiss			/* vt2xx */
    ,nrc_Turkish		/* vt5xx */
    ,nrc_Turkish2		/* vt5xx */
    ,nrc_Unknown
} DECNRCM_codes;

/*
 * Use this enumerated type to check consistency among dpmodes(), savemodes()
 * restoremodes() and do_decrpm().
 */
typedef enum {
    srm_DECCKM = 1
    ,srm_DECANM = 2
    ,srm_DECCOLM = 3
    ,srm_DECSCLM = 4
    ,srm_DECSCNM = 5
    ,srm_DECOM = 6
    ,srm_DECAWM = 7
    ,srm_DECARM = 8
    ,srm_X10_MOUSE = SET_X10_MOUSE
#if OPT_TOOLBAR
    ,srm_RXVT_TOOLBAR = 10
#endif
#if OPT_BLINK_CURS
    ,srm_ATT610_BLINK = 12
#endif
    ,srm_DECPFF = 18
    ,srm_DECPEX = 19
    ,srm_DECTCEM = 25
    ,srm_RXVT_SCROLLBAR = 30
#if OPT_SHIFT_FONTS
    ,srm_RXVT_FONTSIZE = 35
#endif
#if OPT_TEK4014
    ,srm_DECTEK = 38
#endif
    ,srm_132COLS = 40
    ,srm_CURSES_HACK = 41
    ,srm_DECNRCM = 42
    ,srm_MARGIN_BELL = 44
    ,srm_REVERSEWRAP = 45
#ifdef ALLOWLOGGING
    ,srm_ALLOWLOGGING = 46
#endif
    ,srm_OPT_ALTBUF_CURSOR = 1049
    ,srm_OPT_ALTBUF = 1047
    ,srm_ALTBUF = 47
    ,srm_DECNKM = 66
    ,srm_DECBKM = 67
    ,srm_DECLRMM = 69
#if OPT_SIXEL_GRAPHICS
    ,srm_DECSDM = 80		/* Sixel Display Mode */
#endif
    ,srm_DECNCSM = 95
    ,srm_VT200_MOUSE = SET_VT200_MOUSE
    ,srm_VT200_HIGHLIGHT_MOUSE = SET_VT200_HIGHLIGHT_MOUSE
    ,srm_BTN_EVENT_MOUSE = SET_BTN_EVENT_MOUSE
    ,srm_ANY_EVENT_MOUSE = SET_ANY_EVENT_MOUSE
#if OPT_FOCUS_EVENT
    ,srm_FOCUS_EVENT_MOUSE = SET_FOCUS_EVENT_MOUSE
#endif
    ,srm_EXT_MODE_MOUSE = SET_EXT_MODE_MOUSE
    ,srm_SGR_EXT_MODE_MOUSE = SET_SGR_EXT_MODE_MOUSE
    ,srm_URXVT_EXT_MODE_MOUSE = SET_URXVT_EXT_MODE_MOUSE
    ,srm_ALTERNATE_SCROLL = SET_ALTERNATE_SCROLL
    ,srm_RXVT_SCROLL_TTY_OUTPUT = 1010
    ,srm_RXVT_SCROLL_TTY_KEYPRESS = 1011
    ,srm_EIGHT_BIT_META = 1034
#if OPT_NUM_LOCK
    ,srm_REAL_NUMLOCK = 1035
    ,srm_META_SENDS_ESC = 1036
#endif
    ,srm_DELETE_IS_DEL = 1037
#if OPT_NUM_LOCK
    ,srm_ALT_SENDS_ESC = 1039
#endif
    ,srm_KEEP_SELECTION = 1040
    ,srm_SELECT_TO_CLIPBOARD = 1041
    ,srm_BELL_IS_URGENT = 1042
    ,srm_POP_ON_BELL = 1043
    ,srm_KEEP_CLIPBOARD = 1044
    ,srm_TITE_INHIBIT = 1048
#if OPT_TCAP_FKEYS
    ,srm_TCAP_FKEYS = 1050
#endif
#if OPT_SUN_FUNC_KEYS
    ,srm_SUN_FKEYS = 1051
#endif
#if OPT_HP_FUNC_KEYS
    ,srm_HP_FKEYS = 1052
#endif
#if OPT_SCO_FUNC_KEYS
    ,srm_SCO_FKEYS = 1053
#endif
    ,srm_LEGACY_FKEYS = 1060
#if OPT_SUNPC_KBD
    ,srm_VT220_FKEYS = 1061
#endif
#if OPT_GRAPHICS
    ,srm_PRIVATE_COLOR_REGISTERS = 1070
#endif
#if OPT_READLINE
    ,srm_BUTTON1_MOVE_POINT = SET_BUTTON1_MOVE_POINT
    ,srm_BUTTON2_MOVE_POINT = SET_BUTTON2_MOVE_POINT
    ,srm_DBUTTON3_DELETE = SET_DBUTTON3_DELETE
    ,srm_PASTE_IN_BRACKET = SET_PASTE_IN_BRACKET
    ,srm_PASTE_QUOTE = SET_PASTE_QUOTE
    ,srm_PASTE_LITERAL_NL = SET_PASTE_LITERAL_NL
#endif				/* OPT_READLINE */
#if OPT_SIXEL_GRAPHICS
    ,srm_SIXEL_SCROLLS_RIGHT = 8452
#endif
} DECSET_codes;

/* indices for mapping multiple clicks to selection types */
typedef enum {
    Select_CHAR=0
    ,Select_WORD
    ,Select_LINE
    ,Select_GROUP
    ,Select_PAGE
    ,Select_ALL
#if OPT_SELECT_REGEX
    ,Select_REGEX
#endif
    ,NSELECTUNITS
} SelectUnit;

typedef enum {
    ecSetColor = 1
    , ecGetColor
    , ecGetAnsiColor
    , ecLAST
} ColorOps;

typedef enum {
    efSetFont = 1
    , efGetFont
    , efLAST
} FontOps;

typedef enum {
    esFalse = 0
    , esTrue
    , esAlways
    , esNever
} FullscreenOps;

#ifndef NO_ACTIVE_ICON
typedef enum {
    eiFalse = 0
    , eiTrue
    , eiDefault
    , eiLAST
} AIconOps;
#endif

typedef enum {
    emX10 = 1
    , emLocator
    , emVT200Click
    , emVT200Hilite
    , emAnyButton
    , emAnyEvent
    , emFocusEvent
    , emExtended
    , emSGR
    , emURXVT
    , emAlternateScroll
    , emLAST
} MouseOps;

typedef enum {
    etSetTcap = 1
    , etGetTcap
    , etLAST
} TcapOps;

typedef enum {
    /* 1-23 are chosen to be the same as the control-sequence coding */
    ewRestoreWin = 1
    , ewMinimizeWin = 2
    , ewSetWinPosition = 3
    , ewSetWinSizePixels = 4
    , ewRaiseWin = 5
    , ewLowerWin = 6
    , ewRefreshWin = 7
    , ewSetWinSizeChars = 8
#if OPT_MAXIMIZE
    , ewMaximizeWin = 9
    , ewFullscreenWin = 10
#endif
    , ewGetWinState = 11
    , ewGetWinPosition = 13
    , ewGetWinSizePixels = 14
    , ewGetWinSizeChars = 18
#if OPT_MAXIMIZE
    , ewGetScreenSizeChars = 19
#endif
    , ewGetIconTitle = 20
    , ewGetWinTitle = 21
    , ewPushTitle = 22
    , ewPopTitle = 23
    /* these do not fit into that scheme, which is why we use an array */
    , ewSetWinLines
    , ewSetXprop
    , ewGetSelection
    , ewSetSelection
    /* get the size of the array... */
    , ewLAST
} WindowOps;

#define	COLOR_DEFINED(s,w)	((s)->which & (unsigned) (1<<(w)))
#define	COLOR_VALUE(s,w)	((s)->colors[w])
#define	SET_COLOR_VALUE(s,w,v)	(((s)->colors[w] = (v)), UIntSet((s)->which, (1<<(w))))

#define	COLOR_NAME(s,w)		((s)->names[w])
#define	SET_COLOR_NAME(s,w,v)	(((s)->names[w] = (v)), ((s)->which |= (unsigned) (1<<(w))))

#define	UNDEFINE_COLOR(s,w)	((s)->which &= (~((w)<<1)))

/***====================================================================***/

#if OPT_ISO_COLORS
#define TERM_COLOR_FLAGS(xw)	((xw)->flags & (FG_COLOR|BG_COLOR))
#define COLOR_0		0
#define COLOR_1		1
#define COLOR_2		2
#define COLOR_3		3
#define COLOR_4		4
#define COLOR_5		5
#define COLOR_6		6
#define COLOR_7		7
#define COLOR_8		8
#define COLOR_9		9
#define COLOR_10	10
#define COLOR_11	11
#define COLOR_12	12
#define COLOR_13	13
#define COLOR_14	14
#define COLOR_15	15
#define MIN_ANSI_COLORS 16

#if OPT_256_COLORS
# define NUM_ANSI_COLORS 256
#elif OPT_88_COLORS
# define NUM_ANSI_COLORS 88
#else
# define NUM_ANSI_COLORS MIN_ANSI_COLORS
#endif

#if NUM_ANSI_COLORS > MIN_ANSI_COLORS
# define OPT_EXT_COLORS  1
#else
# define OPT_EXT_COLORS  0
#endif

#define COLOR_BD	(NUM_ANSI_COLORS)	/* BOLD */
#define COLOR_UL	(NUM_ANSI_COLORS+1)	/* UNDERLINE */
#define COLOR_BL	(NUM_ANSI_COLORS+2)	/* BLINK */
#define COLOR_RV	(NUM_ANSI_COLORS+3)	/* REVERSE */

#if OPT_WIDE_ATTRS
#define COLOR_IT	(NUM_ANSI_COLORS+4)	/* ITALIC */
#define MAXCOLORS	(NUM_ANSI_COLORS+5)
#else
#define MAXCOLORS	(NUM_ANSI_COLORS+4)
#endif

#ifndef DFT_COLORMODE
#define DFT_COLORMODE True	/* default colorMode resource */
#endif

#define UseItalicFont(screen) (!(screen)->colorITMode)

#define ReverseOrHilite(screen,flags,hilite) \
		(( screen->colorRVMode && hilite ) || \
		    ( !screen->colorRVMode && \
		      (( (flags & INVERSE) && !hilite) || \
		       (!(flags & INVERSE) &&  hilite)) ))

/* Define a fake XK code, we need it for the fake color response in
 * xtermcapKeycode(). */
#if OPT_TCAP_QUERY && OPT_ISO_COLORS
# define XK_COLORS 0x0003
#endif

#else	/* !OPT_ISO_COLORS */

#define TERM_COLOR_FLAGS(xw) 0

#define UseItalicFont(screen) True
#define ReverseOrHilite(screen,flags,hilite) \
		      (( (flags & INVERSE) && !hilite) || \
		       (!(flags & INVERSE) &&  hilite))

#endif	/* OPT_ISO_COLORS */

# define XK_TCAPNAME 0x0004

#if OPT_AIX_COLORS
#define if_OPT_AIX_COLORS(screen, code) if(screen->colorMode) code
#else
#define if_OPT_AIX_COLORS(screen, code) /* nothing */
#endif

#if OPT_256_COLORS || OPT_88_COLORS || OPT_ISO_COLORS
# define if_OPT_ISO_COLORS(screen, code) if (screen->colorMode) code
#else
# define if_OPT_ISO_COLORS(screen, code) /* nothing */
#endif

#define COLOR_RES_NAME(root) "color" root

#if OPT_COLOR_CLASS
#define COLOR_RES_CLASS(root) "Color" root
#else
#define COLOR_RES_CLASS(root) XtCForeground
#endif

#if OPT_COLOR_RES
#define COLOR_RES(root,offset,value) Sres(COLOR_RES_NAME(root), COLOR_RES_CLASS(root), offset.resource, value)
#define COLOR_RES2(name,class,offset,value) Sres(name, class, offset.resource, value)
#else
#define COLOR_RES(root,offset,value) Cres(COLOR_RES_NAME(root), COLOR_RES_CLASS(root), offset, value)
#define COLOR_RES2(name,class,offset,value) Cres(name, class, offset, value)
#endif

#define CLICK_RES_NAME(count)  "on" count "Clicks"
#define CLICK_RES_CLASS(count) "On" count "Clicks"
#define CLICK_RES(count,offset,value) Sres(CLICK_RES_NAME(count), CLICK_RES_CLASS(count), offset, value)

/***====================================================================***/

#if OPT_DEC_CHRSET
#define if_OPT_DEC_CHRSET(code) code
	/* Use 2 bits for encoding the double high/wide sense of characters */
#define CSET_SWL        0
#define CSET_DHL_TOP    1
#define CSET_DHL_BOT    2
#define CSET_DWL        3
#define NUM_CHRSET      8	/* normal/bold and 4 CSET_xxx values */

	/* Use remaining bits for encoding the other character-sets */
#define CSET_NORMAL(code)  ((code) == CSET_SWL)
#define CSET_DOUBLE(code)  (!CSET_NORMAL(code) && !CSET_EXTEND(code))
#define CSET_EXTEND(code)  ((int)(code) > CSET_DWL)

#define DBLCS_BITS            4
#define DBLCS_MASK            BITS2MASK(DBLCS_BITS)

#define GetLineDblCS(ld)      (((ld)->bufHead >> LINEFLAG_BITS) & DBLCS_MASK)
#define SetLineDblCS(ld,cs)   (ld)->bufHead = (RowData) ((ld->bufHead & LINEFLAG_MASK) | (cs << LINEFLAG_BITS))

#define LineCharSet(screen, ld) \
	((CSET_DOUBLE(GetLineDblCS(ld))) \
		? GetLineDblCS(ld) \
		: (screen)->cur_chrset)
#define LineMaxCol(screen, ld) \
	(CSET_DOUBLE(GetLineDblCS(ld)) \
	 ? (screen->max_col / 2) \
	 : (screen->max_col))
#define LineCursorX(screen, ld, col) \
	(CSET_DOUBLE(GetLineDblCS(ld)) \
	 ? CursorX(screen, 2*(col)) \
	 : CursorX(screen, (col)))
#define LineFontWidth(screen, ld) \
	(CSET_DOUBLE(GetLineDblCS(ld)) \
	 ? 2*FontWidth(screen) \
	 : FontWidth(screen))
#else

#define if_OPT_DEC_CHRSET(code) /*nothing*/

#define GetLineDblCS(ld)       0

#define LineCharSet(screen, ld)         0
#define LineMaxCol(screen, ld)          screen->max_col
#define LineCursorX(screen, ld, col)    CursorX(screen, col)
#define LineFontWidth(screen, ld)       FontWidth(screen)

#endif

#if OPT_LUIT_PROG && !OPT_WIDE_CHARS
#error Luit requires the wide-chars configuration
#endif

/***====================================================================***/

#if OPT_EBCDIC
extern int E2A(int);
extern int A2E(int);
#else
#define E2A(a) (a)
#define A2E(a) (a)
#endif

#define CONTROL(a) (A2E(E2A(a)&037))

/***====================================================================***/

#if OPT_TEK4014
#define TEK4014_ACTIVE(xw)      ((xw)->misc.TekEmu)
#define TEK4014_SHOWN(xw)       ((xw)->misc.Tshow)
#define CURRENT_EMU_VAL(tek,vt) (TEK4014_ACTIVE(term) ? tek : vt)
#define CURRENT_EMU()           CURRENT_EMU_VAL((Widget)tekWidget, (Widget)term)
#else
#define TEK4014_ACTIVE(screen)  0
#define TEK4014_SHOWN(xw)       0
#define CURRENT_EMU_VAL(tek,vt) (vt)
#define CURRENT_EMU()           ((Widget)term)
#endif

/***====================================================================***/

#if OPT_TOOLBAR
#define SHELL_OF(widget) XtParent(XtParent(widget))
#else
#define SHELL_OF(widget) XtParent(widget)
#endif

/***====================================================================***/

#if OPT_VT52_MODE
#define if_OPT_VT52_MODE(screen, code) if(screen->vtXX_level == 0) code
#else
#define if_OPT_VT52_MODE(screen, code) /* nothing */
#endif

/***====================================================================***/

#if OPT_XMC_GLITCH
#define if_OPT_XMC_GLITCH(screen, code) if(screen->xmc_glitch) code
#define XMC_GLITCH 1	/* the character we'll show */
#define XMC_FLAGS (INVERSE|UNDERLINE|BOLD|BLINK)
#else
#define if_OPT_XMC_GLITCH(screen, code) /* nothing */
#endif

/***====================================================================***/

typedef unsigned IFlags;	/* at least 32 bits */

#if OPT_WIDE_ATTRS
typedef unsigned short IAttr;	/* at least 16 bits */
#else
typedef unsigned char IAttr;	/* at least 8 bits */
#endif

/***====================================================================***/

#define LO_BYTE(ch) CharOf((ch) & 0xff)
#define HI_BYTE(ch) CharOf((ch) >> 8)

#if OPT_WIDE_CHARS
#define if_OPT_WIDE_CHARS(screen, code) if(screen->wide_chars) code
#define if_WIDE_OR_NARROW(screen, wide, narrow) if(screen->wide_chars) wide else narrow
#if OPT_WIDER_ICHAR
typedef unsigned IChar;		/* for 8-21 bit characters */
#else
typedef unsigned short IChar;	/* for 8-16 bit characters */
#endif
#else
#define if_OPT_WIDE_CHARS(screen, code) /* nothing */
#define if_WIDE_OR_NARROW(screen, wide, narrow) narrow
typedef unsigned char IChar;	/* for 8-bit characters */
#endif

/***====================================================================***/

#ifndef RES_OFFSET
#define RES_OFFSET(offset) XtOffsetOf(XtermWidgetRec, offset)
#endif

#define RES_NAME(name) name
#define RES_CLASS(name) name

#define Bres(name, class, offset, dftvalue) \
	{RES_NAME(name), RES_CLASS(class), XtRBoolean, sizeof(Boolean), \
	 RES_OFFSET(offset), XtRImmediate, (XtPointer) dftvalue}

#define Cres(name, class, offset, dftvalue) \
	{RES_NAME(name), RES_CLASS(class), XtRPixel, sizeof(Pixel), \
	 RES_OFFSET(offset), XtRString, DECONST(char,dftvalue)}

#define Tres(name, class, offset, dftvalue) \
	COLOR_RES2(name, class, screen.Tcolors[offset], dftvalue) \

#define Fres(name, class, offset, dftvalue) \
	{RES_NAME(name), RES_CLASS(class), XtRFontStruct, sizeof(XFontStruct *), \
	 RES_OFFSET(offset), XtRString, DECONST(char,dftvalue)}

#define Ires(name, class, offset, dftvalue) \
	{RES_NAME(name), RES_CLASS(class), XtRInt, sizeof(int), \
	 RES_OFFSET(offset), XtRImmediate, (XtPointer) dftvalue}

#define Dres(name, class, offset, dftvalue) \
	{RES_NAME(name), RES_CLASS(class), XtRFloat, sizeof(float), \
	 RES_OFFSET(offset), XtRString, DECONST(char,dftvalue)}

#define Sres(name, class, offset, dftvalue) \
	{RES_NAME(name), RES_CLASS(class), XtRString, sizeof(char *), \
	 RES_OFFSET(offset), XtRString, DECONST(char,dftvalue)}

#define Wres(name, class, offset, dftvalue) \
	{RES_NAME(name), RES_CLASS(class), XtRWidget, sizeof(Widget), \
	 RES_OFFSET(offset), XtRWidget, (XtPointer) dftvalue}

/***====================================================================***/

#define FRG_SIZE resource.minBufSize
#define BUF_SIZE resource.maxBufSize

typedef struct {
	Char    *next;
	Char    *last;
	int      update;	/* HandleInterpret */
#if OPT_WIDE_CHARS
	IChar    utf_data;	/* resulting character */
	int      utf_size;	/* ...number of bytes decoded */
	Char    *write_buf;
	unsigned write_len;
#endif
	Char     buffer[1];
} PtyData;

/***====================================================================***/

#if OPT_ISO_COLORS
#if OPT_256_COLORS || OPT_88_COLORS
#define COLOR_BITS 8
typedef unsigned short CellColor;
#else
#define COLOR_BITS 4
typedef Char CellColor;
#endif
#else
typedef unsigned CellColor;
#endif

#define BITS2MASK(b)          ((1 << b) - 1)

#define COLOR_MASK            BITS2MASK(COLOR_BITS)

#define GetCellColorFG(src)   ((src) & COLOR_MASK)
#define GetCellColorBG(src)   (((src) >> COLOR_BITS) & COLOR_MASK)

typedef Char RowData;		/* wrap/blink, and DEC single-double chars */

#define LINEFLAG_BITS         4
#define LINEFLAG_MASK         BITS2MASK(LINEFLAG_BITS)

#define GetLineFlags(ld)      ((ld)->bufHead & LINEFLAG_MASK)

#if OPT_DEC_CHRSET
#define SetLineFlags(ld,xx)   (ld)->bufHead = (RowData) ((ld->bufHead & (DBLCS_MASK << LINEFLAG_BITS)) | (xx & LINEFLAG_MASK))
#else
#define SetLineFlags(ld,xx)   (ld)->bufHead = (RowData) (xx & LINEFLAG_MASK)
#endif

typedef IChar CharData;

/*
 * This is the xterm line-data/scrollback structure.
 */
typedef struct {
	Dimension lineSize;	/* number of columns in this row */
	RowData bufHead;	/* flag for wrapped lines */
#if OPT_WIDE_CHARS
	Char combSize;		/* number of items in combData[] */
#endif
	IAttr *attribs;		/* video attributes */
#if OPT_ISO_COLORS
	CellColor *color;	/* foreground+background color numbers */
#endif
	CharData *charData;	/* cell's base character */
	CharData *combData[1];	/* first enum past fixed-offsets */
} LineData;

typedef const LineData CLineData;

/*
 * We use CellData in a few places, when copying a cell's data to a temporary
 * variable.
 */
typedef struct {
	IAttr attribs;
#if OPT_WIDE_CHARS
	Char combSize;		/* number of items in combData[] */
#endif
#if OPT_ISO_COLORS
	CellColor color;	/* color-array */
#endif
	CharData charData;	/* cell's base character */
	CharData combData[1];	/* array of combining chars */
} CellData;

#define for_each_combData(off, ld) for (off = 0; off < ld->combSize; ++off)

/*
 * Accommodate older compilers by not using variable-length arrays.
 */
#define SizeOfLineData  offsetof(LineData, combData)
#define SizeOfCellData  offsetof(CellData, combData)

	/*
	 * A "row" is the index within the visible part of the screen, and an
	 * "inx" is the index within the whole set of scrollable lines.
	 */
#define ROW2INX(screen, row)	((row) + (screen)->topline)
#define INX2ROW(screen, inx)	((inx) - (screen)->topline)

/* these are unused but could be useful for debugging */
#if 0
#define ROW2ABS(screen, row)	((row) + (screen)->savedlines)
#define INX2ABS(screen, inx)	ROW2ABS(screen, INX2ROW(screen, inx))
#endif

#define okScrnRow(screen, row) \
	((row) <= ((screen)->max_row - (screen)->topline) \
      && (row) >= -((screen)->savedlines))

	/*
	 * Cache data for "proportional" and other fonts containing a mixture
	 * of widths.
	 */
typedef struct {
	Bool		mixed;
	Dimension	min_width;	/* nominal cell width for 0..255 */
	Dimension	max_width;	/* maximum cell width */
} FontMap;

#define KNOWN_MISSING	256

typedef enum {
	fwNever = 0,
	fwResource,
	fwAlways
} fontWarningTypes;

typedef struct {
	unsigned	chrset;
	unsigned	flags;
	fontWarningTypes warn;
	XFontStruct *	fs;
	char *		fn;
	FontMap		map;
	Char		known_missing[KNOWN_MISSING];
} XTermFonts;

#if OPT_RENDERFONT
typedef enum {
	erFalse = 0
	, erTrue
	, erDefault
	, erLast
} RenderFont;

#define DefaultRenderFont(xw) \
	if ((xw)->work.render_font == erDefault) \
	    (xw)->work.render_font = erFalse

typedef struct {
	XftFont *	font;
	FontMap		map;
} XTermXftFonts;
#endif

typedef struct {
	int		top;
	int		left;
	int		bottom;
	int		right;
} XTermRect;

	/* indices into save_modes[] */
typedef enum {
	DP_ALTERNATE_SCROLL,
	DP_ALT_SENDS_ESC,
	DP_BELL_IS_URGENT,
	DP_CRS_VISIBLE,
	DP_DECANM,
	DP_DECARM,
	DP_DECAWM,
	DP_DECBKM,
	DP_DECCKM,
	DP_DECCOLM,	/* IN132COLUMNS */
	DP_DECKPAM,
	DP_DECNRCM,
	DP_DECOM,
	DP_DECPEX,
	DP_DECPFF,
	DP_DECSCLM,
	DP_DECSCNM,
	DP_DECTCEM,
	DP_DELETE_IS_DEL,
	DP_EIGHT_BIT_META,
	DP_KEEP_CLIPBOARD,
	DP_KEEP_SELECTION,
	DP_KEYBOARD_TYPE,
	DP_POP_ON_BELL,
	DP_PRN_EXTENT,
	DP_PRN_FORMFEED,
	DP_RXVT_SCROLLBAR,
	DP_RXVT_SCROLL_TTY_KEYPRESS,
	DP_RXVT_SCROLL_TTY_OUTPUT,
	DP_SELECT_TO_CLIPBOARD,
	DP_X_ALTSCRN,
	DP_X_DECCOLM,
	DP_X_EXT_MOUSE,
	DP_X_LOGGING,
	DP_X_LRMM,
	DP_X_MARGIN,
	DP_X_MORE,
	DP_X_MOUSE,
	DP_X_NCSM,
	DP_X_REVWRAP,
	DP_X_X10MSE,
#if OPT_BLINK_CURS
	DP_CRS_BLINK,
#endif
#if OPT_FOCUS_EVENT
	DP_X_FOCUS,
#endif
#if OPT_NUM_LOCK
	DP_REAL_NUMLOCK,
	DP_META_SENDS_ESC,
#endif
#if OPT_SHIFT_FONTS
	DP_RXVT_FONTSIZE,
#endif
#if OPT_SIXEL_GRAPHICS
	DP_DECSDM,
#endif
#if OPT_TEK4014
	DP_DECTEK,
#endif
#if OPT_TOOLBAR
	DP_TOOLBAR,
#endif
	DP_X_PRIVATE_COLOR_REGISTERS,
#if OPT_SIXEL_GRAPHICS
	DP_SIXEL_SCROLLS_RIGHT,
#endif
	DP_LAST
} SaveModes;

#define DoSM(code,value)  screen->save_modes[code] = (unsigned) (value)
#define DoRM(code,value)  value = (Boolean) screen->save_modes[code]
#define DoRM0(code,value) value = screen->save_modes[code]

	/* index into vt_shell[] or tek_shell[] */
typedef enum {
	noMenu = -1
	,mainMenu
	,vtMenu
	,fontMenu
#if OPT_TEK4014
	,tekMenu
#endif
} MenuIndex;

typedef enum {
	bvOff = -1,
	bvLow = 0,
	bvHigh
} BellVolume;

#define NUM_POPUP_MENUS 4

#if OPT_COLOR_RES
typedef struct {
	String		resource;
	Pixel		value;
	unsigned short red, green, blue;
	int		mode;		/* -1=invalid, 0=unset, 1=set   */
} ColorRes;
#else
#define ColorRes Pixel
#endif

/* these are set in getPrinterFlags */
typedef struct {
	int	printer_extent;		/* print complete page		*/
	int	printer_formfeed;	/* print formfeed per function	*/
	int	printer_newline;	/* print newline per function	*/
	int	print_attributes;	/* 0=off, 1=normal, 2=color	*/
	int	print_everything;	/* 0=all, 1=dft, 2=alt, 3=saved */
} PrinterFlags;

typedef struct {
	FILE *	fp;			/* output file/pipe used	*/
	Boolean isOpen;			/* output was opened/tried	*/
	Boolean toFile;			/* true when directly to file	*/
	Boolean printer_checked;	/* printer_command is checked	*/
	String	printer_command;	/* pipe/shell command string	*/
	Boolean printer_autoclose;	/* close printer when offline	*/
	Boolean printer_extent;		/* print complete page		*/
	Boolean printer_formfeed;	/* print formfeed per function	*/
	Boolean printer_newline;	/* print newline per function	*/
	int	printer_controlmode;	/* 0=off, 1=auto, 2=controller	*/
	int	print_attributes;	/* 0=off, 1=normal, 2=color	*/
	int	print_everything;	/* 0=all, 1=dft, 2=alt, 3=saved */
} PrinterState;

typedef struct {
	unsigned	which;		/* must have NCOLORS bits */
	Pixel		colors[NCOLORS];
	char		*names[NCOLORS];
} ScrnColors;

typedef struct {
	Boolean		saved;
	int		row;
	int		col;
	IFlags		flags;		/* VTxxx saves graphics rendition */
	Char		curgl;
	Char		curgr;
	int		gsets[4];
	Boolean		wrap_flag;
#if OPT_ISO_COLORS
	int		cur_foreground; /* current foreground color	*/
	int		cur_background; /* current background color	*/
	int		sgr_foreground; /* current SGR foreground color */
	int		sgr_background; /* current SGR background color */
	Boolean		sgr_extended;	/* SGR set with extended codes? */
#endif
} SavedCursor;

typedef struct _SaveTitle {
	struct _SaveTitle *next;
	char		*iconName;
	char		*windowName;
} SaveTitle;

#define SAVED_CURSORS 2

typedef struct {
	int		width;		/* if > 0, width of scrollbar,	*/
					/* and scrollbar is showing	*/
	Boolean		rv_cached;	/* see ScrollBarReverseVideo	*/
	int		rv_active;	/* ...current reverse-video	*/
	Pixel		bg;		/* ...cached background color	*/
	Pixel		fg;		/* ...cached foreground color	*/
	Pixel		bdr;		/* ...cached border color	*/
	Pixmap		bdpix;		/* ...cached border pixmap	*/
} SbInfo;

#if OPT_TOOLBAR
typedef struct {
	Widget		menu_bar;	/* toolbar, if initialized	*/
	Dimension	menu_height;	/* ...and its height		*/
	Dimension	menu_border;	/* ...and its border		*/
} TbInfo;
#define VT100_TB_INFO(name) screen.fullVwin.tb_info.name
#endif

typedef struct {
	Window		window;		/* X window id			*/
	int		width;		/* width of columns		*/
	int		height;		/* height of rows		*/
	Dimension	fullwidth;	/* full width of window		*/
	Dimension	fullheight;	/* full height of window	*/
	int		f_width;	/* width of fonts in pixels	*/
	int		f_height;	/* height of fonts in pixels	*/
	int		f_ascent;	/* ascent of font in pixels	*/
	int		f_descent;	/* descent of font in pixels	*/
	SbInfo		sb_info;
#if OPT_DOUBLE_BUFFER
	Drawable	drawable;	/* X drawable id                */
#endif
#if OPT_TOOLBAR
	Boolean		active;		/* true if toolbars are used	*/
	TbInfo		tb_info;	/* toolbar information		*/
#endif
} VTwin;

typedef struct {
	Window		window;		/* X window id			*/
	int		width;		/* width of columns		*/
	int		height;		/* height of rows		*/
	Dimension	fullwidth;	/* full width of window		*/
	Dimension	fullheight;	/* full height of window	*/
	double		tekscale;	/* scale factor Tek -> vs100	*/
} TKwin;

typedef struct {
    char *f_n;			/* the normal font */
    char *f_b;			/* the bold font */
#if OPT_WIDE_ATTRS
    char *f_i;			/* italic font (Xft only) */
#endif
#if OPT_WIDE_CHARS
    char *f_w;			/* the normal wide font */
    char *f_wb;			/* the bold wide font */
    char *f_wi;			/* wide italic font (Xft only) */
#endif
} VTFontNames;

typedef struct {
    char **list_n;		/* the normal font */
    char **list_b;		/* the bold font */
#if OPT_WIDE_ATTRS || OPT_RENDERWIDE
    char **list_i;		/* italic font (Xft only) */
#endif
#if OPT_WIDE_CHARS
    char **list_w;		/* the normal wide font */
    char **list_wb;		/* the bold wide font */
    char **list_wi;		/* wide italic font (Xft only) */
#endif
} VTFontList;

typedef struct {
    VTFontList x11;
#if OPT_RENDERFONT
    VTFontList xft;
#endif
} XtermFontNames;

typedef struct {
    VTFontNames default_font;
    String menu_font_names[NMENUFONTS][fMAX];
    XtermFontNames fonts;
} SubResourceRec;

#if OPT_INPUT_METHOD
#define NINPUTWIDGETS	3
typedef struct {
	Widget		w;
	XIM		xim;		/* input method attached to 'w' */
	XIC		xic;		/* input context attached to 'xim' */
} TInput;
#endif

typedef enum {
	CURSOR_BLOCK = 2
	, CURSOR_UNDERLINE = 4
	, CURSOR_BAR = 6
} XtCursorShape;

#define isCursorBlock(s)	((s)->cursor_shape == CURSOR_BLOCK)
#define isCursorUnderline(s)	((s)->cursor_shape == CURSOR_UNDERLINE)
#define isCursorBar(s)		((s)->cursor_shape == CURSOR_BAR)

typedef enum {
	DEFAULT_STYLE = 0
	, BLINK_BLOCK
	, STEADY_BLOCK
	, BLINK_UNDERLINE
	, STEADY_UNDERLINE
	, BLINK_BAR
	, STEADY_BAR
} XtCursorStyle;

typedef struct {
/* These parameters apply to both windows */
	Display		*display;	/* X display for screen		*/
	int		respond;	/* socket for responses
					   (position report, etc.)	*/
/* These parameters apply to VT100 window */
	IChar		unparse_bfr[256];
	unsigned	unparse_len;

#if OPT_TCAP_QUERY
	int		tc_query_code;
	Bool		tc_query_fkey;
#endif
	pid_t		pid;		/* pid of process on far side   */
	uid_t		uid;		/* user id of actual person	*/
	gid_t		gid;		/* group id of actual person	*/
	ColorRes	Tcolors[NCOLORS]; /* terminal colors		*/
#if OPT_HIGHLIGHT_COLOR
	Boolean		hilite_color;	/* hilite colors override	*/
	Boolean		hilite_reverse;	/* hilite overrides reverse	*/
#endif
#if OPT_ISO_COLORS
	XColor *	cmap_data;	/* color table			*/
	unsigned	cmap_size;
	ColorRes	Acolors[MAXCOLORS]; /* ANSI color emulation	*/
	int		veryBoldColors;	/* modifier for boldColors	*/
	Boolean		boldColors;	/* can we make bold colors?	*/
	Boolean		colorMode;	/* are we using color mode?	*/
	Boolean		colorULMode;	/* use color for underline?	*/
	Boolean		italicULMode;	/* italic font for underline?	*/
	Boolean		colorBDMode;	/* use color for bold?		*/
	Boolean		colorBLMode;	/* use color for blink?		*/
	Boolean		colorRVMode;	/* use color for reverse?	*/
	Boolean		colorAttrMode;	/* prefer colorUL/BD to SGR	*/
#if OPT_WIDE_ATTRS
	Boolean		colorITMode;	/* use color for italics?	*/
#endif
#endif
#if OPT_DEC_CHRSET
	Boolean		font_doublesize;/* enable font-scaling		*/
	int		cache_doublesize;/* limit of our cache		*/
	Char		cur_chrset;	/* character-set index & code	*/
	int		fonts_used;	/* count items in double_fonts	*/
	XTermFonts	double_fonts[NUM_CHRSET];
#endif
#if OPT_DEC_RECTOPS
	int		cur_decsace;	/* parameter for DECSACE	*/
#endif
#if OPT_WIDE_CHARS
	Boolean		wide_chars;	/* true when 16-bit chars	*/
	Boolean		vt100_graphics;	/* true to allow vt100-graphics	*/
	Boolean		utf8_inparse;	/* true to enable UTF-8 parser	*/
	Boolean		normalized_c;	/* true to precompose to Form C */
	char *		utf8_mode_s;	/* use UTF-8 decode/encode	*/
	char *		utf8_fonts_s;	/* use UTF-8 decode/encode	*/
	int		utf8_nrc_mode;	/* saved UTF-8 mode for DECNRCM */
	Boolean		utf8_always;	/* special case for wideChars	*/
	int		utf8_mode;	/* use UTF-8 decode/encode: 0-2	*/
	int		utf8_fonts;	/* use UTF-8 decode/encode: 0-2	*/
	int		max_combining;	/* maximum # of combining chars	*/
	Boolean		utf8_latin1;	/* use UTF-8 with Latin-1 bias	*/
	Boolean		utf8_title;	/* use UTF-8 titles		*/
	int		latin9_mode;	/* poor man's luit, latin9	*/
	int		unicode_font;	/* font uses unicode encoding	*/
	int		utf_count;	/* state of utf_char		*/
	IChar		utf_char;	/* in-progress character	*/
	Boolean		char_was_written;
	int		last_written_col;
	int		last_written_row;
	TypedBuffer(XChar2b);
	TypedBuffer(char);
#endif
#if OPT_BROKEN_OSC
	Boolean		brokenLinuxOSC; /* true to ignore Linux palette ctls */
#endif
#if OPT_BROKEN_ST
	Boolean		brokenStringTerm; /* true to match old OSC parse */
#endif
#if OPT_C1_PRINT || OPT_WIDE_CHARS
	Boolean		c1_printable;	/* true if we treat C1 as print	*/
#endif
	int		border;		/* inner border			*/
	int		scrollBarBorder; /* scrollBar border		*/
	long		event_mask;
	unsigned	send_mouse_pos;	/* user wants mouse transition  */
					/* and position information	*/
	int		extend_coords;	/* support large terminals	*/
#if OPT_FOCUS_EVENT
	Boolean		send_focus_pos; /* user wants focus in/out info */
#endif
	Boolean		quiet_grab;	/* true if no cursor change on focus */
#if OPT_PASTE64
	Cardinal	base64_paste;	/* set to send paste in base64	*/
	int		base64_final;	/* string-terminator for paste	*/
	/* _qWriteSelectionData expects these to be initialized to zero.
	 * base64_flush() is the last step of the conversion, it clears these
	 * variables.
	 */
	unsigned	base64_accu;
	unsigned	base64_count;
	unsigned	base64_pad;
#endif
#if OPT_READLINE
	unsigned	click1_moves;
	unsigned	paste_moves;
	unsigned	dclick3_deletes;
	unsigned	paste_brackets;
	unsigned	paste_quotes;
	unsigned	paste_literal_nl;
#endif	/* OPT_READLINE */
#if OPT_DEC_LOCATOR
	Boolean		locator_reset;	/* turn mouse off after 1 report? */
	Boolean		locator_pixels;	/* report in pixels?		*/
					/* if false, report in cells	*/
	unsigned	locator_events;	/* what events to report	*/
	Boolean		loc_filter;	/* is filter rectangle active?	*/
	int		loc_filter_top;	/* filter rectangle for DEC Locator */
	int		loc_filter_left;
	int		loc_filter_bottom;
	int		loc_filter_right;
#endif	/* OPT_DEC_LOCATOR */
	int		mouse_button;	/* current button pressed	*/
	int		mouse_row;	/* ...and its row		*/
	int		mouse_col;	/* ...and its column		*/
	int		select;		/* xterm selected		*/
	Boolean		bellOnReset;	/* bellOnReset			*/
	Boolean		visualbell;	/* visual bell mode		*/
	Boolean		poponbell;	/* pop on bell mode		*/

	Boolean		eraseSavedLines; /* eraseSavedLines option	*/
	Boolean		eraseSavedLines0; /* initial eraseSavedLines	*/
	Boolean		tabCancelsWrap; /* tabCancelsWrap option	*/

	Boolean		allowPasteControls; /* PasteControls mode	*/
	Boolean		allowColorOps;	/* ColorOps mode		*/
	Boolean		allowFontOps;	/* FontOps mode			*/
	Boolean		allowMouseOps;	/* MouseOps mode		*/
	Boolean		allowSendEvents;/* SendEvent mode		*/
	Boolean		allowTcapOps;	/* TcapOps mode			*/
	Boolean		allowTitleOps;	/* TitleOps mode		*/
	Boolean		allowWindowOps;	/* WindowOps mode		*/

	Boolean		allowPasteControl0; /* PasteControls mode	*/
	Boolean		allowColorOp0;	/* initial ColorOps mode	*/
	Boolean		allowFontOp0;	/* initial FontOps mode		*/
	Boolean		allowMouseOp0;	/* initial MouseOps mode	*/
	Boolean		allowSendEvent0;/* initial SendEvent mode	*/
	Boolean		allowTcapOp0;	/* initial TcapOps mode		*/
	Boolean		allowTitleOp0;	/* initial TitleOps mode	*/
	Boolean		allowWindowOp0;	/* initial WindowOps mode	*/

	String		disallowedColorOps;
	char		disallow_color_ops[ecLAST];

	String		disallowedFontOps;
	char		disallow_font_ops[efLAST];

	String		disallowedMouseOps;
	char		disallow_mouse_ops[emLAST];

	String		disallowedTcapOps;
	char		disallow_tcap_ops[etLAST];

	String		disallowedWinOps;
	char		disallow_win_ops[ewLAST];

	Boolean		awaitInput;	/* select-timeout mode		*/
	Boolean		grabbedKbd;	/* keyboard is grabbed		*/
#ifdef ALLOWLOGGING
	int		logging;	/* logging mode			*/
	int		logfd;		/* file descriptor of log	*/
	char		*logfile;	/* log file name		*/
	Char		*logstart;	/* current start of log buffer	*/
#endif
	int		inhibit;	/* flags for inhibiting changes	*/

/* VT window parameters */
	Boolean		Vshow;		/* VT window showing		*/
	VTwin		fullVwin;
	int		needSwap;
#ifndef NO_ACTIVE_ICON
	VTwin		iconVwin;
	VTwin		*whichVwin;
#endif /* NO_ACTIVE_ICON */

	int		pointer_mode;	/* when to use hidden_cursor	*/
	int		pointer_mode0;	/* ...initial value             */
	Boolean 	hide_pointer;	/* true to use "hidden_cursor"  */
	Cursor		pointer_cursor;	/* pointer cursor in window	*/
	Cursor		hidden_cursor;	/* hidden cursor in window	*/

	String	answer_back;		/* response to ENQ		*/

	PrinterState	printer_state;	/* actual printer state		*/
	PrinterFlags	printer_flags;	/* working copy of printer flags */
#if OPT_PRINT_ON_EXIT
	Boolean		write_error;
#endif

	Boolean		fnt_prop;	/* true if proportional fonts	*/
	Boolean		fnt_boxes;	/* true if font has box-chars	*/
	Boolean		force_packed;	/* true to override proportional */
#if OPT_BOX_CHARS
	Boolean		force_box_chars;/* true if we assume no boxchars */
	Boolean		force_all_chars;/* true to outline missing chars */
	Boolean		assume_all_chars;/* true to allow missing chars */
	Boolean		allow_packing;	/* true to allow packed-fonts	*/
#endif
	Dimension	fnt_wide;
	Dimension	fnt_high;
	float		scale_height;	/* scaling for font-height	*/
	XTermFonts	fnts[fMAX];	/* normal/bold/etc for terminal	*/
	Boolean		free_bold_box;	/* same_font_size's austerity	*/
	Boolean		allowBoldFonts;	/* do we use bold fonts at all? */
#if OPT_WIDE_ATTRS
	XTermFonts	ifnts[fMAX];	/* normal/bold/etc italic fonts */
	Boolean		ifnts_ok;	/* true if ifnts[] is cached	*/
#endif
#ifndef NO_ACTIVE_ICON
	XTermFonts	fnt_icon;	/* icon font			*/
	String		icon_fontname;	/* name of icon font		*/
	int		icon_fontnum;	/* number to use for icon font	*/
#endif /* NO_ACTIVE_ICON */
	int		enbolden;	/* overstrike for bold font	*/
	XPoint		*box;		/* draw unselected cursor	*/

	int		cursor_state;	/* ON, OFF, or BLINKED_OFF	*/
	int		cursor_busy;	/* do not redraw...		*/
	Boolean		cursor_underline; /* true if cursor is in underline mode */
	XtCursorShape	cursor_shape;
#if OPT_BLINK_CURS
	Boolean		cursor_blink;	/* cursor blink enable		*/
	Boolean		cursor_blink_res; /* initial cursor blink value	*/
	Boolean		cursor_blink_esc; /* cursor blink escape-state	*/
#endif
#if OPT_BLINK_TEXT
	Boolean		blink_as_bold;	/* text blink disable		*/
#endif
#if OPT_BLINK_CURS || OPT_BLINK_TEXT
	int		blink_state;	/* ON, OFF, or BLINKED_OFF	*/
	int		blink_on;	/* cursor on time (msecs)	*/
	int		blink_off;	/* cursor off time (msecs)	*/
	XtIntervalId	blink_timer;	/* timer-id for cursor-proc	*/
#endif
#if OPT_ZICONBEEP
	Boolean		zIconBeep_flagged; /* True if icon name was changed */
#endif /* OPT_ZICONBEEP */
	int		cursor_GC;	/* see ShowCursor()		*/
	int		cursor_set;	/* requested state		*/
	CELL		cursorp;	/* previous cursor row/column	*/
	int		cur_col;	/* current cursor column	*/
	int		cur_row;	/* current cursor row		*/
	int		max_col;	/* rightmost column		*/
	int		max_row;	/* bottom row			*/
	int		top_marg;	/* top line of scrolling region */
	int		bot_marg;	/* bottom line of  "	    "	*/
	int		lft_marg;	/* left column of "	    "	*/
	int		rgt_marg;	/* right column of "	    "	*/
	Widget		scrollWidget;	/* pointer to scrollbar struct	*/
	/*
	 * Indices used to keep track of the top of the vt100 window and
	 * the saved lines, taking scrolling into account.
	 */
	int		topline;	/* line number of top, <= 0	*/
	long		saved_fifo;     /* number of lines that've ever been saved */
	int		savedlines;     /* number of lines that've been saved */
	int		savelines;	/* number of lines off top to save */
	int		scroll_amt;	/* amount to scroll		*/
	int		refresh_amt;	/* amount to refresh		*/
	/*
	 * Working variables for getLineData().
	 */
	size_t		lineExtra;	/* extra space for combining chars */
	/*
	 * Pointer to the current visible buffer.
	 */
	ScrnBuf		visbuf;		/* ptr to visible screen buf (main) */
	/*
	 * Data for the normal buffer, which may have saved lines to which
	 * the user can scroll.
	 */
	ScrnBuf		saveBuf_index;
	Char		*saveBuf_data;
	/*
	 * Data for visible and alternate buffer.
	 */
	ScrnBuf		editBuf_index[2];
	Char		*editBuf_data[2];
	int		whichBuf;	/* 0/1 for normal/alternate buf */
	Boolean		is_running;	/* true when buffers are legal	*/
	/*
	 * Workspace used for screen operations.
	 */
	Char		**save_ptr;	/* workspace for save-pointers  */
	size_t		save_len;	/* ...and its length		*/

	int		scrolllines;	/* number of lines to button scroll */
	Boolean		alternateScroll; /* scroll-actions become keys */
	Boolean		scrollttyoutput; /* scroll to bottom on tty output */
	Boolean		scrollkey;	/* scroll to bottom on key	*/
	Boolean		cursor_moved;	/* scrolling makes cursor move	*/

	Boolean		do_wrap;	/* true if cursor in last column
					    and character just output    */

	int		incopy;		/* 0 idle; 1 XCopyArea issued;
					    -1 first GraphicsExpose seen,
					    but last not seen		*/
	int		copy_src_x;	/* params from last XCopyArea ... */
	int		copy_src_y;
	unsigned int	copy_width;
	unsigned int	copy_height;
	int		copy_dest_x;
	int		copy_dest_y;

	Dimension	embed_wide;
	Dimension	embed_high;

	Boolean		c132;		/* allow change to 132 columns	*/
	Boolean		curses;		/* kludge line wrap for more	*/
	Boolean		hp_ll_bc;	/* kludge HP-style ll for xdb	*/
	Boolean		marginbell;	/* true if margin bell on	*/
	int		nmarginbell;	/* columns from right margin	*/
	int		bellArmed;	/* cursor below bell margin	*/
	BellVolume	marginVolume;	/* margin-bell volume           */
	BellVolume	warningVolume;	/* warning-bell volume          */
	Boolean		multiscroll;	/* true if multi-scroll		*/
	int		scrolls;	/* outstanding scroll count,
					    used only with multiscroll	*/
	SavedCursor	sc[SAVED_CURSORS]; /* data for restore cursor	*/
	IFlags		save_modes[DP_LAST]; /* save dec/xterm private modes */

	int		title_modes;	/* control set/get of titles	*/
	int		title_modes0;	/* ...initial value         	*/
	SaveTitle	*save_title;

	/* Improved VT100 emulation stuff.				*/
	String		keyboard_dialect; /* default keyboard dialect	*/
	int		gsets[4];	/* G0 through G3.		*/
	Char		curgl;		/* Current GL setting.		*/
	Char		curgr;		/* Current GR setting.		*/
	Char		curss;		/* Current single shift.	*/
	String		term_id;	/* resource for terminal_id	*/
	int		terminal_id;	/* 100=vt100, 220=vt220, etc.	*/
	int		vtXX_level;	/* 0=vt52, 1,2,3 = vt100 ... vt320 */
	int		ansi_level;	/* dpANSI levels 1,2,3		*/
	int		protected_mode;	/* 0=off, 1=DEC, 2=ISO		*/
	Boolean		always_bold_mode; /* compare normal/bold font	*/
	Boolean		always_highlight; /* whether to highlight cursor */
	Boolean		bold_mode;	/* use bold font or overstrike	*/
	Boolean		delete_is_del;	/* true for compatible Delete key */
	Boolean		jumpscroll;	/* whether we should jumpscroll */
	Boolean		fastscroll;	/* whether we should fastscroll */
	Boolean		old_fkeys;	/* true for compatible fkeys	*/
	Boolean		old_fkeys0;	/* ...initial value         	*/
	Boolean		underline;	/* whether to underline text	*/

#if OPT_MAXIMIZE
	Boolean		restore_data;
	int		restore_x;
	int		restore_y;
	unsigned	restore_width;
	unsigned	restore_height;
#endif

#if OPT_REGIS_GRAPHICS
	String		graphics_regis_default_font; /* font for "builtin" */

	String		graphics_regis_screensize; /* given a size in pixels */
	Dimension	graphics_regis_def_wide; /* ...corresponding width   */
	Dimension	graphics_regis_def_high; /* ...and height            */
#endif

#if OPT_GRAPHICS
	String		graphics_max_size;	/* given a size in pixels */
	Dimension	graphics_max_wide;	/* ...corresponding width */
	Dimension	graphics_max_high;	/* ...and height          */
#endif

#if OPT_SCROLL_LOCK
	Boolean		allowScrollLock;/* ScrollLock mode		*/
	Boolean		allowScrollLock0;/* initial ScrollLock mode	*/
	Boolean		scroll_lock;	/* true to keep buffer in view	*/
	Boolean		scroll_dirty;	/* scrolling makes screen dirty	*/
#endif

#if OPT_SIXEL_GRAPHICS
	Boolean		sixel_scrolling; /* sixel scrolling             */
	Boolean		sixel_scrolls_right; /* sixel scrolling moves cursor to right */
#endif

#if OPT_GRAPHICS
	int		numcolorregisters; /* number of supported color registers */
	Boolean		privatecolorregisters; /* private color registers for each graphic */
#endif

#if OPT_VT52_MODE
	Char		vt52_save_curgl;
	Char		vt52_save_curgr;
	Char		vt52_save_curss;
	int		vt52_save_gsets[4];
#endif
	/* Testing */
#if OPT_XMC_GLITCH
	unsigned	xmc_glitch;	/* # of spaces to pad on SGR's	*/
	IAttr		xmc_attributes;	/* attrs that make a glitch	*/
	Boolean		xmc_inline;	/* SGR's propagate only to eol	*/
	Boolean		move_sgr_ok;	/* SGR is reset on move		*/
#endif

	/*
	 * Bell
	 */
	int		visualBellDelay; /* msecs to delay for visibleBell */
	int		bellSuppressTime; /* msecs after Bell before another allowed */
	Boolean		bellInProgress; /* still ringing/flashing prev bell? */
	Boolean		bellIsUrgent;	/* set XUrgency WM hint on bell */
	Boolean		flash_line;	/* show visualBell as current line */
	/*
	 * Select/paste state.
	 */
	Boolean		selectToClipboard; /* primary vs clipboard */
	String		*mappedSelect;	/* mapping for "SELECT" to "PRIMARY" */

	Boolean		waitingForTrackInfo;
	int		numberOfClicks;
	int		maxClicks;
	int		multiClickTime;	/* time between multiclick selects */
	SelectUnit	selectUnit;
	SelectUnit	selectMap[NSELECTUNITS];
	String		onClick[NSELECTUNITS + 1];

	char		*charClass;	/* for overriding word selection */
	Boolean		cutNewline;	/* whether or not line cut has \n */
	Boolean		cutToBeginningOfLine;  /* line cuts to BOL? */
	Boolean		highlight_selection; /* controls appearance of selection */
	Boolean		show_wrap_marks; /* show lines which are wrapped */
	Boolean		trim_selection; /* controls trimming of selection */
	Boolean		i18nSelections;
	Boolean		brokenSelections;
	Boolean		keepClipboard;	/* retain data sent to clipboard */
	Boolean		keepSelection;	/* do not lose selection on output */
	Boolean		replyToEmacs;	/* Send emacs escape code when done selecting or extending? */
	Char		*selection_data; /* the current selection */
	int		selection_size; /* size of allocated buffer */
	unsigned long	selection_length; /* number of significant bytes */
	Char		*clipboard_data; /* the current clipboard */
	unsigned long	clipboard_size; /*  size of allocated buffer */
	EventMode	eventMode;
	Time		selection_time;	/* latest event timestamp */
	Time		lastButtonUpTime;
	unsigned	lastButton;

	CELL		rawPos;		/* raw position for selection start */
	CELL		startRaw;	/* area before selectUnit processing */
	CELL		endRaw;		/* " " */
	CELL		startSel;	/* area after selectUnit processing */
	CELL		endSel;		/* " " */
	CELL		startH;		/* start highlighted text */
	CELL		endH;		/* end highlighted text */
	CELL		saveStartW;	/* saved WORD state, for LINE */
	CELL		startExt;	/* Start, end of extension */
	CELL		endExt;		/* " " */
	CELL		saveStartR;	/* Saved values of raw selection for extend to restore to */
	CELL		saveEndR;	/* " " */
	int		startHCoord, endHCoord;
	int		firstValidRow;	/* Valid rows for selection clipping */
	int		lastValidRow;	/* " " */

	Boolean		selectToBuffer;	/* copy selection to buffer	*/
	InternalSelect	internal_select;

	String		default_string;
	String		eightbit_select_types;
	Atom*		selection_targets_8bit;
#if OPT_WIDE_CHARS
	String		utf8_select_types;
	Atom*		selection_targets_utf8;
#endif
	Atom*		selection_atoms; /* which selections we own */
	Cardinal	sel_atoms_size;	 /* how many atoms allocated */
	Cardinal	selection_count; /* how many atoms in use */
#if OPT_SELECT_REGEX
	char *		selectExpr[NSELECTUNITS];
#endif
	/*
	 * Input/output state.
	 */
	Boolean		input_eight_bits;	/* do not send ESC when meta pressed */
	int		eight_bit_meta;		/* use 8th bit when meta pressed */
	char *		eight_bit_meta_s;	/* ...resource eightBitMeta */
	Boolean		output_eight_bits;	/* honor all bits or strip */
	Boolean		control_eight_bits;	/* send CSI as 8-bits */
	Boolean		backarrow_key;		/* backspace/delete */
	Boolean		alt_is_not_meta;	/* use both Alt- and Meta-key */
	Boolean		alt_sends_esc;		/* Alt-key sends ESC prefix */
	Boolean		meta_sends_esc;		/* Meta-key sends ESC prefix */
	/*
	 * Fonts
	 */
	Pixmap		menu_item_bitmap;	/* mask for checking items */
	String		initial_font;
	char *		menu_font_names[NMENUFONTS][fMAX];
#define MenuFontName(n) menu_font_names[n][fNorm]
#define EscapeFontName() MenuFontName(fontMenu_fontescape)
#define SelectFontName() MenuFontName(fontMenu_fontsel)
	long		menu_font_sizes[NMENUFONTS];
	int		menu_font_number;
#if OPT_LOAD_VTFONTS || OPT_WIDE_CHARS
	Boolean		savedVTFonts;
	Boolean		mergedVTFonts;
	SubResourceRec	cacheVTFonts;
#endif
#if OPT_CLIP_BOLD
	Boolean		use_clipping;
#endif
	void *		main_cgs_cache;
#ifndef NO_ACTIVE_ICON
	void *		icon_cgs_cache;
#endif
#if OPT_RENDERFONT
	XTermXftFonts	renderFontNorm[NMENUFONTS];
	XTermXftFonts	renderFontBold[NMENUFONTS];
	XTermXftFonts	renderFontItal[NMENUFONTS];
#if OPT_RENDERWIDE
	XTermXftFonts	renderWideNorm[NMENUFONTS];
	XTermXftFonts	renderWideBold[NMENUFONTS];
	XTermXftFonts	renderWideItal[NMENUFONTS];
	TypedBuffer(XftCharSpec);
#else
	TypedBuffer(XftChar8);
#endif
	XftDraw *	renderDraw;
#endif
#if OPT_DABBREV
	Boolean		dabbrev_working;	/* nonzero during dabbrev process */
	unsigned char	dabbrev_erase_char;	/* used for deleting inserted completion */
#endif
	char		tcapbuf[TERMCAP_SIZE];
	char		tcap_area[TERMCAP_SIZE];
#if OPT_TCAP_FKEYS
	char **		tcap_fkeys;
#endif
} TScreen;

typedef struct _TekPart {
	XFontStruct *	Tfont[TEKNUMFONTS];
	int		tobaseline[TEKNUMFONTS]; /* top-baseline, each font */
	char *		initial_font;		/* large, 2, 3, small */
	char *		gin_terminator_str;	/* ginTerminator resource */
#if OPT_TOOLBAR
	TbInfo		tb_info;	/* toolbar information		*/
#endif
} TekPart;

/* Tektronix window parameters */
typedef struct _TekScreen {
	GC		TnormalGC;	/* normal painting		*/
	GC		TcursorGC;	/* normal cursor painting	*/

	Boolean		waitrefresh;	/* postpone refresh		*/
	TKwin		fullTwin;
#ifndef NO_ACTIVE_ICON
	TKwin		iconTwin;
	TKwin		*whichTwin;
#endif /* NO_ACTIVE_ICON */

	Cursor		arrow;		/* arrow cursor			*/
	GC		linepat[TEKNUMLINES]; /* line patterns		*/
	int		cur_X;		/* current x			*/
	int		cur_Y;		/* current y			*/
	Tmodes		cur;		/* current tek modes		*/
	Tmodes		page;		/* starting tek modes on page	*/
	int		margin;		/* 0 -> margin 1, 1 -> margin 2	*/
	int		pen;		/* current Tektronix pen 0=up, 1=dn */
	char		*TekGIN;	/* nonzero if Tektronix GIN mode*/
	int		gin_terminator; /* Tek strap option */
	char		tcapbuf[TERMCAP_SIZE];
} TekScreen;

#if OPT_READLINE
#define SCREEN_FLAG(screenp,f)		(1&(screenp)->f)
#define SCREEN_FLAG_set(screenp,f)	((screenp)->f |= 1)
#define SCREEN_FLAG_unset(screenp,f)	((screenp)->f &= (unsigned) ~1L)
#define SCREEN_FLAG_save(screenp,f)	\
	((screenp)->f = (((screenp)->f)<<1) | SCREEN_FLAG(screenp,f))
#define SCREEN_FLAG_restore(screenp,f)	((screenp)->f = (((screenp)->f)>>1))
#else
#define SCREEN_FLAG(screenp,f)		(0)
#endif

/*
 * After screen-updates, reset the flag that tells us we should do wrapping.
 * Likewise, reset (in wide-character mode) the flag that tells us where the
 * "previous" character was written.
 */
#if OPT_WIDE_CHARS
#define ResetWrap(screen) \
    (screen)->do_wrap = \
    (screen)->char_was_written = False
#else
#define ResetWrap(screen) \
    (screen)->do_wrap = False
#endif

/* meaning of bits in screen.select flag */
#define	INWINDOW	01	/* the mouse is in one of the windows */
#define	FOCUS		02	/* one of the windows is the focus window */

#define MULTICLICKTIME 250	/* milliseconds */

typedef struct {
    const char *name;
    int code;
} FlagList;

typedef enum {
    keyboardIsLegacy,		/* bogus vt220 codes for F1-F4, etc. */
    keyboardIsDefault,
    keyboardIsHP,
    keyboardIsSCO,
    keyboardIsSun,
    keyboardIsTermcap,
    keyboardIsVT220
} xtermKeyboardType;

typedef enum {			/* legal values for screen.pointer_mode */
    pNever = 0
    , pNoMouse = 1
    , pAlways = 2
    , pFocused = 3
} pointerModeTypes;

typedef enum {			/* legal values for screen.utf8_mode */
    uFalse = 0
    , uTrue = 1
    , uAlways = 2
    , uDefault = 3
    , uLast
} utf8ModeTypes;

typedef enum {			/* legal values for screen.eight_bit_meta */
    ebFalse = 0
    , ebTrue = 1
    , ebNever = 2
    , ebLocale = 3
    , ebLast
} ebMetaModeTypes;

#define NAME_OLD_KT " legacy"

#if OPT_HP_FUNC_KEYS
#define NAME_HP_KT " hp"
#else
#define NAME_HP_KT /*nothing*/
#endif

#if OPT_SCO_FUNC_KEYS
#define NAME_SCO_KT " sco"
#else
#define NAME_SCO_KT /*nothing*/
#endif

#if OPT_SUN_FUNC_KEYS
#define NAME_SUN_KT " sun"
#else
#define NAME_SUN_KT /*nothing*/
#endif

#if OPT_SUNPC_KBD
#define NAME_VT220_KT " vt220"
#else
#define NAME_VT220_KT /*nothing*/
#endif

#if OPT_TCAP_FKEYS
#define NAME_TCAP_KT " tcap"
#else
#define NAME_TCAP_KT /*nothing*/
#endif

#define KEYBOARD_TYPES NAME_TCAP_KT NAME_HP_KT NAME_SCO_KT NAME_SUN_KT NAME_VT220_KT

#if OPT_TRACE
#define TRACE_RC(code,func) code = func
#else
#define TRACE_RC(code,func) func
#endif

extern	const char * visibleKeyboardType(xtermKeyboardType);

typedef struct
{
    int allow_keys;		/* how to handle legacy/vt220 keyboard */
    int cursor_keys;		/* how to handle cursor-key modifiers */
    int function_keys;		/* how to handle function-key modifiers */
    int keypad_keys;		/* how to handle keypad key-modifiers */
    int other_keys;		/* how to handle other key-modifiers */
    int string_keys;		/* how to handle string() modifiers */
} TModify;

typedef struct
{
    xtermKeyboardType type;
    IFlags flags;
    char *shell_translations;
    char *xterm_translations;
    char *extra_translations;
#if OPT_INITIAL_ERASE
    int	reset_DECBKM;		/* reset should set DECBKM */
#endif
#if OPT_MOD_FKEYS
    TModify modify_now;		/* current modifier value */
    TModify modify_1st;		/* original modifier value, for resets */
    int format_keys;		/* format of modifyOtherKeys */
#endif
} TKeyboard;

#define GravityIsNorthWest(w) ((w)->misc.resizeGravity == NorthWestGravity)
#define GravityIsSouthWest(w) ((w)->misc.resizeGravity == SouthWestGravity)

typedef struct _Misc {
    VTFontNames default_font;
    char *geo_metry;
    char *T_geometry;
#if OPT_WIDE_CHARS
    Boolean cjk_width;		/* true for built-in CJK wcwidth() */
    Boolean mk_width;		/* true for simpler built-in wcwidth() */
    int mk_samplesize;
    int mk_samplepass;
#endif
#if OPT_LUIT_PROG
    Boolean callfilter;		/* true to invoke luit */
    Boolean use_encoding;	/* true to use -encoding option for luit */
    char *locale_str;		/* "locale" resource */
    char *localefilter;		/* path for luit */
#endif
    fontWarningTypes fontWarnings;
    int limit_resize;
#ifdef ALLOWLOGGING
    Boolean log_on;
#endif
    Boolean login_shell;
    Boolean re_verse;
    Boolean re_verse0;		/* initial value of "-rv" */
    XtGravity resizeGravity;
    Boolean reverseWrap;
    Boolean autoWrap;
    Boolean logInhibit;
    Boolean signalInhibit;
#if OPT_TEK4014
    Boolean tekInhibit;
    Boolean tekSmall;		/* start tek window in small size */
    Boolean TekEmu;		/* true if Tektronix emulation	*/
    Boolean Tshow;		/* Tek window showing		*/
#endif
    Boolean scrollbar;
#ifdef SCROLLBAR_RIGHT
    Boolean useRight;
#endif
    Boolean titeInhibit;
    Boolean tiXtraScroll;	/* scroll on ti/te */
    Boolean cdXtraScroll;	/* scroll on cd (clear-display) */
    Boolean appcursorDefault;
    Boolean appkeypadDefault;
#if OPT_INPUT_METHOD
    char* f_x;			/* font for XIM */
    char* input_method;
    char* preedit_type;
    Boolean open_im;		/* true if input-method is opened */
    int retry_im;
#endif
    Boolean dynamicColors;
#ifndef NO_ACTIVE_ICON
    char *active_icon_s;	/* use application icon window  */
    unsigned icon_border_width;
    Pixel icon_border_pixel;
#endif /* NO_ACTIVE_ICON */
#if OPT_DEC_SOFTFONT
    Boolean font_loadable;
#endif
#if OPT_SHIFT_FONTS
    Boolean shift_fonts;	/* true if we interpret fontsize-shifting */
#endif
#if OPT_SUNPC_KBD
    int ctrl_fkeys;		/* amount to add to XK_F1 for ctrl modifier */
#endif
#if OPT_NUM_LOCK
    Boolean real_NumLock;	/* true if we treat NumLock key specially */
    Boolean alwaysUseMods;	/* true if we always want f-key modifiers */
#endif
#if OPT_RENDERFONT
    VTFontNames default_xft;
    float face_size[NMENUFONTS];
    char *render_font_s;
#endif
} Misc;

typedef struct _Work {
    int dummy;
#ifdef SunXK_F36
#define MAX_UDK 37
#else
#define MAX_UDK 35
#endif
    struct {
	char *str;
	int len;
    } user_keys[MAX_UDK];
#ifndef NO_ACTIVE_ICON
    int active_icon;		/* use application icon window  */
#endif /* NO_ACTIVE_ICON */
#if OPT_INPUT_METHOD
    Boolean cannot_im;		/* true if we cannot use input-method */
    XFontSet xim_fs;		/* fontset for XIM preedit */
    int xim_fs_ascent;		/* ascent of fs */
    TInput inputs[NINPUTWIDGETS];
#endif
#if OPT_MAXIMIZE
#define MAX_EWMH_MODE 3
#define MAX_EWMH_DATA (1 + OPT_TEK4014)
    struct {
	int mode;		/* fullscreen, etc.		*/
	Boolean checked[MAX_EWMH_MODE];
	Boolean allowed[MAX_EWMH_MODE];
    } ewmh[MAX_EWMH_DATA];
#endif
#if OPT_NUM_LOCK
    unsigned num_lock;		/* modifier for Num_Lock */
    unsigned alt_mods;		/* modifier for Alt_L or Alt_R */
    unsigned meta_mods;		/* modifier for Meta_L or Meta_R */
#endif
    XtermFontNames fonts;
#if OPT_RENDERFONT
    Boolean render_font;
#endif
#if OPT_DABBREV
#define MAX_DABBREV	1024	/* maximum word length as in tcsh */
    char dabbrev_data[MAX_DABBREV];
#endif
    ScrnColors *oldColors;
    Boolean palette_changed;
} Work;

typedef struct {int foo;} XtermClassPart, TekClassPart;

typedef struct _XtermClassRec {
    CoreClassPart  core_class;
    XtermClassPart xterm_class;
} XtermClassRec;

extern WidgetClass xtermWidgetClass;

#define IsXtermWidget(w) (XtClass(w) == xtermWidgetClass)

#if OPT_TEK4014
typedef struct _TekClassRec {
    CoreClassPart core_class;
    TekClassPart tek_class;
} TekClassRec;

extern WidgetClass tekWidgetClass;

#define IsTekWidget(w) (XtClass(w) == tekWidgetClass)

#endif

/* define masks for keyboard.flags */
#define MODE_KAM	xBIT(0)	/* mode 2: keyboard action mode */
#define MODE_DECKPAM	xBIT(1)	/* keypad application mode */
#define MODE_DECCKM	xBIT(2)	/* private mode 1: cursor keys */
#define MODE_SRM	xBIT(3)	/* mode 12: send-receive mode */
#define MODE_DECBKM	xBIT(4)	/* private mode 67: backarrow */
#define MODE_DECSDM	xBIT(5)	/* private mode 80: sixel scrolling mode */

#define N_MARGINBELL	10

#define TAB_BITS_SHIFT	5	/* FIXME: 2**5 == 32 (should derive) */
#define TAB_BITS_WIDTH	(1 << TAB_BITS_SHIFT)
#define TAB_ARRAY_SIZE	(1024 / TAB_BITS_WIDTH)
#define MAX_TABS	(TAB_BITS_WIDTH * TAB_ARRAY_SIZE)

typedef unsigned Tabs [TAB_ARRAY_SIZE];

typedef struct _XtermWidgetRec {
    CorePart	core;
    XSizeHints	hints;
    XVisualInfo *visInfo;
    int		numVisuals;
    Bool	init_menu;
    TKeyboard	keyboard;	/* terminal keyboard		*/
    TScreen	screen;		/* terminal screen		*/
    IFlags	flags;		/* mode flags			*/
    int		cur_foreground; /* current foreground color	*/
    int		cur_background; /* current background color	*/
    Pixel	dft_foreground; /* default foreground color	*/
    Pixel	dft_background; /* default background color	*/
    Pixel	old_foreground; /* original foreground color	*/
    Pixel	old_background; /* original background color	*/
#if OPT_ISO_COLORS
    int		sgr_foreground; /* current SGR foreground color */
    int		sgr_background; /* current SGR background color */
    Boolean	sgr_extended;	/* SGR set with extended codes? */
#endif
    IFlags	initflags;	/* initial mode flags		*/
    Tabs	tabs;		/* tabstops of the terminal	*/
    Misc	misc;		/* miscellaneous parameters	*/
    Work	work;		/* workspace (no resources)	*/
} XtermWidgetRec, *XtermWidget;

#if OPT_TEK4014
typedef struct _TekWidgetRec {
    CorePart	core;
    XtermWidget vt;		/* main widget has border, etc. */
    TekPart	tek;		/* contains resources */
    TekScreen	screen;		/* contains working data (no resources) */
    Bool	init_menu;
    XSizeHints	hints;
} TekWidgetRec, *TekWidget;
#endif /* OPT_TEK4014 */

/*
 * terminal flags
 * There are actually two namespaces mixed together here.
 * One is the set of flags that can go in screen->visbuf attributes
 * and which must fit in a char (see OFF_ATTRS).
 * The other is the global setting stored in
 * term->flags and screen->save_modes.  This need only fit in an unsigned.
 */

#define AttrBIT(n)	xBIT(n)		/* text-attributes */
#define MiscBIT(n)	xBIT(n + 16)	/* miscellaneous state flags */

/* global flags and character flags (visible character attributes) */
#define INVERSE		AttrBIT(0)	/* invert the characters to be output */
#define UNDERLINE	AttrBIT(1)	/* true if underlining */
#define BOLD		AttrBIT(2)
#define BLINK		AttrBIT(3)
/* global flags (also character attributes) */
#define BG_COLOR	AttrBIT(4)	/* true if background set */
#define FG_COLOR	AttrBIT(5)	/* true if foreground set */

/* character flags (internal attributes) */
#define PROTECTED	AttrBIT(6)	/* a character that cannot be erased */
#define CHARDRAWN	AttrBIT(7)	/* a character has been drawn here on
					   the screen.  Used to distinguish
					   blanks from empty parts of the
					   screen when selecting */

#if OPT_WIDE_ATTRS
#define ATR_FAINT	AttrBIT(8)
#define ATR_ITALIC	AttrBIT(9)
#define ATR_STRIKEOUT	AttrBIT(10)
#define ATR_DBL_UNDER	AttrBIT(11)
#define SGR_MASK2       (ATR_FAINT | ATR_ITALIC | ATR_STRIKEOUT | ATR_DBL_UNDER)
#else
#define SGR_MASK2       0
#endif

/*
 * Other flags
 */
#define WRAPAROUND	MiscBIT(0)	/* true if auto wraparound mode */
#define	REVERSEWRAP	MiscBIT(1)	/* true if reverse wraparound mode */
#define REVERSE_VIDEO	MiscBIT(2)	/* true if screen white on black */
#define LINEFEED	MiscBIT(3)	/* true if in auto linefeed mode */
#define ORIGIN		MiscBIT(4)	/* true if in origin mode */
#define INSERT		MiscBIT(5)	/* true if in insert mode */
#define SMOOTHSCROLL	MiscBIT(6)	/* true if in smooth scroll mode */
#define IN132COLUMNS	MiscBIT(7)	/* true if in 132 column mode */
#define INVISIBLE	MiscBIT(8)	/* true if writing invisible text */
#define NATIONAL        MiscBIT(9)	/* true if writing national charset */
#define LEFT_RIGHT      MiscBIT(10)	/* true if left/right margin mode */
#define NOCLEAR_COLM    MiscBIT(11)	/* true if no clear on DECCOLM change */

#define DrawBIT(n)	xBIT(n + 8)	/* drawXtermText flags */
/* The following attributes are used in the argument of drawXtermText()  */
#define NOBACKGROUND	DrawBIT(0)	/* Used for overstrike */
#define NOTRANSLATION	DrawBIT(1)	/* No scan for chars missing in font */
#define DOUBLEWFONT	DrawBIT(2)	/* The actual X-font is double-width */
#define DOUBLEHFONT	DrawBIT(3)	/* The actual X-font is double-height */
#define CHARBYCHAR	DrawBIT(4)	/* Draw chars one-by-one */

/* The following attribute is used in the argument of xtermSpecialFont etc */
#define NORESOLUTION	DrawBIT(5)	/* find the font without resolution */


/*
 * Groups of attributes
 */
			/* mask for video-attributes only */
#define SGR_MASK	(BOLD | BLINK | UNDERLINE | INVERSE)

			/* mask: user-visible attributes */
#define	ATTRIBUTES	(SGR_MASK | SGR_MASK2 | BG_COLOR | FG_COLOR | INVISIBLE | PROTECTED)

/* The toplevel-call to drawXtermText() should have text-attributes guarded: */
#define DRAWX_MASK	(ATTRIBUTES | CHARDRAWN)

/*
 * BOLDATTR is not only nonzero when we will use bold font, but uses the bits
 * for BOLD/BLINK to match against the video attributes which were originally
 * requested.
 */
#define USE_BOLD(screen) ((screen)->allowBoldFonts)

#if OPT_BLINK_TEXT
#define BOLDATTR(screen) (unsigned) (USE_BOLD(screen) ? (BOLD | ((screen)->blink_as_bold ? BLINK : 0)) : 0)
#else
#define BOLDATTR(screen) (unsigned) (USE_BOLD(screen) ? (BOLD | BLINK) : 0)
#endif

/*
 * Per-line flags
 */
#define LINEWRAPPED	AttrBIT(0)
/* used once per line to indicate that it wraps onto the next line so we can
 * tell the difference between lines that have wrapped around and lines that
 * have ended naturally with a CR at column max_col.
 */
#define LINEBLINKED	AttrBIT(1)
/* set when the line contains blinking text.
 */

#if OPT_ZICONBEEP || OPT_TOOLBAR
#define HANDLE_STRUCT_NOTIFY 1
#else
#define HANDLE_STRUCT_NOTIFY 0
#endif

/*
 * If we've set protected attributes with the DEC-style DECSCA, then we'll have
 * to use DECSED or DECSEL to erase preserving protected text.  (The normal ED,
 * EL won't preserve protected-text).  If we've used SPA, then normal ED and EL
 * will preserve protected-text.  To keep things simple, just remember the last
 * control that was used to begin protected-text, and use that to determine how
 * erases are performed (otherwise we'd need 2 bits per protected character).
 */
#define OFF_PROTECT 0
#define DEC_PROTECT 1
#define ISO_PROTECT 2

#define TScreenOf(xw)	(&(xw)->screen)
#define TekScreenOf(tw) (&(tw)->screen)

#define PrinterOf(screen) (screen)->printer_state

#ifdef SCROLLBAR_RIGHT
#define OriginX(screen) (((term->misc.useRight)?0:ScrollbarWidth(screen)) + screen->border)
#else
#define OriginX(screen) (ScrollbarWidth(screen) + screen->border)
#endif

#define OriginY(screen) (screen->border)

#define CursorMoved(screen) \
		((screen)->cursor_moved || \
		    ((screen)->cursorp.col != (screen)->cur_col || \
		     (screen)->cursorp.row != (screen)->cur_row))

#define CursorX2(screen,col,fw) ((col) * (int)(fw) + OriginX(screen))
#define CursorX(screen,col)     CursorX2(screen, col, FontWidth(screen))
#define CursorY2(screen,row)    (((row) * FontHeight(screen)) + screen->border)
#define CursorY(screen,row)     CursorY2(screen, INX2ROW(screen, row))

/*
 * These definitions depend on whether xterm supports active-icon.
 */
#ifndef NO_ACTIVE_ICON
#define IsIconWin(screen,win)	((win) == &(screen)->iconVwin)
#define IsIcon(screen)		(WhichVWin(screen) == &(screen)->iconVwin)
#define WhichVWin(screen)	((screen)->whichVwin)
#define WhichTWin(screen)	((screen)->whichTwin)

#define WhichVFont(screen,name)	(IsIcon(screen) ? getIconicFont(screen) \
						: getNormalFont(screen, name))->fs
#define FontAscent(screen)	(IsIcon(screen) ? getIconicFont(screen)->fs->ascent \
						: WhichVWin(screen)->f_ascent)
#define FontDescent(screen)	(IsIcon(screen) ? getIconicFont(screen)->fs->descent \
						: WhichVWin(screen)->f_descent)
#else /* NO_ACTIVE_ICON */

#define IsIconWin(screen,win)	(False)
#define IsIcon(screen)		(False)
#define WhichVWin(screen)	(&((screen)->fullVwin))
#define WhichTWin(screen)	(&((screen)->fullTwin))

#define WhichVFont(screen,name)	getNormalFont(screen, name)->fs
#define FontAscent(screen)	WhichVWin(screen)->f_ascent
#define FontDescent(screen)	WhichVWin(screen)->f_descent

#endif /* NO_ACTIVE_ICON */

#define okFont(font) ((font) != 0 && (font)->fid != 0)

/*
 * Macro to check if we are iconified; do not use render for that case.
 */
#define UsingRenderFont(xw)	(((xw)->work.render_font == True) && !IsIcon(TScreenOf(xw)))

/*
 * These definitions do not depend on whether xterm supports active-icon.
 */
#define VWindow(screen)		WhichVWin(screen)->window
#define VShellWindow(xw)	XtWindow(SHELL_OF(xw))
#define TWindow(screen)		WhichTWin(screen)->window
#define TShellWindow		XtWindow(SHELL_OF(tekWidget))

#if OPT_DOUBLE_BUFFER
#define VDrawable(screen)	(((screen)->needSwap=1), WhichVWin(screen)->drawable)
#else
#define VDrawable(screen)	VWindow(screen)
#endif

#define Width(screen)		WhichVWin(screen)->width
#define Height(screen)		WhichVWin(screen)->height
#define FullWidth(screen)	WhichVWin(screen)->fullwidth
#define FullHeight(screen)	WhichVWin(screen)->fullheight
#define FontWidth(screen)	WhichVWin(screen)->f_width
#define FontHeight(screen)	WhichVWin(screen)->f_height

#define NormalFont(screen)	WhichVFont(screen, fNorm)
#define BoldFont(screen)	WhichVFont(screen, fBold)

#if OPT_WIDE_CHARS
#define NormalWFont(screen)	WhichVFont(screen, fWide)
#define BoldWFont(screen)	WhichVFont(screen, fWBold)
#endif

#define ScrollbarWidth(screen)	WhichVWin(screen)->sb_info.width

#define NormalGC(w,sp)		getCgsGC(w, WhichVWin(sp), gcNorm)
#define ReverseGC(w,sp)		getCgsGC(w, WhichVWin(sp), gcNormReverse)
#define NormalBoldGC(w,sp)	getCgsGC(w, WhichVWin(sp), gcBold)
#define ReverseBoldGC(w,sp)	getCgsGC(w, WhichVWin(sp), gcBoldReverse)

#define TWidth(screen)		WhichTWin(screen)->width
#define THeight(screen)		WhichTWin(screen)->height
#define TFullWidth(screen)	WhichTWin(screen)->fullwidth
#define TFullHeight(screen)	WhichTWin(screen)->fullheight
#define TekScale(screen)	WhichTWin(screen)->tekscale

/* use these before tek4014 is realized, good enough for default "9x15" font */
#define TDefaultRows		37
#define TDefaultCols		75

#define BorderWidth(w)		((w)->core.border_width)
#define BorderPixel(w)		((w)->core.border_pixel)

#define AllowXtermOps(w,name)	(TScreenOf(w)->name && !TScreenOf(w)->allowSendEvents)

#define AllowColorOps(w,name)	(AllowXtermOps(w, allowColorOps) || \
				 !TScreenOf(w)->disallow_color_ops[name])

#define AllowFontOps(w,name)	(AllowXtermOps(w, allowFontOps) || \
				 !TScreenOf(w)->disallow_font_ops[name])

#define AllowMouseOps(w,name)	(AllowXtermOps(w, allowMouseOps) || \
				 !TScreenOf(w)->disallow_mouse_ops[name])

#define AllowTcapOps(w,name)	(AllowXtermOps(w, allowTcapOps) || \
				 !TScreenOf(w)->disallow_tcap_ops[name])

#define AllowTitleOps(w)	AllowXtermOps(w, allowTitleOps)

#define SpecialWindowOps(w,name) (!TScreenOf(w)->disallow_win_ops[name])
#define AllowWindowOps(w,name)	(AllowXtermOps(w, allowWindowOps) || \
				 SpecialWindowOps(w,name))

#if OPT_TOOLBAR
#define ToolbarHeight(w)	((resource.toolBar) \
				 ? ((w)->VT100_TB_INFO(menu_height) \
				  + (w)->VT100_TB_INFO(menu_border) * 2) \
				 : 0)
#else
#define ToolbarHeight(w) 0
#endif

#if OPT_TEK4014
#define TEK_LINK_BLOCK_SIZE 1024

typedef struct Tek_Link
{
	struct Tek_Link	*next;	/* pointer to next TekLink in list
				   NULL <=> this is last TekLink */
	unsigned short fontsize;/* character size, 0-3 */
	unsigned short count;	/* number of chars in data */
	char *ptr;		/* current pointer into data */
	char data [TEK_LINK_BLOCK_SIZE];
} TekLink;
#endif /* OPT_TEK4014 */

/* flags for cursors */
#define	OFF		0
#define	ON		1
#define	BLINKED_OFF	2
#define	CLEAR		0
#define	TOGGLE		1

/* flags for inhibit */
#ifdef ALLOWLOGGING
#define	I_LOG		0x01
#endif
#define	I_SIGNAL	0x02
#define	I_TEK		0x04

/***====================================================================***/

#if OPT_TRACE
#undef NDEBUG			/* turn on assert's */
#else
#ifndef NDEBUG
#define NDEBUG			/* not debugging, don't do assert's */
#endif
#endif

#include 

#ifndef TRACE
#define TRACE(p) /*nothing*/
#endif

#ifndef TRACE_CLOSE
#define TRACE_CLOSE() /*nothing*/
#endif

#ifndef TRACE_ARGV
#define TRACE_ARGV(tag,argv) /*nothing*/
#endif

#ifndef TRACE_CHILD
#define TRACE_CHILD /*nothing*/
#endif

#ifndef TRACE_FOCUS
#define TRACE_FOCUS(w,e) /*nothing*/
#endif

#ifndef TRACE_HINTS
#define TRACE_HINTS(hints) /*nothing*/
#endif

#ifndef TRACE_IDS
#define TRACE_IDS /*nothing*/
#endif

#ifndef TRACE_OPTS
#define TRACE_OPTS(opts,ress,lens) /*nothing*/
#endif

#ifndef TRACE_TRANS
#define TRACE_TRANS(name,w) /*nothing*/
#endif

#ifndef TRACE_WIN_ATTRS
#define TRACE_WIN_ATTRS(w) /*nothing*/
#endif

#ifndef TRACE_WM_HINTS
#define TRACE_WM_HINTS(w) /*nothing*/
#endif

#ifndef TRACE_XRES
#define TRACE_XRES() /*nothing*/
#endif

#ifndef TRACE2
#define TRACE2(p) /*nothing*/
#endif

#if OPT_TRACE && !defined(DEBUG)
#define DEBUG 1
#endif

#ifdef DEBUG
#define if_DEBUG(code) if(debug) code
#else
#define if_DEBUG(code) /*nothing*/
#endif

#define DEBUG_MSG(text) if_DEBUG({ IGNORE_RC(write(2, text, sizeof(text) - 1)); })

/* *INDENT-ON* */

#endif /* included_ptyx_h */
xterm-330/trace.h0000644000175100001440000001543713040510350012507 0ustar  tomusers/* $XTermId: trace.h,v 1.80 2017/01/20 22:36:24 tom Exp $ */

/*
 * Copyright 1997-2016,2017 by Thomas E. Dickey
 *
 *                         All Rights Reserved
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name(s) of the above copyright
 * holders shall not be used in advertising or otherwise to promote the
 * sale, use or other dealings in this Software without prior written
 * authorization.
 */

/*
 * Common/useful definitions for XTERM application
 */
#ifndef	included_trace_h
#define	included_trace_h
/* *INDENT-OFF* */

#include 

#if OPT_TRACE

extern	void	Trace ( const char *, ... ) GCC_PRINTFLIKE(1,2);

#undef  TRACE
#define TRACE(p) Trace p

extern	void	TraceClose (void);

#undef  TRACE_CLOSE
#define TRACE_CLOSE TraceClose

#if OPT_TRACE > 1
#define TRACE2(p) Trace p
#endif

extern	const char * visibleChars(const Char * /* buf */, unsigned /* len */);
extern	const char * visibleIChars(const IChar * /* buf */, unsigned /* len */);
extern	const char * visibleUChar(unsigned);
extern	const char * visibleDblChrset(unsigned /* chrset */);
extern	const char * visibleEventType (int);
extern	const char * visibleNotifyDetail(int /* code */);
extern	const char * visibleNotifyMode (int /* code */);
extern	const char * visibleScsCode(int /* chrset */);
extern	const char * visibleSelectionTarget(Display * /* d */, Atom /* a */);
extern	const char * visibleTekparse (int);
extern	const char * visibleVTparse (int);
extern	const char * visibleXError (int /* code */);

extern	const char * TraceAtomName(Display * /* d */, Atom /* a */);

extern	void	TraceArgv(const char * /* tag */, char ** /* argv */);
#undef  TRACE_ARGV
#define	TRACE_ARGV(tag,argv) TraceArgv(tag,argv)

extern	const	char *trace_who;
#undef  TRACE_CHILD
#define TRACE_CHILD int tracing_child = (trace_who = "child") != 0; (void) tracing_child;

extern	void	TraceFocus(Widget, XEvent *);
#undef  TRACE_FOCUS
#define	TRACE_FOCUS(w,e) TraceFocus((Widget)w, (XEvent *)e)

extern	void	TraceSizeHints(XSizeHints *);
#undef  TRACE_HINTS
#define	TRACE_HINTS(hints) TraceSizeHints(hints)

extern	void	TraceIds(const char * /* fname */, int  /* lnum */);
#undef  TRACE_IDS
#define	TRACE_IDS TraceIds(__FILE__, __LINE__)

extern	void	TraceTime(const char * /* fname */, int  /* lnum */);
#undef  TRACE_TIME
#define	TRACE_TIME TraceTime(__FILE__, __LINE__)

extern	void	TraceOptions(OptionHelp * /* options */, XrmOptionDescRec * /* resources */, Cardinal  /* count */);
#undef  TRACE_OPTS
#define	TRACE_OPTS(opts,ress,lens) TraceOptions(opts,ress,lens)

extern	void	TraceTranslations(const char *, Widget);
#undef  TRACE_TRANS
#define	TRACE_TRANS(name,w) TraceTranslations(name,w)

extern	void	TraceWindowAttributes(XWindowAttributes *);
#undef  TRACE_WIN_ATTRS
#define	TRACE_WIN_ATTRS(a) TraceWindowAttributes(a)

extern	void	TraceWMSizeHints(XtermWidget);
#undef  TRACE_WM_HINTS
#define	TRACE_WM_HINTS(w) TraceWMSizeHints(w)

extern	void	TraceXtermResources(void);
#undef  TRACE_XRES
#define	TRACE_XRES() TraceXtermResources()

extern	XtGeometryResult TraceResizeRequest(const char * /* fn */, int  /* ln */, Widget  /* w */, unsigned  /* reqwide */, unsigned  /* reqhigh */, Dimension * /* gotwide */, Dimension * /* gothigh */);
#undef  REQ_RESIZE
#define REQ_RESIZE(w, reqwide, reqhigh, gotwide, gothigh) \
	TraceResizeRequest(__FILE__, __LINE__, w, \
			   (reqwide), (reqhigh), \
			   (gotwide), (gothigh))

extern const char * ModifierName(unsigned /* modifier */);
#define FMT_MODIFIER_NAMES "%s%s%s%s%s%s%s%s"
#define ARG_MODIFIER_NAMES(state) \
	   ModifierName(state & ShiftMask), \
	   ModifierName(state & LockMask), \
	   ModifierName(state & ControlMask), \
	   ModifierName(state & Mod1Mask), \
	   ModifierName(state & Mod2Mask), \
	   ModifierName(state & Mod3Mask), \
	   ModifierName(state & Mod4Mask), \
	   ModifierName(state & Mod5Mask)

#else

#define REQ_RESIZE(w, reqwide, reqhigh, gotwide, gothigh) \
	XtMakeResizeRequest((Widget) (w), \
			    (Dimension) (reqwide), (Dimension) (reqhigh), \
			    (gotwide), (gothigh))

#endif

extern void TraceScreen(XtermWidget /* xw */, int /* whichBuf */);

/*
 * The whole wnew->screen struct is zeroed in VTInitialize.  Use these macros
 * where applicable for copying the pieces from the request widget into the
 * new widget.  We do not have to use them for wnew->misc, but the associated
 * traces are very useful for debugging.
 */
#if OPT_TRACE
#define init_Bres(name) \
	TRACE(("init " #name " = %s\n", \
		BtoS(wnew->name = request->name)))
#define init_Dres(name) \
	TRACE(("init " #name " = %f\n", \
		wnew->name = request->name))
#define init_Dres2(name,i) \
	TRACE(("init " #name "[%d] = %f\n", i, \
		wnew->name[i] = request->name[i]))
#define init_Ires(name) \
	TRACE(("init " #name " = %d\n", \
		wnew->name = request->name))
#define init_Mres(name) \
	TRACE(("init " #name " = %s\n", \
		MtoS(wnew->name = request->name)))
#define init_Sres(name) \
	TRACE(("init " #name " = \"%s\"\n", \
		(wnew->name = x_strtrim(request->name)) != NULL \
			? wnew->name : ""))
#define init_Sres2(name,i) \
	TRACE(("init " #name "[%d] = \"%s\"\n", i, \
		(wnew->name(i) = x_strtrim(request->name(i))) != NULL \
			? wnew->name(i) : ""))
#define init_Tres(offset) \
	TRACE(("init screen.Tcolors[" #offset "] = %#lx\n", \
		fill_Tres(wnew, request, offset)))
#else
#define init_Bres(name)    wnew->name = request->name
#define init_Dres(name)    wnew->name = request->name
#define init_Dres2(name,i) wnew->name[i] = request->name[i]
#define init_Ires(name)    wnew->name = request->name
#define init_Mres(name)    wnew->name = request->name
#define init_Sres(name)    wnew->name = x_strtrim(request->name)
#define init_Sres2(name,i) wnew->name(i) = x_strtrim(request->name(i))
#define init_Tres(offset)  fill_Tres(wnew, request, offset)
#endif

/* *INDENT-ON* */

#endif /* included_trace_h */
xterm-330/button.c0000644000175100001440000042252413113232065012723 0ustar  tomusers/* $XTermId: button.c,v 1.524 2017/05/30 08:58:29 tom Exp $ */

/*
 * Copyright 1999-2016,2017 by Thomas E. Dickey
 *
 *                         All Rights Reserved
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name(s) of the above copyright
 * holders shall not be used in advertising or otherwise to promote the
 * sale, use or other dealings in this Software without prior written
 * authorization.
 *
 *
 * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 *
 *                         All Rights Reserved
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose and without fee is hereby granted,
 * provided that the above copyright notice appear in all copies and that
 * both that copyright notice and this permission notice appear in
 * supporting documentation, and that the name of Digital Equipment
 * Corporation not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 *
 *
 * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */

/*
button.c	Handles button events in the terminal emulator.
		does cut/paste operations, change modes via menu,
		passes button events through to some applications.
				J. Gettys.
*/

#include 

#include 
#include 
#include 

#include 
#include 
#include 

#include 
#include 

#include 
#include 
#include 
#include 
#include 

#if OPT_SELECT_REGEX
#ifdef HAVE_PCREPOSIX_H
#include 
#else /* POSIX regex.h */
#include 
#include 
#endif
#endif

#if OPT_WIDE_CHARS
#include 
#include 
#else
#define CharacterClass(value) \
	charClass[(value) & ((sizeof(charClass)/sizeof(charClass[0]))-1)]
#endif

    /*
     * We'll generally map rows to indices when doing selection.
     * Simplify that with a macro.
     *
     * Note that ROW2INX() is safe to use with auto increment/decrement for
     * the row expression since that is evaluated once.
     */
#define GET_LINEDATA(screen, row) \
	getLineData(screen, ROW2INX(screen, row))

    /*
     * We reserve shift modifier for cut/paste operations.  In principle we
     * can pass through control and meta modifiers, but in practice, the
     * popup menu uses control, and the window manager is likely to use meta,
     * so those events are not delivered to SendMousePosition.
     */
#define OurModifiers (ShiftMask | ControlMask | Mod1Mask)
#define AllModifiers (ShiftMask | LockMask | ControlMask | Mod1Mask | \
		      Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask)

#define BtnModifiers(event) (event->state & OurModifiers)
#define KeyModifiers(event) (event->xbutton.state & OurModifiers)

#define IsBtnEvent(event) ((event)->type == ButtonPress || (event)->type == ButtonRelease)
#define IsKeyEvent(event) ((event)->type == KeyPress    || (event)->type == KeyRelease)

#define KeyState(x) (((int) ((x) & (ShiftMask|ControlMask))) \
			  + (((x) & Mod1Mask) ? 2 : 0))
    /* adds together the bits:
       shift key -> 1
       meta key  -> 2
       control key -> 4 */

#define	Coordinate(s,c)	((c)->row * MaxCols(s) + (c)->col)

static const CELL zeroCELL =
{0, 0};

#if OPT_DEC_LOCATOR
static Bool SendLocatorPosition(XtermWidget xw, XButtonEvent *event);
static void CheckLocatorPosition(XtermWidget xw, XButtonEvent *event);
#endif /* OPT_DEC_LOCATOR */

/* Multi-click handling */
#if OPT_READLINE
static Time lastButtonDownTime = 0;
static int ExtendingSelection = 0;
static Time lastButton3UpTime = 0;
static Time lastButton3DoubleDownTime = 0;
static CELL lastButton3;	/* At the release time */
#endif /* OPT_READLINE */

static Char *SaveText(TScreen *screen, int row, int scol, int ecol,
		      Char *lp, int *eol);
static int Length(TScreen *screen, int row, int scol, int ecol);
static void ComputeSelect(XtermWidget xw, CELL *startc, CELL *endc, Bool extend);
static void EditorButton(XtermWidget xw, XButtonEvent *event);
static void EndExtend(XtermWidget w, XEvent *event, String *params, Cardinal
		      num_params, Bool use_cursor_loc);
static void ExtendExtend(XtermWidget xw, const CELL *cell);
static void PointToCELL(TScreen *screen, int y, int x, CELL *cell);
static void ReHiliteText(XtermWidget xw, CELL *first, CELL *last);
static void SaltTextAway(XtermWidget xw, CELL *cellc, CELL *cell);
static void SelectSet(XtermWidget xw, XEvent *event, String *params, Cardinal num_params);
static void SelectionReceived PROTO_XT_SEL_CB_ARGS;
static void StartSelect(XtermWidget xw, const CELL *cell);
static void TrackDown(XtermWidget xw, XButtonEvent *event);
static void TrackText(XtermWidget xw, const CELL *first, const CELL *last);
static void _OwnSelection(XtermWidget xw, String *selections, Cardinal count);
static void do_select_end(XtermWidget xw, XEvent *event, String *params,
			  Cardinal *num_params, Bool use_cursor_loc);

#define MOUSE_LIMIT (255 - 32)

/* Send SET_EXT_SIZE_MOUSE to enable offsets up to EXT_MOUSE_LIMIT */
#define EXT_MOUSE_LIMIT (2047 - 32)
#define EXT_MOUSE_START (127 - 32)

static int
MouseLimit(TScreen *screen)
{
    int mouse_limit;

    switch (screen->extend_coords) {
    default:
	mouse_limit = MOUSE_LIMIT;
	break;
    case SET_EXT_MODE_MOUSE:
	mouse_limit = EXT_MOUSE_LIMIT;
	break;
    case SET_SGR_EXT_MODE_MOUSE:
    case SET_URXVT_EXT_MODE_MOUSE:
	mouse_limit = -1;
	break;
    }
    return mouse_limit;
}

static unsigned
EmitMousePosition(TScreen *screen, Char line[], unsigned count, int value)
{
    int mouse_limit = MouseLimit(screen);

    /*
     * Add pointer position to key sequence
     *
     * In extended mode we encode large positions as two-byte UTF-8.
     *
     * NOTE: historically, it was possible to emit 256, which became
     * zero by truncation to 8 bits. While this was arguably a bug,
     * it's also somewhat useful as a past-end marker. We preserve
     * this behavior for both normal and extended mouse modes.
     */
    switch (screen->extend_coords) {
    default:
	if (value == mouse_limit) {
	    line[count++] = CharOf(0);
	} else {
	    line[count++] = CharOf(' ' + value + 1);
	}
	break;
    case SET_EXT_MODE_MOUSE:
	if (value == mouse_limit) {
	    line[count++] = CharOf(0);
	} else if (value < EXT_MOUSE_START) {
	    line[count++] = CharOf(' ' + value + 1);
	} else {
	    value += ' ' + 1;
	    line[count++] = CharOf(0xC0 + (value >> 6));
	    line[count++] = CharOf(0x80 + (value & 0x3F));
	}
	break;
    case SET_SGR_EXT_MODE_MOUSE:
	/* FALLTHRU */
    case SET_URXVT_EXT_MODE_MOUSE:
	count += (unsigned) sprintf((char *) line + count, "%d", value + 1);
	break;
    }
    return count;
}

static unsigned
EmitMousePositionSeparator(TScreen *screen, Char line[], unsigned count)
{
    switch (screen->extend_coords) {
    case SET_SGR_EXT_MODE_MOUSE:
    case SET_URXVT_EXT_MODE_MOUSE:
	line[count++] = ';';
	break;
    }
    return count;
}

Bool
SendMousePosition(XtermWidget xw, XEvent *event)
{
    XButtonEvent *my_event = (XButtonEvent *) event;
    Bool result = False;

    switch (okSendMousePos(xw)) {
    case MOUSE_OFF:
	/* If send_mouse_pos mode isn't on, we shouldn't be here */
	break;

    case BTN_EVENT_MOUSE:
    case ANY_EVENT_MOUSE:
	if (KeyModifiers(event) == 0 || KeyModifiers(event) == ControlMask) {
	    /* xterm extension for motion reporting. June 1998 */
	    /* EditorButton() will distinguish between the modes */
	    switch (event->type) {
	    case MotionNotify:
		my_event->button = 0;
		/* FALLTHRU */
	    case ButtonPress:
		/* FALLTHRU */
	    case ButtonRelease:
		EditorButton(xw, my_event);
		result = True;
		break;
	    }
	}
	break;

    case X10_MOUSE:		/* X10 compatibility sequences */
	if (IsBtnEvent(event)) {
	    if (BtnModifiers(my_event) == 0) {
		if (my_event->type == ButtonPress)
		    EditorButton(xw, my_event);
		result = True;
	    }
	}
	break;

    case VT200_HIGHLIGHT_MOUSE:	/* DEC vt200 hilite tracking */
	if (IsBtnEvent(event)) {
	    if (my_event->type == ButtonPress &&
		BtnModifiers(my_event) == 0 &&
		my_event->button == Button1) {
		TrackDown(xw, my_event);
		result = True;
	    } else if (BtnModifiers(my_event) == 0
		       || BtnModifiers(my_event) == ControlMask) {
		EditorButton(xw, my_event);
		result = True;
	    }
	}
	break;

    case VT200_MOUSE:		/* DEC vt200 compatible */
	if (IsBtnEvent(event)) {
	    if (BtnModifiers(my_event) == 0
		|| BtnModifiers(my_event) == ControlMask) {
		EditorButton(xw, my_event);
		result = True;
	    }
	}
	break;

    case DEC_LOCATOR:
	if (IsBtnEvent(event)) {
#if OPT_DEC_LOCATOR
	    result = SendLocatorPosition(xw, my_event);
#endif /* OPT_DEC_LOCATOR */
	}
	break;
    }
    return result;
}

#if OPT_DEC_LOCATOR

#define	LocatorCoords( row, col, x, y, oor )			\
    if( screen->locator_pixels ) {				\
	(oor)=False; (row) = (y)+1; (col) = (x)+1;		\
	/* Limit to screen dimensions */			\
	if ((row) < 1) (row) = 1,(oor)=True;			\
	else if ((row) > screen->border*2+Height(screen))	\
	    (row) = screen->border*2+Height(screen),(oor)=True;	\
	if ((col) < 1) (col) = 1,(oor)=True;			\
	else if ((col) > OriginX(screen)*2+Width(screen))	\
	    (col) = OriginX(screen)*2+Width(screen),(oor)=True;	\
    } else {							\
	(oor)=False;						\
	/* Compute character position of mouse pointer */	\
	(row) = ((y) - screen->border) / FontHeight(screen);	\
	(col) = ((x) - OriginX(screen)) / FontWidth(screen);	\
	/* Limit to screen dimensions */			\
	if ((row) < 0) (row) = 0,(oor)=True;			\
	else if ((row) > screen->max_row)			\
	    (row) = screen->max_row,(oor)=True;			\
	if ((col) < 0) (col) = 0,(oor)=True;			\
	else if ((col) > screen->max_col)			\
	    (col) = screen->max_col,(oor)=True;			\
	(row)++; (col)++;					\
    }

static Bool
SendLocatorPosition(XtermWidget xw, XButtonEvent *event)
{
    ANSI reply;
    TScreen *screen = TScreenOf(xw);
    int row, col;
    Bool oor;
    int button;
    unsigned state;

    /* Make sure the event is an appropriate type */
    if ((!IsBtnEvent(event) &&
	 !screen->loc_filter) ||
	(BtnModifiers(event) != 0 && BtnModifiers(event) != ControlMask))
	return (False);

    if ((event->type == ButtonPress &&
	 !(screen->locator_events & LOC_BTNS_DN)) ||
	(event->type == ButtonRelease &&
	 !(screen->locator_events & LOC_BTNS_UP)))
	return (True);

    if (event->type == MotionNotify) {
	CheckLocatorPosition(xw, event);
	return (True);
    }

    /* get button # */
    button = (int) event->button - 1;

    LocatorCoords(row, col, event->x, event->y, oor);

    /*
     * DECterm mouse:
     *
     * ESCAPE '[' event ; mask ; row ; column '&' 'w'
     */
    memset(&reply, 0, sizeof(reply));
    reply.a_type = ANSI_CSI;

    if (oor) {
	reply.a_nparam = 1;
	reply.a_param[0] = 0;	/* Event - 0 = locator unavailable */
	reply.a_inters = '&';
	reply.a_final = 'w';
	unparseseq(xw, &reply);

	if (screen->locator_reset) {
	    MotionOff(screen, xw);
	    screen->send_mouse_pos = MOUSE_OFF;
	}
	return (True);
    }

    /*
     * event:
     *        1       no buttons
     *        2       left button down
     *        3       left button up
     *        4       middle button down
     *        5       middle button up
     *        6       right button down
     *        7       right button up
     *        8       M4 down
     *        9       M4 up
     */
    reply.a_nparam = 4;
    switch (event->type) {
    case ButtonPress:
	reply.a_param[0] = (ParmType) (2 + (button << 1));
	break;
    case ButtonRelease:
	reply.a_param[0] = (ParmType) (3 + (button << 1));
	break;
    default:
	return (True);
    }
    /*
     * mask:
     * bit7   bit6   bit5   bit4   bit3     bit2       bit1         bit0
     *                             M4 down  left down  middle down  right down
     *
     * Notice that Button1 (left) and Button3 (right) are swapped in the mask.
     * Also, mask should be the state after the button press/release,
     * X provides the state not including the button press/release.
     */
    state = (event->state
	     & (Button1Mask | Button2Mask | Button3Mask | Button4Mask)) >> 8;
    /* update mask to "after" state */
    state ^= ((unsigned) (1 << button));
    /* swap Button1 & Button3 */
    state = ((state & (unsigned) ~(4 | 1))
	     | ((state & 1) ? 4 : 0)
	     | ((state & 4) ? 1 : 0));

    reply.a_param[1] = (ParmType) state;
    reply.a_param[2] = (ParmType) row;
    reply.a_param[3] = (ParmType) col;
    reply.a_inters = '&';
    reply.a_final = 'w';

    unparseseq(xw, &reply);

    if (screen->locator_reset) {
	MotionOff(screen, xw);
	screen->send_mouse_pos = MOUSE_OFF;
    }

    /*
     * DECterm turns the Locator off if a button is pressed while a filter
     * rectangle is active.  This might be a bug, but I don't know, so I'll
     * emulate it anyway.
     */
    if (screen->loc_filter) {
	screen->send_mouse_pos = MOUSE_OFF;
	screen->loc_filter = False;
	screen->locator_events = 0;
	MotionOff(screen, xw);
    }

    return (True);
}

/*
 * mask:
 * bit 7   bit 6   bit 5   bit 4   bit 3   bit 2       bit 1         bit 0
 *                                 M4 down left down   middle down   right down
 *
 * Button1 (left) and Button3 (right) are swapped in the mask relative to X.
 */
#define	ButtonState(state, mask)	\
{ int stemp = (int) (((mask) & (Button1Mask | Button2Mask | Button3Mask | Button4Mask)) >> 8);	\
  /* swap Button1 & Button3 */								\
  (state) = (stemp & ~(4|1)) | ((stemp & 1) ? 4 : 0) | ((stemp & 4) ? 1 : 0);			\
}

void
GetLocatorPosition(XtermWidget xw)
{
    ANSI reply;
    TScreen *screen = TScreenOf(xw);
    Window root, child;
    int rx, ry, x, y;
    unsigned int mask;
    int row = 0, col = 0;
    Bool oor = False;
    Bool ret = False;
    int state;

    /*
     * DECterm turns the Locator off if the position is requested while a
     * filter rectangle is active.  This might be a bug, but I don't know, so
     * I'll emulate it anyways.
     */
    if (screen->loc_filter) {
	screen->send_mouse_pos = MOUSE_OFF;
	screen->loc_filter = False;
	screen->locator_events = 0;
	MotionOff(screen, xw);
    }

    memset(&reply, 0, sizeof(reply));
    reply.a_type = ANSI_CSI;

    if (okSendMousePos(xw) == DEC_LOCATOR) {
	ret = XQueryPointer(screen->display, VWindow(screen), &root,
			    &child, &rx, &ry, &x, &y, &mask);
	if (ret) {
	    LocatorCoords(row, col, x, y, oor);
	}
    }
    if (ret == False || oor) {
	reply.a_nparam = 1;
	reply.a_param[0] = 0;	/* Event - 0 = locator unavailable */
	reply.a_inters = '&';
	reply.a_final = 'w';
	unparseseq(xw, &reply);

	if (screen->locator_reset) {
	    MotionOff(screen, xw);
	    screen->send_mouse_pos = MOUSE_OFF;
	}
	return;
    }

    ButtonState(state, mask);

    reply.a_nparam = 4;
    reply.a_param[0] = 1;	/* Event - 1 = response to locator request */
    reply.a_param[1] = (ParmType) state;
    reply.a_param[2] = (ParmType) row;
    reply.a_param[3] = (ParmType) col;
    reply.a_inters = '&';
    reply.a_final = 'w';
    unparseseq(xw, &reply);

    if (screen->locator_reset) {
	MotionOff(screen, xw);
	screen->send_mouse_pos = MOUSE_OFF;
    }
}

void
InitLocatorFilter(XtermWidget xw)
{
    ANSI reply;
    TScreen *screen = TScreenOf(xw);
    Window root, child;
    int rx, ry, x, y;
    unsigned int mask;
    int row = 0, col = 0;
    Bool oor = 0;
    Bool ret;

    ret = XQueryPointer(screen->display, VWindow(screen),
			&root, &child, &rx, &ry, &x, &y, &mask);
    if (ret) {
	LocatorCoords(row, col, x, y, oor);
    }
    if (ret == False || oor) {
	/* Locator is unavailable */

	if (screen->loc_filter_top != LOC_FILTER_POS ||
	    screen->loc_filter_left != LOC_FILTER_POS ||
	    screen->loc_filter_bottom != LOC_FILTER_POS ||
	    screen->loc_filter_right != LOC_FILTER_POS) {
	    /*
	     * If any explicit coordinates were received,
	     * report immediately with no coordinates.
	     */
	    memset(&reply, 0, sizeof(reply));
	    reply.a_type = ANSI_CSI;
	    reply.a_nparam = 1;
	    reply.a_param[0] = 0;	/* Event - 0 = locator unavailable */
	    reply.a_inters = '&';
	    reply.a_final = 'w';
	    unparseseq(xw, &reply);

	    if (screen->locator_reset) {
		MotionOff(screen, xw);
		screen->send_mouse_pos = MOUSE_OFF;
	    }
	} else {
	    /*
	     * No explicit coordinates were received, and the pointer is
	     * unavailable.  Report when the pointer re-enters the window.
	     */
	    screen->loc_filter = True;
	    MotionOn(screen, xw);
	}
	return;
    }

    /*
     * Adjust rectangle coordinates:
     *  1. Replace "LOC_FILTER_POS" with current coordinates
     *  2. Limit coordinates to screen size
     *  3. make sure top and left are less than bottom and right, resp.
     */
    if (screen->locator_pixels) {
	rx = OriginX(screen) * 2 + Width(screen);
	ry = screen->border * 2 + Height(screen);
    } else {
	rx = screen->max_col;
	ry = screen->max_row;
    }

#define	Adjust( coord, def, max )				\
	if( (coord) == LOC_FILTER_POS )	(coord) = (def);	\
	else if ((coord) < 1)		(coord) = 1;		\
	else if ((coord) > (max))	(coord) = (max)

    Adjust(screen->loc_filter_top, row, ry);
    Adjust(screen->loc_filter_left, col, rx);
    Adjust(screen->loc_filter_bottom, row, ry);
    Adjust(screen->loc_filter_right, col, rx);

    if (screen->loc_filter_top > screen->loc_filter_bottom) {
	ry = screen->loc_filter_top;
	screen->loc_filter_top = screen->loc_filter_bottom;
	screen->loc_filter_bottom = ry;
    }

    if (screen->loc_filter_left > screen->loc_filter_right) {
	rx = screen->loc_filter_left;
	screen->loc_filter_left = screen->loc_filter_right;
	screen->loc_filter_right = rx;
    }

    if ((col < screen->loc_filter_left) ||
	(col > screen->loc_filter_right) ||
	(row < screen->loc_filter_top) ||
	(row > screen->loc_filter_bottom)) {
	int state;

	/* Pointer is already outside the rectangle - report immediately */
	ButtonState(state, mask);

	memset(&reply, 0, sizeof(reply));
	reply.a_type = ANSI_CSI;
	reply.a_nparam = 4;
	reply.a_param[0] = 10;	/* Event - 10 = locator outside filter */
	reply.a_param[1] = (ParmType) state;
	reply.a_param[2] = (ParmType) row;
	reply.a_param[3] = (ParmType) col;
	reply.a_inters = '&';
	reply.a_final = 'w';
	unparseseq(xw, &reply);

	if (screen->locator_reset) {
	    MotionOff(screen, xw);
	    screen->send_mouse_pos = MOUSE_OFF;
	}
	return;
    }

    /*
     * Rectangle is set up.  Allow pointer tracking
     * to detect if the mouse leaves the rectangle.
     */
    screen->loc_filter = True;
    MotionOn(screen, xw);
}

static void
CheckLocatorPosition(XtermWidget xw, XButtonEvent *event)
{
    ANSI reply;
    TScreen *screen = TScreenOf(xw);
    int row, col;
    Bool oor;

    LocatorCoords(row, col, event->x, event->y, oor);

    /*
     * Send report if the pointer left the filter rectangle, if
     * the pointer left the window, or if the filter rectangle
     * had no coordinates and the pointer re-entered the window.
     */
    if (oor || (screen->loc_filter_top == LOC_FILTER_POS) ||
	(col < screen->loc_filter_left) ||
	(col > screen->loc_filter_right) ||
	(row < screen->loc_filter_top) ||
	(row > screen->loc_filter_bottom)) {
	/* Filter triggered - disable it */
	screen->loc_filter = False;
	MotionOff(screen, xw);

	memset(&reply, 0, sizeof(reply));
	reply.a_type = ANSI_CSI;
	if (oor) {
	    reply.a_nparam = 1;
	    reply.a_param[0] = 0;	/* Event - 0 = locator unavailable */
	} else {
	    int state;

	    ButtonState(state, event->state);

	    reply.a_nparam = 4;
	    reply.a_param[0] = 10;	/* Event - 10 = locator outside filter */
	    reply.a_param[1] = (ParmType) state;
	    reply.a_param[2] = (ParmType) row;
	    reply.a_param[3] = (ParmType) col;
	}

	reply.a_inters = '&';
	reply.a_final = 'w';
	unparseseq(xw, &reply);

	if (screen->locator_reset) {
	    MotionOff(screen, xw);
	    screen->send_mouse_pos = MOUSE_OFF;
	}
    }
}
#endif /* OPT_DEC_LOCATOR */

#if OPT_READLINE
static int
isClick1_clean(XtermWidget xw, XButtonEvent *event)
{
    TScreen *screen = TScreenOf(xw);
    int delta;

    if (!IsBtnEvent(event)
    /* Disable on Shift-Click-1, including the application-mouse modes */
	|| (BtnModifiers(event) & ShiftMask)
	|| (okSendMousePos(xw) != MOUSE_OFF)	/* Kinda duplicate... */
	||ExtendingSelection)	/* Was moved */
	return 0;

    if (event->type != ButtonRelease)
	return 0;

    if (lastButtonDownTime == (Time) 0) {
	/* first time or once in a blue moon */
	delta = screen->multiClickTime + 1;
    } else if (event->time > lastButtonDownTime) {
	/* most of the time */
	delta = (int) (event->time - lastButtonDownTime);
    } else {
	/* time has rolled over since lastButtonUpTime */
	delta = (int) ((((Time) ~ 0) - lastButtonDownTime) + event->time);
    }

    return delta <= screen->multiClickTime;
}

static int
isDoubleClick3(TScreen *screen, XButtonEvent *event)
{
    int delta;

    if (event->type != ButtonRelease
	|| (BtnModifiers(event) & ShiftMask)
	|| event->button != Button3) {
	lastButton3UpTime = 0;	/* Disable the cached info */
	return 0;
    }
    /* Process Btn3Release. */
    if (lastButton3DoubleDownTime == (Time) 0) {
	/* No previous click or once in a blue moon */
	delta = screen->multiClickTime + 1;
    } else if (event->time > lastButton3DoubleDownTime) {
	/* most of the time */
	delta = (int) (event->time - lastButton3DoubleDownTime);
    } else {
	/* time has rolled over since lastButton3DoubleDownTime */
	delta = (int) ((((Time) ~ 0) - lastButton3DoubleDownTime) + event->time);
    }
    if (delta <= screen->multiClickTime) {
	/* Double click */
	CELL cell;

	/* Cannot check ExtendingSelection, since mouse-3 always sets it */
	PointToCELL(screen, event->y, event->x, &cell);
	if (isSameCELL(&cell, &lastButton3)) {
	    lastButton3DoubleDownTime = 0;	/* Disable the third click */
	    return 1;
	}
    }
    /* Not a double click, memorize for future check. */
    lastButton3UpTime = event->time;
    PointToCELL(screen, event->y, event->x, &lastButton3);
    return 0;
}

static int
CheckSecondPress3(TScreen *screen, XEvent *event)
{
    int delta;

    if (event->type != ButtonPress
	|| (KeyModifiers(event) & ShiftMask)
	|| event->xbutton.button != Button3) {
	lastButton3DoubleDownTime = 0;	/* Disable the cached info */
	return 0;
    }
    /* Process Btn3Press. */
    if (lastButton3UpTime == (Time) 0) {
	/* No previous click or once in a blue moon */
	delta = screen->multiClickTime + 1;
    } else if (event->xbutton.time > lastButton3UpTime) {
	/* most of the time */
	delta = (int) (event->xbutton.time - lastButton3UpTime);
    } else {
	/* time has rolled over since lastButton3UpTime */
	delta = (int) ((((Time) ~ 0) - lastButton3UpTime) + event->xbutton.time);
    }
    if (delta <= screen->multiClickTime) {
	CELL cell;

	PointToCELL(screen, event->xbutton.y, event->xbutton.x, &cell);
	if (isSameCELL(&cell, &lastButton3)) {
	    /* A candidate for a double-click */
	    lastButton3DoubleDownTime = event->xbutton.time;
	    PointToCELL(screen, event->xbutton.y, event->xbutton.x, &lastButton3);
	    return 1;
	}
	lastButton3UpTime = 0;	/* Disable the info about the previous click */
    }
    /* Either too long, or moved, disable. */
    lastButton3DoubleDownTime = 0;
    return 0;
}

static int
rowOnCurrentLine(TScreen *screen,
		 int line,
		 int *deltap)	/* must be XButtonEvent */
{
    int result = 1;

    *deltap = 0;

    if (line != screen->cur_row) {
	int l1, l2;

	if (line < screen->cur_row)
	    l1 = line, l2 = screen->cur_row;
	else
	    l2 = line, l1 = screen->cur_row;
	l1--;
	while (++l1 < l2) {
	    LineData *ld = GET_LINEDATA(screen, l1);
	    if (!LineTstWrapped(ld)) {
		result = 0;
		break;
	    }
	}
	if (result) {
	    /* Everything is on one "wrapped line" now */
	    *deltap = line - screen->cur_row;
	}
    }
    return result;
}

static int
eventRow(TScreen *screen, XEvent *event)	/* must be XButtonEvent */
{
    return (event->xbutton.y - screen->border) / FontHeight(screen);
}

static int
eventColBetween(TScreen *screen, XEvent *event)		/* must be XButtonEvent */
{
    /* Correct by half a width - we are acting on a boundary, not on a cell. */
    return ((event->xbutton.x - OriginX(screen) + (FontWidth(screen) - 1) / 2)
	    / FontWidth(screen));
}

static int
ReadLineMovePoint(TScreen *screen, int col, int ldelta)
{
    Char line[6];
    unsigned count = 0;

    col += ldelta * MaxCols(screen) - screen->cur_col;
    if (col == 0)
	return 0;
    if (screen->control_eight_bits) {
	line[count++] = ANSI_CSI;
    } else {
	line[count++] = ANSI_ESC;
	line[count++] = '[';	/* XXX maybe sometimes O is better? */
    }
    line[count] = CharOf(col > 0 ? 'C' : 'D');
    if (col < 0)
	col = -col;
    while (col--)
	v_write(screen->respond, line, 3);
    return 1;
}

static int
ReadLineDelete(TScreen *screen, CELL *cell1, CELL *cell2)
{
    int del;

    del = (cell2->col - cell1->col) + ((cell2->row - cell1->row) * MaxCols(screen));
    if (del <= 0)		/* Just in case... */
	return 0;
    while (del--)
	v_write(screen->respond, (const Char *) "\177", 1);
    return 1;
}

static void
readlineExtend(XtermWidget xw, XEvent *event)
{
    TScreen *screen = TScreenOf(xw);
    int ldelta1, ldelta2;

    if (IsBtnEvent(event)) {
	XButtonEvent *my_event = (XButtonEvent *) event;
	if (isClick1_clean(xw, my_event)
	    && SCREEN_FLAG(screen, click1_moves)
	    && rowOnCurrentLine(screen, eventRow(screen, event), &ldelta1)) {
	    ReadLineMovePoint(screen, eventColBetween(screen, event), ldelta1);
	}
	if (isDoubleClick3(screen, my_event)
	    && SCREEN_FLAG(screen, dclick3_deletes)
	    && rowOnCurrentLine(screen, screen->startSel.row, &ldelta1)
	    && rowOnCurrentLine(screen, screen->endSel.row, &ldelta2)) {
	    ReadLineMovePoint(screen, screen->endSel.col, ldelta2);
	    ReadLineDelete(screen, &screen->startSel, &(screen->endSel));
	}
    }
}

#endif /* OPT_READLINE */

/* ^XM-G */
void
DiredButton(Widget w,
	    XEvent *event,	/* must be XButtonEvent */
	    String *params GCC_UNUSED,	/* selections */
	    Cardinal *num_params GCC_UNUSED)
{
    XtermWidget xw;

    if ((xw = getXtermWidget(w)) != 0) {
	TScreen *screen = TScreenOf(xw);

	if (IsBtnEvent(event)
	    && (event->xbutton.y >= screen->border)
	    && (event->xbutton.x >= OriginX(screen))) {
	    Char Line[6];
	    unsigned line, col;

	    line = (unsigned) ((event->xbutton.y - screen->border)
			       / FontHeight(screen));
	    col = (unsigned) ((event->xbutton.x - OriginX(screen))
			      / FontWidth(screen));
	    Line[0] = CONTROL('X');
	    Line[1] = ANSI_ESC;
	    Line[2] = 'G';
	    Line[3] = CharOf(' ' + col);
	    Line[4] = CharOf(' ' + line);
	    v_write(screen->respond, Line, 5);
	}
    }
}

#if OPT_READLINE
void
ReadLineButton(Widget w,
	       XEvent *event,	/* must be XButtonEvent */
	       String *params GCC_UNUSED,	/* selections */
	       Cardinal *num_params GCC_UNUSED)
{
    XtermWidget xw;

    if ((xw = getXtermWidget(w)) != 0) {
	TScreen *screen = TScreenOf(xw);
	Char Line[6];
	int line, col, ldelta = 0;

	if (!IsBtnEvent(event)
	    || (okSendMousePos(xw) != MOUSE_OFF) || ExtendingSelection)
	    goto finish;
	if (event->type == ButtonRelease) {
	    int delta;

	    if (lastButtonDownTime == (Time) 0) {
		/* first time and once in a blue moon */
		delta = screen->multiClickTime + 1;
	    } else if (event->xbutton.time > lastButtonDownTime) {
		/* most of the time */
		delta = (int) (event->xbutton.time - lastButtonDownTime);
	    } else {
		/* time has rolled over since lastButtonUpTime */
		delta = (int) ((((Time) ~ 0) - lastButtonDownTime) + event->xbutton.time);
	    }
	    if (delta > screen->multiClickTime)
		goto finish;	/* All this work for this... */
	}
	line = (event->xbutton.y - screen->border) / FontHeight(screen);
	if (!rowOnCurrentLine(screen, line, &ldelta))
	    goto finish;
	/* Correct by half a width - we are acting on a boundary, not on a cell. */
	col = (event->xbutton.x - OriginX(screen) + (FontWidth(screen) - 1)
	       / 2)
	    / FontWidth(screen) - screen->cur_col + ldelta * MaxCols(screen);
	if (col == 0)
	    goto finish;
	Line[0] = ANSI_ESC;
	/* XXX: sometimes it is better to send '['? */
	Line[1] = 'O';
	Line[2] = CharOf(col > 0 ? 'C' : 'D');
	if (col < 0)
	    col = -col;
	while (col--)
	    v_write(screen->respond, Line, 3);
      finish:
	if (event->type == ButtonRelease)
	    do_select_end(xw, event, params, num_params, False);
    }
}
#endif /* OPT_READLINE */

/* repeats n or p */
void
ViButton(Widget w,
	 XEvent *event,		/* must be XButtonEvent */
	 String *params GCC_UNUSED,	/* selections */
	 Cardinal *num_params GCC_UNUSED)
{
    XtermWidget xw;

    if ((xw = getXtermWidget(w)) != 0) {
	TScreen *screen = TScreenOf(xw);
	int pty = screen->respond;

	if (IsBtnEvent(event)) {
	    int line;

	    line = screen->cur_row -
		((event->xbutton.y - screen->border) / FontHeight(screen));

	    if (line != 0) {
		Char Line[6];

		Line[0] = ANSI_ESC;	/* force an exit from insert-mode */
		v_write(pty, Line, 1);

		if (line < 0) {
		    line = -line;
		    Line[0] = CONTROL('n');
		} else {
		    Line[0] = CONTROL('p');
		}
		while (--line >= 0)
		    v_write(pty, Line, 1);
	    }
	}
    }
}

/*
 * This function handles button-motion events
 */
/*ARGSUSED*/
void
HandleSelectExtend(Widget w,
		   XEvent *event,	/* must be XMotionEvent */
		   String *params GCC_UNUSED,
		   Cardinal *num_params GCC_UNUSED)
{
    XtermWidget xw;

    if ((xw = getXtermWidget(w)) != 0) {
	TScreen *screen = TScreenOf(xw);
	CELL cell;

	TRACE(("HandleSelectExtend @%ld\n", event->xmotion.time));

	screen->selection_time = event->xmotion.time;
	switch (screen->eventMode) {
	    /* If not in one of the DEC mouse-reporting modes */
	case LEFTEXTENSION:
	case RIGHTEXTENSION:
	    PointToCELL(screen, event->xmotion.y, event->xmotion.x, &cell);
	    ExtendExtend(xw, &cell);
	    break;

	    /* If in motion reporting mode, send mouse position to
	       character process as a key sequence \E[M... */
	case NORMAL:
	    /* will get here if send_mouse_pos != MOUSE_OFF */
	    if (okSendMousePos(xw) == BTN_EVENT_MOUSE
		|| okSendMousePos(xw) == ANY_EVENT_MOUSE) {
		(void) SendMousePosition(xw, event);
	    }
	    break;
	}
    }
}

void
HandleKeyboardSelectExtend(Widget w,
			   XEvent *event GCC_UNUSED,	/* must be XButtonEvent */
			   String *params GCC_UNUSED,
			   Cardinal *num_params GCC_UNUSED)
{
    XtermWidget xw;

    if ((xw = getXtermWidget(w)) != 0) {
	TScreen *screen = TScreenOf(xw);

	TRACE(("HandleKeyboardSelectExtend\n"));
	ExtendExtend(xw, &screen->cursorp);
    }
}

static void
do_select_end(XtermWidget xw,
	      XEvent *event,	/* must be XButtonEvent */
	      String *params,	/* selections */
	      Cardinal *num_params,
	      Bool use_cursor_loc)
{
    TScreen *screen = TScreenOf(xw);

    screen->selection_time = event->xbutton.time;
    TRACE(("do_select_end @%ld\n", screen->selection_time));
    switch (screen->eventMode) {
    case NORMAL:
	(void) SendMousePosition(xw, event);
	break;
    case LEFTEXTENSION:
    case RIGHTEXTENSION:
	EndExtend(xw, event, params, *num_params, use_cursor_loc);
#if OPT_READLINE
	readlineExtend(xw, event);
#endif /* OPT_READLINE */
	break;
    }
}

void
HandleSelectEnd(Widget w,
		XEvent *event,	/* must be XButtonEvent */
		String *params,	/* selections */
		Cardinal *num_params)
{
    XtermWidget xw;

    if ((xw = getXtermWidget(w)) != 0) {
	TRACE(("HandleSelectEnd\n"));
	do_select_end(xw, event, params, num_params, False);
    }
}

void
HandleKeyboardSelectEnd(Widget w,
			XEvent *event,	/* must be XButtonEvent */
			String *params,		/* selections */
			Cardinal *num_params)
{
    XtermWidget xw;

    if ((xw = getXtermWidget(w)) != 0) {
	TRACE(("HandleKeyboardSelectEnd\n"));
	do_select_end(xw, event, params, num_params, True);
    }
}

/*
 * Copy the selection data to the given target(s).
 */
void
HandleCopySelection(Widget w,
		    XEvent *event,
		    String *params,	/* list of targets */
		    Cardinal *num_params)
{
    XtermWidget xw;

    if ((xw = getXtermWidget(w)) != 0) {
	TRACE(("HandleCopySelection\n"));
	SelectSet(xw, event, params, *num_params);
    }
}

struct _SelectionList {
    String *params;
    Cardinal count;
    Atom *targets;
    Time time;
};

static unsigned
DECtoASCII(unsigned ch)
{
    if (xtermIsDecGraphic(ch)) {
	ch = CharOf("###########+++++##-##++++|######"[ch]);
	/*           01234567890123456789012345678901 */
    }
    return ch;
}

#if OPT_WIDE_CHARS
static Cardinal
addXtermChar(Char **buffer, Cardinal *used, Cardinal offset, unsigned value)
{
    if (offset + 1 >= *used) {
	*used = 1 + (2 * (offset + 1));
	allocXtermChars(buffer, *used);
    }
    (*buffer)[offset++] = (Char) value;
    return offset;
}
#define AddChar(buffer, used, offset, value) \
	offset = addXtermChar(buffer, used, offset, (unsigned) value)

/*
 * Convert a UTF-8 string to Latin-1, replacing non Latin-1 characters by `#',
 * or ASCII/Latin-1 equivalents for special cases.
 */
static Char *
UTF8toLatin1(TScreen *screen, Char *s, unsigned long len, unsigned long *result)
{
    static Char *buffer;
    static Cardinal used;

    Cardinal offset = 0;

    if (len != 0) {
	PtyData data;

	fakePtyData(&data, s, s + len);
	while (decodeUtf8(screen, &data)) {
	    Bool fails = False;
	    Bool extra = False;
	    IChar value = skipPtyData(&data);
	    if (value == UCS_REPL) {
		fails = True;
	    } else if (value < 256) {
		AddChar(&buffer, &used, offset, CharOf(value));
	    } else {
		unsigned eqv = ucs2dec(value);
		if (xtermIsDecGraphic(eqv)) {
		    AddChar(&buffer, &used, offset, DECtoASCII(eqv));
		} else {
		    eqv = AsciiEquivs(value);
		    if (eqv == value) {
			fails = True;
		    } else {
			AddChar(&buffer, &used, offset, eqv);
		    }
		    if (isWide((wchar_t) value))
			extra = True;
		}
	    }

	    /*
	     * If we're not able to plug in a single-byte result, insert the
	     * defaultString (which normally is a single "#", but could be
	     * whatever the user wants).
	     */
	    if (fails) {
		const Char *p;

		for (p = (const Char *) screen->default_string; *p != '\0'; ++p) {
		    AddChar(&buffer, &used, offset, *p);
		}
	    }
	    if (extra)
		AddChar(&buffer, &used, offset, ' ');
	}
	AddChar(&buffer, &used, offset, '\0');
	*result = (unsigned long) (offset - 1);
    } else {
	*result = 0;
    }
    return buffer;
}

int
xtermUtf8ToTextList(XtermWidget xw,
		    XTextProperty * text_prop,
		    char ***text_list,
		    int *text_list_count)
{
    TScreen *screen = TScreenOf(xw);
    Display *dpy = screen->display;
    int rc = -1;

    if (text_prop->format == 8
	&& (rc = Xutf8TextPropertyToTextList(dpy, text_prop,
					     text_list,
					     text_list_count)) >= 0) {
	if (*text_list != NULL && *text_list_count != 0) {
	    int i;
	    Char *data;
	    char **new_text_list, *tmp;
	    unsigned long size, new_size;

	    TRACE(("xtermUtf8ToTextList size %d\n", *text_list_count));

	    /*
	     * XLib StringList actually uses only two pointers, one for the
	     * list itself, and one for the data.  Pointer to the data is the
	     * first element of the list, the rest (if any) list elements point
	     * to the same memory block as the first element
	     */
	    new_size = 0;
	    for (i = 0; i < *text_list_count; ++i) {
		data = (Char *) (*text_list)[i];
		size = strlen((*text_list)[i]) + 1;
		(void) UTF8toLatin1(screen, data, size, &size);
		new_size += size + 1;
	    }
	    new_text_list = TypeXtMallocN(char *, *text_list_count);
	    new_text_list[0] = tmp = XtMalloc((Cardinal) new_size);
	    for (i = 0; i < (*text_list_count); ++i) {
		data = (Char *) (*text_list)[i];
		size = strlen((*text_list)[i]) + 1;
		if ((data = UTF8toLatin1(screen, data, size, &size)) != 0) {
		    memcpy(tmp, data, size + 1);
		    new_text_list[i] = tmp;
		    tmp += size + 1;
		}
	    }
	    XFreeStringList((*text_list));
	    *text_list = new_text_list;
	} else {
	    rc = -1;
	}
    }
    return rc;
}
#endif /* OPT_WIDE_CHARS */

static char *
parseItem(char *value, char *nextc)
{
    char *nextp = value;
    while (*nextp != '\0' && *nextp != ',') {
	*nextp = x_toupper(*nextp);
	++nextp;
    }
    *nextc = *nextp;
    *nextp = '\0';

    return nextp;
}

/*
 * All of the wanted strings are unique in the first character, so we can
 * use simple abbreviations.
 */
static Bool
sameItem(const char *actual, const char *wanted)
{
    Bool result = False;
    size_t have = strlen(actual);
    size_t need = strlen(wanted);

    if (have != 0 && have <= need) {
	if (!strncmp(actual, wanted, have)) {
	    TRACE(("...matched \"%s\"\n", wanted));
	    result = True;
	}
    }

    return result;
}

/*
 * Handle the eightBitSelectTypes or utf8SelectTypes resource values.
 */
static Bool
overrideTargets(Widget w, String value, Atom **resultp)
{
    Bool override = False;
    XtermWidget xw;

    if ((xw = getXtermWidget(w)) != 0) {
	TScreen *screen = TScreenOf(xw);

	if (!IsEmpty(value)) {
	    char *copied = x_strdup(value);
	    if (copied != 0) {
		Atom *result = 0;
		Cardinal count = 1;
		int n;

		TRACE(("decoding SelectTypes \"%s\"\n", value));
		for (n = 0; copied[n] != '\0'; ++n) {
		    if (copied[n] == ',')
			++count;
		}
		result = TypeXtMallocN(Atom, (2 * count) + 1);
		if (result == NULL) {
		    TRACE(("Couldn't allocate selection types\n"));
		} else {
		    char nextc = '?';
		    char *listp = (char *) copied;
		    count = 0;
		    do {
			char *nextp = parseItem(listp, &nextc);
			char *item = x_strtrim(listp);
			size_t len = (item ? strlen(item) : 0);

			if (len == 0) {
			    /* EMPTY */ ;
			}
#if OPT_WIDE_CHARS
			else if (sameItem(item, "UTF8")) {
			    result[count++] = XA_UTF8_STRING(XtDisplay(w));
			}
#endif
			else if (sameItem(item, "I18N")) {
			    if (screen->i18nSelections) {
				result[count++] = XA_TEXT(XtDisplay(w));
				result[count++] = XA_COMPOUND_TEXT(XtDisplay(w));
			    }
			} else if (sameItem(item, "TEXT")) {
			    result[count++] = XA_TEXT(XtDisplay(w));
			} else if (sameItem(item, "COMPOUND_TEXT")) {
			    result[count++] = XA_COMPOUND_TEXT(XtDisplay(w));
			} else if (sameItem(item, "STRING")) {
			    result[count++] = XA_STRING;
			}
			*nextp++ = nextc;
			listp = nextp;
			free(item);
		    } while (nextc != '\0');
		    if (count) {
			result[count] = None;
			override = True;
			*resultp = result;
		    } else {
			XtFree((char *) result);
		    }
		}
		free(copied);
	    } else {
		TRACE(("Couldn't allocate copy of selection types\n"));
	    }
	}
    }
    return override;
}

#if OPT_WIDE_CHARS
static Atom *
allocUtf8Targets(Widget w, TScreen *screen)
{
    Atom **resultp = &(screen->selection_targets_utf8);

    if (*resultp == 0) {
	Atom *result;

	if (!overrideTargets(w, screen->utf8_select_types, &result)) {
	    result = TypeXtMallocN(Atom, 5);
	    if (result == NULL) {
		TRACE(("Couldn't allocate utf-8 selection targets\n"));
	    } else {
		int n = 0;

		if (XSupportsLocale()) {
		    result[n++] = XA_UTF8_STRING(XtDisplay(w));
#ifdef X_HAVE_UTF8_STRING
		    if (screen->i18nSelections) {
			result[n++] = XA_TEXT(XtDisplay(w));
			result[n++] = XA_COMPOUND_TEXT(XtDisplay(w));
		    }
#endif
		}
		result[n++] = XA_STRING;
		result[n] = None;
	    }
	}

	*resultp = result;
    }

    return *resultp;
}
#endif

static Atom *
alloc8bitTargets(Widget w, TScreen *screen)
{
    Atom **resultp = &(screen->selection_targets_8bit);

    if (*resultp == 0) {
	Atom *result = 0;

	if (!overrideTargets(w, screen->eightbit_select_types, &result)) {
	    result = TypeXtMallocN(Atom, 5);
	    if (result == NULL) {
		TRACE(("Couldn't allocate 8bit selection targets\n"));
	    } else {
		int n = 0;

		if (XSupportsLocale()) {
#ifdef X_HAVE_UTF8_STRING
		    result[n++] = XA_UTF8_STRING(XtDisplay(w));
#endif
		    if (screen->i18nSelections) {
			result[n++] = XA_TEXT(XtDisplay(w));
			result[n++] = XA_COMPOUND_TEXT(XtDisplay(w));
		    }
		}
		result[n++] = XA_STRING;
		result[n] = None;
	    }
	}

	*resultp = result;
    }

    return *resultp;
}

static Atom *
_SelectionTargets(Widget w)
{
    Atom *result;
    XtermWidget xw;

    if ((xw = getXtermWidget(w)) == 0) {
	result = NULL;
    } else {
	TScreen *screen = TScreenOf(xw);

#if OPT_WIDE_CHARS
	if (screen->wide_chars) {
	    result = allocUtf8Targets(w, screen);
	} else
#endif
	{
	    /* not screen->wide_chars */
	    result = alloc8bitTargets(w, screen);
	}
    }

    return result;
}

#define isSELECT(value) (!strcmp(value, "SELECT"))

static void
UnmapSelections(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);
    Cardinal n;

    if (screen->mappedSelect) {
	for (n = 0; screen->mappedSelect[n] != 0; ++n)
	    free((void *) screen->mappedSelect[n]);
	free(screen->mappedSelect);
	screen->mappedSelect = 0;
    }
}

/*
 * xterm generally uses the primary selection.  Some applications prefer
 * (or are limited to) the clipboard.  Since the translations resource is
 * complicated, users seldom change the way it affects selection.  But it
 * is simple to remap the choice between primary and clipboard before the
 * call to XmuInternStrings().
 */
static String *
MapSelections(XtermWidget xw, String *params, Cardinal num_params)
{
    String *result = params;

    if (params != 0 && num_params > 0) {
	Cardinal j;
	Boolean map = False;

	for (j = 0; j < num_params; ++j) {
	    TRACE(("param[%d]:%s\n", j, params[j]));
	    if (isSELECT(params[j])) {
		map = True;
		break;
	    }
	}
	if (map) {
	    TScreen *screen = TScreenOf(xw);
	    const char *mapTo = (screen->selectToClipboard
				 ? "CLIPBOARD"
				 : "PRIMARY");

	    UnmapSelections(xw);
	    if ((result = TypeMallocN(String, num_params + 1)) != 0) {
		result[num_params] = 0;
		for (j = 0; j < num_params; ++j) {
		    result[j] = x_strdup((isSELECT(params[j])
					  ? mapTo
					  : params[j]));
		    if (result[j] == 0) {
			UnmapSelections(xw);
			while (j != 0) {
			    free((void *) result[--j]);
			}
			free(result);
			result = 0;
			break;
		    }
		}
		screen->mappedSelect = result;
	    }
	}
    }
    return result;
}

/*
 * Lookup the cut-buffer number, which will be in the range 0-7.
 * If it is not a cut-buffer, it is the primary selection (-1).
 */
static int
CutBuffer(Atom code)
{
    int cutbuffer;
    switch ((unsigned) code) {
    case XA_CUT_BUFFER0:
	cutbuffer = 0;
	break;
    case XA_CUT_BUFFER1:
	cutbuffer = 1;
	break;
    case XA_CUT_BUFFER2:
	cutbuffer = 2;
	break;
    case XA_CUT_BUFFER3:
	cutbuffer = 3;
	break;
    case XA_CUT_BUFFER4:
	cutbuffer = 4;
	break;
    case XA_CUT_BUFFER5:
	cutbuffer = 5;
	break;
    case XA_CUT_BUFFER6:
	cutbuffer = 6;
	break;
    case XA_CUT_BUFFER7:
	cutbuffer = 7;
	break;
    default:
	cutbuffer = -1;
	break;
    }
    TRACE(("CutBuffer(%d) = %d\n", (int) code, cutbuffer));
    return cutbuffer;
}

#if OPT_PASTE64
static void
FinishPaste64(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);

    TRACE(("FinishPaste64(%d)\n", screen->base64_paste));
    if (screen->base64_paste) {
	screen->base64_paste = 0;
	unparseputc1(xw, screen->base64_final);
	unparse_end(xw);
    }
}
#endif

#if !OPT_PASTE64
static
#endif
void
xtermGetSelection(Widget w,
		  Time ev_time,
		  String *params,	/* selections in precedence order */
		  Cardinal num_params,
		  Atom *targets)
{
    Atom selection;
    int cutbuffer;
    Atom target;

    XtermWidget xw;

    if (num_params == 0)
	return;
    if ((xw = getXtermWidget(w)) == 0)
	return;

    TRACE(("xtermGetSelection num_params %d @%ld\n", num_params, ev_time));
    params = MapSelections(xw, params, num_params);

    XmuInternStrings(XtDisplay(w), params, (Cardinal) 1, &selection);
    cutbuffer = CutBuffer(selection);

    TRACE(("Cutbuffer: %d, target: %s\n", cutbuffer,
	   (targets
	    ? visibleSelectionTarget(XtDisplay(w), targets[0])
	    : "None")));

    if (cutbuffer >= 0) {
	int inbytes;
	unsigned long nbytes;
	int fmt8 = 8;
	Atom type = XA_STRING;
	char *line;

	/* 'line' is freed in SelectionReceived */
	line = XFetchBuffer(XtDisplay(w), &inbytes, cutbuffer);
	nbytes = (unsigned long) inbytes;

	if (nbytes > 0) {
	    SelectionReceived(w, NULL, &selection, &type, (XtPointer) line,
			      &nbytes, &fmt8);
	} else if (num_params > 1) {
	    xtermGetSelection(w, ev_time, params + 1, num_params - 1, NULL);
	}
#if OPT_PASTE64
	else {
	    FinishPaste64(xw);
	}
#endif
    } else {

	if (targets == NULL || targets[0] == None) {
	    targets = _SelectionTargets(w);
	}

	if (targets != 0) {
	    struct _SelectionList *list;

	    target = targets[0];

	    if (targets[1] == None) {	/* last target in list */
		params++;
		num_params--;
		targets = _SelectionTargets(w);
	    } else {
		targets = &(targets[1]);
	    }

	    if (num_params) {
		/* 'list' is freed in SelectionReceived */
		list = TypeXtMalloc(struct _SelectionList);
		if (list != 0) {
		    list->params = params;
		    list->count = num_params;
		    list->targets = targets;
		    list->time = ev_time;
		}
	    } else {
		list = NULL;
	    }

	    XtGetSelectionValue(w, selection,
				target,
				SelectionReceived,
				(XtPointer) list, ev_time);
	}
    }
}

#if OPT_TRACE && OPT_WIDE_CHARS
static void
GettingSelection(Display *dpy, Atom type, Char *line, unsigned long len)
{
    Char *cp;
    const char *name = TraceAtomName(dpy, type);

    TRACE(("Getting %s (type=%ld, length=%ld)\n", name, (long int) type, len));
    for (cp = line; cp < line + len; cp++) {
	TRACE(("[%d:%lu]", (int) (cp + 1 - line), len));
	if (isprint(*cp)) {
	    TRACE(("%c\n", *cp));
	} else {
	    TRACE(("\\x%02x\n", *cp));
	}
    }
}
#else
#define GettingSelection(dpy,type,line,len)	/* nothing */
#endif

#ifdef VMS
#  define tty_vwrite(pty,lag,l)		tt_write(lag,l)
#else /* !( VMS ) */
#  define tty_vwrite(pty,lag,l)		v_write(pty,lag,l)
#endif /* defined VMS */

#if OPT_PASTE64
/* Return base64 code character given 6-bit number */
static const char base64_code[] = "\
ABCDEFGHIJKLMNOPQRSTUVWXYZ\
abcdefghijklmnopqrstuvwxyz\
0123456789+/";
static void
base64_flush(TScreen *screen)
{
    Char x;

    TRACE(("base64_flush count %d, pad %d (%d)\n",
	   screen->base64_count,
	   screen->base64_pad,
	   screen->base64_pad & 3));

    switch (screen->base64_count) {
    case 0:
	break;
    case 2:
	x = CharOf(base64_code[screen->base64_accu << 4]);
	tty_vwrite(screen->respond, &x, 1);
	break;
    case 4:
	x = CharOf(base64_code[screen->base64_accu << 2]);
	tty_vwrite(screen->respond, &x, 1);
	break;
    }
    if (screen->base64_pad & 3) {
	tty_vwrite(screen->respond,
		   (const Char *) "===",
		   (unsigned) (3 - (screen->base64_pad & 3)));
    }
    screen->base64_count = 0;
    screen->base64_accu = 0;
    screen->base64_pad = 0;
}
#endif /* OPT_PASTE64 */

/*
 * Translate ISO-8859-1 or UTF-8 data to NRCS.
 */
static void
ToNational(TScreen *screen, Char *buffer, unsigned *length)
{
    int gsetL = screen->gsets[screen->curgl];
    int gsetR = screen->gsets[screen->curgr];

#if OPT_WIDE_CHARS
    if ((screen->utf8_nrc_mode | screen->utf8_mode) != uFalse) {
	Char *p;
	PtyData *data = TypeXtMallocX(PtyData, *length);

	memset(data, 0, sizeof(*data));
	data->next = data->buffer;
	data->last = data->buffer + *length;
	memcpy(data->buffer, buffer, (size_t) *length);
	p = buffer;
	while (data->next < data->last) {
	    unsigned chr, out, gl, gr;

	    if (!decodeUtf8(screen, data)) {
		data->utf_size = 1;
		data->utf_data = data->next[0];
	    }
	    data->next += data->utf_size;
	    chr = data->utf_data;
	    out = chr;
	    if ((gl = xtermCharSetIn(screen, chr, gsetL)) != chr) {
		out = gl;
	    } else if ((gr = xtermCharSetIn(screen, chr, gsetR)) != chr) {
		out = gr;
	    }
	    *p++ = (Char) ((out < 256) ? out : ' ');
	}
	*length = (unsigned) (p - buffer);
	free(data);
    } else
#endif
    {
	Char *p;

	for (p = buffer; (int) (p - buffer) < (int) *length; ++p) {
	    unsigned gl, gr;
	    unsigned chr = *p;
	    unsigned out = chr;
	    if ((gl = xtermCharSetIn(screen, chr, gsetL)) != chr) {
		out = gl;
	    } else if ((gr = xtermCharSetIn(screen, chr, gsetR)) != chr) {
		out = gr;
	    }
	    *p = (Char) out;
	}
    }
}

static void
_qWriteSelectionData(XtermWidget xw, Char *lag, unsigned length)
{
    TScreen *screen = TScreenOf(xw);

    /*
     * If we are pasting into a window which is using NRCS, we want to map
     * the text from the normal encoding (ISO-8859-1 or UTF-8) into the coding
     * that an application would use to write characters with NRCS.
     *
     * TODO: handle conversion from UTF-8, and adjust length.  This can be done
     * in the same buffer because the target is always 8-bit.
     */
    if ((xw->flags & NATIONAL) && (length != 0)) {
	ToNational(screen, lag, &length);
    }
#if OPT_PASTE64
    if (screen->base64_paste) {
	/* Send data as base64 */
	Char *p = lag;
	Char buf[64];
	unsigned x = 0;

	TRACE(("convert to base64 %d:%s\n", length, visibleChars(p, length)));

	/*
	 * Handle the case where the selection is from _this_ xterm, which
	 * puts part of the reply in the buffer before the selection callback
	 * happens.
	 */
	if (screen->base64_paste && screen->unparse_len) {
	    unparse_end(xw);
	}
	while (length--) {
	    switch (screen->base64_count) {
	    case 0:
		buf[x++] = CharOf(base64_code[*p >> 2]);
		screen->base64_accu = (unsigned) (*p & 0x3);
		screen->base64_count = 2;
		++p;
		break;
	    case 2:
		buf[x++] = CharOf(base64_code[(screen->base64_accu << 4) +
					      (*p >> 4)]);
		screen->base64_accu = (unsigned) (*p & 0xF);
		screen->base64_count = 4;
		++p;
		break;
	    case 4:
		buf[x++] = CharOf(base64_code[(screen->base64_accu << 2) +
					      (*p >> 6)]);
		buf[x++] = CharOf(base64_code[*p & 0x3F]);
		screen->base64_accu = 0;
		screen->base64_count = 0;
		++p;
		break;
	    }
	    if (x >= 63) {
		/* Write 63 or 64 characters */
		screen->base64_pad += x;
		TRACE(("writing base64 interim %s\n", visibleChars(buf, x)));
		tty_vwrite(screen->respond, buf, x);
		x = 0;
	    }
	}
	if (x != 0) {
	    screen->base64_pad += x;
	    TRACE(("writing base64 finish %s\n", visibleChars(buf, x)));
	    tty_vwrite(screen->respond, buf, x);
	}
    } else
#endif /* OPT_PASTE64 */
#if OPT_READLINE
    if (SCREEN_FLAG(screen, paste_quotes)) {
	while (length--) {
	    tty_vwrite(screen->respond, (const Char *) "\026", 1);	/* Control-V */
	    tty_vwrite(screen->respond, lag++, 1);
	}
    } else
#endif
    {
	TRACE(("writing base64 padding %s\n", visibleChars(lag, length)));
	tty_vwrite(screen->respond, lag, length);
    }
}

static void
_WriteSelectionData(XtermWidget xw, Char *line, size_t length)
{
    /* Write data to pty a line at a time. */
    /* Doing this one line at a time may no longer be necessary
       because v_write has been re-written. */

#if OPT_PASTE64
    TScreen *screen = TScreenOf(xw);
#endif
    Char *lag, *end;

    /* in the VMS version, if tt_pasting isn't set to True then qio
       reads aren't blocked and an infinite loop is entered, where the
       pasted text shows up as new input, goes in again, shows up
       again, ad nauseum. */
#ifdef VMS
    tt_pasting = True;
#endif

    end = &line[length];
    lag = line;

#if OPT_PASTE64
    if (screen->base64_paste) {
	_qWriteSelectionData(xw, lag, (unsigned) (end - lag));
	base64_flush(screen);
    } else
#endif
    {
	if (!SCREEN_FLAG(screen, paste_literal_nl)) {
	    Char *cp;
	    for (cp = line; cp != end; cp++) {
		if (*cp == '\n') {
		    *cp = '\r';
		    _qWriteSelectionData(xw, lag, (unsigned) (cp - lag + 1));
		    lag = cp + 1;
		}
	    }
	}

	if (lag != end) {
	    _qWriteSelectionData(xw, lag, (unsigned) (end - lag));
	}
    }
#ifdef VMS
    tt_pasting = False;
    tt_start_read();		/* reenable reads or a character may be lost */
#endif
}

#if OPT_READLINE
static void
_WriteKey(TScreen *screen, const Char *in)
{
    Char line[16];
    unsigned count = 0;
    size_t length = strlen((const char *) in);

    if (screen->control_eight_bits) {
	line[count++] = ANSI_CSI;
    } else {
	line[count++] = ANSI_ESC;
	line[count++] = '[';
    }
    while (length--)
	line[count++] = *in++;
    line[count++] = '~';
    tty_vwrite(screen->respond, line, count);
}
#endif /* OPT_READLINE */

/*
 * Unless enabled by the user, strip control characters other than formatting.
 */
static size_t
removeControls(XtermWidget xw, char *value)
{
    TScreen *screen = TScreenOf(xw);
    size_t dst = 0;

    if (screen->allowPasteControls) {
	dst = strlen(value);
    } else {
	size_t src = 0;
	while ((value[dst] = value[src]) != '\0') {
	    int ch = CharOf(value[src++]);
	    if (ch < 32) {
		switch (ch) {
		case '\b':
		case '\t':
		case '\n':
		case '\r':
		    ++dst;
		    break;
		default:
		    continue;
		}
	    }
#if OPT_WIDE_CHARS
	    else if (screen->utf8_inparse || screen->utf8_nrc_mode)
		++dst;
#endif
#if OPT_C1_PRINT || OPT_WIDE_CHARS
	    else if (screen->c1_printable)
		++dst;
#endif
	    else if (ch >= 128 && ch < 160)
		continue;
	    else
		++dst;
	}
    }
    return dst;
}

/* SelectionReceived: stuff received selection text into pty */

/* ARGSUSED */
static void
SelectionReceived(Widget w,
		  XtPointer client_data,
		  Atom *selection GCC_UNUSED,
		  Atom *type,
		  XtPointer value,
		  unsigned long *length,
		  int *format)
{
    char **text_list = NULL;
    int text_list_count = 0;
    XTextProperty text_prop;
    TScreen *screen;
    Display *dpy;
#if OPT_TRACE && OPT_WIDE_CHARS
    Char *line = (Char *) value;
#endif

    XtermWidget xw;

    if ((xw = getXtermWidget(w)) == 0)
	return;

    screen = TScreenOf(xw);
    dpy = XtDisplay(w);

    if (*type == 0		/*XT_CONVERT_FAIL */
	|| *length == 0
	|| value == NULL) {
	TRACE(("...no data to convert\n"));
	goto fail;
    }

    text_prop.value = (unsigned char *) value;
    text_prop.encoding = *type;
    text_prop.format = *format;
    text_prop.nitems = *length;

    TRACE(("SelectionReceived %s %s format %d, nitems %ld\n",
	   TraceAtomName(screen->display, *selection),
	   visibleSelectionTarget(dpy, text_prop.encoding),
	   text_prop.format,
	   text_prop.nitems));

#if OPT_WIDE_CHARS
    if (XSupportsLocale() && screen->wide_chars) {
	if (*type == XA_UTF8_STRING(dpy) ||
	    *type == XA_STRING ||
	    *type == XA_COMPOUND_TEXT(dpy)) {
	    GettingSelection(dpy, *type, line, *length);
	    if (Xutf8TextPropertyToTextList(dpy, &text_prop,
					    &text_list,
					    &text_list_count) < 0) {
		TRACE(("default Xutf8 Conversion failed\n"));
		text_list = NULL;
	    }
	}
    } else
#endif /* OPT_WIDE_CHARS */
    {
	/* Convert the selection to locale's multibyte encoding. */

	if (*type == XA_UTF8_STRING(dpy) ||
	    *type == XA_STRING ||
	    *type == XA_COMPOUND_TEXT(dpy)) {
	    Status rc;

	    GettingSelection(dpy, *type, line, *length);

#if OPT_WIDE_CHARS
	    if (*type == XA_UTF8_STRING(dpy) &&
		!(screen->wide_chars || screen->c1_printable)) {
		rc = xtermUtf8ToTextList(xw, &text_prop,
					 &text_list, &text_list_count);
	    } else
#endif
	    if (*type == XA_STRING && (!XSupportsLocale() || screen->brokenSelections)) {
		rc = XTextPropertyToStringList(&text_prop,
					       &text_list, &text_list_count);
	    } else {
		rc = XmbTextPropertyToTextList(dpy, &text_prop,
					       &text_list,
					       &text_list_count);
	    }
	    if (rc < 0) {
		TRACE(("Conversion failed\n"));
		text_list = NULL;
	    }
	}
    }

    if (text_list != NULL && text_list_count != 0) {
	int i;

#if OPT_PASTE64
	if (screen->base64_paste) {
	    /* EMPTY */ ;
	} else
#endif
#if OPT_READLINE
	if (SCREEN_FLAG(screen, paste_brackets)) {
	    _WriteKey(screen, (const Char *) "200");
	}
#endif
	for (i = 0; i < text_list_count; i++) {
	    size_t len = removeControls(xw, text_list[i]);

	    if (screen->selectToBuffer) {
		InternalSelect *mydata = &(screen->internal_select);
		size_t have = (mydata->buffer
			       ? strlen(mydata->buffer)
			       : 0);
		size_t need = have + len + 1;
		char *buffer = realloc(mydata->buffer, need);

		screen->selectToBuffer = False;
#if OPT_PASTE64
		screen->base64_paste = mydata->base64_paste;
#endif
#if OPT_READLINE
		screen->paste_brackets = mydata->paste_brackets;
#endif
		if (buffer != 0) {
		    strcpy(buffer + have, text_list[i]);
		    mydata->buffer = buffer;
		}
		TRACE(("FormatSelect %d.%d .. %d.%d %s\n",
		       screen->startSel.row,
		       screen->startSel.col,
		       screen->endSel.row,
		       screen->endSel.col,
		       mydata->buffer));
		mydata->format_select(w, mydata->format, mydata->buffer,
				      &(screen->startSel),
				      &(screen->endSel));

		free(mydata->format);
		free(mydata->buffer);
		memset(mydata, 0, sizeof(*mydata));
	    } else {
		_WriteSelectionData(xw, (Char *) text_list[i], len);
	    }
	}
#if OPT_PASTE64
	if (screen->base64_paste) {
	    FinishPaste64(xw);
	} else
#endif
#if OPT_READLINE
	if (SCREEN_FLAG(screen, paste_brackets)) {
	    _WriteKey(screen, (const Char *) "201");
	}
#endif
	XFreeStringList(text_list);
    } else {
	TRACE(("...empty text-list\n"));
	goto fail;
    }

    XtFree((char *) client_data);
    XtFree((char *) value);

    return;

  fail:
    if (client_data != 0) {
	struct _SelectionList *list = (struct _SelectionList *) client_data;

	TRACE(("SelectionReceived ->xtermGetSelection\n"));
	xtermGetSelection(w, list->time,
			  list->params, list->count, list->targets);
	XtFree((char *) client_data);
#if OPT_PASTE64
    } else {
	FinishPaste64(xw);
#endif
    }
    return;
}

void
HandleInsertSelection(Widget w,
		      XEvent *event,	/* assumed to be XButtonEvent* */
		      String *params,	/* selections in precedence order */
		      Cardinal *num_params)
{
    XtermWidget xw;

    if ((xw = getXtermWidget(w)) != 0) {
	TRACE(("HandleInsertSelection\n"));
	if (!SendMousePosition(xw, event)) {
#if OPT_READLINE
	    int ldelta;
	    TScreen *screen = TScreenOf(xw);
	    if (IsBtnEvent(event)
	    /* Disable on Shift-mouse, including the application-mouse modes */
		&& !(KeyModifiers(event) & ShiftMask)
		&& (okSendMousePos(xw) == MOUSE_OFF)
		&& SCREEN_FLAG(screen, paste_moves)
		&& rowOnCurrentLine(screen, eventRow(screen, event), &ldelta))
		ReadLineMovePoint(screen, eventColBetween(screen, event), ldelta);
#endif /* OPT_READLINE */

	    xtermGetSelection(w, event->xbutton.time, params, *num_params, NULL);
	}
    }
}

static SelectUnit
EvalSelectUnit(XtermWidget xw,
	       Time buttonDownTime,
	       SelectUnit defaultUnit,
	       unsigned int button)
{
    TScreen *screen = TScreenOf(xw);
    SelectUnit result;
    int delta;

    if (button != screen->lastButton) {
	delta = screen->multiClickTime + 1;
    } else if (screen->lastButtonUpTime == (Time) 0) {
	/* first time and once in a blue moon */
	delta = screen->multiClickTime + 1;
    } else if (buttonDownTime > screen->lastButtonUpTime) {
	/* most of the time */
	delta = (int) (buttonDownTime - screen->lastButtonUpTime);
    } else {
	/* time has rolled over since lastButtonUpTime */
	delta = (int) ((((Time) ~ 0) - screen->lastButtonUpTime) + buttonDownTime);
    }

    if (delta > screen->multiClickTime) {
	screen->numberOfClicks = 1;
	result = defaultUnit;
    } else {
	result = screen->selectMap[screen->numberOfClicks % screen->maxClicks];
	screen->numberOfClicks += 1;
    }
    TRACE(("EvalSelectUnit(%d) = %d\n", screen->numberOfClicks, result));
    return result;
}

static void
do_select_start(XtermWidget xw,
		XEvent *event,	/* must be XButtonEvent* */
		CELL *cell)
{
    TScreen *screen = TScreenOf(xw);

    if (SendMousePosition(xw, event))
	return;
    screen->selectUnit = EvalSelectUnit(xw,
					event->xbutton.time,
					Select_CHAR,
					event->xbutton.button);
    screen->replyToEmacs = False;

#if OPT_READLINE
    lastButtonDownTime = event->xbutton.time;
#endif

    StartSelect(xw, cell);
}

/* ARGSUSED */
void
HandleSelectStart(Widget w,
		  XEvent *event,	/* must be XButtonEvent* */
		  String *params GCC_UNUSED,
		  Cardinal *num_params GCC_UNUSED)
{
    XtermWidget xw;

    if ((xw = getXtermWidget(w)) != 0) {
	TScreen *screen = TScreenOf(xw);
	CELL cell;

	TRACE(("HandleSelectStart\n"));
	screen->firstValidRow = 0;
	screen->lastValidRow = screen->max_row;
	PointToCELL(screen, event->xbutton.y, event->xbutton.x, &cell);

#if OPT_READLINE
	ExtendingSelection = 0;
#endif

	do_select_start(xw, event, &cell);
    }
}

/* ARGSUSED */
void
HandleKeyboardSelectStart(Widget w,
			  XEvent *event,	/* must be XButtonEvent* */
			  String *params GCC_UNUSED,
			  Cardinal *num_params GCC_UNUSED)
{
    XtermWidget xw;

    if ((xw = getXtermWidget(w)) != 0) {
	TScreen *screen = TScreenOf(xw);

	TRACE(("HandleKeyboardSelectStart\n"));
	do_select_start(xw, event, &screen->cursorp);
    }
}

static void
TrackDown(XtermWidget xw, XButtonEvent *event)
{
    TScreen *screen = TScreenOf(xw);
    CELL cell;

    screen->selectUnit = EvalSelectUnit(xw,
					event->time,
					Select_CHAR,
					event->button);
    if (screen->numberOfClicks > 1) {
	PointToCELL(screen, event->y, event->x, &cell);
	screen->replyToEmacs = True;
	StartSelect(xw, &cell);
    } else {
	screen->waitingForTrackInfo = True;
	EditorButton(xw, event);
    }
}

#define boundsCheck(x)	if (x < 0) \
			    x = 0; \
			else if (x >= screen->max_row) \
			    x = screen->max_row

void
TrackMouse(XtermWidget xw,
	   int func,
	   CELL *start,
	   int firstrow,
	   int lastrow)
{
    TScreen *screen = TScreenOf(xw);

    if (screen->waitingForTrackInfo) {	/* if Timed, ignore */
	screen->waitingForTrackInfo = False;

	if (func != 0) {
	    CELL first = *start;

	    boundsCheck(first.row);
	    boundsCheck(firstrow);
	    boundsCheck(lastrow);
	    screen->firstValidRow = firstrow;
	    screen->lastValidRow = lastrow;
	    screen->replyToEmacs = True;
	    StartSelect(xw, &first);
	}
    }
}

static void
StartSelect(XtermWidget xw, const CELL *cell)
{
    TScreen *screen = TScreenOf(xw);

    TRACE(("StartSelect row=%d, col=%d\n", cell->row, cell->col));
    if (screen->cursor_state)
	HideCursor();
    if (screen->numberOfClicks == 1) {
	/* set start of selection */
	screen->rawPos = *cell;
    }
    /* else use old values in rawPos */
    screen->saveStartR = screen->startExt = screen->rawPos;
    screen->saveEndR = screen->endExt = screen->rawPos;
    if (Coordinate(screen, cell) < Coordinate(screen, &(screen->rawPos))) {
	screen->eventMode = LEFTEXTENSION;
	screen->startExt = *cell;
    } else {
	screen->eventMode = RIGHTEXTENSION;
	screen->endExt = *cell;
    }
    ComputeSelect(xw, &(screen->startExt), &(screen->endExt), False);
}

static void
EndExtend(XtermWidget xw,
	  XEvent *event,	/* must be XButtonEvent */
	  String *params,	/* selections */
	  Cardinal num_params,
	  Bool use_cursor_loc)
{
    CELL cell;
    TScreen *screen = TScreenOf(xw);

    if (use_cursor_loc) {
	cell = screen->cursorp;
    } else {
	PointToCELL(screen, event->xbutton.y, event->xbutton.x, &cell);
    }
    ExtendExtend(xw, &cell);

    screen->lastButtonUpTime = event->xbutton.time;
    screen->lastButton = event->xbutton.button;

    if (!isSameCELL(&(screen->startSel), &(screen->endSel))) {
	if (screen->replyToEmacs) {
	    Char line[64];
	    unsigned count = 0;

	    if (screen->control_eight_bits) {
		line[count++] = ANSI_CSI;
	    } else {
		line[count++] = ANSI_ESC;
		line[count++] = '[';
	    }
	    if (isSameCELL(&(screen->rawPos), &(screen->startSel))
		&& isSameCELL(&cell, &(screen->endSel))) {
		/* Use short-form emacs select */

		switch (screen->extend_coords) {
		case 0:
		case SET_EXT_MODE_MOUSE:
		    line[count++] = 't';
		    break;
		case SET_SGR_EXT_MODE_MOUSE:
		    line[count++] = '<';
		    break;
		}

		count = EmitMousePosition(screen, line, count, screen->endSel.col);
		count = EmitMousePositionSeparator(screen, line, count);
		count = EmitMousePosition(screen, line, count, screen->endSel.row);

		switch (screen->extend_coords) {
		case SET_SGR_EXT_MODE_MOUSE:
		case SET_URXVT_EXT_MODE_MOUSE:
		    line[count++] = 't';
		    break;
		}
	    } else {
		/* long-form, specify everything */

		switch (screen->extend_coords) {
		case 0:
		case SET_EXT_MODE_MOUSE:
		    line[count++] = 'T';
		    break;
		case SET_SGR_EXT_MODE_MOUSE:
		    line[count++] = '<';
		    break;
		}

		count = EmitMousePosition(screen, line, count, screen->startSel.col);
		count = EmitMousePositionSeparator(screen, line, count);
		count = EmitMousePosition(screen, line, count, screen->startSel.row);
		count = EmitMousePositionSeparator(screen, line, count);
		count = EmitMousePosition(screen, line, count, screen->endSel.col);
		count = EmitMousePositionSeparator(screen, line, count);
		count = EmitMousePosition(screen, line, count, screen->endSel.row);
		count = EmitMousePositionSeparator(screen, line, count);
		count = EmitMousePosition(screen, line, count, cell.col);
		count = EmitMousePositionSeparator(screen, line, count);
		count = EmitMousePosition(screen, line, count, cell.row);

		switch (screen->extend_coords) {
		case SET_SGR_EXT_MODE_MOUSE:
		case SET_URXVT_EXT_MODE_MOUSE:
		    line[count++] = 'T';
		    break;
		}
	    }
	    v_write(screen->respond, line, count);
	    TrackText(xw, &zeroCELL, &zeroCELL);
	}
    }
    SelectSet(xw, event, params, num_params);
    screen->eventMode = NORMAL;
}

void
HandleSelectSet(Widget w,
		XEvent *event,
		String *params,
		Cardinal *num_params)
{
    XtermWidget xw;

    if ((xw = getXtermWidget(w)) != 0) {
	TRACE(("HandleSelectSet\n"));
	SelectSet(xw, event, params, *num_params);
    }
}

/* ARGSUSED */
static void
SelectSet(XtermWidget xw,
	  XEvent *event GCC_UNUSED,
	  String *params,
	  Cardinal num_params)
{
    TScreen *screen = TScreenOf(xw);

    TRACE(("SelectSet\n"));
    /* Only do select stuff if non-null select */
    if (!isSameCELL(&(screen->startSel), &(screen->endSel))) {
	SaltTextAway(xw, &(screen->startSel), &(screen->endSel));
	_OwnSelection(xw, params, num_params);
    } else {
	ScrnDisownSelection(xw);
    }
}

#define Abs(x)		((x) < 0 ? -(x) : (x))

/* ARGSUSED */
static void
do_start_extend(XtermWidget xw,
		XEvent *event,	/* must be XButtonEvent* */
		String *params GCC_UNUSED,
		Cardinal *num_params GCC_UNUSED,
		Bool use_cursor_loc)
{
    TScreen *screen = TScreenOf(xw);
    int coord;
    CELL cell;

    if (SendMousePosition(xw, event))
	return;

    screen->firstValidRow = 0;
    screen->lastValidRow = screen->max_row;
#if OPT_READLINE
    if ((KeyModifiers(event) & ShiftMask)
	|| event->xbutton.button != Button3
	|| !(SCREEN_FLAG(screen, dclick3_deletes)))
#endif
	screen->selectUnit = EvalSelectUnit(xw,
					    event->xbutton.time,
					    screen->selectUnit,
					    event->xbutton.button);
    screen->replyToEmacs = False;

#if OPT_READLINE
    CheckSecondPress3(screen, event);
#endif

    if (screen->numberOfClicks == 1
	|| (SCREEN_FLAG(screen, dclick3_deletes)	/* Dclick special */
	    &&!(KeyModifiers(event) & ShiftMask))) {
	/* Save existing selection so we can reestablish it if the guy
	   extends past the other end of the selection */
	screen->saveStartR = screen->startExt = screen->startRaw;
	screen->saveEndR = screen->endExt = screen->endRaw;
    } else {
	/* He just needed the selection mode changed, use old values. */
	screen->startExt = screen->startRaw = screen->saveStartR;
	screen->endExt = screen->endRaw = screen->saveEndR;
    }
    if (use_cursor_loc) {
	cell = screen->cursorp;
    } else {
	PointToCELL(screen, event->xbutton.y, event->xbutton.x, &cell);
    }
    coord = Coordinate(screen, &cell);

    if (Abs(coord - Coordinate(screen, &(screen->startSel)))
	< Abs(coord - Coordinate(screen, &(screen->endSel)))
	|| coord < Coordinate(screen, &(screen->startSel))) {
	/* point is close to left side of selection */
	screen->eventMode = LEFTEXTENSION;
	screen->startExt = cell;
    } else {
	/* point is close to left side of selection */
	screen->eventMode = RIGHTEXTENSION;
	screen->endExt = cell;
    }
    ComputeSelect(xw, &(screen->startExt), &(screen->endExt), True);

#if OPT_READLINE
    if (!isSameCELL(&(screen->startSel), &(screen->endSel)))
	ExtendingSelection = 1;
#endif
}

static void
ExtendExtend(XtermWidget xw, const CELL *cell)
{
    TScreen *screen = TScreenOf(xw);
    int coord = Coordinate(screen, cell);

    TRACE(("ExtendExtend row=%d, col=%d\n", cell->row, cell->col));
    if (screen->eventMode == LEFTEXTENSION
	&& ((coord + (screen->selectUnit != Select_CHAR))
	    > Coordinate(screen, &(screen->endSel)))) {
	/* Whoops, he's changed his mind.  Do RIGHTEXTENSION */
	screen->eventMode = RIGHTEXTENSION;
	screen->startExt = screen->saveStartR;
    } else if (screen->eventMode == RIGHTEXTENSION
	       && coord < Coordinate(screen, &(screen->startSel))) {
	/* Whoops, he's changed his mind.  Do LEFTEXTENSION */
	screen->eventMode = LEFTEXTENSION;
	screen->endExt = screen->saveEndR;
    }
    if (screen->eventMode == LEFTEXTENSION) {
	screen->startExt = *cell;
    } else {
	screen->endExt = *cell;
    }
    ComputeSelect(xw, &(screen->startExt), &(screen->endExt), False);

#if OPT_READLINE
    if (!isSameCELL(&(screen->startSel), &(screen->endSel)))
	ExtendingSelection = 1;
#endif
}

void
HandleStartExtend(Widget w,
		  XEvent *event,	/* must be XButtonEvent* */
		  String *params,	/* unused */
		  Cardinal *num_params)		/* unused */
{
    XtermWidget xw;

    if ((xw = getXtermWidget(w)) != 0) {
	TRACE(("HandleStartExtend\n"));
	do_start_extend(xw, event, params, num_params, False);
    }
}

void
HandleKeyboardStartExtend(Widget w,
			  XEvent *event,	/* must be XButtonEvent* */
			  String *params,	/* unused */
			  Cardinal *num_params)		/* unused */
{
    XtermWidget xw;

    if ((xw = getXtermWidget(w)) != 0) {
	TRACE(("HandleKeyboardStartExtend\n"));
	do_start_extend(xw, event, params, num_params, True);
    }
}

void
ScrollSelection(TScreen *screen, int amount, Bool always)
{
    int minrow = INX2ROW(screen, -screen->savedlines);
    int maxrow = INX2ROW(screen, screen->max_row);
    int maxcol = screen->max_col;

#define scroll_update_one(cell) \
	(cell)->row += amount; \
	if ((cell)->row < minrow) { \
	    (cell)->row = minrow; \
	    (cell)->col = 0; \
	} \
	if ((cell)->row > maxrow) { \
	    (cell)->row = maxrow; \
	    (cell)->col = maxcol; \
	}

    scroll_update_one(&(screen->startRaw));
    scroll_update_one(&(screen->endRaw));
    scroll_update_one(&(screen->startSel));
    scroll_update_one(&(screen->endSel));

    scroll_update_one(&(screen->rawPos));

    /*
     * If we are told to scroll the selection but it lies outside the scrolling
     * margins, then that could cause the selection to move (bad).  It is not
     * simple to fix, because this function is called both for the scrollbar
     * actions as well as application scrolling.  The 'always' flag is set in
     * the former case.  The rest of the logic handles the latter.
     */
    if (ScrnHaveSelection(screen)) {
	int adjust;

	adjust = ROW2INX(screen, screen->startH.row);
	if (always
	    || !ScrnHaveRowMargins(screen)
	    || ScrnIsRowInMargins(screen, adjust)) {
	    scroll_update_one(&screen->startH);
	}
	adjust = ROW2INX(screen, screen->endH.row);
	if (always
	    || !ScrnHaveRowMargins(screen)
	    || ScrnIsRowInMargins(screen, adjust)) {
	    scroll_update_one(&screen->endH);
	}
    }

    screen->startHCoord = Coordinate(screen, &screen->startH);
    screen->endHCoord = Coordinate(screen, &screen->endH);
}

/*ARGSUSED*/
void
ResizeSelection(TScreen *screen GCC_UNUSED, int rows, int cols)
{
    rows--;			/* decr to get 0-max */
    cols--;

    if (screen->startRaw.row > rows)
	screen->startRaw.row = rows;
    if (screen->startSel.row > rows)
	screen->startSel.row = rows;
    if (screen->endRaw.row > rows)
	screen->endRaw.row = rows;
    if (screen->endSel.row > rows)
	screen->endSel.row = rows;
    if (screen->rawPos.row > rows)
	screen->rawPos.row = rows;

    if (screen->startRaw.col > cols)
	screen->startRaw.col = cols;
    if (screen->startSel.col > cols)
	screen->startSel.col = cols;
    if (screen->endRaw.col > cols)
	screen->endRaw.col = cols;
    if (screen->endSel.col > cols)
	screen->endSel.col = cols;
    if (screen->rawPos.col > cols)
	screen->rawPos.col = cols;
}

#if OPT_WIDE_CHARS
Bool
iswide(int i)
{
    return (i == HIDDEN_CHAR) || (WideCells(i) == 2);
}

#define isWideCell(row, col) iswide((int)XTERM_CELL(row, col))
#endif

static void
PointToCELL(TScreen *screen,
	    int y,
	    int x,
	    CELL *cell)
/* Convert pixel coordinates to character coordinates.
   Rows are clipped between firstValidRow and lastValidRow.
   Columns are clipped between to be 0 or greater, but are not clipped to some
       maximum value. */
{
    cell->row = (y - screen->border) / FontHeight(screen);
    if (cell->row < screen->firstValidRow)
	cell->row = screen->firstValidRow;
    else if (cell->row > screen->lastValidRow)
	cell->row = screen->lastValidRow;
    cell->col = (x - OriginX(screen)) / FontWidth(screen);
    if (cell->col < 0)
	cell->col = 0;
    else if (cell->col > MaxCols(screen)) {
	cell->col = MaxCols(screen);
    }
#if OPT_WIDE_CHARS
    /*
     * If we got a click on the right half of a doublewidth character,
     * pretend it happened on the left half.
     */
    if (cell->col > 0
	&& isWideCell(cell->row, cell->col - 1)
	&& (XTERM_CELL(cell->row, cell->col) == HIDDEN_CHAR)) {
	cell->col -= 1;
    }
#endif
}

/*
 * Find the last column at which text was drawn on the given row.
 */
static int
LastTextCol(TScreen *screen, CLineData *ld, int row)
{
    int i = -1;

    if (ld != 0) {
	if (okScrnRow(screen, row)) {
	    const IAttr *ch;
	    for (i = screen->max_col,
		 ch = ld->attribs + i;
		 i >= 0 && !(*ch & CHARDRAWN);
		 ch--, i--) {
		;
	    }
#if OPT_DEC_CHRSET
	    if (CSET_DOUBLE(GetLineDblCS(ld))) {
		i *= 2;
	    }
#endif
	}
    }
    return (i);
}

#if !OPT_WIDE_CHARS
/*
** double click table for cut and paste in 8 bits
**
** This table is divided in four parts :
**
**	- control characters	[0,0x1f] U [0x80,0x9f]
**	- separators		[0x20,0x3f] U [0xa0,0xb9]
**	- binding characters	[0x40,0x7f] U [0xc0,0xff]
**	- exceptions
*/
/* *INDENT-OFF* */
static int charClass[256] =
{
/* NUL  SOH  STX  ETX  EOT  ENQ  ACK  BEL */
    32,  1,    1,   1,   1,   1,   1,   1,
/*  BS   HT   NL   VT   FF   CR   SO   SI */
     1,  32,   1,   1,   1,   1,   1,   1,
/* DLE  DC1  DC2  DC3  DC4  NAK  SYN  ETB */
     1,   1,   1,   1,   1,   1,   1,   1,
/* CAN   EM  SUB  ESC   FS   GS   RS   US */
     1,   1,   1,   1,   1,   1,   1,   1,
/*  SP    !    "    #    $    %    &    ' */
    32,  33,  34,  35,  36,  37,  38,  39,
/*   (    )    *    +    ,    -    .    / */
    40,  41,  42,  43,  44,  45,  46,  47,
/*   0    1    2    3    4    5    6    7 */
    48,  48,  48,  48,  48,  48,  48,  48,
/*   8    9    :    ;    <    =    >    ? */
    48,  48,  58,  59,  60,  61,  62,  63,
/*   @    A    B    C    D    E    F    G */
    64,  48,  48,  48,  48,  48,  48,  48,
/*   H    I    J    K    L    M    N    O */
    48,  48,  48,  48,  48,  48,  48,  48,
/*   P    Q    R    S    T    U    V    W */
    48,  48,  48,  48,  48,  48,  48,  48,
/*   X    Y    Z    [    \    ]    ^    _ */
    48,  48,  48,  91,  92,  93,  94,  48,
/*   `    a    b    c    d    e    f    g */
    96,  48,  48,  48,  48,  48,  48,  48,
/*   h    i    j    k    l    m    n    o */
    48,  48,  48,  48,  48,  48,  48,  48,
/*   p    q    r    s    t    u    v    w */
    48,  48,  48,  48,  48,  48,  48,  48,
/*   x    y    z    {    |    }    ~  DEL */
    48,  48,  48, 123, 124, 125, 126,   1,
/* x80  x81  x82  x83  IND  NEL  SSA  ESA */
    1,    1,   1,   1,   1,   1,   1,   1,
/* HTS  HTJ  VTS  PLD  PLU   RI  SS2  SS3 */
    1,    1,   1,   1,   1,   1,   1,   1,
/* DCS  PU1  PU2  STS  CCH   MW  SPA  EPA */
    1,    1,   1,   1,   1,   1,   1,   1,
/* x98  x99  x9A  CSI   ST  OSC   PM  APC */
    1,    1,   1,   1,   1,   1,   1,   1,
/*   -    i   c/    L   ox   Y-    |   So */
    160, 161, 162, 163, 164, 165, 166, 167,
/*  ..   c0   ip   <<    _        R0    - */
    168, 169, 170, 171, 172, 173, 174, 175,
/*   o   +-    2    3    '    u   q|    . */
    176, 177, 178, 179, 180, 181, 182, 183,
/*   ,    1    2   >>  1/4  1/2  3/4    ? */
    184, 185, 186, 187, 188, 189, 190, 191,
/*  A`   A'   A^   A~   A:   Ao   AE   C, */
     48,  48,  48,  48,  48,  48,  48,  48,
/*  E`   E'   E^   E:   I`   I'   I^   I: */
     48,  48,  48,  48,  48,  48,  48,  48,
/*  D-   N~   O`   O'   O^   O~   O:    X */
     48,  48,  48,  48,  48,  48,  48, 215,
/*  O/   U`   U'   U^   U:   Y'    P    B */
     48,  48,  48,  48,  48,  48,  48,  48,
/*  a`   a'   a^   a~   a:   ao   ae   c, */
     48,  48,  48,  48,  48,  48,  48,  48,
/*  e`   e'   e^   e:    i`  i'   i^   i: */
     48,  48,  48,  48,  48,  48,  48,  48,
/*   d   n~   o`   o'   o^   o~   o:   -: */
     48,  48,  48,  48,  48,  48,  48, 247,
/*  o/   u`   u'   u^   u:   y'    P   y: */
     48,  48,  48,  48,  48,  48,  48,  48};
/* *INDENT-ON* */

int
SetCharacterClassRange(int low,	/* in range of [0..255] */
		       int high,
		       int value)	/* arbitrary */
{

    if (low < 0 || high > 255 || high < low)
	return (-1);

    for (; low <= high; low++)
	charClass[low] = value;

    return (0);
}
#endif

static int
class_of(LineData *ld, CELL *cell)
{
    CELL temp = *cell;
    int result = 0;

#if OPT_DEC_CHRSET
    if (CSET_DOUBLE(GetLineDblCS(ld))) {
	temp.col /= 2;
    }
#endif
    if (temp.col < (int) ld->lineSize)
	result = CharacterClass((int) (ld->charData[temp.col]));
    return result;
}

#if OPT_WIDE_CHARS
#define CClassSelects(name, cclass) \
	 (CClassOf(name) == cclass \
	 || XTERM_CELL(screen->name.row, screen->name.col) == HIDDEN_CHAR)
#else
#define CClassSelects(name, cclass) \
	 (class_of(ld.name, &((screen->name))) == cclass)
#endif

#define CClassOf(name) class_of(ld.name, &((screen->name)))

#if OPT_REPORT_CCLASS
static int
show_cclass_range(int lo, int hi)
{
    int cclass = CharacterClass(lo);
    int ident = (cclass == lo);
    int more = 0;
    if (ident) {
	int ch;
	for (ch = lo + 1; ch <= hi; ch++) {
	    if (CharacterClass(ch) != ch) {
		ident = 0;
		break;
	    }
	}
	if (ident && (hi < 255)) {
	    ch = hi + 1;
	    if (CharacterClass(ch) == ch) {
		if (ch >= 255 || CharacterClass(ch + 1) != ch) {
		    more = 1;
		}
	    }
	}
    }
    if (!more) {
	if (lo == hi) {
	    printf("\t%d", lo);
	} else {
	    printf("\t%d-%d", lo, hi);
	}
	if (!ident)
	    printf(":%d", cclass);
	if (hi < 255)
	    printf(", \\");
	printf("\n");
    }
    return !more;
}

void
report_char_class(XtermWidget xw)
{
    /* simple table, to match documentation */
    static const char charnames[] =
    "NUL\0" "SOH\0" "STX\0" "ETX\0" "EOT\0" "ENQ\0" "ACK\0" "BEL\0"
    " BS\0" " HT\0" " NL\0" " VT\0" " NP\0" " CR\0" " SO\0" " SI\0"
    "DLE\0" "DC1\0" "DC2\0" "DC3\0" "DC4\0" "NAK\0" "SYN\0" "ETB\0"
    "CAN\0" " EM\0" "SUB\0" "ESC\0" " FS\0" " GS\0" " RS\0" " US\0"
    " SP\0" "  !\0" "  \"\0" "  #\0" "  $\0" "  %\0" "  &\0" "  '\0"
    "  (\0" "  )\0" "  *\0" "  +\0" "  ,\0" "  -\0" "  .\0" "  /\0"
    "  0\0" "  1\0" "  2\0" "  3\0" "  4\0" "  5\0" "  6\0" "  7\0"
    "  8\0" "  9\0" "  :\0" "  ;\0" "  <\0" "  =\0" "  >\0" "  ?\0"
    "  @\0" "  A\0" "  B\0" "  C\0" "  D\0" "  E\0" "  F\0" "  G\0"
    "  H\0" "  I\0" "  J\0" "  K\0" "  L\0" "  M\0" "  N\0" "  O\0"
    "  P\0" "  Q\0" "  R\0" "  S\0" "  T\0" "  U\0" "  V\0" "  W\0"
    "  X\0" "  Y\0" "  Z\0" "  [\0" "  \\\0" "  ]\0" "  ^\0" "  _\0"
    "  `\0" "  a\0" "  b\0" "  c\0" "  d\0" "  e\0" "  f\0" "  g\0"
    "  h\0" "  i\0" "  j\0" "  k\0" "  l\0" "  m\0" "  n\0" "  o\0"
    "  p\0" "  q\0" "  r\0" "  s\0" "  t\0" "  u\0" "  v\0" "  w\0"
    "  x\0" "  y\0" "  z\0" "  {\0" "  |\0" "  }\0" "  ~\0" "DEL\0"
    "x80\0" "x81\0" "x82\0" "x83\0" "IND\0" "NEL\0" "SSA\0" "ESA\0"
    "HTS\0" "HTJ\0" "VTS\0" "PLD\0" "PLU\0" " RI\0" "SS2\0" "SS3\0"
    "DCS\0" "PU1\0" "PU2\0" "STS\0" "CCH\0" " MW\0" "SPA\0" "EPA\0"
    "x98\0" "x99\0" "x9A\0" "CSI\0" " ST\0" "OSC\0" " PM\0" "APC\0"
    "  -\0" "  i\0" " c/\0" "  L\0" " ox\0" " Y-\0" "  |\0" " So\0"
    " ..\0" " c0\0" " ip\0" " <<\0" "  _\0" "   \0" " R0\0" "  -\0"
    "  o\0" " +-\0" "  2\0" "  3\0" "  '\0" "  u\0" " q|\0" "  .\0"
    "  ,\0" "  1\0" "  2\0" " >>\0" "1/4\0" "1/2\0" "3/4\0" "  ?\0"
    " A`\0" " A'\0" " A^\0" " A~\0" " A:\0" " Ao\0" " AE\0" " C,\0"
    " E`\0" " E'\0" " E^\0" " E:\0" " I`\0" " I'\0" " I^\0" " I:\0"
    " D-\0" " N~\0" " O`\0" " O'\0" " O^\0" " O~\0" " O:\0" "  X\0"
    " O/\0" " U`\0" " U'\0" " U^\0" " U:\0" " Y'\0" "  P\0" "  B\0"
    " a`\0" " a'\0" " a^\0" " a~\0" " a:\0" " ao\0" " ae\0" " c,\0"
    " e`\0" " e'\0" " e^\0" " e:\0" " i`\0" " i'\0" " i^\0" " i:\0"
    "  d\0" " n~\0" " o`\0" " o'\0" " o^\0" " o~\0" " o:\0" " -:\0"
    " o/\0" " u`\0" " u'\0" " u^\0" " u:\0" " y'\0" "  P\0" " y:\0";
    int ch, dh;
    int class_p;

    (void) xw;

    printf("static int charClass[256] = {\n");
    for (ch = 0; ch < 256; ++ch) {
	const char *s = charnames + (ch * 4);
	if ((ch & 7) == 0)
	    printf("/*");
	printf(" %s ", s);
	if (((ch + 1) & 7) == 0) {
	    printf("*/\n  ");
	    for (dh = ch - 7; dh <= ch; ++dh) {
		printf(" %3d%s", CharacterClass(dh), dh == 255 ? "};" : ",");
	    }
	    printf("\n");
	}
    }

    /* print the table as if it were the charClass resource */
    printf("\n");
    printf("The table is equivalent to this \"charClass\" resource:\n");
    class_p = CharacterClass(dh = 0);
    for (ch = 0; ch < 256; ++ch) {
	int class_c = CharacterClass(ch);
	if (class_c != class_p) {
	    if (show_cclass_range(dh, ch - 1)) {
		dh = ch;
		class_p = class_c;
	    }
	}
    }
    if (dh < 255) {
	show_cclass_range(dh, 255);
    }

    if_OPT_WIDE_CHARS(TScreenOf(xw), {
	/* if this is a wide-character configuration, print all intervals */
	report_wide_char_class();
    });
}
#endif

/*
 * If the given column is past the end of text on the given row, bump to the
 * beginning of the next line.
 */
static Boolean
okPosition(TScreen *screen,
	   LineData **ld,
	   CELL *cell)
{
    Boolean result = True;

    if (cell->row > screen->max_row) {
	result = False;
    } else if (cell->col > (LastTextCol(screen, *ld, cell->row) + 1)) {
	if (cell->row < screen->max_row) {
	    cell->col = 0;
	    *ld = GET_LINEDATA(screen, ++cell->row);
	    result = False;
	}
    }
    return result;
}

static void
trimLastLine(TScreen *screen,
	     LineData **ld,
	     CELL *last)
{
    if (screen->cutNewline && last->row < screen->max_row) {
	last->col = 0;
	*ld = GET_LINEDATA(screen, ++last->row);
    } else {
	last->col = LastTextCol(screen, *ld, last->row) + 1;
    }
}

#if OPT_SELECT_REGEX
/*
 * Returns the first row of a wrapped line.
 */
static int
firstRowOfLine(TScreen *screen, int row, Bool visible)
{
    LineData *ld = 0;
    int limit = visible ? 0 : -screen->savedlines;

    while (row > limit &&
	   (ld = GET_LINEDATA(screen, row - 1)) != 0 &&
	   LineTstWrapped(ld)) {
	--row;
    }
    return row;
}

/*
 * Returns the last row of a wrapped line.
 */
static int
lastRowOfLine(TScreen *screen, int row)
{
    LineData *ld;

    while (row < screen->max_row &&
	   (ld = GET_LINEDATA(screen, row)) != 0 &&
	   LineTstWrapped(ld)) {
	++row;
    }
    return row;
}

/*
 * Returns the number of cells on the range of rows.
 */
static unsigned
lengthOfLines(TScreen *screen, int firstRow, int lastRow)
{
    unsigned length = 0;
    int n;

    for (n = firstRow; n <= lastRow; ++n) {
	LineData *ld = GET_LINEDATA(screen, n);
	int value = LastTextCol(screen, ld, n);
	if (value >= 0)
	    length += (unsigned) (value + 1);
    }
    return length;
}

/*
 * Make a copy of the wrapped-line which corresponds to the given row as a
 * string of bytes.  Construct an index for the columns from the beginning of
 * the line.
 */
static char *
make_indexed_text(TScreen *screen, int row, unsigned length, int *indexed)
{
    Char *result = 0;
    size_t need = (length + 1);

    /*
     * Get a quick upper bound to the number of bytes needed, if the whole
     * string were UTF-8.
     */
    if_OPT_WIDE_CHARS(screen, {
	need *= ((screen->lineExtra + 1) * 6);
    });

    if ((result = TypeCallocN(Char, need + 1)) != 0) {
	LineData *ld = GET_LINEDATA(screen, row);
	unsigned used = 0;
	Char *last = result;

	do {
	    int col = 0;
	    int limit = LastTextCol(screen, ld, row);

	    while (col <= limit) {
		Char *next = last;
		unsigned data = ld->charData[col];

		assert(col < (int) ld->lineSize);
		/* some internal points may not be drawn */
		if (data == 0)
		    data = ' ';

		if_WIDE_OR_NARROW(screen, {
		    next = convertToUTF8(last, data);
		}
		, {
		    *next++ = CharOf(data);
		});

		if_OPT_WIDE_CHARS(screen, {
		    size_t off;
		    for_each_combData(off, ld) {
			data = ld->combData[off][col];
			if (data == 0)
			    break;
			next = convertToUTF8(next, data);
		    }
		});

		indexed[used] = (int) (last - result);
		*next = 0;
		/* TRACE(("index[%d.%d] %d:%s\n", row, used, indexed[used], last)); */
		last = next;
		++used;
		++col;
		indexed[used] = (int) (next - result);
	    }
	} while (used < length &&
		 LineTstWrapped(ld) &&
		 (ld = GET_LINEDATA(screen, ++row)) != 0 &&
		 row < screen->max_row);
    }
    /* TRACE(("result:%s\n", result)); */
    return (char *) result;
}

/*
 * Find the column given an offset into the character string by using the
 * index constructed in make_indexed_text().
 */
static int
indexToCol(int *indexed, int len, int off)
{
    int col = 0;
    while (indexed[col] < len) {
	if (indexed[col] >= off)
	    break;
	++col;
    }
    return col;
}

/*
 * Given a row number, and a column offset from that (which may be wrapped),
 * set the cell to the actual row/column values.
 */
static void
columnToCell(TScreen *screen, int row, int col, CELL *cell)
{
    while (row < screen->max_row) {
	CLineData *ld = GET_LINEDATA(screen, row);
	int last = LastTextCol(screen, ld, row);

	/* TRACE(("last(%d) = %d, have %d\n", row, last, col)); */
	if (col <= last) {
	    break;
	}
	/*
	 * Stop if the current row does not wrap (does not continue the current
	 * line).
	 */
	if (!LineTstWrapped(ld)) {
	    col = last + 1;
	    break;
	}
	col -= (last + 1);
	++row;
    }
    if (col < 0)
	col = 0;
    cell->row = row;
    cell->col = col;
}

/*
 * Given a cell, find the corresponding column offset.
 */
static int
cellToColumn(TScreen *screen, CELL *cell)
{
    CLineData *ld = 0;
    int col = cell->col;
    int row = firstRowOfLine(screen, cell->row, False);
    while (row < cell->row) {
	ld = GET_LINEDATA(screen, row);
	col += LastTextCol(screen, ld, row++);
    }
#if OPT_DEC_CHRSET
    if (ld == 0)
	ld = GET_LINEDATA(screen, row);
    if (CSET_DOUBLE(GetLineDblCS(ld)))
	col /= 2;
#endif
    return col;
}

static void
do_select_regex(TScreen *screen, CELL *startc, CELL *endc)
{
    LineData *ld = GET_LINEDATA(screen, startc->row);
    int inx = ((screen->numberOfClicks - 1) % screen->maxClicks);
    char *expr = screen->selectExpr[inx];
    regex_t preg;
    regmatch_t match;

    TRACE(("Select_REGEX[%d]:%s\n", inx, NonNull(expr)));
    if (okPosition(screen, &ld, startc) && expr != 0) {
	if (regcomp(&preg, expr, REG_EXTENDED) == 0) {
	    int firstRow = firstRowOfLine(screen, startc->row, True);
	    int lastRow = lastRowOfLine(screen, firstRow);
	    unsigned size = lengthOfLines(screen, firstRow, lastRow);
	    int actual = cellToColumn(screen, startc);
	    int *indexed;

	    TRACE(("regcomp ok rows %d..%d bytes %d\n",
		   firstRow, lastRow, size));

	    if ((indexed = TypeCallocN(int, size + 1)) != 0) {
		char *search;
		if ((search = make_indexed_text(screen,
						firstRow,
						size,
						indexed)) != 0) {
		    int len = (int) strlen(search);
		    int col;
		    int best_col = -1;
		    int best_len = -1;

		    startc->row = 0;
		    startc->col = 0;
		    endc->row = 0;
		    endc->col = 0;

		    for (col = 0; indexed[col] < len; ++col) {
			if (regexec(&preg,
				    search + indexed[col],
				    (size_t) 1, &match, 0) == 0) {
			    int start_inx = (int) (match.rm_so + indexed[col]);
			    int finis_inx = (int) (match.rm_eo + indexed[col]);
			    int start_col = indexToCol(indexed, len, start_inx);
			    int finis_col = indexToCol(indexed, len, finis_inx);

			    if (start_col <= actual &&
				actual <= finis_col) {
				int test = finis_col - start_col;
				if (best_len < test) {
				    best_len = test;
				    best_col = start_col;
				    TRACE(("match column %d len %d\n",
					   best_col,
					   best_len));
				}
			    }
			}
		    }
		    if (best_col >= 0) {
			int best_nxt = best_col + best_len;
			columnToCell(screen, firstRow, best_col, startc);
			columnToCell(screen, firstRow, best_nxt, endc);
			TRACE(("search::%s\n", search));
			TRACE(("indexed:%d..%d -> %d..%d\n",
			       best_col, best_nxt,
			       indexed[best_col],
			       indexed[best_nxt]));
			TRACE(("matched:%d:%s\n",
			       indexed[best_nxt] + 1 -
			       indexed[best_col],
			       visibleChars((Char *) (search + indexed[best_col]),
					    (unsigned) (indexed[best_nxt] +
							1 -
							indexed[best_col]))));
		    }
		    free(search);
		}
		free(indexed);
#if OPT_DEC_CHRSET
		if ((ld = GET_LINEDATA(screen, startc->row)) != 0) {
		    if (CSET_DOUBLE(GetLineDblCS(ld)))
			startc->col *= 2;
		}
		if ((ld = GET_LINEDATA(screen, endc->row)) != 0) {
		    if (CSET_DOUBLE(GetLineDblCS(ld)))
			endc->col *= 2;
		}
#endif
	    }
	    regfree(&preg);
	}
    }
}
#endif /* OPT_SELECT_REGEX */

#define InitRow(name) \
	ld.name = GET_LINEDATA(screen, screen->name.row)

#define NextRow(name) \
	ld.name = GET_LINEDATA(screen, ++screen->name.row)

#define PrevRow(name) \
	ld.name = GET_LINEDATA(screen, --screen->name.row)

#define MoreRows(name) \
	(screen->name.row < screen->max_row)

#define isPrevWrapped(name) \
	(screen->name.row > 0 \
	   && (ltmp = GET_LINEDATA(screen, screen->name.row - 1)) != 0 \
	   && LineTstWrapped(ltmp))

/*
 * sets startSel endSel
 * ensuring that they have legal values
 */
static void
ComputeSelect(XtermWidget xw,
	      CELL *startc,
	      CELL *endc,
	      Bool extend)
{
    TScreen *screen = TScreenOf(xw);

    int cclass;
    CELL first = *startc;
    CELL last = *endc;
    Boolean ignored = False;

    struct {
	LineData *startSel;
	LineData *endSel;
    } ld;
    LineData *ltmp;

    TRACE(("ComputeSelect(startRow=%d, startCol=%d, endRow=%d, endCol=%d, %sextend)\n",
	   first.row, first.col,
	   last.row, last.col,
	   extend ? "" : "no"));

#if OPT_WIDE_CHARS
    if (first.col > 1
	&& isWideCell(first.row, first.col - 1)
	&& XTERM_CELL(first.row, first.col - 0) == HIDDEN_CHAR) {
	TRACE(("Adjusting start. Changing downwards from %i.\n", first.col));
	first.col -= 1;
	if (last.col == (first.col + 1))
	    last.col--;
    }

    if (last.col > 1
	&& isWideCell(last.row, last.col - 1)
	&& XTERM_CELL(last.row, last.col) == HIDDEN_CHAR) {
	last.col += 1;
    }
#endif

    if (Coordinate(screen, &first) <= Coordinate(screen, &last)) {
	screen->startSel = screen->startRaw = first;
	screen->endSel = screen->endRaw = last;
    } else {			/* Swap them */
	screen->startSel = screen->startRaw = last;
	screen->endSel = screen->endRaw = first;
    }

    InitRow(startSel);
    InitRow(endSel);

    switch (screen->selectUnit) {
    case Select_CHAR:
	(void) okPosition(screen, &(ld.startSel), &(screen->startSel));
	(void) okPosition(screen, &(ld.endSel), &(screen->endSel));
	break;

    case Select_WORD:
	TRACE(("Select_WORD\n"));
	if (okPosition(screen, &(ld.startSel), &(screen->startSel))) {
	    cclass = CClassOf(startSel);
	    do {
		--screen->startSel.col;
		if (screen->startSel.col < 0
		    && isPrevWrapped(startSel)) {
		    PrevRow(startSel);
		    screen->startSel.col = LastTextCol(screen, ld.startSel, screen->startSel.row);
		}
	    } while (screen->startSel.col >= 0
		     && CClassSelects(startSel, cclass));
	    ++screen->startSel.col;
	}
#if OPT_WIDE_CHARS
	if (screen->startSel.col
	    && XTERM_CELL(screen->startSel.row,
			  screen->startSel.col) == HIDDEN_CHAR)
	    screen->startSel.col++;
#endif

	if (okPosition(screen, &(ld.endSel), &(screen->endSel))) {
	    int length = LastTextCol(screen, ld.endSel, screen->endSel.row);
	    cclass = CClassOf(endSel);
	    do {
		++screen->endSel.col;
		if (screen->endSel.col > length
		    && LineTstWrapped(ld.endSel)) {
		    if (!MoreRows(endSel))
			break;
		    screen->endSel.col = 0;
		    NextRow(endSel);
		    length = LastTextCol(screen, ld.endSel, screen->endSel.row);
		}
	    } while (screen->endSel.col <= length
		     && CClassSelects(endSel, cclass));
	    /* Word-select selects if pointing to any char in "word",
	     * especially note that it includes the last character in a word.
	     * So we do no --endSel.col and do special eol handling.
	     */
	    if (screen->endSel.col > length + 1
		&& MoreRows(endSel)) {
		screen->endSel.col = 0;
		NextRow(endSel);
	    }
	}
#if OPT_WIDE_CHARS
	if (screen->endSel.col
	    && XTERM_CELL(screen->endSel.row,
			  screen->endSel.col) == HIDDEN_CHAR)
	    screen->endSel.col++;
#endif

	screen->saveStartW = screen->startSel;
	break;

    case Select_LINE:
	TRACE(("Select_LINE\n"));
	while (LineTstWrapped(ld.endSel)
	       && MoreRows(endSel)) {
	    NextRow(endSel);
	}
	if (screen->cutToBeginningOfLine
	    || screen->startSel.row < screen->saveStartW.row) {
	    screen->startSel.col = 0;
	    while (isPrevWrapped(startSel)) {
		PrevRow(startSel);
	    }
	} else if (!extend) {
	    if ((first.row < screen->saveStartW.row)
		|| (isSameRow(&first, &(screen->saveStartW))
		    && first.col < screen->saveStartW.col)) {
		screen->startSel.col = 0;
		while (isPrevWrapped(startSel)) {
		    PrevRow(startSel);
		}
	    } else {
		screen->startSel = screen->saveStartW;
	    }
	}
	trimLastLine(screen, &(ld.endSel), &(screen->endSel));
	break;

    case Select_GROUP:		/* paragraph */
	TRACE(("Select_GROUP\n"));
	if (okPosition(screen, &(ld.startSel), &(screen->startSel))) {
	    /* scan backward for beginning of group */
	    while (screen->startSel.row > 0 &&
		   (LastTextCol(screen, ld.startSel, screen->startSel.row -
				1) > 0 ||
		    isPrevWrapped(startSel))) {
		PrevRow(startSel);
	    }
	    screen->startSel.col = 0;
	    /* scan forward for end of group */
	    while (MoreRows(endSel) &&
		   (LastTextCol(screen, ld.endSel, screen->endSel.row + 1) >
		    0 ||
		    LineTstWrapped(ld.endSel))) {
		NextRow(endSel);
	    }
	    trimLastLine(screen, &(ld.endSel), &(screen->endSel));
	}
	break;

    case Select_PAGE:		/* everything one can see */
	TRACE(("Select_PAGE\n"));
	screen->startSel.row = 0;
	screen->startSel.col = 0;
	screen->endSel.row = MaxRows(screen);
	screen->endSel.col = 0;
	break;

    case Select_ALL:		/* counts scrollback if in normal screen */
	TRACE(("Select_ALL\n"));
	screen->startSel.row = -screen->savedlines;
	screen->startSel.col = 0;
	screen->endSel.row = MaxRows(screen);
	screen->endSel.col = 0;
	break;

#if OPT_SELECT_REGEX
    case Select_REGEX:
	do_select_regex(screen, &(screen->startSel), &(screen->endSel));
	break;
#endif

    case NSELECTUNITS:		/* always ignore */
	ignored = True;
	break;
    }

    if (!ignored) {
	/* check boundaries */
	ScrollSelection(screen, 0, False);
	TrackText(xw, &(screen->startSel), &(screen->endSel));
    }

    return;
}

/* Guaranteed (first.row, first.col) <= (last.row, last.col) */
static void
TrackText(XtermWidget xw,
	  const CELL *firstp,
	  const CELL *lastp)
{
    TScreen *screen = TScreenOf(xw);
    int from, to;
    CELL old_start, old_end;
    CELL first = *firstp;
    CELL last = *lastp;

    TRACE(("TrackText(first=%d,%d, last=%d,%d)\n",
	   first.row, first.col, last.row, last.col));

    old_start = screen->startH;
    old_end = screen->endH;
    TRACE(("...previous(first=%d,%d, last=%d,%d)\n",
	   old_start.row, old_start.col,
	   old_end.row, old_end.col));
    if (isSameCELL(&first, &old_start) &&
	isSameCELL(&last, &old_end)) {
	return;
    }

    screen->startH = first;
    screen->endH = last;
    from = Coordinate(screen, &screen->startH);
    to = Coordinate(screen, &screen->endH);
    if (to <= screen->startHCoord || from > screen->endHCoord) {
	/* No overlap whatsoever between old and new hilite */
	ReHiliteText(xw, &old_start, &old_end);
	ReHiliteText(xw, &first, &last);
    } else {
	if (from < screen->startHCoord) {
	    /* Extend left end */
	    ReHiliteText(xw, &first, &old_start);
	} else if (from > screen->startHCoord) {
	    /* Shorten left end */
	    ReHiliteText(xw, &old_start, &first);
	}
	if (to > screen->endHCoord) {
	    /* Extend right end */
	    ReHiliteText(xw, &old_end, &last);
	} else if (to < screen->endHCoord) {
	    /* Shorten right end */
	    ReHiliteText(xw, &last, &old_end);
	}
    }
    screen->startHCoord = from;
    screen->endHCoord = to;
}

/* Guaranteed that (first->row, first->col) <= (last->row, last->col) */
static void
ReHiliteText(XtermWidget xw,
	     CELL *firstp,
	     CELL *lastp)
{
    TScreen *screen = TScreenOf(xw);
    CELL first = *firstp;
    CELL last = *lastp;

    TRACE(("ReHiliteText from %d.%d to %d.%d\n",
	   first.row, first.col, last.row, last.col));

    if (first.row < 0)
	first.row = first.col = 0;
    else if (first.row > screen->max_row)
	return;			/* nothing to do, since last.row >= first.row */

    if (last.row < 0)
	return;			/* nothing to do, since first.row <= last.row */
    else if (last.row > screen->max_row) {
	last.row = screen->max_row;
	last.col = MaxCols(screen);
    }
    if (isSameCELL(&first, &last))
	return;

    if (!isSameRow(&first, &last)) {	/* do multiple rows */
	int i;
	if ((i = screen->max_col - first.col + 1) > 0) {	/* first row */
	    ScrnRefresh(xw, first.row, first.col, 1, i, True);
	}
	if ((i = last.row - first.row - 1) > 0) {	/* middle rows */
	    ScrnRefresh(xw, first.row + 1, 0, i, MaxCols(screen), True);
	}
	if (last.col > 0 && last.row <= screen->max_row) {	/* last row */
	    ScrnRefresh(xw, last.row, 0, 1, last.col, True);
	}
    } else {			/* do single row */
	ScrnRefresh(xw, first.row, first.col, 1, last.col - first.col, True);
    }
}

/*
 * Guaranteed that (cellc->row, cellc->col) <= (cell->row, cell->col),
 * and that both points are valid
 * (may have cell->row = screen->max_row+1, cell->col = 0).
 */
static void
SaltTextAway(XtermWidget xw,
	     CELL *cellc,
	     CELL *cell)
{
    TScreen *screen = TScreenOf(xw);
    int i, j = 0;
    int eol;
    Char *line;
    Char *lp;
    CELL first = *cellc;
    CELL last = *cell;

    if (isSameRow(&first, &last) && first.col > last.col) {
	int tmp;
	EXCHANGE(first.col, last.col, tmp);
    }

    --last.col;
    /* first we need to know how long the string is before we can save it */

    if (isSameRow(&last, &first)) {
	j = Length(screen, first.row, first.col, last.col);
    } else {			/* two cases, cut is on same line, cut spans multiple lines */
	j += Length(screen, first.row, first.col, screen->max_col) + 1;
	for (i = first.row + 1; i < last.row; i++)
	    j += Length(screen, i, 0, screen->max_col) + 1;
	if (last.col >= 0)
	    j += Length(screen, last.row, 0, last.col);
    }

    /* UTF-8 may require more space */
    if_OPT_WIDE_CHARS(screen, {
	j *= 4;
    });

    /* now get some memory to save it in */

    if (screen->selection_size <= j) {
	if ((line = (Char *) malloc((size_t) j + 1)) == 0)
	    SysError(ERROR_BMALLOC2);
	XtFree((char *) screen->selection_data);
	screen->selection_data = line;
	screen->selection_size = j + 1;
    } else {
	line = screen->selection_data;
    }

    if ((line == 0)
	|| (j < 0))
	return;

    line[j] = '\0';		/* make sure it is null terminated */
    lp = line;			/* lp points to where to save the text */
    if (isSameRow(&last, &first)) {
	lp = SaveText(screen, last.row, first.col, last.col, lp, &eol);
    } else {
	lp = SaveText(screen, first.row, first.col, screen->max_col, lp, &eol);
	if (eol)
	    *lp++ = '\n';	/* put in newline at end of line */
	for (i = first.row + 1; i < last.row; i++) {
	    lp = SaveText(screen, i, 0, screen->max_col, lp, &eol);
	    if (eol)
		*lp++ = '\n';
	}
	if (last.col >= 0)
	    lp = SaveText(screen, last.row, 0, last.col, lp, &eol);
    }
    *lp = '\0';			/* make sure we have end marked */

    TRACE(("Salted TEXT:%d:%s\n", (int) (lp - line),
	   visibleChars(line, (unsigned) (lp - line))));

    screen->selection_length = (unsigned long) (lp - line);
}

#if OPT_PASTE64
void
ClearSelectionBuffer(TScreen *screen)
{
    screen->selection_length = 0;
    screen->base64_count = 0;
}

static void
AppendStrToSelectionBuffer(TScreen *screen, Char *text, size_t len)
{
    if (len != 0) {
	int j = (int) (screen->selection_length + len);		/* New length */
	int k = j + (j >> 2) + 80;	/* New size if we grow buffer: grow by ~50% */
	if (j + 1 >= screen->selection_size) {
	    if (!screen->selection_length) {
		/* New buffer */
		Char *line;
		if ((line = (Char *) malloc((size_t) k)) == 0)
		    SysError(ERROR_BMALLOC2);
		XtFree((char *) screen->selection_data);
		screen->selection_data = line;
	    } else {
		/* Realloc buffer */
		screen->selection_data = (Char *)
		    realloc(screen->selection_data,
			    (size_t) k);
		if (screen->selection_data == 0)
		    SysError(ERROR_BMALLOC2);
	    }
	    screen->selection_size = k;
	}
	if (screen->selection_data != 0) {
	    memcpy(screen->selection_data + screen->selection_length, text, len);
	    screen->selection_length += len;
	    screen->selection_data[screen->selection_length] = 0;
	}
    }
}

void
AppendToSelectionBuffer(TScreen *screen, unsigned c)
{
    unsigned six;
    Char ch;

    /* Decode base64 character */
    if (c >= 'A' && c <= 'Z')
	six = c - 'A';
    else if (c >= 'a' && c <= 'z')
	six = c - 'a' + 26;
    else if (c >= '0' && c <= '9')
	six = c - '0' + 52;
    else if (c == '+')
	six = 62;
    else if (c == '/')
	six = 63;
    else
	return;

    /* Accumulate bytes */
    switch (screen->base64_count) {
    case 0:
	screen->base64_accu = six;
	screen->base64_count = 6;
	break;

    case 2:
	ch = CharOf((screen->base64_accu << 6) + six);
	screen->base64_count = 0;
	AppendStrToSelectionBuffer(screen, &ch, (size_t) 1);
	break;

    case 4:
	ch = CharOf((screen->base64_accu << 4) + (six >> 2));
	screen->base64_accu = (six & 0x3);
	screen->base64_count = 2;
	AppendStrToSelectionBuffer(screen, &ch, (size_t) 1);
	break;

    case 6:
	ch = CharOf((screen->base64_accu << 2) + (six >> 4));
	screen->base64_accu = (six & 0xF);
	screen->base64_count = 4;
	AppendStrToSelectionBuffer(screen, &ch, (size_t) 1);
	break;
    }
}

void
CompleteSelection(XtermWidget xw, String *args, Cardinal len)
{
    TScreen *screen = TScreenOf(xw);

    screen->base64_count = 0;
    screen->base64_accu = 0;
    _OwnSelection(xw, args, len);
}
#endif /* OPT_PASTE64 */

static Bool
_ConvertSelectionHelper(Widget w,
			Atom *type,
			XtPointer *value,
			unsigned long *length,
			Char *data,
			unsigned long remaining,
			int *format,
			int (*conversion_function) (Display *,
						    char **, int,
						    XICCEncodingStyle,
						    XTextProperty *),
			XICCEncodingStyle conversion_style)
{
    XtermWidget xw;

    *value = 0;
    *length = 0;
    *type = 0;
    *format = 0;

    if ((xw = getXtermWidget(w)) != 0) {
	TScreen *screen = TScreenOf(xw);
	Display *dpy = XtDisplay(w);
	XTextProperty textprop;
	int out_n = 0;
	char *result = 0;
	char *the_data = (char *) data;
	char *the_next;

	TRACE(("converting %ld:'%s'\n",
	       (long) screen->selection_length,
	       visibleChars(screen->selection_data, (unsigned) screen->selection_length)));
	/*
	 * For most selections, we can convert in one pass.  It is possible
	 * that some applications contain embedded nulls, e.g., using xterm's
	 * paste64 feature.  For those cases, we will build up the result in
	 * parts.
	 */
	if (memchr(the_data, 0, screen->selection_length) != 0) {
	    TRACE(("selection contains embedded nulls\n"));
	    result = calloc(screen->selection_length + 1, sizeof(char));
	}

      next_try:
	memset(&textprop, 0, sizeof(textprop));
	if (conversion_function(dpy, &the_data, 1,
				conversion_style,
				&textprop) >= Success) {
	    if ((result != 0)
		&& (textprop.value != 0)
		&& (textprop.format == 8)) {
		char *text_values = (char *) textprop.value;
		unsigned long in_n;

		if (out_n == 0) {
		    *value = result;
		    *type = textprop.encoding;
		    *format = textprop.format;
		}
		for (in_n = 0; in_n < textprop.nitems; ++in_n) {
		    result[out_n++] = text_values[in_n];
		}
		*length += textprop.nitems;
		if ((the_next = memchr(the_data, 0, remaining)) != 0) {
		    unsigned long this_was = (unsigned long) (the_next - the_data);
		    this_was++;
		    the_data += this_was;
		    remaining -= this_was;
		    result[out_n++] = 0;
		    *length += 1;
		    if (remaining)
			goto next_try;
		}
		return True;
	    } else {
		free(result);
		*value = (XtPointer) textprop.value;
		*length = textprop.nitems;
		*type = textprop.encoding;
		*format = textprop.format;
		return True;
	    }
	}
	free(result);
    }
    return False;
}

static Boolean
SaveConvertedLength(XtPointer *target, unsigned long source)
{
    Boolean result = False;

    *target = XtMalloc(4);
    if (*target != 0) {
	result = True;
	if (sizeof(unsigned long) == 4) {
	    *(unsigned long *) *target = source;
	} else if (sizeof(unsigned) == 4) {
	    *(unsigned *) *target = (unsigned) source;
	} else if (sizeof(unsigned short) == 4) {
	    *(unsigned short *) *target = (unsigned short) source;
	} else {
	    /* FIXME - does this depend on byte-order? */
	    unsigned long temp = source;
	    memcpy((char *) *target,
		   ((char *) &temp) + sizeof(temp) - 4,
		   (size_t) 4);
	}
    }
    return result;
}

#define keepClipboard(atom) ((screen->keepClipboard) && \
	 (atom == XInternAtom(screen->display, "CLIPBOARD", False)))

static Boolean
ConvertSelection(Widget w,
		 Atom *selection,
		 Atom *target,
		 Atom *type,
		 XtPointer *value,
		 unsigned long *length,
		 int *format)
{
    Display *dpy = XtDisplay(w);
    TScreen *screen;
    Bool result = False;

    Char *data;
    unsigned long data_length;

    XtermWidget xw;

    if ((xw = getXtermWidget(w)) == 0)
	return False;

    screen = TScreenOf(xw);

    TRACE(("ConvertSelection %s\n",
	   visibleSelectionTarget(dpy, *target)));

    if (keepClipboard(*selection)) {
	TRACE(("asked for clipboard\n"));
	data = screen->clipboard_data;
	data_length = screen->clipboard_size;
    } else {
	TRACE(("asked for selection\n"));
	data = screen->selection_data;
	data_length = screen->selection_length;
    }

    if (data == NULL) {
	TRACE(("...FIXME: no selection_data\n"));
	return False;		/* can this happen? */
    }

    if (*target == XA_TARGETS(dpy)) {
	Atom *targetP;
	XPointer std_return = 0;
	unsigned long std_length;

	if (XmuConvertStandardSelection(w, screen->selection_time, selection,
					target, type, &std_return,
					&std_length, format)) {
	    Atom *my_targets = _SelectionTargets(w);
	    Atom *allocP;
	    Atom *std_targets;

	    TRACE(("XmuConvertStandardSelection - success\n"));
	    std_targets = (Atom *) (void *) (std_return);
	    *length = std_length + 6;

	    targetP = TypeXtMallocN(Atom, *length);
	    allocP = targetP;

	    *value = (XtPointer) targetP;

	    if (my_targets != 0) {
		while (*my_targets != None) {
		    *targetP++ = *my_targets++;
		}
	    }
	    *targetP++ = XA_LENGTH(dpy);
	    *targetP++ = XA_LIST_LENGTH(dpy);

	    *length = std_length + (unsigned long) (targetP - allocP);

	    memcpy(targetP, std_targets, sizeof(Atom) * std_length);
	    XtFree((char *) std_targets);
	    *type = XA_ATOM;
	    *format = 32;
	    result = True;
	} else {
	    TRACE(("XmuConvertStandardSelection - failed\n"));
	}
    }
#if OPT_WIDE_CHARS
    else if (screen->wide_chars && *target == XA_STRING) {
	result =
	    _ConvertSelectionHelper(w,
				    type, value, length, data,
				    data_length, format,
				    Xutf8TextListToTextProperty,
				    XStringStyle);
	TRACE(("...Xutf8TextListToTextProperty:%d\n", result));
    } else if (screen->wide_chars && *target == XA_UTF8_STRING(dpy)) {
	result =
	    _ConvertSelectionHelper(w,
				    type, value, length, data,
				    data_length, format,
				    Xutf8TextListToTextProperty,
				    XUTF8StringStyle);
	TRACE(("...Xutf8TextListToTextProperty:%d\n", result));
    } else if (screen->wide_chars && *target == XA_TEXT(dpy)) {
	result =
	    _ConvertSelectionHelper(w,
				    type, value, length, data,
				    data_length, format,
				    Xutf8TextListToTextProperty,
				    XStdICCTextStyle);
	TRACE(("...Xutf8TextListToTextProperty:%d\n", result));
    } else if (screen->wide_chars && *target == XA_COMPOUND_TEXT(dpy)) {
	result =
	    _ConvertSelectionHelper(w,
				    type, value, length, data,
				    data_length, format,
				    Xutf8TextListToTextProperty,
				    XCompoundTextStyle);
	TRACE(("...Xutf8TextListToTextProperty:%d\n", result));
    }
#endif

    else if (*target == XA_STRING) {	/* not wide_chars */
	/* We can only reach this point if the selection requestor
	   requested STRING before any of TEXT, COMPOUND_TEXT or
	   UTF8_STRING.  We therefore assume that the requestor is not
	   properly internationalised, and dump raw eight-bit data
	   with no conversion into the selection.  Yes, this breaks
	   the ICCCM in non-Latin-1 locales. */
	*type = XA_STRING;
	*value = (XtPointer) screen->selection_data;
	*length = screen->selection_length;
	*format = 8;
	result = True;
	TRACE(("...raw 8-bit data:%d\n", result));
    } else if (*target == XA_TEXT(dpy)) {	/* not wide_chars */
	result =
	    _ConvertSelectionHelper(w,
				    type, value, length, data,
				    data_length, format,
				    XmbTextListToTextProperty,
				    XStdICCTextStyle);
	TRACE(("...XmbTextListToTextProperty(StdICC):%d\n", result));
    } else if (*target == XA_COMPOUND_TEXT(dpy)) {	/* not wide_chars */
	result =
	    _ConvertSelectionHelper(w,
				    type, value, length, data,
				    data_length, format,
				    XmbTextListToTextProperty,
				    XCompoundTextStyle);
	TRACE(("...XmbTextListToTextProperty(Compound):%d\n", result));
    }
#ifdef X_HAVE_UTF8_STRING
    else if (*target == XA_UTF8_STRING(dpy)) {	/* not wide_chars */
	result =
	    _ConvertSelectionHelper(w,
				    type, value, length, data,
				    data_length, format,
				    XmbTextListToTextProperty,
				    XUTF8StringStyle);
	TRACE(("...XmbTextListToTextProperty(UTF8):%d\n", result));
    }
#endif
    else if (*target == XA_LIST_LENGTH(dpy)) {
	result = SaveConvertedLength(value, (unsigned long) 1);
	*type = XA_INTEGER;
	*length = 1;
	*format = 32;
	TRACE(("...list of values:%d\n", result));
    } else if (*target == XA_LENGTH(dpy)) {
	/* This value is wrong if we have UTF-8 text */
	result = SaveConvertedLength(value, screen->selection_length);
	*type = XA_INTEGER;
	*length = 1;
	*format = 32;
	TRACE(("...list of values:%d\n", result));
    } else if (XmuConvertStandardSelection(w,
					   screen->selection_time, selection,
					   target, type, (XPointer *) value,
					   length, format)) {
	result = True;
	TRACE(("...XmuConvertStandardSelection:%d\n", result));
    }

    /* else */
    return (Boolean) result;
}

static void
LoseSelection(Widget w, Atom *selection)
{
    TScreen *screen;
    Atom *atomP;
    Cardinal i;

    XtermWidget xw;

    if ((xw = getXtermWidget(w)) == 0)
	return;

    screen = TScreenOf(xw);
    TRACE(("LoseSelection %s\n", TraceAtomName(screen->display, *selection)));

    for (i = 0, atomP = screen->selection_atoms;
	 i < screen->selection_count; i++, atomP++) {
	if (*selection == *atomP)
	    *atomP = (Atom) 0;
	if (CutBuffer(*atomP) >= 0) {
	    *atomP = (Atom) 0;
	}
    }

    for (i = screen->selection_count; i; i--) {
	if (screen->selection_atoms[i - 1] != 0)
	    break;
    }
    screen->selection_count = i;

    for (i = 0, atomP = screen->selection_atoms;
	 i < screen->selection_count; i++, atomP++) {
	if (*atomP == (Atom) 0) {
	    *atomP = screen->selection_atoms[--screen->selection_count];
	}
    }

    if (screen->selection_count == 0)
	TrackText(xw, &zeroCELL, &zeroCELL);
}

/* ARGSUSED */
static void
SelectionDone(Widget w GCC_UNUSED,
	      Atom *selection GCC_UNUSED,
	      Atom *target GCC_UNUSED)
{
    /* empty proc so Intrinsics know we want to keep storage */
    TRACE(("SelectionDone\n"));
}

static void
_OwnSelection(XtermWidget xw,
	      String *selections,
	      Cardinal count)
{
    TScreen *screen = TScreenOf(xw);
    Atom *atoms = screen->selection_atoms;
    Cardinal i;
    Bool have_selection = False;

    if (count == 0)
	return;

    TRACE(("_OwnSelection count %d, length %ld value %s\n", count,
	   screen->selection_length,
	   visibleChars(screen->selection_data, (unsigned) screen->selection_length)));
    selections = MapSelections(xw, selections, count);

    if (count > screen->sel_atoms_size) {
	XtFree((char *) atoms);
	atoms = TypeXtMallocN(Atom, count);
	screen->selection_atoms = atoms;
	screen->sel_atoms_size = count;
    }
    XmuInternStrings(XtDisplay((Widget) xw), selections, count, atoms);
    for (i = 0; i < count; i++) {
	int cutbuffer = CutBuffer(atoms[i]);
	if (cutbuffer >= 0) {
	    unsigned long limit =
	    (unsigned long) (4 * XMaxRequestSize(XtDisplay((Widget) xw)) - 32);
	    if (screen->selection_length > limit) {
		TRACE(("selection too big (%lu bytes), not storing in CUT_BUFFER%d\n",
		       screen->selection_length, cutbuffer));
		xtermWarning("selection too big (%lu bytes), not storing in CUT_BUFFER%d\n",
			     screen->selection_length, cutbuffer);
	    } else {
		/* This used to just use the UTF-8 data, which was totally
		 * broken as not even the corresponding paste code in xterm
		 * understood this!  So now it converts to Latin1 first.
		 *   Robert Brady, 2000-09-05
		 */
		unsigned long length = screen->selection_length;
		Char *data = screen->selection_data;
		if_OPT_WIDE_CHARS((screen), {
		    data = UTF8toLatin1(screen, data, length, &length);
		});
		TRACE(("XStoreBuffer(%d)\n", cutbuffer));
		XStoreBuffer(XtDisplay((Widget) xw),
			     (char *) data,
			     (int) length,
			     cutbuffer);
	    }
	} else if (keepClipboard(atoms[i])) {
	    Char *buf;
	    TRACE(("saving selection to clipboard buffer\n"));
	    if ((buf = (Char *) malloc((size_t) screen->selection_length))
		== 0)
		SysError(ERROR_BMALLOC2);

	    XtFree((char *) screen->clipboard_data);
	    memcpy(buf, screen->selection_data, screen->selection_length);
	    screen->clipboard_data = buf;
	    screen->clipboard_size = screen->selection_length;
	} else if (screen->selection_length == 0) {
	    XtDisownSelection((Widget) xw, atoms[i], screen->selection_time);
	} else if (!screen->replyToEmacs) {
	    have_selection |=
		XtOwnSelection((Widget) xw, atoms[i],
			       screen->selection_time,
			       ConvertSelection, LoseSelection, SelectionDone);
	}
    }
    if (!screen->replyToEmacs)
	screen->selection_count = count;
    if (!have_selection)
	TrackText(xw, &zeroCELL, &zeroCELL);
}

static void
ResetSelectionState(TScreen *screen)
{
    screen->selection_count = 0;
    screen->startH = zeroCELL;
    screen->endH = zeroCELL;
}

void
DisownSelection(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);
    Atom *atoms = screen->selection_atoms;
    Cardinal count = screen->selection_count;
    Cardinal i;

    TRACE(("DisownSelection count %d, start %d.%d, end %d.%d\n",
	   count,
	   screen->startH.row,
	   screen->startH.col,
	   screen->endH.row,
	   screen->endH.col));

    for (i = 0; i < count; i++) {
	int cutbuffer = CutBuffer(atoms[i]);
	if (cutbuffer < 0) {
	    XtDisownSelection((Widget) xw, atoms[i],
			      screen->selection_time);
	}
    }
    /*
     * If none of the callbacks via XtDisownSelection() reset highlighting
     * do it now.
     */
    if (ScrnHaveSelection(screen)) {
	/* save data which will be reset */
	CELL first = screen->startH;
	CELL last = screen->endH;

	ResetSelectionState(screen);
	ReHiliteText(xw, &first, &last);
    } else {
	ResetSelectionState(screen);
    }
}

void
UnhiliteSelection(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);

    if (ScrnHaveSelection(screen)) {
	CELL first = screen->startH;
	CELL last = screen->endH;

	screen->startH = zeroCELL;
	screen->endH = zeroCELL;
	ReHiliteText(xw, &first, &last);
    }
}

/* returns number of chars in line from scol to ecol out */
/* ARGSUSED */
static int
Length(TScreen *screen,
       int row,
       int scol,
       int ecol)
{
    CLineData *ld = GET_LINEDATA(screen, row);
    const int lastcol = LastTextCol(screen, ld, row);

    if (ecol > lastcol)
	ecol = lastcol;
    return (ecol - scol + 1);
}

/* copies text into line, preallocated */
static Char *
SaveText(TScreen *screen,
	 int row,
	 int scol,
	 int ecol,
	 Char *lp,		/* pointer to where to put the text */
	 int *eol)
{
    LineData *ld;
    int i = 0;
    Char *result = lp;
#if OPT_WIDE_CHARS
    unsigned previous = 0;
#endif

    ld = GET_LINEDATA(screen, row);
    i = Length(screen, row, scol, ecol);
    ecol = scol + i;
#if OPT_DEC_CHRSET
    if (CSET_DOUBLE(GetLineDblCS(ld))) {
	scol = (scol + 0) / 2;
	ecol = (ecol + 1) / 2;
    }
#endif
    *eol = !LineTstWrapped(ld);
    for (i = scol; i < ecol; i++) {
	unsigned c;
	assert(i < (int) ld->lineSize);
	c = E2A(ld->charData[i]);
#if OPT_WIDE_CHARS
	/* We want to strip out every occurrence of HIDDEN_CHAR AFTER a
	 * wide character.
	 */
	if (c == HIDDEN_CHAR) {
	    if (isWide((int) previous)) {
		previous = c;
		/* Combining characters attached to double-width characters
		   are in memory attached to the HIDDEN_CHAR */
		if_OPT_WIDE_CHARS(screen, {
		    if ((screen->utf8_nrc_mode | screen->utf8_mode) != uFalse) {
			size_t off;
			for_each_combData(off, ld) {
			    unsigned ch = ld->combData[off][i];
			    if (ch == 0)
				break;
			    lp = convertToUTF8(lp, ch);
			}
		    }
		});
		continue;
	    } else {
		c = ' ';	/* should not happen, but just in case... */
	    }
	}
	previous = c;
	if ((screen->utf8_nrc_mode | screen->utf8_mode) != uFalse) {
	    lp = convertToUTF8(lp, (c != 0) ? c : ' ');
	    if_OPT_WIDE_CHARS(screen, {
		size_t off;
		for_each_combData(off, ld) {
		    unsigned ch = ld->combData[off][i];
		    if (ch == 0)
			break;
		    lp = convertToUTF8(lp, ch);
		}
	    });
	} else
#endif
	{
	    if (c == 0) {
		c = E2A(' ');
	    } else if (c < E2A(' ')) {
		c = DECtoASCII(c);
	    } else if (c == 0x7f) {
		c = 0x5f;
	    }
	    *lp++ = CharOf(A2E(c));
	}
	if (c != E2A(' '))
	    result = lp;
    }

    /*
     * If requested, trim trailing blanks from selected lines.  Do not do this
     * if the line is wrapped.
     */
    if (!*eol || !screen->trim_selection)
	result = lp;

    return (result);
}

/* 32 + following 7-bit word:

   1:0  Button no: 0, 1, 2.  3=release.
     2  shift
     3  meta
     4  ctrl
     5  set for motion notify
     6  set for wheel
*/

/* Position: 32 - 255. */
static int
BtnCode(XButtonEvent *event, int button)
{
    int result = (int) (32 + (KeyState(event->state) << 2));

    if (event->type == MotionNotify)
	result += 32;

    if (button < 0 || button > 5) {
	result += 3;
    } else {
	if (button > 3)
	    result += (64 - 4);
	result += button;
    }
    TRACE(("BtnCode button %d, %s state " FMT_MODIFIER_NAMES " ->%#x\n",
	   button,
	   visibleEventType(event->type),
	   ARG_MODIFIER_NAMES(event->state),
	   result));
    return result;
}

static unsigned
EmitButtonCode(XtermWidget xw,
	       Char *line,
	       unsigned count,
	       XButtonEvent *event,
	       int button)
{
    TScreen *screen = TScreenOf(xw);
    int value;

    if (okSendMousePos(xw) == X10_MOUSE) {
	value = CharOf(' ' + button);
    } else {
	value = BtnCode(event, button);
    }

    switch (screen->extend_coords) {
    default:
	line[count++] = CharOf(value);
	break;
    case SET_SGR_EXT_MODE_MOUSE:
	value -= 32;		/* encoding starts at zero */
	/* FALLTHRU */
    case SET_URXVT_EXT_MODE_MOUSE:
	count += (unsigned) sprintf((char *) line + count, "%d", value);
	break;
    case SET_EXT_MODE_MOUSE:
	if (value < 128) {
	    line[count++] = CharOf(value);
	} else {
	    line[count++] = CharOf(0xC0 + (value >> 6));
	    line[count++] = CharOf(0x80 + (value & 0x3F));
	}
	break;
    }
    return count;
}

static int
FirstBitN(int bits)
{
    int result = -1;
    if (bits > 0) {
	result = 0;
	while (!(bits & 1)) {
	    bits /= 2;
	    ++result;
	}
    }
    return result;
}

#define ButtonBit(button) ((button >= 0) ? (1 << (button)) : 0)

#define EMIT_BUTTON(button) EmitButtonCode(xw, line, count, event, button)

static void
EditorButton(XtermWidget xw, XButtonEvent *event)
{
    TScreen *screen = TScreenOf(xw);
    int pty = screen->respond;
    int mouse_limit = MouseLimit(screen);
    Char line[32];
    Char final = 'M';
    int row, col;
    int button;
    unsigned count = 0;
    Boolean changed = True;

    /* If button event, get button # adjusted for DEC compatibility */
    button = (int) (event->button - 1);
    if (button >= 3)
	button++;

    /* Compute character position of mouse pointer */
    row = (event->y - screen->border) / FontHeight(screen);
    col = (event->x - OriginX(screen)) / FontWidth(screen);

    /* Limit to screen dimensions */
    if (row < 0)
	row = 0;
    else if (row > screen->max_row)
	row = screen->max_row;

    if (col < 0)
	col = 0;
    else if (col > screen->max_col)
	col = screen->max_col;

    if (mouse_limit > 0) {
	/* Limit to representable mouse dimensions */
	if (row > mouse_limit)
	    row = mouse_limit;
	if (col > mouse_limit)
	    col = mouse_limit;
    }

    /* Build key sequence starting with \E[M */
    if (screen->control_eight_bits) {
	line[count++] = ANSI_CSI;
    } else {
	line[count++] = ANSI_ESC;
	line[count++] = '[';
    }
    switch (screen->extend_coords) {
    case 0:
    case SET_EXT_MODE_MOUSE:
#if OPT_SCO_FUNC_KEYS
	if (xw->keyboard.type == keyboardIsSCO) {
	    /*
	     * SCO function key F1 is \E[M, which would conflict with xterm's
	     * normal kmous.
	     */
	    line[count++] = '>';
	}
#endif
	line[count++] = final;
	break;
    case SET_SGR_EXT_MODE_MOUSE:
	line[count++] = '<';
	break;
    }

    /* Add event code to key sequence */
    if (okSendMousePos(xw) == X10_MOUSE) {
	count = EMIT_BUTTON(button);
    } else {
	/* Button-Motion events */
	switch (event->type) {
	case ButtonPress:
	    screen->mouse_button |= ButtonBit(button);
	    count = EMIT_BUTTON(button);
	    break;
	case ButtonRelease:
	    /*
	     * Wheel mouse interface generates release-events for buttons
	     * 4 and 5, coded here as 3 and 4 respectively.  We change the
	     * release for buttons 1..3 to a -1, which will be later mapped
	     * into a "0" (some button was released).
	     */
	    screen->mouse_button &= ~ButtonBit(button);
	    if (button < 3) {
		switch (screen->extend_coords) {
		case SET_SGR_EXT_MODE_MOUSE:
		    final = 'm';
		    break;
		default:
		    button = -1;
		    break;
		}
	    }
	    count = EMIT_BUTTON(button);
	    break;
	case MotionNotify:
	    /* BTN_EVENT_MOUSE and ANY_EVENT_MOUSE modes send motion
	     * events only if character cell has changed.
	     */
	    if ((row == screen->mouse_row)
		&& (col == screen->mouse_col)) {
		changed = False;
	    } else {
		count = EMIT_BUTTON(FirstBitN(screen->mouse_button));
	    }
	    break;
	default:
	    changed = False;
	    break;
	}
    }

    if (changed) {
	screen->mouse_row = row;
	screen->mouse_col = col;

	TRACE(("mouse at %d,%d button+mask = %#x\n", row, col, line[count - 1]));

	/* Add pointer position to key sequence */
	count = EmitMousePositionSeparator(screen, line, count);
	count = EmitMousePosition(screen, line, count, col);
	count = EmitMousePositionSeparator(screen, line, count);
	count = EmitMousePosition(screen, line, count, row);

	switch (screen->extend_coords) {
	case SET_SGR_EXT_MODE_MOUSE:
	case SET_URXVT_EXT_MODE_MOUSE:
	    line[count++] = final;
	    break;
	}

	/* Transmit key sequence to process running under xterm */
	v_write(pty, line, count);
    }
    return;
}

/*
 * Check the current send_mouse_pos against allowed mouse-operations, returning
 * none if it is disallowed.
 */
XtermMouseModes
okSendMousePos(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);
    XtermMouseModes result = screen->send_mouse_pos;

    switch (result) {
    case MOUSE_OFF:
	break;
    case X10_MOUSE:
	if (!AllowMouseOps(xw, emX10))
	    result = MOUSE_OFF;
	break;
    case VT200_MOUSE:
	if (!AllowMouseOps(xw, emVT200Click))
	    result = MOUSE_OFF;
	break;
    case VT200_HIGHLIGHT_MOUSE:
	if (!AllowMouseOps(xw, emVT200Hilite))
	    result = MOUSE_OFF;
	break;
    case BTN_EVENT_MOUSE:
	if (!AllowMouseOps(xw, emAnyButton))
	    result = MOUSE_OFF;
	break;
    case ANY_EVENT_MOUSE:
	if (!AllowMouseOps(xw, emAnyEvent))
	    result = MOUSE_OFF;
	break;
    case DEC_LOCATOR:
	if (!AllowMouseOps(xw, emLocator))
	    result = MOUSE_OFF;
	break;
    }
    return result;
}

#if OPT_FOCUS_EVENT
/*
 * Check the current send_focus_pos against allowed mouse-operations, returning
 * none if it is disallowed.
 */
static int
okSendFocusPos(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);
    int result = screen->send_focus_pos;

    if (!AllowMouseOps(xw, emFocusEvent)) {
	result = False;
    }
    return result;
}

void
SendFocusButton(XtermWidget xw, XFocusChangeEvent *event)
{
    if (okSendFocusPos(xw)) {
	ANSI reply;

	memset(&reply, 0, sizeof(reply));
	reply.a_type = ANSI_CSI;

#if OPT_SCO_FUNC_KEYS
	if (xw->keyboard.type == keyboardIsSCO) {
	    reply.a_pintro = '>';
	}
#endif
	reply.a_final = CharOf((event->type == FocusIn) ? 'I' : 'O');
	unparseseq(xw, &reply);
    }
    return;
}
#endif /* OPT_FOCUS_EVENT */

#if OPT_SELECTION_OPS
/*
 * Get the event-time, needed to process selections.
 */
static Time
getEventTime(XEvent *event)
{
    Time result;

    if (IsBtnEvent(event)) {
	result = ((XButtonEvent *) event)->time;
    } else if (IsKeyEvent(event)) {
	result = ((XKeyEvent *) event)->time;
    } else {
	result = 0;
    }

    return result;
}

/* obtain the selection string, passing the endpoints to caller's parameters */
static void
doSelectionFormat(XtermWidget xw,
		  Widget w,
		  XEvent *event,
		  String *params,
		  Cardinal *num_params,
		  FormatSelect format_select)
{
    TScreen *screen = TScreenOf(xw);
    InternalSelect *mydata = &(screen->internal_select);

    memset(mydata, 0, sizeof(*mydata));
    mydata->format = x_strdup(params[0]);
    mydata->format_select = format_select;

    /* override flags so that SelectionReceived only updates a buffer */
#if OPT_PASTE64
    mydata->base64_paste = screen->base64_paste;
    screen->base64_paste = 0;
#endif
#if OPT_READLINE
    mydata->paste_brackets = screen->paste_brackets;
    SCREEN_FLAG_unset(screen, paste_brackets);
#endif

    screen->selectToBuffer = True;
    xtermGetSelection(w, getEventTime(event), params + 1, *num_params - 1, NULL);
}

/* obtain data from the screen, passing the endpoints to caller's parameters */
static char *
getDataFromScreen(XtermWidget xw, XEvent *event, String method, CELL *start, CELL *finish)
{
    TScreen *screen = TScreenOf(xw);

    CELL save_old_start = screen->startH;
    CELL save_old_end = screen->endH;

    CELL save_startSel = screen->startSel;
    CELL save_startRaw = screen->startRaw;
    CELL save_finishSel = screen->endSel;
    CELL save_finishRaw = screen->endRaw;

    int save_firstValidRow = screen->firstValidRow;
    int save_lastValidRow = screen->lastValidRow;

    const Cardinal noClick = 0;
    int save_numberOfClicks = screen->numberOfClicks;

    SelectUnit saveUnits = screen->selectUnit;
    SelectUnit saveMap = screen->selectMap[noClick];
#if OPT_SELECT_REGEX
    char *saveExpr = screen->selectExpr[noClick];
#endif

    Char *save_selection_data = screen->selection_data;
    int save_selection_size = screen->selection_size;
    unsigned long save_selection_length = screen->selection_length;

    char *result = 0;

    TRACE(("getDataFromScreen %s\n", method));

    screen->selection_data = 0;
    screen->selection_size = 0;
    screen->selection_length = 0;

    screen->numberOfClicks = 1;
    lookupSelectUnit(xw, noClick, method);
    screen->selectUnit = screen->selectMap[noClick];

    memset(start, 0, sizeof(*start));
    if (IsBtnEvent(event)) {
	XButtonEvent *btn_event = (XButtonEvent *) event;
	CELL cell;
	screen->firstValidRow = 0;
	screen->lastValidRow = screen->max_row;
	PointToCELL(screen, btn_event->y, btn_event->x, &cell);
	start->row = cell.row;
	start->col = cell.col;
	finish->row = cell.row;
	finish->col = screen->max_col;
    } else {
	start->row = screen->cur_row;
	start->col = screen->cur_col;
	finish->row = screen->cur_row;
	finish->col = screen->max_col;
    }

    ComputeSelect(xw, start, finish, False);
    SaltTextAway(xw, &(screen->startSel), &(screen->endSel));

    if (screen->selection_length && screen->selection_data) {
	TRACE(("...getDataFromScreen selection_data %.*s\n",
	       (int) screen->selection_length,
	       screen->selection_data));
	result = malloc(screen->selection_length + 1);
	if (result) {
	    memcpy(result, screen->selection_data, screen->selection_length);
	    result[screen->selection_length] = 0;
	}
	free(screen->selection_data);
    }

    TRACE(("...getDataFromScreen restoring previous selection\n"));

    screen->startSel = save_startSel;
    screen->startRaw = save_startRaw;
    screen->endSel = save_finishSel;
    screen->endRaw = save_finishRaw;

    screen->firstValidRow = save_firstValidRow;
    screen->lastValidRow = save_lastValidRow;

    screen->numberOfClicks = save_numberOfClicks;
    screen->selectUnit = saveUnits;
    screen->selectMap[noClick] = saveMap;
#if OPT_SELECT_REGEX
    screen->selectExpr[noClick] = saveExpr;
#endif

    screen->selection_data = save_selection_data;
    screen->selection_size = save_selection_size;
    screen->selection_length = save_selection_length;

    TrackText(xw, &save_old_start, &save_old_end);

    TRACE(("...getDataFromScreen done\n"));
    return result;
}

/*
 * Split-up the format before substituting data, to avoid quoting issues.
 * The resource mechanism has a limited ability to handle escapes.  We take
 * the result as if it were an sh-type string and parse it into a regular
 * argv array.
 */
static char **
tokenizeFormat(String format)
{
    char **result = 0;
    int argc;

    format = x_skip_blanks(format);
    if (*format != '\0') {
	char *blob = x_strdup(format);
	int pass;

	for (pass = 0; pass < 2; ++pass) {
	    int used = 0;
	    int first = 1;
	    int escaped = 0;
	    int squoted = 0;
	    int dquoted = 0;
	    int n;

	    argc = 0;
	    for (n = 0; format[n] != '\0'; ++n) {
		if (escaped) {
		    blob[used++] = format[n];
		    escaped = 0;
		} else if (format[n] == '"') {
		    if (!squoted) {
			if (!dquoted)
			    blob[used++] = format[n];
			dquoted = !dquoted;
		    }
		} else if (format[n] == '\'') {
		    if (!dquoted) {
			if (!squoted)
			    blob[used++] = format[n];
			squoted = !squoted;
		    }
		} else if (format[n] == '\\') {
		    blob[used++] = format[n];
		    escaped = 1;
		} else {
		    if (first) {
			first = 0;
			if (pass) {
			    result[argc] = &blob[n];
			}
			++argc;
		    }
		    if (isspace((Char) format[n])) {
			first = !isspace((Char) format[n + 1]);
			if (squoted || dquoted) {
			    blob[used++] = format[n];
			} else if (first) {
			    blob[used++] = '\0';
			}
		    } else {
			blob[used++] = format[n];
		    }
		}
	    }
	    blob[used] = '\0';
	    assert(strlen(blob) <= strlen(format));
	    if (!pass) {
		result = TypeCallocN(char *, argc + 1);
		if (result == 0) {
		    free(blob);
		    break;
		}
	    }
	}
    }
#if OPT_TRACE
    if (result) {
	TRACE(("tokenizeFormat %s\n", format));
	for (argc = 0; result[argc]; ++argc) {
	    TRACE(("argv[%d] = %s\n", argc, result[argc]));
	}
    }
#endif

    return result;
}

static void
formatVideoAttrs(XtermWidget xw, char *buffer, CELL *cell)
{
    TScreen *screen = TScreenOf(xw);
    LineData *ld = GET_LINEDATA(screen, cell->row);

    *buffer = '\0';
    if (ld != 0 && cell->col < (int) ld->lineSize) {
	IAttr attribs = ld->attribs[cell->col];
	const char *delim = "";

	if (attribs & INVERSE) {
	    buffer += sprintf(buffer, "7");
	    delim = ";";
	}
	if (attribs & UNDERLINE) {
	    buffer += sprintf(buffer, "%s4", delim);
	    delim = ";";
	}
	if (attribs & BOLD) {
	    buffer += sprintf(buffer, "%s1", delim);
	    delim = ";";
	}
	if (attribs & BLINK) {
	    buffer += sprintf(buffer, "%s5", delim);
	    delim = ";";
	}
#if OPT_ISO_COLORS
	if (attribs & FG_COLOR) {
	    unsigned fg = extract_fg(xw, ld->color[cell->col], attribs);
	    if (fg < 8) {
		fg += 30;
	    } else if (fg < 16) {
		fg += 90;
	    } else {
		buffer += sprintf(buffer, "%s38;5", delim);
		delim = ";";
	    }
	    buffer += sprintf(buffer, "%s%u", delim, fg);
	    delim = ";";
	}
	if (attribs & BG_COLOR) {
	    unsigned bg = extract_bg(xw, ld->color[cell->col], attribs);
	    if (bg < 8) {
		bg += 40;
	    } else if (bg < 16) {
		bg += 100;
	    } else {
		buffer += sprintf(buffer, "%s48;5", delim);
		delim = ";";
	    }
	    (void) sprintf(buffer, "%s%u", delim, bg);
	}
#endif
    }
}

static char *
formatStrlen(char *target, char *source, int freeit)
{
    if (source != 0) {
	sprintf(target, "%u", (unsigned) strlen(source));
	if (freeit) {
	    free(source);
	}
    } else {
	strcpy(target, "0");
    }
    return target;
}

/* substitute data into format, reallocating the result */
static char *
expandFormat(XtermWidget xw,
	     const char *format,
	     char *data,
	     CELL *start,
	     CELL *finish)
{
    char *result = 0;
    if (!IsEmpty(format)) {
	static char empty[1];
	int pass;
	int n;
	char numbers[80];

	if (data == 0)
	    data = empty;

	for (pass = 0; pass < 2; ++pass) {
	    size_t need = 0;

	    for (n = 0; format[n] != '\0'; ++n) {

		if (format[n] == '%') {
		    char *value = 0;

		    switch (format[++n]) {
		    case '%':
			if (pass) {
			    result[need] = format[n];
			}
			++need;
			break;
		    case 'P':
			sprintf(numbers, "%d;%d",
				TScreenOf(xw)->topline + start->row + 1,
				start->col + 1);
			value = numbers;
			break;
		    case 'p':
			sprintf(numbers, "%d;%d",
				TScreenOf(xw)->topline + finish->row + 1,
				finish->col + 1);
			value = numbers;
			break;
		    case 'R':
			value = formatStrlen(numbers, x_strrtrim(data), 1);
			break;
		    case 'r':
			value = x_strrtrim(data);
			break;
		    case 'S':
			value = formatStrlen(numbers, data, 0);
			break;
		    case 's':
			value = data;
			break;
		    case 'T':
			value = formatStrlen(numbers, x_strtrim(data), 1);
			break;
		    case 't':
			value = x_strtrim(data);
			break;
		    case 'V':
			formatVideoAttrs(xw, numbers, start);
			value = numbers;
			break;
		    case 'v':
			formatVideoAttrs(xw, numbers, finish);
			value = numbers;
			break;
		    default:
			if (pass) {
			    result[need] = format[n];
			}
			--n;
			++need;
			break;
		    }
		    if (value != 0) {
			if (pass) {
			    strcpy(result + need, value);
			}
			need += strlen(value);
			if (value != numbers && value != data) {
			    free(value);
			}
		    }
		} else {
		    if (pass) {
			result[need] = format[n];
		    }
		    ++need;
		}
	    }
	    if (pass) {
		result[need] = '\0';
	    } else {
		++need;
		result = malloc(need);
		if (result == 0) {
		    break;
		}
	    }
	}
    }
    TRACE(("expandFormat(%s) = %s\n", NonNull(format), NonNull(result)));
    return result;
}

/* execute the command after forking.  The main process frees its data */
static void
executeCommand(pid_t pid, char **argv)
{
    (void) pid;
    if (argv != 0 && argv[0] != 0) {
	char *child_cwd = ProcGetCWD(pid);

	if (fork() == 0) {
	    if (child_cwd) {
		IGNORE_RC(chdir(child_cwd));	/* We don't care if this fails */
	    }
	    execvp(argv[0], argv);
	    exit(EXIT_FAILURE);
	}
	free(child_cwd);
    }
}

static void
freeArgv(char *blob, char **argv)
{
    if (blob) {
	free(blob);
	if (argv) {
	    int n;
	    for (n = 0; argv[n]; ++n)
		free(argv[n]);
	    free(argv);
	}
    }
}

static void
reallyExecFormatted(Widget w, char *format, char *data, CELL *start, CELL *finish)
{
    XtermWidget xw;

    if ((xw = getXtermWidget(w)) != 0) {
	char **argv;

	if ((argv = tokenizeFormat(format)) != 0) {
	    char *blob = argv[0];
	    int argc;

	    for (argc = 0; argv[argc] != 0; ++argc) {
		argv[argc] = expandFormat(xw, argv[argc], data, start, finish);
	    }
	    executeCommand(TScreenOf(xw)->pid, argv);
	    freeArgv(blob, argv);
	}
    }
}

void
HandleExecFormatted(Widget w,
		    XEvent *event,
		    String *params,	/* selections */
		    Cardinal *num_params)
{
    XtermWidget xw;

    TRACE(("HandleExecFormatted(%d)\n", *num_params));
    if ((xw = getXtermWidget(w)) != 0 &&
	(*num_params > 1)) {
	doSelectionFormat(xw, w, event, params, num_params, reallyExecFormatted);
    }
}

void
HandleExecSelectable(Widget w,
		     XEvent *event,
		     String *params,	/* selections */
		     Cardinal *num_params)
{
    XtermWidget xw;

    if ((xw = getXtermWidget(w)) != 0) {
	TRACE(("HandleExecSelectable(%d)\n", *num_params));

	if (*num_params == 2) {
	    CELL start, finish;
	    char *data;
	    char **argv;

	    data = getDataFromScreen(xw, event, params[1], &start, &finish);
	    if (data != 0) {
		if ((argv = tokenizeFormat(params[0])) != 0) {
		    char *blob = argv[0];
		    int argc;

		    for (argc = 0; argv[argc] != 0; ++argc) {
			argv[argc] = expandFormat(xw, argv[argc], data,
						  &start, &finish);
		    }
		    executeCommand(TScreenOf(xw)->pid, argv);
		    freeArgv(blob, argv);
		}
		free(data);
	    }
	}
    }
}

static void
reallyInsertFormatted(Widget w, char *format, char *data, CELL *start, CELL *finish)
{
    XtermWidget xw;

    if ((xw = getXtermWidget(w)) != 0) {
	char *exps;

	if ((exps = expandFormat(xw, format, data, start, finish)) != 0) {
	    unparseputs(xw, exps);
	    unparse_end(xw);
	    free(exps);
	}
    }
}

void
HandleInsertFormatted(Widget w,
		      XEvent *event,
		      String *params,	/* selections */
		      Cardinal *num_params)
{
    XtermWidget xw;

    TRACE(("HandleInsertFormatted(%d)\n", *num_params));
    if ((xw = getXtermWidget(w)) != 0 &&
	(*num_params > 1)) {
	doSelectionFormat(xw, w, event, params, num_params, reallyInsertFormatted);
    }
}

void
HandleInsertSelectable(Widget w,
		       XEvent *event,
		       String *params,	/* selections */
		       Cardinal *num_params)
{
    XtermWidget xw;

    if ((xw = getXtermWidget(w)) != 0) {
	TRACE(("HandleInsertSelectable(%d)\n", *num_params));

	if (*num_params == 2) {
	    CELL start, finish;
	    char *data;
	    char *temp = x_strdup(params[0]);

	    data = getDataFromScreen(xw, event, params[1], &start, &finish);
	    if (data != 0) {
		char *exps = expandFormat(xw, temp, data, &start, &finish);
		if (exps != 0) {
		    unparseputs(xw, exps);
		    unparse_end(xw);
		    free(exps);
		}
		free(data);
	    }
	    free(temp);
	}
    }
}
#endif /* OPT_SELECTION_OPS */
xterm-330/unicode/0000755000175100001440000000000012720410407012662 5ustar  tomusersxterm-330/unicode/keysym.map0000644000175100001440000010072712720410407014711 0ustar  tomusers# $XTermId: keysym.map,v 1.9 2016/05/22 20:05:27 tom Exp $
#
# This list can be used to convert X11 Keysyms to Unicode 2.1 character.
# The list is not checked for correctness by Unicode officials.  Use it
# at your own risk and the creator is not responsible for any damage that
# occurred due to using this list.
#
# The list is created by looking at the Keysym names and the Unicode data
# file.  Other mapping tables were used as a reference where needed.
# Due to a lack of knowledge of the Hebrew, Thai and Hangul symbols,
# expect errors in these sections.  The mapping of the keypad keys
# might also require some adjustments.
#
# The following fields are used:
# 1    The X11 keysym numbers from the include file keysymdef.h
# 2    The Unicode (2.1) position (U0000 means unknown Unicode position)
# #
# 3    the name of the X11 keysym (without XK_)
#
# Authors:  Richard Verhoeven, TUE, 
#           Markus Kuhn, University of Cambridge, 
#
# You are free to use and modify this table.  If you introduce errors
# in the table, please remove the copyright line. If you remove errors,
# please let me know, so I can update my version.
#
# $XFree86: xc/programs/xterm/unicode/keysym.map,v 1.1 1999/06/12 15:37:24 dawes Exp $
#
0x0020     U0020  # space
0x0021     U0021  # exclam
0x0022     U0022  # quotedbl
0x0023     U0023  # numbersign
0x0024     U0024  # dollar
0x0025     U0025  # percent
0x0026     U0026  # ampersand
0x0027     U0027  # apostrophe
0x0028     U0028  # parenleft
0x0029     U0029  # parenright
0x002a     U002a  # asterisk
0x002b     U002b  # plus
0x002c     U002c  # comma
0x002d     U002d  # minus
0x002e     U002e  # period
0x002f     U002f  # slash
0x0030     U0030  # 0
0x0031     U0031  # 1
0x0032     U0032  # 2
0x0033     U0033  # 3
0x0034     U0034  # 4
0x0035     U0035  # 5
0x0036     U0036  # 6
0x0037     U0037  # 7
0x0038     U0038  # 8
0x0039     U0039  # 9
0x003a     U003a  # colon
0x003b     U003b  # semicolon
0x003c     U003c  # less
0x003d     U003d  # equal
0x003e     U003e  # greater
0x003f     U003f  # question
0x0040     U0040  # at
0x0041     U0041  # A
0x0042     U0042  # B
0x0043     U0043  # C
0x0044     U0044  # D
0x0045     U0045  # E
0x0046     U0046  # F
0x0047     U0047  # G
0x0048     U0048  # H
0x0049     U0049  # I
0x004a     U004a  # J
0x004b     U004b  # K
0x004c     U004c  # L
0x004d     U004d  # M
0x004e     U004e  # N
0x004f     U004f  # O
0x0050     U0050  # P
0x0051     U0051  # Q
0x0052     U0052  # R
0x0053     U0053  # S
0x0054     U0054  # T
0x0055     U0055  # U
0x0056     U0056  # V
0x0057     U0057  # W
0x0058     U0058  # X
0x0059     U0059  # Y
0x005a     U005a  # Z
0x005b     U005b  # bracketleft
0x005c     U005c  # backslash
0x005d     U005d  # bracketright
0x005e     U005e  # asciicircum
0x005f     U005f  # underscore
0x0060     U0060  # grave
0x0061     U0061  # a
0x0062     U0062  # b
0x0063     U0063  # c
0x0064     U0064  # d
0x0065     U0065  # e
0x0066     U0066  # f
0x0067     U0067  # g
0x0068     U0068  # h
0x0069     U0069  # i
0x006a     U006a  # j
0x006b     U006b  # k
0x006c     U006c  # l
0x006d     U006d  # m
0x006e     U006e  # n
0x006f     U006f  # o
0x0070     U0070  # p
0x0071     U0071  # q
0x0072     U0072  # r
0x0073     U0073  # s
0x0074     U0074  # t
0x0075     U0075  # u
0x0076     U0076  # v
0x0077     U0077  # w
0x0078     U0078  # x
0x0079     U0079  # y
0x007a     U007a  # z
0x007b     U007b  # braceleft
0x007c     U007c  # bar
0x007d     U007d  # braceright
0x007e     U007e  # asciitilde
0x00a0     U00a0  # nobreakspace
0x00a1     U00a1  # exclamdown
0x00a2     U00a2  # cent
0x00a3     U00a3  # sterling
0x00a4     U00a4  # currency
0x00a5     U00a5  # yen
0x00a6     U00a6  # brokenbar
0x00a7     U00a7  # section
0x00a8     U00a8  # diaeresis
0x00a9     U00a9  # copyright
0x00aa     U00aa  # ordfeminine
0x00ab     U00ab  # guillemotleft	/* left angle quotation mark */
0x00ac     U00ac  # notsign
0x00ad     U00ad  # hyphen
0x00ae     U00ae  # registered
0x00af     U00af  # macron
0x00b0     U00b0  # degree
0x00b1     U00b1  # plusminus
0x00b2     U00b2  # twosuperior
0x00b3     U00b3  # threesuperior
0x00b4     U00b4  # acute
0x00b5     U00b5  # mu
0x00b6     U00b6  # paragraph
0x00b7     U00b7  # periodcentered
0x00b8     U00b8  # cedilla
0x00b9     U00b9  # onesuperior
0x00ba     U00ba  # masculine
0x00bb     U00bb  # guillemotright	/* right angle quotation mark */
0x00bc     U00bc  # onequarter
0x00bd     U00bd  # onehalf
0x00be     U00be  # threequarters
0x00bf     U00bf  # questiondown
0x00c0     U00c0  # Agrave
0x00c1     U00c1  # Aacute
0x00c2     U00c2  # Acircumflex
0x00c3     U00c3  # Atilde
0x00c4     U00c4  # Adiaeresis
0x00c5     U00c5  # Aring
0x00c6     U00c6  # AE
0x00c7     U00c7  # Ccedilla
0x00c8     U00c8  # Egrave
0x00c9     U00c9  # Eacute
0x00ca     U00ca  # Ecircumflex
0x00cb     U00cb  # Ediaeresis
0x00cc     U00cc  # Igrave
0x00cd     U00cd  # Iacute
0x00ce     U00ce  # Icircumflex
0x00cf     U00cf  # Idiaeresis
0x00d0     U00d0  # ETH
0x00d1     U00d1  # Ntilde
0x00d2     U00d2  # Ograve
0x00d3     U00d3  # Oacute
0x00d4     U00d4  # Ocircumflex
0x00d5     U00d5  # Otilde
0x00d6     U00d6  # Odiaeresis
0x00d7     U00d7  # multiply
0x00d8     U00d8  # Oslash
0x00d9     U00d9  # Ugrave
0x00da     U00da  # Uacute
0x00db     U00db  # Ucircumflex
0x00dc     U00dc  # Udiaeresis
0x00dd     U00dd  # Yacute
0x00de     U00de  # THORN
0x00df     U00df  # ssharp
0x00e0     U00e0  # agrave
0x00e1     U00e1  # aacute
0x00e2     U00e2  # acircumflex
0x00e3     U00e3  # atilde
0x00e4     U00e4  # adiaeresis
0x00e5     U00e5  # aring
0x00e6     U00e6  # ae
0x00e7     U00e7  # ccedilla
0x00e8     U00e8  # egrave
0x00e9     U00e9  # eacute
0x00ea     U00ea  # ecircumflex
0x00eb     U00eb  # ediaeresis
0x00ec     U00ec  # igrave
0x00ed     U00ed  # iacute
0x00ee     U00ee  # icircumflex
0x00ef     U00ef  # idiaeresis
0x00f0     U00f0  # eth
0x00f1     U00f1  # ntilde
0x00f2     U00f2  # ograve
0x00f3     U00f3  # oacute
0x00f4     U00f4  # ocircumflex
0x00f5     U00f5  # otilde
0x00f6     U00f6  # odiaeresis
0x00f7     U00f7  # division
0x00f8     U00f8  # oslash
0x00f9     U00f9  # ugrave
0x00fa     U00fa  # uacute
0x00fb     U00fb  # ucircumflex
0x00fc     U00fc  # udiaeresis
0x00fd     U00fd  # yacute
0x00fe     U00fe  # thorn
0x00ff     U00ff  # ydiaeresis
0x01a1     U0104  # Aogonek
0x01a2     U02d8  # breve
0x01a3     U0141  # Lstroke
0x01a5     U013d  # Lcaron
0x01a6     U015a  # Sacute
0x01a9     U0160  # Scaron
0x01aa     U015e  # Scedilla
0x01ab     U0164  # Tcaron
0x01ac     U0179  # Zacute
0x01ae     U017d  # Zcaron
0x01af     U017b  # Zabovedot
0x01b1     U0105  # aogonek
0x01b2     U02db  # ogonek
0x01b3     U0142  # lstroke
0x01b5     U013e  # lcaron
0x01b6     U015b  # sacute
0x01b7     U02c7  # caron
0x01b9     U0161  # scaron
0x01ba     U015f  # scedilla
0x01bb     U0165  # tcaron
0x01bc     U017a  # zacute
0x01bd     U02dd  # doubleacute
0x01be     U017e  # zcaron
0x01bf     U017c  # zabovedot
0x01c0     U0154  # Racute
0x01c3     U0102  # Abreve
0x01c5     U0139  # Lacute
0x01c6     U0106  # Cacute
0x01c8     U010c  # Ccaron
0x01ca     U0118  # Eogonek
0x01cc     U011a  # Ecaron
0x01cf     U010e  # Dcaron
0x01d0     U0110  # Dstroke
0x01d1     U0143  # Nacute
0x01d2     U0147  # Ncaron
0x01d5     U0150  # Odoubleacute
0x01d8     U0158  # Rcaron
0x01d9     U016e  # Uring
0x01db     U0170  # Udoubleacute
0x01de     U0162  # Tcedilla
0x01e0     U0155  # racute
0x01e3     U0103  # abreve
0x01e5     U013a  # lacute
0x01e6     U0107  # cacute
0x01e8     U010d  # ccaron
0x01ea     U0119  # eogonek
0x01ec     U011b  # ecaron
0x01ef     U010f  # dcaron
0x01f0     U0111  # dstroke
0x01f1     U0144  # nacute
0x01f2     U0148  # ncaron
0x01f5     U0151  # odoubleacute
0x01f8     U0159  # rcaron
0x01f9     U016f  # uring
0x01fb     U0171  # udoubleacute
0x01fe     U0163  # tcedilla
0x01ff     U02d9  # abovedot
0x02a1     U0126  # Hstroke
0x02a6     U0124  # Hcircumflex
0x02a9     U0130  # Iabovedot
0x02ab     U011e  # Gbreve
0x02ac     U0134  # Jcircumflex
0x02b1     U0127  # hstroke
0x02b6     U0125  # hcircumflex
0x02b9     U0131  # idotless
0x02bb     U011f  # gbreve
0x02bc     U0135  # jcircumflex
0x02c5     U010a  # Cabovedot
0x02c6     U0108  # Ccircumflex
0x02d5     U0120  # Gabovedot
0x02d8     U011c  # Gcircumflex
0x02dd     U016c  # Ubreve
0x02de     U015c  # Scircumflex
0x02e5     U010b  # cabovedot
0x02e6     U0109  # ccircumflex
0x02f5     U0121  # gabovedot
0x02f8     U011d  # gcircumflex
0x02fd     U016d  # ubreve
0x02fe     U015d  # scircumflex
0x03a2     U0138  # kra
0x03a3     U0156  # Rcedilla
0x03a5     U0128  # Itilde
0x03a6     U013b  # Lcedilla
0x03aa     U0112  # Emacron
0x03ab     U0122  # Gcedilla
0x03ac     U0166  # Tslash
0x03b3     U0157  # rcedilla
0x03b5     U0129  # itilde
0x03b6     U013c  # lcedilla
0x03ba     U0113  # emacron
0x03bb     U0123  # gcedilla
0x03bc     U0167  # tslash
0x03bd     U014a  # ENG
0x03bf     U014b  # eng
0x03c0     U0100  # Amacron
0x03c7     U012e  # Iogonek
0x03cc     U0116  # Eabovedot
0x03cf     U012a  # Imacron
0x03d1     U0145  # Ncedilla
0x03d2     U014c  # Omacron
0x03d3     U0136  # Kcedilla
0x03d9     U0172  # Uogonek
0x03dd     U0168  # Utilde
0x03de     U016a  # Umacron
0x03e0     U0101  # amacron
0x03e7     U012f  # iogonek
0x03ec     U0117  # eabovedot
0x03ef     U012b  # imacron
0x03f1     U0146  # ncedilla
0x03f2     U014d  # omacron
0x03f3     U0137  # kcedilla
0x03f9     U0173  # uogonek
0x03fd     U0169  # utilde
0x03fe     U016b  # umacron
0x047e     U203e  # overline
0x04a1     U3002  # kana_fullstop
0x04a2     U300c  # kana_openingbracket
0x04a3     U300d  # kana_closingbracket
0x04a4     U3001  # kana_comma
0x04a5     U30fb  # kana_conjunctive
0x04a6     U30f2  # kana_WO
0x04a7     U30a1  # kana_a
0x04a8     U30a3  # kana_i
0x04a9     U30a5  # kana_u
0x04aa     U30a7  # kana_e
0x04ab     U30a9  # kana_o
0x04ac     U30e3  # kana_ya
0x04ad     U30e5  # kana_yu
0x04ae     U30e7  # kana_yo
0x04af     U30c3  # kana_tsu
0x04b0     U30fc  # prolongedsound
0x04b1     U30a2  # kana_A
0x04b2     U30a4  # kana_I
0x04b3     U30a6  # kana_U
0x04b4     U30a8  # kana_E
0x04b5     U30aa  # kana_O
0x04b6     U30ab  # kana_KA
0x04b7     U30ad  # kana_KI
0x04b8     U30af  # kana_KU
0x04b9     U30b1  # kana_KE
0x04ba     U30b3  # kana_KO
0x04bb     U30b5  # kana_SA
0x04bc     U30b7  # kana_SHI
0x04bd     U30b9  # kana_SU
0x04be     U30bb  # kana_SE
0x04bf     U30bd  # kana_SO
0x04c0     U30bf  # kana_TA
0x04c1     U30c1  # kana_CHI
0x04c2     U30c4  # kana_TSU
0x04c3     U30c6  # kana_TE
0x04c4     U30c8  # kana_TO
0x04c5     U30ca  # kana_NA
0x04c6     U30cb  # kana_NI
0x04c7     U30cc  # kana_NU
0x04c8     U30cd  # kana_NE
0x04c9     U30ce  # kana_NO
0x04ca     U30cf  # kana_HA
0x04cb     U30d2  # kana_HI
0x04cc     U30d5  # kana_FU
0x04cd     U30d8  # kana_HE
0x04ce     U30db  # kana_HO
0x04cf     U30de  # kana_MA
0x04d0     U30df  # kana_MI
0x04d1     U30e0  # kana_MU
0x04d2     U30e1  # kana_ME
0x04d3     U30e2  # kana_MO
0x04d4     U30e4  # kana_YA
0x04d5     U30e6  # kana_YU
0x04d6     U30e8  # kana_YO
0x04d7     U30e9  # kana_RA
0x04d8     U30ea  # kana_RI
0x04d9     U30eb  # kana_RU
0x04da     U30ec  # kana_RE
0x04db     U30ed  # kana_RO
0x04dc     U30ef  # kana_WA
0x04dd     U30f3  # kana_N
0x04de     U309b  # voicedsound
0x04df     U309c  # semivoicedsound
0x05ac     U060c  # Arabic_comma
0x05bb     U061b  # Arabic_semicolon
0x05bf     U061f  # Arabic_question_mark
0x05c1     U0621  # Arabic_hamza
0x05c2     U0622  # Arabic_maddaonalef
0x05c3     U0623  # Arabic_hamzaonalef
0x05c4     U0624  # Arabic_hamzaonwaw
0x05c5     U0625  # Arabic_hamzaunderalef
0x05c6     U0626  # Arabic_hamzaonyeh
0x05c7     U0627  # Arabic_alef
0x05c8     U0628  # Arabic_beh
0x05c9     U0629  # Arabic_tehmarbuta
0x05ca     U062a  # Arabic_teh
0x05cb     U062b  # Arabic_theh
0x05cc     U062c  # Arabic_jeem
0x05cd     U062d  # Arabic_hah
0x05ce     U062e  # Arabic_khah
0x05cf     U062f  # Arabic_dal
0x05d0     U0630  # Arabic_thal
0x05d1     U0631  # Arabic_ra
0x05d2     U0632  # Arabic_zain
0x05d3     U0633  # Arabic_seen
0x05d4     U0634  # Arabic_sheen
0x05d5     U0635  # Arabic_sad
0x05d6     U0636  # Arabic_dad
0x05d7     U0637  # Arabic_tah
0x05d8     U0638  # Arabic_zah
0x05d9     U0639  # Arabic_ain
0x05da     U063a  # Arabic_ghain
0x05e0     U0640  # Arabic_tatweel
0x05e1     U0641  # Arabic_feh
0x05e2     U0642  # Arabic_qaf
0x05e3     U0643  # Arabic_kaf
0x05e4     U0644  # Arabic_lam
0x05e5     U0645  # Arabic_meem
0x05e6     U0646  # Arabic_noon
0x05e7     U0647  # Arabic_ha
0x05e8     U0648  # Arabic_waw
0x05e9     U0649  # Arabic_alefmaksura
0x05ea     U064a  # Arabic_yeh
0x05eb     U064b  # Arabic_fathatan
0x05ec     U064c  # Arabic_dammatan
0x05ed     U064d  # Arabic_kasratan
0x05ee     U064e  # Arabic_fatha
0x05ef     U064f  # Arabic_damma
0x05f0     U0650  # Arabic_kasra
0x05f1     U0651  # Arabic_shadda
0x05f2     U0652  # Arabic_sukun
0x06a1     U0452  # Serbian_dje
0x06a2     U0453  # Macedonia_gje
0x06a3     U0451  # Cyrillic_io
0x06a4     U0454  # Ukrainian_ie
0x06a5     U0455  # Macedonia_dse
0x06a6     U0456  # Ukrainian_i
0x06a7     U0457  # Ukrainian_yi
0x06a8     U0458  # Cyrillic_je
0x06a9     U0459  # Cyrillic_lje
0x06aa     U045a  # Cyrillic_nje
0x06ab     U045b  # Serbian_tshe
0x06ac     U045c  # Macedonia_kje
0x06ad     U0491  # Ukrainian_ghe_with_upturn
0x06ae     U045e  # Byelorussian_shortu
0x06af     U045f  # Cyrillic_dzhe
0x06b0     U2116  # numerosign
0x06b1     U0402  # Serbian_DJE
0x06b2     U0403  # Macedonia_GJE
0x06b3     U0401  # Cyrillic_IO
0x06b4     U0404  # Ukrainian_IE
0x06b5     U0405  # Macedonia_DSE
0x06b6     U0406  # Ukrainian_I
0x06b7     U0407  # Ukrainian_YI
0x06b8     U0408  # Cyrillic_JE
0x06b9     U0409  # Cyrillic_LJE
0x06ba     U040a  # Cyrillic_NJE
0x06bb     U040b  # Serbian_TSHE
0x06bc     U040c  # Macedonia_KJE
0x06bd     U0490  # Ukrainian_GHE_WITH_UPTURN
0x06be     U040e  # Byelorussian_SHORTU
0x06bf     U040f  # Cyrillic_DZHE
0x06c0     U044e  # Cyrillic_yu
0x06c1     U0430  # Cyrillic_a
0x06c2     U0431  # Cyrillic_be
0x06c3     U0446  # Cyrillic_tse
0x06c4     U0434  # Cyrillic_de
0x06c5     U0435  # Cyrillic_ie
0x06c6     U0444  # Cyrillic_ef
0x06c7     U0433  # Cyrillic_ghe
0x06c8     U0445  # Cyrillic_ha
0x06c9     U0438  # Cyrillic_i
0x06ca     U0439  # Cyrillic_shorti
0x06cb     U043a  # Cyrillic_ka
0x06cc     U043b  # Cyrillic_el
0x06cd     U043c  # Cyrillic_em
0x06ce     U043d  # Cyrillic_en
0x06cf     U043e  # Cyrillic_o
0x06d0     U043f  # Cyrillic_pe
0x06d1     U044f  # Cyrillic_ya
0x06d2     U0440  # Cyrillic_er
0x06d3     U0441  # Cyrillic_es
0x06d4     U0442  # Cyrillic_te
0x06d5     U0443  # Cyrillic_u
0x06d6     U0436  # Cyrillic_zhe
0x06d7     U0432  # Cyrillic_ve
0x06d8     U044c  # Cyrillic_softsign
0x06d9     U044b  # Cyrillic_yeru
0x06da     U0437  # Cyrillic_ze
0x06db     U0448  # Cyrillic_sha
0x06dc     U044d  # Cyrillic_e
0x06dd     U0449  # Cyrillic_shcha
0x06de     U0447  # Cyrillic_che
0x06df     U044a  # Cyrillic_hardsign
0x06e0     U042e  # Cyrillic_YU
0x06e1     U0410  # Cyrillic_A
0x06e2     U0411  # Cyrillic_BE
0x06e3     U0426  # Cyrillic_TSE
0x06e4     U0414  # Cyrillic_DE
0x06e5     U0415  # Cyrillic_IE
0x06e6     U0424  # Cyrillic_EF
0x06e7     U0413  # Cyrillic_GHE
0x06e8     U0425  # Cyrillic_HA
0x06e9     U0418  # Cyrillic_I
0x06ea     U0419  # Cyrillic_SHORTI
0x06eb     U041a  # Cyrillic_KA
0x06ec     U041b  # Cyrillic_EL
0x06ed     U041c  # Cyrillic_EM
0x06ee     U041d  # Cyrillic_EN
0x06ef     U041e  # Cyrillic_O
0x06f0     U041f  # Cyrillic_PE
0x06f1     U042f  # Cyrillic_YA
0x06f2     U0420  # Cyrillic_ER
0x06f3     U0421  # Cyrillic_ES
0x06f4     U0422  # Cyrillic_TE
0x06f5     U0423  # Cyrillic_U
0x06f6     U0416  # Cyrillic_ZHE
0x06f7     U0412  # Cyrillic_VE
0x06f8     U042c  # Cyrillic_SOFTSIGN
0x06f9     U042b  # Cyrillic_YERU
0x06fa     U0417  # Cyrillic_ZE
0x06fb     U0428  # Cyrillic_SHA
0x06fc     U042d  # Cyrillic_E
0x06fd     U0429  # Cyrillic_SHCHA
0x06fe     U0427  # Cyrillic_CHE
0x06ff     U042a  # Cyrillic_HARDSIGN
0x07a1     U0386  # Greek_ALPHAaccent
0x07a2     U0388  # Greek_EPSILONaccent
0x07a3     U0389  # Greek_ETAaccent
0x07a4     U038a  # Greek_IOTAaccent
0x07a5     U03aa  # Greek_IOTAdieresis
0x07a7     U038c  # Greek_OMICRONaccent
0x07a8     U038e  # Greek_UPSILONaccent
0x07a9     U03ab  # Greek_UPSILONdieresis
0x07ab     U038f  # Greek_OMEGAaccent
0x07ae     U0385  # Greek_accentdieresis
0x07af     U2015  # Greek_horizbar
0x07b1     U03ac  # Greek_alphaaccent
0x07b2     U03ad  # Greek_epsilonaccent
0x07b3     U03ae  # Greek_etaaccent
0x07b4     U03af  # Greek_iotaaccent
0x07b5     U03ca  # Greek_IOTAdieresis
0x07b6     U0390  # Greek_iotaaccentdieresis
0x07b7     U03cc  # Greek_omicronaccent
0x07b8     U03cd  # Greek_upsilonaccent
0x07b9     U03cb  # Greek_upsilondieresis
0x07ba     U03b0  # Greek_upsilonaccentdieresis
0x07bb     U03ce  # Greek_omegaaccent
0x07c1     U0391  # Greek_ALPHA
0x07c2     U0392  # Greek_BETA
0x07c3     U0393  # Greek_GAMMA
0x07c4     U0394  # Greek_DELTA
0x07c5     U0395  # Greek_EPSILON
0x07c6     U0396  # Greek_ZETA
0x07c7     U0397  # Greek_ETA
0x07c8     U0398  # Greek_THETA
0x07c9     U0399  # Greek_IOTA
0x07ca     U039a  # Greek_KAPPA
0x07cb     U039b  # Greek_LAMBDA
0x07cb     U039b  # Greek_LAMDA
0x07cc     U039c  # Greek_MU
0x07cd     U039d  # Greek_NU
0x07ce     U039e  # Greek_XI
0x07cf     U039f  # Greek_OMICRON
0x07d0     U03a0  # Greek_PI
0x07d1     U03a1  # Greek_RHO
0x07d2     U03a3  # Greek_SIGMA
0x07d4     U03a4  # Greek_TAU
0x07d5     U03a5  # Greek_UPSILON
0x07d6     U03a6  # Greek_PHI
0x07d7     U03a7  # Greek_CHI
0x07d8     U03a8  # Greek_PSI
0x07d9     U03a9  # Greek_OMEGA
0x07e1     U03b1  # Greek_alpha
0x07e2     U03b2  # Greek_beta
0x07e3     U03b3  # Greek_gamma
0x07e4     U03b4  # Greek_delta
0x07e5     U03b5  # Greek_epsilon
0x07e6     U03b6  # Greek_zeta
0x07e7     U03b7  # Greek_eta
0x07e8     U03b8  # Greek_theta
0x07e9     U03b9  # Greek_iota
0x07ea     U03ba  # Greek_kappa
0x07eb     U03bb  # Greek_lambda
0x07ec     U03bc  # Greek_mu
0x07ed     U03bd  # Greek_nu
0x07ee     U03be  # Greek_xi
0x07ef     U03bf  # Greek_omicron
0x07f0     U03c0  # Greek_pi
0x07f1     U03c1  # Greek_rho
0x07f2     U03c3  # Greek_sigma
0x07f3     U03c2  # Greek_finalsmallsigma
0x07f4     U03c4  # Greek_tau
0x07f5     U03c5  # Greek_upsilon
0x07f6     U03c6  # Greek_phi
0x07f7     U03c7  # Greek_chi
0x07f8     U03c8  # Greek_psi
0x07f9     U03c9  # Greek_omega
0x08a1     U23b7  # leftradical
0x08a2     U250c  # topleftradical
0x08a3     U2500  # horizconnector
0x08a4     U2320  # topintegral
0x08a5     U2321  # botintegral
0x08a6     U2502  # vertconnector
0x08a7     U23a1  # topleftsqbracket
0x08a8     U23a3  # botleftsqbracket
0x08a9     U23a4  # toprightsqbracket
0x08aa     U23a6  # botrightsqbracket
0x08ab     U239b  # topleftparens
0x08ac     U239d  # botleftparens
0x08ad     U239e  # toprightparens
0x08ae     U23a0  # botrightparens
0x08af     U23a8  # leftmiddlecurlybrace
0x08b0     U23ac  # rightmiddlecurlybrace
0x08b1     U0000  # topleftsummation
0x08b2     U0000  # botleftsummation
0x08b3     U0000  # topvertsummationconnector
0x08b4     U0000  # botvertsummationconnector
0x08b5     U0000  # toprightsummation
0x08b6     U0000  # botrightsummation
0x08b7     U0000  # rightmiddlesummation
0x08bc     U2264  # lessthanequal
0x08bd     U2260  # notequal
0x08be     U2265  # greaterthanequal
0x08bf     U222b  # integral
0x08c0     U2234  # therefore
0x08c1     U221d  # variation
0x08c2     U221e  # infinity
0x08c5     U2207  # nabla
0x08c8     U223c  # approximate
0x08c9     U2243  # similarequal
0x08cd     U21d4  # ifonlyif
0x08ce     U21d2  # implies
0x08cf     U2261  # identical
0x08d6     U221a  # radical
0x08da     U2282  # includedin
0x08db     U2283  # includes
0x08dc     U2229  # intersection
0x08dd     U222a  # union
0x08de     U2227  # logicaland
0x08df     U2228  # logicalor
0x08ef     U2202  # partialderivative
0x08f6     U0192  # function
0x08fb     U2190  # leftarrow
0x08fc     U2191  # uparrow
0x08fd     U2192  # rightarrow
0x08fe     U2193  # downarrow
0x09df     U2422  # blank
0x09e0     U25c6  # soliddiamond
0x09e1     U2592  # checkerboard
0x09e2     U2409  # ht
0x09e3     U240c  # ff
0x09e4     U240d  # cr
0x09e5     U240a  # lf
0x09e8     U2424  # nl
0x09e9     U240b  # vt
0x09ea     U2518  # lowrightcorner
0x09eb     U2510  # uprightcorner
0x09ec     U250c  # upleftcorner
0x09ed     U2514  # lowleftcorner
0x09ee     U253c  # crossinglines
0x09ef     U23ba  # horizlinescan1
0x09f0     U23bb  # horizlinescan3
0x09f1     U2500  # horizlinescan5
0x09f2     U23bc  # horizlinescan7
0x09f3     U23bd  # horizlinescan9
0x09f4     U251c  # leftt
0x09f5     U2524  # rightt
0x09f6     U2534  # bott
0x09f7     U252c  # topt
0x09f8     U2502  # vertbar
0x0aa1     U2003  # emspace
0x0aa2     U2002  # enspace
0x0aa3     U2004  # em3space
0x0aa4     U2005  # em4space
0x0aa5     U2007  # digitspace
0x0aa6     U2008  # punctspace
0x0aa7     U2009  # thinspace
0x0aa8     U200a  # hairspace
0x0aa9     U2014  # emdash
0x0aaa     U2013  # endash
0x0aac     U2423  # signifblank
0x0aae     U2026  # ellipsis
0x0aaf     U2025  # doubbaselinedot
0x0ab0     U2153  # onethird
0x0ab1     U2154  # twothirds
0x0ab2     U2155  # onefifth
0x0ab3     U2156  # twofifths
0x0ab4     U2157  # threefifths
0x0ab5     U2158  # fourfifths
0x0ab6     U2159  # onesixth
0x0ab7     U215a  # fivesixths
0x0ab8     U2105  # careof
0x0abb     U2012  # figdash
0x0abc     U2329  # leftanglebracket (not U+27E8)
0x0abd     U002e  # decimalpoint
0x0abe     U232a  # rightanglebracket (not U+27E9)
0x0abf     U0000  # marker
0x0ac3     U215b  # oneeighth
0x0ac4     U215c  # threeeighths
0x0ac5     U215d  # fiveeighths
0x0ac6     U215e  # seveneighths
0x0ac9     U2122  # trademark
0x0aca     U2613  # signaturemark
0x0acb     U0000  # trademarkincircle
0x0acc     U25c1  # leftopentriangle
0x0acd     U25b7  # rightopentriangle
0x0ace     U25cb  # emopencircle
0x0acf     U25af  # emopenrectangle
0x0ad0     U2018  # leftsinglequotemark
0x0ad1     U2019  # rightsinglequotemark
0x0ad2     U201c  # leftdoublequotemark
0x0ad3     U201d  # rightdoublequotemark
0x0ad4     U211e  # prescription
0x0ad5     U2030  # per mille
0x0ad6     U2032  # minutes
0x0ad7     U2033  # seconds
0x0ad9     U271d  # latincross
0x0ada     U0000  # hexagram
0x0adb     U25ac  # filledrectbullet
0x0adc     U25c0  # filledlefttribullet
0x0add     U25b6  # filledrighttribullet
0x0ade     U25cf  # emfilledcircle
0x0adf     U25ae  # emfilledrect
0x0ae0     U25e6  # enopencircbullet
0x0ae1     U25ab  # enopensquarebullet
0x0ae2     U25ad  # openrectbullet
0x0ae3     U25b3  # opentribulletup
0x0ae4     U25bd  # opentribulletdown
0x0ae5     U2606  # openstar
0x0ae6     U2022  # enfilledcircbullet
0x0ae7     U25aa  # enfilledsqbullet
0x0ae8     U25b2  # filledtribulletup
0x0ae9     U25bc  # filledtribulletdown
0x0aea     U261c  # leftpointer
0x0aeb     U261e  # rightpointer
0x0aec     U2663  # club
0x0aed     U2666  # diamond
0x0aee     U2665  # heart
0x0af0     U2720  # maltesecross
0x0af1     U2020  # dagger
0x0af2     U2021  # doubledagger
0x0af3     U2713  # checkmark
0x0af4     U2717  # ballotcross
0x0af5     U266f  # musicalsharp
0x0af6     U266d  # musicalflat
0x0af7     U2642  # malesymbol
0x0af8     U2640  # femalesymbol
0x0af9     U260e  # telephone
0x0afa     U2315  # telephonerecorder
0x0afb     U2117  # phonographcopyright
0x0afc     U2038  # caret
0x0afd     U201a  # singlelowquotemark
0x0afe     U201e  # doublelowquotemark
0x0aff     U0000  # cursor
0x0ba3     U003c  # leftcaret
0x0ba6     U003e  # rightcaret
0x0ba8     U2228  # downcaret
0x0ba9     U2227  # upcaret
0x0bc0     U00af  # overbar
0x0bc2     U22a5  # downtack
0x0bc3     U2229  # upshoe
0x0bc4     U230a  # downstile
0x0bc6     U005f  # underbar
0x0bca     U2218  # jot
0x0bcc     U2395  # quad
0x0bce     U22a4  # uptack
0x0bcf     U25cb  # circle
0x0bd3     U2308  # upstile
0x0bd6     U222a  # downshoe
0x0bd8     U2283  # rightshoe
0x0bda     U2282  # leftshoe
0x0bdc     U22a2  # lefttack
0x0bfc     U22a3  # righttack
0x0cdf     U2017  # hebrew_doublelowline
0x0ce0     U05d0  # hebrew_aleph
0x0ce1     U05d1  # hebrew_bet
0x0ce2     U05d2  # hebrew_gimel
0x0ce3     U05d3  # hebrew_dalet
0x0ce4     U05d4  # hebrew_he
0x0ce5     U05d5  # hebrew_waw
0x0ce6     U05d6  # hebrew_zain
0x0ce7     U05d7  # hebrew_chet
0x0ce8     U05d8  # hebrew_tet
0x0ce9     U05d9  # hebrew_yod
0x0cea     U05da  # hebrew_finalkaph
0x0ceb     U05db  # hebrew_kaph
0x0cec     U05dc  # hebrew_lamed
0x0ced     U05dd  # hebrew_finalmem
0x0cee     U05de  # hebrew_mem
0x0cef     U05df  # hebrew_finalnun
0x0cf0     U05e0  # hebrew_nun
0x0cf1     U05e1  # hebrew_samech
0x0cf2     U05e2  # hebrew_ayin
0x0cf3     U05e3  # hebrew_finalpe
0x0cf4     U05e4  # hebrew_pe
0x0cf5     U05e5  # hebrew_finalzade
0x0cf6     U05e6  # hebrew_zade
0x0cf7     U05e7  # hebrew_qoph
0x0cf8     U05e8  # hebrew_resh
0x0cf9     U05e9  # hebrew_shin
0x0cfa     U05ea  # hebrew_taw
0x0da1     U0e01  # Thai_kokai
0x0da2     U0e02  # Thai_khokhai
0x0da3     U0e03  # Thai_khokhuat
0x0da4     U0e04  # Thai_khokhwai
0x0da5     U0e05  # Thai_khokhon
0x0da6     U0e06  # Thai_khorakhang
0x0da7     U0e07  # Thai_ngongu
0x0da8     U0e08  # Thai_chochan
0x0da9     U0e09  # Thai_choching
0x0daa     U0e0a  # Thai_chochang
0x0dab     U0e0b  # Thai_soso
0x0dac     U0e0c  # Thai_chochoe
0x0dad     U0e0d  # Thai_yoying
0x0dae     U0e0e  # Thai_dochada
0x0daf     U0e0f  # Thai_topatak
0x0db0     U0e10  # Thai_thothan
0x0db1     U0e11  # Thai_thonangmontho
0x0db2     U0e12  # Thai_thophuthao
0x0db3     U0e13  # Thai_nonen
0x0db4     U0e14  # Thai_dodek
0x0db5     U0e15  # Thai_totao
0x0db6     U0e16  # Thai_thothung
0x0db7     U0e17  # Thai_thothahan
0x0db8     U0e18  # Thai_thothong
0x0db9     U0e19  # Thai_nonu
0x0dba     U0e1a  # Thai_bobaimai
0x0dbb     U0e1b  # Thai_popla
0x0dbc     U0e1c  # Thai_phophung
0x0dbd     U0e1d  # Thai_fofa
0x0dbe     U0e1e  # Thai_phophan
0x0dbf     U0e1f  # Thai_fofan
0x0dc0     U0e20  # Thai_phosamphao
0x0dc1     U0e21  # Thai_moma
0x0dc2     U0e22  # Thai_yoyak
0x0dc3     U0e23  # Thai_rorua
0x0dc4     U0e24  # Thai_ru
0x0dc5     U0e25  # Thai_loling
0x0dc6     U0e26  # Thai_lu
0x0dc7     U0e27  # Thai_wowaen
0x0dc8     U0e28  # Thai_sosala
0x0dc9     U0e29  # Thai_sorusi
0x0dca     U0e2a  # Thai_sosua
0x0dcb     U0e2b  # Thai_hohip
0x0dcc     U0e2c  # Thai_lochula
0x0dcd     U0e2d  # Thai_oang
0x0dce     U0e2e  # Thai_honokhuk
0x0dcf     U0e2f  # Thai_paiyannoi
0x0dd0     U0e30  # Thai_saraa
0x0dd1     U0e31  # Thai_maihanakat
0x0dd2     U0e32  # Thai_saraaa
0x0dd3     U0e33  # Thai_saraam
0x0dd4     U0e34  # Thai_sarai
0x0dd5     U0e35  # Thai_saraii
0x0dd6     U0e36  # Thai_saraue
0x0dd7     U0e37  # Thai_sarauee
0x0dd8     U0e38  # Thai_sarau
0x0dd9     U0e39  # Thai_sarauu
0x0dda     U0e3a  # Thai_phinthu
0x0dde     U0e3e  # Thai_maihanakat_maitho
0x0ddf     U0e3f  # Thai_baht
0x0de0     U0e40  # Thai_sarae
0x0de1     U0e41  # Thai_saraae
0x0de2     U0e42  # Thai_sarao
0x0de3     U0e43  # Thai_saraaimaimuan
0x0de4     U0e44  # Thai_saraaimaimalai
0x0de5     U0e45  # Thai_lakkhangyao
0x0de6     U0e46  # Thai_maiyamok
0x0de7     U0e47  # Thai_maitaikhu
0x0de8     U0e48  # Thai_maiek
0x0de9     U0e49  # Thai_maitho
0x0dea     U0e4a  # Thai_maitri
0x0deb     U0e4b  # Thai_maichattawa
0x0dec     U0e4c  # Thai_thanthakhat
0x0ded     U0e4d  # Thai_nikhahit
0x0df0     U0e50  # Thai_leksun
0x0df1     U0e51  # Thai_leknung
0x0df2     U0e52  # Thai_leksong
0x0df3     U0e53  # Thai_leksam
0x0df4     U0e54  # Thai_leksi
0x0df5     U0e55  # Thai_lekha
0x0df6     U0e56  # Thai_lekhok
0x0df7     U0e57  # Thai_lekchet
0x0df8     U0e58  # Thai_lekpaet
0x0df9     U0e59  # Thai_lekkao
0x0ea1     U3131  # Hangul_Kiyeog
0x0ea2     U3132  # Hangul_SsangKiyeog
0x0ea3     U3133  # Hangul_KiyeogSios
0x0ea4     U3134  # Hangul_Nieun
0x0ea5     U3135  # Hangul_NieunJieuj
0x0ea6     U3136  # Hangul_NieunHieuh
0x0ea7     U3137  # Hangul_Dikeud
0x0ea8     U3138  # Hangul_SsangDikeud
0x0ea9     U3139  # Hangul_Rieul
0x0eaa     U313a  # Hangul_RieulKiyeog
0x0eab     U313b  # Hangul_RieulMieum
0x0eac     U313c  # Hangul_RieulPieub
0x0ead     U313d  # Hangul_RieulSios
0x0eae     U313e  # Hangul_RieulTieut
0x0eaf     U313f  # Hangul_RieulPhieuf
0x0eb0     U3140  # Hangul_RieulHieuh
0x0eb1     U3141  # Hangul_Mieum
0x0eb2     U3142  # Hangul_Pieub
0x0eb3     U3143  # Hangul_SsangPieub
0x0eb4     U3144  # Hangul_PieubSios
0x0eb5     U3145  # Hangul_Sios
0x0eb6     U3146  # Hangul_SsangSios
0x0eb7     U3147  # Hangul_Ieung
0x0eb8     U3148  # Hangul_Jieuj
0x0eb9     U3149  # Hangul_SsangJieuj
0x0eba     U314a  # Hangul_Cieuc
0x0ebb     U314b  # Hangul_Khieuq
0x0ebc     U314c  # Hangul_Tieut
0x0ebd     U314d  # Hangul_Phieuf
0x0ebe     U314e  # Hangul_Hieuh
0x0ebf     U314f  # Hangul_A
0x0ec0     U3150  # Hangul_AE
0x0ec1     U3151  # Hangul_YA
0x0ec2     U3152  # Hangul_YAE
0x0ec3     U3153  # Hangul_EO
0x0ec4     U3154  # Hangul_E
0x0ec5     U3155  # Hangul_YEO
0x0ec6     U3156  # Hangul_YE
0x0ec7     U3157  # Hangul_O
0x0ec8     U3158  # Hangul_WA
0x0ec9     U3159  # Hangul_WAE
0x0eca     U315a  # Hangul_OE
0x0ecb     U315b  # Hangul_YO
0x0ecc     U315c  # Hangul_U
0x0ecd     U315d  # Hangul_WEO
0x0ece     U315e  # Hangul_WE
0x0ecf     U315f  # Hangul_WI
0x0ed0     U3160  # Hangul_YU
0x0ed1     U3161  # Hangul_EU
0x0ed2     U3162  # Hangul_YI
0x0ed3     U3163  # Hangul_I
0x0ed4     U11a8  # Hangul_J_Kiyeog
0x0ed5     U11a9  # Hangul_J_SsangKiyeog
0x0ed6     U11aa  # Hangul_J_KiyeogSios
0x0ed7     U11ab  # Hangul_J_Nieun
0x0ed8     U11ac  # Hangul_J_NieunJieuj
0x0ed9     U11ad  # Hangul_J_NieunHieuh
0x0eda     U11ae  # Hangul_J_Dikeud
0x0edb     U11af  # Hangul_J_Rieul
0x0edc     U11b0  # Hangul_J_RieulKiyeog
0x0edd     U11b1  # Hangul_J_RieulMieum
0x0ede     U11b2  # Hangul_J_RieulPieub
0x0edf     U11b3  # Hangul_J_RieulSios
0x0ee0     U11b4  # Hangul_J_RieulTieut
0x0ee1     U11b5  # Hangul_J_RieulPhieuf
0x0ee2     U11b6  # Hangul_J_RieulHieuh
0x0ee3     U11b7  # Hangul_J_Mieum
0x0ee4     U11b8  # Hangul_J_Pieub
0x0ee5     U11b9  # Hangul_J_PieubSios
0x0ee6     U11ba  # Hangul_J_Sios
0x0ee7     U11bb  # Hangul_J_SsangSios
0x0ee8     U11bc  # Hangul_J_Ieung
0x0ee9     U11bd  # Hangul_J_Jieuj
0x0eea     U11be  # Hangul_J_Cieuc
0x0eeb     U11bf  # Hangul_J_Khieuq
0x0eec     U11c0  # Hangul_J_Tieut
0x0eed     U11c1  # Hangul_J_Phieuf
0x0eee     U11c2  # Hangul_J_Hieuh
0x0eef     U316d  # Hangul_RieulYeorinHieuh
0x0ef0     U3171  # Hangul_SunkyeongeumMieum
0x0ef1     U3178  # Hangul_SunkyeongeumPieub
0x0ef2     U317f  # Hangul_PanSios
0x0ef3     U3181  # Hangul_KkogjiDalrinIeung
0x0ef4     U3184  # Hangul_SunkyeongeumPhieuf
0x0ef5     U3186  # Hangul_YeorinHieuh
0x0ef6     U318d  # Hangul_AraeA
0x0ef7     U318e  # Hangul_AraeAE
0x0ef8     U11eb  # Hangul_J_PanSios
0x0ef9     U11f0  # Hangul_J_KkogjiDalrinIeung
0x0efa     U11f9  # Hangul_J_YeorinHieuh
0x0eff     U20a9  # Korean_Won
0x13a4     U20ac  # Euro
0x13bc     U0152  # OE
0x13bd     U0153  # oe
0x13be     U0178  # Ydiaeresis
0x20a0     U20a0  # EcuSign
0x20a1     U20a1  # ColonSign
0x20a2     U20a2  # CruzeiroSign
0x20a3     U20a3  # FFrancSign
0x20a4     U20a4  # LiraSign
0x20a5     U20a5  # MillSign
0x20a6     U20a6  # NairaSign
0x20a7     U20a7  # PesetaSign
0x20a8     U20a8  # RupeeSign
0x20a9     U20a9  # WonSign
0x20aa     U20aa  # NewSheqelSign
0x20ab     U20ab  # DongSign
0x20ac     U20ac  # EuroSign
0xfe50     U0300  # dead_grave
0xfe51     U0301  # dead_acute
0xfe52     U0302  # dead_circumflex
0xfe53     U0303  # dead_tilde
0xfe54     U0304  # dead_macron
0xfe55     U0306  # dead_breve
0xfe56     U0307  # dead_abovedot
0xfe57     U0308  # dead_diaeresis
0xfe58     U030a  # dead_abovering
0xfe59     U030b  # dead_doubleacute
0xfe5a     U030c  # dead_caron
0xfe5b     U0327  # dead_cedilla
0xfe5c     U0328  # dead_ogonek
0xfe5d     U0345  # dead_iota
0xfe5e     U3099  # dead_voiced_sound
0xfe5f     U309a  # dead_semivoiced_sound
0xff08     U0008  # BackSpace	/* back space, back char */
0xff09     U0009  # Tab
0xff0a     U000a  # Linefeed	/* Linefeed, LF */
0xff0b     U000b  # Clear
0xff0d     U000d  # Return	/* Return, enter */
0xff13     U0013  # Pause	/* Pause, hold */
0xff14     U0014  # Scroll_Lock
0xff15     U0015  # Sys_Req
0xff1b     U001b  # Escape
0xff80     U0032  # KP_Space	/* space */
0xff89     U0009  # KP_Tab
0xff8d     U000d  # KP_Enter	/* enter */
0xffaa     U002a  # KP_Multiply
0xffab     U002b  # KP_Add
0xffac     U002c  # KP_Separator	/* separator, often comma */
0xffad     U002d  # KP_Subtract
0xffae     U002e  # KP_Decimal
0xffaf     U002f  # KP_Divide
0xffb0     U0030  # KP_0
0xffb1     U0031  # KP_1
0xffb2     U0032  # KP_2
0xffb3     U0033  # KP_3
0xffb4     U0034  # KP_4
0xffb5     U0035  # KP_5
0xffb6     U0036  # KP_6
0xffb7     U0037  # KP_7
0xffb8     U0038  # KP_8
0xffb9     U0039  # KP_9
0xffbd     U003d  # KP_Equal	/* equals */
xterm-330/unicode/README0000644000175100001440000000150112720410061013533 0ustar  tomusers-- $XTermId: README,v 1.11 2016/05/22 20:01:53 tom Exp $
-- $XFree86: xc/programs/xterm/unicode/README,v 1.5 2004/12/01 01:27:49 dickey Exp $
-- Thomas E. Dickey

These scripts and datafiles are used for generating tables used in the
UTF-8 implementation in xterm.

To run the convmap.pl script, you will need a copy of UnicodeData.txt
which is currently available as

         ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt

It is a large file (>1Mb), so it is not included in this distribution.

convmap.pl is used to generate ../keysym2ucs.c, e.g.,

	./convmap.pl >../keysym2ucs.c

keysym.map is input data for convmap.pl

The make-precompose.sh script makes the precompose.c file, which is used to
handle canonical composition. This also needs UnicodeData.txt. It uses
precompose.c.head and precompose.c.tail as templates.
xterm-330/unicode/precompose.c.head0000644000175100001440000000037012361315250016103 0ustar  tomusers/*
 * Canonical Compositions
 *
 * DO NOT EDIT BY HAND! This is generated by the script
 * unicode/make-precompose.sh
 */
/* @XTermId@ */

#include 

static struct {
  int replacement;
  int base;
  int comb; 
} precompositions[] = {
xterm-330/unicode/make-precompose.sh0000755000175100001440000000125210561501434016312 0ustar  tomusers#!/bin/sh
# $XTermId: make-precompose.sh,v 1.6 2007/02/05 01:06:36 Thomas.Wolff Exp $
# $XFree86: xc/programs/xterm/unicode/make-precompose.sh,v 1.4 2005/03/29 04:00:32 tsi Exp $

cat precompose.c.head | sed -e's/@/$/g'

# extract canonical decomposition data from UnicodeData.txt,
# pad hex values to 5 digits,
# sort numerically on base character, then combining character,
# then reduce to 4 digits again where possible
cut UnicodeData.txt -d ";" -f 1,6 |
 grep ";[0-9,A-F]" | grep " " |
 sed -e "s/ /, 0x/;s/^/{ 0x/;s/;/, 0x/;s/$/},/" |
 sed -e "s,0x\(....\)\([^0-9A-Fa-f]\),0x0\1\2,g" |
 (sort -k 3 || sort +2) |
 sed -e "s,0x0\(...[0-9A-Fa-f]\),0x\1,g"

cat precompose.c.tail
xterm-330/unicode/convmap.pl0000755000175100001440000001424012720407425014674 0ustar  tomusers#!/usr/bin/perl -w
# $XTermId: convmap.pl,v 1.14 2016/05/22 19:57:09 tom Exp $
#
# Generate keysym2ucs.c file
#
# See also:
# http://mail.nl.linux.org/linux-utf8/2001-04/msg00248.html
#
# $XFree86: xc/programs/xterm/unicode/convmap.pl,v 1.5 2000/01/24 22:22:05 dawes Exp $

use strict;

our $keysym;
our %name;
our %keysym_to_ucs;
our %keysym_to_keysymname;

sub utf8 ($);

sub utf8 ($) {
    my $c = shift(@_);

    if ($c < 0x80) {
        return sprintf("%c", $c);
    } elsif ($c < 0x800) {
        return sprintf("%c%c", 0xc0 | ($c >> 6), 0x80 | ($c & 0x3f));
    } elsif ($c < 0x10000) {
        return sprintf("%c%c%c",
                       0xe0 |  ($c >> 12),
                       0x80 | (($c >>  6) & 0x3f),
                       0x80 | ( $c        & 0x3f));
    } elsif ($c < 0x200000) {
        return sprintf("%c%c%c%c",
                       0xf0 |  ($c >> 18),
                       0x80 | (($c >> 12) & 0x3f),
                       0x80 | (($c >>  6) & 0x3f),
                       0x80 | ( $c        & 0x3f));
    } elsif ($c < 0x4000000) {
        return sprintf("%c%c%c%c%c",
                       0xf8 |  ($c >> 24),
                       0x80 | (($c >> 18) & 0x3f),
                       0x80 | (($c >> 12) & 0x3f),
                       0x80 | (($c >>  6) & 0x3f),
                       0x80 | ( $c        & 0x3f));

    } elsif ($c < 0x80000000) {
        return sprintf("%c%c%c%c%c%c",
                       0xfe |  ($c >> 30),
                       0x80 | (($c >> 24) & 0x3f),
                       0x80 | (($c >> 18) & 0x3f),
                       0x80 | (($c >> 12) & 0x3f),
                       0x80 | (($c >> 6)  & 0x3f),
                       0x80 | ( $c        & 0x3f));
    } else {
        return utf8(0xfffd);
    }
}

my $unicodedata = "UnicodeData.txt";

# read list of all Unicode names
if (!open(UDATA, $unicodedata) && !open(UDATA, "$unicodedata")) {
    die ("Can't open Unicode database '$unicodedata':\n$!\n\n" .
         "Please make sure that you have downloaded the file\n" .
         "ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt\n");
}
while () {
    if (/^([0-9,A-F]{4,6});([^;]*);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*)$/) {
        $name{hex($1)} = $2;
    } else {
        die("Syntax error in line '$_' in file '$unicodedata'");
    }
}
close(UDATA);

# read mapping (from http://wsinwp07.win.tue.nl:1234/unicode/keysym.map)
open(LIST, ") {
    if (/^0x([0-9a-f]{4})\s+U([0-9a-f]{4})\s*(\#.*)?$/){
        my $keysym = hex($1);
        my $ucs = hex($2);
	my $comment = $3;
	$comment =~ s/^#\s*//;
        $keysym_to_ucs{$keysym} = $ucs;
	$keysym_to_keysymname{$keysym} = $comment;
    } elsif (/^\s*\#/ || /^\s*$/) {
    } else {
        die("Syntax error in 'list' in line\n$_\n");
    }
}
close(LIST);

# read entries in keysymdef.h
open(LIST, ") {
    if (/^\#define\s+XK_([A-Za-z_0-9]+)\s+0x([0-9a-fA-F]+)\s*(\/.*)?$/) {
	next if /\/\* deprecated \*\//;
	my $keysymname = $1;
	my $keysym = hex($2);
	$keysym_to_keysymname{$keysym} = $keysymname;
    }
}
close(LIST);

print < UTF-8 conversion will hopefully one day be provided
 * by Xlib via XmbLookupString() and should ideally not have to be
 * done in X applications. But we are not there yet.
 *
 * We allow to represent any UCS character in the range U-00000000 to
 * U-00FFFFFF by a keysym value in the range 0x01000000 to 0x01ffffff.
 * This admittedly does not cover the entire 31-bit space of UCS, but
 * it does cover all of the characters up to U-10FFFF, which can be
 * represented by UTF-16, and more, and it is very unlikely that higher
 * UCS codes will ever be assigned by ISO. So to get Unicode character
 * U+ABCD you can directly use keysym 0x0100abcd.
 *
 * NOTE: The comments in the table below contain the actual character
 * encoded in UTF-8, so for viewing and editing best use an editor in
 * UTF-8 mode.
 *
 * Author: Markus G. Kuhn , University of Cambridge, April 2001
 *
 * Special thanks to Richard Verhoeven  for preparing
 * an initial draft of the mapping table.
 *
 * This software is in the public domain. Share and enjoy!
 *
 * AUTOMATICALLY GENERATED FILE, DO NOT EDIT !!! (unicode/convmap.pl)
 */

#ifndef KEYSYM2UCS_INCLUDED
  
#include "keysym2ucs.h"
#define VISIBLE /* */

#else

#define VISIBLE static

#endif

static struct codepair {
  unsigned short keysym;
  unsigned short ucs;
} keysymtab[] = {
EOT

for $keysym (sort {$a <=> $b} keys(%keysym_to_keysymname)) {
    my $ucs = $keysym_to_ucs{$keysym};
    next if $keysym >= 0xf000 || $keysym < 0x100;
    if ($ucs) {
	printf("  { 0x%04x, 0x%04x }, /*%28s %s %s */\n",
	       $keysym, $ucs, $keysym_to_keysymname{$keysym}, utf8($ucs),
	       defined($name{$ucs}) ? $name{$ucs} : "???" );
    } else {
	printf("/*  0x%04x   %39s ? ??? */\n",
	       $keysym, $keysym_to_keysymname{$keysym});
    }
}

print <= 0x0020 && keysym <= 0x007e) ||
        (keysym >= 0x00a0 && keysym <= 0x00ff))
        return keysym;

    /* also check for directly encoded 24-bit UCS characters */
    if ((keysym & 0xff000000) == 0x01000000)
	return keysym & 0x00ffffff;

    /* binary search in table */
    while (max >= min) {
	int mid = (min + max) / 2;
	if (keysymtab[mid].keysym < keysym)
	    min = mid + 1;
	else if (keysymtab[mid].keysym > keysym)
	    max = mid - 1;
	else {
	    /* found it */
	    return keysymtab[mid].ucs;
	}
    }

    /* no matching Unicode value found */
    return -1;
}
EOT
xterm-330/unicode/precompose.c.tail0000644000175100001440000000120412720401621016125 0ustar  tomusers};

#define UNICODE_SHIFT 21

int do_precomposition(int base, int comb) {
  int min = 0;
  int max = sizeof(precompositions) / sizeof(precompositions[0]) - 1;
  unsigned long sought = ((unsigned) base << UNICODE_SHIFT) | (unsigned) comb;

  /* binary search */
  while (max >= min) {
    int mid = (min + max) / 2;
    unsigned long that = ((unsigned long) precompositions[mid].base << UNICODE_SHIFT) | ((unsigned) precompositions[mid].comb);
    if (that < sought) {
      min = mid + 1;
    } else if (that > sought) {
      max = mid - 1;
    } else {
      return precompositions[mid].replacement;
    }
  }
  /* no match */
  return -1;
}
xterm-330/xutf8.h0000644000175100001440000000327011454344504012474 0ustar  tomusers/*
 * $XTermId: xutf8.h,v 1.4 2010/10/10 14:10:12 Jeremy.Huddleston Exp $
 */
/*
Copyright (c) 2001 by Juliusz Chroboczek

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

#include 

#ifndef X_HAVE_UTF8_STRING

#undef XA_UTF8_STRING
Atom _xa_utf8_string(Display*);
#define XA_UTF8_STRING(dpy) _xa_utf8_string(dpy)

#undef XUTF8StringStyle
#define XUTF8StringStyle 4

int Xutf8TextPropertyToTextList(
    Display *,
    const XTextProperty *,
    char ***,
    int *
);
int
Xutf8TextListToTextProperty(
    Display *,
    char **,
    int,
    XICCEncodingStyle,
    XTextProperty *
);
int Xutf8LookupString(
    XIC,
    XKeyPressedEvent *,
    char *,
    int,
    KeySym *,
    Status *
);
#else
void xutf8_dummy(void);
#endif
xterm-330/xtermcap.c0000644000175100001440000003662012720375370013243 0ustar  tomusers/* $XTermId: xtermcap.c,v 1.49 2016/05/22 18:31:20 tom Exp $ */

/*
 * Copyright 2007-2014,2016 by Thomas E. Dickey
 *
 *                         All Rights Reserved
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name(s) of the above copyright
 * holders shall not be used in advertising or otherwise to promote the
 * sale, use or other dealings in this Software without prior written
 * authorization.
 */

#include 
#include 

#include 
#include 

#ifdef VMS
#include 
#endif

#include 

#if USE_TERMINFO && defined(NCURSES_VERSION) && defined(HAVE_USE_EXTENDED_NAMES)
#define USE_EXTENDED_NAMES 1
#else
#define USE_EXTENDED_NAMES 0
#endif

#if USE_TERMINFO
#define TcapInit(buffer, name) (setupterm(name, fileno(stdout), &ignored) == OK)
#else
#define TcapInit(buffer, name) (tgetent(buffer, name) == 1)
#endif

#define NO_STRING (char *)(-1)

#if OPT_TCAP_QUERY || OPT_TCAP_FKEYS

#define SHIFT (MOD_NONE + MOD_SHIFT)

typedef struct {
    const char *tc;
    const char *ti;
    int code;
    unsigned param;		/* see xtermStateToParam() */
} TCAPINFO;
/* *INDENT-OFF* */
#define DATA(tc,ti,x,y) { tc, ti, x, y }
static const TCAPINFO table[] = {
	/*	tcap	terminfo	code		state */
	DATA(	"%1",	"khlp",		XK_Help,	0	),
	DATA(	"#1",	"kHLP",		XK_Help,	SHIFT	),
	DATA(	"@0",	"kfnd",		XK_Find,	0	),
	DATA(	"*0",	"kFND",		XK_Find,	SHIFT	),
	DATA(	"*6",	"kslt",		XK_Select,	0	),
	DATA(	"#6",	"kSLT",		XK_Select,	SHIFT	),

	DATA(	"kh",	"khome",	XK_Home,	0	),
	DATA(	"#2",	"kHOM",		XK_Home,	SHIFT	),
	DATA(	"@7",	"kend",		XK_End,		0	),
	DATA(	"*7",	"kEND",		XK_End,		SHIFT	),

	DATA(	"kl",	"kcub1",	XK_Left,	0	),
	DATA(	"kr",	"kcuf1",	XK_Right,	0	),
	DATA(	"ku",	"kcuu1",	XK_Up,		0	),
	DATA(	"kd",	"kcud1",	XK_Down,	0	),

	DATA(	"#4",	"kLFT",		XK_Left,	SHIFT	),
	DATA(	"%i",	"kRIT",		XK_Right,	SHIFT	),
	DATA(	"kF",	"kind",		XK_Down,	SHIFT	),
	DATA(	"kR",	"kri",		XK_Up,		SHIFT	),

	DATA(	"k1",	"kf1",		XK_Fn(1),	0	),
	DATA(	"k2",	"kf2",		XK_Fn(2),	0	),
	DATA(	"k3",	"kf3",		XK_Fn(3),	0	),
	DATA(	"k4",	"kf4",		XK_Fn(4),	0	),
	DATA(	"k5",	"kf5",		XK_Fn(5),	0	),
	DATA(	"k6",	"kf6",		XK_Fn(6),	0	),
	DATA(	"k7",	"kf7",		XK_Fn(7),	0	),
	DATA(	"k8",	"kf8",		XK_Fn(8),	0	),
	DATA(	"k9",	"kf9",		XK_Fn(9),	0	),
	DATA(	"k;",	"kf10",		XK_Fn(10),	0	),

	DATA(	"F1",	"kf11",		XK_Fn(11),	0	),
	DATA(	"F2",	"kf12",		XK_Fn(12),	0	),
	DATA(	"F3",	"kf13",		XK_Fn(13),	0	),
	DATA(	"F4",	"kf14",		XK_Fn(14),	0	),
	DATA(	"F5",	"kf15",		XK_Fn(15),	0	),
	DATA(	"F6",	"kf16",		XK_Fn(16),	0	),
	DATA(	"F7",	"kf17",		XK_Fn(17),	0	),
	DATA(	"F8",	"kf18",		XK_Fn(18),	0	),
	DATA(	"F9",	"kf19",		XK_Fn(19),	0	),
	DATA(	"FA",	"kf20",		XK_Fn(20),	0	),
	DATA(	"FB",	"kf21",		XK_Fn(21),	0	),
	DATA(	"FC",	"kf22",		XK_Fn(22),	0	),
	DATA(	"FD",	"kf23",		XK_Fn(23),	0	),
	DATA(	"FE",	"kf24",		XK_Fn(24),	0	),
	DATA(	"FF",	"kf25",		XK_Fn(25),	0	),
	DATA(	"FG",	"kf26",		XK_Fn(26),	0	),
	DATA(	"FH",	"kf27",		XK_Fn(27),	0	),
	DATA(	"FI",	"kf28",		XK_Fn(28),	0	),
	DATA(	"FJ",	"kf29",		XK_Fn(29),	0	),
	DATA(	"FK",	"kf30",		XK_Fn(30),	0	),
	DATA(	"FL",	"kf31",		XK_Fn(31),	0	),
	DATA(	"FM",	"kf32",		XK_Fn(32),	0	),
	DATA(	"FN",	"kf33",		XK_Fn(33),	0	),
	DATA(	"FO",	"kf34",		XK_Fn(34),	0	),
	DATA(	"FP",	"kf35",		XK_Fn(35),	0	),

	DATA(	"FQ",	"kf36",		-36,		0	),
	DATA(	"FR",	"kf37",		-37,		0	),
	DATA(	"FS",	"kf38",		-38,		0	),
	DATA(	"FT",	"kf39",		-39,		0	),
	DATA(	"FU",	"kf40",		-40,		0	),
	DATA(	"FV",	"kf41",		-41,		0	),
	DATA(	"FW",	"kf42",		-42,		0	),
	DATA(	"FX",	"kf43",		-43,		0	),
	DATA(	"FY",	"kf44",		-44,		0	),
	DATA(	"FZ",	"kf45",		-45,		0	),
	DATA(	"Fa",	"kf46",		-46,		0	),
	DATA(	"Fb",	"kf47",		-47,		0	),
	DATA(	"Fc",	"kf48",		-48,		0	),
	DATA(	"Fd",	"kf49",		-49,		0	),
	DATA(	"Fe",	"kf50",		-50,		0	),
	DATA(	"Ff",	"kf51",		-51,		0	),
	DATA(	"Fg",	"kf52",		-52,		0	),
	DATA(	"Fh",	"kf53",		-53,		0	),
	DATA(	"Fi",	"kf54",		-54,		0	),
	DATA(	"Fj",	"kf55",		-55,		0	),
	DATA(	"Fk",	"kf56",		-56,		0	),
	DATA(	"Fl",	"kf57",		-57,		0	),
	DATA(	"Fm",	"kf58",		-58,		0	),
	DATA(	"Fn",	"kf59",		-59,		0	),
	DATA(	"Fo",	"kf60",		-60,		0	),
	DATA(	"Fp",	"kf61",		-61,		0	),
	DATA(	"Fq",	"kf62",		-62,		0	),
	DATA(	"Fr",	"kf63",		-63,		0	),

	DATA(	"K1",	"ka1",		XK_KP_Home,	0	),
	DATA(	"K4",	"kc1",		XK_KP_End,	0	),
	DATA(	"K3",	"ka3",		XK_KP_Prior,	0	),
	DATA(	"K5",	"kc3",		XK_KP_Next,	0	),

#ifdef XK_ISO_Left_Tab
	DATA(	"kB",	"kcbt",		XK_ISO_Left_Tab, 0	),
#endif
	DATA(	"kC",	"kclr",		XK_Clear,	0	),
	DATA(	"kD",	"kdch1",	XK_Delete,	0	),
	DATA(	"kI",	"kich1",	XK_Insert,	0	),

	DATA(	"kN",	"knp",		XK_Next,	0	),
	DATA(	"kP",	"kpp",		XK_Prior,	0	),
	DATA(	"%c",	"kNXT",		XK_Next,	SHIFT	),
	DATA(	"%e",	"kPRV",		XK_Prior,	SHIFT	),

	DATA(	"&8",	"kund",		XK_Undo,	0	),
	DATA(	"kb",	"kbs",		XK_BackSpace,	0	),
# if OPT_TCAP_QUERY && OPT_ISO_COLORS
	/* XK_COLORS is a fake code. */
	DATA(	"Co",	"colors",	XK_COLORS,	0	),
# endif
	DATA(	"TN",	"name",		XK_TCAPNAME,	0	),
#if USE_EXTENDED_NAMES
#define DEXT(name, parm, code) DATA("", name, code, parm)
#define D1ST(name, parm, code) DEXT("k" #name, parm, code)
#define DMOD(name, parm, code) DEXT("k" #name #parm, parm, code)

#define DGRP(name, code) \
	D1ST(name, 2, code), \
	DMOD(name, 3, code), \
	DMOD(name, 4, code), \
	DMOD(name, 5, code), \
	DMOD(name, 6, code), \
	DMOD(name, 7, code), \
	DMOD(name, 8, code)

	/* the terminfo codes here are ncurses extensions */
	/* ignore the termcap names, which are empty */
	DATA(	"",	"kUP",		XK_Up,		SHIFT	),
	DATA(	"",	"kDN",		XK_Up,		SHIFT	),

	DGRP(DN,   XK_Down),
	DGRP(LFT,  XK_Left),
	DGRP(RIT,  XK_Right),
	DGRP(UP,   XK_Up),
	DGRP(DC,   XK_Delete),
	DGRP(END,  XK_End),
	DGRP(HOM,  XK_Home),
	DGRP(IC,   XK_Insert),
	DGRP(NXT,  XK_Next),
	DGRP(PRV,  XK_Prior),
#endif
};
#undef DATA
/* *INDENT-ON* */

#if OPT_TCAP_FKEYS
static Boolean
loadTermcapStrings(TScreen *screen)
{
    Boolean result = True;

    if (screen->tcap_fkeys == 0) {
	Cardinal want = XtNumber(table);
	Cardinal have;
#ifdef USE_TERMCAP
	char *area = screen->tcap_area;
#endif

	TRACE(("loadTermcapStrings\n"));
	if ((screen->tcap_fkeys = TypeCallocN(char *, want)) != 0) {

	    for (have = 0; have < want; ++have) {
		char name[80];
		char *fkey;

#ifndef USE_TERMCAP
		fkey = tigetstr(strcpy(name, table[have].ti));
#else
		fkey = tgetstr(strcpy(name, table[have].tc), &area);
#endif
		if (fkey != 0 && fkey != NO_STRING) {
		    screen->tcap_fkeys[have] = x_strdup(fkey);
		} else {
		    screen->tcap_fkeys[have] = NO_STRING;
		}
	    }
	} else {
	    result = False;
	}
    }
    return result;
}
#endif

#if OPT_TCAP_QUERY
static Boolean
keyIsDistinct(XtermWidget xw, int which)
{
    Boolean result = True;

    switch (xw->keyboard.type) {
    case keyboardIsTermcap:
#if OPT_TCAP_FKEYS
	if (table[which].param == SHIFT) {
	    TScreen *screen = TScreenOf(xw);
	    Cardinal k;

	    if (loadTermcapStrings(screen)
		&& screen->tcap_fkeys[which] != NO_STRING) {

		for (k = 0; k < XtNumber(table); k++) {

		    if (table[k].code == table[which].code
			&& table[k].param == 0) {
			char *fkey;

			if ((fkey = screen->tcap_fkeys[k]) != NO_STRING
			    && !strcmp(fkey, screen->tcap_fkeys[which])) {
			    TRACE(("shifted/unshifted keys do not differ\n"));
			    result = False;
			}
			break;
		    }
		}
	    } else {
		/* there is no data for the shifted key */
		result = -1;
	    }
	}
#endif
	break;
	/*
	 * The vt220-keyboard will not return distinct key sequences for
	 * shifted cursor-keys.  Just pretend they do not exist, since some
	 * programs may be confused if we return the same data for
	 * shifted/unshifted keys.
	 */
    case keyboardIsVT220:
	if (table[which].param == SHIFT) {
	    TRACE(("shifted/unshifted keys do not differ\n"));
	    result = False;
	}
	break;
    case keyboardIsLegacy:
    case keyboardIsDefault:
    case keyboardIsHP:
    case keyboardIsSCO:
    case keyboardIsSun:
	break;
    }

    return result;
}

static int
lookupTcapByName(const char *name)
{
    int result = -2;
    Cardinal j;

    if (!IsEmpty(name)) {
	for (j = 0; j < XtNumber(table); j++) {
	    if (!strcmp(table[j].ti, name) || !strcmp(table[j].tc, name)) {
		result = (int) j;
		break;
	    }
	}
    }

    if (result >= 0) {
	TRACE(("lookupTcapByName(%s) tc=%s, ti=%s code %#x, param %#x\n",
	       name,
	       table[result].tc,
	       table[result].ti,
	       table[result].code,
	       table[result].param));
    } else {
	TRACE(("lookupTcapByName(%s) FAIL\n", name));
    }
    return result;
}

/*
 * Parse the termcap/terminfo name from the string, returning a positive number
 * (the keysym) if found, otherwise -1.  Update the string pointer.
 * Returns the (shift, control) state in *state.
 *
 * This does not attempt to construct control/shift modifiers to construct
 * function-key values.  Instead, it sets the *fkey flag to pass to Input()
 * and bypass the lookup of keysym altogether.
 */
int
xtermcapKeycode(XtermWidget xw, const char **params, unsigned *state, Bool *fkey)
{
    const TCAPINFO *data;
    int code = -1;
    char *name;
    const char *p;

    TRACE(("xtermcapKeycode(%s)\n", *params));

    /* Convert hex encoded name to ascii */
    name = x_decode_hex(*params, &p);
    *params = p;

    *state = 0;
    *fkey = False;

    if (!IsEmpty(name) && (*p == 0 || *p == ';')) {
	int which;

	if ((which = lookupTcapByName(name)) >= 0) {
	    if (keyIsDistinct(xw, which)) {
		data = table + which;
		code = data->code;
		*state = xtermParamToState(xw, data->param);
		if (IsFunctionKey(code)) {
		    *fkey = True;
		} else if (code < 0) {
		    *fkey = True;
		    code = XK_Fn((-code));
		}
#if OPT_SUN_FUNC_KEYS
		if (*fkey && xw->keyboard.type == keyboardIsSun) {
		    int num = code - XK_Fn(0);

		    /* match function-key case in sunfuncvalue() */
		    if (num > 20) {
			if (num <= 30 || num > 47) {
			    code = -1;
			} else {
			    code -= 10;
			    switch (num) {
			    case 37:	/* khome */
			    case 39:	/* kpp */
			    case 41:	/* kb2 */
			    case 43:	/* kend */
			    case 45:	/* knp */
				code = -1;
				break;
			    }
			}
		    }
		}
#endif
	    } else {
		TRACE(("... name ok, data not ok\n"));
		code = -1;
	    }
	} else {
	    TRACE(("... name not ok\n"));
	    code = -2;
	}
    } else {
	TRACE(("... name not ok\n"));
	code = -2;
    }

    TRACE(("... xtermcapKeycode(%s, %u, %d) -> %#06x\n",
	   name, *state, *fkey, code));
    free(name);
    return code;
}
#endif /* OPT_TCAP_QUERY */

#if OPT_TCAP_FKEYS
static int
nextTcapByCode(int code, unsigned param, int last)
{
    int result = -1;
    int n;

    TRACE(("lookupTcapByCode %#x:%#x\n", code, param));
    for (n = last + 1; n < (int) XtNumber(table); n++) {
	if (table[n].code == code &&
	    table[n].param == param) {
	    TRACE(("->lookupTcapByCode %d:%s\n", n, table[n].ti));
	    result = n;
	    break;
	}
    }
    return result;
}

static int
firstTcapByCode(int code, unsigned param)
{
    return nextTcapByCode(code, param, -1);
}

int
xtermcapString(XtermWidget xw, int keycode, unsigned mask)
{
    int result = 0;
    unsigned param = xtermStateToParam(xw, mask);
    int which;

    if ((which = firstTcapByCode(keycode, param)) >= 0) {
	TScreen *screen = TScreenOf(xw);

	if (loadTermcapStrings(screen)) {
	    do {
		char *fkey;

		if ((fkey = screen->tcap_fkeys[which]) != NO_STRING) {
		    StringInput(xw, (Char *) fkey, strlen(fkey));
		    result = 1;
		    break;
		}
	    } while ((which = nextTcapByCode(keycode, param, which)) >= 0);
	}
    }

    TRACE(("xtermcapString(keycode=%#x, mask=%#x) ->%d\n",
	   keycode, mask, result));

    return result;
}
#endif /* OPT_TCAP_FKEYS */

#endif /* OPT_TCAP_QUERY || OPT_TCAP_FKEYS */

/*
 * If we're linked to terminfo, tgetent() will return an empty buffer.  We
 * cannot use that to adjust the $TERMCAP variable.
 */
Bool
get_termcap(XtermWidget xw, char *name)
{
#if USE_TERMINFO
    int ignored = 0;
#endif
    char *buffer = get_tcap_buffer(xw);

    *buffer = 0;		/* initialize, in case we're using terminfo's tgetent */

#if USE_EXTENDED_NAMES
    use_extended_names(TRUE);
#endif
    if (!IsEmpty(name)) {
	if (TcapInit(buffer, name)) {
	    TRACE(("get_termcap(%s) succeeded (%s)\n", name,
		   (*buffer
		    ? "ok:termcap, we can update $TERMCAP"
		    : "assuming this is terminfo")));
	    return True;
	} else {
	    *buffer = 0;	/* just in case */
	}
    }
    return False;
}

/*
 * Retrieve the termcap-buffer.
 */
char *
get_tcap_buffer(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);
    char *buffer;

#if OPT_TEK4014
    if (TEK4014_ACTIVE(xw)) {
	buffer = TekScreenOf(tekWidget)->tcapbuf;
    } else
#endif
    {
	buffer = screen->tcapbuf;
    }
    return buffer;
}

/*
 * Retrieve the erase-key, for initialization in main program.
 */
char *
get_tcap_erase(XtermWidget xw GCC_UNUSED)
{
#ifdef USE_TERMCAP
    char *area = TScreenOf(xw)->tcap_area;
#endif
    char *fkey;

#ifndef USE_TERMCAP
    fkey = tigetstr("kbs");
#else
    fkey = tgetstr("kb", &area);
#endif

    if (fkey == NO_STRING)
	fkey = 0;
    if (fkey != 0)
	fkey = x_strdup(fkey);
    return fkey;
}

/*
 * A legal termcap (or terminfo) name consists solely of graphic characters,
 * excluding the punctuation used to delimit fields of the source description.
 */
static Bool
isLegalTcapName(const char *name)
{
    Bool result = False;

    if (*name != '\0') {
	result = True;
	while (*name != '\0') {
	    if (isgraph(CharOf(*name))) {
		if (strchr("\\|,:'\"", *name) != 0) {
		    result = False;
		    break;
		}
	    } else {
		result = False;
		break;
	    }
	    ++name;
	}
    }

    return result;
}

void
set_termcap(XtermWidget xw, const char *name)
{
    Boolean success = False;
#if USE_TERMINFO
    int ignored = 0;
#else
    TScreen *screen = TScreenOf(xw);
    char buffer[sizeof(screen->tcapbuf)];
#endif

    TRACE(("set_termcap(%s)\n", NonNull(name)));
    if (IsEmpty(name)) {
	Bell(xw, XkbBI_MinorError, 0);
    } else {
	const char *temp;
	char *value;

	if ((value = x_decode_hex(name, &temp)) != 0) {
	    if (*temp == '\0' && isLegalTcapName(value)) {
		if (TcapInit(buffer, value)) {
#if !USE_TERMINFO
		    memcpy(screen->tcapbuf, buffer, sizeof(buffer));
#endif
		    free_termcap(xw);
		    success = True;
		}
	    }
	    free(value);
	}
    }
    if (!success)
	Bell(xw, XkbBI_MinorError, 0);
}

void
free_termcap(XtermWidget xw)
{
#if OPT_TCAP_FKEYS
    TScreen *screen = TScreenOf(xw);

    if (screen->tcap_fkeys != 0) {
	Cardinal want = XtNumber(table);
	Cardinal have;

	for (have = 0; have < want; ++have) {
	    char *fkey = screen->tcap_fkeys[have];
	    if (fkey != 0 && fkey != NO_STRING) {
		free(fkey);
	    }
	}
	free(screen->tcap_fkeys);
	screen->tcap_fkeys = 0;
    }
#endif
}
xterm-330/charproc.c0000644000175100001440000115155013121706256013217 0ustar  tomusers/* $XTermId: charproc.c,v 1.1492 2017/06/19 08:34:54 tom Exp $ */

/*
 * Copyright 1999-2016,2017 by Thomas E. Dickey
 *
 *                         All Rights Reserved
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name(s) of the above copyright
 * holders shall not be used in advertising or otherwise to promote the
 * sale, use or other dealings in this Software without prior written
 * authorization.
 *
 *
 * Copyright 1988  The Open Group
 *
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that
 * copyright notice and this permission notice appear in supporting
 * documentation.
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 * OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name of The Open Group shall not be
 * used in advertising or otherwise to promote the sale, use or other dealings
 * in this Software without prior written authorization from The Open Group.
 *
 */
/*
 * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 *
 *                         All Rights Reserved
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose and without fee is hereby granted,
 * provided that the above copyright notice appear in all copies and that
 * both that copyright notice and this permission notice appear in
 * supporting documentation, and that the name of Digital Equipment
 * Corporation not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 *
 *
 * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */

/* charproc.c */

#include 
#include 

#include 
#include 
#include 
#include 
#include 
#include 

#if OPT_INPUT_METHOD

#if defined(HAVE_LIB_XAW)
#include 
#elif defined(HAVE_LIB_XAW3D)
#include 
#elif defined(HAVE_LIB_XAW3DXFT)
#include 
#elif defined(HAVE_LIB_NEXTAW)
#include 
#elif defined(HAVE_LIB_XAWPLUS)
#include 
#endif

#endif

#if OPT_DOUBLE_BUFFER
#include 
#endif

#if OPT_WIDE_CHARS
#include 
#include 
#include 
#ifdef HAVE_LANGINFO_CODESET
#include 
#endif
#endif

#if OPT_INPUT_METHOD
#include 
#endif

#include 
#include 
#include 

#if defined(HAVE_SCHED_YIELD)
#include 
#endif

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

typedef int (*BitFunc) (unsigned * /* p */ ,
			unsigned /* mask */ );

static IChar doinput(void);
static int set_character_class(char * /*s */ );
static void FromAlternate(XtermWidget /* xw */ );
static void ReallyReset(XtermWidget /* xw */ ,
			Bool /* full */ ,
			Bool /* saved */ );
static void RequestResize(XtermWidget /* xw */ ,
			  int /* rows */ ,
			  int /* cols */ ,
			  Bool /* text */ );
static void SwitchBufs(XtermWidget /* xw */ ,
		       int /* toBuf */ ,
		       Bool /* clearFirst */ );
static void ToAlternate(XtermWidget /* xw */ ,
			Bool /* clearFirst */ );
static void ansi_modes(XtermWidget termw,
		       BitFunc /* func */ );
static int bitclr(unsigned *p, unsigned mask);
static int bitcpy(unsigned *p, unsigned q, unsigned mask);
static int bitset(unsigned *p, unsigned mask);
static void dpmodes(XtermWidget /* xw */ ,
		    BitFunc /* func */ );
static void restoremodes(XtermWidget /* xw */ );
static void savemodes(XtermWidget /* xw */ );
static void window_ops(XtermWidget /* xw */ );

#define DoStartBlinking(s) ((s)->cursor_blink ^ (s)->cursor_blink_esc)

#if OPT_BLINK_CURS || OPT_BLINK_TEXT
#define UpdateCursorBlink(screen) SetCursorBlink(screen, screen->cursor_blink)
static void SetCursorBlink(TScreen * /* screen */ ,
			   Bool /* enable */ );
static void HandleBlinking(XtPointer /* closure */ ,
			   XtIntervalId * /* id */ );
static void StartBlinking(TScreen * /* screen */ );
static void StopBlinking(TScreen * /* screen */ );
#else
#define StartBlinking(screen)	/* nothing */
#define StopBlinking(screen)	/* nothing */
#endif

#if OPT_I18N_SUPPORT && OPT_INPUT_METHOD
static void PreeditPosition(XtermWidget /* xw */ );
#endif

#define	DEFAULT		-1
#define BELLSUPPRESSMSEC 200

static ANSI reply;
static PARAMS parms;

#define nparam parms.count

#define InitParams()  parms.count = parms.is_sub[0] = parms.has_subparams = 0
#define GetParam(n)   parms.params[(n)]
#define SetParam(n,v) parms.params[(n)] = v
#define ParamPair(n)  nparam - (n), parms.params + (n)
#define ParamsDone()  InitParams()

static jmp_buf vtjmpbuf;

/* event handlers */
static void HandleBell PROTO_XT_ACTIONS_ARGS;
static void HandleIgnore PROTO_XT_ACTIONS_ARGS;
static void HandleKeymapChange PROTO_XT_ACTIONS_ARGS;
static void HandleVisualBell PROTO_XT_ACTIONS_ARGS;
#if HANDLE_STRUCT_NOTIFY
static void HandleStructNotify PROTO_XT_EV_HANDLER_ARGS;
#endif

/*
 * NOTE: VTInitialize zeros out the entire ".screen" component of the
 * XtermWidget, so make sure to add an assignment statement in VTInitialize()
 * for each new ".screen" field added to this resource list.
 */

/* Defaults */
#if OPT_ISO_COLORS

/*
 * If we default to colorMode enabled, compile-in defaults for the ANSI colors.
 */
#if DFT_COLORMODE
#define DFT_COLOR(name) name
#else
#define DFT_COLOR(name) XtDefaultForeground
#endif
#endif

static char _Font_Selected_[] = "yes";	/* string is arbitrary */

static const char *defaultTranslations;
/* *INDENT-OFF* */
static XtActionsRec actionsList[] = {
    { "allow-bold-fonts",	HandleAllowBoldFonts },
    { "allow-send-events",	HandleAllowSends },
    { "bell",			HandleBell },
    { "clear-saved-lines",	HandleClearSavedLines },
    { "copy-selection",		HandleCopySelection },
    { "create-menu",		HandleCreateMenu },
    { "delete-is-del",		HandleDeleteIsDEL },
    { "dired-button",		DiredButton },
    { "hard-reset",		HandleHardReset },
    { "ignore",			HandleIgnore },
    { "insert",			HandleKeyPressed },  /* alias for insert-seven-bit */
    { "insert-eight-bit",	HandleEightBitKeyPressed },
    { "insert-selection",	HandleInsertSelection },
    { "insert-seven-bit",	HandleKeyPressed },
    { "interpret",		HandleInterpret },
    { "keymap",			HandleKeymapChange },
    { "popup-menu",		HandlePopupMenu },
    { "print",			HandlePrintScreen },
    { "print-everything",	HandlePrintEverything },
    { "print-redir",		HandlePrintControlMode },
    { "quit",			HandleQuit },
    { "redraw",			HandleRedraw },
    { "scroll-back",		HandleScrollBack },
    { "scroll-forw",		HandleScrollForward },
    { "secure",			HandleSecure },
    { "select-cursor-end",	HandleKeyboardSelectEnd },
    { "select-cursor-extend",   HandleKeyboardSelectExtend },
    { "select-cursor-start",	HandleKeyboardSelectStart },
    { "select-end",		HandleSelectEnd },
    { "select-extend",		HandleSelectExtend },
    { "select-set",		HandleSelectSet },
    { "select-start",		HandleSelectStart },
    { "send-signal",		HandleSendSignal },
    { "set-8-bit-control",	Handle8BitControl },
    { "set-allow132",		HandleAllow132 },
    { "set-altscreen",		HandleAltScreen },
    { "set-appcursor",		HandleAppCursor },
    { "set-appkeypad",		HandleAppKeypad },
    { "set-autolinefeed",	HandleAutoLineFeed },
    { "set-autowrap",		HandleAutoWrap },
    { "set-backarrow",		HandleBackarrow },
    { "set-bellIsUrgent",	HandleBellIsUrgent },
    { "set-cursesemul",		HandleCursesEmul },
    { "set-jumpscroll",		HandleJumpscroll },
    { "set-keep-clipboard",	HandleKeepClipboard },
    { "set-keep-selection",	HandleKeepSelection },
    { "set-marginbell",		HandleMarginBell },
    { "set-old-function-keys",	HandleOldFunctionKeys },
    { "set-pop-on-bell",	HandleSetPopOnBell },
    { "set-reverse-video",	HandleReverseVideo },
    { "set-reversewrap",	HandleReverseWrap },
    { "set-scroll-on-key",	HandleScrollKey },
    { "set-scroll-on-tty-output", HandleScrollTtyOutput },
    { "set-scrollbar",		HandleScrollbar },
    { "set-select",		HandleSetSelect },
    { "set-sun-keyboard",	HandleSunKeyboard },
    { "set-titeInhibit",	HandleTiteInhibit },
    { "set-visual-bell",	HandleSetVisualBell },
    { "set-vt-font",		HandleSetFont },
    { "soft-reset",		HandleSoftReset },
    { "start-cursor-extend",	HandleKeyboardStartExtend },
    { "start-extend",		HandleStartExtend },
    { "string",			HandleStringEvent },
    { "vi-button",		ViButton },
    { "visual-bell",		HandleVisualBell },
#ifdef ALLOWLOGGING
    { "set-logging",		HandleLogging },
#endif
#if OPT_ALLOW_XXX_OPS
    { "allow-color-ops",	HandleAllowColorOps },
    { "allow-font-ops",		HandleAllowFontOps },
    { "allow-mouse-ops",	HandleAllowMouseOps },
    { "allow-tcap-ops",		HandleAllowTcapOps },
    { "allow-title-ops",	HandleAllowTitleOps },
    { "allow-window-ops",	HandleAllowWindowOps },
#endif
#if OPT_BLINK_CURS
    { "set-cursorblink",	HandleCursorBlink },
#endif
#if OPT_BOX_CHARS
    { "set-font-linedrawing",	HandleFontBoxChars },
    { "set-font-packed",	HandleFontPacked },
#endif
#if OPT_DABBREV
    { "dabbrev-expand",		HandleDabbrevExpand },
#endif
#if OPT_DEC_CHRSET
    { "set-font-doublesize",	HandleFontDoublesize },
#endif
#if OPT_DEC_SOFTFONT
    { "set-font-loading",	HandleFontLoading },
#endif
#if OPT_SCREEN_DUMPS
    { "dump-html",	        HandleDumpHtml },
    { "dump-svg",	        HandleDumpSvg },
#endif
#if OPT_EXEC_XTERM
    { "spawn-new-terminal",	HandleSpawnTerminal },
#endif
#if OPT_HP_FUNC_KEYS
    { "set-hp-function-keys",	HandleHpFunctionKeys },
#endif
#if OPT_LOAD_VTFONTS
    { "load-vt-fonts",		HandleLoadVTFonts },
#endif
#if OPT_MAXIMIZE
    { "deiconify",		HandleDeIconify },
    { "fullscreen",		HandleFullscreen },
    { "iconify",		HandleIconify },
    { "maximize",		HandleMaximize },
    { "restore",		HandleRestoreSize },
#endif
#if OPT_NUM_LOCK
    { "alt-sends-escape",	HandleAltEsc },
    { "meta-sends-escape",	HandleMetaEsc },
    { "set-num-lock",		HandleNumLock },
#endif
#if OPT_READLINE
    { "readline-button",	ReadLineButton },
#endif
#if OPT_RENDERFONT
    { "set-render-font",	HandleRenderFont },
#endif
#if OPT_SCO_FUNC_KEYS
    { "set-sco-function-keys",	HandleScoFunctionKeys },
#endif
#if OPT_SCROLL_LOCK
    { "scroll-lock",		HandleScrollLock },
#endif
#if OPT_SELECTION_OPS
    { "exec-formatted",		HandleExecFormatted },
    { "exec-selectable",	HandleExecSelectable },
    { "insert-formatted",	HandleInsertFormatted },
    { "insert-selectable",	HandleInsertSelectable },
#endif
#if OPT_SHIFT_FONTS
    { "larger-vt-font",		HandleLargerFont },
    { "smaller-vt-font",	HandleSmallerFont },
#endif
#if OPT_SIXEL_GRAPHICS
    { "set-sixel-scrolling",	HandleSixelScrolling },
#endif
#if OPT_GRAPHICS
    { "set-private-colors",	HandleSetPrivateColorRegisters },
#endif
#if OPT_SUN_FUNC_KEYS
    { "set-sun-function-keys",	HandleSunFunctionKeys },
#endif
#if OPT_TEK4014
    { "set-terminal-type",	HandleSetTerminalType },
    { "set-visibility",		HandleVisibility },
    { "set-tek-text",		HandleSetTekText },
    { "tek-page",		HandleTekPage },
    { "tek-reset",		HandleTekReset },
    { "tek-copy",		HandleTekCopy },
#endif
#if OPT_TOOLBAR
    { "set-toolbar",		HandleToolbar },
#endif
#if OPT_WIDE_CHARS
    { "set-utf8-mode",		HandleUTF8Mode },
    { "set-utf8-fonts",		HandleUTF8Fonts },
    { "set-utf8-title",		HandleUTF8Title },
#endif
};
/* *INDENT-ON* */

#define SPS screen.printer_state

static XtResource xterm_resources[] =
{
    Bres(XtNallowPasteControls, XtCAllowPasteControls,
	 screen.allowPasteControl0, False),
    Bres(XtNallowSendEvents, XtCAllowSendEvents, screen.allowSendEvent0, False),
    Bres(XtNallowColorOps, XtCAllowColorOps, screen.allowColorOp0, DEF_ALLOW_COLOR),
    Bres(XtNallowFontOps, XtCAllowFontOps, screen.allowFontOp0, DEF_ALLOW_FONT),
    Bres(XtNallowMouseOps, XtCAllowMouseOps, screen.allowMouseOp0, DEF_ALLOW_MOUSE),
    Bres(XtNallowTcapOps, XtCAllowTcapOps, screen.allowTcapOp0, DEF_ALLOW_TCAP),
    Bres(XtNallowTitleOps, XtCAllowTitleOps, screen.allowTitleOp0, DEF_ALLOW_TITLE),
    Bres(XtNallowWindowOps, XtCAllowWindowOps, screen.allowWindowOp0, DEF_ALLOW_WINDOW),
    Bres(XtNaltIsNotMeta, XtCAltIsNotMeta, screen.alt_is_not_meta, False),
    Bres(XtNaltSendsEscape, XtCAltSendsEscape, screen.alt_sends_esc, DEF_ALT_SENDS_ESC),
    Bres(XtNallowBoldFonts, XtCAllowBoldFonts, screen.allowBoldFonts, True),
    Bres(XtNalwaysBoldMode, XtCAlwaysBoldMode, screen.always_bold_mode, False),
    Bres(XtNalwaysHighlight, XtCAlwaysHighlight, screen.always_highlight, False),
    Bres(XtNappcursorDefault, XtCAppcursorDefault, misc.appcursorDefault, False),
    Bres(XtNappkeypadDefault, XtCAppkeypadDefault, misc.appkeypadDefault, False),
    Bres(XtNalternateScroll, XtCScrollCond, screen.alternateScroll, False),
    Bres(XtNautoWrap, XtCAutoWrap, misc.autoWrap, True),
    Bres(XtNawaitInput, XtCAwaitInput, screen.awaitInput, False),
    Bres(XtNfreeBoldBox, XtCFreeBoldBox, screen.free_bold_box, False),
    Bres(XtNbackarrowKey, XtCBackarrowKey, screen.backarrow_key, DEF_BACKARO_BS),
    Bres(XtNbellIsUrgent, XtCBellIsUrgent, screen.bellIsUrgent, False),
    Bres(XtNbellOnReset, XtCBellOnReset, screen.bellOnReset, True),
    Bres(XtNboldMode, XtCBoldMode, screen.bold_mode, True),
    Bres(XtNbrokenSelections, XtCBrokenSelections, screen.brokenSelections, False),
    Bres(XtNc132, XtCC132, screen.c132, False),
    Bres(XtNcdXtraScroll, XtCCdXtraScroll, misc.cdXtraScroll, False),
    Bres(XtNcurses, XtCCurses, screen.curses, False),
    Bres(XtNcutNewline, XtCCutNewline, screen.cutNewline, True),
    Bres(XtNcutToBeginningOfLine, XtCCutToBeginningOfLine,
	 screen.cutToBeginningOfLine, True),
    Bres(XtNdeleteIsDEL, XtCDeleteIsDEL, screen.delete_is_del, DEFDELETE_DEL),
    Bres(XtNdynamicColors, XtCDynamicColors, misc.dynamicColors, True),
    Bres(XtNeightBitControl, XtCEightBitControl, screen.control_eight_bits, False),
    Bres(XtNeightBitInput, XtCEightBitInput, screen.input_eight_bits, True),
    Bres(XtNeightBitOutput, XtCEightBitOutput, screen.output_eight_bits, True),
    Bres(XtNeraseSavedLines, XtCEraseSavedLines, screen.eraseSavedLines0, True),
    Bres(XtNhighlightSelection, XtCHighlightSelection,
	 screen.highlight_selection, False),
    Bres(XtNshowWrapMarks, XtCShowWrapMarks, screen.show_wrap_marks, False),
    Bres(XtNhpLowerleftBugCompat, XtCHpLowerleftBugCompat, screen.hp_ll_bc, False),
    Bres(XtNi18nSelections, XtCI18nSelections, screen.i18nSelections, True),
    Bres(XtNfastScroll, XtCFastScroll, screen.fastscroll, False),
    Bres(XtNjumpScroll, XtCJumpScroll, screen.jumpscroll, True),
    Bres(XtNkeepClipboard, XtCKeepClipboard, screen.keepClipboard, False),
    Bres(XtNkeepSelection, XtCKeepSelection, screen.keepSelection, True),
    Bres(XtNloginShell, XtCLoginShell, misc.login_shell, False),
    Bres(XtNmarginBell, XtCMarginBell, screen.marginbell, False),
    Bres(XtNmetaSendsEscape, XtCMetaSendsEscape, screen.meta_sends_esc, DEF_META_SENDS_ESC),
    Bres(XtNmultiScroll, XtCMultiScroll, screen.multiscroll, False),
    Bres(XtNoldXtermFKeys, XtCOldXtermFKeys, screen.old_fkeys, False),
    Bres(XtNpopOnBell, XtCPopOnBell, screen.poponbell, False),
    Bres(XtNprinterAutoClose, XtCPrinterAutoClose, SPS.printer_autoclose, False),
    Bres(XtNprinterExtent, XtCPrinterExtent, SPS.printer_extent, False),
    Bres(XtNprinterFormFeed, XtCPrinterFormFeed, SPS.printer_formfeed, False),
    Bres(XtNprinterNewLine, XtCPrinterNewLine, SPS.printer_newline, True),
    Bres(XtNquietGrab, XtCQuietGrab, screen.quiet_grab, False),
    Bres(XtNreverseVideo, XtCReverseVideo, misc.re_verse, False),
    Bres(XtNreverseWrap, XtCReverseWrap, misc.reverseWrap, False),
    Bres(XtNscrollBar, XtCScrollBar, misc.scrollbar, False),
    Bres(XtNscrollKey, XtCScrollCond, screen.scrollkey, False),
    Bres(XtNscrollTtyOutput, XtCScrollCond, screen.scrollttyoutput, True),
    Bres(XtNselectToClipboard, XtCSelectToClipboard,
	 screen.selectToClipboard, False),
    Bres(XtNsignalInhibit, XtCSignalInhibit, misc.signalInhibit, False),
    Bres(XtNtiteInhibit, XtCTiteInhibit, misc.titeInhibit, False),
    Bres(XtNtiXtraScroll, XtCTiXtraScroll, misc.tiXtraScroll, False),
    Bres(XtNtrimSelection, XtCTrimSelection, screen.trim_selection, False),
    Bres(XtNunderLine, XtCUnderLine, screen.underline, True),
    Bres(XtNvisualBell, XtCVisualBell, screen.visualbell, False),
    Bres(XtNvisualBellLine, XtCVisualBellLine, screen.flash_line, False),

    Dres(XtNscaleHeight, XtCScaleHeight, screen.scale_height, "1.0"),

    Ires(XtNbellSuppressTime, XtCBellSuppressTime, screen.bellSuppressTime, BELLSUPPRESSMSEC),
    Ires(XtNfontWarnings, XtCFontWarnings, misc.fontWarnings, fwResource),
    Ires(XtNinternalBorder, XtCBorderWidth, screen.border, DEFBORDER),
    Ires(XtNlimitResize, XtCLimitResize, misc.limit_resize, 1),
    Ires(XtNmultiClickTime, XtCMultiClickTime, screen.multiClickTime, MULTICLICKTIME),
    Ires(XtNnMarginBell, XtCColumn, screen.nmarginbell, N_MARGINBELL),
    Ires(XtNpointerMode, XtCPointerMode, screen.pointer_mode, DEF_POINTER_MODE),
    Ires(XtNprinterControlMode, XtCPrinterControlMode,
	 SPS.printer_controlmode, 0),
    Ires(XtNtitleModes, XtCTitleModes, screen.title_modes, DEF_TITLE_MODES),
    Ires(XtNvisualBellDelay, XtCVisualBellDelay, screen.visualBellDelay, 100),
    Ires(XtNsaveLines, XtCSaveLines, screen.savelines, SAVELINES),
    Ires(XtNscrollBarBorder, XtCScrollBarBorder, screen.scrollBarBorder, 1),
    Ires(XtNscrollLines, XtCScrollLines, screen.scrolllines, SCROLLLINES),

    Sres(XtNinitialFont, XtCInitialFont, screen.initial_font, NULL),
    Sres(XtNfont1, XtCFont1, screen.MenuFontName(fontMenu_font1), NULL),
    Sres(XtNfont2, XtCFont2, screen.MenuFontName(fontMenu_font2), NULL),
    Sres(XtNfont3, XtCFont3, screen.MenuFontName(fontMenu_font3), NULL),
    Sres(XtNfont4, XtCFont4, screen.MenuFontName(fontMenu_font4), NULL),
    Sres(XtNfont5, XtCFont5, screen.MenuFontName(fontMenu_font5), NULL),
    Sres(XtNfont6, XtCFont6, screen.MenuFontName(fontMenu_font6), NULL),

    Sres(XtNanswerbackString, XtCAnswerbackString, screen.answer_back, ""),
    Sres(XtNboldFont, XtCBoldFont, misc.default_font.f_b, DEFBOLDFONT),
    Sres(XtNcharClass, XtCCharClass, screen.charClass, NULL),
    Sres(XtNdecTerminalID, XtCDecTerminalID, screen.term_id, DFT_DECID),
    Sres(XtNdefaultString, XtCDefaultString, screen.default_string, "#"),
    Sres(XtNdisallowedColorOps, XtCDisallowedColorOps,
	 screen.disallowedColorOps, DEF_DISALLOWED_COLOR),
    Sres(XtNdisallowedFontOps, XtCDisallowedFontOps,
	 screen.disallowedFontOps, DEF_DISALLOWED_FONT),
    Sres(XtNdisallowedMouseOps, XtCDisallowedMouseOps,
	 screen.disallowedMouseOps, DEF_DISALLOWED_MOUSE),
    Sres(XtNdisallowedTcapOps, XtCDisallowedTcapOps,
	 screen.disallowedTcapOps, DEF_DISALLOWED_TCAP),
    Sres(XtNdisallowedWindowOps, XtCDisallowedWindowOps,
	 screen.disallowedWinOps, DEF_DISALLOWED_WINDOW),
    Sres(XtNeightBitMeta, XtCEightBitMeta, screen.eight_bit_meta_s, DEF_8BIT_META),
    Sres(XtNeightBitSelectTypes, XtCEightBitSelectTypes,
	 screen.eightbit_select_types, NULL),
    Sres(XtNfont, XtCFont, misc.default_font.f_n, DEFFONT),
    Sres(XtNgeometry, XtCGeometry, misc.geo_metry, NULL),
    Sres(XtNkeyboardDialect, XtCKeyboardDialect, screen.keyboard_dialect, DFT_KBD_DIALECT),
    Sres(XtNprinterCommand, XtCPrinterCommand, SPS.printer_command, ""),
    Sres(XtNtekGeometry, XtCGeometry, misc.T_geometry, NULL),

    Tres(XtNcursorColor, XtCCursorColor, TEXT_CURSOR, XtDefaultForeground),
    Tres(XtNforeground, XtCForeground, TEXT_FG, XtDefaultForeground),
    Tres(XtNpointerColor, XtCPointerColor, MOUSE_FG, XtDefaultForeground),
    Tres(XtNbackground, XtCBackground, TEXT_BG, XtDefaultBackground),
    Tres(XtNpointerColorBackground, XtCBackground, MOUSE_BG, XtDefaultBackground),

    {XtNresizeGravity, XtCResizeGravity, XtRGravity, sizeof(XtGravity),
     XtOffsetOf(XtermWidgetRec, misc.resizeGravity),
     XtRImmediate, (XtPointer) SouthWestGravity},

    {XtNpointerShape, XtCCursor, XtRCursor, sizeof(Cursor),
     XtOffsetOf(XtermWidgetRec, screen.pointer_cursor),
     XtRString, (XtPointer) "xterm"},

#ifdef ALLOWLOGGING
    Bres(XtNlogInhibit, XtCLogInhibit, misc.logInhibit, False),
    Bres(XtNlogging, XtCLogging, misc.log_on, False),
    Sres(XtNlogFile, XtCLogfile, screen.logfile, NULL),
#endif

#ifndef NO_ACTIVE_ICON
    Sres("activeIcon", "ActiveIcon", misc.active_icon_s, "default"),
    Ires("iconBorderWidth", XtCBorderWidth, misc.icon_border_width, 2),
    Sres("iconFont", "IconFont", screen.icon_fontname, "nil2"),
    Cres("iconBorderColor", XtCBorderColor, misc.icon_border_pixel, XtDefaultBackground),
#endif				/* NO_ACTIVE_ICON */

#if OPT_BLINK_CURS
    Bres(XtNcursorBlink, XtCCursorBlink, screen.cursor_blink, False),
#endif
    Bres(XtNcursorUnderLine, XtCCursorUnderLine, screen.cursor_underline, False),

#if OPT_BLINK_TEXT
    Bres(XtNshowBlinkAsBold, XtCCursorBlink, screen.blink_as_bold, DEFBLINKASBOLD),
#endif

#if OPT_BLINK_CURS || OPT_BLINK_TEXT
    Ires(XtNcursorOnTime, XtCCursorOnTime, screen.blink_on, 600),
    Ires(XtNcursorOffTime, XtCCursorOffTime, screen.blink_off, 300),
#endif

#if OPT_BOX_CHARS
    Bres(XtNforceBoxChars, XtCForceBoxChars, screen.force_box_chars, False),
    Bres(XtNforcePackedFont, XtCForcePackedFont, screen.force_packed, True),
    Bres(XtNshowMissingGlyphs, XtCShowMissingGlyphs, screen.force_all_chars, False),
    Bres(XtNassumeAllChars, XtCAssumeAllChars, screen.assume_all_chars, True),
#endif

#if OPT_BROKEN_OSC
    Bres(XtNbrokenLinuxOSC, XtCBrokenLinuxOSC, screen.brokenLinuxOSC, True),
#endif

#if OPT_BROKEN_ST
    Bres(XtNbrokenStringTerm, XtCBrokenStringTerm, screen.brokenStringTerm, False),
#endif

#if OPT_C1_PRINT
    Bres(XtNallowC1Printable, XtCAllowC1Printable, screen.c1_printable, False),
#endif

#if OPT_CLIP_BOLD
    Bres(XtNuseClipping, XtCUseClipping, screen.use_clipping, True),
#endif

#if OPT_DEC_CHRSET
    Bres(XtNfontDoublesize, XtCFontDoublesize, screen.font_doublesize, True),
    Ires(XtNcacheDoublesize, XtCCacheDoublesize, screen.cache_doublesize, NUM_CHRSET),
#endif

#if OPT_HIGHLIGHT_COLOR
    Tres(XtNhighlightColor, XtCHighlightColor, HIGHLIGHT_BG, XtDefaultForeground),
    Tres(XtNhighlightTextColor, XtCHighlightTextColor, HIGHLIGHT_FG, XtDefaultBackground),
    Bres(XtNhighlightReverse, XtCHighlightReverse, screen.hilite_reverse, True),
    Bres(XtNhighlightColorMode, XtCHighlightColorMode, screen.hilite_color, Maybe),
#endif				/* OPT_HIGHLIGHT_COLOR */

#if OPT_INPUT_METHOD
    Bres(XtNopenIm, XtCOpenIm, misc.open_im, True),
    Sres(XtNinputMethod, XtCInputMethod, misc.input_method, NULL),
    Sres(XtNpreeditType, XtCPreeditType, misc.preedit_type,
	 "OverTheSpot,Root"),
    Ires(XtNretryInputMethod, XtCRetryInputMethod, misc.retry_im, 3),
#endif

#if OPT_ISO_COLORS
    Bres(XtNboldColors, XtCColorMode, screen.boldColors, True),
    Ires(XtNveryBoldColors, XtCVeryBoldColors, screen.veryBoldColors, 0),
    Bres(XtNcolorMode, XtCColorMode, screen.colorMode, DFT_COLORMODE),

    Bres(XtNcolorAttrMode, XtCColorAttrMode, screen.colorAttrMode, False),
    Bres(XtNcolorBDMode, XtCColorAttrMode, screen.colorBDMode, False),
    Bres(XtNcolorBLMode, XtCColorAttrMode, screen.colorBLMode, False),
    Bres(XtNcolorRVMode, XtCColorAttrMode, screen.colorRVMode, False),
    Bres(XtNcolorULMode, XtCColorAttrMode, screen.colorULMode, False),
    Bres(XtNitalicULMode, XtCColorAttrMode, screen.italicULMode, False),
#if OPT_WIDE_ATTRS
    Bres(XtNcolorITMode, XtCColorAttrMode, screen.colorITMode, False),
#endif

    COLOR_RES("0", screen.Acolors[COLOR_0], DFT_COLOR("black")),
    COLOR_RES("1", screen.Acolors[COLOR_1], DFT_COLOR("red3")),
    COLOR_RES("2", screen.Acolors[COLOR_2], DFT_COLOR("green3")),
    COLOR_RES("3", screen.Acolors[COLOR_3], DFT_COLOR("yellow3")),
    COLOR_RES("4", screen.Acolors[COLOR_4], DFT_COLOR(DEF_COLOR4)),
    COLOR_RES("5", screen.Acolors[COLOR_5], DFT_COLOR("magenta3")),
    COLOR_RES("6", screen.Acolors[COLOR_6], DFT_COLOR("cyan3")),
    COLOR_RES("7", screen.Acolors[COLOR_7], DFT_COLOR("gray90")),
    COLOR_RES("8", screen.Acolors[COLOR_8], DFT_COLOR("gray50")),
    COLOR_RES("9", screen.Acolors[COLOR_9], DFT_COLOR("red")),
    COLOR_RES("10", screen.Acolors[COLOR_10], DFT_COLOR("green")),
    COLOR_RES("11", screen.Acolors[COLOR_11], DFT_COLOR("yellow")),
    COLOR_RES("12", screen.Acolors[COLOR_12], DFT_COLOR(DEF_COLOR12)),
    COLOR_RES("13", screen.Acolors[COLOR_13], DFT_COLOR("magenta")),
    COLOR_RES("14", screen.Acolors[COLOR_14], DFT_COLOR("cyan")),
    COLOR_RES("15", screen.Acolors[COLOR_15], DFT_COLOR("white")),
    COLOR_RES("BD", screen.Acolors[COLOR_BD], DFT_COLOR(XtDefaultForeground)),
    COLOR_RES("BL", screen.Acolors[COLOR_BL], DFT_COLOR(XtDefaultForeground)),
    COLOR_RES("UL", screen.Acolors[COLOR_UL], DFT_COLOR(XtDefaultForeground)),
    COLOR_RES("RV", screen.Acolors[COLOR_RV], DFT_COLOR(XtDefaultForeground)),

#if OPT_WIDE_ATTRS
    COLOR_RES("IT", screen.Acolors[COLOR_IT], DFT_COLOR(XtDefaultForeground)),
#endif

#if !OPT_COLOR_RES2
#if OPT_256_COLORS
# include <256colres.h>
#elif OPT_88_COLORS
# include <88colres.h>
#endif
#endif				/* !OPT_COLOR_RES2 */

#endif				/* OPT_ISO_COLORS */

    CLICK_RES("2", screen.onClick[1], "word"),
    CLICK_RES("3", screen.onClick[2], "line"),
    CLICK_RES("4", screen.onClick[3], 0),
    CLICK_RES("5", screen.onClick[4], 0),

#if OPT_MOD_FKEYS
    Ires(XtNmodifyKeyboard, XtCModifyKeyboard,
	 keyboard.modify_1st.allow_keys, 0),
    Ires(XtNmodifyCursorKeys, XtCModifyCursorKeys,
	 keyboard.modify_1st.cursor_keys, 2),
    Ires(XtNmodifyFunctionKeys, XtCModifyFunctionKeys,
	 keyboard.modify_1st.function_keys, 2),
    Ires(XtNmodifyKeypadKeys, XtCModifyKeypadKeys,
	 keyboard.modify_1st.keypad_keys, 0),
    Ires(XtNmodifyOtherKeys, XtCModifyOtherKeys,
	 keyboard.modify_1st.other_keys, 0),
    Ires(XtNmodifyStringKeys, XtCModifyStringKeys,
	 keyboard.modify_1st.string_keys, 0),
    Ires(XtNformatOtherKeys, XtCFormatOtherKeys,
	 keyboard.format_keys, 0),
#endif

#if OPT_NUM_LOCK
    Bres(XtNalwaysUseMods, XtCAlwaysUseMods, misc.alwaysUseMods, False),
    Bres(XtNnumLock, XtCNumLock, misc.real_NumLock, True),
#endif

#if OPT_PRINT_COLORS
    Ires(XtNprintAttributes, XtCPrintAttributes, SPS.print_attributes, 1),
#endif

#if OPT_REGIS_GRAPHICS
    Sres(XtNregisDefaultFont, XtCRegisDefaultFont,
	 screen.graphics_regis_default_font, ""),
    Sres(XtNregisScreenSize, XtCRegisScreenSize,
	 screen.graphics_regis_screensize, "auto"),
#endif

#if OPT_GRAPHICS
    Sres(XtNmaxGraphicSize, XtCMaxGraphicSize, screen.graphics_max_size,
	 "1000x1000"),
#endif

#if OPT_SHIFT_FONTS
    Bres(XtNshiftFonts, XtCShiftFonts, misc.shift_fonts, True),
#endif

#if OPT_SIXEL_GRAPHICS
    Bres(XtNsixelScrolling, XtCSixelScrolling, screen.sixel_scrolling, True),
    Bres(XtNsixelScrollsRight, XtCSixelScrollsRight,
	 screen.sixel_scrolls_right, False),
#endif

#if OPT_GRAPHICS
    Ires(XtNnumColorRegisters, XtCNumColorRegisters,
	 screen.numcolorregisters, 0),
    Bres(XtNprivateColorRegisters, XtCPrivateColorRegisters,
	 screen.privatecolorregisters, True),
#endif

#if OPT_SUNPC_KBD
    Ires(XtNctrlFKeys, XtCCtrlFKeys, misc.ctrl_fkeys, 10),
#endif

#if OPT_TEK4014
    Bres(XtNtekInhibit, XtCTekInhibit, misc.tekInhibit, False),
    Bres(XtNtekSmall, XtCTekSmall, misc.tekSmall, False),
    Bres(XtNtekStartup, XtCTekStartup, misc.TekEmu, False),
#endif

#if OPT_TOOLBAR
    Wres(XtNmenuBar, XtCMenuBar, VT100_TB_INFO(menu_bar), 0),
    Ires(XtNmenuHeight, XtCMenuHeight, VT100_TB_INFO(menu_height), 25),
#endif

#if OPT_WIDE_CHARS
    Bres(XtNcjkWidth, XtCCjkWidth, misc.cjk_width, False),
    Bres(XtNmkWidth, XtCMkWidth, misc.mk_width, False),
    Bres(XtNprecompose, XtCPrecompose, screen.normalized_c, True),
    Bres(XtNutf8Latin1, XtCUtf8Latin1, screen.utf8_latin1, False),
    Bres(XtNutf8Title, XtCUtf8Title, screen.utf8_title, False),
    Bres(XtNvt100Graphics, XtCVT100Graphics, screen.vt100_graphics, True),
    Bres(XtNwideChars, XtCWideChars, screen.wide_chars, False),
    Ires(XtNcombiningChars, XtCCombiningChars, screen.max_combining, 2),
    Ires(XtNmkSamplePass, XtCMkSamplePass, misc.mk_samplepass, 655),
    Ires(XtNmkSampleSize, XtCMkSampleSize, misc.mk_samplesize, 65536),
    Sres(XtNutf8, XtCUtf8, screen.utf8_mode_s, "default"),
    Sres(XtNutf8Fonts, XtCUtf8Fonts, screen.utf8_fonts_s, "default"),
    Sres(XtNwideBoldFont, XtCWideBoldFont, misc.default_font.f_wb, DEFWIDEBOLDFONT),
    Sres(XtNwideFont, XtCWideFont, misc.default_font.f_w, DEFWIDEFONT),
    Sres(XtNutf8SelectTypes, XtCUtf8SelectTypes, screen.utf8_select_types, NULL),
#endif

#if OPT_LUIT_PROG
    Sres(XtNlocale, XtCLocale, misc.locale_str, "medium"),
    Sres(XtNlocaleFilter, XtCLocaleFilter, misc.localefilter, DEFLOCALEFILTER),
#endif

#if OPT_INPUT_METHOD
    Sres(XtNximFont, XtCXimFont, misc.f_x, DEFXIMFONT),
#endif

#if OPT_SCROLL_LOCK
    Bres(XtNallowScrollLock, XtCAllowScrollLock, screen.allowScrollLock0, False),
#endif

    /* these are used only for testing ncurses, not in the manual page */
#if OPT_XMC_GLITCH
    Bres(XtNxmcInline, XtCXmcInline, screen.xmc_inline, False),
    Bres(XtNxmcMoveSGR, XtCXmcMoveSGR, screen.move_sgr_ok, True),
    Ires(XtNxmcAttributes, XtCXmcAttributes, screen.xmc_attributes, 1),
    Ires(XtNxmcGlitch, XtCXmcGlitch, screen.xmc_glitch, 0),
#endif

#ifdef SCROLLBAR_RIGHT
    Bres(XtNrightScrollBar, XtCRightScrollBar, misc.useRight, False),
#endif

#if OPT_RENDERFONT
#define RES_FACESIZE(n) Dres(XtNfaceSize #n, XtCFaceSize #n, misc.face_size[n], "0.0")
    RES_FACESIZE(1),
    RES_FACESIZE(2),
    RES_FACESIZE(3),
    RES_FACESIZE(4),
    RES_FACESIZE(5),
    RES_FACESIZE(6),
    Dres(XtNfaceSize, XtCFaceSize, misc.face_size[0], DEFFACESIZE),
    Sres(XtNfaceName, XtCFaceName, misc.default_xft.f_n, DEFFACENAME),
    Sres(XtNrenderFont, XtCRenderFont, misc.render_font_s, "default"),
#if OPT_RENDERWIDE
    Sres(XtNfaceNameDoublesize, XtCFaceNameDoublesize, misc.default_xft.f_w, DEFFACENAME),
#endif
#endif
};

static Boolean VTSetValues(Widget cur, Widget request, Widget new_arg,
			   ArgList args, Cardinal *num_args);
static void VTClassInit(void);
static void VTDestroy(Widget w);
static void VTExpose(Widget w, XEvent *event, Region region);
static void VTInitialize(Widget wrequest, Widget new_arg, ArgList args,
			 Cardinal *num_args);
static void VTRealize(Widget w, XtValueMask * valuemask,
		      XSetWindowAttributes * values);
static void VTResize(Widget w);

#if OPT_I18N_SUPPORT && OPT_INPUT_METHOD
static void VTInitI18N(XtermWidget);
#endif

#ifdef VMS
globaldef {
    "xtermclassrec"
} noshare

#else
static
#endif				/* VMS */
WidgetClassRec xtermClassRec =
{
    {
	/* core_class fields */
	(WidgetClass) & widgetClassRec,		/* superclass   */
	"VT100",		/* class_name                   */
	sizeof(XtermWidgetRec),	/* widget_size                  */
	VTClassInit,		/* class_initialize             */
	NULL,			/* class_part_initialize        */
	False,			/* class_inited                 */
	VTInitialize,		/* initialize                   */
	NULL,			/* initialize_hook              */
	VTRealize,		/* realize                      */
	actionsList,		/* actions                      */
	XtNumber(actionsList),	/* num_actions                  */
	xterm_resources,	/* resources                    */
	XtNumber(xterm_resources),	/* num_resources        */
	NULLQUARK,		/* xrm_class                    */
	True,			/* compress_motion              */
	False,			/* compress_exposure            */
	True,			/* compress_enterleave          */
	False,			/* visible_interest             */
	VTDestroy,		/* destroy                      */
	VTResize,		/* resize                       */
	VTExpose,		/* expose                       */
	VTSetValues,		/* set_values                   */
	NULL,			/* set_values_hook              */
	XtInheritSetValuesAlmost,	/* set_values_almost    */
	NULL,			/* get_values_hook              */
	NULL,			/* accept_focus                 */
	XtVersion,		/* version                      */
	NULL,			/* callback_offsets             */
	0,			/* tm_table                     */
	XtInheritQueryGeometry,	/* query_geometry               */
	XtInheritDisplayAccelerator,	/* display_accelerator  */
	NULL			/* extension                    */
    }
};

#ifdef VMS
globaldef {
    "xtermwidgetclass"
}
noshare
#endif /* VMS */
WidgetClass xtermWidgetClass = (WidgetClass) & xtermClassRec;

/*
 * Add input-actions for widgets that are overlooked (scrollbar and toolbar):
 *
 *	a) Sometimes the scrollbar passes through translations, sometimes it
 *	   doesn't.  We add the KeyPress translations here, just to be sure.
 *	b) In the normal (non-toolbar) configuration, the xterm widget covers
 *	   almost all of the window.  With a toolbar, there's a relatively
 *	   large area that the user would expect to enter keystrokes since the
 *	   program can get the focus.
 */
void
xtermAddInput(Widget w)
{
    /* *INDENT-OFF* */
    XtActionsRec input_actions[] = {
	{ "insert",		    HandleKeyPressed }, /* alias */
	{ "insert-eight-bit",	    HandleEightBitKeyPressed },
	{ "insert-seven-bit",	    HandleKeyPressed },
	{ "secure",		    HandleSecure },
	{ "string",		    HandleStringEvent },
	{ "scroll-back",	    HandleScrollBack },
	{ "scroll-forw",	    HandleScrollForward },
	{ "select-cursor-end",	    HandleKeyboardSelectEnd },
	{ "select-cursor-extend",   HandleKeyboardSelectExtend },
	{ "select-cursor-start",    HandleKeyboardSelectStart },
	{ "insert-selection",	    HandleInsertSelection },
	{ "select-start",	    HandleSelectStart },
	{ "select-extend",	    HandleSelectExtend },
	{ "start-extend",	    HandleStartExtend },
	{ "select-end",		    HandleSelectEnd },
	{ "clear-saved-lines",	    HandleClearSavedLines },
	{ "popup-menu",		    HandlePopupMenu },
	{ "bell",		    HandleBell },
	{ "ignore",		    HandleIgnore },
#if OPT_DABBREV
	{ "dabbrev-expand",	    HandleDabbrevExpand },
#endif
#if OPT_MAXIMIZE
	{ "fullscreen",		    HandleFullscreen },
#endif
#if OPT_SCROLL_LOCK
	{ "scroll-lock",	    HandleScrollLock },
#endif
#if OPT_SHIFT_FONTS
	{ "larger-vt-font",	    HandleLargerFont },
	{ "smaller-vt-font",	    HandleSmallerFont },
#endif
    };
    /* *INDENT-ON* */

    TRACE_TRANS("BEFORE", w);
    XtAppAddActions(app_con, input_actions, XtNumber(input_actions));
    XtAugmentTranslations(w, XtParseTranslationTable(defaultTranslations));
    TRACE_TRANS("AFTER:", w);

#if OPT_EXTRA_PASTE
    if (term && term->keyboard.extra_translations)
	XtOverrideTranslations((Widget) term, XtParseTranslationTable(term->keyboard.extra_translations));
#endif
}

#if OPT_ISO_COLORS
#ifdef EXP_BOGUS_FG
static Bool
CheckBogusForeground(TScreen *screen, const char *tag)
{
    int row = -1, col = -1, pass;
    Bool isClear = True;

    (void) tag;
    for (pass = 0; pass < 2; ++pass) {
	row = screen->cur_row;
	for (; isClear && (row <= screen->max_row); ++row) {
	    CLineData *ld = getLineData(screen, row);

	    if (ld != 0) {
		IAttr *attribs = ld->attribs;

		col = (row == screen->cur_row) ? screen->cur_col : 0;
		for (; isClear && (col <= screen->max_col); ++col) {
		    unsigned flags = attribs[col];
		    if (pass) {
			flags &= ~FG_COLOR;
			attribs[col] = (IAttr) flags;
		    } else if ((flags & BG_COLOR)) {
			isClear = False;
		    } else if ((flags & FG_COLOR)) {
			unsigned ch = ld->charData[col];
			isClear = ((ch == ' ') || (ch == 0));
		    } else {
			isClear = False;
		    }
		}
	    }
	}
    }
    TRACE(("%s checked %d,%d to %d,%d %s pass %d\n",
	   tag, screen->cur_row, screen->cur_col,
	   row, col,
	   isClear && pass ? "cleared" : "unchanged",
	   pass));

    return isClear;
}
#endif

/*
 * The terminal's foreground and background colors are set via two mechanisms:
 *	text (cur_foreground, cur_background values that are passed down to
 *		XDrawImageString and XDrawString)
 *	area (X11 graphics context used in XClearArea and XFillRectangle)
 */
void
SGR_Foreground(XtermWidget xw, int color)
{
    TScreen *screen = TScreenOf(xw);
    Pixel fg;

    if (color >= 0) {
	UIntSet(xw->flags, FG_COLOR);
    } else {
	UIntClr(xw->flags, FG_COLOR);
    }
    fg = getXtermForeground(xw, xw->flags, color);
    xw->cur_foreground = color;

    setCgsFore(xw, WhichVWin(screen), gcNorm, fg);
    setCgsBack(xw, WhichVWin(screen), gcNormReverse, fg);

    setCgsFore(xw, WhichVWin(screen), gcBold, fg);
    setCgsBack(xw, WhichVWin(screen), gcBoldReverse, fg);

#ifdef EXP_BOGUS_FG
    /*
     * If we've just turned off the foreground color, check for blank cells
     * which have no background color, but do have foreground color.  This
     * could happen due to setting the foreground color just before scrolling.
     *
     * Those cells look uncolored, but will confuse ShowCursor(), which looks
     * for the colors in the current cell, and will see the foreground color.
     * In that case, remove the foreground color from the blank cells.
     */
    if (color < 0) {
	CheckBogusForeground(screen, "SGR_Foreground");
    }
#endif
}

void
SGR_Background(XtermWidget xw, int color)
{
    TScreen *screen = TScreenOf(xw);
    Pixel bg;

    /*
     * An indexing operation may have set screen->scroll_amt, which would
     * normally result in calling FlushScroll() in WriteText().  However,
     * if we're changing the background color now, then the new value
     * should not apply to the pending blank lines.
     */
    if (screen->scroll_amt && (color != xw->cur_background))
	FlushScroll(xw);

    if (color >= 0) {
	UIntSet(xw->flags, BG_COLOR);
    } else {
	UIntClr(xw->flags, BG_COLOR);
    }
    bg = getXtermBackground(xw, xw->flags, color);
    xw->cur_background = color;

    setCgsBack(xw, WhichVWin(screen), gcNorm, bg);
    setCgsFore(xw, WhichVWin(screen), gcNormReverse, bg);

    setCgsBack(xw, WhichVWin(screen), gcBold, bg);
    setCgsFore(xw, WhichVWin(screen), gcBoldReverse, bg);
}

/* Invoked after updating bold/underline flags, computes the extended color
 * index to use for foreground.  (See also 'extract_fg()').
 */
static void
setExtendedFG(XtermWidget xw)
{
    int fg = xw->sgr_foreground;

    if (TScreenOf(xw)->colorAttrMode
	|| (fg < 0)) {
	fg = MapToColorMode(fg, TScreenOf(xw), xw->flags);
    }

    /* This implements the IBM PC-style convention of 8-colors, with one
     * bit for bold, thus mapping the 0-7 codes to 8-15.  It won't make
     * much sense for 16-color applications, but we keep it to retain
     * compatiblity with ANSI-color applications.
     */
#if OPT_PC_COLORS		/* XXXJTL should be settable at runtime (resource or OSC?) */
    if (TScreenOf(xw)->boldColors
	&& (!xw->sgr_extended)
	&& (fg >= 0)
	&& (fg < 8)
	&& (xw->flags & BOLD))
	fg |= 8;
#endif

    SGR_Foreground(xw, fg);
}

/* Invoked after updating inverse flag, computes the extended color
 * index to use for background.  (See also 'extract_bg()').
 */
static void
setExtendedBG(XtermWidget xw)
{
    int bg = xw->sgr_background;

    if (TScreenOf(xw)->colorAttrMode
	|| (bg < 0)) {
	if (TScreenOf(xw)->colorRVMode && (xw->flags & INVERSE))
	    bg = COLOR_RV;
    }

    SGR_Background(xw, bg);
}

static void
reset_SGR_Foreground(XtermWidget xw)
{
    xw->sgr_foreground = -1;
    xw->sgr_extended = False;
    setExtendedFG(xw);
}

static void
reset_SGR_Background(XtermWidget xw)
{
    xw->sgr_background = -1;
    setExtendedBG(xw);
}

static void
reset_SGR_Colors(XtermWidget xw)
{
    reset_SGR_Foreground(xw);
    reset_SGR_Background(xw);
}
#endif /* OPT_ISO_COLORS */

#if OPT_WIDE_ATTRS
/*
 * Call this before changing the state of ATR_ITALIC, to update the GC fonts.
 */
static void
setItalicFont(XtermWidget xw, Bool enable)
{
    if (enable) {
	if ((xw->flags & ATR_ITALIC) == 0) {
	    xtermLoadItalics(xw);
	    TRACE(("setItalicFont: enabling Italics\n"));
	    xtermUpdateFontGCs(xw, True);
	}
    } else if ((xw->flags & ATR_ITALIC) != 0) {
	TRACE(("setItalicFont: disabling Italics\n"));
	xtermUpdateFontGCs(xw, False);
    }
}
#endif

void
resetCharsets(TScreen *screen)
{
    TRACE(("resetCharsets\n"));

    screen->gsets[0] = nrc_ASCII;
    screen->gsets[1] = nrc_ASCII;
    screen->gsets[2] = nrc_ASCII;
    screen->gsets[3] = nrc_ASCII;

    screen->curgl = 0;		/* G0 => GL.            */
    screen->curgr = 2;		/* G2 => GR.            */
    screen->curss = 0;		/* No single shift.     */

#if OPT_VT52_MODE
    if (screen->vtXX_level == 0)
	screen->gsets[1] = nrc_DEC_Spec_Graphic;	/* Graphics */
#endif
}

static void
modified_DECNRCM(XtermWidget xw)
{
#if OPT_WIDE_CHARS
    TScreen *screen = TScreenOf(xw);
    if (screen->wide_chars && (screen->utf8_mode || screen->utf8_nrc_mode)) {
	int enabled = ((xw->flags & NATIONAL) != 0);
	int modefix;
	EXCHANGE(screen->utf8_nrc_mode, screen->utf8_mode, modefix);
	switchPtyData(screen, !enabled);
	TRACE(("UTF8 mode temporarily %s\n", enabled ? "ON" : "OFF"));
    }
#endif
}

/*
 * VT300 and up support three ANSI conformance levels, defined according to
 * the dpANSI X3.134.1 standard.  DEC's manuals equate levels 1 and 2, and
 * are unclear.  This code is written based on the manuals.
 */
static void
set_ansi_conformance(TScreen *screen, int level)
{
    TRACE(("set_ansi_conformance(%d) dec_level %d:%d, ansi_level %d\n",
	   level,
	   screen->vtXX_level * 100,
	   screen->terminal_id,
	   screen->ansi_level));
    if (screen->vtXX_level >= 3) {
	switch (screen->ansi_level = level) {
	case 1:
	    /* FALLTHRU */
	case 2:
	    screen->gsets[0] = nrc_ASCII;	/* G0 is ASCII */
	    screen->gsets[1] = nrc_ASCII;	/* G1 is ISO Latin-1 */
	    screen->curgl = 0;
	    screen->curgr = 1;
	    break;
	case 3:
	    screen->gsets[0] = nrc_ASCII;	/* G0 is ASCII */
	    screen->curgl = 0;
	    break;
	}
    }
}

/*
 * Set scrolling margins.  VTxxx terminals require that the top/bottom are
 * different, so we have at least two lines in the scrolling region.
 */
void
set_tb_margins(TScreen *screen, int top, int bottom)
{
    TRACE(("set_tb_margins %d..%d, prior %d..%d\n",
	   top, bottom,
	   screen->top_marg,
	   screen->bot_marg));
    if (bottom > top) {
	screen->top_marg = top;
	screen->bot_marg = bottom;
    }
    if (screen->top_marg > screen->max_row)
	screen->top_marg = screen->max_row;
    if (screen->bot_marg > screen->max_row)
	screen->bot_marg = screen->max_row;
}

void
set_lr_margins(TScreen *screen, int left, int right)
{
    TRACE(("set_lr_margins %d..%d, prior %d..%d\n",
	   left, right,
	   screen->lft_marg,
	   screen->rgt_marg));
    if (right > left) {
	screen->lft_marg = left;
	screen->rgt_marg = right;
    }
    if (screen->lft_marg > screen->max_col)
	screen->lft_marg = screen->max_col;
    if (screen->rgt_marg > screen->max_col)
	screen->rgt_marg = screen->max_col;
}

#define reset_tb_margins(screen) set_tb_margins(screen, 0, screen->max_row)
#define reset_lr_margins(screen) set_lr_margins(screen, 0, screen->max_col)

static void
reset_margins(TScreen *screen)
{
    reset_tb_margins(screen);
    reset_lr_margins(screen);
}

void
set_max_col(TScreen *screen, int cols)
{
    TRACE(("set_max_col %d, prior %d\n", cols, screen->max_col));
    if (cols < 0)
	cols = 0;
    screen->max_col = cols;
}

void
set_max_row(TScreen *screen, int rows)
{
    TRACE(("set_max_row %d, prior %d\n", rows, screen->max_row));
    if (rows < 0)
	rows = 0;
    screen->max_row = rows;
}

#if OPT_MOD_FKEYS
static void
set_mod_fkeys(XtermWidget xw, int which, int what, Bool enabled)
{
#define SET_MOD_FKEYS(field) \
    xw->keyboard.modify_now.field = ((what == DEFAULT) && enabled) \
				     ? xw->keyboard.modify_1st.field \
				     : what; \
    TRACE(("set modify_now.%s to %d\n", #field, \
	   xw->keyboard.modify_now.field));

    switch (which) {
    case 0:
	SET_MOD_FKEYS(allow_keys);
	break;
    case 1:
	SET_MOD_FKEYS(cursor_keys);
	break;
    case 2:
	SET_MOD_FKEYS(function_keys);
	break;
    case 3:
	SET_MOD_FKEYS(keypad_keys);
	break;
    case 4:
	SET_MOD_FKEYS(other_keys);
	break;
    case 5:
	SET_MOD_FKEYS(string_keys);
	break;
    }
}
#endif /* OPT_MOD_FKEYS */

#if OPT_TRACE
#define DATA(name) { name, #name }
static const struct {
    Const PARSE_T *table;
    const char *name;
} all_tables[] = {

    DATA(ansi_table)
	,DATA(cigtable)
	,DATA(csi2_table)
	,DATA(csi_ex_table)
	,DATA(csi_quo_table)
	,DATA(csi_table)
	,DATA(dec2_table)
	,DATA(dec3_table)
	,DATA(dec_table)
	,DATA(eigtable)
	,DATA(esc_sp_table)
	,DATA(esc_table)
	,DATA(scrtable)
	,DATA(scs96table)
	,DATA(scstable)
	,DATA(sos_table)
#if OPT_BLINK_CURS
	,DATA(csi_sp_table)
#endif
#if OPT_DEC_LOCATOR
	,DATA(csi_tick_table)
#endif
#if OPT_DEC_RECTOPS
	,DATA(csi_dollar_table)
	,DATA(csi_star_table)
	,DATA(csi_dec_dollar_table)
#endif
#if OPT_WIDE_CHARS
	,DATA(esc_pct_table)
	,DATA(scs_pct_table)
#endif
#if OPT_VT52_MODE
	,DATA(vt52_table)
	,DATA(vt52_esc_table)
	,DATA(vt52_ignore_table)
#endif
#undef DATA
};

#define WHICH_TABLE(name) if (table == name) result = #name
static const char *
which_table(Const PARSE_T * table)
{
    const char *result = "?";
    Cardinal n;
    for (n = 0; n < XtNumber(all_tables); ++n) {
	if (table == all_tables[n].table) {
	    result = all_tables[n].name;
	    break;
	}
    }

    return result;
}

static void
check_tables(void)
{
    Cardinal n;
    int ch;

    TRACE(("** check_tables\n"));
    for (n = 0; n < XtNumber(all_tables); ++n) {
	Const PARSE_T *table = all_tables[n].table;
	TRACE(("*** %s\n", all_tables[n].name));
	/*
	 * Most of the tables should use the same codes in 0..31, 128..159
	 * as the "ansi" table.
	 */
	if (strncmp(all_tables[n].name, "ansi", 4) &&
	    strncmp(all_tables[n].name, "sos_", 4) &&
	    strncmp(all_tables[n].name, "vt52", 4)) {
	    for (ch = 0; ch < 32; ++ch) {
		int c1 = ch + 128;
		PARSE_T st_l = table[ch];
		PARSE_T st_r = table[c1];
		if (st_l != ansi_table[ch]) {
		    TRACE(("  %3d: %d vs %d\n", ch, st_l, ansi_table[ch]));
		}
		if (st_r != ansi_table[c1]) {
		    TRACE(("  %3d: %d vs %d\n", c1, st_r, ansi_table[c1]));
		}
	    }
	}
	/*
	 * All of the tables should have their GL/GR parts encoded the same.
	 */
	for (ch = 32; ch < 127; ++ch) {
	    PARSE_T st_l = table[ch];
	    PARSE_T st_r = table[ch + 128];
	    if (st_l != st_r) {
		if (st_r == CASE_IGNORE &&
		    !strncmp(all_tables[n].name, "vt52", 4)) {
		    ;
		} else {
		    TRACE(("  %3d: %d vs %d\n", ch, st_l, st_r));
		}
	    }
	}
    }
}
#endif

#if OPT_TRACE > 0
static void
dump_params(void)
{
    int n;
    int arg;
    TRACE(("params %d (%d)\n", nparam, parms.has_subparams));
    for (arg = 1, n = 0; n < nparam; ++n) {
	TRACE(("%3d.%d %d\n", arg, parms.is_sub[n], parms.params[n]));
	if (!parms.is_sub[n])
	    ++arg;
    }
}
#define DumpParams() dump_params()
#else
#define DumpParams()		/* nothing */
#endif

	/* allocate larger buffer if needed/possible */
#define SafeAlloc(type, area, used, size) \
		type *new_string = area; \
		size_t new_length = size; \
		if (new_length == 0) { \
		    new_length = 256; \
		    new_string = TypeMallocN(type, new_length); \
		} else if (used+1 >= new_length) { \
		    new_length = size * 2; \
		    new_string = TypeMallocN(type, new_length); \
		    if (new_string != 0 \
		     && area != 0 \
		     && used != 0) { \
			memcpy(new_string, area, used * sizeof(type)); \
		     } \
		}
#define SafeFree(area, size) \
		if (area != new_string) { \
		    free(area); \
		    area = new_string; \
		} \
		size = new_length

#define WriteNow() {						\
	    unsigned single = 0;				\
								\
	    if (screen->curss) {				\
		dotext(xw,					\
		       screen->gsets[(int) (screen->curss)],	\
		       sp->print_area,				\
		       (Cardinal) 1);				\
		screen->curss = 0;				\
		single++;					\
	    }							\
	    if (sp->print_used > single) {			\
		dotext(xw,					\
		       screen->gsets[(int) (screen->curgl)],	\
		       sp->print_area + single,			\
		       (Cardinal) (sp->print_used - single));	\
	    }							\
	    sp->print_used = 0;					\
	}							\

struct ParseState {
#if OPT_VT52_MODE
    Bool vt52_cup;
#endif
    Const PARSE_T *groundtable;
    Const PARSE_T *parsestate;
    int scstype;
    int scssize;
    Bool private_function;	/* distinguish private-mode from standard */
    int string_mode;		/* nonzero iff we're processing a string */
    int lastchar;		/* positive iff we had a graphic character */
    int nextstate;
#if OPT_WIDE_CHARS
    int last_was_wide;
#endif
    /* Buffer for processing printable text */
    IChar *print_area;
    size_t print_size;
    size_t print_used;
    /* Buffer for processing strings (e.g., OSC ... ST) */
    Char *string_area;
    size_t string_size;
    size_t string_used;
};

static struct ParseState myState;

static void
init_groundtable(TScreen *screen, struct ParseState *sp)
{
    (void) screen;

#if OPT_VT52_MODE
    if (!(screen->vtXX_level)) {
	sp->groundtable = vt52_table;
    } else if (screen->terminal_id >= 100)
#endif
    {
	sp->groundtable = ansi_table;
    }
}

static void
select_charset(struct ParseState *sp, int type, int size)
{
    TRACE(("select_charset %d %d\n", type, size));
    sp->scstype = type;
    sp->scssize = size;
    if (size == 94) {
	sp->parsestate = scstable;
    } else {
	sp->parsestate = scs96table;
    }
}

static void
decode_scs(XtermWidget xw, int which, int prefix, int suffix)
{
    /* *INDENT-OFF* */
    static struct {
	DECNRCM_codes result;
	int prefix;
	int suffix;
	int min_level;
	int max_level;
	int need_nrc;
    } table[] = {
	{ nrc_ASCII,             0,   'B', 1, 9, 0 },
	{ nrc_British,           0,   'A', 1, 9, 0 },
	{ nrc_DEC_Spec_Graphic,  0,   '0', 1, 9, 0 },
	{ nrc_DEC_Alt_Chars,     0,   '1', 1, 1, 0 },
	{ nrc_DEC_Alt_Graphics,  0,   '2', 1, 1, 0 },
	/* VT2xx */
	{ nrc_DEC_Supp,          0,   '<', 2, 9, 0 },
	{ nrc_Dutch,             0,   '4', 2, 9, 1 },
	{ nrc_Finnish,           0,   '5', 2, 9, 1 },
	{ nrc_Finnish2,          0,   'C', 2, 9, 1 },
	{ nrc_French,            0,   'R', 2, 9, 1 },
	{ nrc_French2,           0,   'f', 2, 9, 1 },
	{ nrc_French_Canadian,   0,   'Q', 2, 9, 1 },
	{ nrc_German,            0,   'K', 2, 9, 1 },
	{ nrc_Italian,           0,   'Y', 2, 9, 1 },
	{ nrc_Norwegian_Danish2, 0,   'E', 2, 9, 1 },
	{ nrc_Norwegian_Danish3, 0,   '6', 2, 9, 1 },
	{ nrc_Spanish,           0,   'Z', 2, 9, 1 },
	{ nrc_Swedish,           0,   '7', 2, 9, 1 },
	{ nrc_Swedish2,          0,   'H', 2, 9, 1 },
	{ nrc_Swiss,             0,   '=', 2, 9, 1 },
	/* VT3xx */
	{ nrc_British_Latin_1,   0,   'A', 3, 9, 1 },
	{ nrc_DEC_Supp_Graphic,  '%', '5', 3, 9, 0 },
	{ nrc_DEC_Technical,     0,   '>', 3, 9, 0 },
	{ nrc_French_Canadian2,  0,   '9', 3, 9, 1 },
	{ nrc_Norwegian_Danish,  0,   '`', 3, 9, 1 },
	{ nrc_Portugese,         '%', '6', 3, 9, 1 },
#if 0
	/* VT5xx (not implemented) */
	{ nrc_Cyrillic,          '&', '4', 5, 9, 0 },
	{ nrc_Greek,             '"', '?', 5, 9, 0 },
	{ nrc_Greek_Supp,        0,   'F', 5, 9, 0 },
	{ nrc_Hebrew,            '"', '4', 5, 9, 0 },
	{ nrc_Hebrew2,           '%', '=', 5, 9, 1 },
	{ nrc_Hebrew_Supp,       0,   'H', 5, 9, 0 },
	{ nrc_Latin_5_Supp,      0,   'M', 5, 9, 0 },
	{ nrc_Latin_Cyrillic,    0,   'L', 5, 9, 0 },
	{ nrc_Russian,           '&', '5', 5, 9, 1 },
	{ nrc_SCS_NRCS,          '%', '3', 5, 9, 0 },
	{ nrc_Turkish,           '%', '0', 5, 9, 0 },
	{ nrc_Turkish2,		 '%', '2', 5, 9, 1 },
#endif
    };
    /* *INDENT-ON* */

    TScreen *screen = TScreenOf(xw);
    Cardinal n;
    DECNRCM_codes result = nrc_Unknown;

    suffix &= 0x7f;
    for (n = 0; n < XtNumber(table); ++n) {
	if (prefix == table[n].prefix
	    && suffix == table[n].suffix
	    && screen->vtXX_level >= table[n].min_level
	    && screen->vtXX_level <= table[n].max_level
	    && (table[n].need_nrc == 0 || (xw->flags & NATIONAL) != 0)) {
	    result = table[n].result;
	    break;
	}
    }
    if (result != nrc_Unknown) {
	screen->gsets[which] = result;
	TRACE(("setting G%d to %s\n", which, visibleScsCode((int) result)));
    } else {
	TRACE(("...unknown GSET\n"));
    }
}

/*
 * Given a parameter number, and subparameter (starting in each case from zero)
 * return the corresponding index into the parameter array.  If the combination
 * is not found, return -1.
 */
static int
subparam_index(int p, int s)
{
    int result = -1;
    int j, p2, s2;

    for (j = p2 = 0; j < nparam; ++j, ++p2) {
	if (parms.is_sub[j]) {
	    s2 = 0;

	    do {
		if ((p == p2) && (s == s2)) {
		    result = j;
		    break;
		}
		++s2;
	    } while ((++j < nparam) && (parms.is_sub[j - 1] < parms.is_sub[j]));

	    if (result >= 0)
		break;

	    --j;		/* undo the last "while" */
	} else if (p == p2) {
	    if (s == 0) {
		result = j;
	    }
	    break;
	}
    }
    TRACE2(("...subparam_index %d.%d = %d\n", p + 1, s + 1, result));
    return result;
}

/*
 * Check if the given item in the parameter array has subparameters.
 * If so, return the number of subparameters to use as a loop limit, etc.
 */
static int
param_has_subparams(int item)
{
    int result = 0;
    if (parms.has_subparams) {
	int n = subparam_index(item, 0);
	if (n >= 0 && parms.is_sub[n]) {
	    while (n++ < nparam && parms.is_sub[n - 1] < parms.is_sub[n]) {
		result++;
	    }
	}
    }
    TRACE(("...param_has_subparams(%d) ->%d\n", item, result));
    return result;
}

#if OPT_256_COLORS || OPT_88_COLORS || OPT_ISO_COLORS
/*
 * Given an index into the parameter array, return the corresponding parameter
 * number (starting from zero).
 */
static int
param_number(int item)
{
    int result = -1;
    int j, p;

    for (j = p = 0; j < nparam; ++j, ++p) {
	if (p >= item) {
	    result = j;
	    break;
	}
	if (parms.is_sub[j]) {
	    while ((++j < nparam) && (parms.is_sub[j - 1] < parms.is_sub[j])) {
		/* EMPTY */
	    }
	    --j;
	}
    }

    TRACE2(("...param_number(%d) = %d\n", item, result));
    return result;
}

static int
get_subparam(int p, int s)
{
    int item = subparam_index(p, s);
    int result = (item >= 0) ? parms.params[item] : DEFAULT;
    TRACE(("...get_subparam[%d] = %d\n", item, result));
    return result;
}

/*
 * Some background -
 *
 * Todd Larason provided the initial changes to support 256-colors in July 1999.
 * I pointed out that the description of SGR 38/48 in ECMA-48 was vague, and
 * was unsure if there would be some standard using those codes.  His response
 * was that this was documented (it turns out, in equally vague terms) in ITU
 * T.416
 *
 * Discussing this with Todd Larason in mid-1999, my point was that given the
 * high cost of obtaining ITU T.416 (ISO-8613-6), the standard was not going
 * to be effective (more than $100 then, more than $200 in 2012)
 *
 * We overlooked the detail about ":" as a subparameter delimiter (documented
 * in 5.4.t2 in ECMA-48).  Some discussion in KDE in mid-2006 led Lars Doelle
 * to discuss the issue with me.  Lars' initial concern dealt with the fact
 * that a sequence such as
 *	CSI 38 ; 5 ; 1 m
 * violated the principle that SGR parameters could be used in any order.
 * Further discussion (see KDE #107487) resolved that the standard expected
 * that the sequence would look like
 *	CSI 38 ; 5 : 1 m
 * which still violates that principle, since the "5:1" parameter has to
 * follow the "38" to be useful.
 *
 * This function accepts either format (per request by Paul Leonerd Evans).
 * It also accepts
 *	CSI 38 : 5 : 1 m
 * according to Lars' original assumption.
 *
 * By the way - all of the parameters are decimal integers.
 */
#define extended_colors_limit(n) ((n) == 5 ? 1 : ((n) == 2 ? 3 : 0))
static Boolean
parse_extended_colors(XtermWidget xw, int *colorp, int *itemp)
{
    Boolean result = False;
    int item = *itemp;
    int next = item;
    int base = param_number(item);
    int code = -1;
    int values[3];		/* maximum number of subparameters */
    int need = 0;		/* number of subparameters needed */
    int have;
    int n;

    /*
     * On entry, 'item' points to the 38/48 code in the parameter array.
     * If that has subparameters, we will expect all of the values to
     * be subparameters of that item.
     */
    if ((have = param_has_subparams(item)) != 0) {
	/* accept CSI 38 : 5 : 1 m */
	/* accept CSI 38 : 2 : 1 : 2 : 3 m */
	code = get_subparam(base, 1);
	need = extended_colors_limit(code);
	next = item + have;
	for (n = 0; n < need && n < 3; ++n) {
	    values[n] = get_subparam(base, 2 + n);
	}
    } else if (++item < nparam) {
	++base;
	if ((have = param_has_subparams(item)) != 0) {
	    /* accept CSI 38 ; 5 : 1 m */
	    /* accept CSI 38 ; 2 : 1 : 2 : 3 m */
	    code = get_subparam(base, 0);
	    need = extended_colors_limit(code);
	    next = base + have;
	    for (n = 0; n < need && n < 3; ++n) {
		values[n] = get_subparam(base, 1 + n);
	    }
	} else {
	    /* accept CSI 38 ; 5 ; 1 m */
	    /* accept CSI 38 ; 2 ; 1 ; 2 ; 3 m */
	    code = GetParam(item);
	    need = extended_colors_limit(code);
	    next = item + need;
	    for (n = 0; n < need && n < 3; ++n) {
		values[n] = GetParam(item + 1 + n);
	    }
	}
    }
    item = next;

    switch (code) {
    case 2:
	/* direct color in rgb space */
	if ((values[0] >= 0 && values[0] < 256) &&
	    (values[1] >= 0 && values[1] < 256) &&
	    (values[2] >= 0 && values[2] < 256)) {
	    *colorp = xtermClosestColor(xw, values[0], values[1], values[2]);
	} else {
	    *colorp = -1;
	}
	break;
    case 5:
	/* indexed color */
	*colorp = values[0];
	break;
    default:
	*colorp = -1;
	break;
    }

    result = (*colorp >= 0 && *colorp < NUM_ANSI_COLORS);
    TRACE(("...resulting color %d/%d %s\n",
	   *colorp, NUM_ANSI_COLORS,
	   result ? "OK" : "ERR"));

    *itemp = item;
    return result;
}
#endif /* ...extended_colors */

static int
optional_param(int which)
{
    return (nparam > which) ? GetParam(which) : DEFAULT;
}

static int
zero_if_default(int which)
{
    int result = (nparam > which) ? GetParam(which) : 0;
    if (result <= 0)
	result = 0;
    return result;
}

static int
one_if_default(int which)
{
    int result = (nparam > which) ? GetParam(which) : 0;
    if (result <= 0)
	result = 1;
    return result;
}

/*
 * Color palette changes using the OSC controls require a repaint of the
 * screen - but not immediately.  Do the repaint as soon as we detect a
 * state which will not lead to another color palette change.
 */
static void
repaintWhenPaletteChanged(XtermWidget xw, struct ParseState *sp)
{
    Boolean ignore = False;

    switch (sp->nextstate) {
    case CASE_ESC:
	ignore = ((sp->parsestate == ansi_table) ||
		  (sp->parsestate == sos_table));
	break;
    case CASE_OSC:
	ignore = ((sp->parsestate == ansi_table) ||
		  (sp->parsestate == esc_table));
	break;
    case CASE_IGNORE:
	ignore = (sp->parsestate == sos_table);
	break;
    case CASE_ST:
	ignore = ((sp->parsestate == esc_table) ||
		  (sp->parsestate == sos_table));
	break;
    case CASE_ESC_DIGIT:
	ignore = (sp->parsestate == csi_table);
	break;
    case CASE_ESC_SEMI:
	ignore = (sp->parsestate == csi2_table);
	break;
    }

    if (!ignore) {
	TRACE(("repaintWhenPaletteChanged\n"));
	xw->work.palette_changed = False;
	xtermRepaint(xw);
    }
}

#if OPT_C1_PRINT || OPT_WIDE_CHARS
#define ParseSOS(screen) ((screen)->c1_printable == 0)
#else
#define ParseSOS(screen) 0
#endif

#define ResetState(sp) ParamsDone(), (sp)->parsestate = (sp)->groundtable

static void
illegal_parse(XtermWidget xw, unsigned c, struct ParseState *sp)
{
    ResetState(sp);
    sp->nextstate = sp->parsestate[E2A(c)];
    Bell(xw, XkbBI_MinorError, 0);
}

static void
init_parser(XtermWidget xw, struct ParseState *sp)
{
    TScreen *screen = TScreenOf(xw);

    memset(sp, 0, sizeof(*sp));
    sp->scssize = 94;		/* number of printable/nonspace ASCII */
    sp->lastchar = -1;		/* not a legal IChar */
    sp->nextstate = -1;		/* not a legal state */

    init_groundtable(screen, sp);
    ResetState(sp);
}

static void
init_reply(unsigned type)
{
    memset(&reply, 0, sizeof(reply));
    reply.a_type = (Char) type;
}

static Boolean
doparsing(XtermWidget xw, unsigned c, struct ParseState *sp)
{
    TScreen *screen = TScreenOf(xw);
    int item;
    int count;
    int value;
    int laststate;
    int thischar = -1;
    XTermRect myRect;

    do {
#if OPT_WIDE_CHARS
	int this_is_wide = 0;

	/*
	 * Handle zero-width combining characters.  Make it faster by noting
	 * that according to the Unicode charts, the majority of Western
	 * character sets do not use this feature.  There are some unassigned
	 * codes at 0x242, but no zero-width characters until past 0x300.
	 */
	if (c >= 0x300
	    && screen->wide_chars
	    && my_wcwidth((wchar_t) c) == 0
	    && !isWideControl(c)) {
	    int prev, test;
	    Boolean used = True;
	    int use_row;
	    int use_col;

	    WriteNow();
	    use_row = (screen->char_was_written
		       ? screen->last_written_row
		       : screen->cur_row);
	    use_col = (screen->char_was_written
		       ? screen->last_written_col
		       : screen->cur_col);

	    /*
	     * Check if the latest data can be added to the base character.
	     * If there is already a combining character stored for the cell,
	     * we cannot, since that would change the order.
	     */
	    if (screen->normalized_c
		&& !IsCellCombined(screen, use_row, use_col)) {
		prev = (int) XTERM_CELL(use_row, use_col);
		test = do_precomposition(prev, (int) c);
		TRACE(("do_precomposition (U+%04X [%d], U+%04X [%d]) -> U+%04X [%d]\n",
		       prev, my_wcwidth((wchar_t) prev),
		       (int) c, my_wcwidth((wchar_t) c),
		       test, my_wcwidth((wchar_t) test)));
	    } else {
		prev = -1;
		test = -1;
	    }

	    /* substitute combined character with precomposed character
	     * only if it does not change the width of the base character
	     */
	    if (test != -1
		&& my_wcwidth((wchar_t) test) == my_wcwidth((wchar_t) prev)) {
		putXtermCell(screen, use_row, use_col, test);
	    } else if (screen->char_was_written
		       || getXtermCell(screen, use_row, use_col) > ' ') {
		addXtermCombining(screen, use_row, use_col, c);
	    } else {
		/*
		 * none of the above... we will add the combining character as
		 * a base character.
		 */
		used = False;
	    }

	    if (used) {
		if (!screen->scroll_amt)
		    ScrnUpdate(xw, use_row, use_col, 1, 1, 1);
		continue;
	    }
	}
#endif

	/* Intercept characters for printer controller mode */
	if (PrinterOf(screen).printer_controlmode == 2) {
	    if ((c = (unsigned) xtermPrinterControl(xw, (int) c)) == 0)
		continue;
	}

	/*
	 * VT52 is a little ugly in the one place it has a parameterized
	 * control sequence, since the parameter falls after the character
	 * that denotes the type of sequence.
	 */
#if OPT_VT52_MODE
	if (sp->vt52_cup) {
	    if (nparam < NPARAM - 1) {
		SetParam(nparam++, (int) (c & 0x7f) - 32);
		parms.is_sub[nparam] = 0;
	    }
	    if (nparam < 2)
		continue;
	    sp->vt52_cup = False;
	    CursorSet(screen, zero_if_default(0), zero_if_default(1), xw->flags);
	    sp->parsestate = vt52_table;
	    SetParam(0, 0);
	    SetParam(1, 0);
	    continue;
	}
#endif

	laststate = sp->nextstate;
	if (c == ANSI_DEL
	    && sp->parsestate == sp->groundtable
	    && sp->scssize == 96
	    && sp->scstype != 0) {
	    /*
	     * Handle special case of shifts for 96-character sets by checking
	     * if we have a DEL.  The other special case for SPACE will always
	     * be printable.
	     */
	    sp->nextstate = CASE_PRINT;
	} else
#if OPT_WIDE_CHARS
	if (c > 255) {
	    /*
	     * The parsing tables all have 256 entries.  If we're supporting
	     * wide characters, we handle them by treating them the same as
	     * printing characters.
	     */
	    if (sp->parsestate == sp->groundtable) {
		sp->nextstate = CASE_PRINT;
	    } else if (sp->parsestate == sos_table) {
		c &= 0xffff;
		if (c > 255) {
		    TRACE(("Found code > 255 while in SOS state: %04X\n", c));
		    c = '?';
		}
	    } else {
		sp->nextstate = CASE_GROUND_STATE;
	    }
	} else
#endif
	    sp->nextstate = sp->parsestate[E2A(c)];

#if OPT_BROKEN_OSC
	/*
	 * Linux console palette escape sequences start with an OSC, but do
	 * not terminate correctly.  Some scripts do not check before writing
	 * them, making xterm appear to hang (it's awaiting a valid string
	 * terminator).  Just ignore these if we see them - there's no point
	 * in emulating bad code.
	 */
	if (screen->brokenLinuxOSC
	    && sp->parsestate == sos_table) {
	    if (sp->string_used) {
		switch (sp->string_area[0]) {
		case 'P':
		    if (sp->string_used <= 7)
			break;
		    /* FALLTHRU */
		case 'R':
		    illegal_parse(xw, c, sp);
		    TRACE(("Reset to ground state (brokenLinuxOSC)\n"));
		    break;
		}
	    }
	}
#endif

#if OPT_BROKEN_ST
	/*
	 * Before patch #171, carriage control embedded within an OSC string
	 * would terminate it.  Some (buggy, of course) applications rely on
	 * this behavior.  Accommodate them by allowing one to compile xterm
	 * and emulate the old behavior.
	 */
	if (screen->brokenStringTerm
	    && sp->parsestate == sos_table
	    && c < 32) {
	    switch (c) {
	    case ANSI_EOT:	/* FALLTHRU */
	    case ANSI_BS:	/* FALLTHRU */
	    case ANSI_HT:	/* FALLTHRU */
	    case ANSI_LF:	/* FALLTHRU */
	    case ANSI_VT:	/* FALLTHRU */
	    case ANSI_FF:	/* FALLTHRU */
	    case ANSI_CR:	/* FALLTHRU */
	    case ANSI_SO:	/* FALLTHRU */
	    case ANSI_SI:	/* FALLTHRU */
	    case ANSI_XON:	/* FALLTHRU */
	    case ANSI_CAN:
		illegal_parse(xw, c, sp);
		TRACE(("Reset to ground state (brokenStringTerm)\n"));
		break;
	    }
	}
#endif

#if OPT_C1_PRINT
	/*
	 * This is not completely foolproof, but will allow an application
	 * with values in the C1 range to use them as printable characters,
	 * provided that they are not intermixed with an escape sequence.
	 */
	if (screen->c1_printable
	    && (c >= 128 && c < 256)) {
	    sp->nextstate = (sp->parsestate == esc_table
			     ? CASE_ESC_IGNORE
			     : sp->parsestate[E2A(160)]);
	    TRACE(("allowC1Printable %04X %s ->%s\n",
		   c, which_table(sp->parsestate),
		   visibleVTparse(sp->nextstate)));
	}
#endif

#if OPT_WIDE_CHARS
	/*
	 * If we have a C1 code and the c1_printable flag is not set, simply
	 * ignore it when it was translated from UTF-8.  That is because the
	 * value could not have been present as-is in the UTF-8.
	 *
	 * To see that CASE_IGNORE is a consistent value, note that it is
	 * always used for NUL and other uninteresting C0 controls.
	 */
#if OPT_C1_PRINT
	if (!screen->c1_printable)
#endif
	    if (screen->wide_chars
		&& (c >= 128 && c < 160)) {
		sp->nextstate = CASE_IGNORE;
	    }

	/*
	 * If this character is a different width than the last one, put the
	 * previous text into the buffer and draw it now.
	 */
	this_is_wide = isWide((int) c);
	if (this_is_wide != sp->last_was_wide) {
	    WriteNow();
	}
#endif

	/*
	 * Accumulate string for printable text.  This may be 8/16-bit
	 * characters.
	 */
	if (sp->nextstate == CASE_PRINT) {
	    SafeAlloc(IChar, sp->print_area, sp->print_used, sp->print_size);
	    if (new_string == 0) {
		xtermWarning("Cannot allocate %lu bytes for printable text\n",
			     (unsigned long) new_length);
		continue;
	    }
	    SafeFree(sp->print_area, sp->print_size);
#if OPT_VT52_MODE
	    /*
	     * Strip output text to 7-bits for VT52.  We should do this for
	     * VT100 also (which is a 7-bit device), but xterm has been
	     * doing this for so long we shouldn't change this behavior.
	     */
	    if (screen->vtXX_level < 1)
		c &= 0x7f;
#endif
	    sp->print_area[sp->print_used++] = (IChar) c;
	    sp->lastchar = thischar = (int) c;
#if OPT_WIDE_CHARS
	    sp->last_was_wide = this_is_wide;
#endif
	    if (morePtyData(screen, VTbuffer)) {
		continue;
	    }
	}

	if (sp->nextstate == CASE_PRINT
	    || (laststate == CASE_PRINT && sp->print_used)) {
	    WriteNow();
	}

	/*
	 * Accumulate string for APC, DCS, PM, OSC, SOS controls
	 * This should always be 8-bit characters.
	 */
	if (sp->parsestate == sos_table) {
	    SafeAlloc(Char, sp->string_area, sp->string_used, sp->string_size);
	    if (new_string == 0) {
		xtermWarning("Cannot allocate %lu bytes for string mode %d\n",
			     (unsigned long) new_length, sp->string_mode);
		continue;
	    }
	    SafeFree(sp->string_area, sp->string_size);
#if OPT_WIDE_CHARS
	    /*
	     * We cannot display codes above 255, but let's try to
	     * accommodate the application a little by not aborting the
	     * string.
	     */
	    if ((c & 0xffff) > 255) {
		sp->nextstate = CASE_PRINT;
		c = '?';
	    }
#endif
	    sp->string_area[(sp->string_used)++] = CharOf(c);
	} else if (sp->parsestate != esc_table) {
	    /* if we were accumulating, we're not any more */
	    sp->string_mode = 0;
	    sp->string_used = 0;
	}

	DumpParams();
	TRACE(("parse %04X -> %s %s (used=%lu)\n",
	       c, visibleVTparse(sp->nextstate),
	       which_table(sp->parsestate),
	       (unsigned long) sp->string_used));

	/*
	 * If the parameter list has subparameters (tokens separated by ":")
	 * reject any controls that do not accept subparameters.
	 */
	if (parms.has_subparams) {
	    switch (sp->nextstate) {
	    case CASE_GROUND_STATE:
	    case CASE_CSI_IGNORE:
		/* FALLTHRU */

	    case CASE_ESC_DIGIT:
	    case CASE_ESC_SEMI:
	    case CASE_ESC_COLON:
		/* these states are required to parse parameter lists */
		break;

	    case CASE_SGR:
		TRACE(("...possible subparam usage\n"));
		break;

	    case CASE_CSI_DEC_DOLLAR_STATE:
	    case CASE_CSI_DOLLAR_STATE:
	    case CASE_CSI_EX_STATE:
	    case CASE_CSI_QUOTE_STATE:
	    case CASE_CSI_SPACE_STATE:
	    case CASE_CSI_STAR_STATE:
	    case CASE_CSI_TICK_STATE:
	    case CASE_DEC2_STATE:
	    case CASE_DEC3_STATE:
	    case CASE_DEC_STATE:
		/* use this branch when we do not yet have the final character */
		TRACE(("...unexpected subparam usage\n"));
		ParamsDone();
		sp->nextstate = CASE_CSI_IGNORE;
		break;

	    default:
		/* use this branch for cases where we have the final character
		 * in the table that processed the parameter list.
		 */
		TRACE(("...unexpected subparam usage\n"));
		ResetState(sp);
		continue;
	    }
	}

	if (xw->work.palette_changed) {
	    repaintWhenPaletteChanged(xw, sp);
	}

	switch (sp->nextstate) {
	case CASE_PRINT:
	    TRACE(("CASE_PRINT - printable characters\n"));
	    break;

	case CASE_GROUND_STATE:
	    TRACE(("CASE_GROUND_STATE - exit ignore mode\n"));
	    ResetState(sp);
	    break;

	case CASE_IGNORE:
	    TRACE(("CASE_IGNORE - Ignore character %02X\n", c));
	    break;

	case CASE_ENQ:
	    TRACE(("CASE_ENQ - answerback\n"));
	    for (count = 0; screen->answer_back[count] != 0; count++)
		unparseputc(xw, screen->answer_back[count]);
	    unparse_end(xw);
	    break;

	case CASE_BELL:
	    TRACE(("CASE_BELL - bell\n"));
	    if (sp->string_mode == ANSI_OSC) {
		if (sp->string_used)
		    sp->string_area[--(sp->string_used)] = '\0';
		do_osc(xw, sp->string_area, sp->string_used, (int) c);
		ResetState(sp);
	    } else {
		/* bell */
		Bell(xw, XkbBI_TerminalBell, 0);
	    }
	    break;

	case CASE_BS:
	    TRACE(("CASE_BS - backspace\n"));
	    CursorBack(xw, 1);
	    break;

	case CASE_CR:
	    TRACE(("CASE_CR\n"));
	    CarriageReturn(xw);
	    break;

	case CASE_ESC:
	    if_OPT_VT52_MODE(screen, {
		sp->parsestate = vt52_esc_table;
		break;
	    });
	    sp->parsestate = esc_table;
	    break;

#if OPT_VT52_MODE
	case CASE_VT52_CUP:
	    TRACE(("CASE_VT52_CUP - VT52 cursor addressing\n"));
	    sp->vt52_cup = True;
	    InitParams();
	    break;

	case CASE_VT52_IGNORE:
	    TRACE(("CASE_VT52_IGNORE - VT52 ignore-character\n"));
	    sp->parsestate = vt52_ignore_table;
	    break;
#endif

	case CASE_VMOT:
	    TRACE(("CASE_VMOT\n"));
	    /*
	     * form feed, line feed, vertical tab
	     */
	    xtermAutoPrint(xw, c);
	    xtermIndex(xw, 1);
	    if (xw->flags & LINEFEED)
		CarriageReturn(xw);
	    else
		do_xevents();
	    break;

	case CASE_CBT:
	    TRACE(("CASE_CBT\n"));
	    /* cursor backward tabulation */
	    count = one_if_default(0);
	    while ((count-- > 0)
		   && (TabToPrevStop(xw))) ;
	    ResetState(sp);
	    break;

	case CASE_CHT:
	    TRACE(("CASE_CHT\n"));
	    /* cursor forward tabulation */
	    count = one_if_default(0);
	    while ((count-- > 0)
		   && (TabToNextStop(xw))) ;
	    ResetState(sp);
	    break;

	case CASE_TAB:
	    /* tab */
	    TabToNextStop(xw);
	    break;

	case CASE_SI:
	    screen->curgl = 0;
	    if_OPT_VT52_MODE(screen, {
		ResetState(sp);
	    });
	    break;

	case CASE_SO:
	    screen->curgl = 1;
	    if_OPT_VT52_MODE(screen, {
		ResetState(sp);
	    });
	    break;

	case CASE_DECDHL:
	    xterm_DECDHL(xw, c == '3');
	    ResetState(sp);
	    break;

	case CASE_DECSWL:
	    xterm_DECSWL(xw);
	    ResetState(sp);
	    break;

	case CASE_DECDWL:
	    xterm_DECDWL(xw);
	    ResetState(sp);
	    break;

	case CASE_SCR_STATE:
	    /* enter scr state */
	    sp->parsestate = scrtable;
	    break;

	case CASE_SCS0_STATE:
	    /* enter scs state 0 */
	    select_charset(sp, 0, 94);
	    break;

	case CASE_SCS1_STATE:
	    /* enter scs state 1 */
	    select_charset(sp, 1, 94);
	    break;

	case CASE_SCS2_STATE:
	    /* enter scs state 2 */
	    select_charset(sp, 2, 94);
	    break;

	case CASE_SCS3_STATE:
	    /* enter scs state 3 */
	    select_charset(sp, 3, 94);
	    break;

	case CASE_SCS1A_STATE:
	    /* enter scs state 1 */
	    select_charset(sp, 1, 96);
	    break;

	case CASE_SCS2A_STATE:
	    /* enter scs state 2 */
	    select_charset(sp, 2, 96);
	    break;

	case CASE_SCS3A_STATE:
	    /* enter scs state 3 */
	    select_charset(sp, 3, 96);
	    break;

	case CASE_ESC_IGNORE:
	    /* unknown escape sequence */
	    sp->parsestate = eigtable;
	    break;

	case CASE_ESC_DIGIT:
	    /* digit in csi or dec mode */
	    if (nparam > 0) {
		value = zero_if_default(nparam - 1);
		SetParam(nparam - 1, (10 * value) + ((int) c - '0'));
		if (GetParam(nparam - 1) > 65535)
		    SetParam(nparam - 1, 65535);
		if (sp->parsestate == csi_table)
		    sp->parsestate = csi2_table;
	    }
	    break;

	case CASE_ESC_SEMI:
	    /* semicolon in csi or dec mode */
	    if (nparam < NPARAM) {
		parms.is_sub[nparam] = 0;
		SetParam(nparam++, DEFAULT);
	    }
	    if (sp->parsestate == csi_table)
		sp->parsestate = csi2_table;
	    break;

	    /*
	     * A _few_ commands accept colon-separated subparameters.
	     * Mark the parameter list so that we can exclude (most) bogus
	     * commands with simple/fast checks.
	     */
	case CASE_ESC_COLON:
	    if (nparam < NPARAM) {
		parms.has_subparams = 1;
		if (nparam == 0) {
		    parms.is_sub[nparam] = 1;
		    SetParam(nparam++, DEFAULT);
		} else if (parms.is_sub[nparam - 1] == 0) {
		    parms.is_sub[nparam - 1] = 1;
		    parms.is_sub[nparam] = 2;
		    parms.params[nparam] = 0;
		    ++nparam;
		} else {
		    parms.is_sub[nparam] = 1 + parms.is_sub[nparam - 1];
		    parms.params[nparam] = 0;
		    ++nparam;
		}
	    }
	    break;

	case CASE_DEC_STATE:
	    /* enter dec mode */
	    sp->parsestate = dec_table;
	    break;

	case CASE_DEC2_STATE:
	    /* enter dec2 mode */
	    sp->parsestate = dec2_table;
	    break;

	case CASE_DEC3_STATE:
	    /* enter dec3 mode */
	    sp->parsestate = dec3_table;
	    break;

	case CASE_ICH:
	    TRACE(("CASE_ICH - insert char\n"));
	    InsertChar(xw, (unsigned) one_if_default(0));
	    ResetState(sp);
	    break;

	case CASE_CUU:
	    TRACE(("CASE_CUU - cursor up\n"));
	    CursorUp(screen, one_if_default(0));
	    ResetState(sp);
	    break;

	case CASE_CUD:
	    TRACE(("CASE_CUD - cursor down\n"));
	    CursorDown(screen, one_if_default(0));
	    ResetState(sp);
	    break;

	case CASE_CUF:
	    TRACE(("CASE_CUF - cursor forward\n"));
	    CursorForward(xw, one_if_default(0));
	    ResetState(sp);
	    break;

	case CASE_CUB:
	    TRACE(("CASE_CUB - cursor backward\n"));
	    CursorBack(xw, one_if_default(0));
	    ResetState(sp);
	    break;

	case CASE_CUP:
	    TRACE(("CASE_CUP - cursor position\n"));
	    if_OPT_XMC_GLITCH(screen, {
		Jump_XMC(xw);
	    });
	    CursorSet(screen, one_if_default(0) - 1, one_if_default(1) - 1, xw->flags);
	    ResetState(sp);
	    break;

	case CASE_VPA:
	    TRACE(("CASE_VPA - vertical position absolute\n"));
	    CursorSet(screen, one_if_default(0) - 1, CursorCol(xw), xw->flags);
	    ResetState(sp);
	    break;

	case CASE_HPA:
	    TRACE(("CASE_HPA - horizontal position absolute\n"));
	    CursorSet(screen, CursorRow(xw), one_if_default(0) - 1, xw->flags);
	    ResetState(sp);
	    break;

	case CASE_VPR:
	    TRACE(("CASE_VPR - vertical position relative\n"));
	    CursorSet(screen,
		      CursorRow(xw) + one_if_default(0),
		      CursorCol(xw),
		      xw->flags);
	    ResetState(sp);
	    break;

	case CASE_HPR:
	    TRACE(("CASE_HPR - horizontal position relative\n"));
	    CursorSet(screen,
		      CursorRow(xw),
		      CursorCol(xw) + one_if_default(0),
		      xw->flags);
	    ResetState(sp);
	    break;

	case CASE_HP_BUGGY_LL:
	    TRACE(("CASE_HP_BUGGY_LL\n"));
	    /* Some HP-UX applications have the bug that they
	       assume ESC F goes to the lower left corner of
	       the screen, regardless of what terminfo says. */
	    if (screen->hp_ll_bc)
		CursorSet(screen, screen->max_row, 0, xw->flags);
	    ResetState(sp);
	    break;

	case CASE_ED:
	    TRACE(("CASE_ED - erase display\n"));
	    do_cd_xtra_scroll(xw);
	    do_erase_display(xw, zero_if_default(0), OFF_PROTECT);
	    ResetState(sp);
	    break;

	case CASE_EL:
	    TRACE(("CASE_EL - erase line\n"));
	    do_erase_line(xw, zero_if_default(0), OFF_PROTECT);
	    ResetState(sp);
	    break;

	case CASE_ECH:
	    TRACE(("CASE_ECH - erase char\n"));
	    /* ECH */
	    ClearRight(xw, one_if_default(0));
	    ResetState(sp);
	    break;

	case CASE_IL:
	    TRACE(("CASE_IL - insert line\n"));
	    set_cur_col(screen, ScrnLeftMargin(xw));
	    InsertLine(xw, one_if_default(0));
	    ResetState(sp);
	    break;

	case CASE_DL:
	    TRACE(("CASE_DL - delete line\n"));
	    set_cur_col(screen, ScrnLeftMargin(xw));
	    DeleteLine(xw, one_if_default(0));
	    ResetState(sp);
	    break;

	case CASE_DCH:
	    TRACE(("CASE_DCH - delete char\n"));
	    DeleteChar(xw, (unsigned) one_if_default(0));
	    ResetState(sp);
	    break;

	case CASE_TRACK_MOUSE:
	    /*
	     * A single parameter other than zero is always scroll-down.
	     * A zero-parameter is used to reset the mouse mode, and is
	     * not useful for scrolling anyway.
	     */
	    if (nparam > 1 || GetParam(0) == 0) {
		CELL start;

		TRACE(("CASE_TRACK_MOUSE\n"));
		/* Track mouse as long as in window and between
		 * specified rows
		 */
		start.row = one_if_default(2) - 1;
		start.col = GetParam(1) - 1;
		TrackMouse(xw,
			   GetParam(0),
			   &start,
			   GetParam(3) - 1, GetParam(4) - 2);
	    } else {
		TRACE(("CASE_SD - scroll down\n"));
		/* SD */
		RevScroll(xw, one_if_default(0));
		do_xevents();
	    }
	    ResetState(sp);
	    break;

	case CASE_DECID:
	    TRACE(("CASE_DECID\n"));
	    if_OPT_VT52_MODE(screen, {
		unparseputc(xw, ANSI_ESC);
		unparseputc(xw, '/');
		unparseputc(xw, 'Z');
		unparse_end(xw);
		ResetState(sp);
		break;
	    });
	    SetParam(0, DEFAULT);	/* Default ID parameter */
	    /* FALLTHRU */
	case CASE_DA1:
	    TRACE(("CASE_DA1\n"));
	    if (GetParam(0) <= 0) {	/* less than means DEFAULT */
		count = 0;
		init_reply(ANSI_CSI);
		reply.a_pintro = '?';

		/*
		 * The first parameter corresponds to the highest operating
		 * level (i.e., service level) of the emulation.  A DEC
		 * terminal can be setup to respond with a different DA
		 * response, but there's no control sequence that modifies
		 * this.  We set it via a resource.
		 */
		if (screen->terminal_id < 200) {
		    switch (screen->terminal_id) {
		    case 125:
			reply.a_param[count++] = 12;	/* VT125 */
#if OPT_REGIS_GRAPHICS
			reply.a_param[count++] = 0 | 2 | 1;	/* no STP, AVO, GPO (ReGIS) */
#else
			reply.a_param[count++] = 0 | 2 | 0;	/* no STP, AVO, no GPO (ReGIS) */
#endif
			reply.a_param[count++] = 0;	/* no printer */
			reply.a_param[count++] = XTERM_PATCH;	/* ROM version */
			break;
		    case 102:
			reply.a_param[count++] = 6;	/* VT102 */
			break;
		    case 101:
			reply.a_param[count++] = 1;	/* VT101 */
			reply.a_param[count++] = 0;	/* no options */
			break;
		    default:	/* VT100 */
			reply.a_param[count++] = 1;	/* VT100 */
			reply.a_param[count++] = 0 | 2 | 0;	/* no STP, AVO, no GPO (ReGIS) */
			break;
		    }
		} else {
		    reply.a_param[count++] = (ParmType) (60
							 + screen->terminal_id
							 / 100);
		    reply.a_param[count++] = 1;		/* 132-columns */
		    reply.a_param[count++] = 2;		/* printer */
#if OPT_REGIS_GRAPHICS
		    if (screen->terminal_id == 240 ||
			screen->terminal_id == 241 ||
			screen->terminal_id == 330 ||
			screen->terminal_id == 340) {
			reply.a_param[count++] = 3;	/* ReGIS graphics */
		    }
#endif
#if OPT_SIXEL_GRAPHICS
		    if (screen->terminal_id == 240 ||
			screen->terminal_id == 241 ||
			screen->terminal_id == 330 ||
			screen->terminal_id == 340 ||
			screen->terminal_id == 382) {
			reply.a_param[count++] = 4;	/* sixel graphics */
		    }
#endif
		    reply.a_param[count++] = 6;		/* selective-erase */
#if OPT_SUNPC_KBD
		    if (xw->keyboard.type == keyboardIsVT220)
#endif
			reply.a_param[count++] = 8;	/* user-defined-keys */
		    reply.a_param[count++] = 9;		/* national replacement charsets */
		    reply.a_param[count++] = 15;	/* technical characters */
		    if (screen->terminal_id >= 400) {
			reply.a_param[count++] = 18;	/* windowing capability */
			reply.a_param[count++] = 21;	/* horizontal scrolling */
		    }
		    if_OPT_ISO_COLORS(screen, {
			reply.a_param[count++] = 22;	/* ANSI color, VT525 */
		    });
#if OPT_DEC_LOCATOR
		    reply.a_param[count++] = 29;	/* ANSI text locator */
#endif
		}
		reply.a_nparam = (ParmType) count;
		reply.a_inters = 0;
		reply.a_final = 'c';
		unparseseq(xw, &reply);
	    }
	    ResetState(sp);
	    break;

	case CASE_DA2:
	    TRACE(("CASE_DA2\n"));
	    if (GetParam(0) <= 0) {	/* less than means DEFAULT */
		count = 0;
		init_reply(ANSI_CSI);
		reply.a_pintro = '>';

		if (screen->terminal_id >= 200) {
		    switch (screen->terminal_id) {
		    case 220:
		    default:
			reply.a_param[count++] = 1;	/* VT220 */
			break;
		    case 240:
			/* http://www.decuslib.com/DECUS/vax87a/gendyn/vt200_kind.lis */
			reply.a_param[count++] = 2;	/* VT240 */
			break;
		    case 320:
			/* http://www.vt100.net/docs/vt320-uu/appendixe.html */
			reply.a_param[count++] = 24;	/* VT320 */
			break;
		    case 330:
			reply.a_param[count++] = 18;	/* VT330 */
			break;
		    case 340:
			reply.a_param[count++] = 19;	/* VT340 */
			break;
		    case 420:
			reply.a_param[count++] = 41;	/* VT420 */
			break;
		    case 510:
			/* http://www.vt100.net/docs/vt510-rm/DA2 */
			reply.a_param[count++] = 61;	/* VT510 */
			break;
		    case 520:
			reply.a_param[count++] = 64;	/* VT520 */
			break;
		    case 525:
			reply.a_param[count++] = 65;	/* VT525 */
			break;
		    }
		} else {
		    reply.a_param[count++] = 0;		/* VT100 (nonstandard) */
		}
		reply.a_param[count++] = XTERM_PATCH;	/* Version */
		reply.a_param[count++] = 0;	/* options (none) */
		reply.a_nparam = (ParmType) count;
		reply.a_inters = 0;
		reply.a_final = 'c';
		unparseseq(xw, &reply);
	    }
	    ResetState(sp);
	    break;

	case CASE_DECRPTUI:
	    TRACE(("CASE_DECRPTUI\n"));
	    if ((screen->vtXX_level >= 4)
		&& (GetParam(0) <= 0)) {	/* less than means DEFAULT */
		unparseputc1(xw, ANSI_DCS);
		unparseputc(xw, '!');
		unparseputc(xw, '|');
		unparseputc(xw, '0');
		unparseputc1(xw, ANSI_ST);
		unparse_end(xw);
	    }
	    ResetState(sp);
	    break;

	case CASE_TBC:
	    TRACE(("CASE_TBC - tab clear\n"));
	    if ((value = GetParam(0)) <= 0)	/* less than means default */
		TabClear(xw->tabs, screen->cur_col);
	    else if (value == 3)
		TabZonk(xw->tabs);
	    ResetState(sp);
	    break;

	case CASE_SET:
	    TRACE(("CASE_SET - set mode\n"));
	    ansi_modes(xw, bitset);
	    ResetState(sp);
	    break;

	case CASE_RST:
	    TRACE(("CASE_RST - reset mode\n"));
	    ansi_modes(xw, bitclr);
	    ResetState(sp);
	    break;

	case CASE_SGR:
	    for (item = 0; item < nparam; ++item) {
		int op = GetParam(item);

		if_OPT_XMC_GLITCH(screen, {
		    Mark_XMC(xw, op);
		});
		TRACE(("CASE_SGR %d\n", op));

		/*
		 * Only SGR 38/48 accept subparameters, and in those cases
		 * the values will not be seen at this point.
		 */
		if (param_has_subparams(item)) {
		    switch (op) {
		    case 38:
			/* FALLTHRU */
		    case 48:
			if_OPT_ISO_COLORS(screen, {
			    break;
			});
			/* FALLTHRU */
		    default:
			TRACE(("...unexpected subparameter in SGR\n"));
			op = 9999;
			ResetState(sp);
			break;
		    }
		}

		switch (op) {
		case DEFAULT:
		    /* FALLTHRU */
		case 0:
#if OPT_WIDE_ATTRS
		    setItalicFont(xw, False);
#endif
		    UIntClr(xw->flags,
			    (SGR_MASK | SGR_MASK2 | INVISIBLE));
		    if_OPT_ISO_COLORS(screen, {
			reset_SGR_Colors(xw);
		    });
		    break;
		case 1:	/* Bold                 */
		    UIntSet(xw->flags, BOLD);
		    if_OPT_ISO_COLORS(screen, {
			setExtendedFG(xw);
		    });
		    break;
#if OPT_WIDE_ATTRS
		case 2:	/* faint, decreased intensity or second colour */
		    UIntSet(xw->flags, ATR_FAINT);
		    if_OPT_ISO_COLORS(screen, {
			setExtendedFG(xw);
		    });
		    break;
		case 3:	/* italicized */
		    setItalicFont(xw, UseItalicFont(screen));
		    UIntSet(xw->flags, ATR_ITALIC);
		    if_OPT_ISO_COLORS(screen, {
			setExtendedFG(xw);
		    });
		    break;
#endif
		case 4:	/* Underscore           */
		    UIntSet(xw->flags, UNDERLINE);
		    if_OPT_ISO_COLORS(screen, {
			setExtendedFG(xw);
		    });
		    break;
		case 5:	/* Blink                */
		    UIntSet(xw->flags, BLINK);
		    StartBlinking(screen);
		    if_OPT_ISO_COLORS(screen, {
			setExtendedFG(xw);
		    });
		    break;
		case 7:
		    UIntSet(xw->flags, INVERSE);
		    if_OPT_ISO_COLORS(screen, {
			setExtendedBG(xw);
		    });
		    break;
		case 8:
		    UIntSet(xw->flags, INVISIBLE);
		    break;
#if OPT_WIDE_ATTRS
		case 9:	/* crossed-out characters */
		    UIntSet(xw->flags, ATR_STRIKEOUT);
		    break;
#endif
#if OPT_WIDE_ATTRS
		case 21:	/* doubly-underlined */
		    UIntSet(xw->flags, ATR_DBL_UNDER);
		    break;
#endif
		case 22:	/* reset 'bold' */
		    UIntClr(xw->flags, BOLD);
#if OPT_WIDE_ATTRS
		    UIntClr(xw->flags, ATR_FAINT);
#endif
		    if_OPT_ISO_COLORS(screen, {
			setExtendedFG(xw);
		    });
		    break;
#if OPT_WIDE_ATTRS
		case 23:	/* not italicized */
		    setItalicFont(xw, False);
		    UIntClr(xw->flags, ATR_ITALIC);
		    if_OPT_ISO_COLORS(screen, {
			setExtendedFG(xw);
		    });
		    break;
#endif
		case 24:
		    UIntClr(xw->flags, UNDERLINE);
#if OPT_WIDE_ATTRS
		    UIntClr(xw->flags, ATR_DBL_UNDER);
#endif
		    if_OPT_ISO_COLORS(screen, {
			setExtendedFG(xw);
		    });
		    break;
		case 25:	/* reset 'blink' */
		    UIntClr(xw->flags, BLINK);
		    if_OPT_ISO_COLORS(screen, {
			setExtendedFG(xw);
		    });
		    break;
		case 27:
		    UIntClr(xw->flags, INVERSE);
		    if_OPT_ISO_COLORS(screen, {
			setExtendedBG(xw);
		    });
		    break;
		case 28:
		    UIntClr(xw->flags, INVISIBLE);
		    break;
#if OPT_WIDE_ATTRS
		case 29:	/* not crossed out */
		    UIntClr(xw->flags, ATR_STRIKEOUT);
		    break;
#endif
		case 30:
		    /* FALLTHRU */
		case 31:
		    /* FALLTHRU */
		case 32:
		    /* FALLTHRU */
		case 33:
		    /* FALLTHRU */
		case 34:
		    /* FALLTHRU */
		case 35:
		    /* FALLTHRU */
		case 36:
		    /* FALLTHRU */
		case 37:
		    if_OPT_ISO_COLORS(screen, {
			xw->sgr_foreground = (op - 30);
			xw->sgr_extended = False;
			setExtendedFG(xw);
		    });
		    break;
		case 38:
		    /* This is more complicated than I'd like, but it should
		     * properly eat all the parameters for unsupported modes.
		     */
		    if_OPT_ISO_COLORS(screen, {
			if (parse_extended_colors(xw, &value, &item)) {
			    xw->sgr_foreground = value;
			    xw->sgr_extended = True;
			    setExtendedFG(xw);
			}
		    });
		    break;
		case 39:
		    if_OPT_ISO_COLORS(screen, {
			reset_SGR_Foreground(xw);
		    });
		    break;
		case 40:
		    /* FALLTHRU */
		case 41:
		    /* FALLTHRU */
		case 42:
		    /* FALLTHRU */
		case 43:
		    /* FALLTHRU */
		case 44:
		    /* FALLTHRU */
		case 45:
		    /* FALLTHRU */
		case 46:
		    /* FALLTHRU */
		case 47:
		    if_OPT_ISO_COLORS(screen, {
			xw->sgr_background = (op - 40);
			setExtendedBG(xw);
		    });
		    break;
		case 48:
		    if_OPT_ISO_COLORS(screen, {
			if (parse_extended_colors(xw, &value, &item)) {
			    xw->sgr_background = value;
			    setExtendedBG(xw);
			}
		    });
		    break;
		case 49:
		    if_OPT_ISO_COLORS(screen, {
			reset_SGR_Background(xw);
		    });
		    break;
		case 90:
		    /* FALLTHRU */
		case 91:
		    /* FALLTHRU */
		case 92:
		    /* FALLTHRU */
		case 93:
		    /* FALLTHRU */
		case 94:
		    /* FALLTHRU */
		case 95:
		    /* FALLTHRU */
		case 96:
		    /* FALLTHRU */
		case 97:
		    if_OPT_AIX_COLORS(screen, {
			xw->sgr_foreground = (op - 90 + 8);
			xw->sgr_extended = False;
			setExtendedFG(xw);
		    });
		    break;
		case 100:
#if !OPT_AIX_COLORS
		    if_OPT_ISO_COLORS(screen, {
			reset_SGR_Foreground(xw);
			reset_SGR_Background(xw);
		    });
		    break;
#endif
		case 101:
		    /* FALLTHRU */
		case 102:
		    /* FALLTHRU */
		case 103:
		    /* FALLTHRU */
		case 104:
		    /* FALLTHRU */
		case 105:
		    /* FALLTHRU */
		case 106:
		    /* FALLTHRU */
		case 107:
		    if_OPT_AIX_COLORS(screen, {
			xw->sgr_background = (op - 100 + 8);
			setExtendedBG(xw);
		    });
		    break;
		}
	    }
	    ResetState(sp);
	    break;

	    /* DSR (except for the '?') is a superset of CPR */
	case CASE_DSR:
	    sp->private_function = True;

	    /* FALLTHRU */
	case CASE_CPR:
	    TRACE(("CASE_DSR - device status report\n"));
	    count = 0;
	    init_reply(ANSI_CSI);
	    reply.a_pintro = CharOf(sp->private_function ? '?' : 0);
	    reply.a_inters = 0;
	    reply.a_final = 'n';

	    switch (GetParam(0)) {
	    case 5:
		TRACE(("...request operating status\n"));
		/* operating status */
		reply.a_param[count++] = 0;	/* (no malfunction ;-) */
		break;
	    case 6:
		TRACE(("...request %s\n",
		       (sp->private_function
			? "DECXCPR"
			: "CPR")));
		/* CPR */
		/* DECXCPR (with page=1) */
		value = (screen->cur_row + 1);
		if ((xw->flags & ORIGIN) != 0) {
		    value -= screen->top_marg;
		}
		reply.a_param[count++] = (ParmType) value;

		value = (screen->cur_col + 1);
		if ((xw->flags & ORIGIN) != 0) {
		    value -= screen->lft_marg;
		}
		reply.a_param[count++] = (ParmType) value;

		if (sp->private_function
		    && screen->vtXX_level >= 4) {	/* VT420 */
		    reply.a_param[count++] = 1;
		}
		reply.a_final = 'R';
		break;
	    case 15:
		TRACE(("...request printer status\n"));
		if (sp->private_function
		    && screen->vtXX_level >= 2) {	/* VT220 */
		    reply.a_param[count++] = 13;	/* no printer detected */
		}
		break;
	    case 25:
		TRACE(("...request UDK status\n"));
		if (sp->private_function
		    && screen->vtXX_level >= 2) {	/* VT220 */
		    reply.a_param[count++] = 20;	/* UDK always unlocked */
		}
		break;
	    case 26:
		TRACE(("...request keyboard status\n"));
		if (sp->private_function
		    && screen->vtXX_level >= 2) {	/* VT220 */
		    reply.a_param[count++] = 27;
		    reply.a_param[count++] = 1;		/* North American */
		    if (screen->vtXX_level >= 4) {	/* VT420 */
			reply.a_param[count++] = 0;	/* ready */
			reply.a_param[count++] = 0;	/* LK201 */
		    }
		}
		break;
	    case 53:		/* according to existing xterm handling */
		/* FALLTHRU */
	    case 55:		/* according to the VT330/VT340 Text Programming Manual */
		TRACE(("...request locator status\n"));
		if (sp->private_function
		    && screen->vtXX_level >= 2) {	/* VT220 */
#if OPT_DEC_LOCATOR
		    reply.a_param[count++] = 50;	/* locator ready */
#else
		    reply.a_param[count++] = 53;	/* no locator */
#endif
		}
		break;
	    case 56:
		TRACE(("...request locator type\n"));
		if (sp->private_function
		    && screen->vtXX_level >= 3) {	/* VT330 (FIXME: what about VT220?) */
		    reply.a_param[count++] = 57;
#if OPT_DEC_LOCATOR
		    reply.a_param[count++] = 1;		/* mouse */
#else
		    reply.a_param[count++] = 0;		/* unknown */
#endif
		}
		break;
	    case 62:
		TRACE(("...request DECMSR - macro space\n"));
		if (sp->private_function
		    && screen->vtXX_level >= 4) {	/* VT420 */
		    reply.a_pintro = 0;
		    reply.a_radix[count] = 16;	/* no data */
		    reply.a_param[count++] = 0;		/* no space for macros */
		    reply.a_inters = '*';
		    reply.a_final = L_CURL;
		}
		break;
	    case 63:
		TRACE(("...request DECCKSR - memory checksum\n"));
		/* DECCKSR - Memory checksum */
		if (sp->private_function
		    && screen->vtXX_level >= 4) {	/* VT420 */
		    init_reply(ANSI_DCS);
		    reply.a_param[count++] = (ParmType) GetParam(1);	/* PID */
		    reply.a_delim = "!~";	/* delimiter */
		    reply.a_radix[count] = 16;	/* use hex */
		    reply.a_param[count++] = 0;		/* no data */
		}
		break;
	    case 75:
		TRACE(("...request data integrity\n"));
		if (sp->private_function
		    && screen->vtXX_level >= 4) {	/* VT420 */
		    reply.a_param[count++] = 70;	/* no errors */
		}
		break;
	    case 85:
		TRACE(("...request multi-session configuration\n"));
		if (sp->private_function
		    && screen->vtXX_level >= 4) {	/* VT420 */
		    reply.a_param[count++] = 83;	/* not configured */
		}
		break;
	    default:
		break;
	    }

	    if ((reply.a_nparam = (ParmType) count) != 0)
		unparseseq(xw, &reply);

	    ResetState(sp);
	    sp->private_function = False;
	    break;

	case CASE_MC:
	    TRACE(("CASE_MC - media control\n"));
	    xtermMediaControl(xw, GetParam(0), False);
	    ResetState(sp);
	    break;

	case CASE_DEC_MC:
	    TRACE(("CASE_DEC_MC - DEC media control\n"));
	    xtermMediaControl(xw, GetParam(0), True);
	    ResetState(sp);
	    break;

	case CASE_HP_MEM_LOCK:
	    /* FALLTHRU */
	case CASE_HP_MEM_UNLOCK:
	    TRACE(("%s\n", ((sp->parsestate[c] == CASE_HP_MEM_LOCK)
			    ? "CASE_HP_MEM_LOCK"
			    : "CASE_HP_MEM_UNLOCK")));
	    if (screen->scroll_amt)
		FlushScroll(xw);
	    if (sp->parsestate[c] == CASE_HP_MEM_LOCK)
		set_tb_margins(screen, screen->cur_row, screen->bot_marg);
	    else
		set_tb_margins(screen, 0, screen->bot_marg);
	    ResetState(sp);
	    break;

	case CASE_DECSTBM:
	    TRACE(("CASE_DECSTBM - set scrolling region\n"));
	    {
		int top;
		int bot;
		top = one_if_default(0);
		if (nparam < 2 || (bot = GetParam(1)) == DEFAULT
		    || bot > MaxRows(screen)
		    || bot == 0)
		    bot = MaxRows(screen);
		if (bot > top) {
		    if (screen->scroll_amt)
			FlushScroll(xw);
		    set_tb_margins(screen, top - 1, bot - 1);
		    CursorSet(screen, 0, 0, xw->flags);
		}
		ResetState(sp);
	    }
	    break;

	case CASE_DECREQTPARM:
	    TRACE(("CASE_DECREQTPARM\n"));
	    if (screen->terminal_id < 200) {	/* VT102 */
		value = zero_if_default(0);
		if (value == 0 || value == 1) {
		    init_reply(ANSI_CSI);
		    reply.a_pintro = 0;
		    reply.a_nparam = 7;
		    reply.a_param[0] = (ParmType) (value + 2);
		    reply.a_param[1] = 1;	/* no parity */
		    reply.a_param[2] = 1;	/* eight bits */
		    reply.a_param[3] = 128;	/* transmit 38.4k baud */
		    reply.a_param[4] = 128;	/* receive 38.4k baud */
		    reply.a_param[5] = 1;	/* clock multiplier ? */
		    reply.a_param[6] = 0;	/* STP flags ? */
		    reply.a_inters = 0;
		    reply.a_final = 'x';
		    unparseseq(xw, &reply);
		}
	    }
	    ResetState(sp);
	    break;

	case CASE_DECSET:
	    /* DECSET */
#if OPT_VT52_MODE
	    if (screen->vtXX_level != 0)
#endif
		dpmodes(xw, bitset);
	    ResetState(sp);
#if OPT_TEK4014
	    if (TEK4014_ACTIVE(xw)) {
		TRACE(("Tek4014 is now active...\n"));
		return False;
	    }
#endif
	    break;

	case CASE_DECRST:
	    /* DECRST */
	    dpmodes(xw, bitclr);
	    init_groundtable(screen, sp);
	    ResetState(sp);
	    break;

	case CASE_DECALN:
	    TRACE(("CASE_DECALN - alignment test\n"));
	    if (screen->cursor_state)
		HideCursor();
	    reset_margins(screen);
	    CursorSet(screen, 0, 0, xw->flags);
	    xtermParseRect(xw, 0, 0, &myRect);
	    ScrnFillRectangle(xw, &myRect, 'E', 0, False);
	    ResetState(sp);
	    break;

	case CASE_GSETS:
	    TRACE(("CASE_GSETS(%d) = '%c'\n", sp->scstype, c));
	    decode_scs(xw, sp->scstype, 0, (int) c);
	    ResetState(sp);
	    break;

	case CASE_ANSI_SC:
	    if (IsLeftRightMode(xw)) {
		int left;
		int right;

		TRACE(("CASE_DECSLRM - set left and right margin\n"));
		left = one_if_default(0);
		if (nparam < 2 || (right = GetParam(1)) == DEFAULT
		    || right > MaxCols(screen)
		    || right == 0)
		    right = MaxCols(screen);
		if (right > left) {
		    set_lr_margins(screen, left - 1, right - 1);
		    CursorSet(screen, 0, 0, xw->flags);
		}
	    } else {
		TRACE(("CASE_ANSI_SC - save cursor\n"));
		CursorSave(xw);
	    }
	    ResetState(sp);
	    break;

	case CASE_DECSC:
	    TRACE(("CASE_DECSC - save cursor\n"));
	    CursorSave(xw);
	    ResetState(sp);
	    break;

	case CASE_ANSI_RC:
	    /* FALLTHRU */
	case CASE_DECRC:
	    TRACE(("CASE_%sRC - restore cursor\n",
		   (sp->nextstate == CASE_DECRC) ? "DEC" : "ANSI_"));
	    CursorRestore(xw);
	    if_OPT_ISO_COLORS(screen, {
		setExtendedFG(xw);
	    });
	    ResetState(sp);
	    break;

	case CASE_DECKPAM:
	    TRACE(("CASE_DECKPAM\n"));
	    xw->keyboard.flags |= MODE_DECKPAM;
	    update_appkeypad();
	    ResetState(sp);
	    break;

	case CASE_DECKPNM:
	    TRACE(("CASE_DECKPNM\n"));
	    UIntClr(xw->keyboard.flags, MODE_DECKPAM);
	    update_appkeypad();
	    ResetState(sp);
	    break;

	case CASE_CSI_QUOTE_STATE:
	    sp->parsestate = csi_quo_table;
	    break;

#if OPT_BLINK_CURS
	case CASE_CSI_SPACE_STATE:
	    sp->parsestate = csi_sp_table;
	    break;

	case CASE_DECSCUSR:
	    TRACE(("CASE_DECSCUSR\n"));
	    {
		Boolean change = True;
		Boolean blinks = screen->cursor_blink_esc;

		HideCursor();

		switch (GetParam(0)) {
		case DEFAULT:
		    /* FALLTHRU */
		case DEFAULT_STYLE:
		    /* FALLTHRU */
		case BLINK_BLOCK:
		    blinks = True;
		    screen->cursor_shape = CURSOR_BLOCK;
		    break;
		case STEADY_BLOCK:
		    blinks = False;
		    screen->cursor_shape = CURSOR_BLOCK;
		    break;
		case BLINK_UNDERLINE:
		    blinks = True;
		    screen->cursor_shape = CURSOR_UNDERLINE;
		    break;
		case STEADY_UNDERLINE:
		    blinks = False;
		    screen->cursor_shape = CURSOR_UNDERLINE;
		    break;
		case BLINK_BAR:
		    blinks = True;
		    screen->cursor_shape = CURSOR_BAR;
		    break;
		case STEADY_BAR:
		    blinks = False;
		    screen->cursor_shape = CURSOR_BAR;
		    break;
		default:
		    change = False;
		    break;
		}
		TRACE(("cursor_shape:%d blinks:%s\n",
		       screen->cursor_shape, BtoS(blinks)));
		if (change) {
		    xtermSetCursorBox(screen);
		    screen->cursor_blink_esc = blinks;
		    UpdateCursorBlink(screen);
		}
	    }
	    ResetState(sp);
	    break;
#endif

#if OPT_SCROLL_LOCK
	case CASE_DECLL:
	    TRACE(("CASE_DECLL\n"));
	    if (nparam > 0) {
		for (count = 0; count < nparam; ++count) {
		    int op = zero_if_default(count);
		    switch (op) {
		    case 0:
		    case DEFAULT:
			xtermClearLEDs(screen);
			break;
		    case 1:
			/* FALLTHRU */
		    case 2:
			/* FALLTHRU */
		    case 3:
			xtermShowLED(screen,
				     (Cardinal) op,
				     True);
			break;
		    case 21:
			/* FALLTHRU */
		    case 22:
			/* FALLTHRU */
		    case 23:
			xtermShowLED(screen,
				     (Cardinal) (op - 20),
				     True);
			break;
		    }
		}
	    } else {
		xtermClearLEDs(screen);
	    }
	    ResetState(sp);
	    break;
#endif

#if OPT_VT52_MODE
	case CASE_VT52_FINISH:
	    TRACE(("CASE_VT52_FINISH terminal_id %d, vtXX_level %d\n",
		   screen->terminal_id,
		   screen->vtXX_level));
	    if (screen->terminal_id >= 100
		&& screen->vtXX_level == 0) {
		sp->groundtable =
		    sp->parsestate = ansi_table;
		/*
		 * On restore, the terminal does not recognize DECRQSS for
		 * DECSCL (per vttest).
		 */
		screen->vtXX_level = 1;
		screen->curgl = screen->vt52_save_curgl;
		screen->curgr = screen->vt52_save_curgr;
		screen->curss = screen->vt52_save_curss;
		memmove(screen->gsets, screen->vt52_save_gsets, sizeof(screen->gsets));
	    }
	    break;
#endif

	case CASE_ANSI_LEVEL_1:
	    TRACE(("CASE_ANSI_LEVEL_1\n"));
	    set_ansi_conformance(screen, 1);
	    ResetState(sp);
	    break;

	case CASE_ANSI_LEVEL_2:
	    TRACE(("CASE_ANSI_LEVEL_2\n"));
	    set_ansi_conformance(screen, 2);
	    ResetState(sp);
	    break;

	case CASE_ANSI_LEVEL_3:
	    TRACE(("CASE_ANSI_LEVEL_3\n"));
	    set_ansi_conformance(screen, 3);
	    ResetState(sp);
	    break;

	case CASE_DECSCL:
	    TRACE(("CASE_DECSCL(%d,%d)\n", GetParam(0), GetParam(1)));
	    /*
	     * This changes the emulation level, and is not recognized by
	     * VT100s.
	     */
	    if (screen->terminal_id >= 200) {
		/*
		 * Disallow unrecognized parameters, as well as attempts to set
		 * the operating level higher than the given terminal-id.
		 */
		if (GetParam(0) >= 61
		    && GetParam(0) <= 60 + (screen->terminal_id / 100)) {
		    int new_vtXX_level = GetParam(0) - 60;
		    int case_value = zero_if_default(1);
		    /*
		     * VT300, VT420, VT520 manuals claim that DECSCL does a
		     * hard reset (RIS).  VT220 manual states that it is a soft
		     * reset.  Perhaps both are right (unlikely).  Kermit says
		     * it's soft.
		     */
		    ReallyReset(xw, False, False);
		    init_parser(xw, sp);
		    screen->vtXX_level = new_vtXX_level;
		    if (new_vtXX_level > 1) {
			switch (case_value) {
			case 1:
			    show_8bit_control(False);
			    break;
			case 0:
			case 2:
			    show_8bit_control(True);
			    break;
			}
		    }
		}
	    }
	    ResetState(sp);
	    break;

	case CASE_DECSCA:
	    TRACE(("CASE_DECSCA\n"));
	    screen->protected_mode = DEC_PROTECT;
	    if (GetParam(0) <= 0 || GetParam(0) == 2) {
		UIntClr(xw->flags, PROTECTED);
		TRACE(("...clear PROTECTED\n"));
	    } else if (GetParam(0) == 1) {
		xw->flags |= PROTECTED;
		TRACE(("...set PROTECTED\n"));
	    }
	    ResetState(sp);
	    break;

	case CASE_DECSED:
	    TRACE(("CASE_DECSED\n"));
	    do_erase_display(xw, zero_if_default(0), DEC_PROTECT);
	    ResetState(sp);
	    break;

	case CASE_DECSEL:
	    TRACE(("CASE_DECSEL\n"));
	    do_erase_line(xw, zero_if_default(0), DEC_PROTECT);
	    ResetState(sp);
	    break;

	case CASE_GRAPHICS_ATTRIBUTES:
#if OPT_GRAPHICS
	    TRACE(("CASE_GRAPHICS_ATTRIBUTES\n"));
	    {
		/* request: item, action, value */
		/* reply: item, status, value */
		if (nparam != 3) {
		    TRACE(("DATA_ERROR: malformed CASE_GRAPHICS_ATTRIBUTES request with %d parameters\n", nparam));
		} else {
		    int status = 3;
		    int result = 0;
		    int result2 = 0;

		    TRACE(("CASE_GRAPHICS_ATTRIBUTES request: %d, %d, %d\n",
			   GetParam(0), GetParam(1), GetParam(2)));
		    switch (GetParam(0)) {
		    case 1:	/* color register count */
			switch (GetParam(1)) {
			case 1:	/* read */
			    status = 0;
			    result = (int) get_color_register_count(screen);
			    break;
			case 2:	/* reset */
			    screen->numcolorregisters = 0;
			    status = 0;
			    result = (int) get_color_register_count(screen);
			    break;
			case 3:	/* set */
			    if (GetParam(2) > 1 &&
				(unsigned) GetParam(2) <= MAX_COLOR_REGISTERS) {
				screen->numcolorregisters = GetParam(2);
				status = 0;
				result = (int) get_color_register_count(screen);
			    }
			    break;
			case 4:	/* read maximum */
			    status = 0;
			    result = MAX_COLOR_REGISTERS;
			    break;
			default:
			    TRACE(("DATA_ERROR: CASE_GRAPHICS_ATTRIBUTES color register count request with unknown action parameter: %d\n",
				   GetParam(1)));
			    status = 2;
			    break;
			}
			break;
		    case 2:	/* graphics geometry */
			switch (GetParam(1)) {
			case 1:	/* read */
			    status = 0;
			    result = screen->graphics_max_wide;
			    result2 = screen->graphics_max_high;
			    break;
			case 2:	/* reset */
			    /* FALLTHRU */
			case 3:	/* set */
			    /* FALLTHRU */
			case 4:	/* read maximum */
			    /* not implemented */
			    break;
			default:
			    TRACE(("DATA_ERROR: CASE_GRAPHICS_ATTRIBUTES graphics geometry request with unknown action parameter: %d\n",
				   GetParam(1)));
			    status = 2;
			    break;
			}
			break;
# if OPT_REGIS_GRAPHICS
		    case 3:	/* ReGIS geometry */
			switch (GetParam(1)) {
			case 1:	/* read */
			    status = 0;
			    result = screen->graphics_regis_def_wide;
			    result2 = screen->graphics_regis_def_high;
			    break;
			case 2:	/* reset */
			    /* FALLTHRU */
			case 3:	/* set */
			    /* FALLTHRU */
			case 4:	/* read maximum */
			    /* not implemented */
			    break;
			default:
			    TRACE(("DATA_ERROR: CASE_GRAPHICS_ATTRIBUTES ReGIS geometry request with unknown action parameter: %d\n",
				   GetParam(1)));
			    status = 2;
			    break;
			}
			break;
#endif
		    default:
			TRACE(("DATA_ERROR: CASE_GRAPHICS_ATTRIBUTES request with unknown item parameter: %d\n",
			       GetParam(0)));
			status = 1;
			break;
		    }

		    init_reply(ANSI_CSI);
		    reply.a_pintro = '?';
		    count = 0;
		    reply.a_param[count++] = (ParmType) GetParam(0);
		    reply.a_param[count++] = (ParmType) status;
		    reply.a_param[count++] = (ParmType) result;
		    if (GetParam(0) >= 2)
			reply.a_param[count++] = (ParmType) result2;
		    reply.a_nparam = (ParmType) count;
		    reply.a_inters = 0;
		    reply.a_final = 'S';
		    unparseseq(xw, &reply);
		}
	    }
#endif
	    ResetState(sp);
	    break;

	case CASE_ST:
	    TRACE(("CASE_ST: End of String (%lu bytes) (mode=%d)\n",
		   (unsigned long) sp->string_used,
		   sp->string_mode));
	    ResetState(sp);
	    if (!sp->string_used)
		break;
	    sp->string_area[--(sp->string_used)] = '\0';
	    switch (sp->string_mode) {
	    case ANSI_APC:
		/* ignored */
		break;
	    case ANSI_DCS:
		do_dcs(xw, sp->string_area, sp->string_used);
		break;
	    case ANSI_OSC:
		do_osc(xw, sp->string_area, sp->string_used, ANSI_ST);
		break;
	    case ANSI_PM:
		/* ignored */
		break;
	    case ANSI_SOS:
		/* ignored */
		break;
	    default:
		TRACE(("unknown mode\n"));
		break;
	    }
	    break;

	case CASE_SOS:
	    TRACE(("CASE_SOS: Start of String\n"));
	    if (ParseSOS(screen)) {
		sp->string_mode = ANSI_SOS;
		sp->parsestate = sos_table;
	    } else {
		illegal_parse(xw, c, sp);
	    }
	    break;

	case CASE_PM:
	    TRACE(("CASE_PM: Privacy Message\n"));
	    if (ParseSOS(screen)) {
		sp->string_mode = ANSI_PM;
		sp->parsestate = sos_table;
	    } else {
		illegal_parse(xw, c, sp);
	    }
	    break;

	case CASE_DCS:
	    TRACE(("CASE_DCS: Device Control String\n"));
	    sp->string_mode = ANSI_DCS;
	    sp->parsestate = sos_table;
	    break;

	case CASE_APC:
	    TRACE(("CASE_APC: Application Program Command\n"));
	    if (ParseSOS(screen)) {
		sp->string_mode = ANSI_APC;
		sp->parsestate = sos_table;
	    } else {
		illegal_parse(xw, c, sp);
	    }
	    break;

	case CASE_SPA:
	    TRACE(("CASE_SPA - start protected area\n"));
	    screen->protected_mode = ISO_PROTECT;
	    xw->flags |= PROTECTED;
	    ResetState(sp);
	    break;

	case CASE_EPA:
	    TRACE(("CASE_EPA - end protected area\n"));
	    UIntClr(xw->flags, PROTECTED);
	    ResetState(sp);
	    break;

	case CASE_SU:
	    TRACE(("CASE_SU - scroll up\n"));
	    xtermScroll(xw, one_if_default(0));
	    ResetState(sp);
	    break;

	case CASE_SL:		/* ISO 6429, non-DEC */
	    TRACE(("CASE_SL - scroll left\n"));
	    xtermScrollLR(xw, one_if_default(0), True);
	    ResetState(sp);
	    break;

	case CASE_SR:		/* ISO 6429, non-DEC */
	    TRACE(("CASE_SR - scroll right\n"));
	    xtermScrollLR(xw, one_if_default(0), False);
	    ResetState(sp);
	    break;

	case CASE_DECDC:
	    TRACE(("CASE_DC - delete column\n"));
	    if (screen->vtXX_level >= 4) {
		xtermColScroll(xw, one_if_default(0), True, screen->cur_col);
	    }
	    ResetState(sp);
	    break;

	case CASE_DECIC:
	    TRACE(("CASE_IC - insert column\n"));
	    if (screen->vtXX_level >= 4) {
		xtermColScroll(xw, one_if_default(0), False, screen->cur_col);
	    }
	    ResetState(sp);
	    break;

	case CASE_DECBI:
	    TRACE(("CASE_BI - back index\n"));
	    if (screen->vtXX_level >= 4) {
		xtermColIndex(xw, True);
	    }
	    ResetState(sp);
	    break;

	case CASE_DECFI:
	    TRACE(("CASE_FI - forward index\n"));
	    if (screen->vtXX_level >= 4) {
		xtermColIndex(xw, False);
	    }
	    ResetState(sp);
	    break;

	case CASE_IND:
	    TRACE(("CASE_IND - index\n"));
	    xtermIndex(xw, 1);
	    do_xevents();
	    ResetState(sp);
	    break;

	case CASE_CPL:
	    TRACE(("CASE_CPL - cursor prev line\n"));
	    CursorPrevLine(xw, one_if_default(0));
	    ResetState(sp);
	    break;

	case CASE_CNL:
	    TRACE(("CASE_CNL - cursor next line\n"));
	    CursorNextLine(xw, one_if_default(0));
	    ResetState(sp);
	    break;

	case CASE_NEL:
	    TRACE(("CASE_NEL\n"));
	    xtermIndex(xw, 1);
	    CarriageReturn(xw);
	    ResetState(sp);
	    break;

	case CASE_HTS:
	    TRACE(("CASE_HTS - horizontal tab set\n"));
	    TabSet(xw->tabs, screen->cur_col);
	    ResetState(sp);
	    break;

	case CASE_RI:
	    TRACE(("CASE_RI - reverse index\n"));
	    RevIndex(xw, 1);
	    ResetState(sp);
	    break;

	case CASE_SS2:
	    TRACE(("CASE_SS2\n"));
	    screen->curss = 2;
	    ResetState(sp);
	    break;

	case CASE_SS3:
	    TRACE(("CASE_SS3\n"));
	    screen->curss = 3;
	    ResetState(sp);
	    break;

	case CASE_CSI_STATE:
	    /* enter csi state */
	    InitParams();
	    SetParam(nparam++, DEFAULT);
	    sp->parsestate = csi_table;
	    break;

	case CASE_ESC_SP_STATE:
	    /* esc space */
	    sp->parsestate = esc_sp_table;
	    break;

	case CASE_CSI_EX_STATE:
	    /* csi exclamation */
	    sp->parsestate = csi_ex_table;
	    break;

	case CASE_CSI_TICK_STATE:
	    /* csi tick (') */
	    sp->parsestate = csi_tick_table;
	    break;

#if OPT_DEC_LOCATOR
	case CASE_DECEFR:
	    TRACE(("CASE_DECEFR - Enable Filter Rectangle\n"));
	    if (okSendMousePos(xw) == DEC_LOCATOR) {
		MotionOff(screen, xw);
		if ((screen->loc_filter_top = GetParam(0)) < 1)
		    screen->loc_filter_top = LOC_FILTER_POS;
		if (nparam < 2
		    || (screen->loc_filter_left = GetParam(1)) < 1)
		    screen->loc_filter_left = LOC_FILTER_POS;
		if (nparam < 3
		    || (screen->loc_filter_bottom = GetParam(2)) < 1)
		    screen->loc_filter_bottom = LOC_FILTER_POS;
		if (nparam < 4
		    || (screen->loc_filter_right = GetParam(3)) < 1)
		    screen->loc_filter_right = LOC_FILTER_POS;
		InitLocatorFilter(xw);
	    }
	    ResetState(sp);
	    break;

	case CASE_DECELR:
	    MotionOff(screen, xw);
	    if (GetParam(0) <= 0 || GetParam(0) > 2) {
		screen->send_mouse_pos = MOUSE_OFF;
		TRACE(("DECELR - Disable Locator Reports\n"));
	    } else {
		TRACE(("DECELR - Enable Locator Reports\n"));
		screen->send_mouse_pos = DEC_LOCATOR;
		xtermShowPointer(xw, True);
		if (GetParam(0) == 2) {
		    screen->locator_reset = True;
		} else {
		    screen->locator_reset = False;
		}
		if (nparam < 2 || GetParam(1) != 1) {
		    screen->locator_pixels = False;
		} else {
		    screen->locator_pixels = True;
		}
		screen->loc_filter = False;
	    }
	    ResetState(sp);
	    break;

	case CASE_DECSLE:
	    TRACE(("DECSLE - Select Locator Events\n"));
	    for (count = 0; count < nparam; ++count) {
		switch (zero_if_default(count)) {
		case 0:
		    MotionOff(screen, xw);
		    screen->loc_filter = False;
		    screen->locator_events = 0;
		    break;
		case 1:
		    screen->locator_events |= LOC_BTNS_DN;
		    break;
		case 2:
		    UIntClr(screen->locator_events, LOC_BTNS_DN);
		    break;
		case 3:
		    screen->locator_events |= LOC_BTNS_UP;
		    break;
		case 4:
		    UIntClr(screen->locator_events, LOC_BTNS_UP);
		    break;
		}
	    }
	    ResetState(sp);
	    break;

	case CASE_DECRQLP:
	    TRACE(("DECRQLP - Request Locator Position\n"));
	    if (GetParam(0) < 2) {
		/* Issue DECLRP Locator Position Report */
		GetLocatorPosition(xw);
	    }
	    ResetState(sp);
	    break;
#endif /* OPT_DEC_LOCATOR */

#if OPT_DEC_RECTOPS
	case CASE_CSI_DOLLAR_STATE:
	    TRACE(("CASE_CSI_DOLLAR_STATE\n"));
	    /* csi dollar ($) */
	    if (screen->vtXX_level >= 3)
		sp->parsestate = csi_dollar_table;
	    else
		sp->parsestate = eigtable;
	    break;

	case CASE_CSI_STAR_STATE:
	    TRACE(("CASE_CSI_STAR_STATE\n"));
	    /* csi star (*) */
	    if (screen->vtXX_level >= 4)
		sp->parsestate = csi_star_table;
	    else
		sp->parsestate = eigtable;
	    break;

	case CASE_DECRQCRA:
	    if (screen->vtXX_level >= 4) {
		int checksum;

		TRACE(("CASE_DECRQCRA - Request checksum of rectangular area\n"));
		xtermCheckRect(xw, ParamPair(0), &checksum);
		init_reply(ANSI_DCS);
		count = 0;
		reply.a_param[count++] = (ParmType) GetParam(1);	/* PID */
		reply.a_delim = "!~";	/* delimiter */
		reply.a_radix[count] = 16;
		reply.a_param[count++] = (ParmType) checksum;
		reply.a_nparam = (ParmType) count;
		unparseseq(xw, &reply);
	    }
	    ResetState(sp);
	    break;

	case CASE_DECCRA:
	    if (screen->vtXX_level >= 4) {
		TRACE(("CASE_DECCRA - Copy rectangular area\n"));
		xtermParseRect(xw, ParamPair(0), &myRect);
		ScrnCopyRectangle(xw, &myRect, ParamPair(5));
	    }
	    ResetState(sp);
	    break;

	case CASE_DECERA:
	    if (screen->vtXX_level >= 4) {
		TRACE(("CASE_DECERA - Erase rectangular area\n"));
		xtermParseRect(xw, ParamPair(0), &myRect);
		ScrnFillRectangle(xw, &myRect, ' ', 0, True);
	    }
	    ResetState(sp);
	    break;

	case CASE_DECFRA:
	    if (screen->vtXX_level >= 4) {
		value = zero_if_default(0);

		TRACE(("CASE_DECFRA - Fill rectangular area\n"));
		if (nparam > 0
		    && ((value >= 32 && value <= 126)
			|| (value >= 160 && value <= 255))) {
		    xtermParseRect(xw, ParamPair(1), &myRect);
		    ScrnFillRectangle(xw, &myRect, value, xw->flags, True);
		}
	    }
	    ResetState(sp);
	    break;

	case CASE_DECSERA:
	    if (screen->vtXX_level >= 4) {
		TRACE(("CASE_DECSERA - Selective erase rectangular area\n"));
		xtermParseRect(xw, ParamPair(0), &myRect);
		ScrnWipeRectangle(xw, &myRect);
	    }
	    ResetState(sp);
	    break;

	case CASE_DECSACE:
	    TRACE(("CASE_DECSACE - Select attribute change extent\n"));
	    screen->cur_decsace = zero_if_default(0);
	    ResetState(sp);
	    break;

	case CASE_DECCARA:
	    if (screen->vtXX_level >= 4) {
		TRACE(("CASE_DECCARA - Change attributes in rectangular area\n"));
		xtermParseRect(xw, ParamPair(0), &myRect);
		ScrnMarkRectangle(xw, &myRect, False, ParamPair(4));
	    }
	    ResetState(sp);
	    break;

	case CASE_DECRARA:
	    if (screen->vtXX_level >= 4) {
		TRACE(("CASE_DECRARA - Reverse attributes in rectangular area\n"));
		xtermParseRect(xw, ParamPair(0), &myRect);
		ScrnMarkRectangle(xw, &myRect, True, ParamPair(4));
	    }
	    ResetState(sp);
	    break;

	case CASE_RQM:
	    TRACE(("CASE_RQM\n"));
	    do_rpm(xw, ParamPair(0));
	    ResetState(sp);
	    break;

	case CASE_DECRQM:
	    TRACE(("CASE_DECRQM\n"));
	    do_decrpm(xw, ParamPair(0));
	    ResetState(sp);
	    break;

	case CASE_CSI_DEC_DOLLAR_STATE:
	    TRACE(("CASE_CSI_DEC_DOLLAR_STATE\n"));
	    /* csi ? dollar ($) */
	    sp->parsestate = csi_dec_dollar_table;
	    break;
#else
	case CASE_CSI_DOLLAR_STATE:
	    /* csi dollar ($) */
	    sp->parsestate = eigtable;
	    break;

	case CASE_CSI_STAR_STATE:
	    /* csi dollar (*) */
	    sp->parsestate = eigtable;
	    break;

	case CASE_CSI_DEC_DOLLAR_STATE:
	    /* csi ? dollar ($) */
	    sp->parsestate = eigtable;
	    break;
#endif /* OPT_DEC_RECTOPS */

	case CASE_S7C1T:
	    TRACE(("CASE_S7C1T\n"));
	    if (screen->vtXX_level >= 2) {
		show_8bit_control(False);
		ResetState(sp);
	    }
	    break;

	case CASE_S8C1T:
	    TRACE(("CASE_S8C1T\n"));
	    if (screen->vtXX_level >= 2) {
#if OPT_VT52_MODE
		if (screen->vtXX_level <= 1)
		    break;
#endif
		show_8bit_control(True);
		ResetState(sp);
	    }
	    break;

	case CASE_OSC:
	    TRACE(("CASE_OSC: Operating System Command\n"));
	    sp->parsestate = sos_table;
	    sp->string_mode = ANSI_OSC;
	    break;

	case CASE_RIS:
	    TRACE(("CASE_RIS\n"));
	    VTReset(xw, True, True);
	    /* NOTREACHED */

	case CASE_DECSTR:
	    TRACE(("CASE_DECSTR\n"));
	    VTReset(xw, False, False);
	    /* NOTREACHED */

	case CASE_REP:
	    TRACE(("CASE_REP\n"));
	    if (sp->lastchar >= 0 &&
		sp->lastchar < 256 &&
		sp->groundtable[E2A(sp->lastchar)] == CASE_PRINT) {
		IChar repeated[2];
		count = one_if_default(0);
		repeated[0] = (IChar) sp->lastchar;
		while (count-- > 0) {
		    dotext(xw,
			   screen->gsets[(int) (screen->curgl)],
			   repeated, 1);
		}
	    }
	    ResetState(sp);
	    break;

	case CASE_LS2:
	    TRACE(("CASE_LS2\n"));
	    screen->curgl = 2;
	    ResetState(sp);
	    break;

	case CASE_LS3:
	    TRACE(("CASE_LS3\n"));
	    screen->curgl = 3;
	    ResetState(sp);
	    break;

	case CASE_LS3R:
	    TRACE(("CASE_LS3R\n"));
	    screen->curgr = 3;
	    ResetState(sp);
	    break;

	case CASE_LS2R:
	    TRACE(("CASE_LS2R\n"));
	    screen->curgr = 2;
	    ResetState(sp);
	    break;

	case CASE_LS1R:
	    TRACE(("CASE_LS1R\n"));
	    screen->curgr = 1;
	    ResetState(sp);
	    break;

	case CASE_XTERM_SAVE:
	    savemodes(xw);
	    ResetState(sp);
	    break;

	case CASE_XTERM_RESTORE:
	    restoremodes(xw);
	    ResetState(sp);
	    break;

	case CASE_XTERM_WINOPS:
	    TRACE(("CASE_XTERM_WINOPS\n"));
	    window_ops(xw);
	    ResetState(sp);
	    break;
#if OPT_WIDE_CHARS
	case CASE_ESC_PERCENT:
	    TRACE(("CASE_ESC_PERCENT\n"));
	    sp->parsestate = esc_pct_table;
	    break;

	case CASE_UTF8:
	    /* If we did not set UTF-8 mode from resource or the
	     * command-line, allow it to be enabled/disabled by
	     * control sequence.
	     */
	    TRACE(("CASE_UTF8 wide:%d, utf8:%d, req:%s\n",
		   screen->wide_chars,
		   screen->utf8_mode,
		   BtoS(c == 'G')));
	    if ((!screen->wide_chars) && (c == 'G')) {
		WriteNow();
		ChangeToWide(xw);
	    }
	    if (screen->wide_chars
		&& !screen->utf8_always) {
		switchPtyData(screen, c == 'G');
		TRACE(("UTF8 mode %s\n",
		       BtoS(screen->utf8_mode)));
	    } else {
		TRACE(("UTF8 mode NOT turned %s (%s)\n",
		       BtoS(c == 'G'),
		       (screen->utf8_mode == uAlways)
		       ? "UTF-8 mode set from command-line"
		       : "wideChars resource was not set"));
	    }
	    ResetState(sp);
	    break;

	case CASE_SCS_PERCENT:
	    TRACE(("CASE_SCS_PERCENT\n"));
	    sp->parsestate = scs_pct_table;
	    break;

	case CASE_GSETS_PERCENT:
	    TRACE(("CASE_GSETS_PERCENT(%d) = '%c'\n", sp->scstype, c));
	    decode_scs(xw, sp->scstype, '%', (int) c);
	    ResetState(sp);
	    break;
#endif
#if OPT_MOD_FKEYS
	case CASE_SET_MOD_FKEYS:
	    TRACE(("CASE_SET_MOD_FKEYS\n"));
	    if (nparam >= 1) {
		set_mod_fkeys(xw,
			      GetParam(0),
			      ((nparam > 1)
			       ? GetParam(1)
			       : DEFAULT),
			      True);
	    } else {
		for (value = 1; value <= 5; ++value)
		    set_mod_fkeys(xw, value, DEFAULT, True);
	    }
	    break;
	case CASE_SET_MOD_FKEYS0:
	    TRACE(("CASE_SET_MOD_FKEYS0\n"));
	    if (nparam >= 1 && GetParam(0) != DEFAULT) {
		set_mod_fkeys(xw, GetParam(0), -1, False);
	    } else {
		xw->keyboard.modify_now.function_keys = -1;
	    }
	    break;
#endif
	case CASE_HIDE_POINTER:
	    TRACE(("CASE_HIDE_POINTER\n"));
	    if (nparam >= 1 && GetParam(0) != DEFAULT) {
		screen->pointer_mode = GetParam(0);
	    } else {
		screen->pointer_mode = DEF_POINTER_MODE;
	    }
	    break;

	case CASE_SM_TITLE:
	    TRACE(("CASE_SM_TITLE\n"));
	    if (nparam >= 1) {
		int n;
		for (n = 0; n < nparam; ++n) {
		    if (GetParam(n) != DEFAULT)
			screen->title_modes |= (1 << GetParam(n));
		}
	    } else {
		screen->title_modes = DEF_TITLE_MODES;
	    }
	    TRACE(("...title_modes %#x\n", screen->title_modes));
	    break;

	case CASE_RM_TITLE:
	    TRACE(("CASE_RM_TITLE\n"));
	    if (nparam >= 1) {
		int n;
		for (n = 0; n < nparam; ++n) {
		    if (GetParam(n) != DEFAULT)
			screen->title_modes &= ~(1 << GetParam(n));
		}
	    } else {
		screen->title_modes = DEF_TITLE_MODES;
	    }
	    TRACE(("...title_modes %#x\n", screen->title_modes));
	    break;

	case CASE_CSI_IGNORE:
	    sp->parsestate = cigtable;
	    break;

	case CASE_DECSWBV:
	    TRACE(("CASE_DECSWBV\n"));
	    switch (zero_if_default(0)) {
	    case 2:
		/* FALLTHRU */
	    case 3:
		/* FALLTHRU */
	    case 4:
		screen->warningVolume = bvLow;
		break;
	    case 5:
		/* FALLTHRU */
	    case 6:
		/* FALLTHRU */
	    case 7:
		/* FALLTHRU */
	    case 8:
		screen->warningVolume = bvHigh;
		break;
	    default:
		screen->warningVolume = bvOff;
		break;
	    }
	    TRACE(("...warningVolume %d\n", screen->warningVolume));
	    ResetState(sp);
	    break;

	case CASE_DECSMBV:
	    TRACE(("CASE_DECSMBV\n"));
	    switch (zero_if_default(0)) {
	    case 2:
		/* FALLTHRU */
	    case 3:
		/* FALLTHRU */
	    case 4:
		screen->marginVolume = bvLow;
		break;
	    case 0:
		/* FALLTHRU */
	    case 5:
		/* FALLTHRU */
	    case 6:
		/* FALLTHRU */
	    case 7:
		/* FALLTHRU */
	    case 8:
		screen->marginVolume = bvHigh;
		break;
	    default:
		screen->marginVolume = bvOff;
		break;
	    }
	    TRACE(("...marginVolume %d\n", screen->marginVolume));
	    ResetState(sp);
	    break;
	}
	if (sp->parsestate == sp->groundtable)
	    sp->lastchar = thischar;
    } while (0);

#if OPT_WIDE_CHARS
    screen->utf8_inparse = (Boolean) ((screen->utf8_mode != uFalse)
				      && (sp->parsestate != sos_table));
#endif

    return True;
}

static void
VTparse(XtermWidget xw)
{
    /* We longjmp back to this point in VTReset() */
    (void) setjmp(vtjmpbuf);
    init_parser(xw, &myState);

    do {
    } while (doparsing(xw, doinput(), &myState));
}

static Char *v_buffer;		/* pointer to physical buffer */
static Char *v_bufstr = NULL;	/* beginning of area to write */
static Char *v_bufptr;		/* end of area to write */
static Char *v_bufend;		/* end of physical buffer */

/* Write data to the pty as typed by the user, pasted with the mouse,
   or generated by us in response to a query ESC sequence. */

void
v_write(int f, const Char *data, unsigned len)
{
    TRACE2(("v_write(%d:%s)\n", len, visibleChars(data, len)));
    if (v_bufstr == NULL) {
	if (len > 0) {
	    v_buffer = (Char *) XtMalloc((Cardinal) len);
	    v_bufstr = v_buffer;
	    v_bufptr = v_buffer;
	    v_bufend = v_buffer + len;
	}
	if (v_bufstr == NULL) {
	    return;
	}
    }
    if_DEBUG({
	fprintf(stderr, "v_write called with %u bytes (%ld left over)",
		len, (long) (v_bufptr - v_bufstr));
	if (len > 1 && len < 10)
	    fprintf(stderr, " \"%.*s\"", len, (const char *) data);
	fprintf(stderr, "\n");
    });

#ifdef VMS
    if ((1 << f) != pty_mask) {
	tt_write((const char *) data, len);
	return;
    }
#else /* VMS */
    if (!FD_ISSET(f, &pty_mask)) {
	IGNORE_RC(write(f, (const char *) data, (size_t) len));
	return;
    }
#endif /* VMS */

    /*
     * Append to the block we already have.
     * Always doing this simplifies the code, and
     * isn't too bad, either.  If this is a short
     * block, it isn't too expensive, and if this is
     * a long block, we won't be able to write it all
     * anyway.
     */

    if (len > 0) {
#if OPT_DABBREV
	TScreenOf(term)->dabbrev_working = False;	/* break dabbrev sequence */
#endif
	if (v_bufend < v_bufptr + len) {	/* we've run out of room */
	    if (v_bufstr != v_buffer) {
		/* there is unused space, move everything down */
		/* possibly overlapping memmove here */
		if_DEBUG({
		    fprintf(stderr, "moving data down %ld\n",
			    (long) (v_bufstr - v_buffer));
		});
		memmove(v_buffer, v_bufstr, (size_t) (v_bufptr - v_bufstr));
		v_bufptr -= v_bufstr - v_buffer;
		v_bufstr = v_buffer;
	    }
	    if (v_bufend < v_bufptr + len) {
		/* still won't fit: get more space */
		/* Don't use XtRealloc because an error is not fatal. */
		unsigned size = (unsigned) (v_bufptr - v_buffer);
		v_buffer = TypeRealloc(Char, size + len, v_buffer);
		if (v_buffer) {
		    if_DEBUG({
			fprintf(stderr, "expanded buffer to %u\n",
				size + len);
		    });
		    v_bufstr = v_buffer;
		    v_bufptr = v_buffer + size;
		    v_bufend = v_bufptr + len;
		} else {
		    /* no memory: ignore entire write request */
		    xtermWarning("cannot allocate buffer space\n");
		    v_buffer = v_bufstr;	/* restore clobbered pointer */
		}
	    }
	}
	if (v_bufend >= v_bufptr + len) {
	    /* new stuff will fit */
	    memmove(v_bufptr, data, (size_t) len);
	    v_bufptr += len;
	}
    }

    /*
     * Write out as much of the buffer as we can.
     * Be careful not to overflow the pty's input silo.
     * We are conservative here and only write
     * a small amount at a time.
     *
     * If we can't push all the data into the pty yet, we expect write
     * to return a non-negative number less than the length requested
     * (if some data written) or -1 and set errno to EAGAIN,
     * EWOULDBLOCK, or EINTR (if no data written).
     *
     * (Not all systems do this, sigh, so the code is actually
     * a little more forgiving.)
     */

#define MAX_PTY_WRITE 128	/* 1/2 POSIX minimum MAX_INPUT */

    if (v_bufptr > v_bufstr) {
	int riten;

#ifdef VMS
	riten = tt_write(v_bufstr,
			 ((v_bufptr - v_bufstr <= VMS_TERM_BUFFER_SIZE)
			  ? v_bufptr - v_bufstr
			  : VMS_TERM_BUFFER_SIZE));
	if (riten == 0)
	    return (riten);
#else /* VMS */
	riten = (int) write(f, v_bufstr,
			    (size_t) ((v_bufptr - v_bufstr <= MAX_PTY_WRITE)
				      ? v_bufptr - v_bufstr
				      : MAX_PTY_WRITE));
	if (riten < 0)
#endif /* VMS */
	{
	    if_DEBUG({
		perror("write");
	    });
	    riten = 0;
	}
	if_DEBUG({
	    fprintf(stderr, "write called with %ld, wrote %d\n",
		    ((long) ((v_bufptr - v_bufstr) <= MAX_PTY_WRITE)
		     ? (long) (v_bufptr - v_bufstr)
		     : MAX_PTY_WRITE),
		    riten);
	});
	v_bufstr += riten;
	if (v_bufstr >= v_bufptr)	/* we wrote it all */
	    v_bufstr = v_bufptr = v_buffer;
    }

    /*
     * If we have lots of unused memory allocated, return it
     */
    if (v_bufend - v_bufptr > 1024) {	/* arbitrary hysteresis */
	/* save pointers across realloc */
	int start = (int) (v_bufstr - v_buffer);
	int size = (int) (v_bufptr - v_buffer);
	unsigned allocsize = (unsigned) (size ? size : 1);

	v_buffer = TypeRealloc(Char, allocsize, v_buffer);
	if (v_buffer) {
	    v_bufstr = v_buffer + start;
	    v_bufptr = v_buffer + size;
	    v_bufend = v_buffer + allocsize;
	    if_DEBUG({
		fprintf(stderr, "shrunk buffer to %u\n", allocsize);
	    });
	} else {
	    /* should we print a warning if couldn't return memory? */
	    v_buffer = v_bufstr - start;	/* restore clobbered pointer */
	}
    }
}

static void
updateCursor(TScreen *screen)
{
    if (screen->cursor_set != screen->cursor_state) {
	if (screen->cursor_set)
	    ShowCursor();
	else
	    HideCursor();
    }
}

#if OPT_BLINK_CURS || OPT_BLINK_TEXT
static void
reallyStopBlinking(TScreen *screen)
{
    if (screen->cursor_state == BLINKED_OFF) {
	/* force cursor to display if it is enabled */
	screen->cursor_state = !screen->cursor_set;
	updateCursor(screen);
	xevents();
    }
}
#endif

#ifdef VMS
#define	ptymask()	(v_bufptr > v_bufstr ? pty_mask : 0)

static void
in_put(XtermWidget xw)
{
    static PtySelect select_mask;
    static PtySelect write_mask;
    int update = VTbuffer->update;
    int size;

    int status;
    Dimension replyWidth, replyHeight;
    XtGeometryResult stat;

    TScreen *screen = TScreenOf(xw);
    char *cp;
    int i;

    select_mask = pty_mask;	/* force initial read */
    for (;;) {

	/* if the terminal changed size, resize the widget */
	if (tt_changed) {
	    tt_changed = False;

	    stat = REQ_RESIZE((Widget) xw,
			      ((Dimension) FontWidth(screen)
			       * (tt_width)
			       + 2 * screen->border
			       + screen->fullVwin.sb_info.width),
			      ((Dimension) FontHeight(screen)
			       * (tt_length)
			       + 2 * screen->border),
			      &replyWidth, &replyHeight);

	    if (stat == XtGeometryYes || stat == XtGeometryDone) {
		xw->core.width = replyWidth;
		xw->core.height = replyHeight;

		ScreenResize(xw, replyWidth, replyHeight, &xw->flags);
	    }
	    repairSizeHints();
	}

	if (screen->eventMode == NORMAL
	    && readPtyData(xw, &select_mask, VTbuffer)) {
	    if (screen->scrollWidget
		&& screen->scrollttyoutput
		&& screen->topline < 0)
		/* Scroll to bottom */
		WindowScroll(xw, 0, False);
	    break;
	}
	if (screen->scroll_amt)
	    FlushScroll(xw);
	if (screen->cursor_set && CursorMoved(screen)) {
	    if (screen->cursor_state)
		HideCursor();
	    ShowCursor();
#if OPT_I18N_SUPPORT && OPT_INPUT_METHOD
	    PreeditPosition(xw);
#endif
	} else {
	    updateCursor(screen);
	}

	if (QLength(screen->display)) {
	    select_mask = X_mask;
	} else {
	    write_mask = ptymask();
	    XFlush(screen->display);
	    select_mask = Select_mask;
	    if (screen->eventMode != NORMAL)
		select_mask = X_mask;
	}
	if (write_mask & ptymask()) {
	    v_write(screen->respond, 0, 0);	/* flush buffer */
	}

	if (select_mask & X_mask) {
	    xevents();
	    if (VTbuffer->update != update)
		break;
	}
    }
}
#else /* VMS */

static void
in_put(XtermWidget xw)
{
    static PtySelect select_mask;
    static PtySelect write_mask;

    TScreen *screen = TScreenOf(xw);
    int i;
    int update = VTbuffer->update;
#if OPT_DOUBLE_BUFFER
    int should_wait = 1;
#endif

    static struct timeval select_timeout;

#if OPT_BLINK_CURS
    /*
     * Compute the timeout for the blinking cursor to be much smaller than
     * the "on" or "off" interval.
     */
    int tick = ((screen->blink_on < screen->blink_off)
		? screen->blink_on
		: screen->blink_off);
    tick *= (1000 / 8);		/* 1000 for msec/usec, 8 for "much" smaller */
    if (tick < 1)
	tick = 1;
#endif

    for (;;) {
	int size;
	int time_select;

	if (screen->eventMode == NORMAL
	    && (size = readPtyData(xw, &select_mask, VTbuffer)) != 0) {
	    if (screen->scrollWidget
		&& screen->scrollttyoutput
		&& screen->topline < 0)
		WindowScroll(xw, 0, False);	/* Scroll to bottom */
	    /* stop speed reading at some point to look for X stuff */
	    TRACE(("VTbuffer uses %ld/%d\n",
		   (long) (VTbuffer->last - VTbuffer->buffer),
		   BUF_SIZE));
	    if ((VTbuffer->last - VTbuffer->buffer) > BUF_SIZE) {
		FD_CLR(screen->respond, &select_mask);
		break;
	    }
#if OPT_DOUBLE_BUFFER
	    if (should_wait) {
		/* wait 25 msec for potential extra data (avoids some bogus flickering) */
		/* that's only 40 FPS but hey, it's still lower than the input lag on some consoles! :) */
		usleep(25000);
		should_wait = 0;
	    }
	    select_timeout.tv_sec = 0;
	    i = Select(max_plus1, &select_mask, &write_mask, 0,
		       &select_timeout);
	    if (i > 0 && FD_ISSET(screen->respond, &select_mask))
		continue;
	    else
		break;
#elif defined(HAVE_SCHED_YIELD)
	    /*
	     * If we've read a full (small/fragment) buffer, let the operating
	     * system have a turn, and we'll resume reading until we've either
	     * read only a fragment of the buffer, or we've filled the large
	     * buffer (see above).  Doing this helps keep up with large bursts
	     * of output.
	     */
	    if (size == FRG_SIZE) {
		select_timeout.tv_sec = 0;
		i = Select(max_plus1, &select_mask, &write_mask, 0,
			   &select_timeout);
		if (i > 0 && FD_ISSET(screen->respond, &select_mask)) {
		    sched_yield();
		} else
		    break;
	    } else {
		break;
	    }
#else
	    (void) size;	/* unused in this branch */
	    break;
#endif
	}
	/* update the screen */
	if (screen->scroll_amt)
	    FlushScroll(xw);
	if (screen->cursor_set && CursorMoved(screen)) {
	    if (screen->cursor_state)
		HideCursor();
	    ShowCursor();
#if OPT_I18N_SUPPORT && OPT_INPUT_METHOD
	    PreeditPosition(xw);
#endif
	} else {
	    updateCursor(screen);
	}

	XFlush(screen->display);	/* always flush writes before waiting */

	/* Update the masks and, unless X events are already in the queue,
	   wait for I/O to be possible. */
	XFD_COPYSET(&Select_mask, &select_mask);
	/* in selection mode xterm does not read pty */
	if (screen->eventMode != NORMAL)
	    FD_CLR(screen->respond, &select_mask);

	if (v_bufptr > v_bufstr) {
	    XFD_COPYSET(&pty_mask, &write_mask);
	} else
	    FD_ZERO(&write_mask);
	select_timeout.tv_sec = 0;
	time_select = 0;

	/*
	 * if there's either an XEvent or an XtTimeout pending, just take
	 * a quick peek, i.e. timeout from the select() immediately.  If
	 * there's nothing pending, let select() block a little while, but
	 * for a shorter interval than the arrow-style scrollbar timeout.
	 * The blocking is optional, because it tends to increase the load
	 * on the host.
	 */
	if (xtermAppPending()) {
	    select_timeout.tv_usec = 0;
	    time_select = 1;
	} else if (screen->awaitInput) {
	    select_timeout.tv_usec = 50000;
	    time_select = 1;
#if OPT_BLINK_CURS
	} else if ((screen->blink_timer != 0 &&
		    ((screen->select & FOCUS) || screen->always_highlight)) ||
		   (screen->cursor_state == BLINKED_OFF)) {
	    select_timeout.tv_usec = tick;
	    while (select_timeout.tv_usec > 1000000) {
		select_timeout.tv_usec -= 1000000;
		select_timeout.tv_sec++;
	    }
	    time_select = 1;
#endif
#if OPT_SESSION_MGT
	} else if (resource.sessionMgt) {
	    if (ice_fd >= 0)
		FD_SET(ice_fd, &select_mask);
#endif
	}
	if (need_cleanup)
	    NormalExit();
#if OPT_DOUBLE_BUFFER
	if (screen->needSwap) {
	    XdbeSwapInfo swap;
	    swap.swap_window = VWindow(screen);
	    swap.swap_action = XdbeCopied;
	    XdbeSwapBuffers(XtDisplay(term), &swap, 1);
	    XFlush(XtDisplay(xw));
	    screen->needSwap = 0;
	}
#endif
	i = Select(max_plus1, &select_mask, &write_mask, 0,
		   (time_select ? &select_timeout : 0));
	if (i < 0) {
	    if (errno != EINTR)
		SysError(ERROR_SELECT);
	    continue;
	}

	/* if there is room to write more data to the pty, go write more */
	if (FD_ISSET(screen->respond, &write_mask)) {
	    v_write(screen->respond, (Char *) 0, 0);	/* flush buffer */
	}

	/* if there are X events already in our queue, it
	   counts as being readable */
	if (xtermAppPending() ||
	    FD_ISSET(ConnectionNumber(screen->display), &select_mask)) {
	    xevents();
	    if (VTbuffer->update != update)	/* HandleInterpret */
		break;
	}

    }
}
#endif /* VMS */

static IChar
doinput(void)
{
    TScreen *screen = TScreenOf(term);

    while (!morePtyData(screen, VTbuffer))
	in_put(term);
    return nextPtyData(screen, VTbuffer);
}

#if OPT_I18N_SUPPORT && OPT_INPUT_METHOD
/*
 *  For OverTheSpot, client has to inform the position for XIM preedit.
 */
static void
PreeditPosition(XtermWidget xw)
{
    TInput *input = lookupTInput(xw, (Widget) xw);
    TScreen *screen = TScreenOf(xw);
    CLineData *ld;
    XPoint spot;
    XVaNestedList list;

    if (input && input->xic
	&& (ld = getLineData(screen, screen->cur_row)) != 0) {
	spot.x = (short) LineCursorX(screen, ld, screen->cur_col);
	spot.y = (short) (CursorY(screen, screen->cur_row) + xw->work.xim_fs_ascent);
	list = XVaCreateNestedList(0,
				   XNSpotLocation, &spot,
				   XNForeground, T_COLOR(screen, TEXT_FG),
				   XNBackground, T_COLOR(screen, TEXT_BG),
				   (void *) 0);
	XSetICValues(input->xic, XNPreeditAttributes, list, (void *) 0);
	XFree(list);
    }
}
#endif

static void
WrapLine(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);
    LineData *ld = getLineData(screen, screen->cur_row);

    if (ld != 0) {
	/* mark that we had to wrap this line */
	LineSetFlag(ld, LINEWRAPPED);
	if (screen->show_wrap_marks) {
	    ShowWrapMarks(xw, screen->cur_row, ld);
	}
	xtermAutoPrint(xw, '\n');
	xtermIndex(xw, 1);
	set_cur_col(screen, ScrnLeftMargin(xw));
    }
}

/*
 * process a string of characters according to the character set indicated
 * by charset.  worry about end of line conditions (wraparound if selected).
 */
void
dotext(XtermWidget xw,
       int charset,
       IChar *buf,		/* start of characters to process */
       Cardinal len)		/* end */
{
    TScreen *screen = TScreenOf(xw);
#if OPT_WIDE_CHARS
    Cardinal chars_chomped = 1;
    int next_col = screen->cur_col;
#else
    int next_col, this_col;	/* must be signed */
#endif
    Cardinal offset;
    int right = ScrnRightMargin(xw);

    /*
     * It is possible to use CUP, etc., to move outside margins.  In that
     * case, the right-margin is ineffective.
     */
    if (screen->cur_col > right) {
	right = screen->max_col;
    }
#if OPT_WIDE_CHARS
    if (screen->vt100_graphics)
#endif
	if (!xtermCharSetOut(xw, buf, buf + len, charset))
	    return;

    if_OPT_XMC_GLITCH(screen, {
	Cardinal n;
	if (charset != '?') {
	    for (n = 0; n < len; n++) {
		if (buf[n] == XMC_GLITCH)
		    buf[n] = XMC_GLITCH + 1;
	    }
	}
    });

#if OPT_WIDE_CHARS
    for (offset = 0;
	 offset < len && (chars_chomped > 0 || screen->do_wrap);
	 offset += chars_chomped) {
	int width_available = right + 1 - screen->cur_col;
	int width_here = 0;
	Boolean force_wrap;
	Boolean need_wrap;
	Boolean did_wrap;
	int last_chomp = 0;
	chars_chomped = 0;

	do {
	    force_wrap = False;
	    need_wrap = False;
	    did_wrap = False;

	    if (screen->do_wrap) {
		screen->do_wrap = False;
		if ((xw->flags & WRAPAROUND)) {
		    WrapLine(xw);
		    width_available = right + 1 - screen->cur_col;
		    next_col = screen->cur_col;
		    did_wrap = True;
		}
	    }

	    /*
	     * This can happen with left/right margins...
	     */
	    if (width_available <= 0) {
		break;
	    }

	    /*
	     * Regarding the soft-hyphen aberration, see
	     * http://archives.miloush.net/michkap/archive/2006/09/02/736881.html
	     */
	    while (width_here <= width_available
		   && chars_chomped < (len - offset)) {
		Cardinal n = chars_chomped + offset;
		if (!screen->utf8_mode
		    || (screen->vt100_graphics && charset == '0')) {
		    last_chomp = 1;
		} else if (screen->c1_printable &&
			   buf[n] >= 0x80 &&
			   buf[n] <= 0xa0) {
		    last_chomp = 1;
		} else {
		    last_chomp = my_wcwidth((wchar_t) buf[n]);
		    if (last_chomp <= 0) {
			IChar ch = buf[n];
			Bool eat_it = (ch > 127);
			if (ch == 0xad) {
			    /*
			     * Only display soft-hyphen if it happens to be at
			     * the right-margin.  While that means that only
			     * the displayed character could be selected for
			     * pasting, a well-behaved application would never
			     * send this, anyway...
			     */
			    if (width_here < width_available - 1) {
				eat_it = True;
			    } else {
				last_chomp = 1;
				eat_it = False;
			    }
			    TRACE(("...will%s display soft-hyphen\n",
				   eat_it ? " not" : ""));
			}
			/*
			 * Supposedly we dealt with combining characters and
			 * control characters in doparse().  Anything left over
			 * is junk that we will not attempt to display.
			 */
			if (eat_it) {
			    TRACE(("...will not display U+%04X\n", ch));
			    --len;
			    while (n < len) {
				buf[n] = buf[n + 1];
				++n;
			    }
			    last_chomp = 0;
			    chars_chomped--;
			}
		    }
		}
		width_here += last_chomp;
		chars_chomped++;
	    }

	    if (width_here > width_available) {
		if (last_chomp > right + 1) {
		    break;	/* give up - it is too big */
		} else if (chars_chomped-- == 0) {
		    /* This can happen with left/right margins... */
		    break;
		}
		width_here -= last_chomp;
		if (chars_chomped > 0) {
		    if (!(xw->flags & WRAPAROUND)) {
			buf[chars_chomped + offset - 1] = buf[len - 1];
		    } else {
			need_wrap = True;
		    }
		}
	    } else if (width_here == width_available) {
		need_wrap = True;
	    } else if (chars_chomped != (len - offset)) {
		need_wrap = True;
	    }

	    if (chars_chomped != 0 && next_col <= screen->max_col) {
		WriteText(xw, buf + offset, chars_chomped);
	    } else if (!did_wrap
		       && len > 0
		       && (xw->flags & WRAPAROUND)
		       && screen->cur_col > ScrnLeftMargin(xw)) {
		force_wrap = True;
		need_wrap = True;
	    }
	    next_col += width_here;
	    screen->do_wrap = need_wrap;
	} while (force_wrap);
    }

    /*
     * Remember that we wrote something to the screen, for use as a base of
     * combining characters.  The logic above may have called cursor-forward
     * or carriage-return operations which resets this flag, so we set it at
     * the very end.
     */
    screen->char_was_written = True;
#else /* ! OPT_WIDE_CHARS */

    for (offset = 0; offset < len; offset += (Cardinal) this_col) {
#if OPT_DEC_CHRSET
	CLineData *ld = getLineData(screen, screen->cur_row);
#endif

	int last_col = LineMaxCol(screen, ld);
	if (last_col > (right + 1))
	    last_col = right + 1;
	this_col = last_col - screen->cur_col + 1;
	if (this_col <= 1) {
	    if (screen->do_wrap) {
		screen->do_wrap = False;
		if ((xw->flags & WRAPAROUND)) {
		    WrapLine(xw);
		}
	    }
	    this_col = 1;
	}
	if (offset + (Cardinal) this_col > len) {
	    this_col = (int) (len - offset);
	}
	next_col = screen->cur_col + this_col;

	WriteText(xw, buf + offset, (unsigned) this_col);

	/*
	 * The call to WriteText updates screen->cur_col.
	 * If screen->cur_col is less than next_col, we must have
	 * hit the right margin - so set the do_wrap flag.
	 */
	screen->do_wrap = (Boolean) (screen->cur_col < next_col);
    }

#endif /* OPT_WIDE_CHARS */
}

#if OPT_WIDE_CHARS
unsigned
visual_width(const IChar *str, Cardinal len)
{
    /* returns the visual width of a string (doublewide characters count
       as 2, normalwide characters count as 1) */
    unsigned my_len = 0;
    while (len) {
	int ch = (int) *str++;
	if (isWide(ch))
	    my_len += 2;
	else
	    my_len++;
	len--;
    }
    return my_len;
}
#endif

#if HANDLE_STRUCT_NOTIFY
/* Flag icon name with "***" on window output when iconified.
 */
static void
HandleStructNotify(Widget w GCC_UNUSED,
		   XtPointer closure GCC_UNUSED,
		   XEvent *event,
		   Boolean *cont GCC_UNUSED)
{
    XtermWidget xw = term;

    switch (event->type) {
    case MapNotify:
	TRACE(("HandleStructNotify(MapNotify) %#lx\n", event->xmap.window));
	resetZIconBeep(xw);
	mapstate = !IsUnmapped;
	break;
    case UnmapNotify:
	TRACE(("HandleStructNotify(UnmapNotify) %#lx\n", event->xunmap.window));
	mapstate = IsUnmapped;
	break;
    case ConfigureNotify:
	if (event->xconfigure.window == XtWindow(toplevel)) {
#if !OPT_TOOLBAR
	    int height, width;

	    height = event->xconfigure.height;
	    width = event->xconfigure.width;
#endif
	    TRACE(("HandleStructNotify(ConfigureNotify) %#lx %d,%d %dx%d\n",
		   event->xconfigure.window,
		   event->xconfigure.y, event->xconfigure.x,
		   event->xconfigure.height, event->xconfigure.width));

#if OPT_TOOLBAR
	    /*
	     * The notification is for the top-level widget, but we care about
	     * vt100 (ignore the tek4014 window).
	     */
	    if (TScreenOf(xw)->Vshow) {
		VTwin *Vwin = WhichVWin(TScreenOf(xw));
		TbInfo *info = &(Vwin->tb_info);
		TbInfo save = *info;

		if (info->menu_bar) {
		    XtVaGetValues(info->menu_bar,
				  XtNheight, &info->menu_height,
				  XtNborderWidth, &info->menu_border,
				  (XtPointer) 0);

		    if (save.menu_height != info->menu_height
			|| save.menu_border != info->menu_border) {

			TRACE(("...menu_height %d\n", info->menu_height));
			TRACE(("...menu_border %d\n", info->menu_border));
			TRACE(("...had height  %d, border %d\n",
			       save.menu_height,
			       save.menu_border));

			/*
			 * Window manager still may be using the old values.
			 * Try to fool it.
			 */
			REQ_RESIZE((Widget) xw,
				   TScreenOf(xw)->fullVwin.fullwidth,
				   (Dimension) (info->menu_height
						- save.menu_height
						+ TScreenOf(xw)->fullVwin.fullheight),
				   NULL, NULL);
			repairSizeHints();
		    }
		}
	    }
#else
	    if (height != xw->hints.height || width != xw->hints.width)
		RequestResize(xw, height, width, False);
#endif /* OPT_TOOLBAR */
	}
	break;
    case ReparentNotify:
	TRACE(("HandleStructNotify(ReparentNotify) %#lx\n", event->xreparent.window));
	break;
    default:
	TRACE(("HandleStructNotify(event %s) %#lx\n",
	       visibleEventType(event->type),
	       event->xany.window));
	break;
    }
}
#endif /* HANDLE_STRUCT_NOTIFY */

#if OPT_BLINK_CURS
static void
SetCursorBlink(TScreen *screen, Bool enable)
{
    screen->cursor_blink = (Boolean) enable;
    if (DoStartBlinking(screen)) {
	StartBlinking(screen);
    } else {
	/* EMPTY */
#if OPT_BLINK_TEXT
	reallyStopBlinking(screen);
#else
	StopBlinking(screen);
#endif
    }
    update_cursorblink();
}

void
ToggleCursorBlink(TScreen *screen)
{
    SetCursorBlink(screen, (Bool) (!(screen->cursor_blink)));
}
#endif

/*
 * process ANSI modes set, reset
 */
static void
ansi_modes(XtermWidget xw, BitFunc func)
{
    int i;

    for (i = 0; i < nparam; ++i) {
	switch (GetParam(i)) {
	case 2:		/* KAM (if set, keyboard locked */
	    (*func) (&xw->keyboard.flags, MODE_KAM);
	    break;

	case 4:		/* IRM                          */
	    (*func) (&xw->flags, INSERT);
	    break;

	case 12:		/* SRM (if set, local echo      */
	    (*func) (&xw->keyboard.flags, MODE_SRM);
	    break;

	case 20:		/* LNM                          */
	    (*func) (&xw->flags, LINEFEED);
	    update_autolinefeed();
	    break;
	}
    }
}

#define IsSM() (func == bitset)

#define set_bool_mode(flag) \
	flag = (Boolean) IsSM()

static void
really_set_mousemode(XtermWidget xw,
		     Bool enabled,
		     XtermMouseModes mode)
{
    TScreenOf(xw)->send_mouse_pos = enabled ? mode : MOUSE_OFF;
    if (okSendMousePos(xw) != MOUSE_OFF)
	xtermShowPointer(xw, True);
}

#define set_mousemode(mode) really_set_mousemode(xw, IsSM(), mode)

#if OPT_READLINE
#define set_mouseflag(f)		\
	(IsSM()				\
	 ? SCREEN_FLAG_set(screen, f)	\
	 : SCREEN_FLAG_unset(screen, f))
#endif

/*
 * process DEC private modes set, reset
 */
static void
dpmodes(XtermWidget xw, BitFunc func)
{
    TScreen *screen = TScreenOf(xw);
    int i, j;
    unsigned myflags;

    TRACE(("changing %d DEC private modes\n", nparam));
    for (i = 0; i < nparam; ++i) {
	int code = GetParam(i);

	TRACE(("%s %d\n", IsSM()? "DECSET" : "DECRST", code));
	switch ((DECSET_codes) code) {
	case srm_DECCKM:
	    (*func) (&xw->keyboard.flags, MODE_DECCKM);
	    update_appcursor();
	    break;
	case srm_DECANM:	/* ANSI/VT52 mode      */
	    if (IsSM()) {	/* ANSI (VT100) */
		/*
		 * Setting DECANM should have no effect, since this function
		 * cannot be reached from vt52 mode.
		 */
		/* EMPTY */ ;
	    }
#if OPT_VT52_MODE
	    else if (screen->terminal_id >= 100) {	/* VT52 */
		TRACE(("DECANM terminal_id %d, vtXX_level %d\n",
		       screen->terminal_id,
		       screen->vtXX_level));
		screen->vtXX_level = 0;
		screen->vt52_save_curgl = screen->curgl;
		screen->vt52_save_curgr = screen->curgr;
		screen->vt52_save_curss = screen->curss;
		memmove(screen->vt52_save_gsets, screen->gsets, sizeof(screen->gsets));
		resetCharsets(screen);
		InitParams();	/* ignore the remaining params, if any */
	    }
#endif
	    break;
	case srm_DECCOLM:
	    if (screen->c132) {
		if (!(xw->flags & NOCLEAR_COLM))
		    ClearScreen(xw);
		CursorSet(screen, 0, 0, xw->flags);
		if ((j = IsSM()? 132 : 80) !=
		    ((xw->flags & IN132COLUMNS) ? 132 : 80) ||
		    j != MaxCols(screen))
		    RequestResize(xw, -1, j, True);
		(*func) (&xw->flags, IN132COLUMNS);
		if (xw->flags & IN132COLUMNS) {
		    UIntClr(xw->flags, LEFT_RIGHT);
		    reset_lr_margins(screen);
		}
	    }
	    break;
	case srm_DECSCLM:	/* (slow scroll)        */
	    if (IsSM()) {
		screen->jumpscroll = 0;
		if (screen->scroll_amt)
		    FlushScroll(xw);
	    } else
		screen->jumpscroll = 1;
	    (*func) (&xw->flags, SMOOTHSCROLL);
	    update_jumpscroll();
	    break;
	case srm_DECSCNM:
	    myflags = xw->flags;
	    (*func) (&xw->flags, REVERSE_VIDEO);
	    if ((xw->flags ^ myflags) & REVERSE_VIDEO)
		ReverseVideo(xw);
	    /* update_reversevideo done in RevVid */
	    break;

	case srm_DECOM:
	    (*func) (&xw->flags, ORIGIN);
	    CursorSet(screen, 0, 0, xw->flags);
	    break;

	case srm_DECAWM:
	    (*func) (&xw->flags, WRAPAROUND);
	    update_autowrap();
	    break;
	case srm_DECARM:
	    /* ignore autorepeat
	     * XAutoRepeatOn() and XAutoRepeatOff() can do this, but only
	     * for the whole display - not limited to a given window.
	     */
	    break;
	case srm_X10_MOUSE:	/* MIT bogus sequence           */
	    MotionOff(screen, xw);
	    set_mousemode(X10_MOUSE);
	    break;
#if OPT_TOOLBAR
	case srm_RXVT_TOOLBAR:
	    ShowToolbar(IsSM());
	    break;
#endif
#if OPT_BLINK_CURS
	case srm_ATT610_BLINK:	/* att610: Start/stop blinking cursor */
	    if (screen->cursor_blink_res) {
		set_bool_mode(screen->cursor_blink_esc);
		UpdateCursorBlink(screen);
	    }
	    break;
#endif
	case srm_DECPFF:	/* print form feed */
	    set_bool_mode(PrinterOf(screen).printer_formfeed);
	    break;
	case srm_DECPEX:	/* print extent */
	    set_bool_mode(PrinterOf(screen).printer_extent);
	    break;
	case srm_DECTCEM:	/* Show/hide cursor (VT200) */
	    set_bool_mode(screen->cursor_set);
	    break;
	case srm_RXVT_SCROLLBAR:
	    if (screen->fullVwin.sb_info.width != (IsSM()? ON : OFF))
		ToggleScrollBar(xw);
	    break;
#if OPT_SHIFT_FONTS
	case srm_RXVT_FONTSIZE:
	    set_bool_mode(xw->misc.shift_fonts);
	    break;
#endif
#if OPT_TEK4014
	case srm_DECTEK:
	    if (IsSM() && !(screen->inhibit & I_TEK)) {
		FlushLog(xw);
		TEK4014_ACTIVE(xw) = True;
		TRACE(("Tek4014 is now active...\n"));
		update_vttekmode();
	    }
	    break;
#endif
	case srm_132COLS:	/* 132 column mode              */
	    set_bool_mode(screen->c132);
	    update_allow132();
	    break;
	case srm_CURSES_HACK:
	    set_bool_mode(screen->curses);
	    update_cursesemul();
	    break;
	case srm_DECNRCM:	/* national charset (VT220) */
	    if (screen->vtXX_level >= 2) {
		if ((*func) (&xw->flags, NATIONAL)) {
		    modified_DECNRCM(xw);
		}
	    }
	    break;
	case srm_MARGIN_BELL:	/* margin bell                  */
	    set_bool_mode(screen->marginbell);
	    if (!screen->marginbell)
		screen->bellArmed = -1;
	    update_marginbell();
	    break;
	case srm_REVERSEWRAP:	/* reverse wraparound   */
	    (*func) (&xw->flags, REVERSEWRAP);
	    update_reversewrap();
	    break;
#ifdef ALLOWLOGGING
	case srm_ALLOWLOGGING:	/* logging              */
#ifdef ALLOWLOGFILEONOFF
	    /*
	     * if this feature is enabled, logging may be
	     * enabled and disabled via escape sequences.
	     */
	    if (IsSM())
		StartLog(xw);
	    else
		CloseLog(xw);
#else
	    Bell(xw, XkbBI_Info, 0);
	    Bell(xw, XkbBI_Info, 0);
#endif /* ALLOWLOGFILEONOFF */
	    break;
#endif
	case srm_OPT_ALTBUF_CURSOR:	/* alternate buffer & cursor */
	    if (!xw->misc.titeInhibit) {
		if (IsSM()) {
		    CursorSave(xw);
		    ToAlternate(xw, True);
		    ClearScreen(xw);
		} else {
		    FromAlternate(xw);
		    CursorRestore(xw);
		}
	    } else if (IsSM()) {
		do_ti_xtra_scroll(xw);
	    }
	    break;
	case srm_OPT_ALTBUF:
	    /* FALLTHRU */
	case srm_ALTBUF:	/* alternate buffer */
	    if (!xw->misc.titeInhibit) {
		if (IsSM()) {
		    ToAlternate(xw, False);
		} else {
		    if (screen->whichBuf
			&& (code == 1047))
			ClearScreen(xw);
		    FromAlternate(xw);
		}
	    } else if (IsSM()) {
		do_ti_xtra_scroll(xw);
	    }
	    break;
	case srm_DECNKM:
	    (*func) (&xw->keyboard.flags, MODE_DECKPAM);
	    update_appkeypad();
	    break;
	case srm_DECBKM:
	    /* back-arrow mapped to backspace or delete(D) */
	    (*func) (&xw->keyboard.flags, MODE_DECBKM);
	    TRACE(("DECSET DECBKM %s\n",
		   BtoS(xw->keyboard.flags & MODE_DECBKM)));
	    update_decbkm();
	    break;
	case srm_DECLRMM:
	    if (screen->vtXX_level >= 4) {	/* VT420 */
		(*func) (&xw->flags, LEFT_RIGHT);
		if (IsLeftRightMode(xw)) {
		    xterm_ResetDouble(xw);
		} else {
		    reset_lr_margins(screen);
		}
	    }
	    break;
#if OPT_SIXEL_GRAPHICS
	case srm_DECSDM:	/* sixel scrolling */
	    if (screen->terminal_id == 240 ||	/* FIXME: VT24x did not scroll sixel graphics */
		screen->terminal_id == 241 ||
		screen->terminal_id == 330 ||
		screen->terminal_id == 340 ||
		screen->terminal_id == 382) {
		(*func) (&xw->keyboard.flags, MODE_DECSDM);
		TRACE(("DECSET/DECRST DECSDM %s (resource default is %d)\n",
		       BtoS(xw->keyboard.flags & MODE_DECSDM),
		       TScreenOf(xw)->sixel_scrolling));
		update_decsdm();
	    }
	    break;
#endif
	case srm_DECNCSM:
	    if (screen->vtXX_level >= 5) {	/* VT510 */
		(*func) (&xw->flags, NOCLEAR_COLM);
	    }
	    break;
	case srm_VT200_MOUSE:	/* xterm bogus sequence         */
	    MotionOff(screen, xw);
	    set_mousemode(VT200_MOUSE);
	    break;
	case srm_VT200_HIGHLIGHT_MOUSE:	/* xterm sequence w/hilite tracking */
	    MotionOff(screen, xw);
	    set_mousemode(VT200_HIGHLIGHT_MOUSE);
	    break;
	case srm_BTN_EVENT_MOUSE:
	    MotionOff(screen, xw);
	    set_mousemode(BTN_EVENT_MOUSE);
	    break;
	case srm_ANY_EVENT_MOUSE:
	    set_mousemode(ANY_EVENT_MOUSE);
	    if (screen->send_mouse_pos == MOUSE_OFF) {
		MotionOff(screen, xw);
	    } else {
		MotionOn(screen, xw);
	    }
	    break;
#if OPT_FOCUS_EVENT
	case srm_FOCUS_EVENT_MOUSE:
	    set_bool_mode(screen->send_focus_pos);
	    break;
#endif
	case srm_EXT_MODE_MOUSE:
	    /* FALLTHRU */
	case srm_SGR_EXT_MODE_MOUSE:
	    /* FALLTHRU */
	case srm_URXVT_EXT_MODE_MOUSE:
	    /*
	     * Rather than choose an arbitrary precedence among the coordinate
	     * modes, they are mutually exclusive.  For consistency, a reset is
	     * only effective against the matching mode.
	     */
	    if (IsSM()) {
		screen->extend_coords = code;
	    } else if (screen->extend_coords == code) {
		screen->extend_coords = 0;
	    }
	    break;
	case srm_ALTERNATE_SCROLL:
	    set_bool_mode(screen->alternateScroll);
	    break;
	case srm_RXVT_SCROLL_TTY_OUTPUT:
	    set_bool_mode(screen->scrollttyoutput);
	    update_scrollttyoutput();
	    break;
	case srm_RXVT_SCROLL_TTY_KEYPRESS:
	    set_bool_mode(screen->scrollkey);
	    update_scrollkey();
	    break;
	case srm_EIGHT_BIT_META:
	    if (screen->eight_bit_meta != ebNever) {
		set_bool_mode(screen->eight_bit_meta);
	    }
	    break;
#if OPT_NUM_LOCK
	case srm_REAL_NUMLOCK:
	    set_bool_mode(xw->misc.real_NumLock);
	    update_num_lock();
	    break;
	case srm_META_SENDS_ESC:
	    set_bool_mode(screen->meta_sends_esc);
	    update_meta_esc();
	    break;
#endif
	case srm_DELETE_IS_DEL:
	    set_bool_mode(screen->delete_is_del);
	    update_delete_del();
	    break;
#if OPT_NUM_LOCK
	case srm_ALT_SENDS_ESC:
	    set_bool_mode(screen->alt_sends_esc);
	    update_alt_esc();
	    break;
#endif
	case srm_KEEP_SELECTION:
	    set_bool_mode(screen->keepSelection);
	    update_keepSelection();
	    break;
	case srm_SELECT_TO_CLIPBOARD:
	    set_bool_mode(screen->selectToClipboard);
	    update_selectToClipboard();
	    break;
	case srm_BELL_IS_URGENT:
	    set_bool_mode(screen->bellIsUrgent);
	    update_bellIsUrgent();
	    break;
	case srm_POP_ON_BELL:
	    set_bool_mode(screen->poponbell);
	    update_poponbell();
	    break;
	case srm_KEEP_CLIPBOARD:
	    set_bool_mode(screen->keepClipboard);
	    update_keepClipboard();
	    break;
	case srm_TITE_INHIBIT:
	    if (!xw->misc.titeInhibit) {
		if (IsSM())
		    CursorSave(xw);
		else
		    CursorRestore(xw);
	    }
	    break;
#if OPT_TCAP_FKEYS
	case srm_TCAP_FKEYS:
	    set_keyboard_type(xw, keyboardIsTermcap, IsSM());
	    break;
#endif
#if OPT_SUN_FUNC_KEYS
	case srm_SUN_FKEYS:
	    set_keyboard_type(xw, keyboardIsSun, IsSM());
	    break;
#endif
#if OPT_HP_FUNC_KEYS
	case srm_HP_FKEYS:
	    set_keyboard_type(xw, keyboardIsHP, IsSM());
	    break;
#endif
#if OPT_SCO_FUNC_KEYS
	case srm_SCO_FKEYS:
	    set_keyboard_type(xw, keyboardIsSCO, IsSM());
	    break;
#endif
	case srm_LEGACY_FKEYS:
	    set_keyboard_type(xw, keyboardIsLegacy, IsSM());
	    break;
#if OPT_SUNPC_KBD
	case srm_VT220_FKEYS:
	    set_keyboard_type(xw, keyboardIsVT220, IsSM());
	    break;
#endif
#if OPT_READLINE
	case srm_BUTTON1_MOVE_POINT:
	    set_mouseflag(click1_moves);
	    break;
	case srm_BUTTON2_MOVE_POINT:
	    set_mouseflag(paste_moves);
	    break;
	case srm_DBUTTON3_DELETE:
	    set_mouseflag(dclick3_deletes);
	    break;
	case srm_PASTE_IN_BRACKET:
	    set_mouseflag(paste_brackets);
	    break;
	case srm_PASTE_QUOTE:
	    set_mouseflag(paste_quotes);
	    break;
	case srm_PASTE_LITERAL_NL:
	    set_mouseflag(paste_literal_nl);
	    break;
#endif /* OPT_READLINE */
#if OPT_GRAPHICS
	case srm_PRIVATE_COLOR_REGISTERS:	/* private color registers for each graphic */
	    TRACE(("DECSET/DECRST PRIVATE_COLOR_REGISTERS to %s (resource default is %s)\n",
		   BtoS(screen->privatecolorregisters),
		   BtoS(TScreenOf(xw)->privatecolorregisters)));
	    set_bool_mode(screen->privatecolorregisters);
	    update_privatecolorregisters();
	    break;
#endif
#if OPT_SIXEL_GRAPHICS
	case srm_SIXEL_SCROLLS_RIGHT:	/* sixel scrolling moves cursor to right */
	    if (screen->terminal_id == 240 ||	/* FIXME: VT24x did not scroll sixel graphics */
		screen->terminal_id == 241 ||
		screen->terminal_id == 330 ||
		screen->terminal_id == 340 ||
		screen->terminal_id == 382) {
		set_bool_mode(screen->sixel_scrolls_right);
		TRACE(("DECSET/DECRST SIXEL_SCROLLS_RIGHT to %s (resource default is %s)\n",
		       BtoS(screen->sixel_scrolls_right),
		       BtoS(TScreenOf(xw)->sixel_scrolls_right)));
	    }
	    break;
#endif
	default:
	    TRACE(("DATA_ERROR: unknown private code %d\n", code));
	    break;
	}
    }
}

/*
 * process xterm private modes save
 */
static void
savemodes(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);
    int i;

    for (i = 0; i < nparam; i++) {
	int code = GetParam(i);

	TRACE(("savemodes %d\n", code));
	switch ((DECSET_codes) code) {
	case srm_DECCKM:
	    DoSM(DP_DECCKM, xw->keyboard.flags & MODE_DECCKM);
	    break;
	case srm_DECANM:	/* ANSI/VT52 mode      */
	    /* no effect */
	    break;
	case srm_DECCOLM:
	    if (screen->c132)
		DoSM(DP_DECCOLM, xw->flags & IN132COLUMNS);
	    break;
	case srm_DECSCLM:	/* (slow scroll)        */
	    DoSM(DP_DECSCLM, xw->flags & SMOOTHSCROLL);
	    break;
	case srm_DECSCNM:
	    DoSM(DP_DECSCNM, xw->flags & REVERSE_VIDEO);
	    break;
	case srm_DECOM:
	    DoSM(DP_DECOM, xw->flags & ORIGIN);
	    break;
	case srm_DECAWM:
	    DoSM(DP_DECAWM, xw->flags & WRAPAROUND);
	    break;
	case srm_DECARM:
	    /* ignore autorepeat */
	    break;
	case srm_X10_MOUSE:	/* mouse bogus sequence */
	    DoSM(DP_X_X10MSE, screen->send_mouse_pos);
	    break;
#if OPT_TOOLBAR
	case srm_RXVT_TOOLBAR:
	    DoSM(DP_TOOLBAR, resource.toolBar);
	    break;
#endif
#if OPT_BLINK_CURS
	case srm_ATT610_BLINK:	/* att610: Start/stop blinking cursor */
	    if (screen->cursor_blink_res) {
		DoSM(DP_CRS_BLINK, screen->cursor_blink_esc);
	    }
	    break;
#endif
	case srm_DECPFF:	/* print form feed */
	    DoSM(DP_PRN_FORMFEED, PrinterOf(screen).printer_formfeed);
	    break;
	case srm_DECPEX:	/* print extent */
	    DoSM(DP_PRN_EXTENT, PrinterOf(screen).printer_extent);
	    break;
	case srm_DECTCEM:	/* Show/hide cursor (VT200) */
	    DoSM(DP_CRS_VISIBLE, screen->cursor_set);
	    break;
	case srm_RXVT_SCROLLBAR:
	    DoSM(DP_RXVT_SCROLLBAR, (screen->fullVwin.sb_info.width != 0));
	    break;
#if OPT_SHIFT_FONTS
	case srm_RXVT_FONTSIZE:
	    DoSM(DP_RXVT_FONTSIZE, xw->misc.shift_fonts);
	    break;
#endif
#if OPT_TEK4014
	case srm_DECTEK:
	    DoSM(DP_DECTEK, TEK4014_ACTIVE(xw));
	    break;
#endif
	case srm_132COLS:	/* 132 column mode              */
	    DoSM(DP_X_DECCOLM, screen->c132);
	    break;
	case srm_CURSES_HACK:	/* curses hack                  */
	    DoSM(DP_X_MORE, screen->curses);
	    break;
	case srm_DECNRCM:	/* national charset (VT220) */
	    if (screen->vtXX_level >= 2) {
		DoSM(DP_DECNRCM, xw->flags & NATIONAL);
	    }
	    break;
	case srm_MARGIN_BELL:	/* margin bell                  */
	    DoSM(DP_X_MARGIN, screen->marginbell);
	    break;
	case srm_REVERSEWRAP:	/* reverse wraparound   */
	    DoSM(DP_X_REVWRAP, xw->flags & REVERSEWRAP);
	    break;
#ifdef ALLOWLOGGING
	case srm_ALLOWLOGGING:	/* logging              */
	    DoSM(DP_X_LOGGING, screen->logging);
	    break;
#endif
	case srm_OPT_ALTBUF_CURSOR:
	    /* FALLTHRU */
	case srm_OPT_ALTBUF:
	    /* FALLTHRU */
	case srm_ALTBUF:	/* alternate buffer             */
	    DoSM(DP_X_ALTSCRN, screen->whichBuf);
	    break;
	case srm_DECNKM:
	    DoSM(DP_DECKPAM, xw->keyboard.flags & MODE_DECKPAM);
	    break;
	case srm_DECBKM:	/* backarrow mapping */
	    DoSM(DP_DECBKM, xw->keyboard.flags & MODE_DECBKM);
	    break;
	case srm_DECLRMM:	/* left-right */
	    DoSM(DP_X_LRMM, LEFT_RIGHT);
	    break;
#if OPT_SIXEL_GRAPHICS
	case srm_DECSDM:	/* sixel scrolling */
	    DoSM(DP_DECSDM, xw->keyboard.flags & MODE_DECSDM);
	    update_decsdm();
	    break;
#endif
	case srm_DECNCSM:	/* noclear */
	    DoSM(DP_X_NCSM, NOCLEAR_COLM);
	    break;
	case srm_VT200_MOUSE:	/* mouse bogus sequence         */
	    /* FALLTHRU */
	case srm_VT200_HIGHLIGHT_MOUSE:
	    /* FALLTHRU */
	case srm_BTN_EVENT_MOUSE:
	    /* FALLTHRU */
	case srm_ANY_EVENT_MOUSE:
	    DoSM(DP_X_MOUSE, screen->send_mouse_pos);
	    break;
#if OPT_FOCUS_EVENT
	case srm_FOCUS_EVENT_MOUSE:
	    DoSM(DP_X_FOCUS, screen->send_focus_pos);
	    break;
#endif
	case srm_EXT_MODE_MOUSE:
	    /* FALLTHRU */
	case srm_SGR_EXT_MODE_MOUSE:
	    /* FALLTHRU */
	case srm_URXVT_EXT_MODE_MOUSE:
	    DoSM(DP_X_EXT_MOUSE, screen->extend_coords);
	    break;
	case srm_ALTERNATE_SCROLL:
	    DoSM(DP_ALTERNATE_SCROLL, screen->alternateScroll);
	    break;
	case srm_RXVT_SCROLL_TTY_OUTPUT:
	    DoSM(DP_RXVT_SCROLL_TTY_OUTPUT, screen->scrollttyoutput);
	    break;
	case srm_RXVT_SCROLL_TTY_KEYPRESS:
	    DoSM(DP_RXVT_SCROLL_TTY_KEYPRESS, screen->scrollkey);
	    break;
	case srm_EIGHT_BIT_META:
	    DoSM(DP_EIGHT_BIT_META, screen->eight_bit_meta);
	    break;
#if OPT_NUM_LOCK
	case srm_REAL_NUMLOCK:
	    DoSM(DP_REAL_NUMLOCK, xw->misc.real_NumLock);
	    break;
	case srm_META_SENDS_ESC:
	    DoSM(DP_META_SENDS_ESC, screen->meta_sends_esc);
	    break;
#endif
	case srm_DELETE_IS_DEL:
	    DoSM(DP_DELETE_IS_DEL, screen->delete_is_del);
	    break;
#if OPT_NUM_LOCK
	case srm_ALT_SENDS_ESC:
	    DoSM(DP_ALT_SENDS_ESC, screen->alt_sends_esc);
	    break;
#endif
	case srm_KEEP_SELECTION:
	    DoSM(DP_KEEP_SELECTION, screen->keepSelection);
	    break;
	case srm_SELECT_TO_CLIPBOARD:
	    DoSM(DP_SELECT_TO_CLIPBOARD, screen->selectToClipboard);
	    break;
	case srm_BELL_IS_URGENT:
	    DoSM(DP_BELL_IS_URGENT, screen->bellIsUrgent);
	    break;
	case srm_POP_ON_BELL:
	    DoSM(DP_POP_ON_BELL, screen->poponbell);
	    break;
	case srm_KEEP_CLIPBOARD:
	    DoSM(DP_KEEP_CLIPBOARD, screen->keepClipboard);
	    break;
#if OPT_TCAP_FKEYS
	case srm_TCAP_FKEYS:
	    /* FALLTHRU */
#endif
#if OPT_SUN_FUNC_KEYS
	case srm_SUN_FKEYS:
	    /* FALLTHRU */
#endif
#if OPT_HP_FUNC_KEYS
	case srm_HP_FKEYS:
	    /* FALLTHRU */
#endif
#if OPT_SCO_FUNC_KEYS
	case srm_SCO_FKEYS:
	    /* FALLTHRU */
#endif
#if OPT_SUNPC_KBD
	case srm_VT220_FKEYS:
	    /* FALLTHRU */
#endif
	case srm_LEGACY_FKEYS:
	    DoSM(DP_KEYBOARD_TYPE, xw->keyboard.type);
	    break;
	case srm_TITE_INHIBIT:
	    if (!xw->misc.titeInhibit) {
		CursorSave(xw);
	    }
	    break;
#if OPT_READLINE
	case srm_BUTTON1_MOVE_POINT:
	    SCREEN_FLAG_save(screen, click1_moves);
	    break;
	case srm_BUTTON2_MOVE_POINT:
	    SCREEN_FLAG_save(screen, paste_moves);
	    break;
	case srm_DBUTTON3_DELETE:
	    SCREEN_FLAG_save(screen, dclick3_deletes);
	    break;
	case srm_PASTE_IN_BRACKET:
	    SCREEN_FLAG_save(screen, paste_brackets);
	    break;
	case srm_PASTE_QUOTE:
	    SCREEN_FLAG_save(screen, paste_quotes);
	    break;
	case srm_PASTE_LITERAL_NL:
	    SCREEN_FLAG_save(screen, paste_literal_nl);
	    break;
#endif /* OPT_READLINE */
#if OPT_GRAPHICS
	case srm_PRIVATE_COLOR_REGISTERS:	/* private color registers for each graphic */
	    TRACE(("save PRIVATE_COLOR_REGISTERS %s\n",
		   BtoS(screen->privatecolorregisters)));
	    DoSM(DP_X_PRIVATE_COLOR_REGISTERS, screen->privatecolorregisters);
	    update_privatecolorregisters();
	    break;
#endif
#if OPT_SIXEL_GRAPHICS
	case srm_SIXEL_SCROLLS_RIGHT:
	    TRACE(("save SIXEL_SCROLLS_RIGHT %s\n",
		   BtoS(screen->sixel_scrolls_right)));
	    DoSM(DP_SIXEL_SCROLLS_RIGHT, screen->sixel_scrolls_right);
	    break;
#endif
	}
    }
}

/*
 * process xterm private modes restore
 */
static void
restoremodes(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);
    int i, j;

    for (i = 0; i < nparam; i++) {
	int code = GetParam(i);

	TRACE(("restoremodes %d\n", code));
	switch ((DECSET_codes) code) {
	case srm_DECCKM:
	    bitcpy(&xw->keyboard.flags,
		   screen->save_modes[DP_DECCKM], MODE_DECCKM);
	    update_appcursor();
	    break;
	case srm_DECANM:	/* ANSI/VT52 mode      */
	    /* no effect */
	    break;
	case srm_DECCOLM:
	    if (screen->c132) {
		if (!(xw->flags & NOCLEAR_COLM))
		    ClearScreen(xw);
		CursorSet(screen, 0, 0, xw->flags);
		if ((j = (screen->save_modes[DP_DECCOLM] & IN132COLUMNS)
		     ? 132 : 80) != ((xw->flags & IN132COLUMNS)
				     ? 132 : 80) || j != MaxCols(screen))
		    RequestResize(xw, -1, j, True);
		bitcpy(&xw->flags,
		       screen->save_modes[DP_DECCOLM],
		       IN132COLUMNS);
	    }
	    break;
	case srm_DECSCLM:	/* (slow scroll)        */
	    if (screen->save_modes[DP_DECSCLM] & SMOOTHSCROLL) {
		screen->jumpscroll = 0;
		if (screen->scroll_amt)
		    FlushScroll(xw);
	    } else
		screen->jumpscroll = 1;
	    bitcpy(&xw->flags, screen->save_modes[DP_DECSCLM], SMOOTHSCROLL);
	    update_jumpscroll();
	    break;
	case srm_DECSCNM:
	    if ((screen->save_modes[DP_DECSCNM] ^ xw->flags) & REVERSE_VIDEO) {
		bitcpy(&xw->flags, screen->save_modes[DP_DECSCNM], REVERSE_VIDEO);
		ReverseVideo(xw);
		/* update_reversevideo done in RevVid */
	    }
	    break;
	case srm_DECOM:
	    bitcpy(&xw->flags, screen->save_modes[DP_DECOM], ORIGIN);
	    CursorSet(screen, 0, 0, xw->flags);
	    break;

	case srm_DECAWM:
	    bitcpy(&xw->flags, screen->save_modes[DP_DECAWM], WRAPAROUND);
	    update_autowrap();
	    break;
	case srm_DECARM:
	    /* ignore autorepeat */
	    break;
	case srm_X10_MOUSE:	/* MIT bogus sequence           */
	    DoRM0(DP_X_X10MSE, screen->send_mouse_pos);
	    really_set_mousemode(xw,
				 screen->send_mouse_pos != MOUSE_OFF,
				 (XtermMouseModes) screen->send_mouse_pos);
	    break;
#if OPT_TOOLBAR
	case srm_RXVT_TOOLBAR:
	    DoRM(DP_TOOLBAR, resource.toolBar);
	    ShowToolbar(resource.toolBar);
	    break;
#endif
#if OPT_BLINK_CURS
	case srm_ATT610_BLINK:	/* Start/stop blinking cursor */
	    if (screen->cursor_blink_res) {
		DoRM(DP_CRS_BLINK, screen->cursor_blink_esc);
		UpdateCursorBlink(screen);
	    }
	    break;
#endif
	case srm_DECPFF:	/* print form feed */
	    DoRM(DP_PRN_FORMFEED, PrinterOf(screen).printer_formfeed);
	    break;
	case srm_DECPEX:	/* print extent */
	    DoRM(DP_PRN_EXTENT, PrinterOf(screen).printer_extent);
	    break;
	case srm_DECTCEM:	/* Show/hide cursor (VT200) */
	    DoRM(DP_CRS_VISIBLE, screen->cursor_set);
	    break;
	case srm_RXVT_SCROLLBAR:
	    if ((screen->fullVwin.sb_info.width != 0) !=
		screen->save_modes[DP_RXVT_SCROLLBAR]) {
		ToggleScrollBar(xw);
	    }
	    break;
#if OPT_SHIFT_FONTS
	case srm_RXVT_FONTSIZE:
	    DoRM(DP_RXVT_FONTSIZE, xw->misc.shift_fonts);
	    break;
#endif
#if OPT_TEK4014
	case srm_DECTEK:
	    if (!(screen->inhibit & I_TEK) &&
		(TEK4014_ACTIVE(xw) != (Boolean) screen->save_modes[DP_DECTEK])) {
		FlushLog(xw);
		TEK4014_ACTIVE(xw) = (Boolean) screen->save_modes[DP_DECTEK];
		update_vttekmode();
	    }
	    break;
#endif
	case srm_132COLS:	/* 132 column mode              */
	    DoRM(DP_X_DECCOLM, screen->c132);
	    update_allow132();
	    break;
	case srm_CURSES_HACK:	/* curses hack                  */
	    DoRM(DP_X_MORE, screen->curses);
	    update_cursesemul();
	    break;
	case srm_DECNRCM:	/* national charset (VT220) */
	    if (screen->vtXX_level >= 2) {
		if (bitcpy(&xw->flags, screen->save_modes[DP_DECNRCM], NATIONAL))
		    modified_DECNRCM(xw);
	    }
	    break;
	case srm_MARGIN_BELL:	/* margin bell                  */
	    if ((DoRM(DP_X_MARGIN, screen->marginbell)) == 0)
		screen->bellArmed = -1;
	    update_marginbell();
	    break;
	case srm_REVERSEWRAP:	/* reverse wraparound   */
	    bitcpy(&xw->flags, screen->save_modes[DP_X_REVWRAP], REVERSEWRAP);
	    update_reversewrap();
	    break;
#ifdef ALLOWLOGGING
	case srm_ALLOWLOGGING:	/* logging              */
#ifdef ALLOWLOGFILEONOFF
	    if (screen->save_modes[DP_X_LOGGING])
		StartLog(xw);
	    else
		CloseLog(xw);
#endif /* ALLOWLOGFILEONOFF */
	    /* update_logging done by StartLog and CloseLog */
	    break;
#endif
	case srm_OPT_ALTBUF_CURSOR:	/* alternate buffer & cursor */
	    /* FALLTHRU */
	case srm_OPT_ALTBUF:
	    /* FALLTHRU */
	case srm_ALTBUF:	/* alternate buffer */
	    if (!xw->misc.titeInhibit) {
		if (screen->save_modes[DP_X_ALTSCRN])
		    ToAlternate(xw, False);
		else
		    FromAlternate(xw);
		/* update_altscreen done by ToAlt and FromAlt */
	    } else if (screen->save_modes[DP_X_ALTSCRN]) {
		do_ti_xtra_scroll(xw);
	    }
	    break;
	case srm_DECNKM:
	    bitcpy(&xw->flags, screen->save_modes[DP_DECKPAM], MODE_DECKPAM);
	    update_appkeypad();
	    break;
	case srm_DECBKM:	/* backarrow mapping */
	    bitcpy(&xw->flags, screen->save_modes[DP_DECBKM], MODE_DECBKM);
	    update_decbkm();
	    break;
	case srm_DECLRMM:	/* left-right */
	    bitcpy(&xw->flags, screen->save_modes[DP_X_LRMM], LEFT_RIGHT);
	    if (IsLeftRightMode(xw)) {
		xterm_ResetDouble(xw);
	    } else {
		reset_lr_margins(screen);
	    }
	    break;
#if OPT_SIXEL_GRAPHICS
	case srm_DECSDM:	/* sixel scrolling */
	    bitcpy(&xw->keyboard.flags, screen->save_modes[DP_DECSDM], MODE_DECSDM);
	    update_decsdm();
	    break;
#endif
	case srm_DECNCSM:	/* noclear */
	    bitcpy(&xw->flags, screen->save_modes[DP_X_NCSM], NOCLEAR_COLM);
	    break;
	case srm_VT200_MOUSE:	/* mouse bogus sequence         */
	    /* FALLTHRU */
	case srm_VT200_HIGHLIGHT_MOUSE:
	    /* FALLTHRU */
	case srm_BTN_EVENT_MOUSE:
	    /* FALLTHRU */
	case srm_ANY_EVENT_MOUSE:
	    DoRM0(DP_X_MOUSE, screen->send_mouse_pos);
	    really_set_mousemode(xw,
				 screen->send_mouse_pos != MOUSE_OFF,
				 (XtermMouseModes) screen->send_mouse_pos);
	    break;
#if OPT_FOCUS_EVENT
	case srm_FOCUS_EVENT_MOUSE:
	    DoRM(DP_X_FOCUS, screen->send_focus_pos);
	    break;
#endif
	case srm_EXT_MODE_MOUSE:
	    /* FALLTHRU */
	case srm_SGR_EXT_MODE_MOUSE:
	    /* FALLTHRU */
	case srm_URXVT_EXT_MODE_MOUSE:
	    DoRM(DP_X_EXT_MOUSE, screen->extend_coords);
	    break;
	case srm_TITE_INHIBIT:
	    if (!xw->misc.titeInhibit) {
		CursorRestore(xw);
	    }
	    break;
	case srm_ALTERNATE_SCROLL:
	    DoRM(DP_ALTERNATE_SCROLL, screen->alternateScroll);
	    break;
	case srm_RXVT_SCROLL_TTY_OUTPUT:
	    DoRM(DP_RXVT_SCROLL_TTY_OUTPUT, screen->scrollttyoutput);
	    update_scrollttyoutput();
	    break;
	case srm_RXVT_SCROLL_TTY_KEYPRESS:
	    DoRM(DP_RXVT_SCROLL_TTY_KEYPRESS, screen->scrollkey);
	    update_scrollkey();
	    break;
	case srm_EIGHT_BIT_META:
	    DoRM(DP_EIGHT_BIT_META, screen->eight_bit_meta);
	    break;
#if OPT_NUM_LOCK
	case srm_REAL_NUMLOCK:
	    DoRM(DP_REAL_NUMLOCK, xw->misc.real_NumLock);
	    update_num_lock();
	    break;
	case srm_META_SENDS_ESC:
	    DoRM(DP_META_SENDS_ESC, screen->meta_sends_esc);
	    update_meta_esc();
	    break;
#endif
	case srm_DELETE_IS_DEL:
	    DoRM(DP_DELETE_IS_DEL, screen->delete_is_del);
	    update_delete_del();
	    break;
#if OPT_NUM_LOCK
	case srm_ALT_SENDS_ESC:
	    DoRM(DP_ALT_SENDS_ESC, screen->alt_sends_esc);
	    update_alt_esc();
	    break;
#endif
	case srm_KEEP_SELECTION:
	    DoRM(DP_KEEP_SELECTION, screen->keepSelection);
	    update_keepSelection();
	    break;
	case srm_SELECT_TO_CLIPBOARD:
	    DoRM(DP_SELECT_TO_CLIPBOARD, screen->selectToClipboard);
	    update_selectToClipboard();
	    break;
	case srm_BELL_IS_URGENT:
	    DoRM(DP_BELL_IS_URGENT, screen->bellIsUrgent);
	    update_bellIsUrgent();
	    break;
	case srm_POP_ON_BELL:
	    DoRM(DP_POP_ON_BELL, screen->poponbell);
	    update_poponbell();
	    break;
	case srm_KEEP_CLIPBOARD:
	    DoRM(DP_KEEP_CLIPBOARD, screen->keepClipboard);
	    update_keepClipboard();
	    break;
#if OPT_TCAP_FKEYS
	case srm_TCAP_FKEYS:
	    /* FALLTHRU */
#endif
#if OPT_SUN_FUNC_KEYS
	case srm_SUN_FKEYS:
	    /* FALLTHRU */
#endif
#if OPT_HP_FUNC_KEYS
	case srm_HP_FKEYS:
	    /* FALLTHRU */
#endif
#if OPT_SCO_FUNC_KEYS
	case srm_SCO_FKEYS:
	    /* FALLTHRU */
#endif
#if OPT_SUNPC_KBD
	case srm_VT220_FKEYS:
	    /* FALLTHRU */
#endif
	case srm_LEGACY_FKEYS:
	    xw->keyboard.type = (xtermKeyboardType) screen->save_modes[DP_KEYBOARD_TYPE];
	    break;
#if OPT_READLINE
	case srm_BUTTON1_MOVE_POINT:
	    SCREEN_FLAG_restore(screen, click1_moves);
	    break;
	case srm_BUTTON2_MOVE_POINT:
	    SCREEN_FLAG_restore(screen, paste_moves);
	    break;
	case srm_DBUTTON3_DELETE:
	    SCREEN_FLAG_restore(screen, dclick3_deletes);
	    break;
	case srm_PASTE_IN_BRACKET:
	    SCREEN_FLAG_restore(screen, paste_brackets);
	    break;
	case srm_PASTE_QUOTE:
	    SCREEN_FLAG_restore(screen, paste_quotes);
	    break;
	case srm_PASTE_LITERAL_NL:
	    SCREEN_FLAG_restore(screen, paste_literal_nl);
	    break;
#endif /* OPT_READLINE */
#if OPT_GRAPHICS
	case srm_PRIVATE_COLOR_REGISTERS:	/* private color registers for each graphic */
	    TRACE(("restore PRIVATE_COLOR_REGISTERS before: %s\n",
		   BtoS(screen->privatecolorregisters)));
	    DoRM(DP_X_PRIVATE_COLOR_REGISTERS, screen->privatecolorregisters);
	    TRACE(("restore PRIVATE_COLOR_REGISTERS after: %s\n",
		   BtoS(screen->privatecolorregisters)));
	    update_privatecolorregisters();
	    break;
#endif
#if OPT_SIXEL_GRAPHICS
	case srm_SIXEL_SCROLLS_RIGHT:
	    TRACE(("restore SIXEL_SCROLLS_RIGHT before: %s\n",
		   BtoS(screen->sixel_scrolls_right)));
	    DoRM(DP_SIXEL_SCROLLS_RIGHT, screen->sixel_scrolls_right);
	    TRACE(("restore SIXEL_SCROLLS_RIGHT after: %s\n",
		   BtoS(screen->sixel_scrolls_right)));
	    break;
#endif
	}
    }
}

/*
 * Convert an XTextProperty to a string.
 *
 * This frees the data owned by the XTextProperty, and returns in its place the
 * string, which must be freed by the caller.
 */
static char *
property_to_string(XtermWidget xw, XTextProperty * text)
{
    TScreen *screen = TScreenOf(xw);
    Display *dpy = screen->display;
    char *result = 0;
    char **list;
    int length = 0;
    int rc;

    TRACE(("property_to_string value %p, encoding %s, format %d, nitems %ld\n",
	   text->value,
	   TraceAtomName(dpy, text->encoding),
	   text->format,
	   text->nitems));

#if OPT_WIDE_CHARS
    /*
     * We will use the XmbTextPropertyToTextList call to extract UTF-8 data.
     * The xtermUtf8ToTextList() call is used to convert UTF-8 explicitly to
     * ISO-8859-1.
     */
    if ((text->format != 8)
	|| IsTitleMode(xw, tmGetUtf8)
	|| (rc = xtermUtf8ToTextList(xw, text, &list, &length)) < 0)
#endif
	if ((rc = XmbTextPropertyToTextList(dpy, text, &list, &length)) < 0)
	    rc = XTextPropertyToStringList(text, &list, &length);

    if (rc >= 0) {
	int n, c, pass;
	size_t need = 0;

	for (pass = 0; pass < 2; ++pass) {
	    for (n = 0, need = 0; n < length; n++) {
		char *s = list[n];
		while ((c = *s++) != '\0') {
		    if (pass)
			result[need] = (char) c;
		    ++need;
		}
	    }
	    if (pass)
		result[need] = '\0';
	    else
		result = malloc(need + 1);
	    if (result == 0)
		break;
	}
	XFreeStringList(list);
    }
    if (text->value != 0)
	XFree(text->value);

    return result;
}

static char *
get_icon_label(XtermWidget xw)
{
    XTextProperty text;
    char *result = 0;

    if (XGetWMIconName(TScreenOf(xw)->display, VShellWindow(xw), &text)) {
	result = property_to_string(xw, &text);
    }
    return result;
}

static char *
get_window_label(XtermWidget xw)
{
    XTextProperty text;
    char *result = 0;

    if (XGetWMName(TScreenOf(xw)->display, VShellWindow(xw), &text)) {
	result = property_to_string(xw, &text);
    }
    return result;
}

/*
 * Report window label (icon or title) in dtterm protocol
 * ESC ] code label ESC backslash
 */
static void
report_win_label(XtermWidget xw,
		 int code,
		 char *text)
{
    unparseputc(xw, ANSI_ESC);
    unparseputc(xw, ']');
    unparseputc(xw, code);

    if (text != 0) {
	int copy = IsTitleMode(xw, tmGetBase16);
	if (copy) {
	    TRACE(("Encoding hex:%s\n", text));
	    text = x_encode_hex(text);
	}
	unparseputs(xw, text);
	if (copy)
	    free(text);
    }

    unparseputc(xw, ANSI_ESC);
    unparseputc(xw, '\\');	/* should be ST */
    unparse_end(xw);
}

/*
 * Window operations (from CDE dtterm description, as well as extensions).
 * See also "allowWindowOps" resource.
 */
static void
window_ops(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);
    XWindowChanges values;
    XWindowAttributes win_attrs;
#if OPT_MAXIMIZE
    unsigned root_width;
    unsigned root_height;
#endif
    int code = zero_if_default(0);
    char *label;

    TRACE(("window_ops %d\n", code));
    switch (code) {
    case ewRestoreWin:		/* Restore (de-iconify) window */
	if (AllowWindowOps(xw, ewRestoreWin)) {
	    TRACE(("...de-iconify window\n"));
	    XMapWindow(screen->display,
		       VShellWindow(xw));
	}
	break;

    case ewMinimizeWin:	/* Minimize (iconify) window */
	if (AllowWindowOps(xw, ewMinimizeWin)) {
	    TRACE(("...iconify window\n"));
	    XIconifyWindow(screen->display,
			   VShellWindow(xw),
			   DefaultScreen(screen->display));
	}
	break;

    case ewSetWinPosition:	/* Move the window to the given position */
	if (AllowWindowOps(xw, ewSetWinPosition)) {
	    unsigned value_mask;

	    values.x = zero_if_default(1);
	    values.y = zero_if_default(2);
	    TRACE(("...move window to %d,%d\n", values.x, values.y));
	    value_mask = (CWX | CWY);
	    XReconfigureWMWindow(screen->display,
				 VShellWindow(xw),
				 DefaultScreen(screen->display),
				 value_mask,
				 &values);
	}
	break;

    case ewSetWinSizePixels:	/* Resize the window to given size in pixels */
	if (AllowWindowOps(xw, ewSetWinSizePixels)) {
	    RequestResize(xw, optional_param(1), optional_param(2), False);
	}
	break;

    case ewRaiseWin:		/* Raise the window to the front of the stack */
	if (AllowWindowOps(xw, ewRaiseWin)) {
	    TRACE(("...raise window\n"));
	    XRaiseWindow(screen->display, VShellWindow(xw));
	}
	break;

    case ewLowerWin:		/* Lower the window to the bottom of the stack */
	if (AllowWindowOps(xw, ewLowerWin)) {
	    TRACE(("...lower window\n"));
	    XLowerWindow(screen->display, VShellWindow(xw));
	}
	break;

    case ewRefreshWin:		/* Refresh the window */
	if (AllowWindowOps(xw, ewRefreshWin)) {
	    TRACE(("...redraw window\n"));
	    Redraw();
	}
	break;

    case ewSetWinSizeChars:	/* Resize the text-area, in characters */
	if (AllowWindowOps(xw, ewSetWinSizeChars)) {
	    RequestResize(xw, optional_param(1), optional_param(2), True);
	}
	break;

#if OPT_MAXIMIZE
    case ewMaximizeWin:	/* Maximize or restore */
	if (AllowWindowOps(xw, ewMaximizeWin)) {
	    RequestMaximize(xw, zero_if_default(1));
	}
	break;
    case ewFullscreenWin:	/* Fullscreen or restore */
	if (AllowWindowOps(xw, ewFullscreenWin)) {
	    FullScreen(xw, zero_if_default(1));
	}
	break;
#endif

    case ewGetWinState:	/* Report the window's state */
	if (AllowWindowOps(xw, ewGetWinState)) {
	    TRACE(("...get window attributes\n"));
	    xtermGetWinAttrs(screen->display,
			     VWindow(screen),
			     &win_attrs);
	    init_reply(ANSI_CSI);
	    reply.a_pintro = 0;
	    reply.a_nparam = 1;
	    reply.a_param[0] = (ParmType) ((win_attrs.map_state == IsViewable)
					   ? 1
					   : 2);
	    reply.a_inters = 0;
	    reply.a_final = 't';
	    unparseseq(xw, &reply);
	}
	break;

    case ewGetWinPosition:	/* Report the window's position */
	if (AllowWindowOps(xw, ewGetWinPosition)) {
	    TRACE(("...get window position\n"));
	    xtermGetWinAttrs(screen->display,
			     WMFrameWindow(xw),
			     &win_attrs);
	    init_reply(ANSI_CSI);
	    reply.a_pintro = 0;
	    reply.a_nparam = 3;
	    reply.a_param[0] = 3;
	    reply.a_param[1] = (ParmType) win_attrs.x;
	    reply.a_param[2] = (ParmType) win_attrs.y;
	    reply.a_inters = 0;
	    reply.a_final = 't';
	    unparseseq(xw, &reply);
	}
	break;

    case ewGetWinSizePixels:	/* Report the window's size in pixels */
	if (AllowWindowOps(xw, ewGetWinSizePixels)) {
	    TRACE(("...get window size in pixels\n"));
	    init_reply(ANSI_CSI);
	    reply.a_pintro = 0;
	    reply.a_nparam = 3;
	    reply.a_param[0] = 4;
	    reply.a_param[1] = (ParmType) Height(screen);
	    reply.a_param[2] = (ParmType) Width(screen);
	    reply.a_inters = 0;
	    reply.a_final = 't';
	    unparseseq(xw, &reply);
	}
	break;

    case ewGetWinSizeChars:	/* Report the text's size in characters */
	if (AllowWindowOps(xw, ewGetWinSizeChars)) {
	    TRACE(("...get window size in characters\n"));
	    init_reply(ANSI_CSI);
	    reply.a_pintro = 0;
	    reply.a_nparam = 3;
	    reply.a_param[0] = 8;
	    reply.a_param[1] = (ParmType) MaxRows(screen);
	    reply.a_param[2] = (ParmType) MaxCols(screen);
	    reply.a_inters = 0;
	    reply.a_final = 't';
	    unparseseq(xw, &reply);
	}
	break;

#if OPT_MAXIMIZE
    case ewGetScreenSizeChars:	/* Report the screen's size, in characters */
	if (AllowWindowOps(xw, ewGetScreenSizeChars)) {
	    TRACE(("...get screen size in characters\n"));
	    TRACE(("...using font size %dx%d\n",
		   FontHeight(screen),
		   FontWidth(screen)));
	    (void) QueryMaximize(xw, &root_width, &root_height);
	    init_reply(ANSI_CSI);
	    reply.a_pintro = 0;
	    reply.a_nparam = 3;
	    reply.a_param[0] = 9;
	    reply.a_param[1] = (ParmType) (root_height
					   / (unsigned) FontHeight(screen));
	    reply.a_param[2] = (ParmType) (root_width
					   / (unsigned) FontWidth(screen));
	    reply.a_inters = 0;
	    reply.a_final = 't';
	    unparseseq(xw, &reply);
	}
	break;
#endif

    case ewGetIconTitle:	/* Report the icon's label */
	if (AllowWindowOps(xw, ewGetIconTitle)) {
	    TRACE(("...get icon's label\n"));
	    report_win_label(xw, 'L', label = get_icon_label(xw));
	    free(label);
	}
	break;

    case ewGetWinTitle:	/* Report the window's title */
	if (AllowWindowOps(xw, ewGetWinTitle)) {
	    TRACE(("...get window's label\n"));
	    report_win_label(xw, 'l', label = get_window_label(xw));
	    free(label);
	}
	break;

    case ewPushTitle:		/* save the window's title(s) on stack */
	if (AllowWindowOps(xw, ewPushTitle)) {
	    SaveTitle *last = screen->save_title;
	    SaveTitle *item = TypeCalloc(SaveTitle);

	    TRACE(("...push title onto stack\n"));
	    if (item != 0) {
		switch (zero_if_default(1)) {
		case 0:
		    item->iconName = get_icon_label(xw);
		    item->windowName = get_window_label(xw);
		    break;
		case 1:
		    item->iconName = get_icon_label(xw);
		    break;
		case 2:
		    item->windowName = get_window_label(xw);
		    break;
		}
		item->next = last;
		if (item->iconName == 0) {
		    item->iconName = ((last == 0)
				      ? get_icon_label(xw)
				      : x_strdup(last->iconName));
		}
		if (item->windowName == 0) {
		    item->windowName = ((last == 0)
					? get_window_label(xw)
					: x_strdup(last->windowName));
		}
		screen->save_title = item;
	    }
	}
	break;

    case ewPopTitle:		/* restore the window's title(s) from stack */
	if (AllowWindowOps(xw, ewPopTitle)) {
	    SaveTitle *item = screen->save_title;

	    TRACE(("...pop title off stack\n"));
	    if (item != 0) {
		switch (zero_if_default(1)) {
		case 0:
		    ChangeIconName(xw, item->iconName);
		    ChangeTitle(xw, item->windowName);
		    break;
		case 1:
		    ChangeIconName(xw, item->iconName);
		    break;
		case 2:
		    ChangeTitle(xw, item->windowName);
		    break;
		}
		screen->save_title = item->next;
		free(item->iconName);
		free(item->windowName);
		free(item);
	    }
	}
	break;

    default:			/* DECSLPP (24, 25, 36, 48, 72, 144) */
	if (AllowWindowOps(xw, ewSetWinLines)) {
	    if (code >= 24)
		RequestResize(xw, code, -1, True);
	}
	break;
    }
}

/*
 * set a bit in a word given a pointer to the word and a mask.
 */
static int
bitset(unsigned *p, unsigned mask)
{
    unsigned before = *p;
    *p |= mask;
    return (before != *p);
}

/*
 * clear a bit in a word given a pointer to the word and a mask.
 */
static int
bitclr(unsigned *p, unsigned mask)
{
    unsigned before = *p;
    *p &= ~mask;
    return (before != *p);
}

/*
 * Copy bits from one word to another, given a mask
 */
static int
bitcpy(unsigned *p, unsigned q, unsigned mask)
{
    unsigned before = *p;
    bitclr(p, mask);
    bitset(p, q & mask);
    return (before != *p);
}

void
unparseputc1(XtermWidget xw, int c)
{
    if (c >= 0x80 && c <= 0x9F) {
	if (!TScreenOf(xw)->control_eight_bits) {
	    unparseputc(xw, A2E(ANSI_ESC));
	    c = A2E(c - 0x40);
	}
    }
    unparseputc(xw, c);
}

void
unparseseq(XtermWidget xw, ANSI *ap)
{
    int c;

    unparseputc1(xw, c = ap->a_type);
    if (c == ANSI_ESC
	|| c == ANSI_DCS
	|| c == ANSI_CSI
	|| c == ANSI_OSC
	|| c == ANSI_PM
	|| c == ANSI_APC
	|| c == ANSI_SS3) {
	int i;
	int inters;

	if (ap->a_pintro != 0)
	    unparseputc(xw, ap->a_pintro);
	for (i = 0; i < ap->a_nparam; ++i) {
	    if (i != 0) {
		if (ap->a_delim) {
		    unparseputs(xw, ap->a_delim);
		} else {
		    unparseputc(xw, ';');
		}
	    }
	    if (ap->a_radix[i]) {
		char temp[8];
		sprintf(temp, "%04X", ap->a_param[i] & 0xffff);
		unparseputs(xw, temp);
	    } else {
		unparseputn(xw, (unsigned int) ap->a_param[i]);
	    }
	}
	if ((inters = ap->a_inters) != 0) {
	    for (i = 3; i >= 0; --i) {
		c = CharOf(inters >> (8 * i));
		if (c != 0)
		    unparseputc(xw, c);
	    }
	}
	switch (ap->a_type) {
	case ANSI_DCS:
	    /* FALLTHRU */
	case ANSI_OSC:
	    /* FALLTHRU */
	case ANSI_PM:
	    /* FALLTHRU */
	case ANSI_APC:
	    unparseputc1(xw, ANSI_ST);
	    break;
	default:
	    unparseputc(xw, (char) ap->a_final);
	    break;
	}
    }
    unparse_end(xw);
}

void
unparseputn(XtermWidget xw, unsigned int n)
{
    unsigned int q;

    q = n / 10;
    if (q != 0)
	unparseputn(xw, q);
    unparseputc(xw, (char) ('0' + (n % 10)));
}

void
unparseputs(XtermWidget xw, const char *s)
{
    if (s != 0) {
	while (*s)
	    unparseputc(xw, *s++);
    }
}

void
unparseputc(XtermWidget xw, int c)
{
    TScreen *screen = TScreenOf(xw);
    IChar *buf = screen->unparse_bfr;
    unsigned len;

    if ((screen->unparse_len + 2) >= sizeof(screen->unparse_bfr) / sizeof(IChar))
	  unparse_end(xw);

    len = screen->unparse_len;

#if OPT_TCAP_QUERY
    /*
     * If we're returning a termcap string, it has to be translated since
     * a DCS must not contain any characters except for the normal 7-bit
     * printable ASCII (counting tab, carriage return, etc).  For now,
     * just use hexadecimal for the whole thing.
     */
    if (screen->tc_query_code >= 0) {
	char tmp[3];
	sprintf(tmp, "%02X", c & 0xFF);
	buf[len++] = CharOf(tmp[0]);
	buf[len++] = CharOf(tmp[1]);
    } else
#endif
    if ((buf[len++] = (IChar) c) == '\r' && (xw->flags & LINEFEED)) {
	buf[len++] = '\n';
    }

    screen->unparse_len = len;

    /* If send/receive mode is reset, we echo characters locally */
    if ((xw->keyboard.flags & MODE_SRM) == 0) {
	(void) doparsing(xw, (unsigned) c, &myState);
    }
}

void
unparse_end(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);

    if (screen->unparse_len) {
#ifdef VMS
	tt_write(screen->unparse_bfr, screen->unparse_len);
#else /* VMS */
	writePtyData(screen->respond, screen->unparse_bfr, screen->unparse_len);
#endif /* VMS */
	screen->unparse_len = 0;
    }
}

void
ToggleAlternate(XtermWidget xw)
{
    if (TScreenOf(xw)->whichBuf)
	FromAlternate(xw);
    else
	ToAlternate(xw, False);
}

static void
ToAlternate(XtermWidget xw, Bool clearFirst)
{
    TScreen *screen = TScreenOf(xw);

    if (screen->whichBuf == 0) {
	TRACE(("ToAlternate\n"));
	if (!screen->editBuf_index[1])
	    screen->editBuf_index[1] = allocScrnBuf(xw,
						    (unsigned) MaxRows(screen),
						    (unsigned) MaxCols(screen),
						    &screen->editBuf_data[1]);
	SwitchBufs(xw, 1, clearFirst);
#if OPT_SAVE_LINES
	screen->visbuf = screen->editBuf_index[screen->whichBuf];
#endif
	update_altscreen();
    }
}

static void
FromAlternate(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);

    if (screen->whichBuf != 0) {
	TRACE(("FromAlternate\n"));
	if (screen->scroll_amt)
	    FlushScroll(xw);
	SwitchBufs(xw, 0, False);
#if OPT_SAVE_LINES
	screen->visbuf = screen->editBuf_index[screen->whichBuf];
#endif
	update_altscreen();
    }
}

static void
SwitchBufs(XtermWidget xw, int toBuf, Bool clearFirst)
{
    TScreen *screen = TScreenOf(xw);
    int rows, top;

    screen->whichBuf = toBuf;
    if (screen->cursor_state)
	HideCursor();

    rows = MaxRows(screen);
    SwitchBufPtrs(screen, toBuf);

    if ((top = INX2ROW(screen, 0)) < rows) {
	if (screen->scroll_amt) {
	    FlushScroll(xw);
	}
#if OPT_DOUBLE_BUFFER
	XFillRectangle(screen->display,
		       VDrawable(screen),
		       ReverseGC(xw, screen),
		       (int) OriginX(screen),
		       (int) top * FontHeight(screen) + screen->border,
		       (unsigned) Width(screen),
		       (unsigned) ((rows - top) * FontHeight(screen)));
#else
	XClearArea(screen->display,
		   VWindow(screen),
		   (int) OriginX(screen),
		   (int) top * FontHeight(screen) + screen->border,
		   (unsigned) Width(screen),
		   (unsigned) ((rows - top) * FontHeight(screen)),
		   False);
#endif
	if (clearFirst) {
	    ClearBufRows(xw, top, rows);
	}
    }
    ScrnUpdate(xw, 0, 0, rows, MaxCols(screen), False);
}

Bool
CheckBufPtrs(TScreen *screen)
{
    return (screen->visbuf != 0
#if OPT_SAVE_LINES
	    && screen->editBuf_index[0] != 0
#endif
	    && screen->editBuf_index[1] != 0);
}

/*
 * Swap buffer line pointers between alternate and regular screens.
 */
void
SwitchBufPtrs(TScreen *screen, int toBuf GCC_UNUSED)
{
    if (CheckBufPtrs(screen)) {
#if OPT_SAVE_LINES
	screen->visbuf = screen->editBuf_index[toBuf];
#else
	size_t len = ScrnPointers(screen, (size_t) MaxRows(screen));

	memcpy(screen->save_ptr, screen->visbuf, len);
	memcpy(screen->visbuf, screen->editBuf_index[1], len);
	memcpy(screen->editBuf_index[1], screen->save_ptr, len);
#endif
    }
}

void
VTRun(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);

    TRACE(("VTRun ...\n"));

    if (!screen->Vshow) {
	set_vt_visibility(True);
    }
    update_vttekmode();
    update_vtshow();
    update_tekshow();
    set_vthide_sensitivity();

    ScrnAllocBuf(xw);

    screen->cursor_state = OFF;
    screen->cursor_set = ON;
#if OPT_BLINK_CURS
    if (DoStartBlinking(screen))
	StartBlinking(screen);
#endif

#if OPT_TEK4014
    if (Tpushb > Tpushback) {
	fillPtyData(xw, VTbuffer, (char *) Tpushback, (int) (Tpushb - Tpushback));
	Tpushb = Tpushback;
    }
#endif
    screen->is_running = True;
    if (screen->embed_high && screen->embed_wide) {
	ScreenResize(xw, screen->embed_wide, screen->embed_high, &(xw->flags));
    }
#if OPT_MAXIMIZE
    else if (resource.fullscreen == esTrue || resource.fullscreen == esAlways)
	FullScreen(term, True);
#endif
    if (!setjmp(VTend))
	VTparse(xw);
    StopBlinking(screen);
    HideCursor();
    screen->cursor_set = OFF;
    TRACE(("... VTRun\n"));
}

/*ARGSUSED*/
static void
VTExpose(Widget w GCC_UNUSED,
	 XEvent *event,
	 Region region GCC_UNUSED)
{
    DEBUG_MSG("Expose\n");
    if (event->type == Expose)
	HandleExposure(term, event);
}

static void
VTGraphicsOrNoExpose(XEvent *event)
{
    TScreen *screen = TScreenOf(term);
    if (screen->incopy <= 0) {
	screen->incopy = 1;
	if (screen->scrolls > 0)
	    screen->scrolls--;
    }
    if (event->type == GraphicsExpose)
	if (HandleExposure(term, event))
	    screen->cursor_state = OFF;
    if ((event->type == NoExpose)
	|| ((XGraphicsExposeEvent *) event)->count == 0) {
	if (screen->incopy <= 0 && screen->scrolls > 0)
	    screen->scrolls--;
	if (screen->scrolls)
	    screen->incopy = -1;
	else
	    screen->incopy = 0;
    }
}

/*ARGSUSED*/
static void
VTNonMaskableEvent(Widget w GCC_UNUSED,
		   XtPointer closure GCC_UNUSED,
		   XEvent *event,
		   Boolean *cont GCC_UNUSED)
{
    switch (event->type) {
    case GraphicsExpose:
	/* FALLTHRU */
    case NoExpose:
	VTGraphicsOrNoExpose(event);
	break;
    }
}

static void
VTResize(Widget w)
{
    if (XtIsRealized(w)) {
	XtermWidget xw = (XtermWidget) w;
	ScreenResize(xw, xw->core.width, xw->core.height, &xw->flags);
    }
}

#define okDimension(src,dst) ((src <= 32767) \
			  && ((dst = (Dimension) src) == src))

static void
RequestResize(XtermWidget xw, int rows, int cols, Bool text)
{
    TScreen *screen = TScreenOf(xw);
    Dimension replyWidth, replyHeight;
    Dimension askedWidth, askedHeight;
    XtGeometryResult status;
    XWindowAttributes attrs;

    TRACE(("RequestResize(rows=%d, cols=%d, text=%d)\n", rows, cols, text));

    /* check first if the row/column values fit into a Dimension */
    if (cols > 0) {
	if ((int) (askedWidth = (Dimension) cols) < cols) {
	    TRACE(("... cols too large for Dimension\n"));
	    return;
	}
    } else {
	askedWidth = 0;
    }
    if (rows > 0) {
	if ((int) (askedHeight = (Dimension) rows) < rows) {
	    TRACE(("... rows too large for Dimension\n"));
	    return;
	}
    } else {
	askedHeight = 0;
    }

    if (askedHeight == 0
	|| askedWidth == 0
	|| xw->misc.limit_resize > 0) {
	xtermGetWinAttrs(XtDisplay(xw),
			 RootWindowOfScreen(XtScreen(xw)), &attrs);
    }

    if (text) {
	unsigned long value;

	if ((value = (unsigned long) rows) != 0) {
	    if (rows < 0)
		value = (unsigned long) MaxRows(screen);
	    value *= (unsigned long) FontHeight(screen);
	    value += (unsigned long) (2 * screen->border);
	    if (!okDimension(value, askedHeight))
		return;
	}

	if ((value = (unsigned long) cols) != 0) {
	    if (cols < 0)
		value = (unsigned long) MaxCols(screen);
	    value *= (unsigned long) FontWidth(screen);
	    value += (unsigned long) ((2 * screen->border)
				      + ScrollbarWidth(screen));
	    if (!okDimension(value, askedWidth))
		return;
	}

    } else {
	if (rows < 0)
	    askedHeight = FullHeight(screen);
	if (cols < 0)
	    askedWidth = FullWidth(screen);
    }

    if (rows == 0)
	askedHeight = (Dimension) attrs.height;
    if (cols == 0)
	askedWidth = (Dimension) attrs.width;

    if (xw->misc.limit_resize > 0) {
	Dimension high = (Dimension) (xw->misc.limit_resize * attrs.height);
	Dimension wide = (Dimension) (xw->misc.limit_resize * attrs.width);
	if ((int) high < attrs.height)
	    high = (Dimension) attrs.height;
	if (askedHeight > high)
	    askedHeight = high;
	if ((int) wide < attrs.width)
	    wide = (Dimension) attrs.width;
	if (askedWidth > wide)
	    askedWidth = wide;
    }
#ifndef nothack
    getXtermSizeHints(xw);
#endif

    TRACE(("...requesting resize %dx%d\n", askedHeight, askedWidth));
    status = REQ_RESIZE((Widget) xw,
			askedWidth, askedHeight,
			&replyWidth, &replyHeight);

    if (status == XtGeometryYes ||
	status == XtGeometryDone) {
	ScreenResize(xw, replyWidth, replyHeight, &xw->flags);
    }
#ifndef nothack
    /*
     * XtMakeResizeRequest() has the undesirable side-effect of clearing
     * the window manager's hints, even on a failed request.  This would
     * presumably be fixed if the shell did its own work.
     */
    if (xw->hints.flags
	&& replyHeight
	&& replyWidth) {
	xw->hints.height = replyHeight;
	xw->hints.width = replyWidth;

	TRACE(("%s@%d -- ", __FILE__, __LINE__));
	TRACE_HINTS(&xw->hints);
	XSetWMNormalHints(screen->display, VShellWindow(xw), &xw->hints);
	TRACE(("%s@%d -- ", __FILE__, __LINE__));
	TRACE_WM_HINTS(xw);
    }
#endif

    XSync(screen->display, False);	/* synchronize */
    if (xtermAppPending())
	xevents();

    TRACE(("...RequestResize done\n"));
}

static String xterm_trans =
"WM_PROTOCOLS: DeleteWindow()\n\
     : KeyboardMapping()\n";

int
VTInit(XtermWidget xw)
{
    Widget vtparent = SHELL_OF(xw);

    TRACE(("VTInit {{\n"));

    XtRealizeWidget(vtparent);
    XtOverrideTranslations(vtparent, XtParseTranslationTable(xterm_trans));
    (void) XSetWMProtocols(XtDisplay(vtparent), XtWindow(vtparent),
			   &wm_delete_window, 1);
    TRACE_TRANS("shell", vtparent);
    TRACE_TRANS("vt100", (Widget) (xw));

    ScrnAllocBuf(xw);

    TRACE(("...}} VTInit\n"));
    return (1);
}

static void
VTClassInit(void)
{
    XtAddConverter(XtRString, XtRGravity, XmuCvtStringToGravity,
		   (XtConvertArgList) NULL, (Cardinal) 0);
}

#if OPT_COLOR_RES
/*
 * Override the use of XtDefaultForeground/XtDefaultBackground to make some
 * colors, such as cursor color, use the actual foreground/background value
 * if there is no explicit resource value used.
 */
static Pixel
fill_Tres(XtermWidget target, XtermWidget source, int offset)
{
    char *name;
    ScrnColors temp;
    TScreen *src = TScreenOf(source);
    TScreen *dst = TScreenOf(target);

    dst->Tcolors[offset] = src->Tcolors[offset];
    dst->Tcolors[offset].mode = False;

    if ((name = x_strtrim(dst->Tcolors[offset].resource)) != 0)
	dst->Tcolors[offset].resource = name;

    if (name == 0) {
	dst->Tcolors[offset].value = target->dft_foreground;
    } else if (isDefaultForeground(name)) {
	dst->Tcolors[offset].value = ((offset == TEXT_FG || offset == TEXT_BG)
				      ? target->dft_foreground
				      : dst->Tcolors[TEXT_FG].value);
    } else if (isDefaultBackground(name)) {
	dst->Tcolors[offset].value = ((offset == TEXT_FG || offset == TEXT_BG)
				      ? target->dft_background
				      : dst->Tcolors[TEXT_BG].value);
    } else {
	memset(&temp, 0, sizeof(temp));
	if (AllocateTermColor(target, &temp, offset, name, True)) {
	    if (COLOR_DEFINED(&(temp), offset))
		free(temp.names[offset]);
	    dst->Tcolors[offset].value = temp.colors[offset];
	} else if (offset == TEXT_FG || offset == TEXT_BG) {
	    free(name);
	    dst->Tcolors[offset].resource = 0;
	}
    }
    return dst->Tcolors[offset].value;
}

/*
 * If one or both of the foreground/background colors cannot be allocated,
 * e.g., due to gross misconfiguration, recover by setting both to the
 * display's default values.
 */
static void
repairColors(XtermWidget target)
{
    TScreen *screen = TScreenOf(target);

    if (screen->Tcolors[TEXT_FG].resource == 0 ||
	screen->Tcolors[TEXT_BG].resource == 0) {
	xtermWarning("unable to allocate fg/bg colors\n");
	screen->Tcolors[TEXT_FG].resource = x_strdup(XtDefaultForeground);
	screen->Tcolors[TEXT_BG].resource = x_strdup(XtDefaultBackground);
	if (screen->Tcolors[TEXT_FG].resource == 0 ||
	    screen->Tcolors[TEXT_BG].resource == 0) {
	    Exit(1);
	}
	screen->Tcolors[TEXT_FG].value = target->dft_foreground;
	screen->Tcolors[TEXT_BG].value = target->dft_background;
    }
}
#else
#define fill_Tres(target, source, offset) \
	TScreenOf(target)->Tcolors[offset] = TScreenOf(source)->Tcolors[offset]
#define repairColors(target)	/* nothing */
#endif

#if OPT_WIDE_CHARS
static void
VTInitialize_locale(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);
    Bool is_utf8 = xtermEnvUTF8();

    TRACE(("VTInitialize_locale\n"));
    TRACE(("... request screen.utf8_mode = %d\n", screen->utf8_mode));
    TRACE(("... request screen.utf8_fonts = %d\n", screen->utf8_fonts));

    screen->utf8_always = (screen->utf8_mode == uAlways);
    if (screen->utf8_mode < 0)
	screen->utf8_mode = uFalse;

    if (screen->utf8_mode > 3)
	screen->utf8_mode = uDefault;

    screen->latin9_mode = 0;
    screen->unicode_font = 0;
#if OPT_LUIT_PROG
    xw->misc.callfilter = 0;
    xw->misc.use_encoding = 0;

    TRACE(("... setup for luit:\n"));
    TRACE(("... request misc.locale_str = \"%s\"\n", xw->misc.locale_str));

    if (screen->utf8_mode == uFalse) {
	TRACE(("... command-line +u8 overrides\n"));
    } else
#if OPT_MINI_LUIT
    if (x_strcasecmp(xw->misc.locale_str, "CHECKFONT") == 0) {
	int fl = (int) strlen(DefaultFontN(xw));
	if (fl > 11
	    && x_strcasecmp(DefaultFontN(xw) + fl - 11, "-ISO10646-1") == 0) {
	    screen->unicode_font = 1;
	    /* unicode font, use True */
#ifdef HAVE_LANGINFO_CODESET
	    if (!strcmp(xtermEnvEncoding(), "ANSI_X3.4-1968")
		|| !strcmp(xtermEnvEncoding(), "ISO-8859-1")) {
		if (screen->utf8_mode == uDefault)
		    screen->utf8_mode = uFalse;
	    } else if (!strcmp(xtermEnvEncoding(), "ISO-8859-15")) {
		if (screen->utf8_mode == uDefault)
		    screen->utf8_mode = uFalse;
		screen->latin9_mode = 1;
	    } else {
		xw->misc.callfilter = (Boolean) (is_utf8 ? 0 : 1);
		screen->utf8_mode = uAlways;
	    }
#else
	    xw->misc.callfilter = is_utf8 ? 0 : 1;
	    screen->utf8_mode = uAlways;
#endif
	} else {
	    /* other encoding, use False */
	    if (screen->utf8_mode == uDefault) {
		screen->utf8_mode = is_utf8 ? uAlways : uFalse;
	    }
	}
    } else
#endif /* OPT_MINI_LUIT */
	if (x_strcasecmp(xw->misc.locale_str, "TRUE") == 0 ||
	    x_strcasecmp(xw->misc.locale_str, "ON") == 0 ||
	    x_strcasecmp(xw->misc.locale_str, "YES") == 0 ||
	    x_strcasecmp(xw->misc.locale_str, "AUTO") == 0 ||
	    strcmp(xw->misc.locale_str, "1") == 0) {
	/* when true ... fully obeying LC_CTYPE locale */
	xw->misc.callfilter = (Boolean) (is_utf8 ? 0 : 1);
	screen->utf8_mode = uAlways;
    } else if (x_strcasecmp(xw->misc.locale_str, "FALSE") == 0 ||
	       x_strcasecmp(xw->misc.locale_str, "OFF") == 0 ||
	       x_strcasecmp(xw->misc.locale_str, "NO") == 0 ||
	       strcmp(xw->misc.locale_str, "0") == 0) {
	/* when false ... original value of utf8_mode is effective */
	if (screen->utf8_mode == uDefault) {
	    screen->utf8_mode = is_utf8 ? uAlways : uFalse;
	}
    } else if (x_strcasecmp(xw->misc.locale_str, "MEDIUM") == 0 ||
	       x_strcasecmp(xw->misc.locale_str, "SEMIAUTO") == 0) {
	/* when medium ... obeying locale only for UTF-8 and Asian */
	if (is_utf8) {
	    screen->utf8_mode = uAlways;
	} else if (
#ifdef MB_CUR_MAX
		      MB_CUR_MAX > 1 ||
#else
		      !strncmp(xtermEnvLocale(), "ja", (size_t) 2) ||
		      !strncmp(xtermEnvLocale(), "ko", (size_t) 2) ||
		      !strncmp(xtermEnvLocale(), "zh", (size_t) 2) ||
#endif
		      !strncmp(xtermEnvLocale(), "th", (size_t) 2) ||
		      !strncmp(xtermEnvLocale(), "vi", (size_t) 2)) {
	    xw->misc.callfilter = 1;
	    screen->utf8_mode = uAlways;
	} else {
	    screen->utf8_mode = uFalse;
	}
    } else if (x_strcasecmp(xw->misc.locale_str, "UTF-8") == 0 ||
	       x_strcasecmp(xw->misc.locale_str, "UTF8") == 0) {
	/* when UTF-8 ... UTF-8 mode */
	screen->utf8_mode = uAlways;
    } else {
	/* other words are regarded as encoding name passed to luit */
	xw->misc.callfilter = 1;
	screen->utf8_mode = uAlways;
	xw->misc.use_encoding = 1;
    }
    TRACE(("... updated misc.callfilter = %s\n", BtoS(xw->misc.callfilter)));
    TRACE(("... updated misc.use_encoding = %s\n", BtoS(xw->misc.use_encoding)));
#else
    if (screen->utf8_mode == uDefault) {
	screen->utf8_mode = is_utf8 ? uAlways : uFalse;
    }
#endif /* OPT_LUIT_PROG */

    if (screen->utf8_fonts == uDefault) {
	switch (screen->utf8_mode) {
	case uFalse:
	    /* FALLTHRU */
	case uTrue:
	    screen->utf8_fonts = screen->utf8_mode;
	    break;
	case uDefault:
	    /* should not happen */
	    screen->utf8_fonts = uTrue;
	    break;
	case uAlways:
	    /* use this to disable menu entry */
	    break;
	}
    }

    screen->utf8_inparse = (Boolean) (screen->utf8_mode != uFalse);

    TRACE(("... updated screen.utf8_mode = %d\n", screen->utf8_mode));
    TRACE(("... updated screen.utf8_fonts = %d\n", screen->utf8_fonts));
    TRACE(("...VTInitialize_locale done\n"));
}
#endif

void
lookupSelectUnit(XtermWidget xw, Cardinal item, String value)
{
    /* *INDENT-OFF* */
    static const struct {
	const char *	name;
	SelectUnit	code;
    } table[] = {
    	{ "char",	Select_CHAR },
    	{ "word",	Select_WORD },
    	{ "line",	Select_LINE },
    	{ "group",	Select_GROUP },
    	{ "page",	Select_PAGE },
    	{ "all",	Select_ALL },
#if OPT_SELECT_REGEX
    	{ "regex",	Select_REGEX },
#endif
    };
    /* *INDENT-ON* */

    TScreen *screen = TScreenOf(xw);
    String next = x_skip_nonblanks(value);
    Cardinal n;

    screen->selectMap[item] = NSELECTUNITS;
    for (n = 0; n < XtNumber(table); ++n) {
	if (!x_strncasecmp(table[n].name, value, (unsigned) (next - value))) {
	    screen->selectMap[item] = table[n].code;
#if OPT_SELECT_REGEX
	    if (table[n].code == Select_REGEX) {
		screen->selectExpr[item] = x_strtrim(next);
		TRACE(("Parsed regex \"%s\"\n", screen->selectExpr[item]));
	    }
#endif
	    break;
	}
    }
}

static void
ParseOnClicks(XtermWidget wnew, XtermWidget wreq, Cardinal item)
{
    lookupSelectUnit(wnew, item, TScreenOf(wreq)->onClick[item]);
}

/*
 * Parse a comma-separated list, returning a string which the caller must
 * free, and updating the source pointer.
 */
static char *
ParseList(const char **source)
{
    const char *base = *source;
    const char *next;
    char *value = 0;
    char *result;

    /* ignore empty values */
    while (*base == ',')
	++base;

    if (*base != '\0') {
	size_t size;

	next = base;
	while (*next != '\0' && *next != ',')
	    ++next;
	size = (size_t) (1 + next - base);
	value = malloc(size);
	if (value != 0) {
	    memcpy(value, base, size);
	    value[size - 1] = '\0';
	}
	*source = next;
    } else {
	*source = base;
    }
    result = x_strtrim(value);
    free(value);
    return result;
}

static void
set_flags_from_list(char *target,
		    const char *source,
		    const FlagList * list)
{
    Cardinal n;
    int value = -1;

    while (!IsEmpty(source)) {
	char *next = ParseList(&source);
	Boolean found = False;

	if (next == 0)
	    break;
	if (isdigit(CharOf(*next))) {
	    char *temp;

	    value = (int) strtol(next, &temp, 0);
	    if (!FullS2L(next, temp)) {
		xtermWarning("Expected a number: %s\n", next);
	    } else {
		for (n = 0; list[n].name != 0; ++n) {
		    if (list[n].code == value) {
			target[value] = 1;
			found = True;
			TRACE(("...found %s (%d)\n", list[n].name, value));
			break;
		    }
		}
	    }
	} else {
	    for (n = 0; list[n].name != 0; ++n) {
		if (!x_wildstrcmp(next, list[n].name)) {
		    value = list[n].code;
		    target[value] = 1;
		    found = True;
		    TRACE(("...found %s (%d)\n", list[n].name, value));
		}
	    }
	}
	if (!found) {
	    xtermWarning("Unrecognized keyword: %s\n", next);
	}
	free(next);
    }
}

#define InitCursorShape(target, source) \
    target->cursor_shape = source->cursor_underline \
	? CURSOR_UNDERLINE \
	: CURSOR_BLOCK

/* ARGSUSED */
static void
VTInitialize(Widget wrequest,
	     Widget new_arg,
	     ArgList args GCC_UNUSED,
	     Cardinal *num_args GCC_UNUSED)
{
#define Kolor(name) TScreenOf(wnew)->name.resource
#define TxtFg(name) !x_strcasecmp(Kolor(Tcolors[TEXT_FG]), Kolor(name))
#define TxtBg(name) !x_strcasecmp(Kolor(Tcolors[TEXT_BG]), Kolor(name))
#define DftFg(name) isDefaultForeground(Kolor(name))
#define DftBg(name) isDefaultBackground(Kolor(name))

#define DATA_END   { NULL,  -1       }
#define DATA(name) { #name, ec##name }
    static const FlagList tblColorOps[] =
    {
	DATA(SetColor)
	,DATA(GetColor)
	,DATA(GetAnsiColor)
	,DATA_END
    };
#undef DATA

#define DATA(name) { #name, ef##name }
    static const FlagList tblFontOps[] =
    {
	DATA(SetFont)
	,DATA(GetFont)
	,DATA_END
    };
#undef DATA

#define DATA(name) { #name, em##name }
    static const FlagList tblMouseOps[] =
    {
	DATA(X10)
	,DATA(Locator)
	,DATA(VT200Click)
	,DATA(VT200Hilite)
	,DATA(AnyButton)
	,DATA(AnyEvent)
	,DATA(FocusEvent)
	,DATA(Extended)
	,DATA(SGR)
	,DATA(URXVT)
	,DATA(AlternateScroll)
	,DATA_END
    };
#undef DATA

#define DATA(name) { #name, et##name }
    static const FlagList tblTcapOps[] =
    {
	DATA(SetTcap)
	,DATA(GetTcap)
	,DATA_END
    };
#undef DATA

#define DATA(name) { #name, ew##name }
    static const FlagList tblWindowOps[] =
    {
	DATA(RestoreWin)
	,DATA(MinimizeWin)
	,DATA(SetWinPosition)
	,DATA(SetWinSizePixels)
	,DATA(RaiseWin)
	,DATA(LowerWin)
	,DATA(RefreshWin)
	,DATA(SetWinSizeChars)
#if OPT_MAXIMIZE
	,DATA(MaximizeWin)
	,DATA(FullscreenWin)
#endif
	,DATA(GetWinState)
	,DATA(GetWinPosition)
	,DATA(GetWinSizePixels)
	,DATA(GetWinSizeChars)
#if OPT_MAXIMIZE
	,DATA(GetScreenSizeChars)
#endif
	,DATA(GetIconTitle)
	,DATA(GetWinTitle)
	,DATA(PushTitle)
	,DATA(PopTitle)
	,DATA(SetWinLines)
	,DATA(SetXprop)
	,DATA(GetSelection)
	,DATA(SetSelection)
	,DATA_END
    };
#undef DATA

#if OPT_RENDERFONT
#define DATA(name) { #name, er##name }
    static const FlagList tblRenderFont[] =
    {
	DATA(Default)
	,DATA_END
    };
#undef DATA
#endif

#if OPT_WIDE_CHARS
#define DATA(name) { #name, u##name }
    static const FlagList tblUtf8Mode[] =
    {
	DATA(Always)
	,DATA(Default)
	,DATA_END
    };
#undef DATA
#endif

#ifndef NO_ACTIVE_ICON
#define DATA(name) { #name, ei##name }
    static const FlagList tblAIconOps[] =
    {
	DATA(Default)
	,DATA_END
    };
#undef DATA
#endif

#define DATA(name) { #name, eb##name }
    static const FlagList tbl8BitMeta[] =
    {
	DATA(Never)
	,DATA(Locale)
	,DATA_END
    };
#undef DATA

    XtermWidget request = (XtermWidget) wrequest;
    XtermWidget wnew = (XtermWidget) new_arg;
    Widget my_parent = SHELL_OF(wnew);
    int i;
    const char *s;

#if OPT_ISO_COLORS
    Bool color_ok;
#endif

#if OPT_COLOR_RES2
    static XtResource fake_resources[] =
    {
#if OPT_256_COLORS
# include <256colres.h>
#elif OPT_88_COLORS
# include <88colres.h>
#endif
    };
#endif /* OPT_COLOR_RES2 */
    TScreen *screen = TScreenOf(wnew);

#if OPT_TRACE
    check_tables();
#endif

    TRACE(("VTInitialize wnew %p, %d / %d resources\n",
	   (void *) wnew, XtNumber(xterm_resources), MAXRESOURCES));
    assert(XtNumber(xterm_resources) < MAXRESOURCES);

    /* Zero out the entire "screen" component of "wnew" widget, then do
     * field-by-field assignment of "screen" fields that are named in the
     * resource list.
     */
    memset(screen, 0, sizeof(wnew->screen));

    /* DESCO Sys#67660
     * Zero out the entire "keyboard" component of "wnew" widget.
     */
    memset(&wnew->keyboard, 0, sizeof(wnew->keyboard));

    /*
     * The workspace has no resources - clear it.
     */
    memset(&wnew->work, 0, sizeof(wnew->work));

    /* dummy values so that we don't try to Realize the parent shell with height
     * or width of 0, which is illegal in X.  The real size is computed in the
     * xtermWidget's Realize proc, but the shell's Realize proc is called first,
     * and must see a valid size.
     */
    wnew->core.height = wnew->core.width = 1;

    /*
     * The definition of -rv now is that it changes the definition of
     * XtDefaultForeground and XtDefaultBackground.  So, we no longer
     * need to do anything special.
     */
    screen->display = wnew->core.screen->display;

    /* prep getVisualInfo() */
    wnew->visInfo = 0;
    wnew->numVisuals = 0;
    (void) getVisualInfo(wnew);

    /*
     * We use the default foreground/background colors to compare/check if a
     * color-resource has been set.
     */
#define MyBlackPixel(dpy) BlackPixel(dpy,DefaultScreen(dpy))
#define MyWhitePixel(dpy) WhitePixel(dpy,DefaultScreen(dpy))

    if (request->misc.re_verse) {
	wnew->dft_foreground = MyWhitePixel(screen->display);
	wnew->dft_background = MyBlackPixel(screen->display);
    } else {
	wnew->dft_foreground = MyBlackPixel(screen->display);
	wnew->dft_background = MyWhitePixel(screen->display);
    }

    init_Tres(TEXT_FG);
    init_Tres(TEXT_BG);
    repairColors(wnew);

    wnew->old_foreground = T_COLOR(screen, TEXT_FG);
    wnew->old_background = T_COLOR(screen, TEXT_BG);

    TRACE(("Color resource initialization:\n"));
    TRACE(("   Default foreground 0x%06lx\n", wnew->dft_foreground));
    TRACE(("   Default background 0x%06lx\n", wnew->dft_background));
    TRACE(("   Screen foreground  0x%06lx\n", T_COLOR(screen, TEXT_FG)));
    TRACE(("   Screen background  0x%06lx\n", T_COLOR(screen, TEXT_BG)));
    TRACE(("   Actual  foreground 0x%06lx\n", wnew->old_foreground));
    TRACE(("   Actual  background 0x%06lx\n", wnew->old_background));

    screen->mouse_button = 0;
    screen->mouse_row = -1;
    screen->mouse_col = -1;

#if OPT_BOX_CHARS
    init_Bres(screen.force_box_chars);
    init_Bres(screen.force_packed);
    init_Bres(screen.force_all_chars);
    init_Bres(screen.assume_all_chars);
#endif
    init_Bres(screen.free_bold_box);
    init_Bres(screen.allowBoldFonts);

    init_Bres(screen.c132);
    init_Bres(screen.curses);
    init_Bres(screen.hp_ll_bc);
#if OPT_XMC_GLITCH
    init_Ires(screen.xmc_glitch);
    init_Ires(screen.xmc_attributes);
    init_Bres(screen.xmc_inline);
    init_Bres(screen.move_sgr_ok);
#endif
#if OPT_BLINK_CURS
    init_Bres(screen.cursor_blink);
    init_Ires(screen.blink_on);
    init_Ires(screen.blink_off);
    screen->cursor_blink_res = screen->cursor_blink;
#endif
    init_Bres(screen.cursor_underline);
    /* resources allow for underline or block, not (yet) bar */
    InitCursorShape(screen, TScreenOf(request));
#if OPT_BLINK_CURS
    TRACE(("cursor_shape:%d blinks:%s\n",
	   screen->cursor_shape,
	   BtoS(screen->cursor_blink)));
#endif
#if OPT_BLINK_TEXT
    init_Ires(screen.blink_as_bold);
#endif
    init_Ires(screen.border);
    init_Bres(screen.jumpscroll);
    init_Bres(screen.fastscroll);

    init_Bres(screen.old_fkeys);
    wnew->screen.old_fkeys0 = wnew->screen.old_fkeys;
    wnew->keyboard.type = screen->old_fkeys
	? keyboardIsLegacy
	: keyboardIsDefault;

    init_Mres(screen.delete_is_del);
#ifdef ALLOWLOGGING
    init_Bres(misc.logInhibit);
    init_Bres(misc.log_on);
    init_Sres(screen.logfile);
#endif
    init_Bres(screen.bellIsUrgent);
    init_Bres(screen.bellOnReset);
    init_Bres(screen.marginbell);
    init_Bres(screen.multiscroll);
    init_Ires(screen.nmarginbell);
    init_Ires(screen.savelines);
    init_Ires(screen.scrollBarBorder);
    init_Ires(screen.scrolllines);
    init_Bres(screen.alternateScroll);
    init_Bres(screen.scrollttyoutput);
    init_Bres(screen.scrollkey);

    init_Dres(screen.scale_height);
    if (screen->scale_height < 0.9)
	screen->scale_height = (float) 0.9;
    if (screen->scale_height > 1.5)
	screen->scale_height = (float) 1.5;

    init_Bres(misc.autoWrap);
    init_Bres(misc.login_shell);
    init_Bres(misc.reverseWrap);
    init_Bres(misc.scrollbar);
    init_Sres(misc.geo_metry);
    init_Sres(misc.T_geometry);

    init_Sres(screen.term_id);
    for (s = TScreenOf(request)->term_id; *s; s++) {
	if (!isalpha(CharOf(*s)))
	    break;
    }
    screen->terminal_id = atoi(s);
    if (screen->terminal_id < MIN_DECID)
	screen->terminal_id = MIN_DECID;
    if (screen->terminal_id > MAX_DECID)
	screen->terminal_id = MAX_DECID;
    TRACE(("term_id '%s' -> terminal_id %d\n",
	   screen->term_id,
	   screen->terminal_id));

    screen->vtXX_level = (screen->terminal_id / 100);

    init_Ires(screen.title_modes);
    wnew->screen.title_modes0 = wnew->screen.title_modes;

    init_Bres(screen.visualbell);
    init_Bres(screen.flash_line);
    init_Ires(screen.visualBellDelay);
    init_Bres(screen.poponbell);

    init_Bres(screen.eraseSavedLines0);
    screen->eraseSavedLines = screen->eraseSavedLines0;

    init_Ires(misc.limit_resize);

#if OPT_NUM_LOCK
    init_Bres(misc.real_NumLock);
    init_Bres(misc.alwaysUseMods);
#endif

#if OPT_INPUT_METHOD
    init_Bres(misc.open_im);
    init_Ires(misc.retry_im);
    init_Sres(misc.f_x);
    init_Sres(misc.input_method);
    init_Sres(misc.preedit_type);
#endif

#if OPT_SHIFT_FONTS
    init_Bres(misc.shift_fonts);
#endif
#if OPT_SUNPC_KBD
    init_Ires(misc.ctrl_fkeys);
#endif
#if OPT_TEK4014
    TEK4014_SHOWN(wnew) = False;	/* not a resource... */
    init_Bres(misc.tekInhibit);
    init_Bres(misc.tekSmall);
    init_Bres(misc.TekEmu);
#endif
#if OPT_TCAP_QUERY
    screen->tc_query_code = -1;
#endif
    wnew->misc.re_verse0 = request->misc.re_verse;
    init_Bres(misc.re_verse);
    init_Ires(screen.multiClickTime);
    init_Ires(screen.bellSuppressTime);
    init_Sres(screen.charClass);

    init_Bres(screen.always_highlight);
    init_Bres(screen.brokenSelections);
    init_Bres(screen.cutNewline);
    init_Bres(screen.cutToBeginningOfLine);
    init_Bres(screen.highlight_selection);
    init_Bres(screen.show_wrap_marks);
    init_Bres(screen.i18nSelections);
    init_Bres(screen.keepClipboard);
    init_Bres(screen.keepSelection);
    init_Bres(screen.selectToClipboard);
    init_Bres(screen.trim_selection);

    screen->pointer_cursor = TScreenOf(request)->pointer_cursor;
    init_Ires(screen.pointer_mode);
    wnew->screen.pointer_mode0 = wnew->screen.pointer_mode;

    init_Sres(screen.answer_back);

    wnew->SPS.printer_checked = False;
    init_Sres(SPS.printer_command);
    init_Bres(SPS.printer_autoclose);
    init_Bres(SPS.printer_extent);
    init_Bres(SPS.printer_formfeed);
    init_Bres(SPS.printer_newline);
    init_Ires(SPS.printer_controlmode);
#if OPT_PRINT_COLORS
    init_Ires(SPS.print_attributes);
#endif

    init_Sres(screen.keyboard_dialect);

    init_Bres(screen.input_eight_bits);
    init_Bres(screen.output_eight_bits);
    init_Bres(screen.control_eight_bits);
    init_Bres(screen.backarrow_key);
    init_Bres(screen.alt_is_not_meta);
    init_Bres(screen.alt_sends_esc);
    init_Bres(screen.meta_sends_esc);

    init_Bres(screen.allowPasteControl0);
    init_Bres(screen.allowSendEvent0);
    init_Bres(screen.allowColorOp0);
    init_Bres(screen.allowFontOp0);
    init_Bres(screen.allowMouseOp0);
    init_Bres(screen.allowTcapOp0);
    init_Bres(screen.allowTitleOp0);
    init_Bres(screen.allowWindowOp0);

#if OPT_SCROLL_LOCK
    init_Bres(screen.allowScrollLock0);
#endif

    init_Sres(screen.disallowedColorOps);

    set_flags_from_list(screen->disallow_color_ops,
			screen->disallowedColorOps,
			tblColorOps);

    init_Sres(screen.disallowedFontOps);

    set_flags_from_list(screen->disallow_font_ops,
			screen->disallowedFontOps,
			tblFontOps);

    init_Sres(screen.disallowedMouseOps);

    set_flags_from_list(screen->disallow_mouse_ops,
			screen->disallowedMouseOps,
			tblMouseOps);

    init_Sres(screen.disallowedTcapOps);

    set_flags_from_list(screen->disallow_tcap_ops,
			screen->disallowedTcapOps,
			tblTcapOps);

    init_Sres(screen.disallowedWinOps);

    set_flags_from_list(screen->disallow_win_ops,
			screen->disallowedWinOps,
			tblWindowOps);

    init_Sres(screen.default_string);
    init_Sres(screen.eightbit_select_types);
#if OPT_WIDE_CHARS
    init_Sres(screen.utf8_select_types);
#endif

    /* make a copy so that editres cannot change the resource after startup */
    screen->allowPasteControls = screen->allowPasteControl0;
    screen->allowSendEvents = screen->allowSendEvent0;
    screen->allowColorOps = screen->allowColorOp0;
    screen->allowFontOps = screen->allowFontOp0;
    screen->allowMouseOps = screen->allowMouseOp0;
    screen->allowTcapOps = screen->allowTcapOp0;
    screen->allowTitleOps = screen->allowTitleOp0;
    screen->allowWindowOps = screen->allowWindowOp0;

#if OPT_SCROLL_LOCK
    screen->allowScrollLock = screen->allowScrollLock0;
#endif

    init_Bres(screen.quiet_grab);

#ifndef NO_ACTIVE_ICON
    init_Sres(screen.icon_fontname);
    getIconicFont(screen)->fs = XLoadQueryFont(screen->display,
					       screen->icon_fontname);
    TRACE(("iconFont '%s' %sloaded successfully\n",
	   screen->icon_fontname,
	   getIconicFont(screen)->fs ? "" : "NOT "));
    init_Sres(misc.active_icon_s);
    wnew->work.active_icon =
	(Boolean) extendedBoolean(wnew->misc.active_icon_s,
				  tblAIconOps, eiLAST);
    init_Ires(misc.icon_border_width);
    wnew->misc.icon_border_pixel = request->misc.icon_border_pixel;
#endif /* NO_ACTIVE_ICON */

    init_Bres(misc.signalInhibit);
    init_Bres(misc.titeInhibit);
    init_Bres(misc.tiXtraScroll);
    init_Bres(misc.cdXtraScroll);
    init_Bres(misc.dynamicColors);

#if OPT_DEC_CHRSET
    for (i = 0; i < NUM_CHRSET; i++) {
	screen->double_fonts[i].warn = fwResource;
    }
#endif
    for (i = fontMenu_font1; i <= fontMenu_lastBuiltin; i++) {
	init_Sres2(screen.MenuFontName, i);
    }
    for (i = 0; i < fMAX; i++) {
	screen->fnts[i].warn = fwResource;
#if OPT_WIDE_ATTRS
	screen->ifnts[i].warn = fwResource;
#endif
    }
#ifndef NO_ACTIVE_ICON
    screen->fnt_icon.warn = fwResource;
#endif

    init_Ires(misc.fontWarnings);

    initFontLists(wnew);

#define DefaultFontNames screen->menu_font_names[fontMenu_default]

    /*
     * Process Xft font resources first, since faceName may contain X11 fonts
     * that should override the "font" resource.
     */
#if OPT_RENDERFONT
    for (i = 0; i <= fontMenu_lastBuiltin; ++i) {
	init_Dres2(misc.face_size, i);
    }

#define ALLOC_FONTLIST(name,which,field) \
    init_Sres(misc.default_xft.field);\
    allocFontList(wnew,\
		  name,\
		  &(wnew->work.fonts),\
		  which,\
		  wnew->misc.default_xft.field,\
		  True)

    ALLOC_FONTLIST(XtNfaceName, fNorm, f_n);

#if OPT_WIDE_CHARS
    ALLOC_FONTLIST(XtNfaceNameDoublesize, fWide, f_w);
#endif

#undef ALLOC_FONTLIST

#endif

    /*
     * Process X11 (XLFD) font specifications.
     */
#define ALLOC_FONTLIST(name,which,field) \
    init_Sres(misc.default_font.field);\
    allocFontList(wnew,\
		  name,\
		  &(wnew->work.fonts),\
		  which,\
		  wnew->misc.default_font.field,\
		  False)

    ALLOC_FONTLIST(XtNfont, fNorm, f_n);
    ALLOC_FONTLIST(XtNboldFont, fBold, f_b);

    DefaultFontNames[fNorm] = x_strdup(DefaultFontN(wnew));
    DefaultFontNames[fBold] = x_strdup(DefaultFontB(wnew));

#if OPT_WIDE_CHARS
    ALLOC_FONTLIST(XtNwideFont, fWide, f_w);
    ALLOC_FONTLIST(XtNwideBoldFont, fWBold, f_wb);

    DefaultFontNames[fWide] = x_strdup(DefaultFontW(wnew));
    DefaultFontNames[fWBold] = x_strdup(DefaultFontWB(wnew));
#endif

#undef ALLOC_FONTLIST

    screen->EscapeFontName() = NULL;
    screen->SelectFontName() = NULL;

    screen->menu_font_number = fontMenu_default;
    init_Sres(screen.initial_font);
    if (screen->initial_font != 0) {
	int result = xtermGetFont(screen->initial_font);
	if (result >= 0)
	    screen->menu_font_number = result;
    }
#if OPT_BROKEN_OSC
    init_Bres(screen.brokenLinuxOSC);
#endif

#if OPT_BROKEN_ST
    init_Bres(screen.brokenStringTerm);
#endif

#if OPT_C1_PRINT
    init_Bres(screen.c1_printable);
#endif

#if OPT_CLIP_BOLD
    init_Bres(screen.use_clipping);
#endif

#if OPT_DEC_CHRSET
    init_Bres(screen.font_doublesize);
    init_Ires(screen.cache_doublesize);
    if (screen->cache_doublesize > NUM_CHRSET)
	screen->cache_doublesize = NUM_CHRSET;
    if (screen->cache_doublesize == 0)
	screen->font_doublesize = False;
    TRACE(("Doublesize%s enabled, up to %d fonts\n",
	   screen->font_doublesize ? "" : " not",
	   screen->cache_doublesize));
#endif

#if OPT_ISO_COLORS
    init_Ires(screen.veryBoldColors);
    init_Bres(screen.boldColors);
    init_Bres(screen.colorAttrMode);
    init_Bres(screen.colorBDMode);
    init_Bres(screen.colorBLMode);
    init_Bres(screen.colorMode);
    init_Bres(screen.colorULMode);
    init_Bres(screen.italicULMode);
    init_Bres(screen.colorRVMode);

#if OPT_WIDE_ATTRS
    init_Bres(screen.colorITMode);
#endif

#if OPT_COLOR_RES2
    TRACE(("...will fake resources for color%d to color%d\n",
	   MIN_ANSI_COLORS,
	   NUM_ANSI_COLORS - 1));
#endif
    for (i = 0, color_ok = False; i < MAXCOLORS; i++) {

#if OPT_COLOR_RES2
	/*
	 * Xt has a hardcoded limit on the maximum number of resources that can
	 * be used in a widget.  If we configure both luit (which implies
	 * wide-characters) and 256-colors, it goes over that limit.  Most
	 * people would not need a resource-file with 256-colors; the default
	 * values in our table are sufficient.  In that case, fake the resource
	 * setting by copying the default value from the table.  The #define's
	 * can be overridden to make these true resources.
	 */
	if (i >= MIN_ANSI_COLORS && i < NUM_ANSI_COLORS) {
	    screen->Acolors[i].resource =
		x_strtrim(fake_resources[i - MIN_ANSI_COLORS].default_addr);
	    if (screen->Acolors[i].resource == 0)
		screen->Acolors[i].resource = XtDefaultForeground;
	} else
#endif /* OPT_COLOR_RES2 */
	{
	    screen->Acolors[i] = TScreenOf(request)->Acolors[i];
	    screen->Acolors[i].resource =
		x_strtrim(screen->Acolors[i].resource);
	}

#if OPT_COLOR_RES
	TRACE(("Acolors[%d] = %s\n", i, screen->Acolors[i].resource));
	screen->Acolors[i].mode = False;
	if (DftFg(Acolors[i])) {
	    screen->Acolors[i].value = T_COLOR(screen, TEXT_FG);
	    screen->Acolors[i].mode = True;
	} else if (DftBg(Acolors[i])) {
	    screen->Acolors[i].value = T_COLOR(screen, TEXT_BG);
	    screen->Acolors[i].mode = True;
	} else {
	    color_ok = True;
	}
#else
	TRACE(("Acolors[%d] = %#lx\n", i, TScreenOf(request)->Acolors[i]));
	if (screen->Acolors[i] != wnew->dft_foreground &&
	    screen->Acolors[i] != T_COLOR(screen, TEXT_FG) &&
	    screen->Acolors[i] != T_COLOR(screen, TEXT_BG))
	    color_ok = True;
#endif
    }

    /*
     * Check if we're trying to use color in a monochrome screen.  Disable
     * color in that case, since that would make ANSI colors unusable.  A 4-bit
     * or 8-bit display is usable, so we do not have to check for anything more
     * specific.
     */
    if (color_ok) {
	if (getVisualDepth(wnew) <= 1) {
	    TRACE(("disabling color since screen is monochrome\n"));
	    color_ok = False;
	}
    }

    /* If none of the colors are anything other than the foreground or
     * background, we'll assume this isn't color, no matter what the colorMode
     * resource says.  (There doesn't seem to be any good way to determine if
     * the resource lookup failed versus the user having misconfigured this).
     */
    if (!color_ok) {
	screen->colorMode = False;
	TRACE(("All colors are foreground or background: disable colorMode\n"));
    }
    wnew->sgr_foreground = -1;
    wnew->sgr_background = -1;
    wnew->sgr_extended = False;
#endif /* OPT_ISO_COLORS */

    /*
     * Decode the resources that control the behavior on multiple mouse clicks.
     * A single click is always bound to normal character selection, but the
     * other flavors can be changed.
     */
    for (i = 0; i < NSELECTUNITS; ++i) {
	int ck = (i + 1);
	screen->maxClicks = ck;
	if (i == Select_CHAR)
	    screen->selectMap[i] = Select_CHAR;
	else if (TScreenOf(request)->onClick[i] != 0)
	    ParseOnClicks(wnew, request, (unsigned) i);
	else if (i <= Select_LINE)
	    screen->selectMap[i] = (SelectUnit) i;
	else
	    break;
	TRACE(("on%dClicks %s=%d\n", ck,
	       NonNull(TScreenOf(request)->onClick[i]),
	       screen->selectMap[i]));
	if (screen->selectMap[i] == NSELECTUNITS)
	    break;
    }
    TRACE(("maxClicks %d\n", screen->maxClicks));

    init_Tres(MOUSE_FG);
    init_Tres(MOUSE_BG);
    init_Tres(TEXT_CURSOR);
#if OPT_HIGHLIGHT_COLOR
    init_Tres(HIGHLIGHT_BG);
    init_Tres(HIGHLIGHT_FG);
    init_Bres(screen.hilite_reverse);
    init_Mres(screen.hilite_color);
    if (screen->hilite_color == Maybe) {
	screen->hilite_color = False;
#if OPT_COLOR_RES
	/*
	 * If the highlight text/background are both set, and if they are
	 * not equal to either the text/background or background/text, then
	 * set the highlightColorMode automatically.
	 */
	if (!DftFg(Tcolors[HIGHLIGHT_BG])
	    && !DftBg(Tcolors[HIGHLIGHT_FG])
	    && !TxtFg(Tcolors[HIGHLIGHT_BG])
	    && !TxtBg(Tcolors[HIGHLIGHT_FG])
	    && !TxtBg(Tcolors[HIGHLIGHT_BG])
	    && !TxtFg(Tcolors[HIGHLIGHT_FG])) {
	    TRACE(("...setting hilite_color automatically\n"));
	    screen->hilite_color = True;
	}
#endif
    }
#endif

#if OPT_TEK4014
    /*
     * The Tek4014 window has no separate resources for foreground, background
     * and cursor color.  Since xterm always creates the vt100 widget first, we
     * can set the Tektronix colors here.  That lets us use escape sequences to
     * set its dynamic colors and get consistent behavior whether or not the
     * window is displayed.
     */
    screen->Tcolors[TEK_BG] = screen->Tcolors[TEXT_BG];
    screen->Tcolors[TEK_FG] = screen->Tcolors[TEXT_FG];
    screen->Tcolors[TEK_CURSOR] = screen->Tcolors[TEXT_CURSOR];
#endif

#ifdef SCROLLBAR_RIGHT
    init_Bres(misc.useRight);
#endif

#if OPT_RENDERFONT
    init_Sres(misc.render_font_s);
    wnew->work.render_font =
	(Boolean) extendedBoolean(wnew->misc.render_font_s,
				  tblRenderFont, erLast);
    if (wnew->work.render_font == erDefault) {
	if (IsEmpty(CurrentXftFont(wnew))) {
	    free((void *) CurrentXftFont(wnew));
	    CurrentXftFont(wnew) = x_strdup(DEFFACENAME_AUTO);
	    TRACE(("will allow runtime switch to render_font using \"%s\"\n",
		   CurrentXftFont(wnew)));
	} else {
	    wnew->work.render_font = erTrue;
	    TRACE(("initially using TrueType font\n"));
	}
    }
    /* minor tweak to make debug traces consistent: */
    if (wnew->work.render_font) {
	if (IsEmpty(CurrentXftFont(wnew))) {
	    wnew->work.render_font = False;
	    TRACE(("reset render_font since there is no face_name\n"));
	}
    }
#endif

#if OPT_WIDE_CHARS
    /* setup data for next call */
    request->screen.utf8_mode =
	extendedBoolean(request->screen.utf8_mode_s, tblUtf8Mode, uLast);
    request->screen.utf8_fonts =
	extendedBoolean(request->screen.utf8_fonts_s, tblUtf8Mode, uLast);

    /*
     * Make a copy in the input/request so that DefaultFontN() works for
     * the "CHECKFONT" option.
     */
    copyFontList(&(request->work.fonts.x11.list_n),
		 wnew->work.fonts.x11.list_n);

    VTInitialize_locale(request);
    init_Bres(screen.normalized_c);
    init_Bres(screen.utf8_latin1);
    init_Bres(screen.utf8_title);

#if OPT_LUIT_PROG
    init_Bres(misc.callfilter);
    init_Bres(misc.use_encoding);
    init_Sres(misc.locale_str);
    init_Sres(misc.localefilter);
#endif

    init_Ires(screen.utf8_inparse);
    init_Ires(screen.utf8_mode);
    init_Ires(screen.utf8_fonts);
    init_Ires(screen.max_combining);

    init_Ires(screen.utf8_always);	/* from utf8_mode, used in doparse */

    if (screen->max_combining < 0) {
	screen->max_combining = 0;
    }
    if (screen->max_combining > 5) {
	screen->max_combining = 5;
    }

    init_Bres(screen.vt100_graphics);
    init_Bres(screen.wide_chars);
    init_Bres(misc.mk_width);
    init_Bres(misc.cjk_width);

    init_Ires(misc.mk_samplesize);
    init_Ires(misc.mk_samplepass);

    if (wnew->misc.mk_samplesize > 0xffff)
	wnew->misc.mk_samplesize = 0xffff;
    if (wnew->misc.mk_samplesize < 0)
	wnew->misc.mk_samplesize = 0;

    if (wnew->misc.mk_samplepass > wnew->misc.mk_samplesize)
	wnew->misc.mk_samplepass = wnew->misc.mk_samplesize;
    if (wnew->misc.mk_samplepass < 0)
	wnew->misc.mk_samplepass = 0;

    if (TScreenOf(request)->utf8_mode) {
	TRACE(("setting wide_chars on\n"));
	screen->wide_chars = True;
    } else {
	TRACE(("setting utf8_mode to 0\n"));
	screen->utf8_mode = uFalse;
    }
    mk_wcwidth_init(screen->utf8_mode);
    TRACE(("initialized UTF-8 mode to %d\n", screen->utf8_mode));

#if OPT_MINI_LUIT
    if (TScreenOf(request)->latin9_mode) {
	screen->latin9_mode = True;
    }
    if (TScreenOf(request)->unicode_font) {
	screen->unicode_font = True;
    }
    TRACE(("initialized Latin9 mode to %d\n", screen->latin9_mode));
    TRACE(("initialized unicode_font to %d\n", screen->unicode_font));
#endif

    decode_wcwidth(wnew);
    xtermSaveVTFonts(wnew);
#endif /* OPT_WIDE_CHARS */

    init_Sres(screen.eight_bit_meta_s);
    wnew->screen.eight_bit_meta =
	extendedBoolean(request->screen.eight_bit_meta_s, tbl8BitMeta, uLast);
    if (wnew->screen.eight_bit_meta == ebLocale) {
#if OPT_WIDE_CHARS
	if (xtermEnvUTF8()) {
	    wnew->screen.eight_bit_meta = ebFalse;
	    TRACE(("...eightBitMeta is false due to locale\n"));
	} else
#endif /* OPT_WIDE_CHARS */
	{
	    wnew->screen.eight_bit_meta = ebTrue;
	    TRACE(("...eightBitMeta is true due to locale\n"));
	}
    }

    init_Bres(screen.always_bold_mode);
    init_Bres(screen.bold_mode);
    init_Bres(screen.underline);

    wnew->cur_foreground = 0;
    wnew->cur_background = 0;

    wnew->keyboard.flags = MODE_SRM;

    if (screen->backarrow_key)
	wnew->keyboard.flags |= MODE_DECBKM;
    TRACE(("initialized DECBKM %s\n",
	   BtoS(wnew->keyboard.flags & MODE_DECBKM)));

#if OPT_SIXEL_GRAPHICS
    init_Bres(screen.sixel_scrolling);
    if (screen->sixel_scrolling)
	wnew->keyboard.flags |= MODE_DECSDM;
    TRACE(("initialized DECSDM %s\n",
	   BtoS(wnew->keyboard.flags & MODE_DECSDM)));
#endif

#if OPT_GRAPHICS
    init_Ires(screen.numcolorregisters);
    TRACE(("initialized NUM_COLOR_REGISTERS to resource default: %d\n",
	   screen->numcolorregisters));

    init_Bres(screen.privatecolorregisters);	/* FIXME: should this be off unconditionally here? */
    TRACE(("initialized PRIVATE_COLOR_REGISTERS to resource default: %s\n",
	   BtoS(screen->privatecolorregisters)));
#endif

#if OPT_GRAPHICS
    {
	int native_w, native_h;

	switch (screen->terminal_id) {
	case 125:
	    native_w = 768;
	    native_h = 460;
	    break;
	case 240:
	    native_w = 800;
	    native_h = 460;
	    break;
	case 241:
	    native_w = 800;
	    native_h = 460;
	    break;
	case 330:
	    native_w = 800;
	    native_h = 480;
	    break;
	case 340:
	    /* FALLTHRU */
	default:
	    native_w = 800;
	    native_h = 480;
	    break;
	case 382:
	    native_w = 960;
	    native_h = 750;
	    break;
	}

# if OPT_REGIS_GRAPHICS
	init_Sres(screen.graphics_regis_default_font);
	TRACE(("default ReGIS font: %s\n",
	       screen->graphics_regis_default_font));

	init_Sres(screen.graphics_regis_screensize);
	screen->graphics_regis_def_high = 1000;
	screen->graphics_regis_def_wide = 1000;
	if (!x_strcasecmp(screen->graphics_regis_screensize, "auto")) {
	    TRACE(("setting default ReGIS screensize based on terminal_id %d\n",
		   screen->terminal_id));
	    screen->graphics_regis_def_high = (Dimension) native_w;
	    screen->graphics_regis_def_wide = (Dimension) native_h;
	} else {
	    int conf_high;
	    int conf_wide;
	    char ignore;

	    if (sscanf(screen->graphics_regis_screensize,
		       "%dx%d%c",
		       &conf_wide,
		       &conf_high,
		       &ignore) == 2) {
		if (conf_high > 0 && conf_wide > 0) {
		    screen->graphics_regis_def_high =
			(Dimension) conf_high;
		    screen->graphics_regis_def_wide =
			(Dimension) conf_wide;
		} else {
		    TRACE(("ignoring invalid regisScreenSize %s\n",
			   screen->graphics_regis_screensize));
		}
	    } else {
		TRACE(("ignoring invalid regisScreenSize %s\n",
		       screen->graphics_regis_screensize));
	    }
	}
	TRACE(("default ReGIS graphics screensize %dx%d\n",
	       (int) screen->graphics_regis_def_wide,
	       (int) screen->graphics_regis_def_high));
# endif

	init_Sres(screen.graphics_max_size);
	screen->graphics_max_high = 1000;
	screen->graphics_max_wide = 1000;
	if (!x_strcasecmp(screen->graphics_max_size, "auto")) {
	    TRACE(("setting max graphics screensize based on terminal_id %d\n",
		   screen->terminal_id));
	    screen->graphics_max_high = (Dimension) native_w;
	    screen->graphics_max_wide = (Dimension) native_h;
	} else {
	    int conf_high;
	    int conf_wide;
	    char ignore;

	    if (sscanf(screen->graphics_max_size,
		       "%dx%d%c",
		       &conf_wide,
		       &conf_high,
		       &ignore) == 2) {
		if (conf_high > 0 && conf_wide > 0) {
		    screen->graphics_max_high = (Dimension) conf_high;
		    screen->graphics_max_wide = (Dimension) conf_wide;
		} else {
		    TRACE(("ignoring invalid maxGraphicSize %s\n",
			   screen->graphics_max_size));
		}
	    } else {
		TRACE(("ignoring invalid maxGraphicSize %s\n",
		       screen->graphics_max_size));
	    }
	}
# if OPT_REGIS_GRAPHICS
	/* Make sure the max is large enough for the default ReGIS size. */
	if (screen->graphics_regis_def_high >
	    screen->graphics_max_high) {
	    screen->graphics_max_high =
		screen->graphics_regis_def_high;
	}
	if (screen->graphics_regis_def_wide >
	    screen->graphics_max_wide) {
	    screen->graphics_max_wide =
		screen->graphics_regis_def_wide;
	}
# endif
	TRACE(("max graphics screensize %dx%d\n",
	       (int) screen->graphics_max_wide,
	       (int) screen->graphics_max_high));
    }
#endif

#if OPT_SIXEL_GRAPHICS
    init_Bres(screen.sixel_scrolls_right);
    TRACE(("initialized SIXEL_SCROLLS_RIGHT to resource default: %s\n",
	   BtoS(screen->sixel_scrolls_right)));
#endif

    /* look for focus related events on the shell, because we need
     * to care about the shell's border being part of our focus.
     */
    TRACE(("adding event handlers for my_parent %p\n", (void *) my_parent));
    XtAddEventHandler(my_parent, EnterWindowMask, False,
		      HandleEnterWindow, (Opaque) NULL);
    XtAddEventHandler(my_parent, LeaveWindowMask, False,
		      HandleLeaveWindow, (Opaque) NULL);
    XtAddEventHandler(my_parent, FocusChangeMask, False,
		      HandleFocusChange, (Opaque) NULL);
    XtAddEventHandler((Widget) wnew, 0L, True,
		      VTNonMaskableEvent, (Opaque) NULL);
    XtAddEventHandler((Widget) wnew, PropertyChangeMask, False,
		      HandleBellPropertyChange, (Opaque) NULL);

#if HANDLE_STRUCT_NOTIFY
#if OPT_TOOLBAR
    wnew->VT100_TB_INFO(menu_bar) = request->VT100_TB_INFO(menu_bar);
    init_Ires(VT100_TB_INFO(menu_height));
#else
    /* Flag icon name with "***"  on window output when iconified.
     * Put in a handler that will tell us when we get Map/Unmap events.
     */
    if (resource.zIconBeep)
#endif
	XtAddEventHandler(my_parent, StructureNotifyMask, False,
			  HandleStructNotify, (Opaque) 0);
#endif /* HANDLE_STRUCT_NOTIFY */

    screen->bellInProgress = False;

    set_character_class(screen->charClass);
#if OPT_REPORT_CCLASS
    if (resource.reportCClass)
	report_char_class(wnew);
#endif

    /* create it, but don't realize it */
    ScrollBarOn(wnew, True);

    /* make sure that the resize gravity acceptable */
    if (!GravityIsNorthWest(wnew) &&
	!GravityIsSouthWest(wnew)) {
	char value[80];
	String temp[2];
	Cardinal nparams = 1;

	sprintf(value, "%d", wnew->misc.resizeGravity);
	temp[0] = value;
	temp[1] = 0;
	XtAppWarningMsg(app_con, "rangeError", "resizeGravity", "XTermError",
			"unsupported resizeGravity resource value (%s)",
			temp, &nparams);
	wnew->misc.resizeGravity = SouthWestGravity;
    }
#ifndef NO_ACTIVE_ICON
    screen->whichVwin = &screen->fullVwin;
#endif /* NO_ACTIVE_ICON */

    if (screen->savelines < 0)
	screen->savelines = 0;

    init_Bres(screen.awaitInput);

    wnew->flags = 0;
    if (!screen->jumpscroll)
	wnew->flags |= SMOOTHSCROLL;
    if (wnew->misc.reverseWrap)
	wnew->flags |= REVERSEWRAP;
    if (wnew->misc.autoWrap)
	wnew->flags |= WRAPAROUND;
    if (wnew->misc.re_verse != wnew->misc.re_verse0)
	wnew->flags |= REVERSE_VIDEO;
    if (screen->c132)
	wnew->flags |= IN132COLUMNS;

    wnew->initflags = wnew->flags;

#if OPT_MOD_FKEYS
    init_Ires(keyboard.modify_1st.allow_keys);
    init_Ires(keyboard.modify_1st.cursor_keys);
    init_Ires(keyboard.modify_1st.function_keys);
    init_Ires(keyboard.modify_1st.keypad_keys);
    init_Ires(keyboard.modify_1st.other_keys);
    init_Ires(keyboard.modify_1st.string_keys);
    init_Ires(keyboard.format_keys);
    wnew->keyboard.modify_now = wnew->keyboard.modify_1st;
#endif

    init_Ires(misc.appcursorDefault);
    if (wnew->misc.appcursorDefault)
	wnew->keyboard.flags |= MODE_DECCKM;

    init_Ires(misc.appkeypadDefault);
    if (wnew->misc.appkeypadDefault)
	wnew->keyboard.flags |= MODE_DECKPAM;

    initLineData(wnew);
#if OPT_WIDE_CHARS
    freeFontList(&(request->work.fonts.x11.list_n));
#endif
    return;
}

void
releaseCursorGCs(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);
    VTwin *win = WhichVWin(screen);
    int n;

    for_each_curs_gc(n) {
	freeCgs(xw, win, (CgsEnum) n);
    }
}

void
releaseWindowGCs(XtermWidget xw, VTwin *win)
{
    int n;

    for_each_text_gc(n) {
	freeCgs(xw, win, (CgsEnum) n);
    }
}

#define TRACE_FREE_LEAK(name) \
	if (name) { \
	    TRACE(("freed " #name ": %p\n", (const void *) name)); \
	    free((void *) name); \
	    name = 0; \
	}

#define FREE_LEAK(name) \
	if (name) { \
	    free((void *) name); \
	    name = 0; \
	}

#if OPT_I18N_SUPPORT && OPT_INPUT_METHOD
static void
cleanupInputMethod(XtermWidget xw)
{
    TInput *input = lookupTInput(xw, (Widget) xw);

    if (input && input->xim) {
	XCloseIM(input->xim);
	input->xim = 0;
	TRACE(("freed screen->xim\n"));
    }
}
#endif

static void
VTDestroy(Widget w GCC_UNUSED)
{
#ifdef NO_LEAKS
    XtermWidget xw = (XtermWidget) w;
    TScreen *screen = TScreenOf(xw);
    Cardinal n, k;

    StopBlinking(screen);

    if (screen->scrollWidget) {
	XtUninstallTranslations(screen->scrollWidget);
	XtDestroyWidget(screen->scrollWidget);
    }
#if OPT_FIFO_LINES
    while (screen->saved_fifo > 0) {
	deleteScrollback(screen);
    }
#endif
    while (screen->save_title != 0) {
	SaveTitle *last = screen->save_title;
	screen->save_title = last->next;
	free(last->iconName);
	free(last->windowName);
	free(last);
    }
    TRACE_FREE_LEAK(xw->misc.active_icon_s);
#if OPT_ISO_COLORS
    TRACE_FREE_LEAK(screen->cmap_data);
    for (n = 0; n < MAXCOLORS; n++) {
	TRACE_FREE_LEAK(screen->Acolors[n].resource);
    }
#endif
#if OPT_COLOR_RES
    for (n = 0; n < NCOLORS; n++) {
	switch (n) {
#if OPT_TEK4014
	case TEK_BG:
	    /* FALLTHRU */
	case TEK_FG:
	    /* FALLTHRU */
	case TEK_CURSOR:
	    break;
#endif
	default:
	    TRACE_FREE_LEAK(screen->Tcolors[n].resource);
	    break;
	}
    }
#endif
    TRACE_FREE_LEAK(screen->save_ptr);
    TRACE_FREE_LEAK(screen->saveBuf_data);
    TRACE_FREE_LEAK(screen->saveBuf_index);
    for (n = 0; n < 2; ++n) {
	TRACE_FREE_LEAK(screen->editBuf_data[n]);
	TRACE_FREE_LEAK(screen->editBuf_index[n]);
    }
    TRACE_FREE_LEAK(screen->keyboard_dialect);
    TRACE_FREE_LEAK(screen->term_id);
#if OPT_WIDE_CHARS
#if OPT_LUIT_PROG
    TRACE_FREE_LEAK(xw->misc.locale_str);
    TRACE_FREE_LEAK(xw->misc.localefilter);
#endif
#endif
    TRACE_FREE_LEAK(xw->misc.T_geometry);
    TRACE_FREE_LEAK(xw->misc.geo_metry);
    TRACE_FREE_LEAK(xw->screen.term_id);
#if OPT_INPUT_METHOD
    cleanupInputMethod(xw);
    TRACE_FREE_LEAK(xw->misc.f_x);
    TRACE_FREE_LEAK(xw->misc.input_method);
    TRACE_FREE_LEAK(xw->misc.preedit_type);
#endif
    releaseCursorGCs(xw);
    releaseWindowGCs(xw, &(screen->fullVwin));
#ifndef NO_ACTIVE_ICON
    XFreeFont(screen->display, getIconicFont(screen)->fs);
    releaseWindowGCs(xw, &(screen->iconVwin));
#endif
    XtUninstallTranslations((Widget) xw);
#if OPT_TOOLBAR
    XtUninstallTranslations((Widget) XtParent(xw));
#endif
    XtUninstallTranslations((Widget) SHELL_OF(xw));

    if (screen->hidden_cursor)
	XFreeCursor(screen->display, screen->hidden_cursor);

    xtermCloseFonts(xw, screen->fnts);
#if OPT_WIDE_ATTRS
    xtermCloseFonts(xw, screen->ifnts);
#endif
    noleaks_cachedCgs(xw);

    TRACE_FREE_LEAK(screen->selection_targets_8bit);
#if OPT_SELECT_REGEX
    for (n = 0; n < NSELECTUNITS; ++n) {
	if (screen->selectMap[n] == Select_REGEX) {
	    TRACE_FREE_LEAK(screen->selectExpr[n]);
	}
    }
#endif

#if OPT_RENDERFONT
    for (n = 0; n < NMENUFONTS; ++n) {
	int e;
	for (e = 0; e < fMAX; ++e) {
	    xtermCloseXft(screen, getMyXftFont(xw, e, (int) n));
	}
    }
    if (screen->renderDraw)
	XftDrawDestroy(screen->renderDraw);
#endif

    /* free things allocated via init_Sres or Init_Sres2 */
#ifndef NO_ACTIVE_ICON
    TRACE_FREE_LEAK(screen->icon_fontname);
#endif
#ifdef ALLOWLOGGING
    TRACE_FREE_LEAK(screen->logfile);
#endif
    TRACE_FREE_LEAK(screen->eight_bit_meta_s);
    TRACE_FREE_LEAK(screen->term_id);
    TRACE_FREE_LEAK(screen->charClass);
    TRACE_FREE_LEAK(screen->answer_back);
    TRACE_FREE_LEAK(screen->printer_state.printer_command);
    TRACE_FREE_LEAK(screen->keyboard_dialect);
    TRACE_FREE_LEAK(screen->disallowedColorOps);
    TRACE_FREE_LEAK(screen->disallowedFontOps);
    TRACE_FREE_LEAK(screen->disallowedMouseOps);
    TRACE_FREE_LEAK(screen->disallowedTcapOps);
    TRACE_FREE_LEAK(screen->disallowedWinOps);
    TRACE_FREE_LEAK(screen->default_string);
    TRACE_FREE_LEAK(screen->eightbit_select_types);

#if OPT_WIDE_CHARS
    TRACE_FREE_LEAK(screen->utf8_select_types);
#endif

#if 0
    for (n = fontMenu_font1; n <= fontMenu_lastBuiltin; n++) {
	TRACE_FREE_LEAK(screen->MenuFontName(n));
    }
#endif

    TRACE_FREE_LEAK(screen->initial_font);

#if OPT_LUIT_PROG
    TRACE_FREE_LEAK(xw->misc.locale_str);
    TRACE_FREE_LEAK(xw->misc.localefilter);
#endif

#if OPT_RENDERFONT
    TRACE_FREE_LEAK(xw->misc.default_xft.f_n);
    TRACE_FREE_LEAK(xw->misc.default_xft.f_w);
    TRACE_FREE_LEAK(xw->misc.render_font_s);
#endif

    TRACE_FREE_LEAK(xw->misc.default_font.f_n);
    TRACE_FREE_LEAK(xw->misc.default_font.f_b);

#if OPT_WIDE_CHARS
    TRACE_FREE_LEAK(xw->misc.default_font.f_w);
    TRACE_FREE_LEAK(xw->misc.default_font.f_wb);
#endif

    freeFontLists(&(xw->work.fonts.x11));
#if OPT_RENDERFONT
    freeFontLists(&(xw->work.fonts.xft));
#endif

    xtermFontName(NULL);
#if OPT_LOAD_VTFONTS || OPT_WIDE_CHARS
    TRACE_FREE_LEAK(screen->cacheVTFonts.default_font.f_n);
    TRACE_FREE_LEAK(screen->cacheVTFonts.default_font.f_b);
#if OPT_WIDE_CHARS
    TRACE_FREE_LEAK(screen->cacheVTFonts.default_font.f_w);
    TRACE_FREE_LEAK(screen->cacheVTFonts.default_font.f_wb);
#endif
    freeFontLists(&(screen->cacheVTFonts.fonts.x11));
    for (n = 0; n < NMENUFONTS; ++n) {
	for (k = 0; k < fMAX; ++k) {
	    if (screen->menu_font_names[n][k] !=
		screen->cacheVTFonts.menu_font_names[n][k]) {
		TRACE_FREE_LEAK(screen->menu_font_names[n][k]);
		TRACE_FREE_LEAK(screen->cacheVTFonts.menu_font_names[n][k]);
	    } else {
		TRACE_FREE_LEAK(screen->menu_font_names[n][k]);
	    }
	}
    }
#endif

#if OPT_SELECT_REGEX
    for (n = 0; n < NSELECTUNITS; ++n) {
	FREE_LEAK(screen->selectExpr[n]);
    }
#endif

    if (screen->selection_atoms)
	XtFree((void *) (screen->selection_atoms));

    XtFree((void *) (screen->selection_data));

    TRACE_FREE_LEAK(xtermClassRec.core_class.tm_table);
    TRACE_FREE_LEAK(xw->keyboard.extra_translations);
    TRACE_FREE_LEAK(xw->keyboard.shell_translations);
    TRACE_FREE_LEAK(xw->keyboard.xterm_translations);

    XtFree((void *) (xw->visInfo));

#if OPT_WIDE_CHARS
    FreeTypedBuffer(XChar2b);
    FreeTypedBuffer(char);
#endif
#if OPT_RENDERFONT
#if OPT_RENDERWIDE
    FreeTypedBuffer(XftCharSpec);
#else
    FreeTypedBuffer(XftChar8);
#endif
#endif

    TRACE_FREE_LEAK(myState.print_area);
    TRACE_FREE_LEAK(myState.string_area);
    memset(&myState, 0, sizeof(myState));

#endif /* defined(NO_LEAKS) */
}

#ifndef NO_ACTIVE_ICON
static void *
getProperty(Display *dpy,
	    Window w,
	    Atom req_type,
	    const char *prop_name)
{
    Atom property;
    Atom actual_return_type;
    int actual_format_return = 0;
    unsigned long nitems_return = 0;
    unsigned long bytes_after_return = 0;
    unsigned char *prop_return = 0;
    long long_length = 1024;
    size_t limit;
    char *result = 0;

    TRACE(("getProperty %s(%s)\n", prop_name,
	   req_type ? TraceAtomName(dpy, req_type) : "?"));
    property = XInternAtom(dpy, prop_name, False);

    if (!xtermGetWinProp(dpy,
			 w,
			 property,
			 0L,
			 long_length,
			 req_type,
			 &actual_return_type,
			 &actual_format_return,
			 &nitems_return,
			 &bytes_after_return,
			 &prop_return)) {
	TRACE((".. Cannot get %s property.\n", prop_name));
    } else if (prop_return != 0) {

	if (nitems_return != 0 &&
	    actual_format_return != 0 &&
	    actual_return_type == req_type) {
	    /*
	     * Null-terminate the result to make string handling easier.
	     * The format==8 corresponds to strings, and the number of items
	     * is the number of characters.
	     */
	    if (actual_format_return == 8) {
		limit = nitems_return;
	    } else {
		/* manpage is misleading - X really uses 'long', not 32-bits */
		limit = sizeof(long) * nitems_return;
	    }
	    if ((result = malloc(limit + 1)) != 0) {
		memcpy(result, prop_return, limit);
		result[limit] = '\0';
	    }
	    TRACE(("... result %s\n", result ? ("ok") : "null"));
	}
	XFree(prop_return);
    } else {
	TRACE((".. no property returned\n"));
    }
    return (void *) result;
}

/*
 * Active icons are supported by fvwm.  This feature is not supported by
 * metacity (gnome) or kwin (kde).  Both metacity and kwin support (in
 * incompatible ways, e.g., one uses the icon theme as a fallback for window
 * decorations but the other does not, etc, ...) an icon as part of the window
 * decoration (usually on the upper-left of the window).
 *
 * In either case, xterm's icon will only be shown in the window decorations if
 * xterm does not use the active icon feature.
 *
 * This function (tries to) determine the window manager's name, so that we can
 * provide a useful automatic default for active icons.  It is based on reading
 * wmctrl, which covers most of EWMH and ICCM.
 */
static char *
getWindowManagerName(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);
    Display *dpy = screen->display;
    Window *sup_window = NULL;
    char *result = 0;

    TRACE(("getWindowManagerName\n"));
#define getWinProp(type, name) \
    (Window *)getProperty(dpy, DefaultRootWindow(dpy), type, name)
    if ((sup_window = getWinProp(XA_WINDOW, "_NET_SUPPORTING_WM_CHECK")) == 0) {
	sup_window = getWinProp(XA_CARDINAL, "_WIN_SUPPORTING_WM_CHECK");
    }

    /*
     * If we found the supporting window, get the property containing the
     * window manager's name.  EWMH defines _NET_WM_NAME, while ICCM defines
     * WM_CLASS.  There is no standard for the names stored there;
     * conventionally it is mixed case.  In practice, the former is more often
     * set; the latter is not given (or is a lowercased version of the former).
     */
    if (sup_window != 0) {
#define getStringProp(type,name) \
	(char *)getProperty(dpy, *sup_window, type, name)
	if ((result = getStringProp(XA_UTF8_STRING(dpy), "_NET_WM_NAME")) == 0
	    && (result = getStringProp(XA_STRING, "_NET_WM_NAME")) == 0
	    && (result = getStringProp(XA_STRING, "WM_CLASS")) == 0) {
	    TRACE(("... window manager does not tell its name\n"));
	}
	free(sup_window);
    } else {
	TRACE(("... Cannot get window manager info properties\n"));
    }
    if (result == 0)
	result = x_strdup("unknown");
    TRACE(("... window manager name is %s\n", result));
    return result;
}
#endif

/*ARGSUSED*/
static void
VTRealize(Widget w,
	  XtValueMask * valuemask,
	  XSetWindowAttributes * values)
{
    XtermWidget xw = (XtermWidget) w;
    TScreen *screen = TScreenOf(xw);

    const VTFontNames *myfont;
    struct Xinerama_geometry pos;
    int pr;
    Atom pid_atom;
    int i;

    TRACE(("VTRealize {{\n"));

#if OPT_TOOLBAR
    /*
     * Layout for the toolbar confuses the Shell widget.  Remind it that we
     * would like to be iconified if the corresponding resource was set.
     */
    if (XtIsRealized(toplevel)) {
	Boolean iconic = 0;

	XtVaGetValues(toplevel,
		      XtNiconic, &iconic,
		      (XtPointer) 0);

	if (iconic) {
	    XIconifyWindow(XtDisplay(toplevel),
			   XtWindow(toplevel),
			   DefaultScreen(XtDisplay(toplevel)));
	}
    }
#endif

    TabReset(xw->tabs);

    if (screen->menu_font_number == fontMenu_default) {
	myfont = defaultVTFontNames(xw);
    } else {
	myfont = xtermFontName(screen->MenuFontName(screen->menu_font_number));
    }
    memset(screen->fnts, 0, sizeof(screen->fnts));

    if (!xtermLoadFont(xw,
		       myfont,
		       False,
		       screen->menu_font_number)) {
	if (XmuCompareISOLatin1(myfont->f_n, DEFFONT) != 0) {
	    char *use_font = x_strdup(DEFFONT);
	    xtermWarning("unable to open font \"%s\", trying \"%s\"....\n",
			 myfont->f_n, use_font);
	    (void) xtermLoadFont(xw,
				 xtermFontName(use_font),
				 False,
				 screen->menu_font_number);
	    screen->MenuFontName(screen->menu_font_number) = use_font;
	}
    }

    /* really screwed if we couldn't open default font */
    if (!getNormalFont(screen, fNorm)->fs) {
	xtermWarning("unable to locate a suitable font\n");
	Exit(1);
    }
#if OPT_WIDE_CHARS
    if (screen->utf8_mode) {
	TRACE(("check if this is a wide font, if not try again\n"));
	if (xtermLoadWideFonts(xw, False)) {
	    SetVTFont(xw, screen->menu_font_number, True, NULL);
	    /* we will not be able to switch to ISO-8859-1 */
	    if (!screen->mergedVTFonts) {
		screen->utf8_fonts = uAlways;
		update_font_utf8_fonts();
	    }
	}
    }
#endif

    /* making cursor */
    if (!screen->pointer_cursor) {
	screen->pointer_cursor =
	    make_colored_cursor(XC_xterm,
				T_COLOR(screen, MOUSE_FG),
				T_COLOR(screen, MOUSE_BG));
    } else {
	recolor_cursor(screen,
		       screen->pointer_cursor,
		       T_COLOR(screen, MOUSE_FG),
		       T_COLOR(screen, MOUSE_BG));
    }

    /* set defaults */
    pos.x = 1;
    pos.y = 1;
    pos.w = 80;
    pos.h = 24;

    TRACE(("parsing geo_metry %s\n", NonNull(xw->misc.geo_metry)));
    pr = XParseXineramaGeometry(screen->display, xw->misc.geo_metry, &pos);
    TRACE(("... position %d,%d size %dx%d\n", pos.y, pos.x, pos.h, pos.w));

    set_max_col(screen, (int) (pos.w - 1));	/* units in character cells */
    set_max_row(screen, (int) (pos.h - 1));	/* units in character cells */
    xtermUpdateFontInfo(xw, False);

    pos.w = screen->fullVwin.fullwidth;
    pos.h = screen->fullVwin.fullheight;

    TRACE(("... border widget %d parent %d shell %d\n",
	   BorderWidth(xw),
	   BorderWidth(XtParent(xw)),
	   BorderWidth(SHELL_OF(xw))));

    if ((pr & XValue) && (XNegative & pr)) {
	pos.x = (Position) (pos.x + (pos.scr_w
				     - (int) pos.w
				     - (BorderWidth(XtParent(xw)) * 2)));
    }
    if ((pr & YValue) && (YNegative & pr)) {
	pos.y = (Position) (pos.y + (pos.scr_h
				     - (int) pos.h
				     - (BorderWidth(XtParent(xw)) * 2)));
    }
    pos.x = (Position) (pos.x + pos.scr_x);
    pos.y = (Position) (pos.y + pos.scr_y);

    /* set up size hints for window manager; min 1 char by 1 char */
    getXtermSizeHints(xw);
    xtermSizeHints(xw, (xw->misc.scrollbar
			? (screen->scrollWidget->core.width
			   + BorderWidth(screen->scrollWidget))
			: 0));

    xw->hints.x = pos.x;
    xw->hints.y = pos.y;
#if OPT_MAXIMIZE
    /* assure single-increment resize for fullscreen */
    if (term->work.ewmh[0].mode) {
	xw->hints.width_inc = 1;
	xw->hints.height_inc = 1;
    }
#endif
    if ((XValue & pr) || (YValue & pr)) {
	xw->hints.flags |= USSize | USPosition;
	xw->hints.flags |= PWinGravity;
	switch (pr & (XNegative | YNegative)) {
	case 0:
	    xw->hints.win_gravity = NorthWestGravity;
	    break;
	case XNegative:
	    xw->hints.win_gravity = NorthEastGravity;
	    break;
	case YNegative:
	    xw->hints.win_gravity = SouthWestGravity;
	    break;
	default:
	    xw->hints.win_gravity = SouthEastGravity;
	    break;
	}
    } else {
	/* set a default size, but do *not* set position */
	xw->hints.flags |= PSize;
    }
    xw->hints.height = xw->hints.base_height
	+ xw->hints.height_inc * MaxRows(screen);
    xw->hints.width = xw->hints.base_width
	+ xw->hints.width_inc * MaxCols(screen);

    if ((WidthValue & pr) || (HeightValue & pr))
	xw->hints.flags |= USSize;
    else
	xw->hints.flags |= PSize;

    /*
     * Note that the size-hints are for the shell, while the resize-request
     * is for the vt100 widget.  They are not the same size.
     */
    (void) REQ_RESIZE((Widget) xw,
		      (Dimension) pos.w, (Dimension) pos.h,
		      &xw->core.width, &xw->core.height);

    /* XXX This is bogus.  We are parsing geometries too late.  This
     * is information that the shell widget ought to have before we get
     * realized, so that it can do the right thing.
     */
    if (xw->hints.flags & USPosition)
	XMoveWindow(XtDisplay(xw), VShellWindow(xw),
		    xw->hints.x, xw->hints.y);

    TRACE(("%s@%d -- ", __FILE__, __LINE__));
    TRACE_HINTS(&xw->hints);
    XSetWMNormalHints(XtDisplay(xw), VShellWindow(xw), &xw->hints);
    TRACE(("%s@%d -- ", __FILE__, __LINE__));
    TRACE_WM_HINTS(xw);

    if ((pid_atom = XInternAtom(XtDisplay(xw), "_NET_WM_PID", False)) != None) {
	/* XChangeProperty format 32 really is "long" */
	unsigned long pid_l = (unsigned long) getpid();
	TRACE(("Setting _NET_WM_PID property to %lu\n", pid_l));
	XChangeProperty(XtDisplay(xw), VShellWindow(xw),
			pid_atom, XA_CARDINAL, 32, PropModeReplace,
			(unsigned char *) &pid_l, 1);
    }

    XFlush(XtDisplay(xw));	/* get it out to window manager */

    /* use ForgetGravity instead of SouthWestGravity because translating
       the Expose events for ConfigureNotifys is too hard */
    values->bit_gravity = (GravityIsNorthWest(xw)
			   ? NorthWestGravity
			   : ForgetGravity);
    screen->fullVwin.window = XtWindow(xw) =
	XCreateWindow(XtDisplay(xw), XtWindow(XtParent(xw)),
		      xw->core.x, xw->core.y,
		      xw->core.width, xw->core.height, BorderWidth(xw),
		      (int) xw->core.depth,
		      InputOutput, CopyFromParent,
		      *valuemask | CWBitGravity, values);
#if OPT_DOUBLE_BUFFER
    screen->fullVwin.drawable = screen->fullVwin.window;

    {
	Window win = screen->fullVwin.window;
	Drawable d;
	int major, minor;
	if (!XdbeQueryExtension(XtDisplay(xw), &major, &minor)) {
	    fprintf(stderr, "XdbeQueryExtension returned zero!\n");
	    exit(3);
	}
	d = XdbeAllocateBackBufferName(XtDisplay(xw), win, XdbeCopied);
	if (d == None) {
	    fprintf(stderr, "Couldn't allocate a back buffer!\n");
	    exit(3);
	}
	screen->fullVwin.drawable = d;
	screen->needSwap = 1;
    }
#endif /* OPT_DOUBLE_BUFFER */
    screen->event_mask = values->event_mask;

#ifndef NO_ACTIVE_ICON
    /*
     * Normally, the font-number for icon fonts does not correspond with any of
     * the menu-selectable fonts.  If we cannot load the font given for the
     * iconFont resource, try with font1 aka "Unreadable".
     */
    screen->icon_fontnum = -1;
    if (getIconicFont(screen)->fs == 0) {
	getIconicFont(screen)->fs =
	    XLoadQueryFont(screen->display,
			   screen->MenuFontName(fontMenu_font1));
	TRACE(("%susing font1 '%s' as iconFont\n",
	       (getIconicFont(screen)->fs
		? ""
		: "NOT "),
	       screen->MenuFontName(fontMenu_font1)));
    }
#if OPT_RENDERFONT
    /*
     * If we still have no result from iconFont resource (perhaps because fonts
     * are missing) but are using Xft, try to use that instead.  We prefer
     * bitmap fonts in any case, since scaled fonts are usually less readable,
     * particularly at small sizes.
     */
    if (UsingRenderFont(xw)
	&& getIconicFont(screen)->fs == 0) {
	screen->icon_fontnum = fontMenu_default;
	getIconicFont(screen)->fs = getNormalFont(screen, fNorm)->fs;	/* need for next-if */
	TRACE(("using TrueType font as iconFont\n"));
    }
#endif
    if ((xw->work.active_icon == eiDefault) && getIconicFont(screen)->fs) {
	char *wm_name = getWindowManagerName(xw);
	if (x_strncasecmp(wm_name, "fvwm", 4) &&
	    x_strncasecmp(wm_name, "window maker", 12))
	    xw->work.active_icon = eiFalse;
	free(wm_name);
    }
    if (xw->work.active_icon && getIconicFont(screen)->fs) {
	int iconX = 0, iconY = 0;
	Widget shell = SHELL_OF(xw);
	VTwin *win = &(screen->iconVwin);
	int save_fontnum = screen->menu_font_number;

	TRACE(("Initializing active-icon %d\n", screen->icon_fontnum));
	screen->menu_font_number = screen->icon_fontnum;
	XtVaGetValues(shell,
		      XtNiconX, &iconX,
		      XtNiconY, &iconY,
		      (XtPointer) 0);
	xtermComputeFontInfo(xw, &(screen->iconVwin),
			     getIconicFont(screen)->fs, 0);
	screen->menu_font_number = save_fontnum;

	/* since only one client is permitted to select for Button
	 * events, we have to let the window manager get 'em...
	 */
	values->event_mask &= ~(ButtonPressMask | ButtonReleaseMask);
	values->border_pixel = xw->misc.icon_border_pixel;

	screen->iconVwin.window =
	    XCreateWindow(XtDisplay(xw),
			  RootWindowOfScreen(XtScreen(shell)),
			  iconX, iconY,
			  screen->iconVwin.fullwidth,
			  screen->iconVwin.fullheight,
			  xw->misc.icon_border_width,
			  (int) xw->core.depth,
			  InputOutput, CopyFromParent,
			  *valuemask | CWBitGravity | CWBorderPixel,
			  values);
#if OPT_DOUBLE_BUFFER
	screen->iconVwin.drawable = screen->iconVwin.window;
#endif
	XtVaSetValues(shell,
		      XtNiconWindow, screen->iconVwin.window,
		      (XtPointer) 0);
	XtRegisterDrawable(XtDisplay(xw), screen->iconVwin.window, w);

	setCgsFont(xw, win, gcNorm, getIconicFont(screen));
	setCgsFore(xw, win, gcNorm, T_COLOR(screen, TEXT_FG));
	setCgsBack(xw, win, gcNorm, T_COLOR(screen, TEXT_BG));

	copyCgs(xw, win, gcBold, gcNorm);

	setCgsFont(xw, win, gcNormReverse, getIconicFont(screen));
	setCgsFore(xw, win, gcNormReverse, T_COLOR(screen, TEXT_BG));
	setCgsBack(xw, win, gcNormReverse, T_COLOR(screen, TEXT_FG));

	copyCgs(xw, win, gcBoldReverse, gcNormReverse);

#if OPT_TOOLBAR
	/*
	 * Toolbar is initialized before we get here.  Enable the menu item
	 * and set it properly.
	 */
	SetItemSensitivity(vtMenuEntries[vtMenu_activeicon].widget, True);
	update_activeicon();
#endif
    } else {
	TRACE(("Disabled active-icon\n"));
	xw->work.active_icon = eiFalse;
    }
#endif /* NO_ACTIVE_ICON */

#if OPT_I18N_SUPPORT && OPT_INPUT_METHOD
    VTInitI18N(xw);
#endif
#if OPT_NUM_LOCK
    VTInitModifiers(xw);
#if OPT_EXTRA_PASTE
    if (xw->keyboard.extra_translations) {
	XtOverrideTranslations((Widget) xw,
			       XtParseTranslationTable(xw->keyboard.extra_translations));
    }
#endif
#endif

    set_cursor_gcs(xw);

    /* Reset variables used by ANSI emulation. */

    resetCharsets(screen);

    XDefineCursor(screen->display, VShellWindow(xw), screen->pointer_cursor);

    set_cur_col(screen, 0);
    set_cur_row(screen, 0);
    set_max_col(screen, Width(screen) / screen->fullVwin.f_width - 1);
    set_max_row(screen, Height(screen) / screen->fullVwin.f_height - 1);
    reset_margins(screen);

    memset(screen->sc, 0, sizeof(screen->sc));

    /* Mark screen buffer as unallocated.  We wait until the run loop so
       that the child process does not fork and exec with all the dynamic
       memory it will never use.  If we were to do it here, the
       swap space for new process would be huge for huge savelines. */
#if OPT_TEK4014
    if (!tekWidget)		/* if not called after fork */
#endif
    {
	screen->visbuf = NULL;
	screen->saveBuf_index = NULL;
    }

    ResetWrap(screen);
    screen->scrolls = screen->incopy = 0;
    xtermSetCursorBox(screen);

    screen->savedlines = 0;

    for (i = 0; i < 2; ++i) {
	screen->whichBuf = !screen->whichBuf;
	CursorSave(xw);
    }

#ifndef NO_ACTIVE_ICON
    if (!xw->work.active_icon)
#endif
	xtermLoadIcon(xw);

    /*
     * Do this last, since it may change the layout via a resize.
     */
    if (xw->misc.scrollbar) {
	screen->fullVwin.sb_info.width = 0;
	ScrollBarOn(xw, False);
    }

    xtermSetWinSize(xw);
    TRACE(("}} VTRealize\n"));
}

#if OPT_I18N_SUPPORT && OPT_INPUT_METHOD

/* limit this feature to recent XFree86 since X11R6.x core dumps */
#if defined(XtSpecificationRelease) && XtSpecificationRelease >= 6 && defined(X_HAVE_UTF8_STRING)
#define USE_XIM_INSTANTIATE_CB

static void
xim_instantiate_cb(Display *display,
		   XPointer client_data GCC_UNUSED,
		   XPointer call_data GCC_UNUSED)
{
    TRACE(("xim_instantiate_cb client=%p, call=%p\n", client_data, call_data));

    if (display == XtDisplay(term)) {
	VTInitI18N(term);
    }
}

static void
xim_destroy_cb(XIM im GCC_UNUSED,
	       XPointer client_data GCC_UNUSED,
	       XPointer call_data GCC_UNUSED)
{
    XtermWidget xw = term;
    TInput *input = lookupTInput(xw, (Widget) xw);

    TRACE(("xim_destroy_cb im=%lx, client=%p, call=%p\n",
	   (long) im, client_data, call_data));
    if (input)
	input->xic = NULL;
    XRegisterIMInstantiateCallback(XtDisplay(xw), NULL, NULL, NULL,
				   xim_instantiate_cb, NULL);
}
#endif /* X11R6+ */

static Boolean
xim_create_fs(XtermWidget xw)
{
    XFontStruct **fonts;
    char **font_name_list;
    char **missing_charset_list;
    char *def_string;
    int missing_charset_count;
    unsigned i, j;

    if (xw->work.xim_fs == 0) {
	xw->work.xim_fs = XCreateFontSet(XtDisplay(xw),
					 xw->misc.f_x,
					 &missing_charset_list,
					 &missing_charset_count,
					 &def_string);
	if (xw->work.xim_fs == NULL) {
	    xtermWarning("Preparation of font set "
			 "\"%s\" for XIM failed.\n", xw->misc.f_x);
	    xw->work.xim_fs = XCreateFontSet(XtDisplay(xw),
					     DEFXIMFONT,
					     &missing_charset_list,
					     &missing_charset_count,
					     &def_string);
	}
    }
    if (xw->work.xim_fs == NULL) {
	xtermWarning("Preparation of default font set "
		     "\"%s\" for XIM failed.\n", DEFXIMFONT);
	cleanupInputMethod(xw);
	xw->work.cannot_im = True;
    } else {
	(void) XExtentsOfFontSet(xw->work.xim_fs);
	j = (unsigned) XFontsOfFontSet(xw->work.xim_fs, &fonts, &font_name_list);
	for (i = 0, xw->work.xim_fs_ascent = 0; i < j; i++) {
	    if (xw->work.xim_fs_ascent < (*fonts)->ascent)
		xw->work.xim_fs_ascent = (*fonts)->ascent;
	}
    }
    return (Boolean) !(xw->work.cannot_im);
}

static void
xim_create_xic(XtermWidget xw, Widget theInput)
{
    Display *myDisplay = XtDisplay(theInput);
    Window myWindow = XtWindow(theInput);
    unsigned i, j;
    char *p = NULL, *s, *t, *ns, *end, buf[32];
    XIMStyles *xim_styles;
    XIMStyle input_style = 0;
    Bool found;
    static struct {
	const char *name;
	unsigned long code;
    } known_style[] = {
	{
	    "OverTheSpot", (XIMPreeditPosition | XIMStatusNothing)
	},
	{
	    "OffTheSpot", (XIMPreeditArea | XIMStatusArea)
	},
	{
	    "Root", (XIMPreeditNothing | XIMStatusNothing)
	},
    };
    TInput *input = lookupTInput(xw, theInput);

    if (xw->work.cannot_im) {
	return;
    }

    if (input == 0) {
	for (i = 0; i < NINPUTWIDGETS; ++i) {
	    if (xw->work.inputs[i].w == 0) {
		input = xw->work.inputs + i;
		input->w = theInput;
		break;
	    }
	}
    }

    if (input == 0) {
	xtermWarning("attempted to add too many input widgets\n");
	return;
    }

    TRACE(("xim_real_init\n"));

    if (IsEmpty(xw->misc.input_method)) {
	if ((p = XSetLocaleModifiers("")) != NULL && *p) {
	    input->xim = XOpenIM(myDisplay, NULL, NULL, NULL);
	}
    } else {
	s = xw->misc.input_method;
	i = 5 + (unsigned) strlen(s);

	t = (char *) MyStackAlloc(i, buf);
	if (t == NULL) {
	    SysError(ERROR_VINIT);
	} else {

	    for (ns = s; ns && *s;) {
		while (*s && isspace(CharOf(*s)))
		    s++;
		if (!*s)
		    break;
		if ((ns = end = strchr(s, ',')) == 0)
		    end = s + strlen(s);
		while ((end != s) && isspace(CharOf(end[-1])))
		    end--;

		if (end != s) {
		    strcpy(t, "@im=");
		    strncat(t, s, (size_t) (end - s));

		    if ((p = XSetLocaleModifiers(t)) != 0 && *p
			&& (input->xim = XOpenIM(myDisplay,
						 NULL,
						 NULL,
						 NULL)) != 0) {
			break;
		    }

		}
		s = ns + 1;
	    }
	    MyStackFree(t, buf);
	}
    }

    if (input->xim == NULL
	&& (p = XSetLocaleModifiers("@im=none")) != NULL
	&& *p) {
	input->xim = XOpenIM(myDisplay, NULL, NULL, NULL);
    }

    if (!input->xim) {
	xtermWarning("Failed to open input method\n");
	return;
    }
    TRACE(("VTInitI18N opened input method:%s\n", NonNull(p)));

    if (XGetIMValues(input->xim, XNQueryInputStyle, &xim_styles, (void *) 0)
	|| !xim_styles
	|| !xim_styles->count_styles) {
	xtermWarning("input method doesn't support any style\n");
	cleanupInputMethod(xw);
	xw->work.cannot_im = True;
	return;
    }

    found = False;
    for (s = xw->misc.preedit_type; s && !found;) {
	while (*s && isspace(CharOf(*s)))
	    s++;
	if (!*s)
	    break;
	if ((ns = end = strchr(s, ',')) != 0)
	    ns++;
	else
	    end = s + strlen(s);
	while ((end != s) && isspace(CharOf(end[-1])))
	    end--;

	if (end != s) {		/* just in case we have a spurious comma */
	    TRACE(("looking for style '%.*s'\n", (int) (end - s), s));
	    for (i = 0; i < XtNumber(known_style); i++) {
		if ((int) strlen(known_style[i].name) == (end - s)
		    && !strncmp(s, known_style[i].name, (size_t) (end - s))) {
		    input_style = known_style[i].code;
		    for (j = 0; j < xim_styles->count_styles; j++) {
			if (input_style == xim_styles->supported_styles[j]) {
			    found = True;
			    break;
			}
		    }
		    if (found)
			break;
		}
	    }
	}

	s = ns;
    }
    XFree(xim_styles);

    if (!found) {
	xtermWarning("input method doesn't support my preedit type (%s)\n",
		     xw->misc.preedit_type);
	cleanupInputMethod(xw);
	xw->work.cannot_im = True;
	return;
    }

    /*
     * Check for styles we do not yet support.
     */
    TRACE(("input_style %#lx\n", input_style));
    if (input_style == (XIMPreeditArea | XIMStatusArea)) {
	xtermWarning("This program doesn't support the 'OffTheSpot' preedit type\n");
	cleanupInputMethod(xw);
	xw->work.cannot_im = True;
	return;
    }

    /*
     * For XIMPreeditPosition (or OverTheSpot), XIM client has to
     * prepare a font.
     * The font has to be locale-dependent XFontSet, whereas
     * XTerm use Unicode font.  This leads a problem that the
     * same font cannot be used for XIM preedit.
     */
    if (input_style != (XIMPreeditNothing | XIMStatusNothing)) {
	XVaNestedList p_list;
	XPoint spot =
	{0, 0};

	if (xim_create_fs(xw)) {
	    p_list = XVaCreateNestedList(0,
					 XNSpotLocation, &spot,
					 XNFontSet, xw->work.xim_fs,
					 (void *) 0);
	    input->xic = XCreateIC(input->xim,
				   XNInputStyle, input_style,
				   XNClientWindow, myWindow,
				   XNFocusWindow, myWindow,
				   XNPreeditAttributes, p_list,
				   (void *) 0);
	}
    } else {
	input->xic = XCreateIC(input->xim, XNInputStyle, input_style,
			       XNClientWindow, myWindow,
			       XNFocusWindow, myWindow,
			       (void *) 0);
    }

    if (!input->xic) {
	xtermWarning("Failed to create input context\n");
	cleanupInputMethod(xw);
    }
#if defined(USE_XIM_INSTANTIATE_CB)
    else {
	XIMCallback destroy_cb;

	destroy_cb.callback = xim_destroy_cb;
	destroy_cb.client_data = NULL;
	if (XSetIMValues(input->xim,
			 XNDestroyCallback,
			 &destroy_cb,
			 (void *) 0)) {
	    xtermWarning("Could not set destroy callback to IM\n");
	}
    }
#endif

    return;
}

static void
xim_real_init(XtermWidget xw)
{
    xim_create_xic(xw, (Widget) xw);
}

static void
VTInitI18N(XtermWidget xw)
{
    if (xw->misc.open_im) {
	xim_real_init(xw);

#if defined(USE_XIM_INSTANTIATE_CB)
	if (lookupTInput(xw, (Widget) xw) == NULL
	    && !xw->work.cannot_im
	    && xw->misc.retry_im-- > 0) {
	    sleep(3);
	    XRegisterIMInstantiateCallback(XtDisplay(xw), NULL, NULL, NULL,
					   xim_instantiate_cb, NULL);
	}
#endif
    }
}

TInput *
lookupTInput(XtermWidget xw, Widget w)
{
    TInput *result = 0;
    unsigned n;

    for (n = 0; n < NINPUTWIDGETS; ++n) {
	if (xw->work.inputs[n].w == w) {
	    result = xw->work.inputs + n;
	    break;
	}
    }

    return result;
}
#endif /* OPT_I18N_SUPPORT && OPT_INPUT_METHOD */

static void
set_cursor_outline_gc(XtermWidget xw,
		      Bool filled,
		      Pixel fg,
		      Pixel bg,
		      Pixel cc)
{
    TScreen *screen = TScreenOf(xw);
    VTwin *win = WhichVWin(screen);
    CgsEnum cgsId = gcVTcursOutline;

    if (cc == bg)
	cc = fg;

    if (filled) {
	setCgsFore(xw, win, cgsId, bg);
	setCgsBack(xw, win, cgsId, cc);
    } else {
	setCgsFore(xw, win, cgsId, cc);
	setCgsBack(xw, win, cgsId, bg);
    }
}

static Boolean
VTSetValues(Widget cur,
	    Widget request GCC_UNUSED,
	    Widget wnew,
	    ArgList args GCC_UNUSED,
	    Cardinal *num_args GCC_UNUSED)
{
    XtermWidget curvt = (XtermWidget) cur;
    XtermWidget newvt = (XtermWidget) wnew;
    Boolean refresh_needed = False;
    Boolean fonts_redone = False;

    if ((T_COLOR(TScreenOf(curvt), TEXT_BG) !=
	 T_COLOR(TScreenOf(newvt), TEXT_BG)) ||
	(T_COLOR(TScreenOf(curvt), TEXT_FG) !=
	 T_COLOR(TScreenOf(newvt), TEXT_FG)) ||
	(TScreenOf(curvt)->MenuFontName(TScreenOf(curvt)->menu_font_number) !=
	 TScreenOf(newvt)->MenuFontName(TScreenOf(newvt)->menu_font_number)) ||
	strcmp(DefaultFontN(curvt), DefaultFontN(newvt))) {
	if (strcmp(DefaultFontN(curvt), DefaultFontN(newvt))) {
	    TScreenOf(newvt)->MenuFontName(fontMenu_default) = DefaultFontN(newvt);
	}
	if (xtermLoadFont(newvt,
			  xtermFontName(TScreenOf(newvt)->MenuFontName(TScreenOf(curvt)->menu_font_number)),
			  True, TScreenOf(newvt)->menu_font_number)) {
	    /* resizing does the redisplay, so don't ask for it here */
	    refresh_needed = True;
	    fonts_redone = True;
	} else if (strcmp(DefaultFontN(curvt), DefaultFontN(newvt))) {
	    TScreenOf(newvt)->MenuFontName(fontMenu_default) = DefaultFontN(curvt);
	}
    }
    if (!fonts_redone
	&& (T_COLOR(TScreenOf(curvt), TEXT_CURSOR) !=
	    T_COLOR(TScreenOf(newvt), TEXT_CURSOR))) {
	if (set_cursor_gcs(newvt))
	    refresh_needed = True;
    }
    if (curvt->misc.re_verse != newvt->misc.re_verse) {
	newvt->flags ^= REVERSE_VIDEO;
	ReverseVideo(newvt);
	/* ReverseVideo toggles */
	newvt->misc.re_verse = (Boolean) (!newvt->misc.re_verse);
	refresh_needed = True;
    }
    if ((T_COLOR(TScreenOf(curvt), MOUSE_FG) !=
	 T_COLOR(TScreenOf(newvt), MOUSE_FG)) ||
	(T_COLOR(TScreenOf(curvt), MOUSE_BG) !=
	 T_COLOR(TScreenOf(newvt), MOUSE_BG))) {
	recolor_cursor(TScreenOf(newvt),
		       TScreenOf(newvt)->pointer_cursor,
		       T_COLOR(TScreenOf(newvt), MOUSE_FG),
		       T_COLOR(TScreenOf(newvt), MOUSE_BG));
	refresh_needed = True;
    }
    if (curvt->misc.scrollbar != newvt->misc.scrollbar) {
	ToggleScrollBar(newvt);
    }

    return refresh_needed;
}

/*
 * Given a font-slot and information about selection/reverse, find the
 * corresponding cached-GC slot.
 */
static int
reverseCgs(XtermWidget xw, unsigned attr_flags, Bool hilite, int font)
{
    TScreen *screen = TScreenOf(xw);
    CgsEnum result = gcMAX;

    if (ReverseOrHilite(screen, attr_flags, hilite)) {
	switch (font) {
	case fNorm:
	    result = gcNormReverse;
	    break;
	case fBold:
	    result = gcBoldReverse;
	    break;
#if OPT_WIDE_ATTRS || OPT_RENDERWIDE
	case fItal:
	    result = gcNormReverse;	/* FIXME */
	    break;
#endif
#if OPT_WIDE_CHARS
	case fWide:
	    result = gcWideReverse;
	    break;
	case fWBold:
	    result = gcWBoldReverse;
	    break;
	case fWItal:
	    result = gcWideReverse;	/* FIXME */
	    break;
#endif
	}
    } else {
	switch (font) {
	case fNorm:
	    result = gcNorm;
	    break;
	case fBold:
	    result = gcBold;
	    break;
#if OPT_WIDE_ATTRS || OPT_RENDERWIDE
	case fItal:
	    result = gcNorm;	/* FIXME */
	    break;
#endif
#if OPT_WIDE_CHARS
	case fWide:
	    result = gcWide;
	    break;
	case fWBold:
	    result = gcWBold;
	    break;
	case fWItal:
	    result = gcWide;	/* FIXME */
	    break;
#endif
	}
    }
    return result;
}

#define setGC(code) set_at = __LINE__, currentCgs = code

#define OutsideSelection(screen,srow,scol)  \
	 ((srow) > (screen)->endH.row || \
	  ((srow) == (screen)->endH.row && \
	   (scol) >= (screen)->endH.col) || \
	  (srow) < (screen)->startH.row || \
	  ((srow) == (screen)->startH.row && \
	   (scol) < (screen)->startH.col))

/*
 * Shows cursor at new cursor position in screen.
 */
void
ShowCursor(void)
{
    XtermWidget xw = term;
    TScreen *screen = TScreenOf(xw);
    IChar base;
    unsigned flags;
    CellColor fg_bg = 0;
    GC currentGC;
    GC outlineGC;
    CgsEnum currentCgs = gcMAX;
    VTwin *currentWin = WhichVWin(screen);
    int set_at;
    Bool in_selection;
    Bool reversed;
    Bool filled;
    Pixel fg_pix;
    Pixel bg_pix;
    Pixel tmp;
#if OPT_HIGHLIGHT_COLOR
    Pixel selbg_pix = T_COLOR(screen, HIGHLIGHT_BG);
    Pixel selfg_pix = T_COLOR(screen, HIGHLIGHT_FG);
    Boolean use_selbg;
    Boolean use_selfg;
#endif
#if OPT_WIDE_CHARS
    int my_col = 0;
#endif
    int cursor_col;
    CLineData *ld = 0;

    if (screen->cursor_state == BLINKED_OFF)
	return;

    if (screen->eventMode != NORMAL)
	return;

    if (INX2ROW(screen, screen->cur_row) > screen->max_row)
	return;

    screen->cursorp.row = screen->cur_row;
    cursor_col = screen->cursorp.col = screen->cur_col;
    screen->cursor_moved = False;

#ifndef NO_ACTIVE_ICON
    if (IsIcon(screen)) {
	screen->cursor_state = ON;
	return;
    }
#endif /* NO_ACTIVE_ICON */

    ld = getLineData(screen, screen->cur_row);

    base = ld->charData[cursor_col];
    flags = ld->attribs[cursor_col];

    if_OPT_WIDE_CHARS(screen, {
	if (base == HIDDEN_CHAR && cursor_col > 0) {
	    /* if cursor points to non-initial part of wide character,
	     * back it up
	     */
	    --cursor_col;
	    base = ld->charData[cursor_col];
	}
	my_col = cursor_col;
	if (base == 0)
	    base = ' ';
	if (isWide((int) base))
	    my_col += 1;
    });

    if (base == 0) {
	base = ' ';
    }
#if OPT_ISO_COLORS
#ifdef EXP_BOGUS_FG
    /*
     * If the cursor happens to be on blanks, and we have not set both
     * foreground and background color, do not treat it as a colored cell.
     */
    if (base == ' ') {
	if ((flags & (FG_COLOR | BG_COLOR)) == BG_COLOR) {
	    TRACE(("ShowCursor - do not treat as a colored cell\n"));
	    flags &= ~(FG_COLOR | BG_COLOR);
	} else if ((flags & (FG_COLOR | BG_COLOR)) == FG_COLOR) {
	    TRACE(("ShowCursor - should we treat as a colored cell?\n"));
	    if (!(xw->flags & FG_COLOR))
		if (CheckBogusForeground(screen, "ShowCursor"))
		    flags &= ~(FG_COLOR | BG_COLOR);
	}
    }
#else /* !EXP_BOGUS_FG */
    /*
     * If the cursor happens to be on blanks, and the foreground color is set
     * but not the background, do not treat it as a colored cell.
     */
    if ((flags & TERM_COLOR_FLAGS(xw)) == FG_COLOR
	&& base == ' ') {
	flags &= ~TERM_COLOR_FLAGS(xw);
    }
#endif
#endif

    /*
     * Compare the current cell to the last set of colors used for the
     * cursor and update the GC's if needed.
     */
    if_OPT_ISO_COLORS(screen, {
	fg_bg = ld->color[cursor_col];
    });

    fg_pix = getXtermForeground(xw, flags, (int) extract_fg(xw, fg_bg, flags));
    bg_pix = getXtermBackground(xw, flags, (int) extract_bg(xw, fg_bg, flags));

    /*
     * If we happen to have the same foreground/background colors, choose
     * a workable foreground color from which we can obtain a visible cursor.
     */
    if (fg_pix == bg_pix) {
	long bg_diff = (long) (bg_pix - T_COLOR(TScreenOf(xw), TEXT_BG));
	long fg_diff = (long) (bg_pix - T_COLOR(TScreenOf(xw), TEXT_FG));
	if (bg_diff < 0)
	    bg_diff = -bg_diff;
	if (fg_diff < 0)
	    fg_diff = -fg_diff;
	if (bg_diff < fg_diff) {
	    fg_pix = T_COLOR(TScreenOf(xw), TEXT_FG);
	} else {
	    fg_pix = T_COLOR(TScreenOf(xw), TEXT_BG);
	}
    }

    if (OutsideSelection(screen, screen->cur_row, screen->cur_col))
	in_selection = False;
    else
	in_selection = True;

    reversed = ReverseOrHilite(screen, flags, in_selection);

    /* This is like updatedXtermGC(), except that we have to worry about
     * whether the window has focus, since in that case we want just an
     * outline for the cursor.
     */
    filled = (screen->select || screen->always_highlight) && isCursorBlock(screen);
#if OPT_HIGHLIGHT_COLOR
    use_selbg = isNotForeground(xw, fg_pix, bg_pix, selbg_pix);
    use_selfg = isNotBackground(xw, fg_pix, bg_pix, selfg_pix);
#endif
    if (filled) {
	if (reversed) {		/* text is reverse video */
	    if (getCgsGC(xw, currentWin, gcVTcursNormal)) {
		setGC(gcVTcursNormal);
	    } else {
		if (flags & BOLDATTR(screen)) {
		    setGC(gcBold);
		} else {
		    setGC(gcNorm);
		}
	    }
	    EXCHANGE(fg_pix, bg_pix, tmp);
#if OPT_HIGHLIGHT_COLOR
	    if (screen->hilite_reverse) {
		if (use_selbg && !use_selfg)
		    fg_pix = bg_pix;
		if (use_selfg && !use_selbg)
		    bg_pix = fg_pix;
		if (use_selbg)
		    bg_pix = selbg_pix;
		if (use_selfg)
		    fg_pix = selfg_pix;
	    }
#endif
	} else {		/* normal video */
	    if (getCgsGC(xw, currentWin, gcVTcursReverse)) {
		setGC(gcVTcursReverse);
	    } else {
		if (flags & BOLDATTR(screen)) {
		    setGC(gcBoldReverse);
		} else {
		    setGC(gcNormReverse);
		}
	    }
	}

#define CUR_XX T_COLOR(screen, TEXT_CURSOR)
#define CGS_FG getCgsFore(xw, currentWin, getCgsGC(xw, currentWin, currentCgs))
#define CGS_BG getCgsBack(xw, currentWin, getCgsGC(xw, currentWin, currentCgs))

#define FIX_311 (CUR_XX == (reversed ? xw->dft_background : xw->dft_foreground))
#define FIX_328 (CUR_XX == bg_pix)
#define FIX_330 (FIX_328 && reversed && in_selection)

	if (FIX_330 || FIX_311) {
	    setCgsBack(xw, currentWin, currentCgs, fg_pix);
	}
	setCgsFore(xw, currentWin, currentCgs, bg_pix);
    } else {			/* not selected */
	if (reversed) {		/* text is reverse video */
	    EXCHANGE(fg_pix, bg_pix, tmp);
	    setGC(gcNormReverse);
	} else {		/* normal video */
	    setGC(gcNorm);
	}
#if OPT_HIGHLIGHT_COLOR
	if (screen->hilite_reverse) {
	    if (in_selection && !reversed) {
		/* EMPTY */
		/* really INVERSE ... */
		;
	    } else if (in_selection || reversed) {
		if (use_selbg) {
		    if (use_selfg) {
			bg_pix = fg_pix;
		    } else {
			fg_pix = bg_pix;
		    }
		}
		if (use_selbg) {
		    bg_pix = selbg_pix;
		}
		if (use_selfg) {
		    fg_pix = selfg_pix;
		}
	    }
	} else {
	    if (in_selection) {
		if (use_selbg) {
		    bg_pix = selbg_pix;
		}
		if (use_selfg) {
		    fg_pix = selfg_pix;
		}
	    }
	}
#endif
	setCgsFore(xw, currentWin, currentCgs, fg_pix);
	setCgsBack(xw, currentWin, currentCgs, bg_pix);
    }

    if (screen->cursor_busy == 0
	&& (screen->cursor_state != ON || screen->cursor_GC != set_at)) {
	int x, y;

	screen->cursor_GC = set_at;
	TRACE(("ShowCursor calling drawXtermText cur(%d,%d) %s-%s, set_at %d\n",
	       screen->cur_row, screen->cur_col,
	       (filled ? "filled" : "outline"),
	       (isCursorBlock(screen) ? "box" :
		isCursorUnderline(screen) ? "underline" : "bar"),
	       set_at));

	currentGC = getCgsGC(xw, currentWin, currentCgs);
	x = LineCursorX(screen, ld, cursor_col);
	y = CursorY(screen, screen->cur_row);

	if (!isCursorBlock(screen)) {
	    /*
	     * Overriding the combination of filled, reversed, in_selection is
	     * too complicated since the underline or bar and the text-cell use
	     * different rules.  Just redraw the text-cell, and draw the
	     * underline or bar on top of it.
	     */
	    HideCursor();

	    /*
	     * Our current-GC is likely to have been modified in HideCursor().
	     * Set up a new request.
	     */
	    if (filled) {
		if (FIX_330 || FIX_311) {
		    setCgsBack(xw, currentWin, currentCgs, fg_pix);
		}
		setCgsFore(xw, currentWin, currentCgs, bg_pix);
	    } else {
		setCgsFore(xw, currentWin, currentCgs, fg_pix);
		setCgsBack(xw, currentWin, currentCgs, bg_pix);
	    }
	}

	/*
	 * Update the outline-gc, to keep the cursor color distinct from the
	 * background color.
	 */
	set_cursor_outline_gc(xw,
			      filled,
			      fg_pix,
			      bg_pix,
			      T_COLOR(screen, TEXT_CURSOR));

	outlineGC = getCgsGC(xw, currentWin, gcVTcursOutline);
	if (outlineGC == 0)
	    outlineGC = currentGC;

	if (isCursorUnderline(screen)) {

	    /*
	     * Finally, draw the underline.
	     */
	    screen->box->x = (short) x;
	    screen->box->y = (short) (y + FontHeight(screen) - 2);
	    XDrawLines(screen->display, VDrawable(screen), outlineGC,
		       screen->box, NBOX, CoordModePrevious);
	} else if (isCursorBar(screen)) {

	    /*
	     * Or draw the bar.
	     */
	    screen->box->x = (short) x;
	    screen->box->y = (short) y;
	    XDrawLines(screen->display, VWindow(screen), outlineGC,
		       screen->box, NBOX, CoordModePrevious);
	} else {
#if OPT_WIDE_ATTRS
	    int italics_on = ((ld->attribs[cursor_col] & ATR_ITALIC) != 0);
	    int italics_off = ((xw->flags & ATR_ITALIC) != 0);
	    int fix_italics = (italics_on != italics_off);
	    int which_font = ((xw->flags & BOLD) ? fBold : fNorm);

	    if_OPT_WIDE_CHARS(screen, {
		if (isWide((int) base)) {
		    which_font = ((xw->flags & BOLD) ? fWBold : fWide);
		}
	    });

	    if (fix_italics && UseItalicFont(screen)) {
		xtermLoadItalics(xw);
		if (italics_on) {
		    setCgsFont(xw, currentWin, currentCgs,
			       getItalicFont(screen, which_font));
		} else {
		    setCgsFont(xw, currentWin, currentCgs,
			       getNormalFont(screen, which_font));
		}
	    }
	    currentGC = getCgsGC(xw, currentWin, currentCgs);
#endif /* OPT_WIDE_ATTRS */

	    drawXtermText(xw,
			  flags & DRAWX_MASK,
			  0,
			  currentGC, x, y,
			  LineCharSet(screen, ld),
			  &base, 1, 0);

#if OPT_WIDE_CHARS
	    if_OPT_WIDE_CHARS(screen, {
		size_t off;
		for_each_combData(off, ld) {
		    if (!(ld->combData[off][my_col]))
			break;
		    drawXtermText(xw,
				  (flags & DRAWX_MASK),
				  NOBACKGROUND,
				  currentGC, x, y,
				  LineCharSet(screen, ld),
				  ld->combData[off] + my_col,
				  1, isWide((int) base));
		}
	    });
#endif

	    if (!filled) {
		screen->box->x = (short) x;
		screen->box->y = (short) y;
		XDrawLines(screen->display, VDrawable(screen), outlineGC,
			   screen->box, NBOX, CoordModePrevious);
	    }
#if OPT_WIDE_ATTRS
	    if (fix_italics && UseItalicFont(screen)) {
		if (italics_on) {
		    setCgsFont(xw, currentWin, currentCgs,
			       getNormalFont(screen, which_font));
		} else {
		    setCgsFont(xw, currentWin, currentCgs,
			       getItalicFont(screen, which_font));
		}
	    }
#endif
	}
    }
    screen->cursor_state = ON;

    return;
}

/*
 * hide cursor at previous cursor position in screen.
 */
void
HideCursor(void)
{
    XtermWidget xw = term;
    TScreen *screen = TScreenOf(xw);
    GC currentGC;
    int x, y;
    IChar base;
    unsigned flags;
    CellColor fg_bg = 0;
    Bool in_selection;
#if OPT_WIDE_CHARS
    int my_col = 0;
#endif
    int cursor_col;
    CLineData *ld = 0;
#if OPT_WIDE_ATTRS
    int which_Cgs = gcMAX;
    unsigned attr_flags;
    int which_font = fNorm;
#endif

    if (screen->cursor_state == OFF)
	return;
    if (INX2ROW(screen, screen->cursorp.row) > screen->max_row)
	return;

    cursor_col = screen->cursorp.col;

#ifndef NO_ACTIVE_ICON
    if (IsIcon(screen)) {
	screen->cursor_state = OFF;
	return;
    }
#endif /* NO_ACTIVE_ICON */

    ld = getLineData(screen, screen->cursorp.row);

    base = ld->charData[cursor_col];
    flags = ld->attribs[cursor_col];

    if_OPT_WIDE_CHARS(screen, {
	if (base == HIDDEN_CHAR && cursor_col > 0) {
	    /* if cursor points to non-initial part of wide character,
	     * back it up
	     */
	    --cursor_col;
	    base = ld->charData[cursor_col];
	}
	my_col = cursor_col;
	if (base == 0)
	    base = ' ';
	if (isWide((int) base))
	    my_col += 1;
    });

    if (base == 0) {
	base = ' ';
    }
#ifdef EXP_BOGUS_FG
    /*
     * If the cursor happens to be on blanks, and we have not set both
     * foreground and background color, do not treat it as a colored cell.
     */
#if OPT_ISO_COLORS
    if (base == ' ') {
	if ((flags & (FG_COLOR | BG_COLOR)) == BG_COLOR) {
	    TRACE(("HideCursor - do not treat as a colored cell\n"));
	    flags &= ~(FG_COLOR | BG_COLOR);
	} else if ((flags & (FG_COLOR | BG_COLOR)) == FG_COLOR) {
	    TRACE(("HideCursor - should we treat as a colored cell?\n"));
	    if (!(xw->flags & FG_COLOR))
		if (CheckBogusForeground(screen, "HideCursor"))
		    flags &= ~(FG_COLOR | BG_COLOR);
	}
    }
#endif
#endif
#if OPT_ISO_COLORS
    fg_bg = 0;
#endif

    /*
     * Compare the current cell to the last set of colors used for the
     * cursor and update the GC's if needed.
     */
    if_OPT_ISO_COLORS(screen, {
	fg_bg = ld->color[cursor_col];
    });

    if (OutsideSelection(screen, screen->cursorp.row, screen->cursorp.col))
	in_selection = False;
    else
	in_selection = True;

#if OPT_WIDE_ATTRS
    attr_flags = ld->attribs[cursor_col];
    if ((attr_flags & ATR_ITALIC) ^ (xw->flags & ATR_ITALIC)) {
	which_font = ((attr_flags & BOLD) ? fBold : fNorm);

	if_OPT_WIDE_CHARS(screen, {
	    if (isWide((int) base)) {
		which_font = ((attr_flags & BOLD) ? fWBold : fWide);
	    }
	});

	which_Cgs = reverseCgs(xw, attr_flags, in_selection, which_font);
	if (which_Cgs != gcMAX) {
	    setCgsFont(xw, WhichVWin(screen),
		       (CgsEnum) which_Cgs,
		       (((attr_flags & ATR_ITALIC) && UseItalicFont(screen))
			? getItalicFont(screen, which_font)
			: getNormalFont(screen, which_font)));
	}
    }
#endif

    currentGC = updatedXtermGC(xw, flags, fg_bg, in_selection);

    TRACE(("HideCursor calling drawXtermText cur(%d,%d)\n",
	   screen->cursorp.row, screen->cursorp.col));

    x = LineCursorX(screen, ld, cursor_col);
    y = CursorY(screen, screen->cursorp.row);

    drawXtermText(xw,
		  flags & DRAWX_MASK,
		  0,
		  currentGC, x, y,
		  LineCharSet(screen, ld),
		  &base, 1, 0);

#if OPT_WIDE_CHARS
    if_OPT_WIDE_CHARS(screen, {
	size_t off;
	for_each_combData(off, ld) {
	    if (!(ld->combData[off][my_col]))
		break;
	    drawXtermText(xw,
			  (flags & DRAWX_MASK),
			  NOBACKGROUND,
			  currentGC, x, y,
			  LineCharSet(screen, ld),
			  ld->combData[off] + my_col,
			  1, isWide((int) base));
	}
    });
#endif
    screen->cursor_state = OFF;

#if OPT_WIDE_ATTRS
    if (which_Cgs != gcMAX) {
	setCgsFont(xw, WhichVWin(screen),
		   (CgsEnum) which_Cgs,
		   (((xw->flags & ATR_ITALIC) && UseItalicFont(screen))
		    ? getItalicFont(screen, which_font)
		    : getNormalFont(screen, which_font)));
    }
#endif
    resetXtermGC(xw, flags, in_selection);

    refresh_displayed_graphics(xw,
			       screen->cursorp.col,
			       screen->cursorp.row,
			       1, 1);

    return;
}

#if OPT_BLINK_CURS || OPT_BLINK_TEXT
static void
StartBlinking(TScreen *screen)
{
    if (screen->blink_timer == 0) {
	unsigned long interval = (unsigned long) ((screen->cursor_state == ON)
						  ? screen->blink_on
						  : screen->blink_off);
	if (interval == 0)	/* wow! */
	    interval = 1;	/* let's humor him anyway */
	screen->blink_timer = XtAppAddTimeOut(app_con,
					      interval,
					      HandleBlinking,
					      screen);
    }
}

static void
StopBlinking(TScreen *screen)
{
    if (screen->blink_timer) {
	XtRemoveTimeOut(screen->blink_timer);
	screen->blink_timer = 0;
	reallyStopBlinking(screen);
    } else {
	screen->blink_timer = 0;
    }
}

#if OPT_BLINK_TEXT
Bool
LineHasBlinking(TScreen *screen, CLineData *ld)
{
    Bool result = False;
    if (ld != 0) {
	int col;

	for (col = 0; col < MaxCols(screen); ++col) {
	    if (ld->attribs[col] & BLINK) {
		result = True;
		break;
	    }
	}
    }
    return result;
}
#endif

/*
 * Blink the cursor by alternately showing/hiding cursor.  We leave the timer
 * running all the time (even though that's a little inefficient) to make the
 * logic simple.
 */
static void
HandleBlinking(XtPointer closure, XtIntervalId * id GCC_UNUSED)
{
    TScreen *screen = (TScreen *) closure;
    Bool resume = False;

    screen->blink_timer = 0;
    screen->blink_state = !screen->blink_state;

#if OPT_BLINK_CURS
    if (DoStartBlinking(screen)) {
	if (screen->cursor_state == ON) {
	    if (screen->select || screen->always_highlight) {
		HideCursor();
		if (screen->cursor_state == OFF)
		    screen->cursor_state = BLINKED_OFF;
	    }
	} else if (screen->cursor_state == BLINKED_OFF) {
	    screen->cursor_state = OFF;
	    ShowCursor();
	    if (screen->cursor_state == OFF)
		screen->cursor_state = BLINKED_OFF;
	}
	resume = True;
    }
#endif

#if OPT_BLINK_TEXT
    /*
     * Inspect the lines on the current screen to see if any have the BLINK flag
     * associated with them.  Prune off any that have had the corresponding
     * cells reset.  If any are left, repaint those lines with ScrnRefresh().
     */
    if (!(screen->blink_as_bold)) {
	int row;
	int first_row = screen->max_row;
	int last_row = -1;

	for (row = screen->max_row; row >= 0; row--) {
	    LineData *ld = getLineData(screen, ROW2INX(screen, row));

	    if (ld != 0 && LineTstBlinked(ld)) {
		if (LineHasBlinking(screen, ld)) {
		    resume = True;
		    if (row > last_row)
			last_row = row;
		    if (row < first_row)
			first_row = row;
		} else {
		    LineClrBlinked(ld);
		}
	    }
	}
	/*
	 * FIXME: this could be a little more efficient, e.g,. by limiting the
	 * columns which are updated.
	 */
	if (first_row <= last_row) {
	    ScrnRefresh(term,
			first_row,
			0,
			last_row + 1 - first_row,
			MaxCols(screen),
			True);
	}
    }
#endif

    /*
     * If either the cursor or text is blinking, restart the timer.
     */
    if (resume)
	StartBlinking(screen);
}
#endif /* OPT_BLINK_CURS || OPT_BLINK_TEXT */

void
RestartBlinking(TScreen *screen GCC_UNUSED)
{
#if OPT_BLINK_CURS || OPT_BLINK_TEXT
    if (screen->blink_timer == 0) {
	Bool resume = False;

#if OPT_BLINK_CURS
	if (DoStartBlinking(screen)) {
	    resume = True;
	}
#endif
#if OPT_BLINK_TEXT
	if (!resume) {
	    int row;

	    for (row = screen->max_row; row >= 0; row--) {
		CLineData *ld = getLineData(screen, ROW2INX(screen, row));

		if (ld != 0 && LineTstBlinked(ld)) {
		    if (LineHasBlinking(screen, ld)) {
			resume = True;
			break;
		    }
		}
	    }
	}
#endif
	if (resume)
	    StartBlinking(screen);
    }
#endif
}

/*
 * Implement soft or hard (full) reset of the VTxxx emulation.  There are a
 * couple of differences from real DEC VTxxx terminals (to avoid breaking
 * applications which have come to rely on xterm doing this):
 *
 *	+ autowrap mode should be reset (instead it's reset to the resource
 *	  default).
 *	+ the popup menu offers a choice of resetting the savedLines, or not.
 *	  (but the control sequence does this anyway).
 */
static void
ReallyReset(XtermWidget xw, Bool full, Bool saved)
{
    TScreen *screen = TScreenOf(xw);

    if (!XtIsRealized((Widget) xw) || (CURRENT_EMU() != (Widget) xw)) {
	Bell(xw, XkbBI_MinorError, 0);
	return;
    }

    if (saved) {
	screen->savedlines = 0;
	ScrollBarDrawThumb(screen->scrollWidget);
    }

    /* make cursor visible */
    screen->cursor_set = ON;
    InitCursorShape(screen, screen);
#if OPT_BLINK_CURS
    TRACE(("cursor_shape:%d blinks:%s\n",
	   screen->cursor_shape,
	   BtoS(screen->cursor_blink)));
#endif

    /* reset scrolling region */
    reset_margins(screen);

    bitclr(&xw->flags, ORIGIN);

    if_OPT_ISO_COLORS(screen, {
	static char empty[1];
	reset_SGR_Colors(xw);
	if (ResetAnsiColorRequest(xw, empty, 0))
	    xtermRepaint(xw);
    });

    /* Reset character-sets to initial state */
    resetCharsets(screen);

#if OPT_MOD_FKEYS
    /* Reset modifier-resources to initial state */
    xw->keyboard.modify_now = xw->keyboard.modify_1st;
#endif

    /* Reset DECSCA */
    bitclr(&xw->flags, PROTECTED);
    screen->protected_mode = OFF_PROTECT;

    reset_displayed_graphics(screen);

    if (full) {			/* RIS */
	if (screen->bellOnReset)
	    Bell(xw, XkbBI_TerminalBell, 0);

	/* reset the mouse mode */
	screen->send_mouse_pos = MOUSE_OFF;
	screen->send_focus_pos = OFF;
	screen->extend_coords = 0;
	screen->waitingForTrackInfo = False;
	screen->eventMode = NORMAL;

	xtermShowPointer(xw, True);

	TabReset(xw->tabs);
	xw->keyboard.flags = MODE_SRM;

	guard_keyboard_type = False;
	screen->old_fkeys = screen->old_fkeys0;
	decode_keyboard_type(xw, &resource);
	update_keyboard_type();

#if OPT_INITIAL_ERASE
	if (xw->keyboard.reset_DECBKM == 1)
	    xw->keyboard.flags |= MODE_DECBKM;
	else if (xw->keyboard.reset_DECBKM == 2)
#endif
	    if (TScreenOf(xw)->backarrow_key)
		xw->keyboard.flags |= MODE_DECBKM;
	TRACE(("full reset DECBKM %s\n",
	       BtoS(xw->keyboard.flags & MODE_DECBKM)));

#if OPT_SCROLL_LOCK
	xtermClearLEDs(screen);
#endif
	screen->title_modes = screen->title_modes0;
	screen->pointer_mode = screen->pointer_mode0;
#if OPT_SIXEL_GRAPHICS
	if (TScreenOf(xw)->sixel_scrolling)
	    xw->keyboard.flags |= MODE_DECSDM;
	TRACE(("full reset DECSDM to %s (resource default is %s)\n",
	       BtoS(xw->keyboard.flags & MODE_DECSDM),
	       BtoS(TScreenOf(xw)->sixel_scrolling)));
#endif

#if OPT_GRAPHICS
	screen->privatecolorregisters = TScreenOf(xw)->privatecolorregisters;
	TRACE(("full reset PRIVATE_COLOR_REGISTERS to %s (resource default is %s)\n",
	       BtoS(screen->privatecolorregisters),
	       BtoS(TScreenOf(xw)->privatecolorregisters)));
#endif

#if OPT_SIXEL_GRAPHICS
	screen->sixel_scrolls_right = TScreenOf(xw)->sixel_scrolls_right;
	TRACE(("full reset SIXEL_SCROLLS_RIGHT to %s (resource default is %s)\n",
	       BtoS(screen->sixel_scrolls_right),
	       BtoS(TScreenOf(xw)->sixel_scrolls_right)));
#endif

	update_appcursor();
	update_appkeypad();
	update_decbkm();
	update_decsdm();
	show_8bit_control(False);
	reset_decudk(xw);

	FromAlternate(xw);
	ClearScreen(xw);
	screen->cursor_state = OFF;
	if (xw->flags & REVERSE_VIDEO)
	    ReverseVideo(xw);

	xw->flags = xw->initflags;
	update_reversevideo();
	update_autowrap();
	update_reversewrap();
	update_autolinefeed();

	screen->jumpscroll = (Boolean) (!(xw->flags & SMOOTHSCROLL));
	update_jumpscroll();

#if OPT_DEC_RECTOPS
	screen->cur_decsace = 0;
#endif
#if OPT_READLINE
	screen->click1_moves = OFF;
	screen->paste_moves = OFF;
	screen->dclick3_deletes = OFF;
	screen->paste_brackets = OFF;
	screen->paste_quotes = OFF;
	screen->paste_literal_nl = OFF;
#endif /* OPT_READLINE */

	if (screen->c132 && (xw->flags & IN132COLUMNS)) {
	    Dimension reqWidth = (Dimension) (80 * FontWidth(screen)
					      + 2 * screen->border
					      + ScrollbarWidth(screen));
	    Dimension reqHeight = (Dimension) (FontHeight(screen)
					       * MaxRows(screen)
					       + 2 * screen->border);
	    Dimension replyWidth;
	    Dimension replyHeight;

	    TRACE(("Making resize-request to restore 80-columns %dx%d\n",
		   reqHeight, reqWidth));
	    REQ_RESIZE((Widget) xw,
		       reqWidth,
		       reqHeight,
		       &replyWidth, &replyHeight);
	    repairSizeHints();
	    XSync(screen->display, False);	/* synchronize */
	    if (xtermAppPending())
		xevents();
	}

	CursorSet(screen, 0, 0, xw->flags);
	CursorSave(xw);
    } else {			/* DECSTR */
	/*
	 * There's a tiny difference, to accommodate usage of xterm.
	 * We reset autowrap to the resource values rather than turning
	 * it off.
	 */
	UIntClr(xw->keyboard.flags, (MODE_DECCKM | MODE_KAM | MODE_DECKPAM));
	bitcpy(&xw->flags, xw->initflags, WRAPAROUND | REVERSEWRAP);
	bitclr(&xw->flags, INSERT | INVERSE | BOLD | BLINK | UNDERLINE | INVISIBLE);
	if_OPT_ISO_COLORS(screen, {
	    reset_SGR_Colors(xw);
	});
	update_appcursor();
	update_autowrap();
	update_reversewrap();

	CursorSave(xw);
	screen->sc[screen->whichBuf].row =
	    screen->sc[screen->whichBuf].col = 0;
    }
}

void
VTReset(XtermWidget xw, Bool full, Bool saved)
{
    ReallyReset(xw, full, saved);
    longjmp(vtjmpbuf, 1);	/* force ground state in parser */
}

typedef enum {
    ccLO,
    ccDASH,
    ccHI,
    ccCOLON,
    ccID,
    ccCOMMA
} CCLASS;

/*
 * set_character_class - takes a string of the form
 *
 *   low[-high][:id][,low[-high][:id][...]]
 *
 * and sets the indicated ranges to the indicated values.
 */
static int
set_character_class(char *s)
{
#define FMT "%s in range string \"%s\" (position %d)\n"

    TRACE(("set_character_class(%s) {{\n", NonNull(s)));
    if (IsEmpty(s)) {
	return -1;
    } else {
	CCLASS state = ccLO;
	int arg[3];
	int i;
	int len = (int) strlen(s);

	arg[0] =
	    arg[1] =
	    arg[2] = -1;

	for (i = 0; i < len; ++i) {
	    int ch = CharOf(s[i]);
	    char *t = 0;
	    long value = 0;

	    if (isspace(ch))
		continue;

	    switch (state) {
	    case ccLO:
	    case ccHI:
	    case ccID:
		if (!isdigit(ch)) {
		    xtermWarning(FMT, "missing number", s, i);
		    return (-1);
		}
		value = strtol(s + i, &t, 0);
		i = (int) (t - s - 1);
		break;
	    case ccDASH:
	    case ccCOLON:
	    case ccCOMMA:
		break;
	    }

	    switch (state) {
	    case ccLO:
		arg[0] =
		    arg[1] = (int) value;
		arg[2] = -1;
		state = ccDASH;
		break;

	    case ccDASH:
		if (ch == '-') {
		    state = ccHI;
		} else {
		    goto parse_class;
		}
		break;

	    case ccHI:
		arg[1] = (int) value;
		state = ccCOLON;
		break;

	      parse_class:
	    case ccCOLON:
		if (ch == ':') {
		    state = ccID;
		} else if (ch == ',') {
		    goto apply_class;
		} else {
		    xtermWarning(FMT, "unexpected character", s, i);
		    return (-1);
		}
		break;

	    case ccID:
		arg[2] = (int) value;
		state = ccCOMMA;
		break;

	      apply_class:
	    case ccCOMMA:
		if (SetCharacterClassRange(arg[0], arg[1], arg[2]) != 0) {
		    xtermWarning(FMT, "bad range", s, i);
		    return -1;
		}
		state = ccLO;
		break;
	    }
	}
	if (state >= ccDASH) {
	    if (SetCharacterClassRange(arg[0], arg[1], arg[2]) != 0) {
		xtermWarning(FMT, "bad range", s, i);
		return -1;
	    }
	}
    }

    TRACE(("}} set_character_class\n"));
    return (0);
#undef FMT
}

void
getKeymapResources(Widget w,
		   const char *mapName,
		   const char *mapClass,
		   const char *type,
		   void *result,
		   size_t size)
{
    XtResource key_resources[1];
    key_resources[0].resource_name = XtNtranslations;
    key_resources[0].resource_class = XtCTranslations;
    key_resources[0].resource_type = (char *) type;
    key_resources[0].resource_size = (Cardinal) size;
    key_resources[0].resource_offset = 0;
    key_resources[0].default_type = key_resources[0].resource_type;
    key_resources[0].default_addr = 0;
    XtGetSubresources(w, (XtPointer) result, mapName, mapClass,
		      key_resources, (Cardinal) 1, NULL, (Cardinal) 0);
}

/* ARGSUSED */
static void
HandleKeymapChange(Widget w,
		   XEvent *event GCC_UNUSED,
		   String *params,
		   Cardinal *param_count)
{
    static XtTranslations keymap, original;

    TRACE(("HandleKeymapChange(%#lx, %s)\n",
	   (unsigned long) w,
	   (*param_count
	    ? params[0]
	    : "missing")));

    if (*param_count != 1)
	return;

    if (original == NULL) {
	TRACE(("...saving original keymap-translations\n"));
	original = w->core.tm.translations;
    }

    if (strcmp(params[0], "None") == 0) {
	TRACE(("...restoring original keymap-translations\n"));
	XtOverrideTranslations(w, original);
    } else {
	char mapName[1000];
	char mapClass[1000];
	char *pmapName;
	char *pmapClass;
	size_t len;

	len = strlen(params[0]) + 7;

	pmapName = (char *) MyStackAlloc(len, mapName);
	pmapClass = (char *) MyStackAlloc(len, mapClass);
	if (pmapName == NULL
	    || pmapClass == NULL) {
	    SysError(ERROR_KMMALLOC1);
	} else {

	    (void) sprintf(pmapName, "%sKeymap", params[0]);
	    (void) strcpy(pmapClass, pmapName);
	    if (islower(CharOf(pmapClass[0])))
		pmapClass[0] = x_toupper(pmapClass[0]);
	    getKeymapResources(w, pmapName, pmapClass, XtRTranslationTable,
			       &keymap, sizeof(keymap));
	    if (keymap != NULL) {
		TRACE(("...applying keymap \"%s\"\n", pmapName));
		XtOverrideTranslations(w, keymap);
	    } else {
		TRACE(("...found no match for keymap \"%s\"\n", pmapName));
	    }

	    MyStackFree(pmapName, mapName);
	    MyStackFree(pmapClass, mapClass);
	}
    }
}

/* ARGSUSED */
static void
HandleBell(Widget w GCC_UNUSED,
	   XEvent *event GCC_UNUSED,
	   String *params,	/* [0] = volume */
	   Cardinal *param_count)	/* 0 or 1 */
{
    int percent = (*param_count) ? atoi(params[0]) : 0;

    Bell(term, XkbBI_TerminalBell, percent);
}

/* ARGSUSED */
static void
HandleVisualBell(Widget w GCC_UNUSED,
		 XEvent *event GCC_UNUSED,
		 String *params GCC_UNUSED,
		 Cardinal *param_count GCC_UNUSED)
{
    VisualBell();
}

/* ARGSUSED */
static void
HandleIgnore(Widget w,
	     XEvent *event,
	     String *params GCC_UNUSED,
	     Cardinal *param_count GCC_UNUSED)
{
    XtermWidget xw;

    TRACE(("Handle ignore for %p %s\n",
	   (void *) w, visibleEventType(event->type)));
    if ((xw = getXtermWidget(w)) != 0) {
	/* do nothing, but check for funny escape sequences */
	(void) SendMousePosition(xw, event);
    }
}

/* ARGSUSED */
static void
DoSetSelectedFont(Widget w,
		  XtPointer client_data GCC_UNUSED,
		  Atom *selection GCC_UNUSED,
		  Atom *type,
		  XtPointer value,
		  unsigned long *length,
		  int *format)
{
    XtermWidget xw = getXtermWidget(w);

    if (xw == 0) {
	xtermWarning("unexpected widget in DoSetSelectedFont\n");
    } else if (*type != XA_STRING || *format != 8) {
	Bell(xw, XkbBI_MinorError, 0);
    } else {
	Boolean failed = False;
	int oldFont = TScreenOf(xw)->menu_font_number;
	char *save = TScreenOf(xw)->SelectFontName();
	char *val;
	char *test = 0;
	unsigned len = (unsigned) *length;
	unsigned tst;

	/*
	 * Some versions of X deliver null-terminated selections, some do not.
	 */
	for (tst = 0; tst < len; ++tst) {
	    if (((char *) value)[tst] == '\0') {
		len = tst;
		break;
	    }
	}

	if (len > 0 && (val = TypeMallocN(char, len + 1)) != 0) {
	    char *used;

	    memcpy(val, value, (size_t) len);
	    val[len] = '\0';
	    used = x_strtrim(val);
	    TRACE(("DoSetSelectedFont(%s)\n", used));
	    /* Do some sanity checking to avoid sending a long selection
	       back to the server in an OpenFont that is unlikely to succeed.
	       XLFD allows up to 255 characters and no control characters;
	       we are a little more liberal here. */
	    if (len < 1000
		&& used != 0
		&& !strchr(used, '\n')
		&& (test = x_strdup(used)) != 0) {
		TScreenOf(xw)->SelectFontName() = test;
		if (!xtermLoadFont(term,
				   xtermFontName(used),
				   True,
				   fontMenu_fontsel)) {
		    failed = True;
		    free(test);
		    TScreenOf(xw)->SelectFontName() = save;
		}
	    } else {
		failed = True;
	    }
	    if (failed) {
		(void) xtermLoadFont(term,
				     xtermFontName(TScreenOf(xw)->MenuFontName(oldFont)),
				     True,
				     oldFont);
		Bell(xw, XkbBI_MinorError, 0);
	    }
	    free(used);
	    free(val);
	}
    }
}

void
FindFontSelection(XtermWidget xw, const char *atom_name, Bool justprobe)
{
    TScreen *screen = TScreenOf(xw);
    static AtomPtr *atoms;
    static unsigned int atomCount = 0;
    AtomPtr *pAtom;
    unsigned a;
    Atom target;

    if (!atom_name)
	atom_name = ((screen->mappedSelect && atomCount)
		     ? screen->mappedSelect[0]
		     : "PRIMARY");
    TRACE(("FindFontSelection(%s)\n", atom_name));

    for (pAtom = atoms, a = atomCount; a; a--, pAtom++) {
	if (strcmp(atom_name, XmuNameOfAtom(*pAtom)) == 0) {
	    TRACE(("...found atom %d:%s\n", a + 1, atom_name));
	    break;
	}
    }
    if (!a) {
	atoms = TypeXtReallocN(AtomPtr, atoms, atomCount + 1);
	*(pAtom = &atoms[atomCount]) = XmuMakeAtom(atom_name);
	++atomCount;
	TRACE(("...added atom %d:%s\n", atomCount, atom_name));
    }

    target = XmuInternAtom(XtDisplay(xw), *pAtom);
    if (justprobe) {
	screen->SelectFontName() =
	    XGetSelectionOwner(XtDisplay(xw), target) ? _Font_Selected_ : 0;
	TRACE(("...selected fontname '%s'\n",
	       NonNull(screen->SelectFontName())));
    } else {
	XtGetSelectionValue((Widget) xw, target, XA_STRING,
			    DoSetSelectedFont, NULL,
			    XtLastTimestampProcessed(XtDisplay(xw)));
    }
    return;
}

Bool
set_cursor_gcs(XtermWidget xw)
{
    TScreen *screen = TScreenOf(xw);
    VTwin *win = WhichVWin(screen);

    Pixel cc = T_COLOR(screen, TEXT_CURSOR);
    Pixel fg = T_COLOR(screen, TEXT_FG);
    Pixel bg = T_COLOR(screen, TEXT_BG);
    Bool changed = False;

    /*
     * Let's see, there are three things that have "color":
     *
     *     background
     *     text
     *     cursorblock
     *
     * And, there are four situations when drawing a cursor, if we decide
     * that we like have a solid block of cursor color with the letter
     * that it is highlighting shown in the background color to make it
     * stand out:
     *
     *     selected window, normal video - background on cursor
     *     selected window, reverse video - foreground on cursor
     *     unselected window, normal video - foreground on background
     *     unselected window, reverse video - background on foreground
     *
     * Since the last two are really just normalGC and reverseGC, we only
     * need two new GC's.  Under monochrome, we get the same effect as
     * above by setting cursor color to foreground.
     */

    TRACE(("set_cursor_gcs cc=%#lx, fg=%#lx, bg=%#lx\n", cc, fg, bg));
    if (win != 0 && (cc != bg)) {
	/* set the fonts to the current one */
	setCgsFont(xw, win, gcVTcursNormal, 0);
	setCgsFont(xw, win, gcVTcursFilled, 0);
	setCgsFont(xw, win, gcVTcursReverse, 0);
	setCgsFont(xw, win, gcVTcursOutline, 0);

	/* we have a colored cursor */
	setCgsFore(xw, win, gcVTcursNormal, fg);
	setCgsBack(xw, win, gcVTcursNormal, cc);

	setCgsFore(xw, win, gcVTcursFilled, cc);
	setCgsBack(xw, win, gcVTcursFilled, fg);

	if (screen->always_highlight) {
	    /* both GC's use the same color */
	    setCgsFore(xw, win, gcVTcursReverse, bg);
	    setCgsBack(xw, win, gcVTcursReverse, cc);
	} else {
	    setCgsFore(xw, win, gcVTcursReverse, bg);
	    setCgsBack(xw, win, gcVTcursReverse, cc);
	}
	set_cursor_outline_gc(xw, screen->always_highlight, fg, bg, cc);
	changed = True;
    }

    if (changed) {
	TRACE(("...set_cursor_gcs - done\n"));
    }
    return changed;
}

/*
 * Build up the default translations string, allowing the user to suppress
 * some of the features.
 */
void
VTInitTranslations(void)
{
    /* *INDENT-OFF* */
    static struct {
	Boolean wanted;
	const char *name;
	const char *value;
    } table[] = {
	{
	    False,
	    "default",
"\
          Shift  Prior:scroll-back(1,halfpage) \n\
           Shift  Next:scroll-forw(1,halfpage) \n\
         Shift  Select:select-cursor-start() select-cursor-end(SELECT, CUT_BUFFER0) \n\
         Shift  Insert:insert-selection(SELECT, CUT_BUFFER0) \n\
"
	},
#if OPT_MAXIMIZE
	{
	    False,
	    "fullscreen",
"\
                 Alt Return:fullscreen() \n\
"
	},
#endif
#if OPT_SCROLL_LOCK
	{
	    False,
	    "scroll-lock",
"\
         Scroll_Lock:scroll-lock() \n\
"
	},
#endif
#if OPT_SHIFT_FONTS
	{
	    False,
	    "shift-fonts",
"\
    Shift~Ctrl  KP_Add:larger-vt-font() \n\
    Shift Ctrl  KP_Add:smaller-vt-font() \n\
    Shift  KP_Subtract:smaller-vt-font() \n\
"
	},
#endif
	/* PROCURA added "Meta :clear-saved-lines()" */
	{
	    False,
	    "default",
"\
                ~Meta :insert-seven-bit() \n\
                 Meta :insert-eight-bit() \n\
                !Ctrl :popup-menu(mainMenu) \n\
           !Lock Ctrl :popup-menu(mainMenu) \n\
 !Lock Ctrl @Num_Lock :popup-menu(mainMenu) \n\
     ! @Num_Lock Ctrl :popup-menu(mainMenu) \n\
                ~Meta :select-start() \n\
              ~Meta :select-extend() \n\
                !Ctrl :popup-menu(vtMenu) \n\
           !Lock Ctrl :popup-menu(vtMenu) \n\
 !Lock Ctrl @Num_Lock :popup-menu(vtMenu) \n\
     ! @Num_Lock Ctrl :popup-menu(vtMenu) \n\
          ~Ctrl ~Meta :ignore() \n\
                 Meta :clear-saved-lines() \n\
            ~Ctrl ~Meta :insert-selection(SELECT, CUT_BUFFER0) \n\
                !Ctrl :popup-menu(fontMenu) \n\
           !Lock Ctrl :popup-menu(fontMenu) \n\
 !Lock Ctrl @Num_Lock :popup-menu(fontMenu) \n\
     ! @Num_Lock Ctrl :popup-menu(fontMenu) \n\
          ~Ctrl ~Meta :start-extend() \n\
              ~Meta :select-extend() \n\
"
	},
	{
	    False,
	    "wheel-mouse",
"\
                 Ctrl :scroll-back(1,halfpage,m) \n\
            Lock Ctrl :scroll-back(1,halfpage,m) \n\
  Lock @Num_Lock Ctrl :scroll-back(1,halfpage,m) \n\
       @Num_Lock Ctrl :scroll-back(1,halfpage,m) \n\
                      :scroll-back(5,line,m)     \n\
                 Ctrl :scroll-forw(1,halfpage,m) \n\
            Lock Ctrl :scroll-forw(1,halfpage,m) \n\
  Lock @Num_Lock Ctrl :scroll-forw(1,halfpage,m) \n\
       @Num_Lock Ctrl :scroll-forw(1,halfpage,m) \n\
                      :scroll-forw(5,line,m)     \n\
"
	},
	{
	    False,
	    "default",
"\
                         :select-end(SELECT, CUT_BUFFER0) \n\
                       :ignore() \
"
	}
    };
    /* *INDENT-ON* */

    char *result = 0;

    int pass;
    Cardinal item;

    TRACE(("VTInitTranslations\n"));
    for (item = 0; item < XtNumber(table); ++item) {
	table[item].wanted = True;
    }
#if OPT_MAXIMIZE
    /*
     * As a special case, allow for disabling the alt-enter translation if
     * the resource settings prevent fullscreen from being used.  We would
     * do the same for scroll-lock and shift-fonts if they were application
     * resources too, rather than in the widget.
     */
    if (resource.fullscreen == esNever) {
	for (item = 0; item < XtNumber(table); ++item) {
	    if (!strcmp(table[item].name, "fullscreen")) {
		table[item].wanted = False;
		TRACE(("omit(%s):\n%s\n", table[item].name, table[item].value));
	    }
	}
    }
#endif
    if (!IsEmpty(resource.omitTranslation)) {
	char *value;
	const char *source = resource.omitTranslation;

	while (*source != '\0' && (value = ParseList(&source)) != 0) {
	    size_t len = strlen(value);

	    TRACE(("parsed:%s\n", value));
	    for (item = 0; item < XtNumber(table); ++item) {
		if (strlen(table[item].name) >= len
		    && x_strncasecmp(table[item].name,
				     value,
				     (unsigned) len) == 0) {
		    table[item].wanted = False;
		    TRACE(("omit(%s):\n%s\n", table[item].name, table[item].value));
		    break;
		}
	    }
	    free(value);
	}
    }

    for (pass = 0; pass < 2; ++pass) {
	size_t needed = 0;
	for (item = 0; item < XtNumber(table); ++item) {
	    if (table[item].wanted) {
		if (pass) {
		    strcat(result, table[item].value);
		} else {
		    needed += strlen(table[item].value) + 1;
		}
	    }
	}
	if (!pass) {
	    result = XtMalloc((Cardinal) needed);
	    *result = '\0';
	}
    }

    TRACE(("result:\n%s\n", result));

    defaultTranslations = result;
    xtermClassRec.core_class.tm_table = result;
}

#ifdef NO_LEAKS
void
noleaks_charproc(void)
{
    if (v_buffer != 0)
	free(v_buffer);
}
#endif
xterm-330/install-sh0000755000175100001440000001572307762207755013274 0ustar  tomusers#! /bin/sh
#
# install - install a program, script, or datafile
#
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.  It can only install one file at a time, a restriction
# shared with many OS's install programs.


# set DOITPROG to echo to test this script

# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"


# put in absolute paths if you don't have them in your path; or use env. vars.

mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"

transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""

while [ x"$1" != x ]; do
    case $1 in
	-c) instcmd=$cpprog
	    shift
	    continue;;

	-d) dir_arg=true
	    shift
	    continue;;

	-m) chmodcmd="$chmodprog $2"
	    shift
	    shift
	    continue;;

	-o) chowncmd="$chownprog $2"
	    shift
	    shift
	    continue;;

	-g) chgrpcmd="$chgrpprog $2"
	    shift
	    shift
	    continue;;

	-s) stripcmd=$stripprog
	    shift
	    continue;;

	-t=*) transformarg=`echo $1 | sed 's/-t=//'`
	    shift
	    continue;;

	-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
	    shift
	    continue;;

	*)  if [ x"$src" = x ]
	    then
		src=$1
	    else
		# this colon is to work around a 386BSD /bin/sh bug
		:
		dst=$1
	    fi
	    shift
	    continue;;
    esac
done

if [ x"$src" = x ]
then
	echo "$0: no input file specified" >&2
	exit 1
else
	:
fi

if [ x"$dir_arg" != x ]; then
	dst=$src
	src=""

	if [ -d "$dst" ]; then
		instcmd=:
		chmodcmd=""
	else
		instcmd=$mkdirprog
	fi
else

# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.

	if [ -f "$src" ] || [ -d "$src" ]
	then
		:
	else
		echo "$0: $src does not exist" >&2
		exit 1
	fi

	if [ x"$dst" = x ]
	then
		echo "$0: no destination specified" >&2
		exit 1
	else
		:
	fi

# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic

	if [ -d "$dst" ]
	then
		dst=$dst/`basename "$src"`
	else
		:
	fi
fi

## this sed command emulates the dirname command
dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`

# Make sure that the destination directory exists.
#  this part is taken from Noah Friedman's mkinstalldirs script

# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
	'
IFS="${IFS-$defaultIFS}"

oIFS=$IFS
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS=$oIFS

pathcomp=''

while [ $# -ne 0 ] ; do
	pathcomp=$pathcomp$1
	shift

	if [ ! -d "$pathcomp" ] ;
        then
		$mkdirprog "$pathcomp"
	else
		:
	fi

	pathcomp=$pathcomp/
done
fi

if [ x"$dir_arg" != x ]
then
	$doit $instcmd "$dst" &&

	if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi &&
	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi &&
	if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi &&
	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi
else

# If we're going to rename the final executable, determine the name now.

	if [ x"$transformarg" = x ]
	then
		dstfile=`basename "$dst"`
	else
		dstfile=`basename "$dst" $transformbasename |
			sed $transformarg`$transformbasename
	fi

# don't allow the sed command to completely eliminate the filename

	if [ x"$dstfile" = x ]
	then
		dstfile=`basename "$dst"`
	else
		:
	fi

# Make a couple of temp file names in the proper directory.

	dsttmp=$dstdir/#inst.$$#
	rmtmp=$dstdir/#rm.$$#

# Trap to clean up temp files at exit.

	trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
	trap '(exit $?); exit' 1 2 13 15

# Move or copy the file name to the temp name

	$doit $instcmd "$src" "$dsttmp" &&

# and set any options; do chmod last to preserve setuid bits

# If any of these fail, we abort the whole thing.  If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.

	if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi &&
	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi &&
	if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi &&
	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi &&

# Now remove or move aside any old file at destination location.  We try this
# two ways since rm can't unlink itself on some systems and the destination
# file might be busy for other reasons.  In this case, the final cleanup
# might fail but the new file should still install successfully.

{
	if [ -f "$dstdir/$dstfile" ]
	then
		$doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null ||
		$doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null ||
		{
		  echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
		  (exit 1); exit
		}
	else
		:
	fi
} &&

# Now rename the file to the real destination.

	$doit $mvcmd "$dsttmp" "$dstdir/$dstfile"

fi &&

# The final little trick to "correctly" pass the exit status to the exit trap.

{
	(exit 0); exit
}
xterm-330/plink.sh0000755000175100001440000000456712166141160012725 0ustar  tomusers#!/bin/sh
# $XTermId: plink.sh,v 1.10 2013/07/07 01:20:48 tom Exp $
# -----------------------------------------------------------------------------
# this file is part of xterm
#
# Copyright 2001-2010,2013 by Thomas E. Dickey
#
#                         All Rights Reserved
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name(s) of the above copyright
# holders shall not be used in advertising or otherwise to promote the
# sale, use or other dealings in this Software without prior written
# authorization.
# -----------------------------------------------------------------------------
#
# Reduce the number of dynamic libraries used to link an executable.
LINKIT=
ASNEED=no
while test $# != 0
do
	if test $ASNEED = no && test -n "$LINKIT"
	then
		ASNEED=yes
		OPT=-Wl,-as-needed
		if ( eval $LINKIT $OPT $* >/dev/null 2>/dev/null )
		then
			WARNED=`eval $LINKIT $OPT $* 2>&1`
			case ".$WARNED" in
			*Warning*|*nsupported*|*nrecognized*|*nknown*)
				;;
			*)
				LINKIT="$LINKIT $OPT $*"
				break
				;;
			esac
		fi
	fi

	OPT="$1"
	shift
	case $OPT in
	-k*)
		OPT=`echo "$OPT" | sed -e 's/^-k/-l/'`
		LINKIT="$LINKIT $OPT"
		;;
	-l*)
		echo "testing if $OPT is needed"
		if ( eval $LINKIT $* >/dev/null 2>/dev/null )
		then
			: echo ...no
		else
			echo ...yes
			LINKIT="$LINKIT $OPT"
		fi
		;;
	*)
		LINKIT="$LINKIT $OPT"
		;;
	esac
done
eval $LINKIT
xterm-330/Makefile.in0000644000175100001440000004637313036266617013333 0ustar  tomusers## $XTermId: Makefile.in,v 1.239 2017/01/14 00:15:11 tom Exp $
# -----------------------------------------------------------------------------
# this file is part of xterm
#
# Copyright 1997-2016,2017 by Thomas E. Dickey
#
#                         All Rights Reserved
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name(s) of the above copyright
# holders shall not be used in advertising or otherwise to promote the
# sale, use or other dealings in this Software without prior written
# authorization.
# -----------------------------------------------------------------------------

SHELL		= /bin/sh

#### Start of system configuration section. ####

srcdir		= @srcdir@
VPATH  		= @srcdir@

x		= @EXEEXT@
o		= .@OBJEXT@

CC		= @CC@
CPP		= @CPP@
AWK		= @AWK@
LINK		= $(CC) $(CFLAGS)

CTAGS		= @CTAGS@
ETAGS		= @ETAGS@

LN_S		= @LN_S@
RM              = rm -f
LINT		= @LINT@
LINT_OPTS	= @LINT_OPTS@

INSTALL		= @INSTALL@
INSTALL_PROGRAM	= @INSTALL_PROGRAM@
INSTALL_SCRIPT	= @INSTALL_SCRIPT@
INSTALL_DATA	= @INSTALL_DATA@
transform	= @program_transform_name@

EXTRA_CFLAGS	= @EXTRA_CFLAGS@
EXTRA_CPPFLAGS	= @EXTRA_CPPFLAGS@
EXTRA_LOADFLAGS	= @IMAKE_LOADFLAGS@

CPPFLAGS	= -I. -I$(srcdir) -DHAVE_CONFIG_H @CPPFLAGS@ -DDEFCLASS=\"@APP_CLASS@\" $(EXTRA_CPPFLAGS)
CFLAGS		= @CFLAGS@ $(EXTRA_CFLAGS)
LDFLAGS		= @LDFLAGS@ @EXTRA_LDFLAGS@
LIBS		= @LIBS@

prefix		= @prefix@
exec_prefix	= @exec_prefix@
datarootdir	= @datarootdir@
datadir		= @datadir@

manext		= 1
bindir		= @bindir@
libdir		= @libdir@
mandir		= @mandir@/man$(manext)
appsdir		= @APPSDIR@
icondir		= @ICONDIR@
pixmapdir	= @PIXMAPDIR@

#### End of system configuration section. ####

ICON_NAME	= @ICON_NAME@
ICON_SYMLINK	= @ICON_SYMLINK@

DESTDIR		=
BINDIR		= $(DESTDIR)$(bindir)
LIBDIR		= $(DESTDIR)$(libdir)
MANDIR		= $(DESTDIR)$(mandir)
APPSDIR		= $(DESTDIR)$(appsdir)

@no_icondir@ICONDIR		= $(DESTDIR)$(icondir)
@no_pixmapdir@PIXMAPDIR	= $(DESTDIR)$(pixmapdir)

INSTALL_DIRS    = $(BINDIR) $(APPSDIR) $(ICONDIR) $(PIXMAPDIR) $(MANDIR)

CLASS		= @APP_CLASS@
EXTRAHDR	= @EXTRAHDRS@
EXTRASRC	= @EXTRASRCS@
EXTRAOBJ	= @EXTRAOBJS@

          SRCS1 = button.c cachedGCs.c charproc.c charsets.c cursor.c \
	  	  data.c doublechr.c fontutils.c input.c \
		  linedata.c main.c menu.c misc.c \
		  print.c ptydata.c scrollback.c \
		  screen.c scrollbar.c tabs.c util.c version.c xstrings.c \
		  xtermcap.c VTPrsTbl.c $(EXTRASRC)
          OBJS1 = button$o cachedGCs$o charproc$o charsets$o cursor$o \
	  	  data$o doublechr$o fontutils$o input$o \
		  linedata$o main$o menu$o misc$o \
		  print$o ptydata$o scrollback$o \
		  screen$o scrollbar$o tabs$o util$o version$o xstrings$o \
		  xtermcap$o VTPrsTbl$o $(EXTRAOBJ)
          SRCS2 = resize.c version.c xstrings.c
          OBJS2 = resize$o version$o xstrings$o
           SRCS = $(SRCS1) $(SRCS2)
           OBJS = $(OBJS1) $(OBJS2)
           HDRS = VTparse.h data.h error.h fontutils.h main.h menu.h \
                  ptyx.h version.h xstrings.h xterm.h xtermcap.h $(EXTRAHDR)
       PROGRAMS = xterm$x resize$x

all :	$(PROGRAMS)
################################################################################
.SUFFIXES : .i .def .cin .hin .$(manext) .ms .man .txt @MAN2HTML_NOTE@ .html @GROFF_NOTE@ .ps .pdf

.c$o :
	@RULE_CC@
	@ECHO_CC@$(CC) $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/$*.c

.c.i :
	@RULE_CC@
	@ECHO_CC@$(CPP) -C $(CPPFLAGS) $*.c >$@

.def.cin :
	$(AWK) '/^CASE_/{printf "{ %d, \"%s\" },\n", n++, $$1; }' < $< >$@

.def.hin :
	$(AWK) '/^CASE_/{printf "#define %s %d\n", $$1, n++}' < $< >$@

.man.$(manext) :
	$(SHELL) ./minstall "$(INSTALL_DATA)" $< $@ $(appsdir) $(CLASS) $* $* $(pixmapdir)

@NROFF_NOTE@.$(manext).txt :
@NROFF_NOTE@	$(SHELL) -c "tbl $*.$(manext) | nroff -man | col -bx" >$@
@NROFF_NOTE@
@NROFF_NOTE@.ms.txt :
@NROFF_NOTE@	$(SHELL) -c "tbl $*.$(manext) | nroff -ms | col -bx" >$@
@NROFF_NOTE@

@MAN2HTML_NOTE@.$(manext).html :
@MAN2HTML_NOTE@	./@MAN2HTML_TEMP@ $* $(manext) man >$@
@MAN2HTML_NOTE@
@GROFF_NOTE@.$(manext).ps :
@GROFF_NOTE@	$(SHELL) -c "tbl $*.$(manext) | groff -man" >$@
@GROFF_NOTE@
@GROFF_NOTE@.$(manext).txt :
@GROFF_NOTE@	GROFF_NO_SGR=stupid $(SHELL) -c "tbl $*.$(manext) | groff -Tascii -man | col -bx" >$@
@GROFF_NOTE@
@MAN2HTML_NOTE@.ms.html :
@MAN2HTML_NOTE@	./@MAN2HTML_TEMP@ $* ms ms >$@
@MAN2HTML_NOTE@
@GROFF_NOTE@.ms.ps :
@GROFF_NOTE@	$(SHELL) -c "tbl $< | groff -ms" >$@
@GROFF_NOTE@
@GROFF_NOTE@.ms.txt :
@GROFF_NOTE@	GROFF_NO_SGR=stupid $(SHELL) -c "tbl $< | groff -Tascii -ms | col -bx" >$@
@GROFF_NOTE@
@GROFF_NOTE@.ps.pdf :
@GROFF_NOTE@	ps2pdf $*.ps
################################################################################

VTPARSE_H = VTparse.h VTparse.hin
TEKPARSE_H = Tekparse.h Tekparse.hin

main$o : main.h
misc$o : version.h

$(OBJS1) : xterm.h ptyx.h xtermcfg.h
main$o resize$o screen$o : xterm_io.h

xterm$x : $(OBJS1)
	@ECHO_LD@$(SHELL) $(srcdir)/plink.sh $(LINK) $(LDFLAGS) -o $@ $(OBJS1) $(LIBS) $(EXTRA_LOADFLAGS)

resize$x : $(OBJS2)
	@ECHO_LD@$(SHELL) $(srcdir)/plink.sh $(LINK) $(LDFLAGS) -o $@ $(OBJS2) $(LIBS)

256colres.h :
	-$(RM) $@
	perl $(srcdir)/256colres.pl > $@

88colres.h :
	-$(RM) $@
	perl $(srcdir)/88colres.pl > $@

charproc$o : $(VTPARSE_H) main.h @CHARPROC_DEPS@
graphics_regis$o : $(VTPARSE_H) 
graphics_sixel$o : $(VTPARSE_H) 
misc$o : $(VTPARSE_H) 
VTPrsTbl$o : $(VTPARSE_H) 

TekPrsTbl$o : $(TEKPARSE_H)
Tekproc$o : $(TEKPARSE_H)

misc$o : builtin_icons.h

trace$o : VTparse.cin Tekparse.cin

# do this to quiet gcc -Wcast-qual warnings 
builtin_icons.h :
	@echo "#if OPT_BUILTIN_XPMS" >$@
	@echo "#include " >>$@
	@echo "#include " >>$@
	@echo "#include " >>$@
	@echo "#include " >>$@
	@echo "#else" >>$@
	@sed -e 's/static char \* /static const char * /' $(srcdir)/icons/mini.xterm_48x48.xpm >>$@
	@echo "#endif" >>$@
	@echo "made $@"

################################################################################
actual_xterm  = `echo xterm|        sed '$(transform)'`
actual_resize = `echo resize|       sed '$(transform)'`
actual_uxterm = `echo uxterm|       sed '$(transform)'`
actual_k8term = `echo koi8rxterm|   sed '$(transform)'`

binary_xterm  = $(actual_xterm)$x
binary_resize = $(actual_resize)$x
binary_uxterm = $(actual_uxterm)
binary_k8term = $(actual_k8term)

install \
install-bin \
install-full :: xterm$x resize$x $(BINDIR)
@MAY_SETUID@	$(SHELL) $(srcdir)/sinstall.sh @SINSTALL_OPTS@ "$(INSTALL_PROGRAM)" xterm$x  @XTERM_PATH@ $(BINDIR)/$(binary_xterm)
@NOT_SETUID@	$(INSTALL_PROGRAM) xterm$x $(BINDIR)/$(binary_xterm)
	$(INSTALL_PROGRAM) -m  755 resize$x $(BINDIR)/$(binary_resize)

EDIT_SCRIPT = sed -e s,=xterm,=\$$name, -e s,XTerm,$(CLASS),

InstallLink = \
	if test @XTERM_SYMLINK@ != NONE \
	&& test \$$source != NONE \
	&& test \$$source != \$$target ; then \
		cd \$$TARGET && ( \
			$(RM) \$$source ; \
			$(LN_S) \$$target \$$source ; \
			echo \"... created symbolic link:\" ; \
			ls -l \$$target \$$source ) ; \
	fi

InstallBinLink = TARGET=$(BINDIR); $(InstallLink)
InstallManLink = TARGET=$(MANDIR); $(InstallLink)

InstallScript = \
	echo \"... installing $(BINDIR)/\$$target\"; \
	name=$(binary_xterm); \
	$(EDIT_SCRIPT) $(srcdir)/\$$source >\$$source.tmp; \
	$(INSTALL_SCRIPT) -m  755 \$$source.tmp $(BINDIR)/\$$target; \
	$(RM) \$$source.tmp

install \
install-bin \
install-scripts \
install-full :: $(BINDIR)
	@$(SHELL) -c "source=\"@XTERM_SYMLINK@\"; \
		target=\"$(binary_xterm)\"; \
		$(InstallBinLink)"
	@$(SHELL) -c "source=\"resize\"; \
		target=\"$(binary_resize)\"; \
		$(InstallBinLink)"
	@$(SHELL) -c "source=\"uxterm\"; \
		target=\"$(binary_uxterm)\"; \
		$(InstallScript); \
		$(InstallBinLink)"
	@$(SHELL) -c "source=\"koi8rxterm\"; \
		target=\"$(binary_k8term)\"; \
		$(InstallScript); \
		$(InstallBinLink)"

install \
install-man \
install-full :: $(MANDIR)
	@-$(SHELL) -c "for source in xterm resize uxterm koi8rxterm ; \
		do \
			target=\`echo \"\$$source\" | sed '@program_transform_name@'\`; \
			$(SHELL) ./minstall \"$(INSTALL_DATA)\" \
				$(srcdir)/\$$source.man  \
				$(MANDIR)/\$$target.$(manext) \
				$(appsdir) \
				$(CLASS) \
				\$$source \
				\$$target \
				$(pixmapdir); \
		done"
	@-$(SHELL) -c "if test @XTERM_SYMLINK@ != NONE ; then \
		source=$(actual_xterm).$(manext); \
		target=@XTERM_SYMLINK@.$(manext); \
		cd $(MANDIR) && ( \
			$(RM) \$$target ; \
			$(LN_S) \$$source \$$target ; \
			echo '... created symbolic link:' ; \
			ls -l \$$source \$$target ; \
			) \
		fi"

APP_NAMES = XTerm UXTerm KOI8RXTerm

@no_appsdir@install \
@no_appsdir@install-app \
@no_appsdir@install-full :: $(APPSDIR)
@no_appsdir@	@-$(SHELL) -c 'for s in $(APP_NAMES); \
@no_appsdir@	do \
@no_appsdir@		echo "** $$s"; \
@no_appsdir@		d=`echo $$s | sed -e s/XTerm/$(CLASS)/`; \
@no_appsdir@		echo installing $(APPSDIR)/$$d; \
@no_appsdir@		sed -e s/XTerm/$(CLASS)/ $(srcdir)/$$s.ad >XTerm.tmp; \
@no_appsdir@		$(INSTALL_DATA) XTerm.tmp $(APPSDIR)/$$d; \
@no_appsdir@		echo installing $(APPSDIR)/$$d-color; \
@no_appsdir@		sed -e s/XTerm/$$d/ $(srcdir)/XTerm-col.ad >XTerm.tmp; \
@no_appsdir@		$(INSTALL_DATA) XTerm.tmp $(APPSDIR)/$$d-color; \
@no_appsdir@	done'
@no_appsdir@	@$(RM) XTerm.tmp
@no_icondir@	@echo "... installed app-defaults"

@no_icondir@ICON_LIST = @ICON_LIST@
@no_icondir@ICON_THEME = @ICON_THEME@
@no_icondir@install \
@no_icondir@install-icon \
@no_icondir@install-full :: $(ICONDIR)
@no_icondir@	ACTUAL_XTERM=$(actual_xterm) \
@no_icondir@	$(SHELL) -c '\
@no_icondir@		h=$(ICONDIR)/$(ICON_THEME); \
@no_icondir@		for n in $(ICON_LIST); \
@no_icondir@		do \
@no_icondir@			x=$$ACTUAL_XTERM; \
@no_icondir@			l=`echo "$$n" | cut -f1 -d:`; \
@no_icondir@			r=`echo "$$n" | cut -f2 -d: |sed -e s,$(ICON_NAME),$$x-color,`; \
@no_icondir@			test -z "$$r" && continue; \
@no_icondir@			d=$$h/`echo "$$r" | sed -e "s,/[^/]*$$,,"`; \
@no_icondir@			test -d "$$d" || mkdir -p "$$d"; \
@no_icondir@			echo "installing icon $$h/$$r"; \
@no_icondir@			$(INSTALL_DATA) $$l $$h/$$r; \
@no_icondir@			s=`echo "$$r" | sed -e '"'s,^.*\.,.,'"'`; \
@no_icondir@			t=$(ICON_SYMLINK)$$s; \
@no_icondir@			b=`basename $$n $$s | sed -e "s,_[1-9][0-9]*x.*,,"`; \
@no_icondir@			if test "$(ICON_SYMLINK)" != NONE ; then \
@no_icondir@				if test "$$r" != "$$t" ; then \
@no_icondir@					if test "x$$b" = "x$(ICON_NAME)" ; then \
@no_icondir@						echo "linking $$r -> $$t"; \
@no_icondir@						( cd $$h; $(RM) $$t; $(LN_S) $$r $$t; ) \
@no_icondir@					fi \
@no_icondir@				fi \
@no_icondir@			fi \
@no_icondir@		done'
@no_icondir@	@echo "... installed icons"

@no_pixmapdir@install \
@no_pixmapdir@install-icon \
@no_pixmapdir@install-full :: $(PIXMAPDIR)
@no_pixmapdir@	ACTUAL_XTERM=$(actual_xterm) \
@no_pixmapdir@	$(SHELL) -c '\
@no_pixmapdir@		h=$(PIXMAPDIR); \
@no_pixmapdir@		for n in $(srcdir)/icons/*xterm*_32x32.xpm $(srcdir)/icons/*xterm*_48x48.xpm; \
@no_pixmapdir@		do \
@no_pixmapdir@			l=`basename $$n`; \
@no_pixmapdir@			r=`echo "$$l" | sed -e "s,xterm,$$ACTUAL_XTERM,"`; \
@no_pixmapdir@			echo "installing pixmap $$h/$$r"; \
@no_pixmapdir@			$(INSTALL_DATA) $(srcdir)/icons/$$l $$h/$$r; \
@no_pixmapdir@			s=`echo "$$r" | sed -e '"'s,^.*\.,.,'"'`; \
@no_pixmapdir@			t=$(ICON_SYMLINK)$$s; \
@no_pixmapdir@			b=`basename $$n $$s | sed -e "s,_[1-9][0-9]*x.*,,"`; \
@no_pixmapdir@			if test "$(ICON_SYMLINK)" != NONE ; then \
@no_pixmapdir@				if test "x$$r" != "$$t" ; then \
@no_pixmapdir@					if test "x$$b" = "x$(ICON_NAME)" ; then \
@no_pixmapdir@						echo "linking $$r -> $$t"; \
@no_pixmapdir@						( cd $$h; $(RM) $$t; $(LN_S) $$r $$t; ) \
@no_pixmapdir@					fi \
@no_pixmapdir@				fi \
@no_pixmapdir@			fi \
@no_pixmapdir@		done'
@no_pixmapdir@	@echo "... installed icons"

install ::
	@echo 'Completed installation of executables and documentation.'
	@echo 'Use "make install-ti" to install terminfo description.'

TERMINFO_DIR = @TERMINFO_DIR@
SET_TERMINFO = @SET_TERMINFO@

@no_ticprog@install-full \
@no_ticprog@install-ti :: $(TERMINFO_DIR)
@no_ticprog@	@$(SHELL) -c "$(SET_TERMINFO) $(srcdir)/run-tic.sh $(srcdir)/terminfo"
@no_ticprog@	@echo 'Completed installation of terminfo description.'

install-full \
install-tc ::
	@-$(SHELL) -c "test -f /etc/termcap && echo 'You must install the termcap entry manually by editing /etc/termcap'"

installdirs : $(INSTALL_DIRS)
################################################################################

UninstallLink = \
	if test @XTERM_SYMLINK@ != NONE \
	&& test \$$source != NONE \
	&& test \$$source != \$$target \
	&& test -h \$$TARGET/\$$source ; then \
		echo \"... removing \$$TARGET/\$$source\"; \
		cd \$$TARGET && \
		$(RM) \$$source; \
	fi

UninstallBinLink = TARGET=$(BINDIR); $(UninstallLink)
UninstallManLink = TARGET=$(MANDIR); $(UninstallLink)

UninstallBinary = \
	echo \"... removing $(BINDIR)/\$$target\"; \
	$(RM) $(BINDIR)/\$$target

uninstall \
uninstall-bin \
uninstall-full ::
	@-$(SHELL) -c "source=\"@XTERM_SYMLINK@\"; \
		target=\"$(binary_xterm)\"; \
		$(UninstallBinLink); \
		$(UninstallBinary)"
	@-$(SHELL) -c "source=\"resize\"; \
		target=\"$(binary_resize)\"; \
		$(UninstallBinLink); \
		$(UninstallBinary)"

uninstall \
uninstall-bin \
uninstall-scripts \
uninstall-full ::
	@-$(SHELL) -c "source=\"uxterm\"; \
		target=\"$(binary_uxterm)\"; \
		$(UninstallBinLink); \
		$(UninstallBinary)"
	@-$(SHELL) -c "source=\"koi8rxterm\"; \
		target=\"$(binary_k8term)\"; \
		$(UninstallBinLink); \
		$(UninstallBinary)"

uninstall \
uninstall-man \
uninstall-full ::
	@-$(SHELL) -c "\
		source=@XTERM_SYMLINK@.$(manext); \
		target=$(actual_xterm).$(manext); \
		$(UninstallManLink)"
	@-$(SHELL) -c "for source in \
		$(actual_xterm).$(manext) \
		$(actual_resize).$(manext) \
		$(actual_uxterm).$(manext) \
		$(actual_k8term).$(manext); \
		do \
			echo \"... removing $(MANDIR)/\$$source\"; \
			$(RM) $(MANDIR)/\$$source; \
		done"

@no_appsdir@uninstall \
@no_appsdir@uninstall-app \
@no_appsdir@uninstall-full ::
@no_appsdir@	@-$(SHELL) -c 'for s in $(APP_NAMES); \
@no_appsdir@	do \
@no_appsdir@		echo "** $$s"; \
@no_appsdir@		d=`echo $$s | sed -e s/XTerm/$(CLASS)/`; \
@no_appsdir@		echo uninstalling $(APPSDIR)/$$d; \
@no_appsdir@		$(RM) $(APPSDIR)/$$d; \
@no_appsdir@		echo uninstalling $(APPSDIR)/$$d-color; \
@no_appsdir@		$(RM) $(APPSDIR)/$$d-color; \
@no_appsdir@	done'

@no_icondir@uninstall \
@no_icondir@uninstall-icon \
@no_icondir@uninstall-full ::
@no_icondir@	-@$(SHELL) -c 'for n in $(ICON_LIST); \
@no_icondir@		do \
@no_icondir@		x=$(actual_xterm); \
@no_icondir@		r=`echo "$$n" | sed -e s,\^.\*:,, -e s,xterm,$$x,`; \
@no_icondir@		test -z "$$r" && continue; \
@no_icondir@		h=$(ICONDIR)/$(ICON_THEME); \
@no_icondir@		echo removing $$h/$$r; \
@no_icondir@		$(RM) $$h/$$r; \
@no_icondir@		done'
@no_icondir@	@echo "... removed icons"

@no_pixmapdir@uninstall \
@no_pixmapdir@uninstall-icon \
@no_pixmapdir@uninstall-full ::
@no_pixmapdir@	ACTUAL_XTERM=$(actual_xterm) \
@no_pixmapdir@	$(SHELL) -c 'for n in $(srcdir)/icons/*xterm*_32x32.xpm $(srcdir)/icons/*xterm*_48x48.xpm; \
@no_pixmapdir@		do \
@no_pixmapdir@			l=`basename $$n`; \
@no_pixmapdir@			r=`echo "$$l" | sed -e "s,xterm,$$ACTUAL_XTERM,"`; \
@no_pixmapdir@			echo removing $(PIXMAPDIR)/$$r; \
@no_pixmapdir@			$(RM) $(PIXMAPDIR)/$$r; \
@no_pixmapdir@		done'
@no_pixmapdir@	@echo "... removed icons"
################################################################################
# Desktop-utils does not provide an uninstall, and is not uniformly available.
@desktop_utils@DESKTOP_FILES = $(srcdir)/xterm.desktop $(srcdir)/uxterm.desktop
@desktop_utils@DESKTOP_FLAGS = @DESKTOP_FLAGS@
@desktop_utils@install-desktop \
@desktop_utils@install-full ::
@desktop_utils@	ACTUAL_XTERM=$(actual_xterm) \
@desktop_utils@	$(SHELL) -c 'for n in $(DESKTOP_FILES); \
@desktop_utils@		do $(SHELL) df-install $$ACTUAL_XTERM $(DESKTOP_FLAGS) $$n; \
@desktop_utils@		done'
################################################################################
mostlyclean :
	-$(RM) *$o *.[is] XtermLog.* .pure core *~ *.bak *.BAK *.out *.tmp

clean : mostlyclean
	-$(RM) $(PROGRAMS) builtin_icons.h *.cin *parse.hin

distclean :: clean
	-$(RM) Makefile config.status config.cache config.log xtermcfg.h
	-$(RM) df-install minstall

distclean \
docs-clean ::
	-$(RM) *.ps *.pdf *.png
	-$(SHELL) -c 'for p in xterm resize uxterm koi8rxterm; \
	do \
		$(RM) $$p.html $$p.$(manext) $$p.txt; \
	done'
	-$(RM) ctlseqs.html ctlseqs.$(manext)

distclean ::
	-$(RM) man2html.tmp

realclean : distclean
	-$(RM) tags TAGS

maintainer-clean : realclean
	-$(RM) 256colres.h 88colres.h
################################################################################
terminfo.out : terminfo		; tic -a -I -1 terminfo >$@
termcap.out : termcap		; tic -a -C -U termcap >$@
################################################################################
docs-ctlseqs \
docs :: $(srcdir)/ctlseqs.txt @MAN2HTML_NOTE@ ctlseqs.html @GROFF_NOTE@ ctlseqs.pdf ctlseqs.ps

ctlseqs.html : $(srcdir)/ctlseqs.ms
ctlseqs.pdf : ctlseqs.ps
ctlseqs.ps : $(srcdir)/ctlseqs.ms
ctlseqs.txt : $(srcdir)/ctlseqs.ms
################################################################################
docs-resize \
docs ::  resize.txt @MAN2HTML_NOTE@ resize.html @GROFF_NOTE@ resize.pdf resize.ps
resize.html : resize.$(manext)
resize.pdf : resize.ps
resize.ps : resize.$(manext)
resize.txt : resize.$(manext)
################################################################################
docs-xterm \
docs ::  xterm.txt @MAN2HTML_NOTE@ xterm.html @GROFF_NOTE@ xterm.pdf xterm.ps
xterm.html : xterm.$(manext)
xterm.pdf : xterm.ps
xterm.ps : xterm.$(manext)
xterm.txt : xterm.$(manext)
################################################################################
docs-uxterm \
docs ::  uxterm.txt @MAN2HTML_NOTE@ uxterm.html @GROFF_NOTE@ uxterm.pdf uxterm.ps
uxterm.html : uxterm.$(manext)
uxterm.pdf : uxterm.ps
uxterm.ps : uxterm.$(manext)
uxterm.txt : uxterm.$(manext)
################################################################################
docs-koi8rxterm \
docs ::  koi8rxterm.txt @MAN2HTML_NOTE@ koi8rxterm.html @GROFF_NOTE@ koi8rxterm.pdf koi8rxterm.ps
koi8rxterm.html : koi8rxterm.$(manext)
koi8rxterm.pdf : koi8rxterm.ps
koi8rxterm.ps : koi8rxterm.$(manext)
koi8rxterm.txt : koi8rxterm.$(manext)
################################################################################
lint :
	$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(SRCS1)
	$(LINT) $(LINT_OPTS) $(CPPFLAGS) $(SRCS2)

tags :
	$(CTAGS) $(SRCS) $(HDRS)

TAGS :
	$(ETAGS) $(SRCS) $(HDRS)

$(TERMINFO_DIR) $(INSTALL_DIRS) :
	mkdir -p $@

ALWAYS :

depend : $(TABLES)
	makedepend -- $(CPPFLAGS) -- $(SRCS)

# DO NOT DELETE THIS LINE -- make depend depends on it.
xterm-330/minstall.in0000644000175100001440000001314313003505500013403 0ustar  tomusers#!/bin/sh
# $XTermId: minstall.in,v 1.24 2016/10/24 22:29:20 tom Exp $
# -----------------------------------------------------------------------------
# this file is part of xterm
#
# Copyright 2001-2015,2016 by Thomas E. Dickey
#
#                         All Rights Reserved
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name(s) of the above copyright
# holders shall not be used in advertising or otherwise to promote the
# sale, use or other dealings in this Software without prior written
# authorization.
# -----------------------------------------------------------------------------
#
# Install manpages, substituting a reasonable section value since XFree86 4.x
# and derived imakes do not use constants...
#
# Parameters:
#	$1 = program to invoke as "install"
#	$2 = manpage to install
#	$3 = final installed-path
#	$4 = app-defaults directory
#	$5 = app-defaults class
#	$6 = application name, normally "xterm"
#	$7 = application name transformed
#	$8 = pixmap directory
#
# Other values correspond to definitions in xtermcfg.h, and cannot be directly
# modified using "make".  They are substituted directly into this script.
#

# override locale...
LANG=C;		export LANG
LANGUAGE=C;	export LANGUAGE
LC_ALL=C;	export LC_ALL
LC_CTYPE=C;	export LC_CTYPE
XTERM_LOCALE=C	export XTERM_LOCALE

# avoid interference by the "man" command.
for p in /bin /usr/bin
do
if test -f $p/cat ; then
MANPAGER=cat;   export MANPAGER
PAGER=cat;      export PAGER
break
fi
done

# get parameters
MINSTALL="$1"
OLD_FILE="$2"
END_FILE="$3"
APPS_DIR="$4"
APP_TYPE="$5"
APP_name="$6"
USE_name="$7"
XPMS_DIR="$8"

suffix=`echo "$END_FILE" | sed -e 's%^.*\.%%'`
NEW_FILE=temp$$

MY_MANSECT=$suffix

# utmp and wtmp have different pathnames on different systems, but there
# are only a few common choices.  Note that they may not necessarily appear
# in the same directories.  Prefer utmpx/wtmpx to utmp/wtmp, since that's
# the way the configure script is designed.
UTMP_NAME=utmp
UTMP_PATH=/etc
for name in /etc /var/adm /var/run /var/log
do
	if test -f $name/utmpx ; then
		UTMP_NAME=utmpx
		UTMP_PATH=$name
		break
	elif test -f $name/utmp ; then
		UTMP_PATH=$name
		break
	fi
done
UTMP_PATH=$UTMP_PATH/$UTMP_NAME

WTMP_NAME=wtmp
WTMP_PATH=/etc
for name in /etc /var/adm /var/run /var/log
do
	if test -f $name/wtmpx ; then
		WTMP_NAME=wtmpx
		WTMP_PATH=$name
		break
	elif test -f $name/wtmp ; then
		WTMP_PATH=$name
		break
	fi
done
WTMP_PATH=$WTMP_PATH/$WTMP_NAME

# "X" is usually in the miscellaneous section, along with "undocumented".
# Use that to guess an appropriate section.  This relies on having the manpage
# installed.
X_MANPAGE=X
X_MANSECT=`man $X_MANPAGE 2>&1 | grep $X_MANPAGE'([^)]*)' | head -n 1 | tr '\012' '\040' | sed -e 's/^[^0123456789]*\([^) ][^) ]*\).*/\1/'`
test -z "$X_MANSECT" && X_MANSECT=$suffix

VERSION_H=`echo "$OLD_FILE" | sed -e 's,/[^/]*$,/version.h,' -e s',^[^/]*$,version.h,'`
PATCH_NUM=`fgrep XTERM_PATCH $VERSION_H|sed -e 's/[^0-9]*//g'`
PATCH_YMD=`fgrep XTERM_DATE  $VERSION_H|sed -e 's,[^0-9/.-]*,,g'`

# Make capitalization variants
APP_chr0=`echo "$APP_name" | sed -e 's/^\(.\).*/\1/' | tr '[a-z]' '[A-Z]'`
APP_chr1=`echo "$APP_name" | sed -e 's/^.//'`
APP_Name=${APP_chr0}${APP_chr1}
APP_NAME=`echo "$APP_name" | tr '[a-z]' '[A-Z]'`

# Provide for renaming in test-builds:
USE_chr0=`echo "$USE_name" | sed -e 's/^\(.\).*/\1/' | tr '[a-z]' '[A-Z]'`
USE_chr1=`echo "$USE_name" | sed -e 's/^.//'`
USE_Name=${USE_chr0}${USE_chr1}
USE_NAME=`echo "$USE_name" | tr '[a-z]' '[A-Z]'`

sed	-e 's%__vendorversion__%"X Window System"%' \
	-e 's%__app_version__%Patch\ \#'$PATCH_NUM% \
	-e 's%__app_date__%'$PATCH_YMD% \
	-e "s%^\.TH [^ ][^ ]*%.TH $USE_NAME%" \
	-e "s%^\.ds N $APP_Name%.ds N $USE_Name%" \
	-e "s%^\.ds n $APP_name%.ds n $USE_name%" \
	-e 's%^'"$APP_name"' \\- %'"$USE_name"' \- %' \
	-e s%__default_termname__%@default_TERM@% \
	-e s%__default_termid__%@default_termid@% \
	-e s%__alt_sends_esc__%@alt_sends_esc@% \
	-e s%__meta_sends_esc__%@meta_sends_esc@% \
	-e s%__backarrow_is_bs__%@backarrow_is_bs@% \
	-e s%__backarrow_is_erase__%@backarrow_is_erase@% \
	-e s%__delete_is_del__%@delete_is_del@% \
	-e s%__initial_erase__%@initial_erase@% \
	-e s%__default_class__%$APP_TYPE% \
	-e s%__apploaddir__%$APPS_DIR% \
	-e s%__mansuffix__%$MY_MANSECT%g \
	-e s%__miscmansuffix__%$X_MANSECT%g \
	-e s%__pixmapsdir__%$XPMS_DIR% \
	-e s%fIutmp'\\%fI'$UTMP_NAME'\\%g' \
	-e s%/etc/utmp%$UTMP_PATH%g \
	-e s%fIwtmp'\\%fI'$WTMP_NAME'\\%g' \
	-e s%/etc/wtmp%$WTMP_PATH%g \
	-e 's%/\\(\*\*%/*%g' \
	$OLD_FILE >$NEW_FILE
# diff -u $OLD_FILE $NEW_FILE

echo "$MINSTALL $OLD_FILE $END_FILE"
eval "$MINSTALL $NEW_FILE $END_FILE"

rm -f $NEW_FILE
xterm-330/ctlseqs.txt0000644000175100001440000026103313117363777013502 0ustar  tomusers








                        XTerm Control Sequences


                               Edward Moy
                   University of California, Berkeley

                               Revised by

                             Stephen Gildea
                          X Consortium (1994)

                             Thomas Dickey
                      XFree86 Project (1996-2006)
                    invisible-island.net (2006-2017)
               updated for XTerm Patch #329 (2017/06/11)



Definitions

c    The literal character c.

C    A single (required) character.

Ps   A single (usually optional) numeric parameter, composed of one of
     more digits.

Pm   A multiple numeric parameter composed of any number of single
     numeric parameters, separated by ;  character(s).  Individual val-
     ues for the parameters are listed with Ps .

Pt   A text parameter composed of printable characters.

Control Bytes, Characters, and Sequences

ECMA-48 (aka "ISO 6429") documents C1 (8-bit) and C0 (7-bit) codes.
Those are respectively codes 128 to 159 and 0 to 31.  ECMA-48 avoids
referring to these codes as characters, because that term is associated
with graphic characters.  Instead, it uses "bytes" and "codes", with
occasional lapses to "characters" where the meaning cannot be mistaken.

Controls (including the escape code 27) are processed once:

o This means that a C1 control can be mistaken for badly-formed UTF-8
  when the terminal runs in UTF-8 mode because C1 controls are valid
  continuation bytes of a UTF-8 encoded (multibyte) value.

o It is not possible to use a C1 control obtained from decoding the
  UTF-8 text, because that would require reprocessing the data.  Conse-
  quently there is no ambiguity in the way this document uses the term
  "character" to refer to bytes in a control sequence.

The order of processing is a necessary consequence of the way ECMA-48 is
designed:

o Each byte sent to the terminal can be unambiguously determined to fall
  into one of a few categories (C0, C1 and graphic characters).

o ECMA-48 is modal; once it starts processing a control sequence, the
  terminal continues until the sequence is complete, or some byte is
  found which is not allowed in the sequence.

o Intermediate, parameter and final bytes may use the same codes as
  graphic characters, but they are processed as part of a control
  sequence and are not actually graphic characters.

o Eight-bit controls can have intermediate, etc., bytes in the range 160
  to 255.  Those can be treated as their counterparts in the range 32 to
  127.

o Single-byte controls can be handled separately from multi-byte control
  sequences because ECMA-48's rules are unambiguous.

  As a special case, ECMA-48 (section 9) mentions that the control func-
  tions shift-in and shift-out are allowed to occur within a 7-bit
  multibyte control sequence because those cannot alter the meaning of
  the control sequence.

o Some controls (such as OSC ) introduce a string mode, which is ended
  on a ST  (string terminator).

  Again, the terminal should accept single-byte controls within the
  string.  However, xterm has a resource setting brokenLinuxOSC to allow
  recovery from applications which rely upon malformed palette sequences
  used by the Linux console.

C1 (8-Bit) Control Characters

The xterm program recognizes both 8-bit and 7-bit control characters.
It generates 7-bit controls (by default) or 8-bit if S8C1T is enabled.
The following pairs of 7-bit and 8-bit control characters are equiva-
lent:

ESC D
     Index (IND  is 0x84).
ESC E
     Next Line (NEL  is 0x85).
ESC H
     Tab Set (HTS  is 0x88).
ESC M
     Reverse Index (RI  is 0x8d).
ESC N
     Single Shift Select of G2 Character Set (SS2  is 0x8e).  This
     affects next character only.
ESC O
     Single Shift Select of G3 Character Set (SS3  is 0x8f).  This
     affects next character only.
ESC P
     Device Control String (DCS  is 0x90).
ESC V
     Start of Guarded Area (SPA  is 0x96).
ESC W
     End of Guarded Area (EPA  is 0x97).
ESC X
     Start of String (SOS  is 0x98).
ESC Z
     Return Terminal ID (DECID is 0x9a).  Obsolete form of CSI c  (DA).
ESC [
     Control Sequence Introducer (CSI  is 0x9b).
ESC \
     String Terminator (ST  is 0x9c).
ESC ]
     Operating System Command (OSC  is 0x9d).
ESC ^
     Privacy Message (PM  is 0x9e).
ESC _
     Application Program Command (APC  is 0x9f).

These control characters are used in the vtXXX emulation.

VT100 Mode
Most of these control sequences are standard VT102 control sequences,
but there is support for later DEC VT terminals (i.e., VT220, VT320,
VT420, VT510), as well as ISO 6429 and aixterm color controls.  The only
VT102 feature not supported is auto-repeat, since the only way X pro-
vides for this will affect all windows.
There are additional control sequences to provide xterm-dependent func-
tions, such as the scrollbar or window size.  Where the function is
specified by DEC or ISO 6429, the code assigned to it is given in paren-
theses.
The escape codes to designate and invoke character sets are specified by
ISO 2022 (see that document for a discussion of character sets).
Many of the features are optional; xterm can be configured and built
without support for them.

Single-character functions
BEL       Bell (Ctrl-G).
BS        Backspace (Ctrl-H).
CR        Carriage Return (Ctrl-M).
ENQ       Return Terminal Status (Ctrl-E).  Default response is an empty
          string, but may be overridden by a resource answerbackString.
FF        Form Feed or New Page (NP).  (FF  is Ctrl-L).  FF  is treated
          the same as LF .
LF        Line Feed or New Line (NL).  (LF  is Ctrl-J).
SI        Shift In (Ctrl-O) -> Switch to Standard Character Set.  This
          invokes the G0 character set (the default).
SO        Shift Out (Ctrl-N) -> Switch to Alternate Character Set.  This
          invokes the G1 character set.
SP        Space.
TAB       Horizontal Tab (HT) (Ctrl-I).
VT        Vertical Tab (Ctrl-K).  This is treated the same as LF.

Controls beginning with ESC
This excludes controls where ESC  is part of a 7-bit equivalent to 8-bit
C1 controls, ordered by the final character(s).
ESC SP F  7-bit controls (S7C1T).
ESC SP G  8-bit controls (S8C1T).
ESC SP L  Set ANSI conformance level 1 (dpANS X3.134.1).
ESC SP M  Set ANSI conformance level 2 (dpANS X3.134.1).
ESC SP N  Set ANSI conformance level 3 (dpANS X3.134.1).
ESC # 3   DEC double-height line, top half (DECDHL).
ESC # 4   DEC double-height line, bottom half (DECDHL).
ESC # 5   DEC single-width line (DECSWL).
ESC # 6   DEC double-width line (DECDWL).
ESC # 8   DEC Screen Alignment Test (DECALN).
ESC % @   Select default character set.  That is ISO 8859-1 (ISO 2022).
ESC % G   Select UTF-8 character set (ISO 2022).
ESC ( C   Designate G0 Character Set (ISO 2022, VT100).
          Final character C for designating 94-character sets.  In this
          list, 0 , A  and B  apply to VT100 and up, the remainder to
          VT220 and up.  The VT220 character sets, together with the
          Portuguese character set are activated by the National
          Replacement Character controls.  The A  is a special case,
          since it is also activated by the VT300-control for British
          Latin-1 separately from the National Replacement Character
          controls.
            C = 0  -> DEC Special Character and Line Drawing Set.
            C = <  -> DEC Supplementary (VT200).
            C = % 5  -> DEC Supplementary Graphics (VT300).
            C = >  -> DEC Technical (VT300).
            C = A  -> United Kingdom (UK).
            C = B  -> United States (USASCII).
            C = 4  -> Dutch.
            C = C  or 5  -> Finnish.
            C = R  or f  -> French.
            C = Q  or 9  -> French Canadian (VT200, VT300).
            C = K  -> German.
            C = Y  -> Italian.
            C = ` , E  or 6  -> Norwegian/Danish.
            C = % 6  -> Portuguese (VT300).
            C = Z  -> Spanish.
            C = H  or 7  -> Swedish.
            C = =  -> Swiss.
ESC ) C   Designate G1 Character Set (ISO 2022, VT100).
          The same character sets apply as for ESC ( C.
ESC * C   Designate G2 Character Set (ISO 2022, VT220).
          The same character sets apply as for ESC ( C.
ESC + C   Designate G3 Character Set (ISO 2022, VT220).
          The same character sets apply as for ESC ( C.
ESC - C   Designate G1 Character Set (VT300).
          The same character sets apply as for ESC ( C.
ESC . C   Designate G2 Character Set (VT300).
          The same character sets apply as for ESC ( C.
ESC / C   Designate G3 Character Set (VT300).
          These work for 96-character sets only.
            C = A  -> ISO Latin-1 Supplemental.
ESC 6     Back Index (DECBI), VT420 and up.
ESC 7     Save Cursor (DECSC).
ESC 8     Restore Cursor (DECRC).
ESC 9     Forward Index (DECFI), VT420 and up.
ESC =     Application Keypad (DECKPAM).
ESC >     Normal Keypad (DECKPNM).
ESC F     Cursor to lower left corner of screen.  This is enabled by the
          hpLowerleftBugCompat resource.
ESC c     Full Reset (RIS).
ESC l     Memory Lock (per HP terminals).  Locks memory above the cur-
          sor.
ESC m     Memory Unlock (per HP terminals).
ESC n     Invoke the G2 Character Set as GL (LS2).
ESC o     Invoke the G3 Character Set as GL (LS3).
ESC |     Invoke the G3 Character Set as GR (LS3R).
ESC }     Invoke the G2 Character Set as GR (LS2R).
ESC ~     Invoke the G1 Character Set as GR (LS1R).

Application Program-Command functions
APC Pt ST None.  xterm implements no APC  functions; Pt is ignored.  Pt
          need not be printable characters.

Device-Control functions
DCS Ps; Ps| Pt ST
          User-Defined Keys (DECUDK).  The first parameter:
            Ps = 0  -> Clear all UDK definitions before starting
          (default).
            Ps = 1  -> Erase Below (default).
          The second parameter:
            Ps = 0  <- Lock the keys (default).
            Ps = 1  <- Do not lock.
          The third parameter is a ';'-separated list of strings denot-
          ing the key-code separated by a '/' from the hex-encoded key
          value.  The key codes correspond to the DEC function-key codes
          (e.g., F6=17).
DCS $ q Pt ST
          Request Status String (DECRQSS).  The string following the "q"
          is one of the following:
            " q     -> DECSCA
            " p     -> DECSCL
            r       -> DECSTBM
            s       -> DECSLRM
            m       -> SGR
            SP q    -> DECSCUSR
          xterm responds with DCS 1 $ r Pt ST for valid requests,
          replacing the Pt with the corresponding CSI string, or DCS 0 $
          r Pt ST for invalid requests.
DCS + p Pt ST
          Set Termcap/Terminfo Data (xterm, experimental).  The string
          following the "p" is a name to use for retrieving data from
          the terminal database.  The data will be used for the "tcap"
          keyboard configuration's function- and special-keys, as well
          as by the Request Termcap/Terminfo String control.
DCS + q Pt ST
          Request Termcap/Terminfo String (xterm, experimental).  The
          string following the "q" is a list of names encoded in hexa-
          decimal (2 digits per character) separated by ; which corre-
          spond to termcap or terminfo key names.
          Two special features are also recognized, which are not key
          names: Co for termcap colors (or colors for terminfo colors),
          and TN for termcap name (or name for terminfo name).
          xterm responds with DCS 1 + r Pt ST for valid requests, adding
          to Pt an = , and the value of the corresponding string that
          xterm would send, or DCS 0 + r Pt ST for invalid requests.
          The strings are encoded in hexadecimal (2 digits per charac-
          ter).

Functions using CSI , ordered by the final character(s)
CSI Ps @  Insert Ps (Blank) Character(s) (default = 1) (ICH).
CSI Ps A  Cursor Up Ps Times (default = 1) (CUU).
CSI Ps B  Cursor Down Ps Times (default = 1) (CUD).
CSI Ps C  Cursor Forward Ps Times (default = 1) (CUF).
CSI Ps D  Cursor Backward Ps Times (default = 1) (CUB).
CSI Ps E  Cursor Next Line Ps Times (default = 1) (CNL).
CSI Ps F  Cursor Preceding Line Ps Times (default = 1) (CPL).
CSI Ps G  Cursor Character Absolute  [column] (default = [row,1]) (CHA).
CSI Ps ; Ps H
          Cursor Position [row;column] (default = [1,1]) (CUP).
CSI Ps I  Cursor Forward Tabulation Ps tab stops (default = 1) (CHT).
CSI Ps J  Erase in Display (ED).
            Ps = 0  -> Erase Below (default).
            Ps = 1  -> Erase Above.
            Ps = 2  -> Erase All.
            Ps = 3  -> Erase Saved Lines (xterm).
CSI ? Ps J
          Erase in Display (DECSED).
            Ps = 0  -> Selective Erase Below (default).
            Ps = 1  -> Selective Erase Above.
            Ps = 2  -> Selective Erase All.
            Ps = 3  -> Selective Erase Saved Lines (xterm).
CSI Ps K  Erase in Line (EL).
            Ps = 0  -> Erase to Right (default).
            Ps = 1  -> Erase to Left.
            Ps = 2  -> Erase All.
CSI ? Ps K
          Erase in Line (DECSEL).
            Ps = 0  -> Selective Erase to Right (default).
            Ps = 1  -> Selective Erase to Left.
            Ps = 2  -> Selective Erase All.
CSI Ps L  Insert Ps Line(s) (default = 1) (IL).
CSI Ps M  Delete Ps Line(s) (default = 1) (DL).
CSI Ps P  Delete Ps Character(s) (default = 1) (DCH).
CSI Ps S  Scroll up Ps lines (default = 1) (SU).
CSI ? Pi; Pa; Pv S
          If configured to support either Sixel Graphics or ReGIS Graph-
          ics, xterm accepts a three-parameter control sequence, where
          Pi, Pa and Pv are the item, action and value:

            Pi = 1  -> item is number of color registers.
            Pi = 2  -> item is Sixel graphics geometry (in pixels).
            Pi = 3  -> item is ReGIS graphics geometry (in pixels).

            Pa = 1  -> read
            Pa = 2  -> reset to default
            Pa = 3  -> set to value in Pv
            Pa = 4  -> read the maximum allowed value

            Pv can be omitted except when setting (Pa == 3 ).
            Pv = n <- A single integer is used for color registers.
            Pv = width; height <- Two integers for graphics geometry.

          xterm replies with a control sequence of the same form:

               CSI ? Pi; Ps; Pv S

          where Ps is the status:
            Ps = 0  -> success.
            Ps = 1  -> error in Pi.
            Ps = 2  -> error in Pa.
            Ps = 3  -> failure.

          On success, Pv represents the value read or set.

          Notes:
          o The current implementation allows reading the graphics
            sizes, but disallows modifying those sizes because that is
            done once, using resource-values.
          o Graphics geometry is not necessarily the same as "window
            size" (see the dtterm window manipulation extensions). For
            example, xterm limits the maximum graphics geometry at com-
            pile time (1000x1000 as of version 328) although the window
            size can be larger.
          o While resizing a window will always change the current
            graphics geometry, the reverse is not true.  Setting graph-
            ics geometry does not affect the window size.
CSI Ps T  Scroll down Ps lines (default = 1) (SD).
CSI Ps ; Ps ; Ps ; Ps ; Ps T
          Initiate highlight mouse tracking.  Parameters are
          [func;startx;starty;firstrow;lastrow].  See the section Mouse
          Tracking.
CSI > Ps; Ps T
          Reset one or more features of the title modes to the default
          value.  Normally, "reset" disables the feature.  It is possi-
          ble to disable the ability to reset features by compiling a
          different default for the title modes into xterm.
            Ps = 0  -> Do not set window/icon labels using hexadecimal.
            Ps = 1  -> Do not query window/icon labels using hexadeci-
          mal.
            Ps = 2  -> Do not set window/icon labels using UTF-8.
            Ps = 3  -> Do not query window/icon labels using UTF-8.
          (See discussion of "Title Modes").
CSI Ps X  Erase Ps Character(s) (default = 1) (ECH).
CSI Ps Z  Cursor Backward Tabulation Ps tab stops (default = 1) (CBT).
CSI Pm `  Character Position Absolute  [column] (default = [row,1])
          (HPA).
CSI Pm a  Character Position Relative  [columns] (default = [row,col+1])
          (HPR).
CSI Ps b  Repeat the preceding graphic character Ps times (REP).
CSI Ps c  Send Device Attributes (Primary DA).
            Ps = 0  or omitted -> request attributes from terminal.  The
          response depends on the decTerminalID resource setting.
            -> CSI ? 1 ; 2 c  ("VT100 with Advanced Video Option")
            -> CSI ? 1 ; 0 c  ("VT101 with No Options")
            -> CSI ? 6 c  ("VT102")
            -> CSI ? 6 2 ; Psc  ("VT220")
            -> CSI ? 6 3 ; Psc  ("VT320")
            -> CSI ? 6 4 ; Psc  ("VT420")
          The VT100-style response parameters do not mean anything by
          themselves.  VT220 (and higher) parameters do, telling the
          host what features the terminal supports:
            Ps = 1  -> 132-columns.
            Ps = 2  -> Printer.
            Ps = 3  -> ReGIS graphics.
            Ps = 4  -> Sixel graphics.
            Ps = 6  -> Selective erase.
            Ps = 8  -> User-defined keys.
            Ps = 9  -> National Replacement Character sets.
            Ps = 1 5  -> Technical characters.
            Ps = 1 8  -> User windows.
            Ps = 2 1  -> Horizontal scrolling.
            Ps = 2 2  -> ANSI color, e.g., VT525.
            Ps = 2 9  -> ANSI text locator (i.e., DEC Locator mode).
CSI > Ps c
          Send Device Attributes (Secondary DA).
            Ps = 0  or omitted -> request the terminal's identification
          code.  The response depends on the decTerminalID resource set-
          ting.  It should apply only to VT220 and up, but xterm extends
          this to VT100.
            -> CSI  > Pp ; Pv ; Pc c
          where Pp denotes the terminal type
            Pp = 0  -> "VT100".
            Pp = 1  -> "VT220".
            Pp = 2  -> "VT240".
            Pp = 1 8 -> "VT330".
            Pp = 1 9 -> "VT340".
            Pp = 2 4 -> "VT320".
            Pp = 4 1 -> "VT420".
            Pp = 6 1 -> "VT510".
            Pp = 6 4 -> "VT520".
            Pp = 6 5 -> "VT525".
          and Pv is the firmware version (for xterm, this was originally
          the XFree86 patch number, starting with 95).  In a DEC termi-
          nal, Pc indicates the ROM cartridge registration number and is
          always zero.
CSI Pm d  Line Position Absolute  [row] (default = [1,column]) (VPA).
CSI Pm e  Line Position Relative  [rows] (default = [row+1,column])
          (VPR).
CSI Ps ; Ps f
          Horizontal and Vertical Position [row;column] (default =
          [1,1]) (HVP).
CSI Ps g  Tab Clear (TBC).
            Ps = 0  -> Clear Current Column (default).
            Ps = 3  -> Clear All.
CSI Pm h  Set Mode (SM).
            Ps = 2  -> Keyboard Action Mode (AM).
            Ps = 4  -> Insert Mode (IRM).
            Ps = 1 2  -> Send/receive (SRM).
            Ps = 2 0  -> Automatic Newline (LNM).
CSI ? Pm h
          DEC Private Mode Set (DECSET).
            Ps = 1  -> Application Cursor Keys (DECCKM).
            Ps = 2  -> Designate USASCII for character sets G0-G3
          (DECANM), and set VT100 mode.
            Ps = 3  -> 132 Column Mode (DECCOLM).
            Ps = 4  -> Smooth (Slow) Scroll (DECSCLM).
            Ps = 5  -> Reverse Video (DECSCNM).
            Ps = 6  -> Origin Mode (DECOM).
            Ps = 7  -> Wraparound Mode (DECAWM).
            Ps = 8  -> Auto-repeat Keys (DECARM).
            Ps = 9  -> Send Mouse X & Y on button press.  See the sec-
          tion Mouse Tracking.  This is the X10 xterm mouse protocol.
            Ps = 1 0  -> Show toolbar (rxvt).
            Ps = 1 2  -> Start Blinking Cursor (att610).
            Ps = 1 8  -> Print form feed (DECPFF).
            Ps = 1 9  -> Set print extent to full screen (DECPEX).
            Ps = 2 5  -> Show Cursor (DECTCEM).
            Ps = 3 0  -> Show scrollbar (rxvt).
            Ps = 3 5  -> Enable font-shifting functions (rxvt).
            Ps = 3 8  -> Enter Tektronix Mode (DECTEK).
            Ps = 4 0  -> Allow 80 -> 132 Mode.
            Ps = 4 1  -> more(1) fix (see curses resource).
            Ps = 4 2  -> Enable National Replacement Character sets
          (DECNRCM).
            Ps = 4 4  -> Turn On Margin Bell.
            Ps = 4 5  -> Reverse-wraparound Mode.
            Ps = 4 6  -> Start Logging.  This is normally disabled by a
          compile-time option.
            Ps = 4 7  -> Use Alternate Screen Buffer.  (This may be dis-
          abled by the titeInhibit resource).
            Ps = 6 6  -> Application keypad (DECNKM).
            Ps = 6 7  -> Backarrow key sends backspace (DECBKM).
            Ps = 6 9  -> Enable left and right margin mode (DECLRMM),
          VT420 and up.
            Ps = 9 5  -> Do not clear screen when DECCOLM is set/reset
          (DECNCSM), VT510 and up.
            Ps = 1 0 0 0  -> Send Mouse X & Y on button press and
          release.  See the section Mouse Tracking.  This is the X11
          xterm mouse protocol.
            Ps = 1 0 0 1  -> Use Hilite Mouse Tracking.
            Ps = 1 0 0 2  -> Use Cell Motion Mouse Tracking.
            Ps = 1 0 0 3  -> Use All Motion Mouse Tracking.
            Ps = 1 0 0 4  -> Send FocusIn/FocusOut events.
            Ps = 1 0 0 5  -> Enable UTF-8 Mouse Mode.
            Ps = 1 0 0 6  -> Enable SGR Mouse Mode.
            Ps = 1 0 0 7  -> Enable Alternate Scroll Mode, i.e., the
          alternateScroll resource.
            Ps = 1 0 1 0  -> Scroll to bottom on tty output (rxvt).
            Ps = 1 0 1 1  -> Scroll to bottom on key press (rxvt).
            Ps = 1 0 1 5  -> Enable urxvt Mouse Mode.
            Ps = 1 0 3 4  -> Interpret "meta" key, sets eighth bit.
          (enables the eightBitInput resource).
            Ps = 1 0 3 5  -> Enable special modifiers for Alt and Num-
          Lock keys.  (This enables the numLock resource).
            Ps = 1 0 3 6  -> Send ESC   when Meta modifies a key.  (This
          enables the metaSendsEscape resource).
            Ps = 1 0 3 7  -> Send DEL from the editing-keypad Delete
          key.
            Ps = 1 0 3 9  -> Send ESC  when Alt modifies a key.  (This
          enables the altSendsEscape resource).
            Ps = 1 0 4 0  -> Keep selection even if not highlighted.
          (This enables the keepSelection resource).
            Ps = 1 0 4 1  -> Use the CLIPBOARD selection.  (This enables
          the selectToClipboard resource).
            Ps = 1 0 4 2  -> Enable Urgency window manager hint when
          Control-G is received.  (This enables the bellIsUrgent
          resource).
            Ps = 1 0 4 3  -> Enable raising of the window when Control-G
          is received.  (enables the popOnBell resource).
            Ps = 1 0 4 4  -> Reuse the most recent data copied to CLIP-
          BOARD.  (This enables the keepClipboard resource).
            Ps = 1 0 4 7  -> Use Alternate Screen Buffer.  (This may be
          disabled by the titeInhibit resource).
            Ps = 1 0 4 8  -> Save cursor as in DECSC.  (This may be dis-
          abled by the titeInhibit resource).
            Ps = 1 0 4 9  -> Save cursor as in DECSC and use Alternate
          Screen Buffer, clearing it first.  (This may be disabled by
          the titeInhibit resource).  This combines the effects of the 1
          0 4 7  and 1 0 4 8  modes.  Use this with terminfo-based
          applications rather than the 4 7  mode.
            Ps = 1 0 5 0  -> Set terminfo/termcap function-key mode.
            Ps = 1 0 5 1  -> Set Sun function-key mode.
            Ps = 1 0 5 2  -> Set HP function-key mode.
            Ps = 1 0 5 3  -> Set SCO function-key mode.
            Ps = 1 0 6 0  -> Set legacy keyboard emulation (X11R6).
            Ps = 1 0 6 1  -> Set VT220 keyboard emulation.
            Ps = 2 0 0 4  -> Set bracketed paste mode.
CSI Pm i  Media Copy (MC).
            Ps = 0  -> Print screen (default).
            Ps = 4  -> Turn off printer controller mode.
            Ps = 5  -> Turn on printer controller mode.
            Ps = 1  0  -> HTML screen dump.
            Ps = 1  1  -> SVG screen dump.
CSI ? Pm i
          Media Copy (MC, DEC-specific).
            Ps = 1  -> Print line containing cursor.
            Ps = 4  -> Turn off autoprint mode.
            Ps = 5  -> Turn on autoprint mode.
            Ps = 1  0  -> Print composed display, ignores DECPEX.
            Ps = 1  1  -> Print all pages.
CSI Pm l  Reset Mode (RM).
            Ps = 2  -> Keyboard Action Mode (AM).
            Ps = 4  -> Replace Mode (IRM).
            Ps = 1 2  -> Send/receive (SRM).
            Ps = 2 0  -> Normal Linefeed (LNM).
CSI ? Pm l
          DEC Private Mode Reset (DECRST).
            Ps = 1  -> Normal Cursor Keys (DECCKM).
            Ps = 2  -> Designate VT52 mode (DECANM).
            Ps = 3  -> 80 Column Mode (DECCOLM).
            Ps = 4  -> Jump (Fast) Scroll (DECSCLM).
            Ps = 5  -> Normal Video (DECSCNM).
            Ps = 6  -> Normal Cursor Mode (DECOM).
            Ps = 7  -> No Wraparound Mode (DECAWM).
            Ps = 8  -> No Auto-repeat Keys (DECARM).
            Ps = 9  -> Don't send Mouse X & Y on button press.
            Ps = 1 0  -> Hide toolbar (rxvt).
            Ps = 1 2  -> Stop Blinking Cursor (att610).
            Ps = 1 8  -> Don't print form feed (DECPFF).
            Ps = 1 9  -> Limit print to scrolling region (DECPEX).
            Ps = 2 5  -> Hide Cursor (DECTCEM).
            Ps = 3 0  -> Don't show scrollbar (rxvt).
            Ps = 3 5  -> Disable font-shifting functions (rxvt).
            Ps = 4 0  -> Disallow 80 -> 132 Mode.
            Ps = 4 1  -> No more(1) fix (see curses resource).
            Ps = 4 2  -> Disable National Replacement Character sets
          (DECNRCM).
            Ps = 4 4  -> Turn Off Margin Bell.
            Ps = 4 5  -> No Reverse-wraparound Mode.
            Ps = 4 6  -> Stop Logging.  (This is normally disabled by a
          compile-time option).
            Ps = 4 7  -> Use Normal Screen Buffer.
            Ps = 6 6  -> Numeric keypad (DECNKM).
            Ps = 6 7  -> Backarrow key sends delete (DECBKM).
            Ps = 6 9  -> Disable left and right margin mode (DECLRMM),
          VT420 and up.
            Ps = 9 5  -> Clear screen when DECCOLM is set/reset (DEC-
          NCSM), VT510 and up.
            Ps = 1 0 0 0  -> Don't send Mouse X & Y on button press and
          release.  See the section Mouse Tracking.
            Ps = 1 0 0 1  -> Don't use Hilite Mouse Tracking.
            Ps = 1 0 0 2  -> Don't use Cell Motion Mouse Tracking.
            Ps = 1 0 0 3  -> Don't use All Motion Mouse Tracking.
            Ps = 1 0 0 4  -> Don't send FocusIn/FocusOut events.
            Ps = 1 0 0 5  -> Disable UTF-8 Mouse Mode.
            Ps = 1 0 0 6  -> Disable SGR Mouse Mode.
            Ps = 1 0 0 7  -> Disable Alternate Scroll Mode, i.e., the
          alternateScroll resource.
            Ps = 1 0 1 0  -> Don't scroll to bottom on tty output
          (rxvt).
            Ps = 1 0 1 1  -> Don't scroll to bottom on key press (rxvt).
            Ps = 1 0 1 5  -> Disable urxvt Mouse Mode.
            Ps = 1 0 3 4  -> Don't interpret "meta" key.  (This disables
          the eightBitInput resource).
            Ps = 1 0 3 5  -> Disable special modifiers for Alt and Num-
          Lock keys.  (This disables the numLock resource).
            Ps = 1 0 3 6  -> Don't send ESC  when Meta modifies a key.
          (This disables the metaSendsEscape resource).
            Ps = 1 0 3 7  -> Send VT220 Remove from the editing-keypad
          Delete key.
            Ps = 1 0 3 9  -> Don't send ESC  when Alt modifies a key.
          (This disables the altSendsEscape resource).
            Ps = 1 0 4 0  -> Do not keep selection when not highlighted.
          (This disables the keepSelection resource).
            Ps = 1 0 4 1  -> Use the PRIMARY selection.  (This disables
          the selectToClipboard resource).
            Ps = 1 0 4 2  -> Disable Urgency window manager hint when
          Control-G is received.  (This disables the bellIsUrgent
          resource).
            Ps = 1 0 4 3  -> Disable raising of the window when Control-
          G is received.  (This disables the popOnBell resource).
            Ps = 1 0 4 7  -> Use Normal Screen Buffer, clearing screen
          first if in the Alternate Screen.  (This may be disabled by
          the titeInhibit resource).
            Ps = 1 0 4 8  -> Restore cursor as in DECRC.  (This may be
          disabled by the titeInhibit resource).
            Ps = 1 0 4 9  -> Use Normal Screen Buffer and restore cursor
          as in DECRC.  (This may be disabled by the titeInhibit
          resource).  This combines the effects of the 1 0 4 7  and 1 0
          4 8  modes.  Use this with terminfo-based applications rather
          than the 4 7  mode.
            Ps = 1 0 5 0  -> Reset terminfo/termcap function-key mode.
            Ps = 1 0 5 1  -> Reset Sun function-key mode.
            Ps = 1 0 5 2  -> Reset HP function-key mode.
            Ps = 1 0 5 3  -> Reset SCO function-key mode.
            Ps = 1 0 6 0  -> Reset legacy keyboard emulation (X11R6).
            Ps = 1 0 6 1  -> Reset keyboard emulation to Sun/PC style.
            Ps = 2 0 0 4  -> Reset bracketed paste mode.
CSI Pm m  Character Attributes (SGR).
            Ps = 0  -> Normal (default).
            Ps = 1  -> Bold.
            Ps = 2  -> Faint, decreased intensity (ISO 6429).
            Ps = 3  -> Italicized (ISO 6429).
            Ps = 4  -> Underlined.
            Ps = 5  -> Blink (appears as Bold).
            Ps = 7  -> Inverse.
            Ps = 8  -> Invisible, i.e., hidden (VT300).
            Ps = 9  -> Crossed-out characters (ISO 6429).
            Ps = 2 1  -> Doubly-underlined (ISO 6429).
            Ps = 2 2  -> Normal (neither bold nor faint).
            Ps = 2 3  -> Not italicized (ISO 6429).
            Ps = 2 4  -> Not underlined.
            Ps = 2 5  -> Steady (not blinking).
            Ps = 2 7  -> Positive (not inverse).
            Ps = 2 8  -> Visible, i.e., not hidden (VT300).
            Ps = 2 9  -> Not crossed-out (ISO 6429).
            Ps = 3 0  -> Set foreground color to Black.
            Ps = 3 1  -> Set foreground color to Red.
            Ps = 3 2  -> Set foreground color to Green.
            Ps = 3 3  -> Set foreground color to Yellow.
            Ps = 3 4  -> Set foreground color to Blue.
            Ps = 3 5  -> Set foreground color to Magenta.
            Ps = 3 6  -> Set foreground color to Cyan.
            Ps = 3 7  -> Set foreground color to White.
            Ps = 3 9  -> Set foreground color to default (original).
            Ps = 4 0  -> Set background color to Black.
            Ps = 4 1  -> Set background color to Red.
            Ps = 4 2  -> Set background color to Green.
            Ps = 4 3  -> Set background color to Yellow.
            Ps = 4 4  -> Set background color to Blue.
            Ps = 4 5  -> Set background color to Magenta.
            Ps = 4 6  -> Set background color to Cyan.
            Ps = 4 7  -> Set background color to White.
            Ps = 4 9  -> Set background color to default (original).

          If 16-color support is compiled, the following apply.  Assume
          that xterm's resources are set so that the ISO color codes are
          the first 8 of a set of 16.  Then the aixterm colors are the
          bright versions of the ISO colors:
            Ps = 9 0  -> Set foreground color to Black.
            Ps = 9 1  -> Set foreground color to Red.
            Ps = 9 2  -> Set foreground color to Green.
            Ps = 9 3  -> Set foreground color to Yellow.
            Ps = 9 4  -> Set foreground color to Blue.
            Ps = 9 5  -> Set foreground color to Magenta.
            Ps = 9 6  -> Set foreground color to Cyan.
            Ps = 9 7  -> Set foreground color to White.
            Ps = 1 0 0  -> Set background color to Black.
            Ps = 1 0 1  -> Set background color to Red.
            Ps = 1 0 2  -> Set background color to Green.
            Ps = 1 0 3  -> Set background color to Yellow.
            Ps = 1 0 4  -> Set background color to Blue.
            Ps = 1 0 5  -> Set background color to Magenta.
            Ps = 1 0 6  -> Set background color to Cyan.
            Ps = 1 0 7  -> Set background color to White.

          If xterm is compiled with the 16-color support disabled, it
          supports the following, from rxvt:
            Ps = 1 0 0  -> Set foreground and background color to
          default.

          Xterm maintains a color palette whose entries are identified
          by an index beginning with zero.  If 88- or 256-color support
          is compiled, the following apply:
          o All parameters are decimal integers.
          o RGB values range from zero (0) to 255.
          o ISO-8613-3 can be interpreted in more than one way; xterm
            allows the semicolons in this control to be replaced by
            colons (but after the first colon, colons must be used).

          These ISO-8613-3 controls are supported:
            Pm = 3 8 ; 2 ; Pr; Pg; Pb -> Set foreground color to the
          closest match in xterm's palette for the given RGB Pr/Pg/Pb.
            Pm = 3 8 ; 5 ; Ps -> Set foreground color to Ps.
            Pm = 4 8 ; 2 ; Pr; Pg; Pb -> Set background color to the
          closest match in xterm's palette for the given RGB Pr/Pg/Pb.
            Pm = 4 8 ; 5 ; Ps -> Set background color to Ps.

CSI > Ps; Ps m
          Set or reset resource-values used by xterm to decide whether
          to construct escape sequences holding information about the
          modifiers pressed with a given key.  The first parameter iden-
          tifies the resource to set/reset.  The second parameter is the
          value to assign to the resource.  If the second parameter is
          omitted, the resource is reset to its initial value.
            Ps = 0  -> modifyKeyboard.
            Ps = 1  -> modifyCursorKeys.
            Ps = 2  -> modifyFunctionKeys.
            Ps = 4  -> modifyOtherKeys.
          If no parameters are given, all resources are reset to their
          initial values.
CSI Ps n  Device Status Report (DSR).
            Ps = 5  -> Status Report.
          Result ("OK") is CSI 0 n
            Ps = 6  -> Report Cursor Position (CPR) [row;column].
          Result is CSI r ; c R

          Note: it is possible for this sequence to be sent by a func-
          tion key.  For example, with the default keyboard configura-
          tion the shifted F1 key may send (with shift-, control-, alt-
          modifiers)
            CSI 1  ; 2  R , or
            CSI 1  ; 5  R , or
            CSI 1  ; 6  R , etc.
          The second parameter encodes the modifiers; values range from
          2 to 16.  See the section PC-Style Function Keys for the
          codes.  The modifyFunctionKeys and modifyKeyboard resources
          can change the form of the string sent from the modified F1
          key.

CSI > Ps n
          Disable modifiers which may be enabled via the CSI > Ps; Ps m
          sequence.  This corresponds to a resource value of "-1", which
          cannot be set with the other sequence.  The parameter identi-
          fies the resource to be disabled:
            Ps = 0  -> modifyKeyboard.
            Ps = 1  -> modifyCursorKeys.
            Ps = 2  -> modifyFunctionKeys.
            Ps = 4  -> modifyOtherKeys.
          If the parameter is omitted, modifyFunctionKeys is disabled.
          When modifyFunctionKeys is disabled, xterm uses the modifier
          keys to make an extended sequence of functions rather than
          adding a parameter to each function key to denote the modi-
          fiers.
CSI ? Ps n
          Device Status Report (DSR, DEC-specific).
            Ps = 6  -> Report Cursor Position (DECXCPR) [row;column] as
          CSI ? r ; c R (assumes the default page, i.e., "1").
            Ps = 1 5  -> Report Printer status as CSI ? 1 0 n  (ready).
          or CSI ? 1 1 n  (not ready).
            Ps = 2 5  -> Report UDK status as CSI ? 2 0 n  (unlocked) or
          CSI ? 2 1 n  (locked).
            Ps = 2 6  -> Report Keyboard status as
          CSI ? 2 7 ; 1 ; 0 ; 0 n  (North American).
          The last two parameters apply to VT400 & up, and denote key-
          board ready and LK01 respectively.
            Ps = 5 3  -> Report Locator status as CSI ? 5 3 n  Locator
          available, if compiled-in, or CSI ? 5 0 n  No Locator, if not.
            Ps = 5 5  -> Report Locator status as CSI ? 5 3 n  Locator
          available, if compiled-in, or CSI ? 5 0 n  No Locator, if not.
            Ps = 5 6  -> Report Locator type as CSI ? 5 7 ; 1 n  Mouse,
          if compiled-in, or CSI ? 5 7 ; 0 n  Cannot identify, if not.
            Ps = 6 2  -> Report macro space (DECMSR) as CSI Pn \* { .
            Ps = 6 3  -> Report memory checksum (DECCKSR) as DCS Pt ! x
          x x x ST .
              Pt is the request id (from an optional parameter to the
          request).
              The x's are hexadecimal digits 0-9 and A-F.
            Ps = 7 5  -> Report data integrity as CSI ? 7 0 n  (ready,
          no errors).
            Ps = 8 5  -> Report multi-session configuration as CSI ? 8 3
          n  (not configured for multiple-session operation).
CSI > Ps p
          Set resource value pointerMode.  This is used by xterm to
          decide whether to hide the pointer cursor as the user types.
          Valid values for the parameter:
            Ps = 0  -> never hide the pointer.
            Ps = 1  -> hide if the mouse tracking mode is not enabled.
            Ps = 2  -> always hide the pointer, except when leaving the
          window.
            Ps = 3  -> always hide the pointer, even if leaving/entering
          the window.  If no parameter is given, xterm uses the default,
          which is 1 .
CSI ! p   Soft terminal reset (DECSTR).
CSI Ps ; Ps " p
          Set conformance level (DECSCL).  Valid values for the first
          parameter:
            Ps = 6 1  -> VT100.
            Ps = 6 2  -> VT200.
            Ps = 6 3  -> VT300.
          Valid values for the second parameter:
            Ps = 0  -> 8-bit controls.
            Ps = 1  -> 7-bit controls (always set for VT100).
            Ps = 2  -> 8-bit controls.
CSI Ps $ p
          Request ANSI mode (DECRQM).  For VT300 and up, reply is
            CSI Ps; Pm$ y
          where Ps is the mode number as in RM, and Pm is the mode
          value:
            0 - not recognized
            1 - set
            2 - reset
            3 - permanently set
            4 - permanently reset
CSI ? Ps$ p
          Request DEC private mode (DECRQM).  For VT300 and up, reply is
            CSI ? Ps; Pm$ y
          where Ps is the mode number as in DECSET, Pm is the mode value
          as in the ANSI DECRQM.
CSI Ps q  Load LEDs (DECLL).
            Ps = 0  -> Clear all LEDS (default).
            Ps = 1  -> Light Num Lock.
            Ps = 2  -> Light Caps Lock.
            Ps = 3  -> Light Scroll Lock.
            Ps = 2  1  -> Extinguish Num Lock.
            Ps = 2  2  -> Extinguish Caps Lock.
            Ps = 2  3  -> Extinguish Scroll Lock.
CSI Ps SP q
          Set cursor style (DECSCUSR, VT520).
            Ps = 0  -> blinking block.
            Ps = 1  -> blinking block (default).
            Ps = 2  -> steady block.
            Ps = 3  -> blinking underline.
            Ps = 4  -> steady underline.
            Ps = 5  -> blinking bar (xterm).
            Ps = 6  -> steady bar (xterm).
CSI Ps " q
          Select character protection attribute (DECSCA).  Valid values
          for the parameter:
            Ps = 0  -> DECSED and DECSEL can erase (default).
            Ps = 1  -> DECSED and DECSEL cannot erase.
            Ps = 2  -> DECSED and DECSEL can erase.
CSI Ps ; Ps r
          Set Scrolling Region [top;bottom] (default = full size of win-
          dow) (DECSTBM).
CSI ? Pm r
          Restore DEC Private Mode Values.  The value of Ps previously
          saved is restored.  Ps values are the same as for DECSET.
CSI Pt; Pl; Pb; Pr; Ps$ r
          Change Attributes in Rectangular Area (DECCARA), VT400 and up.
            Pt; Pl; Pb; Pr denotes the rectangle.
            Ps denotes the SGR attributes to change: 0, 1, 4, 5, 7.
CSI s     Save cursor (ANSI.SYS), available only when DECLRMM is dis-
          abled.
CSI Pl; Pr s
          Set left and right margins (DECSLRM), available only when
          DECLRMM is enabled (VT420 and up).
CSI ? Pm s
          Save DEC Private Mode Values.  Ps values are the same as for
          DECSET.
CSI Ps ; Ps ; Ps t
          Window manipulation (from dtterm, as well as extensions).
          These controls may be disabled using the allowWindowOps
          resource.  Valid values for the first (and any additional
          parameters) are:
            Ps = 1  -> De-iconify window.
            Ps = 2  -> Iconify window.
            Ps = 3  ;  x ;  y -> Move window to [x, y].
            Ps = 4  ;  height ;  width -> Resize the xterm window to
          given height and width in pixels.  Omitted parameters reuse
          the current height or width.  Zero parameters use the dis-
          play's height or width.
            Ps = 5  -> Raise the xterm window to the front of the stack-
          ing order.
            Ps = 6  -> Lower the xterm window to the bottom of the
          stacking order.
            Ps = 7  -> Refresh the xterm window.
            Ps = 8  ;  height ;  width -> Resize the text area to given
          height and width in characters.  Omitted parameters reuse the
          current height or width.  Zero parameters use the display's
          height or width.
            Ps = 9  ;  0  -> Restore maximized window.
            Ps = 9  ;  1  -> Maximize window (i.e., resize to screen
          size).
            Ps = 9  ;  2  -> Maximize window vertically.
            Ps = 9  ;  3  -> Maximize window horizontally.
            Ps = 1 0  ;  0  -> Undo full-screen mode.
            Ps = 1 0  ;  1  -> Change to full-screen.
            Ps = 1 0  ;  2  -> Toggle full-screen.
            Ps = 1 1  -> Report xterm window state.  If the xterm window
          is open (non-iconified), it returns CSI 1 t .  If the xterm
          window is iconified, it returns CSI 2 t .
            Ps = 1 3  -> Report xterm window position.
          Result is CSI 3 ; x ; y t
            Ps = 1 4  -> Report xterm window in pixels.
          Result is CSI  4  ;  height ;  width t
            Ps = 1 8  -> Report the size of the text area in characters.
          Result is CSI  8  ;  height ;  width t
            Ps = 1 9  -> Report the size of the screen in characters.
          Result is CSI  9  ;  height ;  width t
            Ps = 2 0  -> Report xterm window's icon label.
          Result is OSC  L  label ST
            Ps = 2 1  -> Report xterm window's title.
          Result is OSC  l  label ST
            Ps = 2 2  ;  0  -> Save xterm icon and window title on
          stack.
            Ps = 2 2  ;  1  -> Save xterm icon title on stack.
            Ps = 2 2  ;  2  -> Save xterm window title on stack.
            Ps = 2 3  ;  0  -> Restore xterm icon and window title from
          stack.
            Ps = 2 3  ;  1  -> Restore xterm icon title from stack.
            Ps = 2 3  ;  2  -> Restore xterm window title from stack.
            Ps >= 2 4  -> Resize to Ps lines (DECSLPP).
CSI > Ps; Ps t
          Set one or more features of the title modes.  Each parameter
          enables a single feature.
            Ps = 0  -> Set window/icon labels using hexadecimal.
            Ps = 1  -> Query window/icon labels using hexadecimal.
            Ps = 2  -> Set window/icon labels using UTF-8.
            Ps = 3  -> Query window/icon labels using UTF-8.  (See dis-
          cussion of "Title Modes")
CSI Ps SP t
          Set warning-bell volume (DECSWBV, VT520).
            Ps = 0  or 1  -> off.
            Ps = 2 , 3  or 4  -> low.
            Ps = 5 , 6 , 7 , or 8  -> high.
CSI Pt; Pl; Pb; Pr; Ps$ t
          Reverse Attributes in Rectangular Area (DECRARA), VT400 and
          up.
            Pt; Pl; Pb; Pr denotes the rectangle.
            Ps denotes the attributes to reverse, i.e.,  1, 4, 5, 7.
CSI u     Restore cursor (ANSI.SYS).
CSI Ps SP u
          Set margin-bell volume (DECSMBV, VT520).
            Ps = 1  -> off.
            Ps = 2 , 3  or 4  -> low.
            Ps = 0 , 5 , 6 , 7 , or 8  -> high.
CSI Pt; Pl; Pb; Pr; Pp; Pt; Pl; Pp$ v
          Copy Rectangular Area (DECCRA, VT400 and up).
            Pt; Pl; Pb; Pr denotes the rectangle.
            Pp denotes the source page.
            Pt; Pl denotes the target location.
            Pp denotes the target page.
CSI Pt ; Pl ; Pb ; Pr ' w
          Enable Filter Rectangle (DECEFR), VT420 and up.
          Parameters are [top;left;bottom;right].
          Defines the coordinates of a filter rectangle and activates
          it.  Anytime the locator is detected outside of the filter
          rectangle, an outside rectangle event is generated and the
          rectangle is disabled.  Filter rectangles are always treated
          as "one-shot" events.  Any parameters that are omitted default
          to the current locator position.  If all parameters are omit-
          ted, any locator motion will be reported.  DECELR always can-
          cels any prevous rectangle definition.
CSI Ps x  Request Terminal Parameters (DECREQTPARM).
          if Ps is a "0" (default) or "1", and xterm is emulating VT100,
          the control sequence elicits a response of the same form whose
          parameters describe the terminal:
            Ps -> the given Ps incremented by 2.
            Pn = 1  <- no parity.
            Pn = 1  <- eight bits.
            Pn = 1  <- 2  8  transmit 38.4k baud.
            Pn = 1  <- 2  8  receive 38.4k baud.
            Pn = 1  <- clock multiplier.
            Pn = 0  <- STP flags.
CSI Ps * x
          Select Attribute Change Extent (DECSACE).
            Ps = 0  -> from start to end position, wrapped.
            Ps = 1  -> from start to end position, wrapped.
            Ps = 2  -> rectangle (exact).
CSI Pc ; Pt ; Pl ; Pb ; Pr $ x
          Fill Rectangular Area (DECFRA), VT420 and up.
            Pc is the character to use.
            Pt; Pl; Pb; Pr denotes the rectangle.
CSI Pi ; Pg ; Pt; Pl; Pb; Pr * y
          Request Checksum of Rectangular Area (DECRQCRA), VT420 and up.
          Response is
          DCS Pi ! x x x x ST
            Pi is the request id.
            Pg is the page number.
            Pt; Pl; Pb; Pr denotes the rectangle.
            The x's are hexadecimal digits 0-9 and A-F.
CSI Ps ; Pu ' z
          Enable Locator Reporting (DECELR).
          Valid values for the first parameter:
            Ps = 0  -> Locator disabled (default).
            Ps = 1  -> Locator enabled.
            Ps = 2  -> Locator enabled for one report, then disabled.
          The second parameter specifies the coordinate unit for locator
          reports.
          Valid values for the second parameter:
            Pu = 0  <- or omitted -> default to character cells.
            Pu = 1  <- device physical pixels.
            Pu = 2  <- character cells.
CSI Pt; Pl; Pb; Pr$ z
          Erase Rectangular Area (DECERA), VT400 and up.
            Pt; Pl; Pb; Pr denotes the rectangle.
CSI Pm ' {
          Select Locator Events (DECSLE).
          Valid values for the first (and any additional parameters)
          are:
            Ps = 0  -> only respond to explicit host requests (DECRQLP).
                       (This is default).  It also cancels any filter
                       rectangle.
            Ps = 1  -> report button down transitions.
            Ps = 2  -> do not report button down transitions.
            Ps = 3  -> report button up transitions.
            Ps = 4  -> do not report button up transitions.
CSI Pt; Pl; Pb; Pr $ {
          Selective Erase Rectangular Area (DECSERA), VT400 and up.
            Pt; Pl; Pb; Pr denotes the rectangle.
CSI Ps ' |
          Request Locator Position (DECRQLP).
          Valid values for the parameter are:
            Ps = 0 , 1 or omitted -> transmit a single DECLRP locator
          report.

          If Locator Reporting has been enabled by a DECELR, xterm will
          respond with a DECLRP Locator Report.  This report is also
          generated on button up and down events if they have been
          enabled with a DECSLE, or when the locator is detected outside
          of a filter rectangle, if filter rectangles have been enabled
          with a DECEFR.

            -> CSI Pe ; Pb ; Pr ; Pc ; Pp &  w

          Parameters are [event;button;row;column;page].
          Valid values for the event:
            Pe = 0  -> locator unavailable - no other parameters sent.
            Pe = 1  -> request - xterm received a DECRQLP.
            Pe = 2  -> left button down.
            Pe = 3  -> left button up.
            Pe = 4  -> middle button down.
            Pe = 5  -> middle button up.
            Pe = 6  -> right button down.
            Pe = 7  -> right button up.
            Pe = 8  -> M4 button down.
            Pe = 9  -> M4 button up.
            Pe = 1 0  -> locator outside filter rectangle.
          The "button" parameter is a bitmask indicating which buttons
          are pressed:
            Pb = 0  <- no buttons down.
            Pb & 1  <- right button down.
            Pb & 2  <- middle button down.
            Pb & 4  <- left button down.
            Pb & 8  <- M4 button down.
          The "row" and "column" parameters are the coordinates of the
          locator position in the xterm window, encoded as ASCII deci-
          mal.
          The "page" parameter is not used by xterm.
CSI Pm ' }
          Insert Ps Column(s) (default = 1) (DECIC), VT420 and up.
CSI Pm ' ~
          Delete Ps Column(s) (default = 1) (DECDC), VT420 and up.

Operating System Commands
OSC Ps ; Pt BEL
OSC Ps ; Pt ST
          Set Text Parameters.  For colors and font, if Pt is a "?", the
          control sequence elicits a response which consists of the con-
          trol sequence which would set the corresponding value.  The
          dtterm control sequences allow you to determine the icon name
          and window title.
            Ps = 0  -> Change Icon Name and Window Title to Pt.
            Ps = 1  -> Change Icon Name to Pt.
            Ps = 2  -> Change Window Title to Pt.
            Ps = 3  -> Set X property on top-level window.  Pt should be
          in the form "prop=value", or just "prop" to delete the prop-
          erty
            Ps = 4 ; c; spec -> Change Color Number c to the color spec-
          ified by spec.  This can be a name or RGB specification as per
          XParseColor.  Any number of c/spec pairs may be given.  The
          color numbers correspond to the ANSI colors 0-7, their bright
          versions 8-15, and if supported, the remainder of the 88-color
          or 256-color table.

          If a "?" is given rather than a name or RGB specification,
          xterm replies with a control sequence of the same form which
          can be used to set the corresponding color.  Because more than
          one pair of color number and specification can be given in one
          control sequence, xterm can make more than one reply.

            Ps = 5 ; c; spec -> Change Special Color Number c to the
          color specified by spec.  This can be a name or RGB specifica-
          tion as per XParseColor.  Any number of c/spec pairs may be
          given.  The special colors can also be set by adding the maxi-
          mum number of colors to these codes in an OSC 4  control:

              Pc = 0  <- resource colorBD (BOLD).
              Pc = 1  <- resource colorUL (UNDERLINE).
              Pc = 2  <- resource colorBL (BLINK).
              Pc = 3  <- resource colorRV (REVERSE).
              Pc = 4  <- resource colorIT (ITALIC).

            Ps = 6 ; c; f -> Enable/disable Special Color Number c.  OSC
          6  is the same as OSC 1 0 6 .

          The 10 colors (below) which may be set or queried using 1 0
          through 1 9  are denoted dynamic colors, since the correspond-
          ing control sequences were the first means for setting xterm's
          colors dynamically, i.e., after it was started.  They are not
          the same as the ANSI colors.  These controls may be disabled
          using the allowColorOps resource.  At least one parameter is
          expected for Pt.  Each successive parameter changes the next
          color in the list.  The value of Ps tells the starting point
          in the list.  The colors are specified by name or RGB specifi-
          cation as per XParseColor.

          If a "?" is given rather than a name or RGB specification,
          xterm replies with a control sequence of the same form which
          can be used to set the corresponding dynamic color.  Because
          more than one pair of color number and specification can be
          given in one control sequence, xterm can make more than one
          reply.

            Ps = 1 0  -> Change VT100 text foreground color to Pt.
            Ps = 1 1  -> Change VT100 text background color to Pt.
            Ps = 1 2  -> Change text cursor color to Pt.
            Ps = 1 3  -> Change mouse foreground color to Pt.
            Ps = 1 4  -> Change mouse background color to Pt.
            Ps = 1 5  -> Change Tektronix foreground color to Pt.
            Ps = 1 6  -> Change Tektronix background color to Pt.
            Ps = 1 7  -> Change highlight background color to Pt.
            Ps = 1 8  -> Change Tektronix cursor color to Pt.
            Ps = 1 9  -> Change highlight foreground color to Pt.

            Ps = 4 6  -> Change Log File to Pt.  (This is normally dis-
          abled by a compile-time option).

            Ps = 5 0  -> Set Font to Pt.  These controls may be disabled
          using the allowFontOps resource.  If Pt begins with a "#",
          index in the font menu, relative (if the next character is a
          plus or minus sign) or absolute.  A number is expected but not
          required after the sign (the default is the current entry for
          relative, zero for absolute indexing).
          The same rule (plus or minus sign, optional number) is used
          when querying the font.  The remainder of Pt is ignored.
          A font can be specified after a "#" index expression, by
          adding a space and then the font specifier.
          If the "TrueType Fonts" menu entry is set (the renderFont
          resource), then this control sets/queries the faceName
          resource.

            Ps = 5 1  -> reserved for Emacs shell.

            Ps = 5 2  -> Manipulate Selection Data.  These controls may
          be disabled using the allowWindowOps resource.  The parameter
          Pt is parsed as
               Pc; Pd
          The first, Pc, may contain zero or more characters from the
          set c  p  s  0  1  2  3  4  5  6  7 .  It is used to construct
          a list of selection parameters for clipboard, primary, select,
          or cut buffers 0 through 7 respectively, in the order given.
          If the parameter is empty, xterm uses s 0 , to specify the
          configurable primary/clipboard selection and cut buffer 0.
          The second parameter, Pd, gives the selection data.  Normally
          this is a string encoded in base64.  The data becomes the new
          selection, which is then available for pasting by other appli-
          cations.
          If the second parameter is a ? , xterm replies to the host
          with the selection data encoded using the same protocol.
          If the second parameter is neither a base64 string nor ? ,
          then the selection is cleared.

            Ps = 1 0 4 ; c -> Reset Color Number c.  It is reset to the
          color specified by the corresponding X resource.  Any number
          of c parameters may be given.  These parameters correspond to
          the ANSI colors 0-7, their bright versions 8-15, and if sup-
          ported, the remainder of the 88-color or 256-color table.  If
          no parameters are given, the entire table will be reset.

            Ps = 1 0 5 ; c -> Reset Special Color Number c.  It is reset
          to the color specified by the corresponding X resource.  Any
          number of c parameters may be given.  These parameters corre-
          spond to the special colors which can be set using an OSC 5
          control (or by adding the maximum number of colors using an
          OSC 4  control).

            Ps = 1 0 6 ; c; f -> Enable/disable Special Color Number c.
          The second parameter tells xterm to enable the corresponding
          color mode if nonzero, disable it if zero.

              Pc = 0  <- resource colorBDMode (BOLD).
              Pc = 1  <- resource colorULMode (UNDERLINE).
              Pc = 2  <- resource colorBLMode (BLINK).
              Pc = 3  <- resource colorRVMode (REVERSE).
              Pc = 4  <- resource colorITMode (ITALIC).
              Pc = 5  <- resource colorAttrMode (Override ANSI).

          The dynamic colors can also be reset to their default
          (resource) values:
            Ps = 1 1 0  -> Reset VT100 text foreground color.
            Ps = 1 1 1  -> Reset VT100 text background color.
            Ps = 1 1 2  -> Reset text cursor color.
            Ps = 1 1 3  -> Reset mouse foreground color.
            Ps = 1 1 4  -> Reset mouse background color.
            Ps = 1 1 5  -> Reset Tektronix foreground color.
            Ps = 1 1 6  -> Reset Tektronix background color.
            Ps = 1 1 7  -> Reset highlight color.
            Ps = 1 1 8  -> Reset Tektronix cursor color.
            Ps = 1 1 9  -> Reset highlight foreground color.

Privacy Message
PM Pt ST  xterm implements no PM  functions; Pt is ignored.  Pt need not
          be printable characters.

Alt and Meta Keys
Many keyboards have keys labeled "Alt".  Few have keys labeled "Meta".
However, xterm's default translations use the Meta modifier.  Common
keyboard configurations assign the Meta modifier to an "Alt" key.  By
using xmodmap one may have the modifier assigned to a different key, and
have "real" alt and meta keys.  Here is an example:

     ! put meta on mod3 to distinguish it from alt
     keycode 64 = Alt_L
     clear mod1
     add mod1 = Alt_L
     keycode 115 = Meta_L
     clear mod3
     add mod3 = Meta_L


The metaSendsEscape resource (and altSendsEscape if altIsNotMeta is set)
can be used to control the way the Meta modifier applies to ordinary
keys unless the modifyOtherKeys resource is set:
          - prefix a key with the ESC  character.
          - shift the key from codes 0-127 to 128-255 by adding 128.

The table shows the result for a given character "x" with modifiers
according to the default translations with the resources set on or off.
This assumes altIsNotMeta is set:

       -----------------------------------------------------------
       key          altSendsEscape   metaSendsEscape   result
       -----------+----------------+-----------------+------------
       x          | off            | off             | x
       Meta-x     | off            | off             | shift
       Alt-x      | off            | off             | shift
       Alt+Meta-x | off            | off             | shift
       x          | ON             | off             | x
       Meta-x     | ON             | off             | shift
       Alt-x      | ON             | off             | ESC  x
       Alt+Meta-x | ON             | off             | ESC  shift
       x          | off            | ON              | x
       Meta-x     | off            | ON              | ESC  x
       Alt-x      | off            | ON              | shift
       Alt+Meta-x | off            | ON              | ESC  shift
       x          | ON             | ON              | x
       Meta-x     | ON             | ON              | ESC  x
       Alt-x      | ON             | ON              | ESC  x
       Alt+Meta-x | ON             | ON              | ESC  x
       -----------+----------------+-----------------+------------


PC-Style Function Keys
If xterm does minimal translation of the function keys, it usually does
this with a PC-style keyboard, so PC-style function keys result.  Sun
keyboards are similar to PC keyboards.  Both have cursor and scrolling
operations printed on the keypad, which duplicate the smaller cursor and
scrolling keypads.

X does not predefine NumLock (used for VT220 keyboards) or Alt (used as
an extension for the Sun/PC keyboards) as modifiers.  These keys are
recognized as modifiers when enabled by the numLock resource, or by the
"DECSET 1 0 3 5 " control sequence.

The cursor keys transmit the following escape sequences depending on the
mode specified via the DECCKM escape sequence.

                  Key            Normal     Application
                  -------------+----------+-------------
                  Cursor Up    | CSI A    | SS3 A
                  Cursor Down  | CSI B    | SS3 B
                  Cursor Right | CSI C    | SS3 C
                  Cursor Left  | CSI D    | SS3 D
                  -------------+----------+-------------

The home- and end-keys (unlike PageUp and other keys also on the 6-key
editing keypad) are considered "cursor keys" by xterm.  Their mode is
also controlled by the DECCKM escape sequence:

                    Key        Normal     Application
                    ---------+----------+-------------
                    Home     | CSI H    | SS3 H
                    End      | CSI F    | SS3 F
                    ---------+----------+-------------


The application keypad transmits the following escape sequences depend-
ing on the mode specified via the DECKPNM and DECKPAM escape sequences.
Use the NumLock key to override the application mode.

Not all keys are present on the Sun/PC keypad (e.g., PF1, Tab), but are
supported by the program.

      Key              Numeric    Application   Terminfo   Termcap
      ---------------+----------+-------------+----------+----------
      Space          | SP       | SS3 SP      | -        | -
      Tab            | TAB      | SS3 I       | -        | -
      Enter          | CR       | SS3 M       | kent     | @8
      PF1            | SS3 P    | SS3 P       | kf1      | k1
      PF2            | SS3 Q    | SS3 Q       | kf2      | k2
      PF3            | SS3 R    | SS3 R       | kf3      | k3
      PF4            | SS3 S    | SS3 S       | kf4      | k4
      * (multiply)   | *        | SS3 j       | -        | -
      + (add)        | +        | SS3 k       | -        | -
      , (comma)      | ,        | SS3 l       | -        | -
      - (minus)      | -        | SS3 m       | -        | -
      . (Delete)     | .        | CSI 3 ~     | -        | -
      / (divide)     | /        | SS3 o       | -        | -
      0 (Insert)     | 0        | CSI 2 ~     | -        | -
      1 (End)        | 1        | SS3 F       | kc1      | K4
      2 (DownArrow)  | 2        | CSI B       | -        | -
      3 (PageDown)   | 3        | CSI 6 ~     | kc3      | K5
      4 (LeftArrow)  | 4        | CSI D       | -        | -
      5 (Begin)      | 5        | CSI E       | kb2      | K2
      6 (RightArrow) | 6        | CSI C       | -        | -
      7 (Home)       | 7        | SS3 H       | ka1      | K1
      8 (UpArrow)    | 8        | CSI A       | -        | -
      9 (PageUp)     | 9        | CSI 5 ~     | ka3      | K3
      = (equal)      | =        | SS3 X       | -        | -
      ---------------+----------+-------------+----------+----------

They also provide 12 function keys, as well as a few other special-pur-
pose keys:

                       Key        Escape Sequence
                       ---------+-----------------
                       F1       | SS3 P
                       F2       | SS3 Q
                       F3       | SS3 R
                       F4       | SS3 S
                       F5       | CSI 1 5 ~
                       F6       | CSI 1 7 ~
                       F7       | CSI 1 8 ~
                       F8       | CSI 1 9 ~
                       F9       | CSI 2 0 ~
                       F10      | CSI 2 1 ~
                       F11      | CSI 2 3 ~
                       F12      | CSI 2 4 ~
                       ---------+-----------------


Note that F1 through F4 are prefixed with SS3 , while the other keys are
prefixed with CSI .  Older versions of xterm implement different escape
sequences for F1 through F4, with a CSI  prefix.  These can be activated
by setting the oldXtermFKeys resource.  However, since they do not cor-
respond to any hardware terminal, they have been deprecated.  (The DEC
VT220 reserves F1 through F5 for local functions such as Setup).

                       Key        Escape Sequence
                       ---------+-----------------
                       F1       | CSI 1 1 ~
                       F2       | CSI 1 2 ~
                       F3       | CSI 1 3 ~
                       F4       | CSI 1 4 ~
                       ---------+-----------------

In normal mode, i.e., a Sun/PC keyboard when the sunKeyboard resource is
false (and none of the other keyboard resources such as oldXtermFKeys
resource is set), xterm encodes function key modifiers as parameters
appended before the final character of the control sequence.  As a spe-
cial case, the SS3  sent before F1 through F4 is altered to CSI  when
sending a function key modifier as a parameter.

                    Code     Modifiers
                  ---------+---------------------------
                     2     | Shift
                     3     | Alt
                     4     | Shift + Alt
                     5     | Control
                     6     | Shift + Control
                     7     | Alt + Control
                     8     | Shift + Alt + Control
                     9     | Meta
                     10    | Meta + Shift
                     11    | Meta + Alt
                     12    | Meta + Alt + Shift
                     13    | Meta + Ctrl
                     14    | Meta + Ctrl + Shift
                     15    | Meta + Ctrl + Alt
                     16    | Meta + Ctrl + Alt + Shift
                  ---------+---------------------------

For example, shift-F5 would be sent as CSI 1 5 ; 2 ~

If the alwaysUseMods resource is set, the Meta modifier also is recog-
nized, making parameters 9 through 16.

VT220-Style Function Keys
However, xterm is most useful as a DEC VT102 or VT220 emulator.  Set the
sunKeyboard resource to true to force a Sun/PC keyboard to act like a
VT220 keyboard.

The VT102/VT220 application keypad transmits unique escape sequences in
application mode, which are distinct from the cursor and scrolling key-
pad:

                  Key            Numeric    Application
                  -------------+----------+-------------
                  Space        | SP       | SS3 SP
                  Tab          | TAB      | SS3 I
                  Enter        | CR       | SS3 M
                  PF1          | SS3 P    | SS3 P
                  PF2          | SS3 Q    | SS3 Q
                  PF3          | SS3 R    | SS3 R
                  PF4          | SS3 S    | SS3 S
                  * (multiply) | *        | SS3 j
                  + (add)      | +        | SS3 k
                  , (comma)    | ,        | SS3 l
                  - (minus)    | -        | SS3 m
                  . (period)   | .        | SS3 n
                  / (divide)   | /        | SS3 o
                  0            | 0        | SS3 p
                  1            | 1        | SS3 q
                  2            | 2        | SS3 r
                  3            | 3        | SS3 s
                  4            | 4        | SS3 t
                  5            | 5        | SS3 u
                  6            | 6        | SS3 v
                  7            | 7        | SS3 w
                  8            | 8        | SS3 x
                  9            | 9        | SS3 y
                  = (equal)    | =        | SS3 X
                  -------------+----------+-------------

The VT220 provides a 6-key editing keypad, which is analogous to that on
the PC keyboard.  It is not affected by DECCKM or DECKPNM/DECKPAM:

                   Key        Normal     Application
                   ---------+----------+-------------
                   Insert   | CSI 2 ~  | CSI 2 ~
                   Delete   | CSI 3 ~  | CSI 3 ~
                   Home     | CSI 1 ~  | CSI 1 ~
                   End      | CSI 4 ~  | CSI 4 ~
                   PageUp   | CSI 5 ~  | CSI 5 ~
                   PageDown | CSI 6 ~  | CSI 6 ~
                   ---------+----------+-------------

The VT220 provides 8 additional function keys.  With a Sun/PC keyboard,
access these keys by Control/F1 for F13, etc.

                       Key        Escape Sequence
                       ---------+-----------------
                       F13      | CSI 2 5 ~
                       F14      | CSI 2 6 ~
                       F15      | CSI 2 8 ~
                       F16      | CSI 2 9 ~
                       F17      | CSI 3 1 ~
                       F18      | CSI 3 2 ~
                       F19      | CSI 3 3 ~
                       F20      | CSI 3 4 ~
                       ---------+-----------------


VT52-Style Function Keys
A VT52 does not have function keys, but it does have a numeric keypad
and cursor keys.  They differ from the other emulations by the prefix.
Also, the cursor keys do not change:

                   Key            Normal/Application
                   -------------+--------------------
                   Cursor Up    | ESC A
                   Cursor Down  | ESC B
                   Cursor Right | ESC C
                   Cursor Left  | ESC D
                   -------------+--------------------

The keypad is similar:

                  Key            Numeric    Application
                  -------------+----------+-------------
                  Space        | SP       | ESC ? SP
                  Tab          | TAB      | ESC ? I
                  Enter        | CR       | ESC ? M
                  PF1          | ESC P    | ESC P
                  PF2          | ESC Q    | ESC Q
                  PF3          | ESC R    | ESC R
                  PF4          | ESC S    | ESC S
                  * (multiply) | *        | ESC ? j
                  + (add)      | +        | ESC ? k
                  , (comma)    | ,        | ESC ? l
                  - (minus)    | -        | ESC ? m
                  . (period)   | .        | ESC ? n
                  / (divide)   | /        | ESC ? o
                  0            | 0        | ESC ? p
                  1            | 1        | ESC ? q
                  2            | 2        | ESC ? r
                  3            | 3        | ESC ? s
                  4            | 4        | ESC ? t
                  5            | 5        | ESC ? u
                  6            | 6        | ESC ? v
                  7            | 7        | ESC ? w
                  8            | 8        | ESC ? x
                  9            | 9        | ESC ? y
                  = (equal)    | =        | ESC ? X
                  -------------+----------+-------------


Sun-Style Function Keys
The xterm program provides support for Sun keyboards more directly, by a
menu toggle that causes it to send Sun-style function key codes rather
than VT220.  Note, however, that the sun and VT100 emulations are not
really compatible.  For example, their wrap-margin behavior differs.

Only function keys are altered; keypad and cursor keys are the same.
The emulation responds identically.  See the xterm-sun terminfo entry
for details.

HP-Style Function Keys
Similarly, xterm can be compiled to support HP keyboards.  See the
xterm-hp terminfo entry for details.

The Alternate Screen Buffer
Xterm maintains two screen buffers.  The normal screen buffer allows you
to scroll back to view saved lines of output up to the maximum set by
the saveLines resource.  The alternate screen buffer is exactly as large
as the display, contains no additional saved lines.  When the alternate
screen buffer is active, you cannot scroll back to view saved lines.
Xterm provides control sequences and menu entries for switching between
the two.

Most full-screen applications use terminfo or termcap to obtain strings
used to start/stop full-screen mode, i.e., smcup and rmcup for terminfo,
or the corresponding ti and te for termcap.  The titeInhibit resource
removes the ti and te strings from the TERMCAP string which is set in
the environment for some platforms.  That is not done when xterm is
built with terminfo libraries because terminfo does not provide the
whole text of the termcap data in one piece.  It would not work for ter-
minfo anyway, since terminfo data is not passed in environment vari-
ables; setting an environment variable in this manner would have no
effect on the application's ability to switch between normal and alter-
nate screen buffers.  Instead, the newer private mode controls (such as
1 0 4 9 ) for switching between normal and alternate screen buffers sim-
ply disable the switching.  They add other features such as clearing the
display for the same reason: to make the details of switching indepen-
dent of the application that requests the switch.

Bracketed Paste Mode
When bracketed paste mode is set, pasted text is bracketed with control
sequences so that the program can differentiate pasted text from typed-
in text.  When bracketed paste mode is set, the program will receive:
   ESC [ 2 0 0 ~ ,
followed by the pasted text, followed by
   ESC [ 2 0 1 ~ .

Title Modes
The window- and icon-labels can be set or queried using control
sequences.  As a VT220-emulator, xterm "should" limit the character
encoding for the corresponding strings to ISO-8859-1.  Indeed, it used
to be the case (and was documented) that window titles had to be
ISO-8859-1.  This is no longer the case.  However, there are many appli-
cations which still assume that titles are set using ISO-8859-1.  So
that is the default behavior.

If xterm is running with UTF-8 encoding, it is possible to use window-
and icon-labels encoded using UTF-8.  That is because the underlying X
libraries (and many, but not all) window managers support this feature.

The utf8Title X resource setting tells xterm to disable a reconversion
of the title string back to ISO-8859-1, allowing the title strings to be
interpreted as UTF-8.  The same feature can be enabled using the title
mode control sequence described in this summary.

Separate from the ability to set the titles, xterm provides the ability
to query the titles, returning them either in ISO-8859-1 or UTF-8.  This
choice is available only while xterm is using UTF-8 encoding.

Finally, the characters sent to, or returned by a title control are less
constrained than the rest of the control sequences.  To make them more
manageable (and constrained), for use in shell scripts, xterm has an
optional feature which decodes the string from hexadecimal (for setting
titles) or for encoding the title into hexadecimal when querying the
value.

Mouse Tracking
The VT widget can be set to send the mouse position and other informa-
tion on button presses.  These modes are typically used by editors and
other full-screen applications that want to make use of the mouse.

There are two sets of mutually exclusive modes:
o mouse protocol
o protocol encoding

The mouse protocols include DEC Locator mode, enabled by the DECELR CSI
Ps ; Ps  '  z control sequence, and is not described here (control
sequences are summarized above).  The remaining five modes of the mouse
protocols are each enabled (or disabled) by a different parameter in the
"DECSET CSI ? Pm h " or "DECRST CSI ? Pm l " control sequence.

Manifest constants for the parameter values are defined in xcharmouse.h
as follows:

     #define SET_X10_MOUSE               9
     #define SET_VT200_MOUSE             1000
     #define SET_VT200_HIGHLIGHT_MOUSE   1001
     #define SET_BTN_EVENT_MOUSE         1002
     #define SET_ANY_EVENT_MOUSE         1003

     #define SET_FOCUS_EVENT_MOUSE       1004

     #define SET_EXT_MODE_MOUSE          1005
     #define SET_SGR_EXT_MODE_MOUSE      1006
     #define SET_URXVT_EXT_MODE_MOUSE    1015

     #define SET_ALTERNATE_SCROLL        1007

The motion reporting modes are strictly xterm extensions, and are not
part of any standard, though they are analogous to the DEC VT200 DECELR
locator reports.

Normally, parameters (such as pointer position and button number) for
all mouse tracking escape sequences generated by xterm encode numeric
parameters in a single character as value+32.  For example, !  specifies
the value 1.  The upper left character position on the terminal is
denoted as 1,1.  This scheme dates back to X10, though the normal mouse-
tracking (from X11) is more elaborate.
X10 compatbility mode

X10 compatibility mode sends an escape sequence only on button press,
encoding the location and the mouse button pressed.  It is enabled by
specifying parameter 9 to DECSET.  On button press, xterm sends CSI M
CbCxCy (6 characters).
o Cb is button-1.
o Cx and Cy are the x and y coordinates of the mouse when the button was
  pressed.
Normal tracking mode

Normal tracking mode sends an escape sequence on both button press and
release.  Modifier key (shift, ctrl, meta) information is also sent.  It
is enabled by specifying parameter 1000 to DECSET.  On button press or
release, xterm sends CSI M CbCxCy.
o The low two bits of Cb encode button information: 0=MB1 pressed, 1=MB2
  pressed, 2=MB3 pressed, 3=release.
o The next three bits encode the modifiers which were down when the but-
  ton was pressed and are added together:  4=Shift, 8=Meta, 16=Control.
  Note however that the shift and control bits are normally unavailable
  because xterm uses the control modifier with mouse for popup menus,
  and the shift modifier is used in the default translations for button
  events.  The Meta modifier recognized by xterm is the mod1 mask, and
  is not necessarily the "Meta" key (see xmodmap).
o Cx and Cy are the x and y coordinates of the mouse event, encoded as
  in X10 mode.
Wheel mice

Wheel mice may return buttons 4 and 5.  Those buttons are represented by
the same event codes as buttons 1 and 2 respectively, except that 64 is
added to the event code.  Release events for the wheel buttons are not
reported.  By default, the wheel mouse events are translated to scroll-
back and scroll-forw actions.  Those actions normally scroll the whole
window, as if the scrollbar was used.  However if Alternate Scroll mode
is set, then cursor up/down controls are sent when the terminal is dis-
playing the alternate screen.  The initial state of Alternate Scroll
mode is set using the alternateScroll resource.
Highlight tracking

Mouse highlight tracking notifies a program of a button press, receives
a range of lines from the program, highlights the region covered by the
mouse within that range until button release, and then sends the program
the release coordinates.  It is enabled by specifying parameter 1001 to
DECSET.  Highlighting is performed only for button 1, though other but-
ton events can be received.

Warning: use of this mode requires a cooperating program or it will hang
xterm.

On button press, the same information as for normal tracking is gener-
ated; xterm then waits for the program to send mouse tracking informa-
tion.  All X events are ignored until the proper escape sequence is
received from the pty: CSI Ps ; Ps ; Ps ; Ps ; Ps T .  The parameters
are func, startx, starty, firstrow, and lastrow.  func is non-zero to
initiate highlight tracking and zero to abort.  startx and starty give
the starting x and y location for the highlighted region.  The ending
location tracks the mouse, but will never be above row firstrow and will
always be above row lastrow.  (The top of the screen is row 1.)  When
the button is released, xterm reports the ending position one of two
ways:
o if the start and end coordinates are the same locations:
  CSI t CxCy.
o otherwise:
  CSI T CxCyCxCyCxCy.
  The parameters are startx, starty, endx, endy, mousex, and mousey.
  - startx, starty, endx, and endy give the starting and ending charac-
    ter positions of the region.
  - mousex and mousey give the location of the mouse at button up, which
    may not be over a character.
Button-event tracking

Button-event tracking is essentially the same as normal tracking, but
xterm also reports button-motion events.  Motion events are reported
only if the mouse pointer has moved to a different character cell.  It
is enabled by specifying parameter 1002 to DECSET.  On button press or
release, xterm sends the same codes used by normal tracking mode.
o On button-motion events, xterm adds 32 to the event code (the third
  character, Cb).
o The other bits of the event code specify button and modifier keys as
  in normal mode.  For example, motion into cell x,y with button 1 down
  is reported as CSI M @ CxCy.  ( @  = 32 + 0 (button 1) + 32 (motion
  indicator) ).  Similarly, motion with button 3 down is reported as CSI
  M B CxCy.  ( B  = 32 + 2 (button 3) + 32 (motion indicator) ).
Any-event tracking

Any-event mode is the same as button-event mode, except that all motion
events are reported, even if no mouse button is down.  It is enabled by
specifying 1003 to DECSET.
FocusIn/FocusOut

FocusIn/FocusOut can be combined with any of the mouse events since it
uses a different protocol.  When set, it causes xterm to send CSI I
when the terminal gains focus, and CSI O  when it loses focus.
Extended coordinates

The original X10 mouse protocol limits the Cx and Cy ordinates to 223
(=255 - 32).  Xterm supports more than one scheme for extending this
range, by changing the protocol encoding:
UTF-8 (1005)
          This enables UTF-8 encoding for Cx and Cy under all tracking
          modes, expanding the maximum encodable position from 223 to
          2015.  For positions less than 95, the resulting output is
          identical under both modes.  Under extended mouse mode, posi-
          tions greater than 95 generate "extra" bytes which will con-
          fuse applications which do not treat their input as a UTF-8
          stream.  Likewise, Cb will be UTF-8 encoded, to reduce confu-
          sion with wheel mouse events.
          Under normal mouse mode, positions outside (160,94) result in
          byte pairs which can be interpreted as a single UTF-8 charac-
          ter; applications which do treat their input as UTF-8 will
          almost certainly be confused unless extended mouse mode is
          active.
          This scheme has the drawback that the encoded coordinates will
          not pass through luit unchanged, e.g., for locales using non-
          UTF-8 encoding.
SGR (1006)
          The normal mouse response is altered to use CSI < followed by
          semicolon-separated encoded button value, the Cx and Cy ordi-
          nates and a final character which is M  for button press and m
          for button release.
          o The encoded button value in this case does not add 32 since
            that was useful only in the X10 scheme for ensuring that the
            byte containing the button value is a printable code.
          o The modifiers are encoded in the same way.
          o A different final character is used for button release to
            resolve the X10 ambiguity regarding which button was
            released.
          The highlight tracking responses are also modified to an SGR-
          like format, using the same SGR-style scheme and button-encod-
          ings.
URXVT (1015)
          The normal mouse response is altered to use CSI followed by
          semicolon-separated encoded button value, the Cx and Cy ordi-
          nates and final character M .
          This uses the same button encoding as X10, but printing it as
          a decimal integer rather than as a single byte.
          However, CSI M  can be mistaken for DL (delete lines), while
          the highlight tracking CSI T  can be mistaken for SD (scroll
          down), and the Window manipulation controls.  For these rea-
          sons, the 1015 control is not recommended; it is not an
          improvement over 1005.

Sixel Graphics
If xterm is configured as VT240, VT241, VT330, VT340 or VT382 using the
decTerminalID resource, it supports Sixel Graphics controls, a palleted
bitmap graphics system using sets of six vertical pixels as the basic
element.

CSI Ps c  xterm responds to Send Device Attributes (Primary DA) with
          these additional codes:
            Ps = 4  -> Sixel graphics.
CSI ? Pm h
          xterm has these additional private Set Mode values:
            Ps = 8 0  -> Sixel scrolling.
            Ps = 1 0 7 0  -> use private color registers for each
          graphic.
            Ps = 8 4 5 2  -> Sixel scrolling leaves cursor to right of
          graphic.
DCS Pa; Pb; Ph q  Ps..Ps ST
          See:

               http://vt100.net/docs/vt3xx-gp/chapter14.html

          The sixel data device control string has three positional
          parameters, following the q  with sixel data.
            Pa -> pixel aspect ratio
            Pb -> background color option
            Ph -> horizontal grid size (ignored).
            Ps -> sixel data

ReGIS Graphics
If xterm is configured as VT125, VT240, VT241, VT330 or VT340 using the
decTerminalID resource, it supports Remote Graphic Instruction Set, a
graphics description language.

CSI Ps c  xterm responds to Send Device Attributes (Primary DA) with
          these additional codes:
            Ps = 3  -> ReGIS graphics.
CSI ? Pm h
          xterm has these additional private Set Mode values:
            Ps = 1 0 7 0  -> use private color registers for each
          graphic.
DCS Pm p Pr..Pr ST
          See:

               http://vt100.net/docs/vt3xx-gp/chapter1.html

          The ReGIS data device control string has one positional param-
          eter with four possible values:
            Pm = 0 -> resume command, use fullscreen mode.
            Pm = 1 -> start new command, use fullscreen mode.
            Pm = 2 -> resume command, use command display mode.
            Pm = 3 -> start new command, use command display mode.

Tektronix 4014 Mode
Most of these sequences are standard Tektronix 4014 control sequences.
Graph mode supports the 12-bit addressing of the Tektronix 4014.  The
major features missing are the write-through and defocused modes.  This
document does not describe the commands used in the various Tektronix
plotting modes but does describe the commands to switch modes.

BEL       Bell (Ctrl-G).
BS        Backspace (Ctrl-H).
TAB       Horizontal Tab (Ctrl-I).
LF        Line Feed or New Line (Ctrl-J).
VT        Cursor up (Ctrl-K).
FF        Form Feed or New Page (Ctrl-L).
CR        Carriage Return (Ctrl-M).
ESC ETX   Switch to VT100 Mode (ESC  Ctrl-C).
ESC ENQ   Return Terminal Status (ESC  Ctrl-E).
ESC FF    PAGE (Clear Screen) (ESC  Ctrl-L).
ESC SO    Begin 4015 APL mode (ESC  Ctrl-N).  (This is ignored by
          xterm).
ESC SI    End 4015 APL mode (ESC  Ctrl-O).  (This is ignored by xterm).
ESC ETB   COPY (Save Tektronix Codes to file COPYyyyy-mm-dd.hh:mm:ss).
            ETB  (end transmission block) is the same as Ctrl-W.
ESC CAN   Bypass Condition (ESC  Ctrl-X).
ESC SUB   GIN mode (ESC  Ctrl-Z).
ESC FS    Special Point Plot Mode (ESC  Ctrl-\).
ESC 8     Select Large Character Set.
ESC 9     Select #2 Character Set.
ESC :     Select #3 Character Set.
ESC ;     Select Small Character Set.
OSC Ps ; Pt BEL
          Set Text Parameters of VT window.
            Ps = 0  -> Change Icon Name and Window Title to Pt.
            Ps = 1  -> Change Icon Name to Pt.
            Ps = 2  -> Change Window Title to Pt.
            Ps = 4 6  -> Change Log File to Pt.  (This is normally dis-
          abled by a compile-time option).
ESC `     Normal Z Axis and Normal (solid) Vectors.
ESC a     Normal Z Axis and Dotted Line Vectors.
ESC b     Normal Z Axis and Dot-Dashed Vectors.
ESC c     Normal Z Axis and Short-Dashed Vectors.
ESC d     Normal Z Axis and Long-Dashed Vectors.
ESC h     Defocused Z Axis and Normal (solid) Vectors.
ESC i     Defocused Z Axis and Dotted Line Vectors.
ESC j     Defocused Z Axis and Dot-Dashed Vectors.
ESC k     Defocused Z Axis and Short-Dashed Vectors.
ESC l     Defocused Z Axis and Long-Dashed Vectors.
ESC p     Write-Thru Mode and Normal (solid) Vectors.
ESC q     Write-Thru Mode and Dotted Line Vectors.
ESC r     Write-Thru Mode and Dot-Dashed Vectors.
ESC s     Write-Thru Mode and Short-Dashed Vectors.
ESC t     Write-Thru Mode and Long-Dashed Vectors.
FS        Point Plot Mode (Ctrl-\).
GS        Graph Mode (Ctrl-]).
RS        Incremental Plot Mode (Ctrl-^).
US        Alpha Mode (Ctrl-_).

VT52 Mode
Parameters for cursor movement are at the end of the ESC Y  escape
sequence.  Each ordinate is encoded in a single character as value+32.
For example, !  is 1.  The screen coordinate system is 0-based.

ESC <     Exit VT52 mode (Enter VT100 mode).
ESC =     Enter alternate keypad mode.
ESC >     Exit alternate keypad mode.
ESC A     Cursor up.
ESC B     Cursor down.
ESC C     Cursor right.
ESC D     Cursor left.
ESC F     Enter graphics mode.
ESC G     Exit graphics mode.
ESC H     Move the cursor to the home position.
ESC I     Reverse line feed.
ESC J     Erase from the cursor to the end of the screen.
ESC K     Erase from the cursor to the end of the line.
ESC Y Ps Ps
          Move the cursor to given row and column.
ESC Z     Identify.
            -> ESC  /  Z  ("I am a VT52.").
xterm-330/README0000644000175100001440000000165710625366077012144 0ustar  tomusers-- $XTermId: README,v 1.3 2007/05/24 19:49:19 tom Exp $
-- Below is the original README for xterm from 1991, for your amusement.
-- For a better overview, see http://invisible-island.net/xterm/ 
-------------------------------------------------------------------------------
			Abandon All Hope, Ye Who Enter Here


This is undoubtedly the most ugly program in the distribution.  It was one of
the first "serious" programs ported, and still has a lot of historical baggage.
Ideally, there would be a general tty widget and then vt102 and tek4014 
subwidgets so that they could be used in other programs.  We are trying to 
clean things up as we go, but there is still a lot of work to do.

If you are porting this to a machine that has problems with overlapping
bcopy's, watch out!

There are two documents on xterm: the man page, xterm.man, which describes
how to use it, and ctlseqs.ms, which describes the control sequences it
understands.
xterm-330/charsets.c0000644000175100001440000005051112246662765013241 0ustar  tomusers/* $XTermId: charsets.c,v 1.67 2013/12/01 16:38:13 tom Exp $ */

/*
 * Copyright 1998-2011,2013 by Thomas E. Dickey
 *
 *                         All Rights Reserved
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name(s) of the above copyright
 * holders shall not be used in advertising or otherwise to promote the
 * sale, use or other dealings in this Software without prior written
 * authorization.
 *
 */

#include 
#include 
#include 

#include 

/*
 * This module performs translation as needed to support the DEC VT220 national
 * replacement character sets.  We assume that xterm's font is based on the ISO
 * 8859-1 (Latin 1) character set, which is almost the same as the DEC
 * multinational character set.  Glyph positions 0-31 have to be the DEC
 * graphic characters, though.
 *
 * References:
 *	"VT220 Programmer Pocket Guide" EK-VT220-HR-002 (2nd ed., 1984), which
 *		contains character charts for the national character sets.
 *	"VT330/VT340 Programmer Reference Manual Volume 1: Text Programming"
 *		EK-VT3XX-TP-001 (1st ed, 1987), which contains a table (2-1)
 *		listing the glyphs which are mapped from the multinational
 *		character set to the national character set.
 *
 * The latter reference, though easier to read, has a few errors and omissions.
 */

#define map_NRCS_Dutch(code) \
	switch (code) { \
	    MAP(0x23, XK_sterling); \
	    MAP(0x40, XK_threequarters); \
	    UNI(0x5b, 0x0133); /* ij ligature */ \
	    MAP(0x5c, XK_onehalf); \
	    MAP(0x5d, XK_bar); \
	    MAP(0x7b, XK_diaeresis); \
	    UNI(0x7c, 0x0192); /* florin */ \
	    MAP(0x7d, XK_onequarter); \
	    MAP(0x7e, XK_acute); \
	}

#define map_NRCS_Finnish(code) \
	switch (code) { \
	    MAP(0x5b, XK_Adiaeresis); \
	    MAP(0x5c, XK_Odiaeresis); \
	    MAP(0x5d, XK_Aring); \
	    MAP(0x5e, XK_Udiaeresis); \
	    MAP(0x60, XK_eacute); \
	    MAP(0x7b, XK_adiaeresis); \
	    MAP(0x7c, XK_odiaeresis); \
	    MAP(0x7d, XK_aring); \
	    MAP(0x7e, XK_udiaeresis); \
	}

#define map_NRCS_French(code) \
	switch (code) { \
	    MAP(0x23, XK_sterling); \
	    MAP(0x40, XK_agrave); \
	    MAP(0x5b, XK_degree); \
	    MAP(0x5c, XK_ccedilla); \
	    MAP(0x5d, XK_section); \
	    MAP(0x7b, XK_eacute); \
	    MAP(0x7c, XK_ugrave); \
	    MAP(0x7d, XK_egrave); \
	    MAP(0x7e, XK_diaeresis); \
	}

#define map_NRCS_French_Canadian(code) \
	switch (code) { \
	    MAP(0x40, XK_agrave); \
	    MAP(0x5b, XK_acircumflex); \
	    MAP(0x5c, XK_ccedilla); \
	    MAP(0x5d, XK_ecircumflex); \
	    MAP(0x5e, XK_icircumflex); \
	    MAP(0x60, XK_ocircumflex); \
	    MAP(0x7b, XK_eacute); \
	    MAP(0x7c, XK_ugrave); \
	    MAP(0x7d, XK_egrave); \
	    MAP(0x7e, XK_ucircumflex); \
	}

#define map_NRCS_German(code) \
	switch (code) { \
	    MAP(0x40, XK_section); \
	    MAP(0x5b, XK_Adiaeresis); \
	    MAP(0x5c, XK_Odiaeresis); \
	    MAP(0x5d, XK_Udiaeresis); \
	    MAP(0x7b, XK_adiaeresis); \
	    MAP(0x7c, XK_odiaeresis); \
	    MAP(0x7d, XK_udiaeresis); \
	    MAP(0x7e, XK_ssharp); \
	}

#define map_NRCS_Italian(code) \
	switch (code) { \
	    MAP(0x23, XK_sterling); \
	    MAP(0x40, XK_section); \
	    MAP(0x5b, XK_degree); \
	    MAP(0x5c, XK_ccedilla); \
	    MAP(0x5d, XK_eacute); \
	    MAP(0x60, XK_ugrave); \
	    MAP(0x7b, XK_agrave); \
	    MAP(0x7c, XK_ograve); \
	    MAP(0x7d, XK_egrave); \
	    MAP(0x7e, XK_igrave); \
	}

#define map_NRCS_Norwegian_Danish(code) \
	switch (code) { \
	    MAP(0x40, XK_Adiaeresis); \
	    MAP(0x5b, XK_AE); \
	    MAP(0x5c, XK_Ooblique); \
	    MAP(0x5d, XK_Aring); \
	    MAP(0x5e, XK_Udiaeresis); \
	    MAP(0x60, XK_adiaeresis); \
	    MAP(0x7b, XK_ae); \
	    MAP(0x7c, XK_oslash); \
	    MAP(0x7d, XK_aring); \
	    MAP(0x7e, XK_udiaeresis); \
	}

#define map_NRCS_Portuguese(code) \
	switch (code) { \
	    MAP(0x5b, XK_Atilde); \
	    MAP(0x5c, XK_Ccedilla); \
	    MAP(0x5d, XK_Otilde); \
	    MAP(0x7b, XK_atilde); \
	    MAP(0x7c, XK_ccedilla); \
	    MAP(0x7d, XK_otilde); \
	}

#define map_NRCS_Spanish(code) \
	switch (code) { \
	    MAP(0x23, XK_sterling); \
	    MAP(0x40, XK_section); \
	    MAP(0x5b, XK_exclamdown); \
	    MAP(0x5c, XK_Ntilde); \
	    MAP(0x5d, XK_questiondown); \
	    MAP(0x7b, XK_degree); \
	    MAP(0x7c, XK_ntilde); \
	    MAP(0x7d, XK_ccedilla); \
	}

#define map_NRCS_Swedish(code) \
	switch (code) { \
	    MAP(0x40, XK_Eacute); \
	    MAP(0x5b, XK_Adiaeresis); \
	    MAP(0x5c, XK_Odiaeresis); \
	    MAP(0x5d, XK_Aring); \
	    MAP(0x5e, XK_Udiaeresis); \
	    MAP(0x60, XK_eacute); \
	    MAP(0x7b, XK_adiaeresis); \
	    MAP(0x7c, XK_odiaeresis); \
	    MAP(0x7d, XK_aring); \
	    MAP(0x7e, XK_udiaeresis); \
	}

#define map_NRCS_Swiss(code) \
	switch (code) { \
	    MAP(0x23, XK_ugrave); \
	    MAP(0x40, XK_agrave); \
	    MAP(0x5b, XK_eacute); \
	    MAP(0x5c, XK_ccedilla); \
	    MAP(0x5d, XK_ecircumflex); \
	    MAP(0x5e, XK_icircumflex); \
	    MAP(0x5f, XK_egrave); \
	    MAP(0x60, XK_ocircumflex); \
	    MAP(0x7b, XK_adiaeresis); \
	    MAP(0x7c, XK_odiaeresis); \
	    MAP(0x7d, XK_udiaeresis); \
	    MAP(0x7e, XK_ucircumflex); \
	}

/*
 * Unlike NRCS, which splices a few characters onto ASCII, the supplementary
 * character sets are complete, normally mapped to GR.  Most of these mappings
 * rely upon glyphs not found in ISO-8859-1.  We can display most of those
 * using Unicode, thereby supporting specialized applications that use SCS
 * with luit, subject to the limitation that select/paste will give meaningless
 * results in terms of the application which uses these mappings.
 *
 * Since the VT320, etc, use only 8-bit encodings, there is no plausible
 * argument to be made that these mappings "use" UTF-8, even though there is
 * a hidden step in the terminal emulator which relies upon UTF-8.
 */
#define map_SCS_DEC_Supp(code,dft) \
	switch (code) { \
	    XXX(0x24, 0x2e2e); \
	    XXX(0x26, 0x2e2e); \
	    XXX(0x2c, 0x2e2e); \
	    XXX(0x2d, 0x2e2e); \
	    XXX(0x2e, 0x2e2e); \
	    XXX(0x2f, 0x2e2e); \
	    XXX(0x34, 0x2e2e); \
	    XXX(0x38, 0x2e2e); \
	    XXX(0x3e, 0x2e2e); \
	    UNI(0x47, 0x2426); \
	    MAP(0x48, 0xc7); \
	    MAP(0x49, 0xc8); \
	    MAP(0x4a, 0xc9); \
	    MAP(0x4b, 0xca); \
	    MAP(0x4c, 0xcb); \
	    MAP(0x4d, 0xcc); \
	    MAP(0x4e, 0xcd); \
	    MAP(0x4f, 0xce); \
	    XXX(0x50, 0x2e2e); \
	    UNI(0x57, 0x0152); \
	    XXX(0x5e, 0x2e2e); \
	    XXX(0x70, 0x2e2e); \
	    UNI(0x77, 0x0153); \
	    MAP(0x7d, 0xff); \
	    XXX(0x7e, 0x2e2e); \
	    default: dft; break; \
	}

#define map_SCS_DEC_Supp_Graphic(code,dft) \
	switch (code) { \
	    XXX(0x24, 0x2e2e); \
	    XXX(0x26, 0x2e2e); \
	    XXX(0x2c, 0x2e2e); \
	    XXX(0x2d, 0x2e2e); \
	    XXX(0x2e, 0x2e2e); \
	    XXX(0x2f, 0x2e2e); \
	    XXX(0x34, 0x2e2e); \
	    XXX(0x38, 0x2e2e); \
	    XXX(0x3e, 0x2e2e); \
	    XXX(0x50, 0x2e2e); \
	    UNI(0x57, 0x0152); \
	    XXX(0x5e, 0x2e2e); \
	    XXX(0x70, 0x2e2e); \
	    UNI(0x77, 0x0153); \
	    MAP(0x7d, 0xff); \
	    XXX(0x7e, 0x2e2e); \
	    XXX(0x7f, 0x2e2e); \
	    default: dft; break; \
	}

	/* derived from http://www.vt100.net/charsets/technical.html */
#if OPT_WIDE_CHARS
#define map_SCS_DEC_Technical(code) \
	switch (code) { \
	    UNI(0x21, 0x23b7);	/* RADICAL SYMBOL BOTTOM Centred left to right, so that it joins up with 02/02 */ \
	    UNI(0x22, 0x250c);	/* BOX DRAWINGS LIGHT DOWN AND RIGHT */ \
	    UNI(0x23, 0x2500);	/* BOX DRAWINGS LIGHT HORIZONTAL */ \
	    UNI(0x24, 0x2320);	/* TOP HALF INTEGRAL with the proviso that the stem is vertical, to join with 02/06 */ \
	    UNI(0x25, 0x2321);	/* BOTTOM HALF INTEGRAL with the proviso above. */ \
	    UNI(0x26, 0x2502);	/* BOX DRAWINGS LIGHT VERTICAL */ \
	    UNI(0x27, 0x23a1);	/* LEFT SQUARE BRACKET UPPER CORNER Joins vertically to 02/06, 02/08. Doesn't join to its right. */ \
	    UNI(0x28, 0x23a3);	/* LEFT SQUARE BRACKET LOWER CORNER Joins vertically to 02/06, 02/07. Doesn't join to its right. */ \
	    UNI(0x29, 0x23a4);	/* RIGHT SQUARE BRACKET UPPER CORNER Joins vertically to 026, 02a. Doesn't join to its left. */ \
	    UNI(0x2a, 0x23a6);	/* RIGHT SQUARE BRACKET LOWER CORNER Joins vertically to 026, 029. Doesn't join to its left. */ \
	    UNI(0x2b, 0x239b);	/* LEFT PARENTHESIS UPPER HOOK Joins vertically to 026, 02c, 02/15. Doesn't join to its right. */ \
	    UNI(0x2c, 0x239d);	/* LEFT PARENTHESIS LOWER HOOK Joins vertically to 026, 02b, 02/15. Doesn't join to its right. */ \
	    UNI(0x2d, 0x239e);	/* RIGHT PARENTHESIS UPPER HOOK Joins vertically to 026, 02e, 03/00. Doesn't join to its left. */ \
	    UNI(0x2e, 0x23a0);	/* RIGHT PARENTHESIS LOWER HOOK Joins vertically to 026, 02d, 03/00. Doesn't join to its left. */ \
	    UNI(0x2f, 0x23a8);	/* LEFT CURLY BRACKET MIDDLE PIECE Joins vertically to 026, 02b, 02c. */ \
	    UNI(0x30, 0x23ac);	/* RIGHT CURLY BRACKET MIDDLE PIECE Joins vertically to 02/06, 02d, 02e. */ \
	    XXX(0x31, 0x2426);	/* Top Left Sigma. Joins to right with 02/03, 03/05. Joins diagonally below right with 03/03, 03/07. */ \
	    XXX(0x32, 0x2426);	/* Bottom Left Sigma. Joins to right with 02/03, 03/06. Joins diagonally above right with 03/04, 03/07. */ \
	    XXX(0x33, 0x2426);	/* Top Diagonal Sigma. Line for joining 03/01 to 03/04 or 03/07. */ \
	    XXX(0x34, 0x2426);	/* Bottom Diagonal Sigma. Line for joining 03/02 to 03/03 or 03/07. */ \
	    XXX(0x35, 0x2426);	/* Top Right Sigma. Joins to left with 02/03, 03/01. */ \
	    XXX(0x36, 0x2426);	/* Bottom Right Sigma. Joins to left with 02/03, 03/02. */ \
	    XXX(0x37, 0x2426);	/* Middle Sigma. Joins diagonally with 03/01, 03/02, 03/03, 03/04. */ \
	    XXX(0x38, 0x2426);	/* undefined */ \
	    XXX(0x39, 0x2426);	/* undefined */ \
	    XXX(0x3a, 0x2426);	/* undefined */ \
	    XXX(0x3b, 0x2426);	/* undefined */ \
	    UNI(0x3c, 0x2264);	/* LESS-THAN OR EQUAL TO */ \
	    UNI(0x3d, 0x2260);	/* NOT EQUAL TO */ \
	    UNI(0x3e, 0x2265);	/* GREATER-THAN OR EQUAL TO */ \
	    UNI(0x3f, 0x222B);	/* INTEGRAL */ \
	    UNI(0x40, 0x2234);	/* THEREFORE */ \
	    UNI(0x41, 0x221d);	/* PROPORTIONAL TO */ \
	    UNI(0x42, 0x221e);	/* INFINITY */ \
	    UNI(0x43, 0x00f7);	/* DIVISION SIGN */ \
	    UNI(0x44, 0x039a);	/* GREEK CAPITAL DELTA */ \
	    UNI(0x45, 0x2207);	/* NABLA */ \
	    UNI(0x46, 0x03a6);	/* GREEK CAPITAL LETTER PHI */ \
	    UNI(0x47, 0x0393);	/* GREEK CAPITAL LETTER GAMMA */ \
	    UNI(0x48, 0x223c);	/* TILDE OPERATOR */ \
	    UNI(0x49, 0x2243);	/* ASYMPTOTICALLY EQUAL TO */ \
	    UNI(0x4a, 0x0398);	/* GREEK CAPITAL LETTER THETA */ \
	    UNI(0x4b, 0x00d7);	/* MULTIPLICATION SIGN */ \
	    UNI(0x4c, 0x039b);	/* GREEK CAPITAL LETTER LAMDA */ \
	    UNI(0x4d, 0x21d4);	/* LEFT RIGHT DOUBLE ARROW */ \
	    UNI(0x4e, 0x21d2);	/* RIGHTWARDS DOUBLE ARROW */ \
	    UNI(0x4f, 0x2261);	/* IDENTICAL TO */ \
	    UNI(0x50, 0x03a0);	/* GREEK CAPITAL LETTER PI */ \
	    UNI(0x51, 0x03a8);	/* GREEK CAPITAL LETTER PSI */ \
	    UNI(0x52, 0x2426);	/* undefined */ \
	    UNI(0x53, 0x03a3);	/* GREEK CAPITAL LETTER SIGMA */ \
	    XXX(0x54, 0x2426);	/* undefined */ \
	    XXX(0x55, 0x2426);	/* undefined */ \
	    UNI(0x56, 0x221a);	/* SQUARE ROOT */ \
	    UNI(0x57, 0x03a9);	/* GREEK CAPITAL LETTER OMEGA */ \
	    UNI(0x58, 0x039e);	/* GREEK CAPITAL LETTER XI */ \
	    UNI(0x59, 0x03a5);	/* GREEK CAPITAL LETTER UPSILON */ \
	    UNI(0x5a, 0x2282);	/* SUBSET OF */ \
	    UNI(0x5b, 0x2283);	/* SUPERSET OF */ \
	    UNI(0x5c, 0x2229);	/* INTERSECTION */ \
	    UNI(0x5d, 0x222a);	/* UNION */ \
	    UNI(0x5e, 0x2227);	/* LOGICAL AND */ \
	    UNI(0x5f, 0x2228);	/* LOGICAL OR */ \
	    UNI(0x60, 0x00ac);	/* NOT SIGN */ \
	    UNI(0x61, 0x03b1);	/* GREEK SMALL LETTER ALPHA */ \
	    UNI(0x62, 0x03b2);	/* GREEK SMALL LETTER BETA */ \
	    UNI(0x63, 0x03c7);	/* GREEK SMALL LETTER CHI */ \
	    UNI(0x64, 0x03b4);	/* GREEK SMALL LETTER DELTA */ \
	    UNI(0x65, 0x03b5);	/* GREEK SMALL LETTER EPSILON */ \
	    UNI(0x66, 0x03c6);	/* GREEK SMALL LETTER PHI */ \
	    UNI(0x67, 0x03b3);	/* GREEK SMALL LETTER GAMMA */ \
	    UNI(0x68, 0x03b7);	/* GREEK SMALL LETTER ETA */ \
	    UNI(0x69, 0x03b9);	/* GREEK SMALL LETTER IOTA */ \
	    UNI(0x6a, 0x03b8);	/* GREEK SMALL LETTER THETA */ \
	    UNI(0x6b, 0x03ba);	/* GREEK SMALL LETTER KAPPA */ \
	    UNI(0x6c, 0x03bb);	/* GREEK SMALL LETTER LAMDA */ \
	    XXX(0x6d, 0x2426);	/* undefined */ \
	    UNI(0x6e, 0x03bd);	/* GREEK SMALL LETTER NU */ \
	    UNI(0x6f, 0x2202);	/* PARTIAL DIFFERENTIAL */ \
	    UNI(0x70, 0x03c0);	/* GREEK SMALL LETTER PI */ \
	    UNI(0x71, 0x03c8);	/* GREEK SMALL LETTER PSI */ \
	    UNI(0x72, 0x03c1);	/* GREEK SMALL LETTER RHO */ \
	    UNI(0x73, 0x03c3);	/* GREEK SMALL LETTER SIGMA */ \
	    UNI(0x74, 0x03c4);	/* GREEK SMALL LETTER TAU */ \
	    XXX(0x75, 0x2426);	/* undefined */ \
	    UNI(0x76, 0x0192);	/* LATIN SMALL LETTER F WITH HOOK Probably chosen for its meaning of "function" */ \
	    UNI(0x77, 0x03c9);	/* GREEK SMALL LETTER OMEGA */ \
	    UNI(0x78, 0x03bE);	/* GREEK SMALL LETTER XI */ \
	    UNI(0x79, 0x03c5);	/* GREEK SMALL LETTER UPSILON */ \
	    UNI(0x7a, 0x03b6);	/* GREEK SMALL LETTER ZETA */ \
	    UNI(0x7b, 0x2190);	/* LEFTWARDS ARROW */ \
	    UNI(0x7c, 0x2191);	/* UPWARDS ARROW */ \
	    UNI(0x7d, 0x2192);	/* RIGHTWARDS ARROW */ \
	    UNI(0x7e, 0x2193);	/* DOWNWARDS ARROW */ \
	}
#else
#define map_SCS_DEC_Technical(code)	/* nothing */
#endif /* OPT_WIDE_CHARS */

/*
 * Translate an input keysym to the corresponding NRC keysym.
 */
unsigned
xtermCharSetIn(TScreen *screen, unsigned code, int charset)
{
#define MAP(to, from) case from: code = to; break

#if OPT_WIDE_CHARS
#define UNI(to, from) case from: if (screen->utf8_nrc_mode) code = to; break
#else
#define UNI(to, from) case from: break
#endif

#define XXX(to, from)		/* no defined mapping to 0..255 */

    TRACE(("CHARSET-IN GL=%s(G%d) GR=%s(G%d) SS%d\n\t%s\n",
	   visibleScsCode(screen->gsets[screen->curgl]), screen->curgl,
	   visibleScsCode(screen->gsets[screen->curgr]), screen->curgr,
	   screen->curss,
	   visibleUChar(code)));

    switch (charset) {
    case nrc_British:		/* United Kingdom set (or Latin 1)      */
	if (code == XK_sterling)
	    code = 0x23;
	code &= 0x7f;
	break;

#if OPT_XMC_GLITCH
    case nrc_Unknown:
#endif
    case nrc_DEC_Alt_Chars:
    case nrc_DEC_Alt_Graphics:
    case nrc_ASCII:
	break;

    case nrc_DEC_Spec_Graphic:
	break;

    case nrc_DEC_Supp:
	map_SCS_DEC_Supp(code, code &= 0x7f);
	break;

    case nrc_DEC_Supp_Graphic:
	map_SCS_DEC_Supp_Graphic(code, code |= 0x80);
	break;

    case nrc_DEC_Technical:
	map_SCS_DEC_Technical(code);
	break;

    case nrc_Dutch:
	map_NRCS_Dutch(code);
	break;

    case nrc_Finnish:
    case nrc_Finnish2:
	map_NRCS_Finnish(code);
	break;

    case nrc_French:
    case nrc_French2:
	map_NRCS_French(code);
	break;

    case nrc_French_Canadian:
	map_NRCS_French_Canadian(code);
	break;

    case nrc_German:
	map_NRCS_German(code);
	break;

    case nrc_Hebrew:
    case nrc_Hebrew2:
	/* FIXME */
	break;

    case nrc_Italian:
	map_NRCS_Italian(code);
	break;

    case nrc_Norwegian_Danish:
    case nrc_Norwegian_Danish2:
    case nrc_Norwegian_Danish3:
	map_NRCS_Norwegian_Danish(code);
	break;

    case nrc_Portugese:
	map_NRCS_Portuguese(code);
	break;

    case nrc_SCS_NRCS:		/* vt5xx - probably Serbo/Croatian */
	/* FIXME */
	break;

    case nrc_Spanish:
	map_NRCS_Spanish(code);
	break;

    case nrc_Swedish2:
    case nrc_Swedish:
	map_NRCS_Swedish(code);
	break;

    case nrc_Swiss:
	map_NRCS_Swiss(code);
	break;

    case nrc_Turkish:
    case nrc_Turkish2:
	/* FIXME */
	break;

    default:			/* any character sets we don't recognize */
	break;
    }
    code &= 0x7f;		/* NRC in any case is 7-bit */
    TRACE(("->\t%s\n",
	   visibleUChar(code)));
    return code;
#undef MAP
#undef UNI
#undef XXX
}

/*
 * Translate a string to the display form.  This assumes the font has the
 * DEC graphic characters in cells 0-31, and otherwise is ISO-8859-1.
 */
int
xtermCharSetOut(XtermWidget xw, IChar *buf, IChar *ptr, int leftset)
{
    IChar *s;
    TScreen *screen = TScreenOf(xw);
    int count = 0;
    int rightset = screen->gsets[(int) (screen->curgr)];

#define MAP(from, to) case from: chr = to; break

#if OPT_WIDE_CHARS
#define UNI(from, to) case from: if (screen->utf8_nrc_mode) chr = to; break
#define XXX(from, to) UNI(from, to)
#else
#define UNI(old, new) chr = old; break
#define XXX(from, to)		/* nothing */
#endif

    TRACE(("CHARSET-OUT GL=%s(G%d) GR=%s(G%d) SS%d\n\t%s\n",
	   visibleScsCode(leftset), screen->curgl,
	   visibleScsCode(rightset), screen->curgr,
	   screen->curss,
	   visibleIChars(buf, (unsigned) (ptr - buf))));

    for (s = buf; s < ptr; ++s) {
	int eight = CharOf(E2A(*s));
	int seven = eight & 0x7f;
	int cs = (eight >= 128) ? rightset : leftset;
	int chr = eight;

	count++;
#if OPT_WIDE_CHARS
	/*
	 * This is only partly right - prevent inadvertant remapping of
	 * the replacement character and other non-8bit codes into bogus
	 * 8bit codes.
	 */
	if (screen->utf8_mode || screen->utf8_nrc_mode) {
	    if (*s > 255)
		continue;
	}
#endif
	if (*s < 32)
	    continue;

	switch (cs) {
	case nrc_British_Latin_1:
	    /* FALLTHRU */
	case nrc_British:	/* United Kingdom set (or Latin 1)      */
	    if ((xw->flags & NATIONAL)
		|| (screen->vtXX_level <= 1)) {
		if ((xw->flags & NATIONAL)) {
		    chr = seven;
		}
		if (chr == 0x23) {
		    chr = XTERM_POUND;
#if OPT_WIDE_CHARS
		    if (screen->utf8_nrc_mode) {
			chr = 0xa3;
		    }
#endif
		}
	    } else {
		chr = (seven | 0x80);
	    }
	    break;

#if OPT_XMC_GLITCH
	case nrc_Unknown:
#endif
	case nrc_DEC_Alt_Chars:
	case nrc_DEC_Alt_Graphics:
	case nrc_ASCII:
	    break;

	case nrc_DEC_Spec_Graphic:
	    if (seven > 0x5f && seven <= 0x7e) {
#if OPT_WIDE_CHARS
		if (screen->utf8_mode || screen->utf8_nrc_mode)
		    chr = (int) dec2ucs((unsigned) (seven - 0x5f));
		else
#endif
		    chr = seven - 0x5f;
	    } else {
		chr = seven;
	    }
	    break;

	case nrc_DEC_Supp:
	    map_SCS_DEC_Supp(chr = seven, chr |= 0x80);
	    break;

	case nrc_DEC_Supp_Graphic:
	    map_SCS_DEC_Supp_Graphic(chr = seven, chr |= 0x80);
	    break;

	case nrc_DEC_Technical:
	    map_SCS_DEC_Technical(chr = seven);
	    break;

	case nrc_Dutch:
	    map_NRCS_Dutch(chr = seven);
	    break;

	case nrc_Finnish:
	case nrc_Finnish2:
	    map_NRCS_Finnish(chr = seven);
	    break;

	case nrc_French:
	case nrc_French2:
	    map_NRCS_French(chr = seven);
	    break;

	case nrc_French_Canadian:
	case nrc_French_Canadian2:
	    map_NRCS_French_Canadian(chr = seven);
	    break;

	case nrc_German:
	    map_NRCS_German(chr = seven);
	    break;

	case nrc_Hebrew:
	case nrc_Hebrew2:
	    /* FIXME */
	    break;

	case nrc_Italian:
	    map_NRCS_Italian(chr = seven);
	    break;

	case nrc_Norwegian_Danish:
	case nrc_Norwegian_Danish2:
	case nrc_Norwegian_Danish3:
	    map_NRCS_Norwegian_Danish(chr = seven);
	    break;

	case nrc_Portugese:
	    map_NRCS_Portuguese(chr = seven);
	    break;

	case nrc_SCS_NRCS:	/* vt5xx - probably Serbo/Croatian */
	    /* FIXME */
	    break;

	case nrc_Spanish:
	    map_NRCS_Spanish(chr = seven);
	    break;

	case nrc_Swedish2:
	case nrc_Swedish:
	    map_NRCS_Swedish(chr = seven);
	    break;

	case nrc_Swiss:
	    map_NRCS_Swiss(chr = seven);
	    break;

	case nrc_Turkish:
	case nrc_Turkish2:
	    /* FIXME */
	    break;

	default:		/* any character sets we don't recognize */
	    count--;
	    break;
	}
	/*
	 * The state machine already treated DEL as a nonprinting and
	 * nonspacing character.  If we have DEL now, simply render
	 * it as a blank.
	 */
	if (chr == ANSI_DEL)
	    chr = ' ';
	*s = (IChar) A2E(chr);
    }
    TRACE(("%d\t%s\n",
	   count,
	   visibleIChars(buf, (unsigned) (ptr - buf))));
    return count;
#undef MAP
#undef UNI
#undef XXX
}
xterm-330/xstrings.c0000644000175100001440000002716613117332045013277 0ustar  tomusers/* $XTermId: xstrings.c,v 1.70 2017/06/11 21:20:37 tom Exp $ */

/*
 * Copyright 2000-2016,2017 by Thomas E. Dickey
 *
 *                         All Rights Reserved
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name(s) of the above copyright
 * holders shall not be used in advertising or otherwise to promote the
 * sale, use or other dealings in this Software without prior written
 * authorization.
 */

#include 

#include 
#include 
#include 
#include 

#include 

static void
alloc_pw(struct passwd *target, struct passwd *source)
{
    *target = *source;
    /* we care only about these strings */
    target->pw_dir = x_strdup(source->pw_dir);
    target->pw_name = x_strdup(source->pw_name);
    target->pw_shell = x_strdup(source->pw_shell);
}

static void
free_pw(struct passwd *source)
{
    free(source->pw_dir);
    free(source->pw_name);
    free(source->pw_shell);
}

void
x_appendargv(char **target, char **source)
{
    if (target && source) {
	target += x_countargv(target);
	while ((*target++ = *source++) != 0) ;
    }
}

char *
x_basename(char *name)
{
    char *cp;

    cp = strrchr(name, '/');
    return (cp ? cp + 1 : name);
}

unsigned
x_countargv(char **argv)
{
    unsigned result = 0;
    if (argv) {
	while (*argv++) {
	    ++result;
	}
    }
    return result;
}

/*
 * Decode a hexadecimal string, returning the decoded string.
 * On return, 'next' points to the first character not part of the input.
 * The caller must free the result.
 */
char *
x_decode_hex(const char *source, const char **next)
{
    char *result = 0;
    int pass;
    size_t j, k;

    for (pass = 0; pass < 2; ++pass) {
	for (j = k = 0; isxdigit(CharOf(source[j])); ++j) {
	    if ((pass != 0) && (j & 1) != 0) {
		result[k++] = (char) ((x_hex2int(source[j - 1]) << 4)
				      | x_hex2int(source[j]));
	    }
	}
	*next = (source + j);
	if ((j & 1) == 0) {
	    if (pass) {
		result[k] = '\0';
	    } else {
		result = malloc(++j);
		if (result == 0)
		    break;	/* not enough memory */
	    }
	} else {
	    break;		/* must have an even number of digits */
	}
    }
    return result;
}

/*
 * Encode a string into hexadecimal, returning the encoded string.
 * The caller must free the result.
 */
char *
x_encode_hex(const char *source)
{
    size_t need = (strlen(source) * 2) + 1;
    char *result = malloc(need);

    if (result != 0) {
	unsigned j, k;
	for (j = k = 0; source[j] != '\0'; ++j) {
	    sprintf(result + k, "%02X", CharOf(source[j]));
	    k += 2;
	}
    }
    return result;
}

char *
x_getenv(const char *name)
{
    char *result;
    result = x_strdup(x_nonempty(getenv(name)));
    TRACE2(("getenv(%s) %s\n", name, result));
    return result;
}

static char *
login_alias(char *login_name, uid_t uid, struct passwd *in_out)
{
    /*
     * If the logon-name differs from the value we get by looking in the
     * password file, check if it does correspond to the same uid.  If so,
     * allow that as an alias for the uid.
     */
    if (!IsEmpty(login_name)
	&& strcmp(login_name, in_out->pw_name)) {
	struct passwd pw2;
	Boolean ok2;

	if ((ok2 = x_getpwnam(login_name, &pw2))) {
	    uid_t uid2 = pw2.pw_uid;
	    struct passwd pw3;
	    Boolean ok3;

	    if ((ok3 = x_getpwuid(uid, &pw3))
		&& ((uid_t) pw3.pw_uid == uid2)) {
		/* use the other passwd-data including shell */
		alloc_pw(in_out, &pw2);
	    } else {
		free(login_name);
		login_name = NULL;
	    }
	    if (ok2)
		free_pw(&pw2);
	    if (ok3)
		free_pw(&pw3);
	}
    }
    return login_name;
}

/*
 * Call this with in_out pointing to data filled in by x_getpwnam() or by
 * x_getpwnam().  It finds the user's logon name, if possible.  As a side
 * effect, it updates in_out to fill in possibly more-relevant data, i.e.,
 * in case there is more than one alias for the same uid.
 */
char *
x_getlogin(uid_t uid, struct passwd *in_out)
{
    char *login_name = NULL;

    login_name = login_alias(x_getenv("LOGNAME"), uid, in_out);
    if (IsEmpty(login_name)) {
	free(login_name);
	login_name = login_alias(x_getenv("USER"), uid, in_out);
    }
#ifdef HAVE_GETLOGIN
    /*
     * Of course getlogin() will fail if we're started from a window-manager,
     * since there's no controlling terminal to fuss with.  For that reason, we
     * tried first to get something useful from the user's $LOGNAME or $USER
     * environment variables.
     */
    if (IsEmpty(login_name)) {
	TRACE2(("...try getlogin\n"));
	free(login_name);
	login_name = login_alias(x_strdup(getlogin()), uid, in_out);
    }
#endif

    if (IsEmpty(login_name)) {
	free(login_name);
	login_name = x_strdup(in_out->pw_name);
    }

    TRACE2(("x_getloginid ->%s\n", NonNull(login_name)));
    return login_name;
}

/*
 * Simpler than getpwnam_r, retrieves the passwd result by name and stores the
 * result via the given pointer.  On failure, wipes the data to prevent use.
 */
Boolean
x_getpwnam(const char *name, struct passwd *result)
{
    struct passwd *ptr = getpwnam(name);
    Boolean code;

    if (ptr != 0 && OkPasswd(ptr)) {
	code = True;
	alloc_pw(result, ptr);
    } else {
	code = False;
	memset(result, 0, sizeof(*result));
    }
    return code;
}

/*
 * Simpler than getpwuid_r, retrieves the passwd result by uid and stores the
 * result via the given pointer.  On failure, wipes the data to prevent use.
 */
Boolean
x_getpwuid(uid_t uid, struct passwd *result)
{
    struct passwd *ptr = getpwuid((uid_t) uid);
    Boolean code;

    if (ptr != 0 && OkPasswd(ptr)) {
	code = True;
	alloc_pw(result, ptr);
    } else {
	code = False;
	memset(result, 0, sizeof(*result));
    }
    TRACE2(("x_getpwuid(%d) %d\n", (int) uid, (int) code));
    return code;
}

/*
 * Decode a single hex "nibble", returning the nibble as 0-15, or -1 on error.
 */
int
x_hex2int(int c)
{
    if (c >= '0' && c <= '9')
	return c - '0';
    if (c >= 'a' && c <= 'f')
	return c - 'a' + 10;
    if (c >= 'A' && c <= 'F')
	return c - 'A' + 10;
    return -1;
}

/*
 * Check if the given string is nonnull/nonempty.  If so, return a pointer
 * to the beginning of its content, otherwise return null.
 */
String
x_nonempty(String s)
{
    if (s != 0) {
	if (*s == '\0') {
	    s = 0;
	} else {
	    s = x_skip_blanks(s);
	    if (*s == '\0')
		s = 0;
	}
    }
    return s;
}

String
x_skip_blanks(String s)
{
    while (IsSpace(CharOf(*s)))
	++s;
    return s;
}

String
x_skip_nonblanks(String s)
{
    while (*s != '\0' && !IsSpace(CharOf(*s)))
	++s;
    return s;
}

static const char *
skip_blanks(const char *s)
{
    while (IsSpace(CharOf(*s)))
	++s;
    return s;
}

/*
 * Split a command-string into an argv[]-style array.
 */
char **
x_splitargs(const char *command)
{
    char **result = 0;

    if (command != 0) {
	const char *first = skip_blanks(command);
	char *blob = x_strdup(first);

	if (blob != 0) {
	    int pass;

	    for (pass = 0; pass < 2; ++pass) {
		int state;
		size_t count;
		size_t n;

		for (n = count = 0, state = 0; first[n] != '\0'; ++n) {

		    switch (state) {
		    case 0:
			if (!IsSpace(CharOf(first[n]))) {
			    state = 1;
			    if (pass)
				result[count] = blob + n;
			    ++count;
			} else {
			    blob[n] = '\0';
			}
			break;
		    case 1:
			if (IsSpace(CharOf(first[n]))) {
			    blob[n] = '\0';
			    state = 0;
			}
			break;
		    }
		}
		if (!pass) {
		    result = TypeCallocN(char *, count + 1);
		    if (!result) {
			free(blob);
			break;
		    }
		}
	    }
	}
    } else {
	result = TypeCalloc(char *);
    }
    return result;
}

/*
 * Free storage allocated by x_splitargs().
 */
void
x_freeargs(char **argv)
{
    if (argv != 0) {
	if (*argv != 0)
	    free(*argv);
	free(argv);
    }
}

int
x_strcasecmp(const char *s1, const char *s2)
{
    size_t len = strlen(s1);

    if (len != strlen(s2))
	return 1;

    return x_strncasecmp(s1, s2, (unsigned) len);
}

int
x_strncasecmp(const char *s1, const char *s2, unsigned n)
{
    while (n-- != 0) {
	char c1 = x_toupper(*s1);
	char c2 = x_toupper(*s2);
	if (c1 != c2)
	    return 1;
	if (c1 == 0)
	    break;
	s1++, s2++;
    }

    return 0;
}

/*
 * Allocates a copy of a string
 */
char *
x_strdup(const char *s)
{
    char *result = 0;

    if (s != 0) {
	char *t = TextAlloc(4 + strlen(s));
	if (t != 0) {
	    strcpy(t, s);
	}
	result = t;
    }
    return result;
}

/*
 * Returns a pointer to the first occurrence of s2 in s1,
 * or NULL if there are none.
 */
char *
x_strindex(char *s1, const char *s2)
{
    char *s3;
    size_t s2len = strlen(s2);

    while ((s3 = (strchr) (s1, *s2)) != NULL) {
	if (strncmp(s3, s2, s2len) == 0)
	    return (s3);
	s1 = ++s3;
    }
    return (NULL);
}

/*
 * Trims leading/trailing spaces from a copy of the string.
 */
char *
x_strtrim(const char *source)
{
    char *result;

    if (source != 0 && *source != '\0') {
	char *t = x_strdup(source);
	if (t != 0) {
	    char *s = t;
	    char *d = s;
	    while (IsSpace(CharOf(*s)))
		++s;
	    while ((*d++ = *s++) != '\0') {
		;
	    }
	    if (*t != '\0') {
		s = t + strlen(t);
		while (s != t && IsSpace(CharOf(s[-1]))) {
		    *--s = '\0';
		}
	    }
	}
	result = t;
    } else {
	result = x_strdup("");
    }
    return result;
}

/*
 * Trims trailing whitespace from a copy of the string.
 */
char *
x_strrtrim(const char *source)
{
    char *result;

    if (source != 0 && *source != '\0') {
	char *t = x_strdup(source);
	if (t != 0) {
	    if (*t != '\0') {
		char *s = t + strlen(t);
		while (s != t && IsSpace(CharOf(s[-1]))) {
		    *--s = '\0';
		}
	    }
	}
	result = t;
    } else {
	result = x_strdup("");
    }
    return result;
}

/*
 * Avoid using system locale for upper/lowercase conversion, since there are
 * a few locales where toupper(tolower(c)) != c.
 */
char
x_toupper(int ch)
{
    static char table[256];
    char result = table[CharOf(ch)];

    if (result == '\0') {
	unsigned n;
	static const char s[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

	for (n = 0; n < sizeof(table); ++n) {
	    table[n] = (char) n;
	}
	for (n = 0; s[n] != '\0'; ++n) {
	    table[CharOf(s[n])] = s[n % 26];
	}
	result = table[CharOf(ch)];
    }

    return result;
}

/*
 * Match strings ignoring case and allowing glob-like '*' and '?'
 */
int
x_wildstrcmp(const char *pattern, const char *actual)
{
    int result = 0;

    while (*pattern && *actual) {
	char c1 = x_toupper(*pattern);
	char c2 = x_toupper(*actual);

	if (c1 == '*') {
	    Boolean found = False;
	    pattern++;
	    while (*actual != '\0') {
		if (!x_wildstrcmp(pattern, actual++)) {
		    found = True;
		    break;
		}
	    }
	    if (!found) {
		result = 1;
		break;
	    }
	} else if (c1 == '?') {
	    ++pattern;
	    ++actual;
	} else if ((result = (c1 != c2)) == 0) {
	    ++pattern;
	    ++actual;
	} else {
	    break;
	}
    }
    return result;
}
xterm-330/xstrings.h0000644000175100001440000000576013027063126013301 0ustar  tomusers/* $XTermId: xstrings.h,v 1.30 2016/12/22 23:48:38 tom Exp $ */

/*
 * Copyright 2000-2015,2016 by Thomas E. Dickey
 *
 *                         All Rights Reserved
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name(s) of the above copyright
 * holders shall not be used in advertising or otherwise to promote the
 * sale, use or other dealings in this Software without prior written
 * authorization.
 */

#ifndef included_xstrings_h
#define included_xstrings_h 1
/* *INDENT-OFF* */

#include 
#include 

#define OkPasswd(p) ((p)->pw_name != 0 && (p)->pw_name[0] != 0)

extern Boolean x_getpwnam(const char * /* name */, struct passwd * /* result */);
extern Boolean x_getpwuid(uid_t /* uid */, struct passwd * /* result */);
extern String x_nonempty(String /* s */);
extern String x_skip_blanks(String /* s */);
extern String x_skip_nonblanks(String /* s */);
extern char **x_splitargs(const char * /* command */);
extern char *x_basename(char * /* name */);
extern char *x_decode_hex(const char * /* source */, const char ** /* next */);
extern char *x_encode_hex(const char * /* source */);
extern char *x_getenv(const char * /* name */);
extern char *x_getlogin(uid_t /* uid */, struct passwd * /* in_out */);
extern char *x_strdup(const char * /* s */);
extern char *x_strindex(char * /* s1 */, const char * /* s2 */);
extern char *x_strtrim(const char * /* s */);
extern char *x_strrtrim(const char * /* s */);
extern char x_toupper(int /* ch */);
extern int x_hex2int(int /* ch */);
extern int x_strcasecmp(const char * /* s1 */, const char * /* s2 */);
extern int x_strncasecmp(const char * /* s1 */, const char * /* s2 */, unsigned  /* n */);
extern int x_wildstrcmp(const char * /* pattern */, const char * /* actual */);
extern unsigned x_countargv(char ** /* argv */);
extern void x_appendargv(char ** /* target */, char ** /* source */);
extern void x_freeargs(char ** /* argv */);

/* *INDENT-ON* */

#endif /* included_xstrings_h */
xterm-330/configure.in0000644000175100001440000011062213113500427013546 0ustar  tomusersdnl $XTermId: configure.in,v 1.345 2017/05/31 08:38:47 tom Exp $
dnl
dnl -----------------------------------------------------------------------------
dnl this file is part of xterm
dnl
dnl Copyright 1997-2016,2017 by Thomas E. Dickey
dnl 
dnl                         All Rights Reserved
dnl 
dnl Permission is hereby granted, free of charge, to any person obtaining a
dnl copy of this software and associated documentation files (the
dnl "Software"), to deal in the Software without restriction, including
dnl without limitation the rights to use, copy, modify, merge, publish,
dnl distribute, sublicense, and/or sell copies of the Software, and to
dnl permit persons to whom the Software is furnished to do so, subject to
dnl the following conditions:
dnl 
dnl The above copyright notice and this permission notice shall be included
dnl in all copies or substantial portions of the Software.
dnl 
dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
dnl IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
dnl CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
dnl TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
dnl SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
dnl 
dnl Except as contained in this notice, the name(s) of the above copyright
dnl holders shall not be used in advertising or otherwise to promote the
dnl sale, use or other dealings in this Software without prior written
dnl authorization.
dnl ---------------------------------------------------------------------------
dnl Process this file with autoconf to produce a configure script.
dnl
AC_PREREQ(2.52.20170501)
AC_INIT
AC_CONFIG_SRCDIR([charproc.c])
AC_CONFIG_HEADER(xtermcfg.h:xtermcfg.hin)
CF_CHECK_CACHE

###	checks for alternative programs

dnl Only add to this case statement when a system has a compiler that is not
dnl detected by AC_PROG_CC.
case "$host_os" in
(openedition)	: ${CFLAGS="-O2 -Wc,dll -Wl,EDIT=NO"}
		: ${CPPFLAGS="-D_ALL_SOURCE"}
		: ${LIBS="/usr/lib/Xaw.x /usr/lib/SM.x /usr/lib/ICE.x /usr/lib/X11.x"}
		: ${CC=c89};;
(darwin*)
		: ${LDFLAGS}="${LDFLAGS} -Wl,-bind_at_load";;
esac

CF_PROG_CC
AC_PROG_CPP
AC_PROG_AWK
AC_PROG_INSTALL
AC_PROG_LN_S
AC_ARG_PROGRAM
CF_PROG_LINT

###	checks for compiler characteristics
CF_XOPEN_SOURCE(700)
CF_SIGWINCH

###	checks for header files
AC_CHECK_HEADERS( \
ncurses/curses.h \
ncurses/term.h \
stdlib.h \
sys/ptem.h sys/ttydefaults.h \
term.h \
termios.h \
unistd.h \
wchar.h \
)
AC_HEADER_TIME
AM_LANGINFO_CODESET

###	checks for typedefs
CF_SIG_ATOMIC_T
AC_CHECK_TYPE(time_t, long)
CF_TYPE_CC_T
AC_TYPE_MODE_T
AC_TYPE_PID_T
AC_TYPE_UID_T
AC_TYPE_OFF_T

###	checks for library functions
AC_CHECK_FUNCS( \
	gethostname \
	getlogin \
	initgroups \
	mkdtemp \
	putenv \
	unsetenv \
	sched_yield \
	setpgid \
	strftime \
	tcgetattr \
	waitpid \
	wcswidth \
	wcwidth )
CF_UTMP
CF_STRUCT_LASTLOG
CF_POSIX_SAVED_IDS

CF_HELP_MESSAGE(Compile/Install Options:)
CF_FUNC_TGETENT

CF_WITH_APP_CLASS(XTerm)
CF_WITH_APP_DEFAULTS
CF_WITH_ICON_NAME(xterm-color)
CF_WITH_ICON_SYMLINK(xterm)
CF_WITH_ICON_THEME([icons/$ICON_NAME icons/${ICON_NAME}_48x48],,,icons/${ICON_NAME}_48x48)
CF_DISABLE_DESKTOP(xterm)
CF_WITH_DESKTOP_CATEGORY(xterm,
	[*rxvt*|*konsole|*[[Tt]]erminal],
	[System|TerminalEmulator|*])

AC_MSG_CHECKING(for install-permissions reference)
AC_ARG_WITH(reference,
	[  --with-reference=XXX    program to use as permissions-reference],
	[with_reference=$withval],
	[with_reference=xterm])
AC_MSG_RESULT($with_reference)

with_full_paths=yes
CF_PATH_PROG(XTERM_PATH,$with_reference)

# If any of --program-prefix, --program-suffix or --program-transform-name is
# given, accept an option tell the makefile to create a symbolic link, e.g.,
# to "xterm" on install.
XTERM_SYMLINK=NONE
AC_SUBST(XTERM_SYMLINK)
if test "$program_transform_name" != "'s,,,'" ; then
cf_name=`echo "$program_transform_name" | sed -e '[s,\\$\\$,$,g]'`
cf_name=`echo xterm |sed -e "$cf_name"`
AC_MSG_CHECKING(for symbolic link to create to $cf_name)
AC_ARG_WITH(xterm-symlink,
	[  --with-xterm-symlink=XXX make symbolic link to installed xterm],
	[with_symlink=$withval],
	[with_symlink=xterm])
AC_MSG_RESULT($with_symlink)
test "$with_symlink" = yes && with_symlink=xterm
test -n "$with_symlink" && \
	test "$with_symlink" != no && \
	test "$with_symlink" != $cf_name && \
	XTERM_SYMLINK="$with_symlink"
fi

AC_MSG_CHECKING(if you want to disable openpty)
CF_ARG_DISABLE(openpty,
	[  --disable-openpty       disable openpty, prefer other interfaces],
	[disable_openpty=yes],
	[disable_openpty=no],
	no)
AC_MSG_RESULT($disable_openpty)

AC_MSG_CHECKING(if you want to disable setuid)
CF_ARG_DISABLE(setuid,
	[  --disable-setuid        disable setuid in xterm, do not install setuid/setgid],
	[disable_setuid=yes],
	[disable_setuid=no],
	no)
AC_MSG_RESULT($disable_setuid)

AC_MSG_CHECKING(if you want to disable setgid)
CF_ARG_DISABLE(setgid,
	[  --disable-setgid        disable setgid in xterm, do not install setuid/setgid],
	[disable_setgid=yes],
	[disable_setgid=no],
	no)
AC_MSG_RESULT($disable_setgid)

AC_MSG_CHECKING(if you want to run xterm setuid to a given user)
AC_ARG_WITH(setuid,
	[  --with-setuid=XXX       use the given setuid user],
	[use_given_setuid=$withval],
	[use_given_setuid=no])
AC_MSG_RESULT($use_given_setuid)

if test "$use_given_setuid" != no ; then
	if test "$use_given_setuid" = yes ; then
		cf_cv_given_setuid=root
	else
		cf_cv_given_setuid=$use_given_setuid
	fi
	# inherit SINSTALL_OPTS from environment to allow packager to customize it.
	SINSTALL_OPTS="$SINSTALL_OPTS u+s -u $cf_cv_given_setuid"
fi

AC_MSG_CHECKING(if you want to run xterm setgid to match utmp/utmpx file)
AC_ARG_WITH(utmp-setgid,
	[  --with-utmp-setgid=XXX  use setgid to match utmp/utmpx file],
	[use_utmp_setgid=$withval],
	[use_utmp_setgid=no])
AC_MSG_RESULT($use_utmp_setgid)

if test "$use_utmp_setgid" != no ; then
	if test "$use_utmp_setgid" = yes ; then
		CF_UTMP_GROUP
	else
		cf_cv_utmp_group=$use_utmp_setgid
	fi
	if test "$cf_cv_posix_saved_ids" != yes ; then
		AC_MSG_ERROR(Your system does not support POSIX saved-ids)
	fi
	AC_DEFINE(USE_UTMP_SETGID,1,[Define to 1 if we should use setgid to access utmp/utmpx])
	SINSTALL_OPTS="$SINSTALL_OPTS g+s -g $cf_cv_utmp_group"
fi

AC_SUBST(SINSTALL_OPTS)

AC_MSG_CHECKING(if you want to link with utempter)
AC_ARG_WITH(utempter,
	[  --with-utempter         use utempter library for access to utmp],
	[use_utempter=$withval],
	[use_utempter=no])
AC_MSG_RESULT($use_utempter)

if test "$use_utempter" = yes ; then
	CF_UTEMPTER
	test "$cf_cv_have_utempter" != yes && use_utempter=no
else
	use_utempter=no
fi

# Some configurations permit (or require) either setuid or setgid mode.
# Let the user decide.
if test "$use_utempter" = yes ; then
	if test "${enable_setuid+set}" != set ; then
		disable_setuid=yes
		CF_VERBOSE([No --disable-setuid option given, force to yes])
	fi
fi

###	checks for external data
CF_ERRNO
CF_TTY_GROUP

###	checks for system services and user specified options

CF_POSIX_WAIT
CF_SYSV
CF_SVR4
CF_X_TOOLKIT

AC_CHECK_HEADERS( \
	X11/DECkeysym.h \
	X11/Sunkeysym.h \
	X11/XF86keysym.h \
	X11/XKBlib.h \
	X11/Xpoll.h \
	X11/extensions/XKB.h \
	)

CF_WITH_XPM
CF_WITH_XINERAMA
CF_X_ATHENA
CF_TYPE_FD_MASK
CF_TERMIO_C_ISPEED

# If we notice Xcursor, there is a workaround needed.
AC_CHECK_LIB(Xcursor, XcursorGetTheme,[AC_DEFINE(HAVE_LIB_XCURSOR)])

LIBS="$LIBS $X_EXTRA_LIBS"

CF_FUNC_GRANTPT
CF_XKB_QUERY_EXTENSION
CF_XKB_KEYCODE_TO_KEYSYM
CF_XKB_BELL_EXT

AC_CHECK_FUNCS(Xutf8LookupString, [],[
	EXTRAHDRS="$EXTRAHDRS xutf8.h"
	EXTRASRCS="$EXTRASRCS xutf8.c"
	EXTRAOBJS="$EXTRAOBJS xutf8.o"
])

CF_WITH_IMAKE_CFLAGS($(MAIN_DEFINES) $(VENDORMANDEFS))
CF_WITH_MAN2HTML

# If we have already established that there is a full termcap implementation,
# suppress the definitions for terminfo that we make have imported from the
# imake-file.
if test "x$cf_cv_lib_tgetent" != xno || test "x$cf_cv_lib_part_tgetent" != xno ; then
	case "$IMAKE_CFLAGS" in
	(*-DUSE_TERMINFO\ -DHAVE_TIGETSTR*)
		CF_UNDO_CFLAGS(IMAKE_CFLAGS,terminfo,[-DUSE_TERMINFO[[ 	]]*-DHAVE_TIGETSTR[[ 	]]*])
		CF_UNDO_CFLAGS(CPPFLAGS,terminfo,[-DUSE_TERMINFO[[ 	]]*-DHAVE_TIGETSTR[[ 	]]*])
		;;
	esac
fi

CF_HELP_MESSAGE(Terminal Configuration:)

AC_MSG_CHECKING(for default terminal-id)
AC_ARG_WITH(terminal-id,
	[  --with-terminal-id=V    set default decTerminalID (default: vt420)],
	[default_termid=$withval],
	[default_termid=vt420])
AC_MSG_RESULT($default_termid)
case $default_termid in
(vt*)	default_termid=`echo $default_termid | sed -e 's/^..//'`
	;;
esac
AC_DEFINE_UNQUOTED(DFT_DECID,"$default_termid",[default terminal-id])
AC_SUBST(default_termid)

AC_MSG_CHECKING(for default terminal-type)
AC_ARG_WITH(terminal-type,
	[  --with-terminal-type=T  set default $TERM (default: xterm)],
	[default_TERM=$withval],
	[default_TERM=xterm])
AC_MSG_RESULT($default_TERM)
AC_DEFINE_UNQUOTED(DFT_TERMTYPE,"$default_TERM",[default terminal-type])
AC_SUBST(default_TERM)

###############################################################################
AC_MSG_CHECKING(if backarrow-key should be BS)
CF_ARG_DISABLE(backarrow-key,
	[  --enable-backarrow-key  set default backarrowKey resource (default: true)],
	[backarrow_is_bs=$enableval],
	[backarrow_is_bs=yes])
CF_XBOOL_RESULT(DEF_BACKARO_BS,backarrow_is_bs,[Define to 1 if backarrow-key should be BS])

AC_MSG_CHECKING(if backarrow-key should be treated as erase)
CF_ARG_ENABLE(backarrow-is-erase,
	[  --enable-backarrow-is-erase set default backarrowKeyIsErase resource (default: false)],
	[backarrow_is_erase=$enableval],
	[backarrow_is_erase=no])
CF_XBOOL_RESULT(DEF_BACKARO_ERASE,backarrow_is_erase,[Define to 1 if backarrow-key should be treated as erase])

AC_MSG_CHECKING(for default backspace/DEL setting)
AC_ARG_ENABLE(delete-is-del,
	[  --enable-delete-is-del  set default deleteIsDEL resource (default: maybe)],
	[delete_is_del=$enableval],
	[delete_is_del=maybe])
CF_XBOOL_RESULT(DEFDELETE_DEL,delete_is_del,[Define to 1 if default backspace/DEL setting is DEL])

AC_MSG_CHECKING(for default pty initial erase setting)
AC_ARG_ENABLE(pty-erase,
	[  --enable-pty-erase      set default ptyInitialErase resource (default: maybe)],
	[initial_erase=$enableval],
	[initial_erase=False])
CF_XBOOL_RESULT(DEF_INITIAL_ERASE,initial_erase,[Define to 1 if default pty initial erase setting is TRUE])

AC_MSG_CHECKING(if alt should send ESC)
CF_ARG_ENABLE(alt-sends-esc,
	[  --enable-alt-sends-esc  set default altSendsEscape resource (default: no)],
	[alt_sends_esc=$enableval],
	[alt_sends_esc=no])
CF_XBOOL_RESULT(DEF_ALT_SENDS_ESC,alt_sends_esc,[Define to 1 if alt should send ESC])

AC_MSG_CHECKING(if meta should send ESC)
CF_ARG_ENABLE(meta-sends-esc,
	[  --enable-meta-sends-esc set default metaSendsEscape resource (default: no)],
	[meta_sends_esc=$enableval],
	[meta_sends_esc=no])
CF_XBOOL_RESULT(DEF_META_SENDS_ESC,meta_sends_esc,[Define to 1 if meta should send ESC])

###############################################################################
AC_CHECK_PROG(cf_tic_prog,tic,yes,no)
if test "$cf_tic_prog" = yes ; then
	AC_MSG_CHECKING(for private terminfo-directory)
	AC_ARG_WITH(own-terminfo,
		[  --with-own-terminfo=P   set default $TERMINFO (default: from environment)],
		[TERMINFO_DIR=$withval],
		[TERMINFO_DIR=${TERMINFO-none}])
	AC_MSG_RESULT($TERMINFO_DIR)
	if test "$TERMINFO_DIR" = yes ; then
		AC_MSG_WARN(no value given)
	elif test "$TERMINFO_DIR" != none ; then
		if test -d $TERMINFO_DIR ; then
			AC_DEFINE_UNQUOTED(OWN_TERMINFO_DIR,"$TERMINFO_DIR",[Define to override default TERMINFO value])
			AC_MSG_CHECKING(if \$TERMINFO should also be set)
			AC_ARG_ENABLE(env-terminfo,
				[  --enable-env-terminfo   setenv $TERMINFO if --with-own-terminfo gives value],
				[cf_env_terminfo=yes],
				[cf_env_terminfo=no])
			AC_MSG_RESULT($cf_env_terminfo)
			test $cf_env_terminfo = yes &&
			AC_DEFINE(OWN_TERMINFO_ENV,1,[Define to 1 to enable setenv of $TERMINFO value])
		else
			AC_MSG_WARN(not a directory)
		fi
	elif test "$prefix" != NONE ; then
		TERMINFO_DIR='${prefix}/lib/terminfo'
	elif test -d /usr/lib/terminfo ; then
		TERMINFO_DIR=/usr/lib/terminfo
	else
		TERMINFO_DIR=
	fi
	SET_TERMINFO=
	if test -n "$TERMINFO_DIR" ; then
		TERMINFO_DIR='$(DESTDIR)'$TERMINFO_DIR
		SET_TERMINFO='TERMINFO=$(TERMINFO_DIR)'
	fi
	no_ticprog=
else
	no_ticprog="#"
	TERMINFO_DIR=
	SET_TERMINFO=
fi
AC_SUBST(no_ticprog)
AC_SUBST(TERMINFO_DIR)
AC_SUBST(SET_TERMINFO)

###############################################################################
CF_HELP_MESSAGE(Optional Features:)

AC_MSG_CHECKING(if you want active-icons)
CF_ARG_DISABLE(active-icon,
	[  --disable-active-icon   disable X11R6.3 active-icon feature],
	[enable_active_icon=no],
	[enable_active_icon=yes])
AC_MSG_RESULT($enable_active_icon)
if test "$enable_active_icon" = no ; then
	AC_DEFINE(NO_ACTIVE_ICON,1,[Define to 1 to disable X11R6.3 active-icon feature])
fi

AC_MSG_CHECKING(if you want ANSI color)
CF_ARG_DISABLE(ansi-color,
	[  --disable-ansi-color    disable ANSI color],
	[enable_ansi_color=no],
	[enable_ansi_color=yes])
AC_MSG_RESULT($enable_ansi_color)
test "$enable_ansi_color" = no && AC_DEFINE(OPT_ISO_COLORS,0,[Define to 0 to disable ANSI color])

if test "$enable_ansi_color" = yes ; then

	AC_MSG_CHECKING(if you want 16 colors like aixterm)
	CF_ARG_DISABLE(16-color,
		[  --disable-16-color      disable 16-color support],
		[enable_16_color=no],
		[enable_16_color=yes])
	AC_MSG_RESULT($enable_16_color)
	test "$enable_16_color" = no && AC_DEFINE(OPT_AIX_COLORS,0,[Define to 0 to disable 16-color support])

	AC_MSG_CHECKING(if you want 256 colors)
	CF_ARG_ENABLE(256-color,
		[  --enable-256-color      enable 256-color support],
		[enable_256_color=yes],
		[enable_256_color=no])
	AC_MSG_RESULT($enable_256_color)
	if test "$enable_256_color" = yes ; then
		CHARPROC_DEPS="$CHARPROC_DEPS 256colres.h"
		EXTRAHDRS="$EXTRAHDRS 256colres.h"
		AC_DEFINE(OPT_256_COLORS,1,[Define to 1 to enable 256-color support])
	else
	AC_MSG_CHECKING(if you want 88 colors)
	CF_ARG_ENABLE(88-color,
		[  --enable-88-color       enable 88-color support],
		[enable_88_color=yes],
		[enable_88_color=no])
	AC_MSG_RESULT($enable_88_color)
	if test "$enable_88_color" = yes ; then
		CHARPROC_DEPS="$CHARPROC_DEPS 88colres.h"
		EXTRAHDRS="$EXTRAHDRS 88colres.h"
		AC_DEFINE(OPT_88_COLORS,1,[Define to 1 to enable 88-color support])
	fi
	fi

fi

AC_MSG_CHECKING(if you want blinking cursor)
CF_ARG_DISABLE(blink-cursor,
	[  --disable-blink-cursor  disable support for blinking cursor],
	[enable_blink_curs=no],
	[enable_blink_curs=yes])
AC_MSG_RESULT($enable_blink_curs)
test "$enable_blink_curs" = no && AC_DEFINE(OPT_BLINK_CURS,0,[Define to 0 to disable support for blinking cursor])

AC_MSG_CHECKING(if you want to ignore Linux's broken palette-strings)

case $host_os in
(linux*)
	assume_broken_osc=yes ;;
(*)
	assume_broken_osc=no ;;
esac

CF_ARG_OPTION(broken-osc,
	[  --enable-broken-osc     allow broken Linux OSC-strings],
	[enable_broken_osc=$enableval],
	[enable_broken_osc=$enableval],
	[$assume_broken_osc])
AC_MSG_RESULT($enable_broken_osc)
if test "$enable_broken_osc" = yes ; then
	AC_DEFINE(OPT_BROKEN_OSC,1,[Define to 1 to allow broken Linux OSC-strings])
else
	AC_DEFINE(OPT_BROKEN_OSC,0,[Define to 0 to allow broken Linux OSC-strings])
fi

AC_MSG_CHECKING(if you want to allow broken string-terminators)
CF_ARG_ENABLE(broken-st,
	[  --disable-broken-st     disallow broken string-terminators],
	[enable_broken_st=no],
	[enable_broken_st=yes])
AC_MSG_RESULT($enable_broken_st)
test "$enable_broken_st" = no && AC_DEFINE(OPT_BROKEN_ST,0,[Define to 0 to disallow broken string-terminators])

AC_MSG_CHECKING(if you want to compile-in icon data)
CF_ARG_ENABLE(builtin-xpms,
	[  --enable-builtin-xpms   compile-in icon data],
	[enable_builtin_xpms=yes],
	[enable_builtin_xpms=no])
AC_MSG_RESULT($enable_builtin_xpms)
test "$enable_builtin_xpms" = yes && AC_DEFINE(OPT_BUILTIN_XPMS,1,[Define to 1 to compile-in icon data])

AC_MSG_CHECKING(if you want printable 128-159)
CF_ARG_DISABLE(c1-print,
	[  --disable-c1-print      disallow -k8 option for printable 128-159],
	[enable_c1_print=no],
	[enable_c1_print=yes])
AC_MSG_RESULT($enable_c1_print)
test "$enable_c1_print" = no && AC_DEFINE(OPT_C1_PRINT,0,[Define to 0 to disallow -k8 option for printable 128-159])

if test "$enable_ansi_color" = yes ; then

	AC_MSG_CHECKING(if you want bold colors mapped like IBM PC)
	CF_ARG_DISABLE(bold-color,
		[  --disable-bold-color    disable PC-style mapping of bold colors],
		[enable_pc_color=no],
		[enable_pc_color=yes])
	AC_MSG_RESULT($enable_pc_color)
	test "$enable_pc_color" = no && AC_DEFINE(OPT_PC_COLORS,0,[Define to 0 to disable PC-style mapping of bold colors])

	AC_MSG_CHECKING(if you want separate color-classes)
	CF_ARG_DISABLE(color-class,
		[  --disable-color-class   disable separate color class resources],
		[enable_color_class=no],
		[enable_color_class=yes])
	AC_MSG_RESULT($enable_color_class)
	test "$enable_color_class" = no && AC_DEFINE(OPT_COLOR_CLASS,0,[Define to 0 to disable separate color class resources])

	AC_MSG_CHECKING(if you want color-mode enabled by default)
	CF_ARG_DISABLE(color-mode,
		[  --disable-color-mode    disable default colorMode resource],
		[default_colormode=no],
		[default_colormode=yes])
	AC_MSG_RESULT($default_colormode)
	test "$default_colormode" = no && AC_DEFINE(DFT_COLORMODE,0,[Define to 0 if you want color-mode enabled by default])

fi

AC_MSG_CHECKING(if you want support for color highlighting)
CF_ARG_DISABLE(highlighting,
	[  --disable-highlighting  disable support for color highlighting],
	[default_highlight=no],
	[default_highlight=yes])
AC_MSG_RESULT($default_highlight)
test "$default_highlight" = no && AC_DEFINE(OPT_HIGHLIGHT_COLOR,0,[Define to 1 if you want support for color highlighting])

AC_MSG_CHECKING(if you want support for doublesize characters)
CF_ARG_DISABLE(doublechars,
	[  --disable-doublechars   disable support for double-size chars],
	[enable_doublechars=no],
	[enable_doublechars=yes])
AC_MSG_RESULT($enable_doublechars)
test "$enable_doublechars" = no && AC_DEFINE(OPT_DEC_CHRSET,0,[Define to 0 to disable support for double-size chars])

AC_MSG_CHECKING(if you want fallback-support for box characters)
CF_ARG_DISABLE(boxchars,
	[  --disable-boxchars      disable fallback-support for box chars],
	[enable_boxchars=no],
	[enable_boxchars=yes])
AC_MSG_RESULT($enable_boxchars)
test "$enable_boxchars" = no && AC_DEFINE(OPT_BOX_CHARS,0,[Define to 0 to disable fallback-support for box chars])

AC_MSG_CHECKING(if you want to allow spawning new xterms)
CF_ARG_ENABLE(exec-xterm,
	[  --enable-exec-xterm     enable "spawn-new-terminal" action],
	[enable_exec_xterm=yes],
	[enable_exec_xterm=no])
AC_MSG_RESULT($enable_exec_xterm)
if test "$enable_exec_xterm" = yes ; then
	CF_PROCFS_CWD
	if test "$cf_cv_procfs_cwd" = no ; then
		AC_MSG_WARN(no suitable proc filesystem found)
	else
		AC_DEFINE_UNQUOTED(PROCFS_ROOT,"$cf_cv_procfs_cwd",[This is defined via the --enable-exec-xterm option])
		AC_DEFINE(OPT_EXEC_XTERM,1,[Define to 1 to enable "spawn-new-terminal" action])
	fi
fi

AC_MSG_CHECKING(if you want to use double-buffering)
CF_ARG_ENABLE(double-buffer,
	[  --enable-double-buffer  enable double-buffering],
	[enable_double_bfr=yes],
	[enable_double_bfr=no])
AC_MSG_RESULT($enable_double_bfr)
if test "$enable_double_bfr" = yes ; then
	case "x$LIBS" in
	(*Xext*)
		;;
	(*)
		CF_X_EXT 
		;;
	esac
	AC_DEFINE(OPT_DOUBLE_BUFFER,1,[Define to 1 to enable double-buffering])
fi

AC_MSG_CHECKING(if you want to use FreeType library)
CF_ARG_DISABLE(freetype,
	[  --disable-freetype      disable freetype library-support],
	[enable_freetype=no],
	[enable_freetype=yes])
AC_MSG_RESULT($enable_freetype)
if test "$enable_freetype" = yes ; then
	CF_X_FONTCONFIG
else
	CPPFLAGS=`echo "$CPPFLAGS" | sed -e s/-DXRENDERFONT//`
fi

AC_MSG_CHECKING(if you want support for HP-style function keys)
CF_ARG_ENABLE(hp-fkeys,
	[  --enable-hp-fkeys       enable support for HP-style function keys],
	[enable_hp_fkeys=yes],
	[enable_hp_fkeys=no])
AC_MSG_RESULT($enable_hp_fkeys)
if test "$enable_hp_fkeys" = yes ; then
	AC_DEFINE(OPT_HP_FUNC_KEYS,1,[Define to 1 to enable support for HP-style function keys])
fi

AC_MSG_CHECKING(if you want support for SCO-style function keys)
CF_ARG_ENABLE(sco-fkeys,
	[  --enable-sco-fkeys      enable support for SCO-style function keys],
	[enable_sco_fkeys=yes],
	[enable_sco_fkeys=no])
AC_MSG_RESULT($enable_sco_fkeys)
if test "$enable_sco_fkeys" = yes ; then
	AC_DEFINE(OPT_SCO_FUNC_KEYS,1,[Define to 1 to enable support for SCO-style function keys])
fi

AC_MSG_CHECKING(if you want support for Sun-style function keys)
CF_ARG_DISABLE(sun-fkeys,
	[  --disable-sun-fkeys     disable support for Sun-style function keys],
	[enable_sun_fkeys=no],
	[enable_sun_fkeys=yes])
AC_MSG_RESULT($enable_sun_fkeys)
if test "$enable_sun_fkeys" = no ; then
	AC_DEFINE(OPT_SUN_FUNC_KEYS,0,[Define to 0 to disable support for Sun-style function keys])
fi

AC_MSG_CHECKING(if you want saved-lines stored as a FIFO)
CF_ARG_DISABLE(fifo-lines,
	[  --disable-fifo-lines    disable FIFO-storage for saved-lines],
	[enable_fifo_lines=no],
	[enable_fifo_lines=yes])
AC_MSG_RESULT($enable_fifo_lines)
if test "$enable_fifo_lines" = yes ; then
	AC_DEFINE(OPT_FIFO_LINES,1,[Define to 1 to disable FIFO-storage for saved-lines])
fi

AC_MSG_CHECKING(if you want support for internationalization)
CF_ARG_DISABLE(i18n,
	[  --disable-i18n          disable internationalization],
	[enable_i18n=no],
	[enable_i18n=yes])
AC_MSG_RESULT($enable_i18n)
if test "$enable_i18n" = no ; then
	AC_DEFINE(OPT_I18N_SUPPORT,0,[Define to 0 to disable internationalization])
fi

AC_MSG_CHECKING(if you want support for initial-erase setup)
CF_ARG_DISABLE(initial-erase,
	[  --disable-initial-erase disable setup for stty erase],
	[enable_ie=no],
	[enable_ie=yes])
AC_MSG_RESULT($enable_ie)
if test "$enable_ie" = no ; then
	AC_DEFINE(OPT_INITIAL_ERASE,0,[Define to 0 to disable setup for stty erase])
fi

AC_MSG_CHECKING(if you want support for input-method)
CF_ARG_DISABLE(input-method,
	[  --disable-input-method  disable input-method],
	[enable_ximp=no],
	[enable_ximp=yes])
AC_MSG_RESULT($enable_ximp)
CF_INPUT_METHOD
test "$cf_cv_input_method" = no && enable_ximp=no
if test "$enable_ximp" = no ; then
	AC_DEFINE(OPT_INPUT_METHOD,0,[Define to 0 to disable input-method])
fi

AC_MSG_CHECKING(if you want support for load-vt-fonts)
CF_ARG_ENABLE(load-vt-fonts,
	[  --enable-load-vt-fonts  enable load-vt-fonts() action],
	[enable_load_vt_fonts=yes],
	[enable_load_vt_fonts=no])
AC_MSG_RESULT($enable_load_vt_fonts)
if test "$enable_load_vt_fonts" = yes ; then
	AC_DEFINE(OPT_LOAD_VTFONTS,1,[Define to 1 to enable load-vt-fonts() action])
fi

AC_MSG_CHECKING(if you want support for logging)
CF_ARG_ENABLE(logging,
	[  --enable-logging        enable logging],
	[enable_logging=yes],
	[enable_logging=no])
AC_MSG_RESULT($enable_logging)
if test "$enable_logging" = yes ; then
	AC_DEFINE(ALLOWLOGGING,1,[if you want support for logging])
	AC_MSG_CHECKING(if you want to allow logging via a pipe)
	CF_ARG_ENABLE(logfile-exec,
		[  --enable-logfile-exec   enable exec'd logfile filter],
		[enable_log_exec=yes],
		[enable_log_exec=no])
	AC_MSG_RESULT($enable_log_exec)
	if test "$enable_log_exec" = yes ; then
		AC_DEFINE(ALLOWLOGFILEEXEC,1,[if you want to allow logging via a pipe])
	fi
fi

AC_MSG_CHECKING(if you want support for iconify/maximize translations)
CF_ARG_DISABLE(maximize,
	[  --disable-maximize      disable actions for iconify/deiconify/maximize/restore],
	[enable_maximize=no],
	[enable_maximize=yes])
AC_MSG_RESULT($enable_maximize)
test "$enable_maximize" = no && AC_DEFINE(OPT_MAXIMIZE,0,[Define to 0 to disable actions for iconify/deiconify/maximize/restore])

AC_MSG_CHECKING(if you want NumLock to override keyboard tables)
CF_ARG_DISABLE(num-lock,
	[  --disable-num-lock      disable NumLock keypad support],
	[enable_numlock=no],
	[enable_numlock=yes])
AC_MSG_RESULT($enable_numlock)
test "$enable_numlock" = no && AC_DEFINE(OPT_NUM_LOCK,0,[Define to 0 to disable NumLock keypad support])

AC_MSG_CHECKING(if you want support for get/set of base64 selection data)

CF_ARG_DISABLE(paste64,
	[  --disable-paste64       disable get/set base64 selection data],
	[enable_paste64=no],
	[enable_paste64=yes])
AC_MSG_RESULT($enable_paste64)
if test "$enable_paste64" = yes ; then
	AC_DEFINE(OPT_PASTE64,1,[Define to 1 to disable get/set base64 selection data])
else
	AC_DEFINE(OPT_PASTE64,0,[Define to 0 to disable get/set base64 selection data])
fi

AC_MSG_CHECKING(if you want support for pty-handshaking)

CF_ARG_DISABLE(pty-handshake,
	[  --disable-pty-handshake disable pty-handshake support],
	[enable_pty_handshake=no],
	[enable_pty_handshake=yes])
AC_MSG_RESULT($enable_pty_handshake)
if test "$enable_pty_handshake" = yes ; then
	AC_DEFINE(OPT_PTY_HANDSHAKE,1,[Define to 1 to disable pty-handshake support])
else
	AC_DEFINE(OPT_PTY_HANDSHAKE,0,[Define to 0 to disable pty-handshake support])
fi

AC_MSG_CHECKING(if you want support for mouse in readline applications)
CF_ARG_ENABLE(readline-mouse,
	[  --enable-readline-mouse enable support for mouse in readline applications],
	[enable_readline_mouse=yes],
	[enable_readline_mouse=no])
AC_MSG_RESULT($enable_readline_mouse)
if test "$enable_readline_mouse" = yes ; then
	AC_DEFINE(OPT_READLINE,1,[Define to 1 to enable support for mouse in readline applications])
fi

AC_MSG_CHECKING(if you want support for regular-expression selections)
CF_ARG_DISABLE(regex,
	[  --disable-regex         disable regular-expression selections],
	[enable_regex=no],
	[enable_regex=yes])
AC_MSG_RESULT($enable_regex)
if test "$enable_regex" = yes ; then
	CF_WITH_PCRE
	if test "$with_pcre" = no ; then
		CF_REGEX
		if test "X$cf_cv_regex_hdrs" != "Xregex.h" ; then
			AC_MSG_ERROR(Only POSIX or PCRE regular expressions are supported)
		fi
	fi
	AC_DEFINE(OPT_SELECT_REGEX,1,[Define to 1 to enable regular-expression selections])
fi

AC_MSG_CHECKING(if you want support for right-scrollbar)
CF_ARG_DISABLE(rightbar,
	[  --disable-rightbar      disable right-scrollbar support],
	[enable_rightbar=no],
	[enable_rightbar=yes])
AC_MSG_RESULT($enable_rightbar)
if test "$enable_rightbar" = yes ; then
	AC_DEFINE(SCROLLBAR_RIGHT,1,[Define to 1 to enable right-scrollbar support])
fi

AC_MSG_CHECKING(if you want check for redundant name-change)
CF_ARG_DISABLE(samename,
	[  --disable-samename      disable check for redundant name-change],
	[enable_samename=no],
	[enable_samename=yes])
AC_MSG_RESULT($enable_samename)
test "$enable_samename" = no && AC_DEFINE(OPT_SAME_NAME,0,[Define to 0 to disable check for redundant name-change])

AC_MSG_CHECKING(if you want support for selection-actions)
CF_ARG_DISABLE(selection-ops,
	[  --disable-selection-ops disable selection-action operations],
	[enable_selection_ops=no],
	[enable_selection_ops=yes])
AC_MSG_RESULT($enable_selection_ops)
test "$enable_selection_ops" = no && AC_DEFINE(OPT_SELECTION_OPS,0,[Define to 0 disable selection-action operations])

AC_MSG_CHECKING(if you want support for session management)
CF_ARG_DISABLE(session-mgt,
	[  --disable-session-mgt   disable support for session management],
	[enable_session_mgt=no],
	[enable_session_mgt=yes])
AC_MSG_RESULT($enable_session_mgt)
test "$enable_session_mgt" = no && AC_DEFINE(OPT_SESSION_MGT,0,[Define to 0 to disable support for session management])

AC_MSG_CHECKING(if you want to use termcap function-keys)
CF_ARG_DISABLE(tcap-fkeys,
	[  --disable-tcap-fkeys    disable termcap function-keys support],
	[enable_tcap_fkeys=no],
	[enable_tcap_fkeys=yes])
AC_MSG_RESULT($enable_tcap_fkeys)
test "$enable_tcap_fkeys" = yes && AC_DEFINE(OPT_TCAP_FKEYS,1,[Define to 1 to disable termcap function-keys support])

AC_MSG_CHECKING(if you want to use termcap-query/report)
CF_ARG_DISABLE(tcap-query,
	[  --disable-tcap-query    disable compiled-in termcap-query support],
	[enable_tcap_query=no],
	[enable_tcap_query=yes])
AC_MSG_RESULT($enable_tcap_query)
test "$enable_tcap_query" = yes && AC_DEFINE(OPT_TCAP_QUERY,1,[Define to 1 to disable compiled-in termcap-query support])

AC_MSG_CHECKING(if you want support for tek4014)
CF_ARG_DISABLE(tek4014,
	[  --disable-tek4014       disable tek4014 emulation],
	[enable_tek4014=no],
	[enable_tek4014=yes])
AC_MSG_RESULT($enable_tek4014)
if test "$enable_tek4014" = no ; then
	AC_DEFINE(OPT_TEK4014,0,[Define to 0 to disable tek4014 emulation])
else
	EXTRAHDRS="$EXTRAHDRS Tekparse.h"
	EXTRASRCS="$EXTRASRCS TekPrsTbl.c Tekproc.c"
	EXTRAOBJS="$EXTRAOBJS TekPrsTbl.o Tekproc.o"
fi

AC_MSG_CHECKING(if you want pulldown menus with a toolbar)
CF_ARG_ENABLE(toolbar,
	[  --enable-toolbar        compile-in toolbar for pulldown menus],
	[enable_toolbar=yes],
	[enable_toolbar=no])
AC_MSG_RESULT($enable_toolbar)
if test "$enable_toolbar" = yes ; then
	AC_DEFINE(OPT_TOOLBAR,1,[Define to 1 to compile-in toolbar for pulldown menus])
fi

AC_MSG_CHECKING(if you want VT52 emulation)
CF_ARG_DISABLE(vt52,
	[  --disable-vt52          disable VT52 emulation],
	[enable_vt52=no],
	[enable_vt52=yes])
AC_MSG_RESULT($enable_vt52)
test "$enable_vt52" = no && AC_DEFINE(OPT_VT52_MODE,0,[Define to 0 to disable VT52 emulation])

AC_MSG_CHECKING(if you want wide-attribute support)
CF_ARG_DISABLE(wide-attrs,
	[  --disable-wide-attrs    disable wide-attribute support],
	[enable_wattr=no],
	[enable_wattr=yes])
AC_MSG_RESULT($enable_wattr)

AC_MSG_CHECKING(if you want wide-character support)
CF_ARG_DISABLE(wide-chars,
	[  --disable-wide-chars    disable wide-character support],
	[enable_wchar=no],
	[enable_wchar=yes])
AC_MSG_RESULT($enable_wchar)
test "$enable_wattr" = no && AC_DEFINE(OPT_WIDE_ATTRS,0,[Define to 0 to disable rarely-used SGR features])

AC_MSG_CHECKING(if you want only 16-bit character support)
CF_ARG_ENABLE(16bit-chars,
	[  --enable-16bit-chars    enable 16-bit character support],
	[enable_16bit_chars=yes],
	[enable_16bit_chars=no])
AC_MSG_RESULT($enable_16bit_chars)

if test "$enable_16bit_chars" = yes ; then
	AC_DEFINE(OPT_WIDER_ICHAR,0,[Define to 0 to enable 16-bit character support])
	enable_wchar=yes
fi

if test "$enable_wchar" = yes ; then

AC_MSG_CHECKING(if you want to use mini-luit/Latin9 built-in support)
CF_ARG_ENABLE(mini-luit,
	[  --enable-mini-luit      enable mini-luit (built-in Latin9 support)],
	[enable_mini_luit=yes],
	[enable_mini_luit=no])
AC_MSG_RESULT($enable_mini_luit)
if test "$enable_mini_luit" = yes ; then
	AC_DEFINE(OPT_MINI_LUIT,1,[Define to 1 to enable mini-luit (built-in Latin9 support)])
fi

AC_MSG_CHECKING(if you want to use luit)
CF_ARG_DISABLE(luit,
	[  --disable-luit          enable luit filter (Unicode translation)],
	[enable_luit=no],
	[enable_luit=yes])
AC_MSG_RESULT($enable_luit)
if test "$enable_luit" = yes ; then
	AC_DEFINE(OPT_LUIT_PROG,1,[Define to 1 to enable luit filter (Unicode translation)])
	CF_PATH_PROG(LUIT,xterm-filter,bluit luit)
fi

	AC_DEFINE(OPT_WIDE_CHARS,1,[Define to 1 to enable wide-character support])
	EXTRAHDRS="$EXTRAHDRS charclass.h precompose.h wcwidth.h"
	EXTRASRCS="$EXTRASRCS charclass.c precompose.c wcwidth.c"
	EXTRAOBJS="$EXTRAOBJS charclass.o precompose.o wcwidth.o"
fi

AC_MSG_CHECKING(if you want dynamic-abbreviation support)
CF_ARG_ENABLE(dabbrev,
	[  --enable-dabbrev        enable dynamic-abbreviation support],
	[enable_dabbrev=yes],
	[enable_dabbrev=no])
AC_MSG_RESULT($enable_dabbrev)
if test "$enable_dabbrev" = yes ; then
	AC_DEFINE(OPT_DABBREV,1,[Define to 1 to enable dynamic-abbreviation support])
fi

AC_MSG_CHECKING(if you want DECterm Locator support)
CF_ARG_ENABLE(dec-locator,
	[  --enable-dec-locator    enable DECterm Locator support],
	[enable_dec_locator=yes],
	[enable_dec_locator=no])
AC_MSG_RESULT($enable_dec_locator)
if test "$enable_dec_locator" = yes ; then
	AC_DEFINE(OPT_DEC_LOCATOR,1,[Define to 1 to enable DECterm Locator support])
fi

AC_MSG_CHECKING(if you want XHTML and SVG screen dump support)
CF_ARG_ENABLE(screen-dumps,
	[  --enable-screen-dumps   enable XHTML and SVG screen dumps],
	[enable_screen_dumps=yes],
	[enable_screen_dumps=no])
AC_MSG_RESULT($enable_screen_dumps)
if test "$enable_screen_dumps" = yes ; then
	AC_DEFINE(OPT_SCREEN_DUMPS,1,[Define to 1 to enable XHTML and SVG screen dump support])
	EXTRASRCS="$EXTRASRCS html.c svg.c"
	EXTRAOBJS="$EXTRAOBJS html.o svg.o"
fi

AC_MSG_CHECKING(if you want ReGIS graphics support)
CF_ARG_ENABLE(regis-graphics,
	[  --enable-regis-graphics enable ReGIS graphics support],
	[enable_regis_graphics=yes],
	[enable_regis_graphics=no])
AC_MSG_RESULT($enable_regis_graphics)
if test "$enable_regis_graphics" = yes ; then
	AC_DEFINE(OPT_REGIS_GRAPHICS,1,[Define to 1 to enable ReGIS graphics support])
	EXTRAHDRS="$EXTRAHDRS graphics_regis.h"
	EXTRASRCS="$EXTRASRCS graphics_regis.c"
	EXTRAOBJS="$EXTRAOBJS graphics_regis.o"
	CF_MATH_LIB
fi

AC_MSG_CHECKING(if you want sixel graphics support)
CF_ARG_ENABLE(sixel-graphics,
	[  --enable-sixel-graphics enable sixel graphics support],
	[enable_sixel_graphics=yes],
	[enable_sixel_graphics=no])
AC_MSG_RESULT($enable_sixel_graphics)
if test "$enable_sixel_graphics" = yes ; then
	AC_DEFINE(OPT_SIXEL_GRAPHICS,1,[Define to 1 to enable sixel graphics support])
	EXTRAHDRS="$EXTRAHDRS graphics_sixel.h"
	EXTRASRCS="$EXTRASRCS graphics_sixel.c"
	EXTRAOBJS="$EXTRAOBJS graphics_sixel.o"
fi

if test "$enable_regis_graphics" = yes || test "$enable_sixel_graphics" = yes ; then
	AC_DEFINE(OPT_GRAPHICS,1,[Defined to 1 to if any graphics mode is enabled])
	EXTRAHDRS="$EXTRAHDRS graphics.h"
	EXTRASRCS="$EXTRASRCS graphics.c"
	EXTRAOBJS="$EXTRAOBJS graphics.o"
fi

AC_MSG_CHECKING(if you want VT420 rectangle support)
CF_ARG_DISABLE(rectangles,
	[  --disable-rectangles    disable VT420 rectangle support],
	[enable_rectangles=no],
	[enable_rectangles=yes])
AC_MSG_RESULT($enable_rectangles)
if test "$enable_rectangles" = yes ; then
	AC_DEFINE(OPT_DEC_RECTOPS,1,[Define to 1 to disable VT420 rectangle support])
fi

AC_MSG_CHECKING(if you want -ziconbeep option)
CF_ARG_DISABLE(ziconbeep,
	[  --disable-ziconbeep     disable -ziconbeep option],
	[enable_ziconbeep=no],
	[enable_ziconbeep=yes])
AC_MSG_RESULT($enable_ziconbeep)
test "$enable_ziconbeep" = no && AC_DEFINE(OPT_ZICONBEEP,0,[Define to 0 to disable -ziconbeep option])

###############################################################################
CF_HELP_MESSAGE(Testing/development Options:)

AC_MSG_CHECKING(if you want debugging traces)
CF_ARG_ENABLE(trace,
	[  --enable-trace          test: set to enable debugging traces],
	[enable_trace=yes],
	[enable_trace=no])
AC_MSG_RESULT($enable_trace)
if test "$enable_trace" = yes ; then
	AC_DEFINE(OPT_TRACE,1,[Define to 1 to enable debugging traces])
	EXTRASRCS="$EXTRASRCS trace.c"
	EXTRAOBJS="$EXTRAOBJS trace.o"
fi

CF_DISABLE_LEAKS
CF_DISABLE_ECHO

AC_MSG_CHECKING(if you want magic cookie emulation)
CF_ARG_ENABLE(xmc-glitch,
	[  --enable-xmc-glitch     test: enable xmc magic-cookie emulation],
	[enable_xmc=yes],
	[enable_xmc=no])
AC_MSG_RESULT($enable_xmc)
if test "$enable_xmc" = yes ; then
	AC_DEFINE(OPT_XMC_GLITCH,1,[Define to 1 to enable xmc magic-cookie emulation])
	EXTRASRCS="$EXTRASRCS testxmc.c"
	EXTRAOBJS="$EXTRAOBJS testxmc.o"
fi

dnl FIXME - extra test needed to make tcap-fkeys work on HPUX
AC_CHECK_FUNCS(tigetstr)

dnl only check for ncurses' use_extended_names if really not using termcap
if test -n "$cf_cv_lib_part_tgetent"; then
    AC_CHECK_FUNCS(use_extended_names)
fi

if test -n "$GCC" ; then
AC_MSG_CHECKING(if you want to turn on gcc warnings)
CF_ARG_ENABLE(warnings,
	[  --enable-warnings       test: turn on GCC compiler warnings],
	[with_warnings=yes],
	[with_warnings=no])
AC_MSG_RESULT($with_warnings)
if test "$with_warnings" = yes
then
	CF_GCC_ATTRIBUTES
	CF_GCC_WARNINGS(Wdeclaration-after-statement Wextra Wno-unknown-pragmas Wswitch-enum)
fi
fi

AC_SUBST(EXTRA_CFLAGS)
AC_SUBST(CHARPROC_DEPS)
AC_SUBST(EXTRAHDRS)
AC_SUBST(EXTRASRCS)
AC_SUBST(EXTRAOBJS)

test "$disable_setuid" = yes && AC_DEFINE(DISABLE_SETUID,1,[Define to 1 if you want to disable setuid])
test "$disable_setgid" = yes && AC_DEFINE(DISABLE_SETGID,1,[Define to 1 if you want to disable setgid])

if test $disable_setuid = yes ; then
	MAY_SETUID="#"
	NOT_SETUID=
elif test $disable_setgid = yes ; then
	MAY_SETUID="#"
	NOT_SETUID=
else
	MAY_SETUID=
	NOT_SETUID="#"
fi

AC_SUBST(MAY_SETUID)
AC_SUBST(NOT_SETUID)

###	remove from CPPFLAGS the optional features we define in xtermcfg.h
###	or other conflicting symbols that may be defined via imake:
for cf_def in \
	__STDC__ \
	ALLOWLOGGING \
	ALLOWLOGFILEEXEC \
	OPT_LUIT_PROG \
	OPT_WIDE_CHARS \
	SCROLLBAR_RIGHT \
	USE_TTY_GROUP \
	USE_UTEMPTER \
	XRENDERFONT
do
	CPPFLAGS=`echo "$CPPFLAGS" | sed -e s/-D$cf_def//`
done

CF_MAKE_TAGS
CF_DISABLE_RPATH_HACK

# Force plink.sh to not trim pcre's libraries, which have the same symbol
# names as the system regexp.
if test "$with_pcre" != no
then
	LIBS=`echo "$LIBS" | sed -e 's/-lpcre/-kpcre/g'`
fi

###	output xtermcfg.h, etc
AC_CONFIG_FILES([Makefile df-install minstall:minstall.in])
AC_OUTPUT
xterm-330/Tekproc.c0000644000175100001440000015510313113126206013012 0ustar  tomusers/* $XTermId: Tekproc.c,v 1.228 2017/05/29 23:19:34 tom Exp $ */

/*
 * Copyright 2001-2016,2017 by Thomas E. Dickey
 *
 *                         All Rights Reserved
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name(s) of the above copyright
 * holders shall not be used in advertising or otherwise to promote the
 * sale, use or other dealings in this Software without prior written
 * authorization.
 *
 * Copyright 1988  The Open Group
 *
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that
 * copyright notice and this permission notice appear in supporting
 * documentation.
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 * OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name of The Open Group shall not be
 * used in advertising or otherwise to promote the sale, use or other dealings
 * in this Software without prior written authorization from The Open Group.
 *
 * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 *
 *                         All Rights Reserved
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose and without fee is hereby granted,
 * provided that the above copyright notice appear in all copies and that
 * both that copyright notice and this permission notice appear in
 * supporting documentation, and that the name of Digital Equipment
 * Corporation not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 *
 *
 * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */

/* Tekproc.c */

#define RES_OFFSET(field)	XtOffsetOf(TekWidgetRec, field)

#include 

#include 
#include 
#include 
#include 

#if OPT_TOOLBAR

#if defined(HAVE_LIB_XAW)
#include 
#elif defined(HAVE_LIB_XAW3D)
#include 
#elif defined(HAVE_LIB_XAW3DXFT)
#include 
#elif defined(HAVE_LIB_NEXTAW)
#include 
#elif defined(HAVE_LIB_XAWPLUS)
#include 
#endif

#endif /* OPT_TOOLBAR */

#include 
#include 
#include 
#include 

#include 
#include 
#include 
#include 
#include 

#define DefaultGCID(tw) \
	XGContextFromGC(DefaultGC(XtDisplay(tw), \
			DefaultScreen(XtDisplay(tw))))

/* Tek defines */

#define MY_CLASS "Tek4014"
#define MY_NAME  "tek4014"

#define	SOLIDLINE	0
#define	DOTTEDLINE	1
#define	DOTDASHEDLINE	2
#define	SHORTDASHEDLINE	3
#define	LONGDASHEDLINE	4

#define	EAST		001
#define	WEST		002
#define	NORTH		004
#define	SOUTH		010

#define	LINEMASK	07
#define	MARGIN1		0
#define	MARGIN2		1
#define MAX_PTS		150
#define MAX_VTX		300
#define	PENDOWN		1
#define	PENUP		0
#define	TEKBOTTOMPAD	23
#define	TEKDEFHEIGHT	565
#define	TEKDEFWIDTH	750
#define	TEKHEIGHT	3072
#define	TEKHOME		( (TekChar[tekscr->page.fontsize].nlines - 1) \
			 * TekChar[tekscr->page.fontsize].vsize)
#define	TEKMINHEIGHT	452
#define	TEKMINWIDTH	600
#define	TEKTOPPAD	34
#define	TEKWIDTH	4096

#define	FULL_HEIGHT	(TEKHEIGHT + TEKTOPPAD + TEKBOTTOMPAD)

#define	BottomY(y)	(TEKHEIGHT + TEKTOPPAD - (y))
#define	BorderOf(tw)	(TScreenOf((tw)->vt)->border)
#define	ScaleOf(tw)	TekScale(TekScreenOf(tw))
#define	ScaledX(tw,x)	(((x) * ScaleOf(tw)) + BorderOf(tw))
#define	ScaledY(tw,y)	((BottomY(y) * ScaleOf(tw)) + BorderOf(tw))

#define	TekMove(tw,x,y)	tekscr->cur_X = x; tekscr->cur_Y = y
#define	input()		Tinput(tw)
#define	unput(c)	*Tpushback++ = (Char) c
/* *INDENT-OFF* */
static const struct Tek_Char {
    int hsize;			/* in Tek units */
    int vsize;			/* in Tek units */
    int charsperline;
    int nlines;
} TekChar[TEKNUMFONTS] = {
    {56, 88, 74, 35},		/* large */
    {51, 82, 81, 38},		/* #2 */
    {34, 53, 121, 58},		/* #3 */
    {31, 48, 133, 64},		/* small */
};
/* *INDENT-ON* */

static Cursor GINcursor;
static XSegment *line_pt;
static int nplot;
static TekLink Tek0;
static jmp_buf Tekjump;
static TekLink *TekRecord;
static XSegment *Tline;

static Const int *curstate = Talptable;
static Const int *Tparsestate = Talptable;

static char defaultTranslations[] = "\
                ~Meta: insert-seven-bit() \n\
                 Meta: insert-eight-bit() \n\
               !Ctrl : popup-menu(mainMenu) \n\
          !Lock Ctrl : popup-menu(mainMenu) \n\
!Lock Ctrl @Num_Lock : popup-menu(mainMenu) \n\
     !Ctrl @Num_Lock : popup-menu(mainMenu) \n\
               !Ctrl : popup-menu(tekMenu) \n\
          !Lock Ctrl : popup-menu(tekMenu) \n\
!Lock Ctrl @Num_Lock : popup-menu(tekMenu) \n\
     !Ctrl @Num_Lock : popup-menu(tekMenu) \n\
          Shift ~Meta: gin-press(L) \n\
                ~Meta: gin-press(l) \n\
          Shift ~Meta: gin-press(M) \n\
                ~Meta: gin-press(m) \n\
          Shift ~Meta: gin-press(R) \n\
                ~Meta: gin-press(r)";
/* *INDENT-OFF* */
static XtActionsRec actionsList[] = {
    { "string",			HandleStringEvent },
    { "insert",			HandleKeyPressed },	/* alias for insert-seven-bit */
    { "insert-seven-bit",	HandleKeyPressed },
    { "insert-eight-bit",	HandleEightBitKeyPressed },
    { "gin-press",		HandleGINInput },
    { "secure",			HandleSecure },
    { "create-menu",		HandleCreateMenu },
    { "popup-menu",		HandlePopupMenu },
    /* menu actions */
    { "allow-send-events",	HandleAllowSends },
    { "set-visual-bell",	HandleSetVisualBell },
#ifdef ALLOWLOGGING
    { "set-logging",		HandleLogging },
#endif
    { "redraw",			HandleRedraw },
    { "send-signal",		HandleSendSignal },
    { "quit",			HandleQuit },
    { "set-scrollbar",		HandleScrollbar },
    { "set-jumpscroll",		HandleJumpscroll },
    { "set-reverse-video",	HandleReverseVideo },
    { "set-autowrap",		HandleAutoWrap },
    { "set-reversewrap",	HandleReverseWrap },
    { "set-autolinefeed",	HandleAutoLineFeed },
    { "set-appcursor",		HandleAppCursor },
    { "set-appkeypad",		HandleAppKeypad },
    { "set-scroll-on-key",	HandleScrollKey },
    { "set-scroll-on-tty-output", HandleScrollTtyOutput },
    { "set-allow132",		HandleAllow132 },
    { "set-cursesemul",		HandleCursesEmul },
    { "set-marginbell",		HandleMarginBell },
    { "set-altscreen",		HandleAltScreen },
    { "soft-reset",		HandleSoftReset },
    { "hard-reset",		HandleHardReset },
    { "set-terminal-type",	HandleSetTerminalType },
    { "set-visibility",		HandleVisibility },
    { "set-tek-text",		HandleSetTekText },
    { "tek-page",		HandleTekPage },
    { "tek-reset",		HandleTekReset },
    { "tek-copy",		HandleTekCopy },
#if OPT_TOOLBAR
    { "set-toolbar",		HandleToolbar },
#endif
};
/* *INDENT-ON* */

static Dimension defOne = 1;

#define GIN_TERM_NONE_STR	"none"
#define GIN_TERM_CR_STR		"CRonly"
#define GIN_TERM_EOT_STR	"CR&EOT"

#define GIN_TERM_NONE	0
#define GIN_TERM_CR	1
#define GIN_TERM_EOT	2

#ifdef VMS
#define DFT_FONT_SMALL "FIXED"
#else
#define DFT_FONT_SMALL "6x10"
#endif

static XtResource resources[] =
{
    {XtNwidth, XtCWidth, XtRDimension, sizeof(Dimension),
     XtOffsetOf(CoreRec, core.width), XtRDimension, (caddr_t) & defOne},
    {XtNheight, XtCHeight, XtRDimension, sizeof(Dimension),
     XtOffsetOf(CoreRec, core.height), XtRDimension, (caddr_t) & defOne},
    Fres("fontLarge", XtCFont, tek.Tfont[TEK_FONT_LARGE], "9x15"),
    Fres("font2", XtCFont, tek.Tfont[TEK_FONT_2], "6x13"),
    Fres("font3", XtCFont, tek.Tfont[TEK_FONT_3], "8x13"),
    Fres("fontSmall", XtCFont, tek.Tfont[TEK_FONT_SMALL], DFT_FONT_SMALL),
    Sres(XtNinitialFont, XtCInitialFont, tek.initial_font, "large"),
    Sres("ginTerminator", "GinTerminator", tek.gin_terminator_str, GIN_TERM_NONE_STR),
#if OPT_TOOLBAR
    Wres(XtNmenuBar, XtCMenuBar, tek.tb_info.menu_bar, 0),
    Ires(XtNmenuHeight, XtCMenuHeight, tek.tb_info.menu_height, 25),
#endif
};

static IChar Tinput(TekWidget /* tw */ );
static int getpoint(TekWidget /* tw */ );
static void TCursorBack(TekWidget /* tw */ );
static void TCursorDown(TekWidget /* tw */ );
static void TCursorForward(TekWidget /* tw */ );
static void TCursorUp(TekWidget /* tw */ );
static void TekBackground(TekWidget /* tw */ ,
			  TScreen * /* screen */ );
static void TekResize(Widget /* w */ );
static void TekDraw(TekWidget /* tw */ ,
		    int /* x */ ,
		    int /* y */ );
static void TekEnq(TekWidget /* tw */ ,
		   unsigned /* status */ ,
		   int /* x */ ,
		   int /* y */ );
static void TekFlush(TekWidget /* tw */ );
static void TekInitialize(Widget /* request */ ,
			  Widget /* wnew */ ,
			  ArgList /* args */ ,
			  Cardinal * /* num_args */ );
static void TekPage(TekWidget /* tw */ );
static void TekRealize(Widget /* gw */ ,
		       XtValueMask * /* valuemaskp */ ,
		       XSetWindowAttributes * /* values */ );

static WidgetClassRec tekClassRec =
{
    {
/* core_class fields */
	(WidgetClass) & widgetClassRec,		/* superclass     */
	MY_CLASS,		/* class_name                   */
	sizeof(TekWidgetRec),	/* widget_size                  */
	NULL,			/* class_initialize             */
	NULL,			/* class_part_initialize        */
	False,			/* class_inited                 */
	TekInitialize,		/* initialize                   */
	NULL,			/* initialize_hook              */
	TekRealize,		/* realize                      */
	actionsList,		/* actions                      */
	XtNumber(actionsList),	/* num_actions                  */
	resources,		/* resources                    */
	XtNumber(resources),	/* num_resources                */
	NULLQUARK,		/* xrm_class                    */
	True,			/* compress_motion              */
	True,			/* compress_exposure            */
	True,			/* compress_enterleave          */
	False,			/* visible_interest             */
	NULL,			/* destroy                      */
	TekResize,		/* resize                       */
	TekExpose,		/* expose                       */
	NULL,			/* set_values                   */
	NULL,			/* set_values_hook              */
	XtInheritSetValuesAlmost,	/* set_values_almost    */
	NULL,			/* get_values_hook              */
	NULL,			/* accept_focus                 */
	XtVersion,		/* version                      */
	NULL,			/* callback_offsets             */
	defaultTranslations,	/* tm_table                     */
	XtInheritQueryGeometry,	/* query_geometry               */
	XtInheritDisplayAccelerator,	/* display_accelerator  */
	NULL			/* extension                    */
    }
};
WidgetClass tekWidgetClass = (WidgetClass) & tekClassRec;

static Bool Tfailed = False;

/*
 * TekInit/TekRun are called after the VT100 widget has been initialized, but
 * may be before VT100 is realized, depending upon whether Tek4014 is the
 * first window to be shown.
 */
int
TekInit(void)
{
    Widget form_top, menu_top;
    Dimension menu_high;

    if (!Tfailed
	&& tekWidget == 0) {
	Cardinal nargs = 0;
	Arg myArgs[3];
	Boolean iconic = 0;

	TRACE(("TekInit\n"));
	XtSetArg(myArgs[nargs], XtNiconic, &iconic);
	++nargs;
	XtGetValues(toplevel, myArgs, nargs);

	nargs = 0;
	XtSetArg(myArgs[nargs], XtNiconic, iconic);
	++nargs;
	XtSetArg(myArgs[nargs], XtNallowShellResize, True);
	++nargs;
	XtSetArg(myArgs[nargs], XtNinput, True);
	++nargs;

	/* this causes the Initialize method to be called */
	tekshellwidget =
	    XtCreatePopupShell("tektronix", topLevelShellWidgetClass,
			       toplevel, myArgs, nargs);

	SetupMenus(tekshellwidget, &form_top, &menu_top, &menu_high);

	/* this causes the Realize method to be called */
	tekWidget = (TekWidget)
	    XtVaCreateManagedWidget(MY_NAME,
				    tekWidgetClass, form_top,
#if OPT_TOOLBAR
				    XtNmenuBar, menu_top,
				    XtNresizable, True,
				    XtNfromVert, menu_top,
				    XtNtop, XawChainTop,
				    XtNleft, XawChainLeft,
				    XtNright, XawChainRight,
				    XtNbottom, XawChainBottom,
				    XtNmenuHeight, menu_high,
#endif
				    (XtPointer) 0);
#if OPT_TOOLBAR
	ShowToolbar(resource.toolBar);
#endif
    }
    return (!Tfailed);
}

/*
 * If we haven't allocated the PtyData struct, do so.
 */
static int
TekPtyData(void)
{
    if (Tpushb == 0 && !Tfailed) {
	if ((Tpushb = TypeMallocN(Char, 10)) == NULL
	    || (Tline = TypeMallocN(XSegment, MAX_VTX)) == NULL) {
	    xtermWarning("Not enough core for Tek mode\n");
	    if (Tpushb)
		free(Tpushb);
	    Tfailed = True;
	}
    }
    return (Tfailed ? 0 : 1);
}

static void
Tekparse(TekWidget tw)
{
    TekScreen *tekscr = TekScreenOf(tw);
    TScreen *screen = TScreenOf(tw->vt);
    int x, y;
    IChar ch;
    int nextstate;

    for (;;) {
	IChar c = input();
	/*
	 * The parsing tables all have 256 entries.  If we're supporting
	 * wide characters, we handle them by treating them the same as
	 * printing characters.
	 */
#if OPT_WIDE_CHARS
	if (c > 255) {
	    nextstate = (Tparsestate == Talptable)
		? CASE_PRINT
		: CASE_IGNORE;
	} else
#endif
	    nextstate = Tparsestate[c];
	TRACE(("Tekparse %04X -> %d\n", c, nextstate));

	switch (nextstate) {
	case CASE_REPORT:
	    TRACE(("case: report address\n"));
	    if (tekscr->TekGIN) {
		TekGINoff(tw);
		TekEnqMouse(tw, 0);
	    } else {
		c = 064;	/* has hard copy unit */
		if (tekscr->margin == MARGIN2)
		    c |= 02;
		TekEnq(tw, c, tekscr->cur_X, tekscr->cur_Y);
	    }
	    TekRecord->ptr[-1] = ANSI_NAK;	/* remove from recording */
	    Tparsestate = curstate;
	    break;

	case CASE_VT_MODE:
	    TRACE(("case: special return to vt102 mode\n"));
	    Tparsestate = curstate;
	    TekRecord->ptr[-1] = ANSI_NAK;	/* remove from recording */
	    FlushLog(tw->vt);
	    return;

	case CASE_SPT_STATE:
	    TRACE(("case: Enter Special Point Plot mode\n"));
	    if (tekscr->TekGIN)
		TekGINoff(tw);
	    Tparsestate = curstate = Tspttable;
	    break;

	case CASE_GIN:
	    TRACE(("case: Do Tek GIN mode\n"));
	    tekscr->TekGIN = &TekRecord->ptr[-1];
	    /* Set cross-hair cursor raster array */
	    if ((GINcursor =
		 make_colored_cursor(XC_tcross,
				     T_COLOR(screen, MOUSE_FG),
				     T_COLOR(screen, MOUSE_BG))) != 0) {
		XDefineCursor(XtDisplay(tw), TWindow(tekscr),
			      GINcursor);
	    }
	    Tparsestate = Tbyptable;	/* Bypass mode */
	    break;

	case CASE_BEL:
	    TRACE(("case: BEL\n"));
	    if (tekscr->TekGIN)
		TekGINoff(tw);
	    if (!tekRefreshList)
		Bell(tw->vt, XkbBI_TerminalBell, 0);
	    Tparsestate = curstate;	/* clear bypass condition */
	    break;

	case CASE_BS:
	    TRACE(("case: BS\n"));
	    if (tekscr->TekGIN)
		TekGINoff(tw);
	    Tparsestate = curstate;	/* clear bypass condition */
	    TCursorBack(tw);
	    break;

	case CASE_PT_STATE:
	    TRACE(("case: Enter Tek Point Plot mode\n"));
	    if (tekscr->TekGIN)
		TekGINoff(tw);
	    Tparsestate = curstate = Tpttable;
	    break;

	case CASE_PLT_STATE:
	    TRACE(("case: Enter Tek Plot mode\n"));
	    if (tekscr->TekGIN)
		TekGINoff(tw);
	    Tparsestate = curstate = Tplttable;
	    if ((c = input()) == ANSI_BEL)
		tekscr->pen = PENDOWN;
	    else {
		unput(c);
		tekscr->pen = PENUP;
	    }
	    break;

	case CASE_TAB:
	    TRACE(("case: HT\n"));
	    if (tekscr->TekGIN)
		TekGINoff(tw);
	    Tparsestate = curstate;	/* clear bypass condition */
	    TCursorForward(tw);
	    break;

	case CASE_IPL_STATE:
	    TRACE(("case: Enter Tek Incremental Plot mode\n"));
	    if (tekscr->TekGIN)
		TekGINoff(tw);
	    Tparsestate = curstate = Tipltable;
	    break;

	case CASE_ALP_STATE:
	    TRACE(("case: Enter Tek Alpha mode from any other mode\n"));
	    if (tekscr->TekGIN)
		TekGINoff(tw);
	    /* if in one of graphics states, move alpha cursor */
	    if (nplot > 0)	/* flush line VTbuffer */
		TekFlush(tw);
	    Tparsestate = curstate = Talptable;
	    break;

	case CASE_UP:
	    TRACE(("case: cursor up\n"));
	    if (tekscr->TekGIN)
		TekGINoff(tw);
	    Tparsestate = curstate;	/* clear bypass condition */
	    TCursorUp(tw);
	    break;

	case CASE_COPY:
	    TRACE(("case: make copy\n"));
	    if (tekscr->TekGIN)
		TekGINoff(tw);
	    TekCopy(tw);
	    TekRecord->ptr[-1] = ANSI_NAK;	/* remove from recording */
	    Tparsestate = curstate;	/* clear bypass condition */
	    break;

	case CASE_PAGE:
	    TRACE(("case: Page Function\n"));
	    if (tekscr->TekGIN)
		TekGINoff(tw);
	    TekPage(tw);	/* clear bypass condition */
	    break;

	case CASE_BES_STATE:
	    TRACE(("case: Byp: an escape char\n"));
	    Tparsestate = Tbestable;
	    break;

	case CASE_BYP_STATE:
	    TRACE(("case: set bypass condition\n"));
	    Tparsestate = Tbyptable;
	    break;

	case CASE_IGNORE:
	    TRACE(("case: Esc: totally ignore CR, ESC, LF, ~\n"));
	    break;

	case CASE_ASCII:
	    TRACE(("case: Select ASCII char set\n"));
	    /* ignore for now */
	    Tparsestate = curstate;
	    break;

	case CASE_APL:
	    TRACE(("case: Select APL char set\n"));
	    /* ignore for now */
	    Tparsestate = curstate;
	    break;

	case CASE_CHAR_SIZE:
	    TRACE(("case: character size selector\n"));
	    TekSetFontSize(tw, False, (int) (c & 03));
	    Tparsestate = curstate;
	    break;

	case CASE_BEAM_VEC:
	    TRACE(("case: beam and vector selector\n"));
	    /* only line types */
	    c = (IChar) (c & LINEMASK);
	    if (c != tekscr->cur.linetype) {
		if (nplot > 0)
		    TekFlush(tw);
		if (c <= TEKNUMLINES)
		    tekscr->cur.linetype = c;
	    }
	    Tparsestate = curstate;
	    break;

	case CASE_CURSTATE:
	    Tparsestate = curstate;
	    break;

	case CASE_PENUP:
	    TRACE(("case: Ipl: penup\n"));
	    tekscr->pen = PENUP;
	    break;

	case CASE_PENDOWN:
	    TRACE(("case: Ipl: pendown\n"));
	    tekscr->pen = PENDOWN;
	    break;

	case CASE_IPL_POINT:
	    TRACE(("case: Ipl: point\n"));
	    x = tekscr->cur_X;
	    y = tekscr->cur_Y;
	    if (c & NORTH)
		y++;
	    else if (c & SOUTH)
		y--;
	    if (c & EAST)
		x++;
	    else if (c & WEST)
		x--;
	    if (tekscr->pen == PENDOWN)
		TekDraw(tw, x, y);
	    else
		TekMove(tw, x, y);
	    break;

	case CASE_PLT_VEC:
	    TRACE(("case: Plt: vector\n"));
	    unput(c);
	    if (getpoint(tw)) {
		if (tekscr->pen == PENDOWN) {
		    TekDraw(tw, tekscr->cur.x, tekscr->cur.y);
		} else {
		    TekMove(tw, tekscr->cur.x, tekscr->cur.y);
		}
		tekscr->pen = PENDOWN;
	    }
	    break;

	case CASE_PT_POINT:
	    TRACE(("case: Pt: point\n"));
	    unput(c);
	    if (getpoint(tw)) {
		TekMove(tw, tekscr->cur.x, tekscr->cur.y);
		TekDraw(tw, tekscr->cur.x, tekscr->cur.y);
	    }
	    break;

	case CASE_SPT_POINT:
	    TRACE(("case: Spt: point\n"));
	    /* ignore intensity character in c */
	    if (getpoint(tw)) {
		TekMove(tw, tekscr->cur.x, tekscr->cur.y);
		TekDraw(tw, tekscr->cur.x, tekscr->cur.y);
	    }
	    break;

	case CASE_CR:
	    TRACE(("case: CR\n"));
	    if (tekscr->TekGIN)
		TekGINoff(tw);
	    if (nplot > 0)	/* flush line VTbuffer */
		TekFlush(tw);
	    tekscr->cur_X = tekscr->margin == MARGIN1 ? 0 :
		TEKWIDTH / 2;
	    Tparsestate = curstate = Talptable;
	    break;

	case CASE_ESC_STATE:
	    TRACE(("case: ESC\n"));
	    Tparsestate = Tesctable;
	    break;

	case CASE_LF:
	    TRACE(("case: LF\n"));
	    if (tekscr->TekGIN)
		TekGINoff(tw);
	    TCursorDown(tw);
	    if (!tekRefreshList)
		do_xevents();
	    break;

	case CASE_SP:
	    TRACE(("case: SP\n"));
	    TCursorForward(tw);
	    break;

	case CASE_PRINT:
	    TRACE(("case: printable character\n"));
	    ch = c;
	    x = (int) ScaledX(tw, tekscr->cur_X);
	    y = (int) ScaledY(tw, tekscr->cur_Y);

#if OPT_WIDE_CHARS
	    if (screen->wide_chars
		&& (ch > 255)) {
		XChar2b sbuf;
		sbuf.byte2 = LO_BYTE(ch);
		sbuf.byte1 = HI_BYTE(ch);
		XDrawImageString16(XtDisplay(tw),
				   TWindow(tekscr),
				   tekscr->TnormalGC,
				   x,
				   y,
				   &sbuf,
				   1);
	    } else
#endif
	    {
		char ch2 = (char) ch;
		XDrawString(XtDisplay(tw),
			    TWindow(tekscr),
			    tekscr->TnormalGC,
			    x,
			    y,
			    &ch2,
			    1);
	    }
	    TCursorForward(tw);
	    break;
	case CASE_OSC:
	    /* FIXME:  someone should disentangle the input queues
	     * of this code so that it can be state-driven.
	     */
	    TRACE(("case: do osc escape\n"));
	    {
		/*
		 * do_osc() can call TekExpose(), which calls TekRefresh(),
		 * and sends us recurring here - don't do that...
		 */
		static int nested;

		Char buf2[512];
		IChar c2;
		size_t len = 0;
		while ((c2 = input()) != ANSI_BEL) {
		    if (!isprint((int) (c2 & 0x7f))
			|| len + 2 >= (int) sizeof(buf2))
			break;
		    buf2[len++] = (Char) c2;
		}
		buf2[len] = 0;
		if (!nested++) {
		    if (c2 == ANSI_BEL)
			do_osc(tw->vt, buf2, len, ANSI_BEL);
		}
		--nested;
	    }
	    Tparsestate = curstate;
	    break;
	}
    }
}

static int rcnt;
static char *rptr;
static PtySelect Tselect_mask;

static IChar
Tinput(TekWidget tw)
{
    TekScreen *tekscr = TekScreenOf(tw);
    TScreen *screen = TScreenOf(tw->vt);
    TekLink *tek;

    if (Tpushback > Tpushb)
	return (*--Tpushback);
    if (tekRefreshList) {
	if (rcnt-- > 0)
	    return (IChar) (*rptr++);
	if ((tek = tekRefreshList->next) != 0) {
	    tekRefreshList = tek;
	    rptr = tek->data;
	    rcnt = tek->count - 1;
	    TekSetFontSize(tw, False, tek->fontsize);
	    return (IChar) (*rptr++);
	}
	tekRefreshList = (TekLink *) 0;
	longjmp(Tekjump, 1);
    }
  again:
    if (VTbuffer->next >= VTbuffer->last) {
	int update = VTbuffer->update;

	if (nplot > 0)		/* flush line */
	    TekFlush(tw);
#ifdef VMS
	Tselect_mask = pty_mask;	/* force a read */
#else /* VMS */
	XFD_COPYSET(&pty_mask, &Tselect_mask);
#endif /* VMS */
	for (;;) {
#ifdef CRAY
	    struct timeval crocktimeout;
	    crocktimeout.tv_sec = 0;
	    crocktimeout.tv_usec = 0;
	    (void) Select(max_plus1,
			  &Tselect_mask, NULL, NULL,
			  &crocktimeout);
#endif
	    if (readPtyData(tw->vt, &Tselect_mask, VTbuffer)) {
		break;
	    }
	    if (Ttoggled && curstate == Talptable) {
		TCursorToggle(tw, TOGGLE);
		Ttoggled = False;
	    }
	    if (xtermAppPending() & XtIMXEvent) {
#ifdef VMS
		Tselect_mask = X_mask;
#else /* VMS */
		XFD_COPYSET(&X_mask, &Tselect_mask);
#endif /* VMS */
	    } else {
		XFlush(XtDisplay(tw));
#ifdef VMS
		Tselect_mask = Select_mask;

#else /* VMS */
		XFD_COPYSET(&Select_mask, &Tselect_mask);
		if (Select(max_plus1, &Tselect_mask, NULL, NULL, NULL) < 0) {
		    if (errno != EINTR)
			SysError(ERROR_TSELECT);
		    continue;
		}
#endif /* VMS */
	    }
#ifdef VMS
	    if (Tselect_mask & X_mask) {
		xevents();
		if (VTbuffer->update != update)
		    goto again;
	    }
#else /* VMS */
	    if (FD_ISSET(ConnectionNumber(XtDisplay(tw)), &Tselect_mask)) {
		xevents();
		if (VTbuffer->update != update)
		    goto again;
	    }
#endif /* VMS */
	}
	if (!Ttoggled && curstate == Talptable) {
	    TCursorToggle(tw, TOGGLE);
	    Ttoggled = True;
	}
    }
    tek = TekRecord;
    if (tek->count >= TEK_LINK_BLOCK_SIZE
	|| tek->fontsize != tekscr->cur.fontsize) {
	if ((TekRecord = tek->next = CastMalloc(TekLink)) == 0) {
	    Panic("Tinput: malloc error (%d)\n", errno);
	} else {
	    tek = tek->next;
	    tek->next = (TekLink *) 0;
	    tek->fontsize = (unsigned short) tekscr->cur.fontsize;
	    tek->count = 0;
	    tek->ptr = tek->data;
	}
    }
    tek->count++;

    (void) morePtyData(screen, VTbuffer);
    return (IChar) (*tek->ptr++ = (char) nextPtyData(screen, VTbuffer));
}

static void
TekClear(TekWidget tw)
{
    TekScreen *tekscr = TekScreenOf(tw);

    TRACE(("TekClear\n"));
    nplot = 0;
    line_pt = Tline;
    if (TWindow(tekscr))
	XClearWindow(XtDisplay(tw), TWindow(tekscr));
}

void
TekSetWinSize(TekWidget tw)
{
    if (TEK4014_ACTIVE(tw->vt)) {
	TekScreen *tekscr = TekScreenOf(tw);
	const struct Tek_Char *t = &TekChar[tekscr->cur.fontsize];
	int rows = THeight(tekscr) / (int) (ScaleOf(tw) * t->vsize);
	int cols = TWidth(tekscr) / (int) (ScaleOf(tw) * t->hsize);

	update_winsize(TScreenOf(tw->vt)->respond,
		       rows, cols,
		       TFullHeight(tekscr),
		       TFullWidth(tekscr));
    }
}

static void
compute_sizes(TekWidget tw)
{
    TekScreen *tekscr = TekScreenOf(tw);
    int border = 2 * BorderOf(tw);
    double d;
#if OPT_TRACE
    const struct Tek_Char *t = &TekChar[tekscr->cur.fontsize];
    const XFontStruct *fs = tw->tek.Tfont[tekscr->cur.fontsize];
#endif

    /* *INDENT-EQLS* */
    TWidth(tekscr)  = tw->core.width - border;
    THeight(tekscr) = tw->core.height - border;
    ScaleOf(tw)     = (double) TWidth(tekscr) / TEKWIDTH;

    if ((d = (double) THeight(tekscr) / FULL_HEIGHT) < ScaleOf(tw))
	ScaleOf(tw) = d;

    TFullWidth(tekscr) = tw->core.width;
    TFullHeight(tekscr) = tw->core.height;

    TRACE(("%s size %dx%d full %dx%d scale %.2f\n", MY_NAME,
	   THeight(tekscr), TWidth(tekscr),
	   TFullHeight(tekscr), TFullWidth(tekscr),
	   ScaleOf(tw)));

    /* The tek4014 fonts always look odd since their spacing is overridden to
     * get the "same" size as a real Tektronix terminal.  TrueType fonts for
     * these small sizes would be no better...
     */
    TRACE(("unscaled font %dx%d\n", t->vsize, t->hsize));
    TRACE(("scaled   font %.1fx%.1f\n", d * t->vsize, d * t->hsize));
    TRACE(("actual   font %dx%d\n",
	   fs->max_bounds.ascent + fs->max_bounds.descent,
	   fs->max_bounds.width));

    TekSetWinSize(tw);
}

static void
TekResize(Widget w)
{
    TekWidget tw = getTekWidget(w);
    if (tw != 0) {

	TRACE(("TekResize {{\n"));
	TekClear(tw);

	compute_sizes(tw);

	TRACE(("}} TekResize\n"));
    }
}

/*ARGSUSED*/
void
TekExpose(Widget w,
	  XEvent *event GCC_UNUSED,
	  Region region GCC_UNUSED)
{
    TekWidget tw = getTekWidget(w);
    if (tw != 0) {
	TekScreen *tekscr = TekScreenOf(tw);

	TRACE(("TekExpose {{\n"));

#ifdef lint
	region = region;
#endif
	if (!Ttoggled)
	    TCursorToggle(tw, CLEAR);
	Ttoggled = True;
	Tpushback = Tpushb;
	tekscr->cur_X = 0;
	tekscr->cur_Y = TEKHOME;
	tekscr->cur = tekscr->page;
	TekSetFontSize(tw, False, tekscr->cur.fontsize);
	tekscr->margin = MARGIN1;
	if (tekscr->TekGIN) {
	    tekscr->TekGIN = NULL;
	    TekGINoff(tw);
	}
	tekRefreshList = &Tek0;
	rptr = tekRefreshList->data;
	rcnt = tekRefreshList->count;
	Tparsestate = curstate = Talptable;
	TRACE(("TekExpose resets data to replay %d bytes\n", rcnt));
	first_map_occurred();
	if (!tekscr->waitrefresh)
	    TekRefresh(tw);
	TRACE(("}} TekExpose\n"));
    }
}

void
TekRefresh(TekWidget tw)
{
    if (tw != 0) {
	TScreen *screen = TScreenOf(tw->vt);
	TekScreen *tekscr = TekScreenOf(tw);
	static Cursor wait_cursor = None;

	if (wait_cursor == None)
	    wait_cursor = make_colored_cursor(XC_watch,
					      T_COLOR(screen, MOUSE_FG),
					      T_COLOR(screen, MOUSE_BG));
	XDefineCursor(XtDisplay(tw), TWindow(tekscr), wait_cursor);
	XFlush(XtDisplay(tw));
	if (!setjmp(Tekjump))
	    Tekparse(tw);
	XDefineCursor(XtDisplay(tw), TWindow(tekscr),
		      (tekscr->TekGIN && GINcursor) ? GINcursor : tekscr->arrow);
    }
}

void
TekRepaint(TekWidget tw)
{
    TRACE(("TekRepaint\n"));
    TekClear(tw);
    TekExpose((Widget) tw, (XEvent *) NULL, (Region) NULL);
}

static void
TekPage(TekWidget tw)
{
    TekScreen *tekscr = TekScreenOf(tw);
    TekLink *tek;

    TRACE(("TekPage\n"));
    TekClear(tw);
    tekscr->cur_X = 0;
    tekscr->cur_Y = TEKHOME;
    tekscr->margin = MARGIN1;
    tekscr->page = tekscr->cur;
    if (tekscr->TekGIN)
	TekGINoff(tw);
    tek = TekRecord = &Tek0;
    tek->fontsize = (unsigned short) tekscr->cur.fontsize;
    tek->count = 0;
    tek->ptr = tek->data;
    tek = tek->next;
    if (tek)
	do {
	    TekLink *tek2 = tek->next;

	    free(tek);
	    tek = tek2;
	} while (tek);
    TekRecord->next = (TekLink *) 0;
    tekRefreshList = (TekLink *) 0;
    Ttoggled = True;
    Tparsestate = curstate = Talptable;		/* Tek Alpha mode */
}

#define	EXTRABITS	017
#define	FIVEBITS	037
#define	HIBITS		(FIVEBITS << SHIFTHI)
#define	LOBITS		(FIVEBITS << SHIFTLO)
#define	SHIFTHI		7
#define	SHIFTLO		2
#define	TWOBITS		03

static int
getpoint(TekWidget tw)
{
    int x, y, e, lo_y = 0;
    TekScreen *tekscr = TekScreenOf(tw);

    x = tekscr->cur.x;
    y = tekscr->cur.y;

    for (;;) {
	int c;

	if ((c = (int) input()) < ' ') {	/* control character */
	    unput(c);
	    return (0);
	}
	if (c < '@') {		/* Hi X or Hi Y */
	    if (lo_y) {		/* seen a Lo Y, so this must be Hi X */
		x &= ~HIBITS;
		x |= (c & FIVEBITS) << SHIFTHI;
		continue;
	    }
	    /* else Hi Y */
	    y &= ~HIBITS;
	    y |= (c & FIVEBITS) << SHIFTHI;
	    continue;
	}
	if (c < '`') {		/* Lo X */
	    x &= ~LOBITS;
	    x |= (c & FIVEBITS) << SHIFTLO;
	    tekscr->cur.x = x;
	    tekscr->cur.y = y;
	    return (1);		/* OK */
	}
	/* else Lo Y */
	if (lo_y) {		/* seen a Lo Y, so other must be extra bits */
	    e = (y >> SHIFTLO) & EXTRABITS;
	    x &= ~TWOBITS;
	    x |= e & TWOBITS;
	    y &= ~TWOBITS;
	    y |= (e >> SHIFTLO) & TWOBITS;
	}
	y &= ~LOBITS;
	y |= (c & FIVEBITS) << SHIFTLO;
	lo_y++;
    }
}

static void
TCursorBack(TekWidget tw)
{
    TekScreen *tekscr = TekScreenOf(tw);
    const struct Tek_Char *t;
    int x = (tekscr->cur_X -= (t = &TekChar[tekscr->cur.fontsize])->hsize);

    if (((tekscr->margin == MARGIN1) && (x < 0))
	|| ((tekscr->margin == MARGIN2) && (x < TEKWIDTH / 2))) {
	int l = ((tekscr->cur_Y + (t->vsize - 1)) / t->vsize + 1);
	if (l >= t->nlines) {
	    tekscr->margin = !tekscr->margin;
	    l = 0;
	}
	tekscr->cur_Y = l * t->vsize;
	tekscr->cur_X = (t->charsperline - 1) * t->hsize;
    }
}

static void
TCursorForward(TekWidget tw)
{
    TekScreen *tekscr = TekScreenOf(tw);
    const struct Tek_Char *t = &TekChar[tekscr->cur.fontsize];

    if ((tekscr->cur_X += t->hsize) > TEKWIDTH) {
	int l = (tekscr->cur_Y / t->vsize - 1);
	if (l < 0) {
	    tekscr->margin = !tekscr->margin;
	    l = t->nlines - 1;
	}
	tekscr->cur_Y = l * t->vsize;
	tekscr->cur_X = tekscr->margin == MARGIN1 ? 0 : TEKWIDTH / 2;
    }
}

static void
TCursorUp(TekWidget tw)
{
    TekScreen *tekscr = TekScreenOf(tw);
    const struct Tek_Char *t;
    int l;

    t = &TekChar[tekscr->cur.fontsize];

    if ((l = (tekscr->cur_Y + (t->vsize - 1)) / t->vsize + 1) >= t->nlines) {
	l = 0;
	if ((tekscr->margin = !tekscr->margin) != MARGIN1) {
	    if (tekscr->cur_X < TEKWIDTH / 2)
		tekscr->cur_X += TEKWIDTH / 2;
	} else if (tekscr->cur_X >= TEKWIDTH / 2)
	    tekscr->cur_X -= TEKWIDTH / 2;
    }
    tekscr->cur_Y = l * t->vsize;
}

static void
TCursorDown(TekWidget tw)
{
    TekScreen *tekscr = TekScreenOf(tw);
    const struct Tek_Char *t;
    int l;

    t = &TekChar[tekscr->cur.fontsize];

    if ((l = tekscr->cur_Y / t->vsize - 1) < 0) {
	l = t->nlines - 1;
	if ((tekscr->margin = !tekscr->margin) != MARGIN1) {
	    if (tekscr->cur_X < TEKWIDTH / 2)
		tekscr->cur_X += TEKWIDTH / 2;
	} else if (tekscr->cur_X >= TEKWIDTH / 2)
	    tekscr->cur_X -= TEKWIDTH / 2;
    }
    tekscr->cur_Y = l * t->vsize;
}

static void
AddToDraw(TekWidget tw, int x1, int y1, int x2, int y2)
{
    XSegment *lp;

    TRACE(("AddToDraw (%d,%d) (%d,%d)\n", x1, y1, x2, y2));
    if (nplot >= MAX_PTS) {
	TekFlush(tw);
    }
    lp = line_pt++;
    lp->x1 = (short) ScaledX(tw, x1);
    lp->y1 = (short) ScaledY(tw, y1);
    lp->x2 = (short) ScaledX(tw, x2);
    lp->y2 = (short) ScaledY(tw, y2);
    nplot++;
    TRACE(("...AddToDraw %d points\n", nplot));
}

static void
TekDraw(TekWidget tw, int x, int y)
{
    TekScreen *tekscr = TekScreenOf(tw);

    if (nplot == 0 || T_lastx != tekscr->cur_X || T_lasty != tekscr->cur_Y) {
	/*
	 * We flush on each unconnected line segment if the line
	 * type is not solid.  This solves a bug in X when drawing
	 * points while the line type is not solid.
	 */
	if (nplot > 0 && tekscr->cur.linetype != SOLIDLINE)
	    TekFlush(tw);
    }
    AddToDraw(tw, tekscr->cur_X, tekscr->cur_Y, x, y);
    T_lastx = tekscr->cur_X = x;
    T_lasty = tekscr->cur_Y = y;
}

static void
TekFlush(TekWidget tw)
{
    TekScreen *tekscr = TekScreenOf(tw);

    TRACE(("TekFlush\n"));
    XDrawSegments(XtDisplay(tw), TWindow(tekscr),
		  ((tekscr->cur.linetype == SOLIDLINE)
		   ? tekscr->TnormalGC
		   : tekscr->linepat[tekscr->cur.linetype - 1]),
		  Tline, nplot);
    nplot = 0;
    line_pt = Tline;
}

void
TekGINoff(TekWidget tw)
{
    TekScreen *tekscr = TekScreenOf(tw);

    TRACE(("TekGINoff\n"));
    XDefineCursor(XtDisplay(tw), TWindow(tekscr), tekscr->arrow);
    if (GINcursor)
	XFreeCursor(XtDisplay(tw), GINcursor);
    if (tekscr->TekGIN) {
	*tekscr->TekGIN = ANSI_CAN;	/* modify recording */
	tekscr->TekGIN = NULL;
    }
}

void
TekEnqMouse(TekWidget tw, int c)	/* character pressed */
{
    TekScreen *tekscr = TekScreenOf(tw);
    int mousex, mousey, rootx, rooty;
    unsigned int mask;		/* XQueryPointer */
    Window root, subw;

    TRACE(("TekEnqMouse\n"));
    XQueryPointer(
		     XtDisplay(tw), TWindow(tekscr),
		     &root, &subw,
		     &rootx, &rooty,
		     &mousex, &mousey,
		     &mask);
    if ((mousex = (int) ((mousex - BorderOf(tw)) / ScaleOf(tw))) < 0)
	mousex = 0;
    else if (mousex >= TEKWIDTH)
	mousex = TEKWIDTH - 1;
    if ((mousey = (int) BottomY((mousey - BorderOf(tw)) / ScaleOf(tw))) < 0)
	mousey = 0;
    else if (mousey >= TEKHEIGHT)
	mousey = TEKHEIGHT - 1;
    TekEnq(tw, (unsigned) c, mousex, mousey);
}

static void
TekEnq(TekWidget tw,
       unsigned status,
       int x,
       int y)
{
    TScreen *screen = TScreenOf(tw->vt);
    TekScreen *tekscr = TekScreenOf(tw);
    Char cplot[7];
    int len = 5;
    int adj = (status != 0) ? 0 : 1;

    TRACE(("TekEnq\n"));
    cplot[0] = (Char) status;
    /* Translate x and y to Tektronix code */
    cplot[1] = (Char) (040 | ((x >> SHIFTHI) & FIVEBITS));
    cplot[2] = (Char) (040 | ((x >> SHIFTLO) & FIVEBITS));
    cplot[3] = (Char) (040 | ((y >> SHIFTHI) & FIVEBITS));
    cplot[4] = (Char) (040 | ((y >> SHIFTLO) & FIVEBITS));

    if (tekscr->gin_terminator != GIN_TERM_NONE)
	cplot[len++] = '\r';
    if (tekscr->gin_terminator == GIN_TERM_EOT)
	cplot[len++] = '\004';
#ifdef VMS
    tt_write(cplot + adj, len - adj);
#else /* VMS */
    v_write(screen->respond, cplot + adj, (unsigned) (len - adj));
#endif /* VMS */
}

void
TekRun(void)
{
    XtermWidget xw = term;

    assert(xw != 0);
    if (tekWidget == 0) {
	TekInit();
    }
    if (tekWidget != 0) {
	TRACE(("TekRun ...\n"));

	if (!TEK4014_SHOWN(xw)) {
	    set_tek_visibility(True);
	}
	update_vttekmode();
	update_vtshow();
	update_tekshow();
	set_tekhide_sensitivity();

	Tpushback = Tpushb;
	Ttoggled = True;
	if (!setjmp(Tekend))
	    Tekparse(tekWidget);
	if (!Ttoggled) {
	    TCursorToggle(tekWidget, TOGGLE);
	    Ttoggled = True;
	}
	TEK4014_ACTIVE(xw) = False;
    } else {
	TEK4014_ACTIVE(xw) = False;
	if (VWindow(TScreenOf(xw)) == 0) {
	    Exit(ERROR_TINIT);
	}
    }
}

#define DOTTED_LENGTH 2
#define DOT_DASHED_LENGTH 4
#define SHORT_DASHED_LENGTH 2
#define LONG_DASHED_LENGTH 2

static const int dash_length[TEKNUMLINES] =
{
    DOTTED_LENGTH,
    DOT_DASHED_LENGTH,
    SHORT_DASHED_LENGTH,
    LONG_DASHED_LENGTH,
};

static _Xconst char dotted[DOTTED_LENGTH] =
{3, 1};
static _Xconst char dot_dashed[DOT_DASHED_LENGTH] =
{3, 4, 3, 1};
static _Xconst char short_dashed[SHORT_DASHED_LENGTH] =
{4, 4};
static _Xconst char long_dashed[LONG_DASHED_LENGTH] =
{4, 7};

static _Xconst char *dashes[TEKNUMLINES] =
{
    dotted,
    dot_dashed,
    short_dashed,
    long_dashed,
};

/*
 * The following functions are called to initialize and realize the tekWidget
 */
static void
TekInitialize(Widget wrequest,
	      Widget new_arg,
	      ArgList args GCC_UNUSED,
	      Cardinal *num_args GCC_UNUSED)
{
    XtermWidget xw = term;
    TScreen *vtscr = TScreenOf(xw);

    TekWidget request = (TekWidget) wrequest;
    TekWidget wnew = (TekWidget) new_arg;

    Widget tekparent = SHELL_OF(wnew);
    TekScreen *tekscr = TekScreenOf((TekWidget) wnew);

    int i;
    int border;
    int pr;
    int winX, winY;
    unsigned min_width, min_height;
    unsigned width, height;
    char Tdefault[32];

    (void) args;
    (void) num_args;

    TRACE(("TekInitialize {{\n"));
    memset(tekscr, 0, sizeof(*tekscr));

    /*
     * Eliminate 'term' as global from other functions.
     */
    wnew->vt = xw;
    border = 2 * BorderOf(wnew);
    TRACE(("... border*2: %d\n", border));

    /* look for focus related events on the shell, because we need
     * to care about the shell's border being part of our focus.
     */
    XtAddEventHandler(tekparent, EnterWindowMask, False,
		      HandleEnterWindow, (Opaque) 0);
    XtAddEventHandler(tekparent, LeaveWindowMask, False,
		      HandleLeaveWindow, (Opaque) 0);
    XtAddEventHandler(tekparent, FocusChangeMask, False,
		      HandleFocusChange, (Opaque) 0);
    XtAddEventHandler(new_arg, PropertyChangeMask, False,
		      HandleBellPropertyChange, (Opaque) 0);

#ifndef NO_ACTIVE_ICON
    tekscr->whichTwin = &(tekscr->fullTwin);
#endif /* NO_ACTIVE_ICON */

    init_Sres(tek.initial_font);
    init_Sres(tek.gin_terminator_str);
#if OPT_TOOLBAR
    init_Ires(tek.tb_info.menu_height);
    wnew->tek.tb_info.menu_bar = request->tek.tb_info.menu_bar;
#endif

    BorderPixel(wnew) = BorderPixel(xw);

    tekscr->arrow = make_colored_cursor(XC_left_ptr,
					T_COLOR(vtscr, MOUSE_FG),
					T_COLOR(vtscr, MOUSE_BG));

    for (i = 0; i < TEKNUMFONTS; i++) {
	if (!wnew->tek.Tfont[i]) {
	    wnew->tek.Tfont[i] = XQueryFont(XtDisplay(wnew), DefaultGCID(wnew));
	}
	if (wnew->tek.Tfont[i]) {
	    TRACE(("Tfont[%d] %dx%d\n",
		   i,
		   wnew->tek.Tfont[i]->max_bounds.width,
		   wnew->tek.Tfont[i]->ascent +
		   wnew->tek.Tfont[i]->descent));
	    wnew->tek.tobaseline[i] = wnew->tek.Tfont[i]->ascent;
	} else {
	    TRACE(("Tfont[%d] disabled\n", i));
	    SetItemSensitivity(tekMenuEntries[i].widget, False);
	}
    }

    if (xw->misc.T_geometry == NULL) {
	int def_width, def_height;

	if (xw->misc.tekSmall) {
	    def_width = TEKMINWIDTH;
	    def_height = TEKMINHEIGHT;
	} else {
	    def_width = TEKDEFWIDTH;
	    def_height = TEKDEFHEIGHT;
	}
	sprintf(Tdefault, "=%dx%d", def_width + border, def_height + border);
	xw->misc.T_geometry = Tdefault;
    }

    winX = 1;
    winY = 1;
    width = (unsigned) (TEKDEFWIDTH + border);
    height = (unsigned) (TEKDEFHEIGHT + border);
    min_width = (unsigned) (TEKMINWIDTH + border);
    min_height = (unsigned) (TEKMINHEIGHT + border);

    TRACE(("parsing T_geometry %s\n", NonNull(xw->misc.T_geometry)));
    pr = XParseGeometry(xw->misc.T_geometry,
			&winX,
			&winY,
			&width,
			&height);

    /* window-manager hints will do this anyway... */
    if (height < min_height) {
	TRACE(("... override height from %d to %d\n", height, min_height));
	height = min_height;
    }
    if (width < min_width) {
	TRACE(("... override width from %d to %d\n", width, min_width));
	width = min_width;
    }

    TRACE(("... position %d,%d size %dx%d\n", winY, winX, height, width));
    if ((pr & XValue) && (pr & XNegative)) {
	winX += DisplayWidth(XtDisplay(wnew), DefaultScreen(XtDisplay(wnew)))
	    - (int) width - (BorderWidth(SHELL_OF(xw)) * 2);
    }
    if ((pr & YValue) && (pr & YNegative)) {
	winY += DisplayHeight(XtDisplay(wnew), DefaultScreen(XtDisplay(wnew)))
	    - (int) height - (BorderWidth(SHELL_OF(xw)) * 2);
    }

    /* set up size hints */

    /* *INDENT-EQLS* */
    wnew->hints.min_width  = (int) min_width;
    wnew->hints.min_height = (int) min_height;
    wnew->hints.width_inc  = 1;
    wnew->hints.height_inc = 1;
    wnew->hints.flags      = PMinSize | PResizeInc;
    wnew->hints.x          = winX;
    wnew->hints.y          = winY;

    if ((XValue & pr) || (YValue & pr)) {
	wnew->hints.flags |= USSize | USPosition;
	wnew->hints.flags |= PWinGravity;
	switch (pr & (XNegative | YNegative)) {
	case 0:
	    wnew->hints.win_gravity = NorthWestGravity;
	    break;
	case XNegative:
	    wnew->hints.win_gravity = NorthEastGravity;
	    break;
	case YNegative:
	    wnew->hints.win_gravity = SouthWestGravity;
	    break;
	default:
	    wnew->hints.win_gravity = SouthEastGravity;
	    break;
	}
    } else {
	/* set a default size, but do *not* set position */
	wnew->hints.flags |= PSize;
    }
    wnew->hints.width = (int) width;
    wnew->hints.height = (int) height;
    if ((WidthValue & pr) || (HeightValue & pr))
	wnew->hints.flags |= USSize;
    else
	wnew->hints.flags |= PSize;

    tekscr->cur.fontsize = TEK_FONT_LARGE;
    if (wnew->tek.initial_font) {
	int result = TekGetFontSize(wnew->tek.initial_font);
	if (result >= 0)
	    tekscr->cur.fontsize = result;
    }
    TRACE(("Tek cur.fontsize=%d\n", tekscr->cur.fontsize));

#define TestGIN(s) XmuCompareISOLatin1(wnew->tek.gin_terminator_str, s)

    if (TestGIN(GIN_TERM_NONE_STR) == 0)
	tekscr->gin_terminator = GIN_TERM_NONE;
    else if (TestGIN(GIN_TERM_CR_STR) == 0)
	tekscr->gin_terminator = GIN_TERM_CR;
    else if (TestGIN(GIN_TERM_EOT_STR) == 0)
	tekscr->gin_terminator = GIN_TERM_EOT;
    else
	xtermWarning("illegal GIN terminator setting \"%s\"\n",
		     wnew->tek.gin_terminator_str);
    TRACE(("Tek gin_terminator=%d\n", tekscr->gin_terminator));

    TRACE(("}} TekInitialize\n"));
}

static void
TekRealize(Widget gw,
	   XtValueMask * valuemaskp,
	   XSetWindowAttributes * values)
{
    TekWidget tw = (TekWidget) gw;
    TekScreen *tekscr = TekScreenOf(tw);
    TScreen *vtscr = TScreenOf(tw->vt);

    int i;
    TekLink *tek;
    XGCValues gcv;
    unsigned width, height;
    unsigned long TEKgcFontMask;

    TRACE(("TekRealize {{\n"));

    if (!TekPtyData())
	return;

    /* use values from TekInitialize... */
    height = (unsigned) tw->hints.height;
    width = (unsigned) tw->hints.width;

    (void) REQ_RESIZE((Widget) tw,
		      (Dimension) width, (Dimension) height,
		      &tw->core.width, &tw->core.height);

    /* XXX This is bogus.  We are parsing geometries too late.  This
     * is information that the shell widget ought to have before we get
     * realized, so that it can do the right thing.
     */
    if (tw->hints.flags & USPosition)
	XMoveWindow(XtDisplay(tw), TShellWindow, tw->hints.x, tw->hints.y);

    XSetWMNormalHints(XtDisplay(tw), TShellWindow, &tw->hints);
    XFlush(XtDisplay(tw));	/* get it out to window manager */

    values->win_gravity = NorthWestGravity;
    values->background_pixel = T_COLOR(vtscr, TEK_BG);

    XtWindow(tw) = TWindow(tekscr) =
	XCreateWindow(XtDisplay(tw),
		      VShellWindow(tw),
		      tw->core.x, tw->core.y,
		      tw->core.width, tw->core.height,
		      BorderWidth(tw),
		      (int) tw->core.depth,
		      InputOutput, CopyFromParent,
		      ((*valuemaskp) | CWBackPixel | CWWinGravity),
		      values);

    compute_sizes(tw);

    gcv.graphics_exposures = True;	/* default */
    gcv.font = tw->tek.Tfont[tekscr->cur.fontsize]->fid;
    gcv.foreground = T_COLOR(vtscr, TEK_FG);
    gcv.background = T_COLOR(vtscr, TEK_BG);

    /* if font wasn't successfully opened, then gcv.font will contain
       the Default GC's ID, meaning that we must use the server default font.
     */
    TEKgcFontMask = (unsigned long) ((gcv.font == DefaultGCID(tw))
				     ? 0
				     : GCFont);
    tekscr->TnormalGC = XCreateGC(XtDisplay(tw), TWindow(tekscr),
				  (TEKgcFontMask | GCGraphicsExposures |
				   GCForeground | GCBackground),
				  &gcv);

    gcv.function = GXinvert;
    gcv.plane_mask = (T_COLOR(vtscr, TEK_BG) ^
		      T_COLOR(vtscr, TEK_CURSOR));
    gcv.join_style = JoinMiter;	/* default */
    gcv.line_width = 1;
    tekscr->TcursorGC = XCreateGC(XtDisplay(tw), TWindow(tekscr),
				  (GCFunction | GCPlaneMask), &gcv);

    gcv.foreground = T_COLOR(vtscr, TEK_FG);
    gcv.line_style = LineOnOffDash;
    gcv.line_width = 0;
    for (i = 0; i < TEKNUMLINES; i++) {
	tekscr->linepat[i] = XCreateGC(XtDisplay(tw), TWindow(tekscr),
				       (GCForeground | GCLineStyle), &gcv);
	XSetDashes(XtDisplay(tw), tekscr->linepat[i], 0,
		   dashes[i], dash_length[i]);
    }

    TekBackground(tw, vtscr);

    tekscr->margin = MARGIN1;	/* Margin 1             */
    tekscr->TekGIN = False;	/* GIN off              */

    XDefineCursor(XtDisplay(tw), TWindow(tekscr), tekscr->arrow);

    {				/* there's gotta be a better way... */
	static Arg args[] =
	{
	    {XtNtitle, (XtArgVal) NULL},
	    {XtNiconName, (XtArgVal) NULL},
	};
	char *icon_name, *title, *tek_icon_name, *tek_title;

	args[0].value = (XtArgVal) & icon_name;
	args[1].value = (XtArgVal) & title;
	XtGetValues(SHELL_OF(tw), args, 2);
	TRACE(("TekShell title='%s', iconName='%s'\n", title, icon_name));
	tek_icon_name = XtMalloc((Cardinal) strlen(icon_name) + 7);
	strcpy(tek_icon_name, icon_name);
	strcat(tek_icon_name, "(Tek)");
	tek_title = XtMalloc((Cardinal) strlen(title) + 7);
	strcpy(tek_title, title);
	strcat(tek_title, "(Tek)");
	args[0].value = (XtArgVal) tek_icon_name;
	args[1].value = (XtArgVal) tek_title;
	TRACE(("Tek title='%s', iconName='%s'\n", tek_title, tek_icon_name));
	XtSetValues(SHELL_OF(tw), args, 2);
	XtFree(tek_icon_name);
	XtFree(tek_title);
    }

    /* *INDENT-EQLS* */
    tek           = TekRecord = &Tek0;
    tek->next     = (TekLink *) 0;
    tek->fontsize = (unsigned short) tekscr->cur.fontsize;
    tek->count    = 0;
    tek->ptr      = tek->data;
    Tpushback     = Tpushb;
    tekscr->cur_X = 0;
    tekscr->cur_Y = TEKHOME;
    line_pt       = Tline;
    Ttoggled      = True;
    tekscr->page  = tekscr->cur;

    TRACE(("}} TekRealize\n"));
}

int
TekGetFontSize(const char *param)
{
    int result;

    if (XmuCompareISOLatin1(param, "l") == 0 ||
	XmuCompareISOLatin1(param, "large") == 0)
	result = TEK_FONT_LARGE;
    else if (XmuCompareISOLatin1(param, "2") == 0 ||
	     XmuCompareISOLatin1(param, "two") == 0)
	result = TEK_FONT_2;
    else if (XmuCompareISOLatin1(param, "3") == 0 ||
	     XmuCompareISOLatin1(param, "three") == 0)
	result = TEK_FONT_3;
    else if (XmuCompareISOLatin1(param, "s") == 0 ||
	     XmuCompareISOLatin1(param, "small") == 0)
	result = TEK_FONT_SMALL;
    else
	result = -1;

    return result;
}

void
TekSetFontSize(TekWidget tw, Bool fromMenu, int newitem)
{
    if (tw != 0) {
	TekScreen *tekscr = TekScreenOf(tw);
	int oldsize = tekscr->cur.fontsize;
	int newsize = MI2FS(newitem);
	Font fid;

	TRACE(("TekSetFontSize(%d) size %d ->%d\n", newitem, oldsize, newsize));
	if (newsize < 0 || newsize >= TEKNUMFONTS) {
	    Bell(tw->vt, XkbBI_MinorError, 0);
	} else if (oldsize != newsize) {
	    if (!Ttoggled)
		TCursorToggle(tw, TOGGLE);
	    set_tekfont_menu_item(oldsize, False);

	    tekscr->cur.fontsize = newsize;
	    TekSetWinSize(tw);
	    if (fromMenu)
		tekscr->page.fontsize = newsize;

	    fid = tw->tek.Tfont[newsize]->fid;
	    if (fid == DefaultGCID(tw)) {
		/* we didn't succeed in opening a real font
		   for this size.  Instead, use server default. */
		XCopyGC(XtDisplay(tw),
			DefaultGC(XtDisplay(tw), DefaultScreen(XtDisplay(tw))),
			GCFont, tekscr->TnormalGC);
	    } else {
		XSetFont(XtDisplay(tw), tekscr->TnormalGC, fid);
	    }

	    set_tekfont_menu_item(newsize, True);
	    if (!Ttoggled)
		TCursorToggle(tw, TOGGLE);

	    if (fromMenu) {
		/* we'll get an exposure event after changing fontsize, so we
		 * have to clear the screen to avoid painting over the previous
		 * text.
		 */
		TekClear(tw);
	    }
	}
    }
}

void
ChangeTekColors(TekWidget tw, TScreen *screen, ScrnColors * pNew)
{
    TekScreen *tekscr = TekScreenOf(tw);
    XGCValues gcv;

    if (COLOR_DEFINED(pNew, TEK_FG)) {
	T_COLOR(screen, TEK_FG) = COLOR_VALUE(pNew, TEK_FG);
	TRACE(("... TEK_FG: %#lx\n", T_COLOR(screen, TEK_FG)));
    }
    if (COLOR_DEFINED(pNew, TEK_BG)) {
	T_COLOR(screen, TEK_BG) = COLOR_VALUE(pNew, TEK_BG);
	TRACE(("... TEK_BG: %#lx\n", T_COLOR(screen, TEK_BG)));
    }
    if (COLOR_DEFINED(pNew, TEK_CURSOR)) {
	T_COLOR(screen, TEK_CURSOR) = COLOR_VALUE(pNew, TEK_CURSOR);
	TRACE(("... TEK_CURSOR: %#lx\n", T_COLOR(screen, TEK_CURSOR)));
    } else {
	T_COLOR(screen, TEK_CURSOR) = T_COLOR(screen, TEK_FG);
	TRACE(("... TEK_CURSOR: %#lx\n", T_COLOR(screen, TEK_CURSOR)));
    }

    if (tw) {
	int i;

	XSetForeground(XtDisplay(tw), tekscr->TnormalGC,
		       T_COLOR(screen, TEK_FG));
	XSetBackground(XtDisplay(tw), tekscr->TnormalGC,
		       T_COLOR(screen, TEK_BG));
	if (BorderPixel(tw) == T_COLOR(screen, TEK_BG)) {
	    BorderPixel(tw) = T_COLOR(screen, TEK_FG);
	    BorderPixel(XtParent(tw)) = T_COLOR(screen, TEK_FG);
	    if (XtWindow(XtParent(tw)))
		XSetWindowBorder(XtDisplay(tw),
				 XtWindow(XtParent(tw)),
				 BorderPixel(tw));
	}

	for (i = 0; i < TEKNUMLINES; i++) {
	    XSetForeground(XtDisplay(tw), tekscr->linepat[i],
			   T_COLOR(screen, TEK_FG));
	}

	gcv.plane_mask = (T_COLOR(screen, TEK_BG) ^
			  T_COLOR(screen, TEK_CURSOR));
	XChangeGC(XtDisplay(tw), tekscr->TcursorGC, GCPlaneMask, &gcv);
	TekBackground(tw, screen);
    }
    return;
}

void
TekReverseVideo(XtermWidget xw, TekWidget tw)
{
    TScreen *screen = TScreenOf(xw);
    TekScreen *tekscr = TekScreenOf(tw);
    Pixel tmp;
    XGCValues gcv;

    EXCHANGE(T_COLOR(screen, TEK_FG), T_COLOR(screen, TEK_BG), tmp);

    T_COLOR(screen, TEK_CURSOR) = T_COLOR(screen, TEK_FG);

    if (tw) {
	int i;

	XSetForeground(XtDisplay(tw), tekscr->TnormalGC, T_COLOR(screen, TEK_FG));
	XSetBackground(XtDisplay(tw), tekscr->TnormalGC, T_COLOR(screen, TEK_BG));

	if (BorderPixel(tw) == T_COLOR(screen, TEK_BG)) {
	    BorderPixel(tw) = T_COLOR(screen, TEK_FG);
	    BorderPixel(XtParent(tw)) = T_COLOR(screen, TEK_FG);
	    if (XtWindow(XtParent(tw)))
		XSetWindowBorder(XtDisplay(tw),
				 XtWindow(XtParent(tw)),
				 BorderPixel(tw));
	}

	for (i = 0; i < TEKNUMLINES; i++) {
	    XSetForeground(XtDisplay(tw), tekscr->linepat[i],
			   T_COLOR(screen, TEK_FG));
	}

	gcv.plane_mask = (T_COLOR(screen, TEK_BG) ^
			  T_COLOR(screen, TEK_CURSOR));
	XChangeGC(XtDisplay(tw), tekscr->TcursorGC, GCPlaneMask, &gcv);
	TekBackground(tw, screen);
    }
}

static void
TekBackground(TekWidget tw, TScreen *screen)
{
    TekScreen *tekscr = TekScreenOf(tw);

    if (TWindow(tekscr))
	XSetWindowBackground(XtDisplay(tw), TWindow(tekscr),
			     T_COLOR(screen, TEK_BG));
}

/*
 * Toggles cursor on or off at cursor position in screen.
 */
void
TCursorToggle(TekWidget tw, int toggle)		/* TOGGLE or CLEAR */
{
    TekScreen *tekscr = TekScreenOf(tw);
    TScreen *screen = TScreenOf(tw->vt);
    int c, x, y;
    unsigned int cellwidth, cellheight;

    if (!TEK4014_SHOWN(tw->vt))
	return;

    TRACE(("TCursorToggle %s\n", (toggle == TOGGLE) ? "toggle" : "clear"));
    c = tekscr->cur.fontsize;
    cellwidth = (unsigned) tw->tek.Tfont[c]->max_bounds.width;
    cellheight = (unsigned) (tw->tek.Tfont[c]->ascent +
			     tw->tek.Tfont[c]->descent);

    x = (int) ScaledX(tw, tekscr->cur_X);
    y = (int) ScaledY(tw, tekscr->cur_Y) - tw->tek.tobaseline[c];

    if (toggle == TOGGLE) {
	if (screen->select || screen->always_highlight)
	    XFillRectangle(XtDisplay(tw), TWindow(tekscr),
			   tekscr->TcursorGC, x, y,
			   cellwidth, cellheight);
	else {			/* fix to use different GC! */
	    XDrawRectangle(XtDisplay(tw), TWindow(tekscr),
			   tekscr->TcursorGC, x, y,
			   cellwidth - 1, cellheight - 1);
	}
    } else {
	/* Clear the entire rectangle, even though we may only
	 * have drawn an outline.  This fits with our refresh
	 * scheme of redrawing the entire window on any expose
	 * event and is easier than trying to figure out exactly
	 * which part of the cursor needs to be erased.
	 */
	XClearArea(XtDisplay(tw), TWindow(tekscr), x, y,
		   cellwidth, cellheight, False);
    }
}

void
TekSimulatePageButton(TekWidget tw, Bool reset)
{
    if (tw != 0) {
	TekScreen *tekscr = TekScreenOf(tw);

	if (reset) {
	    memset(&tekscr->cur, 0, sizeof tekscr->cur);
	}
	tekRefreshList = (TekLink *) 0;
	TekPage(tw);
	tekscr->cur_X = 0;
	tekscr->cur_Y = TEKHOME;
    }
}

/* write copy of screen to a file */

void
TekCopy(TekWidget tw)
{
    if (tw != 0) {
	TekScreen *tekscr = TekScreenOf(tw);
	TScreen *screen = TScreenOf(tw->vt);

	TekLink *Tp;
	char buf[TIMESTAMP_LEN + 10];
	int tekcopyfd;

	timestamp_filename(buf, "COPY");
	if (access(buf, F_OK) >= 0
	    && access(buf, W_OK) < 0) {
	    Bell(tw->vt, XkbBI_MinorError, 0);
	    return;
	}
#ifndef VMS
	if (access(".", W_OK) < 0) {	/* can't write in directory */
	    Bell(tw->vt, XkbBI_MinorError, 0);
	    return;
	}
#endif

	tekcopyfd = open_userfile(screen->uid, screen->gid, buf, False);
	if (tekcopyfd >= 0) {
	    char initbuf[5];

	    sprintf(initbuf, "%c%c%c%c",
		    ANSI_ESC, (char) (tekscr->page.fontsize + '8'),
		    ANSI_ESC, (char) (tekscr->page.linetype + '`'));
	    IGNORE_RC(write(tekcopyfd, initbuf, (size_t) 4));
	    Tp = &Tek0;
	    do {
		IGNORE_RC(write(tekcopyfd, Tp->data, (size_t) Tp->count));
		Tp = Tp->next;
	    } while (Tp);
	    close(tekcopyfd);
	}
    }
}

/*ARGSUSED*/
void
HandleGINInput(Widget w,
	       XEvent *event GCC_UNUSED,
	       String *param_list,
	       Cardinal *nparamsp)
{
    TekWidget tw = getTekWidget(w);

    if (tw != 0) {
	TekScreen *tekscr = TekScreenOf(tw);

	if (tekscr->TekGIN && *nparamsp == 1) {
	    int c = param_list[0][0];
	    switch (c) {
	    case 'l':
	    case 'm':
	    case 'r':
	    case 'L':
	    case 'M':
	    case 'R':
		break;
	    default:
		Bell(tw->vt, XkbBI_MinorError, 0);	/* let them know they goofed */
		c = 'l';	/* provide a default */
	    }
	    TekEnqMouse(tw, c | 0x80);
	    TekGINoff(tw);
	} else {
	    Bell(tw->vt, XkbBI_MinorError, 0);
	}
    }
}

/*
 * Check if the current widget, or any parent, is the VT100 "xterm" widget.
 */
TekWidget
getTekWidget(Widget w)
{
    TekWidget tw;

    if (w == 0) {
	tw = (TekWidget) CURRENT_EMU();
	if (!IsTekWidget(tw)) {
	    tw = 0;
	}
    } else if (IsTekWidget(w)) {
	tw = (TekWidget) w;
    } else {
	tw = getTekWidget(XtParent(w));
    }
    TRACE2(("getTekWidget %p -> %p\n", w, tw));
    return tw;
}
xterm-330/vms.h0000644000175100001440000000162011454542517012224 0ustar  tomusers/* $XFree86: xc/programs/xterm/vms.h,v 1.1 2000/02/08 17:19:45 dawes Exp $ */

/* vms.h
 */
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

struct IOSB
{
	short int status;
	short int len;
	int unused;
} mbx_read_iosb,iosb;

#define MAXITEMLIST   5

short int	tt_chan;    /* channel to the Pseudo terminal */
short int	mbx_chan;   /* channel to the mailbox */
struct accdef	mbx_buf;    /* mailbox buffer */
short int	mbxunit;    /* mailbox unit number */
int		pid;		/* PID of created process */
static $DESCRIPTOR  (image, "SYS$SYSTEM:LOGINOUT.EXE");

static struct	    items {
	short int	buflen;
	short int	code;
	int		buffer;
	int		return_addr;
} itemlist[MAXITEMLIST];

int tt_write(const char *tt_write_buf,int size);
xterm-330/cachedGCs.c0000644000175100001440000004555013032521305013212 0ustar  tomusers/* $XTermId: cachedGCs.c,v 1.67 2017/01/02 18:58:13 tom Exp $ */

/*
 * Copyright 2007-2016,2017 by Thomas E. Dickey
 *
 *                         All Rights Reserved
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name(s) of the above copyright
 * holders shall not be used in advertising or otherwise to promote the
 * sale, use or other dealings in this Software without prior written
 * authorization.
 */

#include 
#include 
#include 

#include 

/*
 * hide (or eliminate) calls to
 *	XCreateGC()
 *	XFreeGC()
 *	XGetGCValues()
 *	XSetBackground()
 *	XSetFont()
 *	XSetForeground()
 *	XtGetGC()
 *	XtReleaseGC()
 * by associating an integer with each GC, maintaining a cache which
 * reflects frequency of use rather than most recent usage.
 *
 * FIXME: XTermFonts should hold gc, font, fs.
 */
typedef struct {
    GC gc;
    unsigned used;
    unsigned cset;
    XTermFonts *font;
    Pixel tile;
    Pixel fg;
    Pixel bg;
} CgsCacheData;

#define DEPTH 8
#define ITEM()      (int) (me->data - me->list)
#define LIST(item)  me->list[item]
#define LINK(item)  me->data = (me->list + (item))
#define THIS(field) me->data->field
#define NEXT(field) me->next.field

#define HaveFont(font) (Boolean) ((font) != 0 && (font)->fs != 0)

#define GC_CSet GCFunction

typedef struct {
    CgsCacheData list[DEPTH];
    CgsCacheData *data;		/* points to current list[] entry */
    XtGCMask mask;		/* changes since the last getCgsGC() */
    CgsCacheData next;		/* updated values, apply in getCgsGC() */
} CgsCache;

#if OPT_TRACE
#define CASE(name) case gc##name: result = #name; break
static const char *
traceCgsEnum(CgsEnum value)
{
    const char *result = "?";
    switch (value) {
	CASE(Norm);
	CASE(Bold);
	CASE(NormReverse);
	CASE(BoldReverse);
#if OPT_BOX_CHARS
	CASE(Line);
	CASE(Dots);
#endif
#if OPT_DEC_CHRSET
	CASE(CNorm);
	CASE(CBold);
#endif
#if OPT_WIDE_CHARS
	CASE(Wide);
	CASE(WBold);
	CASE(WideReverse);
	CASE(WBoldReverse);
#endif
	CASE(VTcursNormal);
	CASE(VTcursFilled);
	CASE(VTcursReverse);
	CASE(VTcursOutline);
#if OPT_TEK4014
	CASE(TKcurs);
#endif
	CASE(MAX);
    }
    return result;
}

#undef CASE

static const char *
traceVTwin(XtermWidget xw, VTwin *value)
{
    const char *result = "?";
    if (value == 0)
	result = "null";
    else if (value == &(TScreenOf(xw)->fullVwin))
	result = "fullVwin";
#ifndef NO_ACTIVE_ICON
    else if (value == &(TScreenOf(xw)->iconVwin))
	result = "iconVwin";
#endif
    return result;
}

#if OPT_TRACE > 1
static String
traceCSet(unsigned cset)
{
    static char result[80];
    switch (cset) {
    case CSET_SWL:
	strcpy(result, "SWL");
	break;
    case CSET_DHL_TOP:
	strcpy(result, "DHL_TOP");
	break;
    case CSET_DHL_BOT:
	strcpy(result, "DHL_BOT");
	break;
    case CSET_DWL:
	strcpy(result, "DWL");
	break;
    default:
	sprintf(result, "%#x", cset);
	break;
    }
    return result;
}

static String
traceFont(XTermFonts * font)
{
    static char result[80];

    if (HaveFont(font)) {
	XFontStruct *fs = font->fs;
	sprintf(result, "%p(%dx%d %d %#lx)",
		fs,
		fs->max_bounds.width,
		fs->max_bounds.ascent + fs->max_bounds.descent,
		fs->max_bounds.descent,
		(unsigned long) (fs->fid));
    } else {
	strcpy(result, "null");
    }
    return result;
}

static String
tracePixel(XtermWidget xw, Pixel value)
{
#define CASE(name) { name, #name }
    static struct {
	TermColors code;
	String name;
    } t_colors[] = {
	CASE(TEXT_FG),
	    CASE(TEXT_BG),
	    CASE(TEXT_CURSOR),
	    CASE(MOUSE_FG),
	    CASE(MOUSE_BG),
#if OPT_TEK4014
	    CASE(TEK_FG),
	    CASE(TEK_BG),
#endif
#if OPT_HIGHLIGHT_COLOR
	    CASE(HIGHLIGHT_BG),
	    CASE(HIGHLIGHT_FG),
#endif
#if OPT_TEK4014
	    CASE(TEK_CURSOR),
#endif
    };
    TScreen *screen = TScreenOf(xw);
    String result = 0;
    int n;

    for (n = 0; n < NCOLORS; ++n) {
	if (value == T_COLOR(screen, t_colors[n].code)) {
	    result = t_colors[n].name;
	    break;
	}
    }

    if (result == 0) {
	for (n = 0; n < MAXCOLORS; ++n) {
#if OPT_COLOR_RES
	    if (screen->Acolors[n].mode > 0
		&& value == screen->Acolors[n].value) {
		result = screen->Acolors[n].resource;
		break;
	    }
#else
	    if (value == screen->Acolors[n]) {
		char temp[80];
		sprintf(temp, "Acolors[%d]", n);
		result = x_strdup(temp);
		break;
	    }
#endif
	}
    }

    if (result == 0) {
	char temp[80];
	sprintf(temp, "%#lx", value);
	result = x_strdup(temp);
    }

    return result;
}

#undef CASE

#endif /* OPT_TRACE > 1 */
#endif /* OPT_TRACE */

static CgsCache *
allocCache(void **cache_pointer)
{
    if (*cache_pointer == 0) {
	*cache_pointer = TypeCallocN(CgsCache, gcMAX);
	TRACE(("allocCache %p\n", *cache_pointer));
    }
    return *((CgsCache **) cache_pointer);
}

static int
dataIndex(CgsCache * me)
{
    return ITEM();
}

static void
relinkData(CgsCache * me, int item)
{
    LINK(item);
}

/*
 * Returns the appropriate cache pointer.
 */
static CgsCache *
myCache(XtermWidget xw, VTwin *cgsWin, CgsEnum cgsId)
{
    CgsCache *result = 0;

    if ((int) cgsId >= 0 && cgsId < gcMAX) {
#ifdef NO_ACTIVE_ICON
	(void) xw;
	(void) cgsWin;
#else
	if (cgsWin == &(TScreenOf(xw)->iconVwin))
	    result = allocCache(&(TScreenOf(xw)->icon_cgs_cache));
	else
#endif
	    result = allocCache(&(TScreenOf(xw)->main_cgs_cache));

	result += cgsId;
	if (result->data == 0) {
	    result->data = result->list;
	}
    }

    return result;
}

static Display *
myDisplay(XtermWidget xw)
{
    return TScreenOf(xw)->display;
}

static Drawable
myDrawable(XtermWidget xw, VTwin *cgsWin)
{
    Drawable drawable = 0;

    if (cgsWin != 0 && cgsWin->window != 0)
	drawable = cgsWin->window;
    if (drawable == 0)
	drawable = RootWindowOfScreen(XtScreen(xw));
    return drawable;
}

static GC
newCache(XtermWidget xw, VTwin *cgsWin, CgsEnum cgsId, CgsCache * me)
{
    XGCValues xgcv;
    XtGCMask mask;

    THIS(font) = NEXT(font);
    THIS(cset) = NEXT(cset);
    THIS(fg) = NEXT(fg);
    THIS(bg) = NEXT(bg);

    memset(&xgcv, 0, sizeof(xgcv));
    xgcv.font = NEXT(font)->fs->fid;
    mask = (GCForeground | GCBackground | GCFont);

    switch (cgsId) {
    case gcNorm:
    case gcBold:
    case gcNormReverse:
    case gcBoldReverse:
#if OPT_WIDE_CHARS
    case gcWide:
    case gcWBold:
    case gcWideReverse:
    case gcWBoldReverse:
#endif
	mask |= (GCGraphicsExposures | GCFunction);
	xgcv.graphics_exposures = True;		/* default */
	xgcv.function = GXcopy;
	break;
#if OPT_BOX_CHARS
    case gcLine:
	mask |= (GCGraphicsExposures | GCFunction);
	xgcv.graphics_exposures = True;		/* default */
	xgcv.function = GXcopy;
	break;
    case gcDots:
	xgcv.fill_style = FillTiled;
	xgcv.tile =
	    XmuCreateStippledPixmap(XtScreen((Widget) xw),
				    THIS(fg),
				    THIS(bg),
				    xw->core.depth);
	THIS(tile) = xgcv.tile;
	mask = (GCForeground | GCBackground);
	mask |= (GCGraphicsExposures | GCFunction | GCTile | GCFillStyle);
	xgcv.graphics_exposures = True;		/* default */
	xgcv.function = GXcopy;
	break;
#endif
#if OPT_DEC_CHRSET
    case gcCNorm:
    case gcCBold:
	break;
#endif
    case gcVTcursNormal:	/* FALLTHRU */
    case gcVTcursFilled:	/* FALLTHRU */
    case gcVTcursReverse:	/* FALLTHRU */
    case gcVTcursOutline:	/* FALLTHRU */
	break;
#if OPT_TEK4014
    case gcTKcurs:		/* FALLTHRU */
	/* FIXME */
#endif
    case gcMAX:		/* should not happen */
	return 0;
    }
    xgcv.foreground = NEXT(fg);
    xgcv.background = NEXT(bg);

    THIS(gc) = XCreateGC(myDisplay(xw), myDrawable(xw, cgsWin), mask, &xgcv);
    TRACE(("getCgsGC(%s) created gc %p(%d)\n",
	   traceCgsEnum(cgsId), (void *) THIS(gc), ITEM()));

    THIS(used) = 0;
    return THIS(gc);
}

static Boolean
SameFont(XTermFonts * a, XTermFonts * b)
{
    return (Boolean) (HaveFont(a)
		      && HaveFont(b)
		      && ((a->fs == b->fs)
			  || !memcmp(a->fs, b->fs, sizeof(*(a->fs)))));
}

#define SameColor(a,b) ((a) == (b))
#define SameCSet(a,b)  ((a) == (b))

static GC
chgCache(XtermWidget xw, CgsEnum cgsId GCC_UNUSED, CgsCache * me, Bool both)
{
    XGCValues xgcv;
    XtGCMask mask = (GCForeground | GCBackground | GCFont);

    memset(&xgcv, 0, sizeof(xgcv));

    TRACE2(("chgCache(%s) old data fg=%s, bg=%s, font=%s cset %s\n",
	    traceCgsEnum(cgsId),
	    tracePixel(xw, THIS(fg)),
	    tracePixel(xw, THIS(bg)),
	    traceFont(THIS(font)),
	    traceCSet(THIS(cset))));
#if OPT_TRACE > 1
    if (!SameFont(THIS(font), NEXT(font)))
	TRACE2(("...chgCache new font=%s\n", traceFont(NEXT(font))));
    if (!SameCSet(THIS(cset), NEXT(cset)))
	TRACE2(("...chgCache new cset=%s\n", traceCSet(NEXT(cset))));
    if (!SameColor(THIS(fg), NEXT(fg)))
	TRACE2(("...chgCache new fg=%s\n", tracePixel(xw, NEXT(fg))));
    if (!SameColor(THIS(bg), NEXT(bg)))
	TRACE2(("...chgCache new bg=%s\n", tracePixel(xw, NEXT(bg))));
#endif

    if (both) {
	THIS(font) = NEXT(font);
	THIS(cset) = NEXT(cset);
    }
    THIS(fg) = NEXT(fg);
    THIS(bg) = NEXT(bg);

    xgcv.font = THIS(font)->fs->fid;
    xgcv.foreground = THIS(fg);
    xgcv.background = THIS(bg);

    XChangeGC(myDisplay(xw), THIS(gc), mask, &xgcv);
    TRACE2(("...chgCache(%s) updated gc %p(%d)\n",
	    traceCgsEnum(cgsId), THIS(gc), ITEM()));

    THIS(used) = 0;
    return THIS(gc);
}

/*
 * Use the "setCgsXXXX()" calls to initialize parameters for a new GC.
 */
void
setCgsFore(XtermWidget xw, VTwin *cgsWin, CgsEnum cgsId, Pixel fg)
{
    CgsCache *me;

    if ((me = myCache(xw, cgsWin, cgsId)) != 0) {
	NEXT(fg) = fg;
	me->mask |= GCForeground;
    }
}

void
setCgsBack(XtermWidget xw, VTwin *cgsWin, CgsEnum cgsId, Pixel bg)
{
    CgsCache *me;

    if ((me = myCache(xw, cgsWin, cgsId)) != 0) {
	NEXT(bg) = bg;
	me->mask |= GCBackground;
    }
}

#if OPT_DEC_CHRSET
void
setCgsCSet(XtermWidget xw, VTwin *cgsWin, CgsEnum cgsId, unsigned cset)
{
    CgsCache *me;

    if ((me = myCache(xw, cgsWin, cgsId)) != 0) {
	NEXT(cset) = cset;
	me->mask |= GC_CSet;
    }
}
#else
#define setCgsCSet(xw, cgsWin, dstCgsId, cset)	/* nothing */
#endif

void
setCgsFont(XtermWidget xw, VTwin *cgsWin, CgsEnum cgsId, XTermFonts * font)
{
    CgsCache *me;

    if ((me = myCache(xw, cgsWin, cgsId)) != 0) {
	TScreen *screen = TScreenOf(xw);
	if (!HaveFont(font)) {
	    if (cgsId != gcNorm)
		(void) getCgsGC(xw, cgsWin, gcNorm);
#ifndef NO_ACTIVE_ICON
	    if (cgsWin == &(TScreenOf(xw)->iconVwin))
		font = getIconicFont(screen);
	    else
#endif
		font = getNormalFont(screen, fNorm);
	}
	if (HaveFont(font) && okFont(font->fs)) {
	    TRACE2(("setCgsFont next: %s for %s slot %p, gc %p\n",
		    traceFont(font), traceCgsEnum(cgsId),
		    me, THIS(gc)));
	    TRACE2(("...next font was %s\n", traceFont(NEXT(font))));
	    NEXT(font) = font;
	    me->mask |= GCFont;
	} else {
	    /* EMPTY */
	    TRACE2(("...NOT updated font for %s\n",
		    traceCgsEnum(cgsId)));
	}
    }
}

/*
 * Discard all of the font information, e.g., we are resizing the font.
 * Keep the GC's so we can simply change them rather than creating new ones.
 */
void
clrCgsFonts(XtermWidget xw, VTwin *cgsWin, XTermFonts * font)
{
    if (HaveFont(font)) {
	int j;
	for_each_gc(j) {
	    CgsCache *me;
	    if ((me = myCache(xw, cgsWin, (CgsEnum) j)) != 0) {
		int k;
		for (k = 0; k < DEPTH; ++k) {
		    if (SameFont(LIST(k).font, font)) {
			TRACE2(("clrCgsFonts %s gc %p(%d) %s\n",
				traceCgsEnum((CgsEnum) j),
				LIST(k).gc,
				k,
				traceFont(font)));
			LIST(k).font = 0;
			LIST(k).cset = 0;
		    }
		}
		if (SameFont(NEXT(font), font)) {
		    TRACE2(("clrCgsFonts %s next %s\n",
			    traceCgsEnum((CgsEnum) j),
			    traceFont(font)));
		    NEXT(font) = 0;
		    NEXT(cset) = 0;
		    me->mask &= (unsigned) ~(GCFont | GC_CSet);
		}
	    }
	}
    }
}

/*
 * Return a GC associated with the given id, allocating if needed.
 */
GC
getCgsGC(XtermWidget xw, VTwin *cgsWin, CgsEnum cgsId)
{
    CgsCache *me;
    GC result = 0;

    if ((me = myCache(xw, cgsWin, cgsId)) != 0) {
	TRACE2(("getCgsGC(%s, %s)\n",
		traceVTwin(xw, cgsWin), traceCgsEnum(cgsId)));
	if (me->mask != 0) {
	    int j;
	    unsigned used = 0;

	    /* fill in the unchanged fields */
	    if (!(me->mask & GC_CSet))
		NEXT(cset) = 0;	/* OPT_DEC_CHRSET */
	    if (!(me->mask & GCFont))
		NEXT(font) = THIS(font);
	    if (!(me->mask & GCForeground))
		NEXT(fg) = THIS(fg);
	    if (!(me->mask & GCBackground))
		NEXT(bg) = THIS(bg);

	    if (NEXT(font) == 0) {
		setCgsFont(xw, cgsWin, cgsId, 0);
	    }

	    TRACE2(("...Cgs new data fg=%s, bg=%s, font=%s cset %s\n",
		    tracePixel(xw, NEXT(fg)),
		    tracePixel(xw, NEXT(bg)),
		    traceFont(NEXT(font)),
		    traceCSet(NEXT(cset))));

	    /* try to find the given data in an already-created GC */
	    for (j = 0; j < DEPTH; ++j) {
		if (LIST(j).gc != 0
		    && SameFont(LIST(j).font, NEXT(font))
		    && SameCSet(LIST(j).cset, NEXT(cset))
		    && SameColor(LIST(j).fg, NEXT(fg))
		    && SameColor(LIST(j).bg, NEXT(bg))) {
		    LINK(j);
		    result = THIS(gc);
		    TRACE2(("getCgsGC existing %p(%d)\n", result, ITEM()));
		    break;
		}
	    }

	    if (result == 0) {
		/* try to find an empty slot, to create a new GC */
		used = 0;
		for (j = 0; j < DEPTH; ++j) {
		    if (LIST(j).gc == 0) {
			LINK(j);
			result = newCache(xw, cgsWin, cgsId, me);
			break;
		    }
		    if (used < LIST(j).used)
			used = LIST(j).used;
		}
	    }

	    if (result == 0) {
		int k;
		/* if none were empty, pick the least-used slot, to modify */
		for (j = 0, k = -1; j < DEPTH; ++j) {
		    if (used >= LIST(j).used) {
			used = LIST(j).used;
			k = j;
		    }
		}
		LINK(k);
		TRACE2(("...getCgsGC least-used(%d) was %d\n", k, THIS(used)));
		result = chgCache(xw, cgsId, me, True);
	    }
	    me->next = *(me->data);
	} else {
	    result = THIS(gc);
	}
	me->mask = 0;
	THIS(used) += 1;
	TRACE2(("...getCgsGC(%s, %s) gc %p(%d), used %d\n",
		traceVTwin(xw, cgsWin),
		traceCgsEnum(cgsId), result, ITEM(), THIS(used)));
    }
    return result;
}

/*
 * Return the font for the given GC.
 */
CgsEnum
getCgsId(XtermWidget xw, VTwin *cgsWin, GC gc)
{
    int n;
    CgsEnum result = gcNorm;

    for_each_gc(n) {
	CgsCache *me;

	if ((me = myCache(xw, cgsWin, (CgsEnum) n)) != 0) {
	    if (THIS(gc) == gc) {
		result = (CgsEnum) n;
		break;
	    }
	}
    }
    return result;
}

/*
 * Return the font for the given GC.
 */
XTermFonts *
getCgsFont(XtermWidget xw, VTwin *cgsWin, GC gc)
{
    int n;
    XTermFonts *result = 0;

    for_each_gc(n) {
	CgsCache *me;

	if ((me = myCache(xw, cgsWin, (CgsEnum) n)) != 0) {
	    if (THIS(gc) == gc) {
		result = THIS(font);
		break;
	    }
	}
    }
    return result;
}

/*
 * Return the foreground color for the given GC.
 */
Pixel
getCgsFore(XtermWidget xw, VTwin *cgsWin, GC gc)
{
    int n;
    Pixel result = 0;

    for_each_gc(n) {
	CgsCache *me;

	if ((me = myCache(xw, cgsWin, (CgsEnum) n)) != 0) {
	    if (THIS(gc) == gc) {
		result = THIS(fg);
		break;
	    }
	}
    }
    return result;
}

/*
 * Return the background color for the given GC.
 */
Pixel
getCgsBack(XtermWidget xw, VTwin *cgsWin, GC gc)
{
    int n;
    Pixel result = 0;

    for_each_gc(n) {
	CgsCache *me;

	if ((me = myCache(xw, cgsWin, (CgsEnum) n)) != 0) {
	    if (THIS(gc) == gc) {
		result = THIS(bg);
		break;
	    }
	}
    }
    return result;
}

/*
 * Copy the parameters (except GC of course) from one cache record to another.
 */
void
copyCgs(XtermWidget xw, VTwin *cgsWin, CgsEnum dstCgsId, CgsEnum srcCgsId)
{
    if (dstCgsId != srcCgsId) {
	CgsCache *me;

	if ((me = myCache(xw, cgsWin, srcCgsId)) != 0) {
	    TRACE(("copyCgs from %s to %s\n",
		   traceCgsEnum(srcCgsId),
		   traceCgsEnum(dstCgsId)));
	    TRACE2(("copyCgs from %s (me %p, fg %s, bg %s, cset %s) to %s {{\n",
		    traceCgsEnum(srcCgsId),
		    me,
		    tracePixel(xw, THIS(fg)),
		    tracePixel(xw, THIS(bg)),
		    traceCSet(THIS(cset)),
		    traceCgsEnum(dstCgsId)));
	    setCgsCSet(xw, cgsWin, dstCgsId, THIS(cset));
	    setCgsFore(xw, cgsWin, dstCgsId, THIS(fg));
	    setCgsBack(xw, cgsWin, dstCgsId, THIS(bg));
	    setCgsFont(xw, cgsWin, dstCgsId, THIS(font));
	    TRACE2(("...copyCgs }}\n"));
	}
    }
}

/*
 * Interchange colors in the cache, e.g., for reverse-video.
 */
void
redoCgs(XtermWidget xw, Pixel fg, Pixel bg, CgsEnum cgsId)
{
    VTwin *cgsWin = WhichVWin(TScreenOf(xw));
    CgsCache *me = myCache(xw, cgsWin, cgsId);

    if (me != 0) {
	CgsCacheData *save_data = me->data;
	int n;

	for (n = 0; n < DEPTH; ++n) {
	    if (LIST(n).gc != 0 && HaveFont(LIST(n).font)) {
		LINK(n);

		if (LIST(n).fg == fg
		    && LIST(n).bg == bg) {
		    setCgsFore(xw, cgsWin, cgsId, bg);
		    setCgsBack(xw, cgsWin, cgsId, fg);
		} else if (LIST(n).fg == bg
			   && LIST(n).bg == fg) {
		    setCgsFore(xw, cgsWin, cgsId, fg);
		    setCgsBack(xw, cgsWin, cgsId, bg);
		} else {
		    continue;
		}

		(void) chgCache(xw, cgsId, me, False);
	    }
	}
	me->data = save_data;
    }
}

/*
 * Swap the cache records, e.g., when doing reverse-video.
 */
void
swapCgs(XtermWidget xw, VTwin *cgsWin, CgsEnum dstCgsId, CgsEnum srcCgsId)
{
    if (dstCgsId != srcCgsId) {
	CgsCache *src;

	if ((src = myCache(xw, cgsWin, srcCgsId)) != 0) {
	    CgsCache *dst;

	    if ((dst = myCache(xw, cgsWin, dstCgsId)) != 0) {
		CgsCache tmp;
		int srcIndex = dataIndex(src);
		int dstIndex = dataIndex(dst);

		EXCHANGE(*src, *dst, tmp);

		relinkData(src, dstIndex);
		relinkData(dst, srcIndex);
	    }
	}
    }
}

/*
 * Free any GC associated with the given id.
 */
GC
freeCgs(XtermWidget xw, VTwin *cgsWin, CgsEnum cgsId)
{
    CgsCache *me;

    if ((me = myCache(xw, cgsWin, cgsId)) != 0) {
	int j;

	for (j = 0; j < DEPTH; ++j) {
	    if (LIST(j).gc != 0) {
		TRACE(("freeCgs(%s, %s) gc %p(%d)\n",
		       traceVTwin(xw, cgsWin),
		       traceCgsEnum(cgsId), (void *) LIST(j).gc, j));
		clrCgsFonts(xw, cgsWin, LIST(j).font);
#if OPT_BOX_CHARS
		if (cgsId == gcDots) {
		    XmuReleaseStippledPixmap(XtScreen((Widget) xw), LIST(j).tile);
		}
#endif
		XFreeGC(TScreenOf(xw)->display, LIST(j).gc);
		memset(&LIST(j), 0, sizeof(LIST(j)));
	    }
	    LINK(0);
	}
    }
    return 0;
}

#ifdef NO_LEAKS
void
noleaks_cachedCgs(XtermWidget xw)
{
#ifndef NO_ACTIVE_ICON
    free(TScreenOf(xw)->icon_cgs_cache);
#endif
    free(TScreenOf(xw)->main_cgs_cache);
}
#endif
xterm-330/uxterm.man0000644000175100001440000000621512070430227013261 0ustar  tomusers.\" $XTermId: uxterm.man,v 1.6 2013/01/01 00:40:55 tom Exp $
.\"
.\" Copyright 2001, 2004 Branden Robinson
.\"
.\" Permission is hereby granted, free of charge, to any person obtaining a
.\" copy of this software and associated documentation files (the "Software"),
.\" to deal in the Software without restriction, including without limitation
.\" the rights to use, copy, modify, merge, publish, distribute, sublicense,
.\" and/or sell copies of the Software, and to permit persons to whom the
.\" Software is furnished to do so, subject to the following conditions:
.\"
.\" The above copyright notice and this permission notice shall be included in
.\" all copies or substantial portions of the Software.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
.\" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
.\" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
.\" SOFTWARE IN THE PUBLIC INTEREST, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR
.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
.\" DEALINGS IN THE SOFTWARE.
.\"
.ds N Uxterm
.ds n uxterm
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds AQ \(aq
.el       .ds AQ '
.ie \n(.g .ds `` \(lq
.el       .ds `` ``
.ie \n(.g .ds '' \(rq
.el       .ds '' ''
.\"
.TH UXTERM 1 "__app_date__" "__app_version__" "X Window System"
.SH NAME
uxterm \- X terminal emulator for Unicode (UTF-8) environments
.SH SYNOPSIS
.B \*n
[
.I xterm-options
]
.SH DESCRIPTION
.B \*n
is a wrapper around the
.BR xterm(1)
program that invokes the latter program with the \*(``U__default_class__\*('' X resource
class set.
All arguments to
.B \*n
are passed to
.B xterm
without processing; the
.B \-class
and
.B \-u8
options should not be specified because they are used by the wrapper.
See the
.B xterm
manual page for more information on
.IR xterm-options .
.PP
The environment's locale settings (see \*(``ENVIRONMENT\*('' below) are
used to discern the locale's character set.
If no current locale can be determined, the locale \*(``en_US\*('' (the
English language as used in the territory of the United States) is assumed.
The
.BR locale(1)
utility is used to determine whether the system supports the selected
locale.
If it does not,
.B \*n
will exit with an error and report the output of
.BR locale .
.PP
.B Note: \*n
may produce unexpected results if the current locale is set to one in which
the UTF-8 character encoding is not supported, or if fonts using the ISO
10646-1 character set are not available.
In the Debian system, the \*(``xfonts\-base\*('' package provides the fonts
that
.B \*n
uses by default.
To change the fonts
.B \*n
uses, edit the
.I __apploaddir__/U__default_class__
file.
.PP
A similar wrapper,
.BR koi8rxterm(1),
is available for KOI8-R environments.
.SH ENVIRONMENT
.TP
.B LC_ALL\fR, \fBLC_CTYPE\fR, \fBLANG
The values of these variables are checked, in order, to determine the
character set used by the current locale.
.SH AUTHOR
Thomas Dickey
.SH "SEE ALSO"
.BR locale(1),
.BR locale(7),
.BR koi8rxterm(1),
.BR xterm(1)
xterm-330/configure0000755000175100001440000223572113113500560013154 0ustar  tomusers#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by Autoconf 2.52.20170501.
#
# Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
# Free Software Foundation, Inc.
# This configure script is free software; the Free Software Foundation
# gives unlimited permission to copy, distribute and modify it.

# Avoid depending upon Character Ranges.
as_cr_letters='abcdefghijklmnopqrstuvwxyz'
as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
as_cr_Letters=$as_cr_letters$as_cr_LETTERS
as_cr_digits='0123456789'
as_cr_alnum=$as_cr_Letters$as_cr_digits

# Sed expression to map a string onto a valid variable name.
as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g"

# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g"

# Be Bourne compatible
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
  emulate sh
  NULLCMD=:
elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
  set -o posix
fi

# Name of the executable.
as_me=`echo "$0" |sed 's,.*[\\/],,'`

if expr a : '\(a\)' >/dev/null 2>&1; then
  as_expr=expr
else
  as_expr=false
fi

rm -f conf$$ conf$$.exe conf$$.file
echo >conf$$.file
if ln -s conf$$.file conf$$ 2>/dev/null; then
  # We could just check for DJGPP; but this test a) works b) is more generic
  # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
  if test -f conf$$.exe; then
    # Don't use ln at all; we don't have any links
    as_ln_s='cp -p'
  else
    as_ln_s='ln -s'
  fi
elif ln conf$$.file conf$$ 2>/dev/null; then
  as_ln_s=ln
else
  as_ln_s='cp -p'
fi
rm -f conf$$ conf$$.exe conf$$.file

as_executable_p="test -f"

# Support unset when possible.
if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
  as_unset=unset
else
  as_unset=false
fi

# NLS nuisances.
$as_unset LANG || test "${LANG+set}" != set || { LANG=C; export LANG; }
$as_unset LC_ALL || test "${LC_ALL+set}" != set || { LC_ALL=C; export LC_ALL; }
$as_unset LC_TIME || test "${LC_TIME+set}" != set || { LC_TIME=C; export LC_TIME; }
$as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set || { LC_CTYPE=C; export LC_CTYPE; }
$as_unset LANGUAGE || test "${LANGUAGE+set}" != set || { LANGUAGE=C; export LANGUAGE; }
$as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set || { LC_COLLATE=C; export LC_COLLATE; }
$as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set || { LC_NUMERIC=C; export LC_NUMERIC; }
$as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set || { LC_MESSAGES=C; export LC_MESSAGES; }

# IFS
# We need space, tab and new line, in precisely that order.
as_nl='
'
IFS=" 	$as_nl"

# CDPATH.
$as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=:; export CDPATH; }

# Name of the host.
# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
# so uname gets run too.
ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`

exec 6>&1

#
# Initializations.
#
ac_default_prefix=/usr/local
cross_compiling=no
subdirs=
MFLAGS= MAKEFLAGS=
SHELL=${CONFIG_SHELL-/bin/sh}

# Maximum number of lines to put in a shell here document.
# This variable seems obsolete.  It should probably be removed, and
# only ac_max_sed_lines should be used.
: ${ac_max_here_lines=38}

ac_unique_file="charproc.c"
# Factoring default headers for most tests.
ac_includes_default="\
#include 
#if HAVE_SYS_TYPES_H
# include 
#endif
#if HAVE_SYS_STAT_H
# include 
#endif
#if STDC_HEADERS
# include 
# include 
#else
# if HAVE_STDLIB_H
#  include 
# endif
#endif
#if HAVE_STRING_H
# if !STDC_HEADERS && HAVE_MEMORY_H
#  include 
# endif
# include 
#endif
#if HAVE_STRINGS_H
# include 
#endif
#if HAVE_INTTYPES_H
# include 
#else
# if HAVE_STDINT_H
#  include 
# endif
#endif
#if HAVE_UNISTD_H
# include 
#endif"

# Initialize some variables set by options.
ac_init_help=
ac_init_version=false
# The variables have the same names as the options, with
# dashes changed to underlines.
cache_file=/dev/null
exec_prefix=NONE
no_create=
no_recursion=
prefix=NONE
program_prefix=NONE
program_suffix=NONE
program_transform_name=s,x,x,
silent=
site=
srcdir=
verbose=
x_includes=NONE
x_libraries=NONE

# Installation directory options.
# These are left unexpanded so users can "make install exec_prefix=/foo"
# and all the variables that are supposed to be based on exec_prefix
# by default will actually change.
# Use braces instead of parens because sh, perl, etc. also accept them.
bindir='${exec_prefix}/bin'
sbindir='${exec_prefix}/sbin'
libexecdir='${exec_prefix}/libexec'
datarootdir='${prefix}/share'
datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
libdir='${exec_prefix}/lib'
includedir='${prefix}/include'
oldincludedir='/usr/include'
infodir='${datarootdir}/info'
mandir='${datarootdir}/man'

# Identity of this package.
PACKAGE_NAME=
PACKAGE_TARNAME=
PACKAGE_VERSION=
PACKAGE_STRING=
PACKAGE_BUGREPORT=

ac_prev=
for ac_option
do
  # If the previous option needs an argument, assign it.
  if test -n "$ac_prev"; then
    eval "$ac_prev=\$ac_option"
    ac_prev=
    continue
  fi

  ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`

  # Accept the important Cygnus configure options, so we can diagnose typos.

  case $ac_option in

  -bindir | --bindir | --bindi | --bind | --bin | --bi)
    ac_prev=bindir ;;
  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
    bindir=$ac_optarg ;;

  -build | --build | --buil | --bui | --bu)
    ac_prev=build_alias ;;
  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
    build_alias=$ac_optarg ;;

  -cache-file | --cache-file | --cache-fil | --cache-fi \
  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
    ac_prev=cache_file ;;
  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
    cache_file=$ac_optarg ;;

  --config-cache | -C)
    cache_file=config.cache ;;

  -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
    ac_prev=datadir ;;
  -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
  | --da=*)
    datadir=$ac_optarg ;;

  -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
  | --dataroo | --dataro | --datar)
    ac_prev=datarootdir ;;
  -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
  | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
    datarootdir=$ac_optarg ;;

  -disable-* | --disable-*)
    ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
    # Reject names that are not valid shell variable names.
    expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
      { echo "$as_me: error: invalid feature name: $ac_feature" >&2
   { (exit 1); exit 1; }; }
    ac_feature=`echo $ac_feature | sed 's/-/_/g'`
    eval "enable_$ac_feature=no" ;;

  -enable-* | --enable-*)
    ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
    # Reject names that are not valid shell variable names.
    expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
      { echo "$as_me: error: invalid feature name: $ac_feature" >&2
   { (exit 1); exit 1; }; }
    ac_feature=`echo $ac_feature | sed 's/-/_/g'`
    case $ac_option in
      *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
      *) ac_optarg=yes ;;
    esac
    eval "enable_$ac_feature='$ac_optarg'" ;;

  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
  | --exec | --exe | --ex)
    ac_prev=exec_prefix ;;
  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
  | --exec=* | --exe=* | --ex=*)
    exec_prefix=$ac_optarg ;;

  -gas | --gas | --ga | --g)
    # Obsolete; use --with-gas.
    with_gas=yes ;;

  -help | --help | --hel | --he | -h)
    ac_init_help=long ;;
  -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
    ac_init_help=recursive ;;
  -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
    ac_init_help=short ;;

  -host | --host | --hos | --ho)
    ac_prev=host_alias ;;
  -host=* | --host=* | --hos=* | --ho=*)
    host_alias=$ac_optarg ;;

  -includedir | --includedir | --includedi | --included | --include \
  | --includ | --inclu | --incl | --inc)
    ac_prev=includedir ;;
  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
  | --includ=* | --inclu=* | --incl=* | --inc=*)
    includedir=$ac_optarg ;;

  -infodir | --infodir | --infodi | --infod | --info | --inf)
    ac_prev=infodir ;;
  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
    infodir=$ac_optarg ;;

  -libdir | --libdir | --libdi | --libd)
    ac_prev=libdir ;;
  -libdir=* | --libdir=* | --libdi=* | --libd=*)
    libdir=$ac_optarg ;;

  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
  | --libexe | --libex | --libe)
    ac_prev=libexecdir ;;
  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
  | --libexe=* | --libex=* | --libe=*)
    libexecdir=$ac_optarg ;;

  -localstatedir | --localstatedir | --localstatedi | --localstated \
  | --localstate | --localstat | --localsta | --localst \
  | --locals | --local | --loca | --loc | --lo)
    ac_prev=localstatedir ;;
  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
  | --localstate=* | --localstat=* | --localsta=* | --localst=* \
  | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
    localstatedir=$ac_optarg ;;

  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
    ac_prev=mandir ;;
  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
    mandir=$ac_optarg ;;

  -nfp | --nfp | --nf)
    # Obsolete; use --without-fp.
    with_fp=no ;;

  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
  | --no-cr | --no-c)
    no_create=yes ;;

  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
    no_recursion=yes ;;

  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
  | --oldin | --oldi | --old | --ol | --o)
    ac_prev=oldincludedir ;;
  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
    oldincludedir=$ac_optarg ;;

  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
    ac_prev=prefix ;;
  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
    prefix=$ac_optarg ;;

  -program-prefix | --program-prefix | --program-prefi | --program-pref \
  | --program-pre | --program-pr | --program-p)
    ac_prev=program_prefix ;;
  -program-prefix=* | --program-prefix=* | --program-prefi=* \
  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
    program_prefix=$ac_optarg ;;

  -program-suffix | --program-suffix | --program-suffi | --program-suff \
  | --program-suf | --program-su | --program-s)
    ac_prev=program_suffix ;;
  -program-suffix=* | --program-suffix=* | --program-suffi=* \
  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
    program_suffix=$ac_optarg ;;

  -program-transform-name | --program-transform-name \
  | --program-transform-nam | --program-transform-na \
  | --program-transform-n | --program-transform- \
  | --program-transform | --program-transfor \
  | --program-transfo | --program-transf \
  | --program-trans | --program-tran \
  | --progr-tra | --program-tr | --program-t)
    ac_prev=program_transform_name ;;
  -program-transform-name=* | --program-transform-name=* \
  | --program-transform-nam=* | --program-transform-na=* \
  | --program-transform-n=* | --program-transform-=* \
  | --program-transform=* | --program-transfor=* \
  | --program-transfo=* | --program-transf=* \
  | --program-trans=* | --program-tran=* \
  | --progr-tra=* | --program-tr=* | --program-t=*)
    program_transform_name=$ac_optarg ;;

  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
  | -silent | --silent | --silen | --sile | --sil)
    silent=yes ;;

  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
    ac_prev=sbindir ;;
  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
  | --sbi=* | --sb=*)
    sbindir=$ac_optarg ;;

  -sharedstatedir | --sharedstatedir | --sharedstatedi \
  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
  | --sharedst | --shareds | --shared | --share | --shar \
  | --sha | --sh)
    ac_prev=sharedstatedir ;;
  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
  | --sha=* | --sh=*)
    sharedstatedir=$ac_optarg ;;

  -site | --site | --sit)
    ac_prev=site ;;
  -site=* | --site=* | --sit=*)
    site=$ac_optarg ;;

  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
    ac_prev=srcdir ;;
  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
    srcdir=$ac_optarg ;;

  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
  | --syscon | --sysco | --sysc | --sys | --sy)
    ac_prev=sysconfdir ;;
  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
    sysconfdir=$ac_optarg ;;

  -target | --target | --targe | --targ | --tar | --ta | --t)
    ac_prev=target_alias ;;
  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
    target_alias=$ac_optarg ;;

  -v | -verbose | --verbose | --verbos | --verbo | --verb)
    verbose=yes ;;

  -version | --version | --versio | --versi | --vers | -V)
    ac_init_version=: ;;

  -with-* | --with-*)
    ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
    # Reject names that are not valid shell variable names.
    expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
      { echo "$as_me: error: invalid package name: $ac_package" >&2
   { (exit 1); exit 1; }; }
    ac_package=`echo $ac_package| sed 's/-/_/g'`
    case $ac_option in
      *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
      *) ac_optarg=yes ;;
    esac
    eval "with_$ac_package='$ac_optarg'" ;;

  -without-* | --without-*)
    ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
    # Reject names that are not valid shell variable names.
    expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
      { echo "$as_me: error: invalid package name: $ac_package" >&2
   { (exit 1); exit 1; }; }
    ac_package=`echo $ac_package | sed 's/-/_/g'`
    eval "with_$ac_package=no" ;;

  --x)
    # Obsolete; use --with-x.
    with_x=yes ;;

  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
  | --x-incl | --x-inc | --x-in | --x-i)
    ac_prev=x_includes ;;
  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
    x_includes=$ac_optarg ;;

  -x-libraries | --x-libraries | --x-librarie | --x-librari \
  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
    ac_prev=x_libraries ;;
  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
    x_libraries=$ac_optarg ;;

  -*) { echo "$as_me: error: unrecognized option: $ac_option
Try \`$0 --help' for more information." >&2
   { (exit 1); exit 1; }; }
    ;;

  *=*)
    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
    # Reject names that are not valid shell variable names.
    expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
      { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
   { (exit 1); exit 1; }; }
    ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
    eval "$ac_envvar='$ac_optarg'"
    export $ac_envvar ;;

  *)
    # FIXME: should be removed in autoconf 3.0.
    echo "$as_me: WARNING: you should use --build, --host, --target" >&2
    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
      echo "$as_me: WARNING: invalid host type: $ac_option" >&2
    : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
    ;;

  esac
done

if test -n "$ac_prev"; then
  ac_option=--`echo $ac_prev | sed 's/_/-/g'`
  { echo "$as_me: error: missing argument to $ac_option" >&2
   { (exit 1); exit 1; }; }
fi

# Be sure to have absolute paths.
for ac_var in exec_prefix prefix
do
  eval ac_val=$`echo $ac_var`
  case $ac_val in
    [\\/$]* | ?:[\\/]* | NONE | '' ) ;;
    *)  { echo "$as_me: error: expected an absolute path for --$ac_var: $ac_val" >&2
   { (exit 1); exit 1; }; };;
  esac
done

# Be sure to have absolute paths.
for ac_var in bindir sbindir libexecdir datarootdir datadir sysconfdir sharedstatedir \
              localstatedir libdir includedir oldincludedir infodir mandir
do
  eval ac_val=$`echo $ac_var`
  case $ac_val in
    [\\/$]* | ?:[\\/]* ) ;;
    *)  { echo "$as_me: error: expected an absolute path for --$ac_var: $ac_val" >&2
   { (exit 1); exit 1; }; };;
  esac
done

# There might be people who depend on the old broken behavior: `$host'
# used to hold the argument of --host etc.
build=$build_alias
host=$host_alias
target=$target_alias

# FIXME: should be removed in autoconf 3.0.
if test "x$host_alias" != x; then
  if test "x$build_alias" = x; then
    cross_compiling=maybe
    echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
    If a cross compiler is detected then cross compile mode will be used." >&2
  elif test "x$build_alias" != "x$host_alias"; then
    cross_compiling=yes
  fi
fi

ac_tool_prefix=
test -n "$host_alias" && ac_tool_prefix=$host_alias-

test "$silent" = yes && exec 6>/dev/null

# Find the source files, if location was not specified.
if test -z "$srcdir"; then
  ac_srcdir_defaulted=yes
  # Try the directory containing this script, then its parent.
  ac_prog=$0
  ac_confdir=`echo "$ac_prog" | sed 's%[\\/][^\\/][^\\/]*$%%'`
  test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
  srcdir=$ac_confdir
  if test ! -r $srcdir/$ac_unique_file; then
    srcdir=..
  fi
else
  ac_srcdir_defaulted=no
fi
if test ! -r $srcdir/$ac_unique_file; then
  if test "$ac_srcdir_defaulted" = yes; then
    { echo "$as_me: error: cannot find sources in $ac_confdir or .." >&2
   { (exit 1); exit 1; }; }
  else
    { echo "$as_me: error: cannot find sources in $srcdir" >&2
   { (exit 1); exit 1; }; }
  fi
fi
srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
ac_env_build_alias_set=${build_alias+set}
ac_env_build_alias_value=$build_alias
ac_cv_env_build_alias_set=${build_alias+set}
ac_cv_env_build_alias_value=$build_alias
ac_env_host_alias_set=${host_alias+set}
ac_env_host_alias_value=$host_alias
ac_cv_env_host_alias_set=${host_alias+set}
ac_cv_env_host_alias_value=$host_alias
ac_env_target_alias_set=${target_alias+set}
ac_env_target_alias_value=$target_alias
ac_cv_env_target_alias_set=${target_alias+set}
ac_cv_env_target_alias_value=$target_alias
ac_env_CC_set=${CC+set}
ac_env_CC_value=$CC
ac_cv_env_CC_set=${CC+set}
ac_cv_env_CC_value=$CC
ac_env_CFLAGS_set=${CFLAGS+set}
ac_env_CFLAGS_value=$CFLAGS
ac_cv_env_CFLAGS_set=${CFLAGS+set}
ac_cv_env_CFLAGS_value=$CFLAGS
ac_env_LDFLAGS_set=${LDFLAGS+set}
ac_env_LDFLAGS_value=$LDFLAGS
ac_cv_env_LDFLAGS_set=${LDFLAGS+set}
ac_cv_env_LDFLAGS_value=$LDFLAGS
ac_env_CPPFLAGS_set=${CPPFLAGS+set}
ac_env_CPPFLAGS_value=$CPPFLAGS
ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set}
ac_cv_env_CPPFLAGS_value=$CPPFLAGS
ac_env_CPP_set=${CPP+set}
ac_env_CPP_value=$CPP
ac_cv_env_CPP_set=${CPP+set}
ac_cv_env_CPP_value=$CPP

#
# Report the --help message.
#
if test "$ac_init_help" = "long"; then
  # Omit some internal or obsolete options to make the list less imposing.
  # This message is too long to be a string in the A/UX 3.1 sh.
  cat < if you have libraries in a
              nonstandard directory 
  CPPFLAGS    C/C++ preprocessor flags, e.g. -I if you have
              headers in a nonstandard directory 
  CPP         C preprocessor

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.

EOF
fi

if test "$ac_init_help" = "recursive"; then
  # If there are subdirs, report their specific --help.
  ac_popdir=`pwd`
  for ac_subdir in : $ac_subdirs_all; do test "x$ac_subdir" = x: && continue
    cd $ac_subdir
    # A "../" for each directory in /$ac_subdir.
    ac_dots=`echo $ac_subdir |
             sed 's,^\./,,;s,[^/]$,&/,;s,[^/]*/,../,g'`

    case $srcdir in
    .) # No --srcdir option.  We are building in place.
      ac_sub_srcdir=$srcdir ;;
    [\\/]* | ?:[\\/]* ) # Absolute path.
      ac_sub_srcdir=$srcdir/$ac_subdir ;;
    *) # Relative path.
      ac_sub_srcdir=$ac_dots$srcdir/$ac_subdir ;;
    esac

    # Check for guested configure; otherwise get Cygnus style configure.
    if test -f $ac_sub_srcdir/configure.gnu; then
      echo
      $SHELL $ac_sub_srcdir/configure.gnu  --help=recursive
    elif test -f $ac_sub_srcdir/configure; then
      echo
      $SHELL $ac_sub_srcdir/configure  --help=recursive
    elif test -f $ac_sub_srcdir/configure.ac ||
           test -f $ac_sub_srcdir/configure.in; then
      echo
      $ac_configure --help
    else
      echo "$as_me: WARNING: no configuration information is in $ac_subdir" >&2
    fi
    cd $ac_popdir
  done
fi

test -n "$ac_init_help" && exit 0
if $ac_init_version; then
  cat <<\EOF

Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
Free Software Foundation, Inc.
This configure script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it.
EOF
  exit 0
fi
exec 5>config.log
cat >&5 </dev/null | sed 1q`
uname -m = `(uname -m) 2>/dev/null || echo unknown`
uname -r = `(uname -r) 2>/dev/null || echo unknown`
uname -s = `(uname -s) 2>/dev/null || echo unknown`
uname -v = `(uname -v) 2>/dev/null || echo unknown`

/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`

/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
hostinfo               = `(hostinfo) 2>/dev/null               || echo unknown`
/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`

PATH = $PATH

_ASUNAME
} >&5

cat >&5 <\?\"\']*)
    ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"`
    ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
    ac_sep=" " ;;
  *) ac_configure_args="$ac_configure_args$ac_sep$ac_arg"
     ac_sep=" " ;;
  esac
  # Get rid of the leading space.
done

# When interrupted or exit'd, cleanup temporary files, and complete
# config.log.  We remove comments because anyway the quotes in there
# would cause problems or look ugly.
trap 'exit_status=$?
  # Save into config.log some information that might help in debugging.
  echo >&5
  echo "## ----------------- ##" >&5
  echo "## Cache variables.  ##" >&5
  echo "## ----------------- ##" >&5
  echo >&5
  # The following way of writing the cache mishandles newlines in values,
{
  (set) 2>&1 |
    case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in
    *ac_space=\ *)
      sed -n \
        "s/'"'"'/'"'"'\\\\'"'"''"'"'/g;
    	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p"
      ;;
    *)
      sed -n \
        "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
      ;;
    esac;
} >&5
  sed "/^$/d" confdefs.h >conftest.log
  if test -s conftest.log; then
    echo >&5
    echo "## ------------ ##" >&5
    echo "## confdefs.h.  ##" >&5
    echo "## ------------ ##" >&5
    echo >&5
    cat conftest.log >&5
  fi
  (echo; echo) >&5
  test "$ac_signal" != 0 &&
    echo "$as_me: caught signal $ac_signal" >&5
  echo "$as_me: exit $exit_status" >&5
  rm -rf conftest* confdefs* core core.* *.core conf$$* $ac_clean_files &&
    exit $exit_status
     ' 0
for ac_signal in 1 2 13 15; do
  trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
done
ac_signal=0

# confdefs.h avoids OS command line length limits that DEFS can exceed.
rm -rf conftest* confdefs.h
# AIX cpp loses on an empty file, so make sure it contains at least a newline.
echo >confdefs.h

# Let the site file select an alternate cache file if it wants to.
# Prefer explicitly selected file to automatically selected ones.
if test -z "$CONFIG_SITE"; then
  if test "x$prefix" != xNONE; then
    CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
  else
    CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
  fi
fi
for ac_site_file in $CONFIG_SITE; do
  if test -r "$ac_site_file"; then
    { echo "$as_me:999: loading site script $ac_site_file" >&5
echo "$as_me: loading site script $ac_site_file" >&6;}
    cat "$ac_site_file" >&5
    . "$ac_site_file"
  fi
done

if test -r "$cache_file"; then
  # Some versions of bash will fail to source /dev/null (special
  # files actually), so we avoid doing that.
  if test -f "$cache_file"; then
    { echo "$as_me:1010: loading cache $cache_file" >&5
echo "$as_me: loading cache $cache_file" >&6;}
    case $cache_file in
      [\\/]* | ?:[\\/]* ) . $cache_file;;
      *)                      . ./$cache_file;;
    esac
  fi
else
  { echo "$as_me:1018: creating cache $cache_file" >&5
echo "$as_me: creating cache $cache_file" >&6;}
  >$cache_file
fi

# Check that the precious variables saved in the cache have kept the same
# value.
ac_cache_corrupted=false
for ac_var in `(set) 2>&1 |
               sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do
  eval ac_old_set=\$ac_cv_env_${ac_var}_set
  eval ac_new_set=\$ac_env_${ac_var}_set
  eval ac_old_val="\$ac_cv_env_${ac_var}_value"
  eval ac_new_val="\$ac_env_${ac_var}_value"
  case $ac_old_set,$ac_new_set in
    set,)
      { echo "$as_me:1034: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
      ac_cache_corrupted=: ;;
    ,set)
      { echo "$as_me:1038: error: \`$ac_var' was not set in the previous run" >&5
echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
      ac_cache_corrupted=: ;;
    ,);;
    *)
      if test "x$ac_old_val" != "x$ac_new_val"; then
        { echo "$as_me:1044: error: \`$ac_var' has changed since the previous run:" >&5
echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
        { echo "$as_me:1046:   former value:  $ac_old_val" >&5
echo "$as_me:   former value:  $ac_old_val" >&2;}
        { echo "$as_me:1048:   current value: $ac_new_val" >&5
echo "$as_me:   current value: $ac_new_val" >&2;}
        ac_cache_corrupted=:
      fi;;
  esac
  # Pass precious variables to config.status.  It doesn't matter if
  # we pass some twice (in addition to the command line arguments).
  if test "$ac_new_set" = set; then
    case $ac_new_val in
    *" "*|*"	"*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
      ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"`
      ac_configure_args="$ac_configure_args '$ac_arg'"
      ;;
    *) ac_configure_args="$ac_configure_args $ac_var=$ac_new_val"
       ;;
    esac
  fi
done
if $ac_cache_corrupted; then
  { echo "$as_me:1067: error: changes in the environment can compromise the build" >&5
echo "$as_me: error: changes in the environment can compromise the build" >&2;}
  { { echo "$as_me:1069: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
   { (exit 1); exit 1; }; }
fi

ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_main_return=return

case `echo "testing\c" 2>/dev/null; echo 1,2,3`,`echo -n testing 2>/dev/null; echo 1,2,3` in
  *c*,-n*) ECHO_N= ECHO_C=	# newlines do not sed ;-) only broken shells would use this case anyway
		   ECHO_T='	' ;;
  *c*,*  ) ECHO_N=-n ECHO_C= ECHO_T= ;;
  *)      ECHO_N= ECHO_C='\c' ECHO_T= ;;
esac
echo "#! $SHELL" >conftest.sh
echo  "exit 0"   >>conftest.sh
chmod +x conftest.sh
if { (echo "$as_me:1090: PATH=\".;.\"; conftest.sh") >&5
  (PATH=".;."; conftest.sh) 2>&5
  ac_status=$?
  echo "$as_me:1093: \$? = $ac_status" >&5
  (exit $ac_status); }; then
  ac_path_separator=';'
else
  ac_path_separator=:
fi
PATH_SEPARATOR="$ac_path_separator"
rm -f conftest.sh

ac_config_headers="$ac_config_headers xtermcfg.h:xtermcfg.hin"

ac_aux_dir=
for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
  if test -f $ac_dir/install-sh; then
    ac_aux_dir=$ac_dir
    ac_install_sh="$ac_aux_dir/install-sh -c"
    break
  elif test -f $ac_dir/install.sh; then
    ac_aux_dir=$ac_dir
    ac_install_sh="$ac_aux_dir/install.sh -c"
    break
  elif test -f $ac_dir/shtool; then
    ac_aux_dir=$ac_dir
    ac_install_sh="$ac_aux_dir/shtool install -c"
    break
  fi
done
if test -z "$ac_aux_dir"; then
  { { echo "$as_me:1121: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;}
   { (exit 1); exit 1; }; }
fi
ac_config_guess="$SHELL $ac_aux_dir/config.guess"
ac_config_sub="$SHELL $ac_aux_dir/config.sub"
ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.

# Make sure we can run config.sub.
$ac_config_sub sun4 >/dev/null 2>&1 ||
  { { echo "$as_me:1131: error: cannot run $ac_config_sub" >&5
echo "$as_me: error: cannot run $ac_config_sub" >&2;}
   { (exit 1); exit 1; }; }

echo "$as_me:1135: checking build system type" >&5
echo $ECHO_N "checking build system type... $ECHO_C" >&6
if test "${ac_cv_build+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_cv_build_alias=$build_alias
test -z "$ac_cv_build_alias" &&
  ac_cv_build_alias=`$ac_config_guess`
test -z "$ac_cv_build_alias" &&
  { { echo "$as_me:1144: error: cannot guess build type; you must specify one" >&5
echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
   { (exit 1); exit 1; }; }
ac_cv_build=`$ac_config_sub $ac_cv_build_alias` ||
  { { echo "$as_me:1148: error: $ac_config_sub $ac_cv_build_alias failed." >&5
echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed." >&2;}
   { (exit 1); exit 1; }; }

fi
echo "$as_me:1153: result: $ac_cv_build" >&5
echo "${ECHO_T}$ac_cv_build" >&6
build=$ac_cv_build
build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`

if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
	echo "$as_me:1161: checking host system type" >&5
echo $ECHO_N "checking host system type... $ECHO_C" >&6
if test "${ac_cv_host+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_cv_host_alias=$host_alias
test -z "$ac_cv_host_alias" &&
  ac_cv_host_alias=$ac_cv_build_alias
ac_cv_host=`$ac_config_sub $ac_cv_host_alias` ||
  { { echo "$as_me:1170: error: $ac_config_sub $ac_cv_host_alias failed" >&5
echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;}
   { (exit 1); exit 1; }; }

fi
echo "$as_me:1175: result: $ac_cv_host" >&5
echo "${ECHO_T}$ac_cv_host" >&6
host=$ac_cv_host
host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`

	system_name="$host_os"
else
	system_name="`(uname -s -r) 2>/dev/null`"
	if test -z "$system_name" ; then
		system_name="`(hostname) 2>/dev/null`"
	fi
fi
test -n "$system_name" &&
cat >>confdefs.h <&6
else
  cf_cv_system_name="$system_name"
fi

test -z "$system_name" && system_name="$cf_cv_system_name"
test -n "$cf_cv_system_name" && echo "$as_me:1201: result: Configuring for $cf_cv_system_name" >&5
echo "${ECHO_T}Configuring for $cf_cv_system_name" >&6

if test ".$system_name" != ".$cf_cv_system_name" ; then
	echo "$as_me:1205: result: Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&5
echo "${ECHO_T}Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&6
	{ { echo "$as_me:1207: error: \"Please remove config.cache and try again.\"" >&5
echo "$as_me: error: \"Please remove config.cache and try again.\"" >&2;}
   { (exit 1); exit 1; }; }
fi

###	checks for alternative programs

case "$host_os" in
(openedition)	: ${CFLAGS="-O2 -Wc,dll -Wl,EDIT=NO"}
		: ${CPPFLAGS="-D_ALL_SOURCE"}
		: ${LIBS="/usr/lib/Xaw.x /usr/lib/SM.x /usr/lib/ICE.x /usr/lib/X11.x"}
		: ${CC=c89};;
(darwin*)
		: ${LDFLAGS}="${LDFLAGS} -Wl,-bind_at_load";;
esac

ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_main_return=return
if test -n "$ac_tool_prefix"; then
  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
set dummy ${ac_tool_prefix}gcc; ac_word=$2
echo "$as_me:1232: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_CC+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  if test -n "$CC"; then
  ac_cv_prog_CC="$CC" # Let the user override the test.
else
  ac_save_IFS=$IFS; IFS=$ac_path_separator
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
  IFS=$ac_save_IFS
  test -z "$ac_dir" && ac_dir=.
  $as_executable_p "$ac_dir/$ac_word" || continue
ac_cv_prog_CC="${ac_tool_prefix}gcc"
echo "$as_me:1247: found $ac_dir/$ac_word" >&5
break
done

fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
  echo "$as_me:1255: result: $CC" >&5
echo "${ECHO_T}$CC" >&6
else
  echo "$as_me:1258: result: no" >&5
echo "${ECHO_T}no" >&6
fi

fi
if test -z "$ac_cv_prog_CC"; then
  ac_ct_CC=$CC
  # Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
echo "$as_me:1267: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  if test -n "$ac_ct_CC"; then
  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
else
  ac_save_IFS=$IFS; IFS=$ac_path_separator
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
  IFS=$ac_save_IFS
  test -z "$ac_dir" && ac_dir=.
  $as_executable_p "$ac_dir/$ac_word" || continue
ac_cv_prog_ac_ct_CC="gcc"
echo "$as_me:1282: found $ac_dir/$ac_word" >&5
break
done

fi
fi
ac_ct_CC=$ac_cv_prog_ac_ct_CC
if test -n "$ac_ct_CC"; then
  echo "$as_me:1290: result: $ac_ct_CC" >&5
echo "${ECHO_T}$ac_ct_CC" >&6
else
  echo "$as_me:1293: result: no" >&5
echo "${ECHO_T}no" >&6
fi

  CC=$ac_ct_CC
else
  CC="$ac_cv_prog_CC"
fi

if test -z "$CC"; then
  if test -n "$ac_tool_prefix"; then
  # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
set dummy ${ac_tool_prefix}cc; ac_word=$2
echo "$as_me:1306: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_CC+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  if test -n "$CC"; then
  ac_cv_prog_CC="$CC" # Let the user override the test.
else
  ac_save_IFS=$IFS; IFS=$ac_path_separator
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
  IFS=$ac_save_IFS
  test -z "$ac_dir" && ac_dir=.
  $as_executable_p "$ac_dir/$ac_word" || continue
ac_cv_prog_CC="${ac_tool_prefix}cc"
echo "$as_me:1321: found $ac_dir/$ac_word" >&5
break
done

fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
  echo "$as_me:1329: result: $CC" >&5
echo "${ECHO_T}$CC" >&6
else
  echo "$as_me:1332: result: no" >&5
echo "${ECHO_T}no" >&6
fi

fi
if test -z "$ac_cv_prog_CC"; then
  ac_ct_CC=$CC
  # Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo "$as_me:1341: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  if test -n "$ac_ct_CC"; then
  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
else
  ac_save_IFS=$IFS; IFS=$ac_path_separator
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
  IFS=$ac_save_IFS
  test -z "$ac_dir" && ac_dir=.
  $as_executable_p "$ac_dir/$ac_word" || continue
ac_cv_prog_ac_ct_CC="cc"
echo "$as_me:1356: found $ac_dir/$ac_word" >&5
break
done

fi
fi
ac_ct_CC=$ac_cv_prog_ac_ct_CC
if test -n "$ac_ct_CC"; then
  echo "$as_me:1364: result: $ac_ct_CC" >&5
echo "${ECHO_T}$ac_ct_CC" >&6
else
  echo "$as_me:1367: result: no" >&5
echo "${ECHO_T}no" >&6
fi

  CC=$ac_ct_CC
else
  CC="$ac_cv_prog_CC"
fi

fi
if test -z "$CC"; then
  # Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo "$as_me:1380: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_CC+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  if test -n "$CC"; then
  ac_cv_prog_CC="$CC" # Let the user override the test.
else
  ac_prog_rejected=no
  ac_save_IFS=$IFS; IFS=$ac_path_separator
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
  IFS=$ac_save_IFS
  test -z "$ac_dir" && ac_dir=.
  $as_executable_p "$ac_dir/$ac_word" || continue
if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
  ac_prog_rejected=yes
  continue
fi
ac_cv_prog_CC="cc"
echo "$as_me:1400: found $ac_dir/$ac_word" >&5
break
done

if test $ac_prog_rejected = yes; then
  # We found a bogon in the path, so make sure we never use it.
  set dummy $ac_cv_prog_CC
  shift
  if test $# != 0; then
    # We chose a different compiler from the bogus one.
    # However, it has the same basename, so the bogon will be chosen
    # first if we set CC to just the basename; use the full file name.
    shift
    set dummy "$ac_dir/$ac_word" ${1+"$@"}
    shift
    ac_cv_prog_CC="$@"
  fi
fi
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
  echo "$as_me:1422: result: $CC" >&5
echo "${ECHO_T}$CC" >&6
else
  echo "$as_me:1425: result: no" >&5
echo "${ECHO_T}no" >&6
fi

fi
if test -z "$CC"; then
  if test -n "$ac_tool_prefix"; then
  for ac_prog in cl
  do
    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
set dummy $ac_tool_prefix$ac_prog; ac_word=$2
echo "$as_me:1436: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_CC+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  if test -n "$CC"; then
  ac_cv_prog_CC="$CC" # Let the user override the test.
else
  ac_save_IFS=$IFS; IFS=$ac_path_separator
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
  IFS=$ac_save_IFS
  test -z "$ac_dir" && ac_dir=.
  $as_executable_p "$ac_dir/$ac_word" || continue
ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
echo "$as_me:1451: found $ac_dir/$ac_word" >&5
break
done

fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
  echo "$as_me:1459: result: $CC" >&5
echo "${ECHO_T}$CC" >&6
else
  echo "$as_me:1462: result: no" >&5
echo "${ECHO_T}no" >&6
fi

    test -n "$CC" && break
  done
fi
if test -z "$CC"; then
  ac_ct_CC=$CC
  for ac_prog in cl
do
  # Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo "$as_me:1475: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  if test -n "$ac_ct_CC"; then
  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
else
  ac_save_IFS=$IFS; IFS=$ac_path_separator
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
  IFS=$ac_save_IFS
  test -z "$ac_dir" && ac_dir=.
  $as_executable_p "$ac_dir/$ac_word" || continue
ac_cv_prog_ac_ct_CC="$ac_prog"
echo "$as_me:1490: found $ac_dir/$ac_word" >&5
break
done

fi
fi
ac_ct_CC=$ac_cv_prog_ac_ct_CC
if test -n "$ac_ct_CC"; then
  echo "$as_me:1498: result: $ac_ct_CC" >&5
echo "${ECHO_T}$ac_ct_CC" >&6
else
  echo "$as_me:1501: result: no" >&5
echo "${ECHO_T}no" >&6
fi

  test -n "$ac_ct_CC" && break
done

  CC=$ac_ct_CC
fi

fi

test -z "$CC" && { { echo "$as_me:1513: error: no acceptable cc found in \$PATH" >&5
echo "$as_me: error: no acceptable cc found in \$PATH" >&2;}
   { (exit 1); exit 1; }; }

# Provide some information about the compiler.
echo "$as_me:1518:" \
     "checking for C compiler version" >&5
ac_compiler=`set X $ac_compile; echo $2`
{ (eval echo "$as_me:1521: \"$ac_compiler --version &5\"") >&5
  (eval $ac_compiler --version &5) 2>&5
  ac_status=$?
  echo "$as_me:1524: \$? = $ac_status" >&5
  (exit $ac_status); }
{ (eval echo "$as_me:1526: \"$ac_compiler -v &5\"") >&5
  (eval $ac_compiler -v &5) 2>&5
  ac_status=$?
  echo "$as_me:1529: \$? = $ac_status" >&5
  (exit $ac_status); }
{ (eval echo "$as_me:1531: \"$ac_compiler -V &5\"") >&5
  (eval $ac_compiler -V &5) 2>&5
  ac_status=$?
  echo "$as_me:1534: \$? = $ac_status" >&5
  (exit $ac_status); }

cat >conftest.$ac_ext <<_ACEOF
#line 1538 "configure"
#include "confdefs.h"

int
main (void)
{

  ;
  return 0;
}
_ACEOF
ac_clean_files_save=$ac_clean_files
ac_clean_files="$ac_clean_files a.out a.exe"
# Try to create an executable without -o first, disregard a.out.
# It will help us diagnose broken compilers, and finding out an intuition
# of exeext.
echo "$as_me:1554: checking for C compiler default output" >&5
echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6
ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
if { (eval echo "$as_me:1557: \"$ac_link_default\"") >&5
  (eval $ac_link_default) 2>&5
  ac_status=$?
  echo "$as_me:1560: \$? = $ac_status" >&5
  (exit $ac_status); }; then
  # Find the output, starting from the most likely.  This scheme is
# not robust to junk in `.', hence go to wildcards (a.*) only as a last
# resort.
for ac_file in `ls a.exe conftest.exe 2>/dev/null;
                ls a.out conftest 2>/dev/null;
                ls a.* conftest.* 2>/dev/null`; do
  case $ac_file in
    *.$ac_ext | *.xcoff | *.tds | *.d | *.dbg | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;;
    a.out ) # We found the default executable, but exeext='' is most
            # certainly right.
            break;;
    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
          # FIXME: I believe we export ac_cv_exeext for Libtool --akim.
          export ac_cv_exeext
          break;;
    * ) break;;
  esac
done
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
{ { echo "$as_me:1583: error: C compiler cannot create executables" >&5
echo "$as_me: error: C compiler cannot create executables" >&2;}
   { (exit 77); exit 77; }; }
fi

ac_exeext=$ac_cv_exeext
echo "$as_me:1589: result: $ac_file" >&5
echo "${ECHO_T}$ac_file" >&6

# Check the compiler produces executables we can run.  If not, either
# the compiler is broken, or we cross compile.
echo "$as_me:1594: checking whether the C compiler works" >&5
echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
# If not cross compiling, check that we can run a simple program.
if test "$cross_compiling" != yes; then
  if { ac_try='./$ac_file'
  { (eval echo "$as_me:1600: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:1603: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
    cross_compiling=no
  else
    if test "$cross_compiling" = maybe; then
	cross_compiling=yes
    else
	{ { echo "$as_me:1610: error: cannot run C compiled programs.
If you meant to cross compile, use \`--host'." >&5
echo "$as_me: error: cannot run C compiled programs.
If you meant to cross compile, use \`--host'." >&2;}
   { (exit 1); exit 1; }; }
    fi
  fi
fi
echo "$as_me:1618: result: yes" >&5
echo "${ECHO_T}yes" >&6

rm -f a.out a.exe conftest$ac_cv_exeext
ac_clean_files=$ac_clean_files_save
# Check the compiler produces executables we can run.  If not, either
# the compiler is broken, or we cross compile.
echo "$as_me:1625: checking whether we are cross compiling" >&5
echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
echo "$as_me:1627: result: $cross_compiling" >&5
echo "${ECHO_T}$cross_compiling" >&6

echo "$as_me:1630: checking for executable suffix" >&5
echo $ECHO_N "checking for executable suffix... $ECHO_C" >&6
if { (eval echo "$as_me:1632: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:1635: \$? = $ac_status" >&5
  (exit $ac_status); }; then
  # If both `conftest.exe' and `conftest' are `present' (well, observable)
# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
# work properly (i.e., refer to `conftest.exe'), while it won't with
# `rm'.
for ac_file in `(ls conftest.exe; ls conftest; ls conftest.*) 2>/dev/null`; do
  case $ac_file in
    *.$ac_ext | *.xcoff | *.tds | *.d | *.dbg | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;;
    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
          export ac_cv_exeext
          break;;
    * ) break;;
  esac
done
else
  { { echo "$as_me:1651: error: cannot compute EXEEXT: cannot compile and link" >&5
echo "$as_me: error: cannot compute EXEEXT: cannot compile and link" >&2;}
   { (exit 1); exit 1; }; }
fi

rm -f conftest$ac_cv_exeext
echo "$as_me:1657: result: $ac_cv_exeext" >&5
echo "${ECHO_T}$ac_cv_exeext" >&6

rm -f conftest.$ac_ext
EXEEXT=$ac_cv_exeext
ac_exeext=$EXEEXT
echo "$as_me:1663: checking for object suffix" >&5
echo $ECHO_N "checking for object suffix... $ECHO_C" >&6
if test "${ac_cv_objext+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 1669 "configure"
#include "confdefs.h"

int
main (void)
{

  ;
  return 0;
}
_ACEOF
rm -f conftest.o conftest.obj
if { (eval echo "$as_me:1681: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:1684: \$? = $ac_status" >&5
  (exit $ac_status); }; then
  for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
  case $ac_file in
    *.$ac_ext | *.xcoff | *.tds | *.d | *.dbg | *.pdb | *.xSYM | *.map | *.inf ) ;;
    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
       break;;
  esac
done
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
{ { echo "$as_me:1696: error: cannot compute OBJEXT: cannot compile" >&5
echo "$as_me: error: cannot compute OBJEXT: cannot compile" >&2;}
   { (exit 1); exit 1; }; }
fi

rm -f conftest.$ac_cv_objext conftest.$ac_ext
fi
echo "$as_me:1703: result: $ac_cv_objext" >&5
echo "${ECHO_T}$ac_cv_objext" >&6
OBJEXT=$ac_cv_objext
ac_objext=$OBJEXT
echo "$as_me:1707: checking whether we are using the GNU C compiler" >&5
echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
if test "${ac_cv_c_compiler_gnu+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 1713 "configure"
#include "confdefs.h"

int
main (void)
{
#ifndef __GNUC__
       choke me
#endif

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:1728: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:1731: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:1734: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:1737: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_compiler_gnu=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_compiler_gnu=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext
ac_cv_c_compiler_gnu=$ac_compiler_gnu

fi
echo "$as_me:1749: result: $ac_cv_c_compiler_gnu" >&5
echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
GCC=`test $ac_compiler_gnu = yes && echo yes`
ac_test_CFLAGS=${CFLAGS+set}
ac_save_CFLAGS=$CFLAGS
CFLAGS="-g"
echo "$as_me:1755: checking whether $CC accepts -g" >&5
echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
if test "${ac_cv_prog_cc_g+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 1761 "configure"
#include "confdefs.h"

int
main (void)
{

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:1773: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:1776: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:1779: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:1782: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_prog_cc_g=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_prog_cc_g=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:1792: result: $ac_cv_prog_cc_g" >&5
echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
if test "$ac_test_CFLAGS" = set; then
  CFLAGS=$ac_save_CFLAGS
elif test $ac_cv_prog_cc_g = yes; then
  if test "$GCC" = yes; then
    CFLAGS="-g -O2"
  else
    CFLAGS="-g"
  fi
else
  if test "$GCC" = yes; then
    CFLAGS="-O2"
  else
    CFLAGS=
  fi
fi
# Some people use a C++ compiler to compile C.  Since we use `exit',
# in C++ we need to declare it.  In case someone uses the same compiler
# for both compiling C and C++ we need to have the C++ compiler decide
# the declaration of exit, since it's the most demanding environment.
cat >conftest.$ac_ext <<_ACEOF
#ifndef __cplusplus
  choke me
#endif
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:1819: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:1822: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:1825: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:1828: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  for ac_declaration in \
   ''\
   '#include ' \
   'extern "C" void std::exit (int) throw (); using std::exit;' \
   'extern "C" void std::exit (int); using std::exit;' \
   'extern "C" void exit (int) throw ();' \
   'extern "C" void exit (int);' \
   'void exit (int);'
do
  cat >conftest.$ac_ext <<_ACEOF
#line 1840 "configure"
#include "confdefs.h"
#include 
$ac_declaration
int
main (void)
{
exit (42);
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:1853: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:1856: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:1859: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:1862: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  :
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
continue
fi
rm -f conftest.$ac_objext conftest.$ac_ext
  cat >conftest.$ac_ext <<_ACEOF
#line 1872 "configure"
#include "confdefs.h"
$ac_declaration
int
main (void)
{
exit (42);
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:1884: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:1887: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:1890: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:1893: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  break
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
fi
rm -f conftest.$ac_objext conftest.$ac_ext
done
rm -rf conftest*
if test -n "$ac_declaration"; then
  echo '#ifdef __cplusplus' >>confdefs.h
  echo $ac_declaration      >>confdefs.h
  echo '#endif'             >>confdefs.h
fi

else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
fi
rm -f conftest.$ac_objext conftest.$ac_ext
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_main_return=return

GCC_VERSION=none
if test "$GCC" = yes ; then
	echo "$as_me:1923: checking version of $CC" >&5
echo $ECHO_N "checking version of $CC... $ECHO_C" >&6
	GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC[^)]*) //' -e 's/^.*(Debian[^)]*) //' -e 's/^[^0-9.]*//' -e 's/[^0-9.].*//'`"
	test -z "$GCC_VERSION" && GCC_VERSION=unknown
	echo "$as_me:1927: result: $GCC_VERSION" >&5
echo "${ECHO_T}$GCC_VERSION" >&6
fi

echo "$as_me:1931: checking for $CC option to accept ANSI C" >&5
echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
if test "${ac_cv_prog_cc_stdc+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_cv_prog_cc_stdc=no
ac_save_CC=$CC
cat >conftest.$ac_ext <<_ACEOF
#line 1939 "configure"
#include "confdefs.h"
#include 
#include 
#include 
#include 
/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
struct buf { int x; };
FILE * (*rcsopen) (struct buf *, struct stat *, int);
static char *e (p, i)
     char **p;
     int i;
{
  return p[i];
}
static char *f (char * (*g) (char **, int), char **p, ...)
{
  char *s;
  va_list v;
  va_start (v,p);
  s = g (p, va_arg (v,int));
  va_end (v);
  return s;
}
int test (int i, double x);
struct s1 {int (*f) (int a);};
struct s2 {int (*f) (double a);};
int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
int argc;
char **argv;
int
main (void)
{
return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
  ;
  return 0;
}
_ACEOF
# Don't try gcc -ansi; that turns off useful extensions and
# breaks some systems' header files.
# AIX			-qlanglvl=ansi
# Ultrix and OSF/1	-std1
# HP-UX 10.20 and later	-Ae
# HP-UX older versions	-Aa -D_HPUX_SOURCE
# SVR4			-Xc -D__EXTENSIONS__
for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
do
  CC="$ac_save_CC $ac_arg"
  rm -f conftest.$ac_objext
if { (eval echo "$as_me:1988: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:1991: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:1994: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:1997: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_prog_cc_stdc=$ac_arg
break
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
fi
rm -f conftest.$ac_objext
done
rm -f conftest.$ac_ext conftest.$ac_objext
CC=$ac_save_CC

fi

case "x$ac_cv_prog_cc_stdc" in
  x|xno)
    echo "$as_me:2014: result: none needed" >&5
echo "${ECHO_T}none needed" >&6 ;;
  *)
    echo "$as_me:2017: result: $ac_cv_prog_cc_stdc" >&5
echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
    CC="$CC $ac_cv_prog_cc_stdc" ;;
esac

# This should have been defined by AC_PROG_CC
: ${CC:=cc}

echo "$as_me:2025: checking \$CC variable" >&5
echo $ECHO_N "checking \$CC variable... $ECHO_C" >&6
case "$CC" in
(*[\ \	]-*)
	echo "$as_me:2029: result: broken" >&5
echo "${ECHO_T}broken" >&6
	{ echo "$as_me:2031: WARNING: your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options" >&5
echo "$as_me: WARNING: your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options" >&2;}
	# humor him...
	cf_prog=`echo "$CC" | sed -e 's/	/ /g' -e 's/[ ]* / /g' -e 's/[ ]*[ ]-[^ ].*//'`
	cf_flags=`echo "$CC" | ${AWK:-awk} -v prog="$cf_prog" '{ printf("%s", substr($0,1+length(prog))); }'`
	CC="$cf_prog"
	for cf_arg in $cf_flags
	do
		case "x$cf_arg" in
		(x-[IUDfgOW]*)

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_arg
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

			;;
		(*)
			CC="$CC $cf_arg"
			;;
		esac
	done
	test -n "$verbose" && echo "	resulting CC: '$CC'" 1>&6

echo "${as_me:-configure}:2148: testing resulting CC: '$CC' ..." 1>&5

	test -n "$verbose" && echo "	resulting CFLAGS: '$CFLAGS'" 1>&6

echo "${as_me:-configure}:2152: testing resulting CFLAGS: '$CFLAGS' ..." 1>&5

	test -n "$verbose" && echo "	resulting CPPFLAGS: '$CPPFLAGS'" 1>&6

echo "${as_me:-configure}:2156: testing resulting CPPFLAGS: '$CPPFLAGS' ..." 1>&5

	;;
(*)
	echo "$as_me:2160: result: ok" >&5
echo "${ECHO_T}ok" >&6
	;;
esac

ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_main_return=return
echo "$as_me:2171: checking how to run the C preprocessor" >&5
echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
  CPP=
fi
if test -z "$CPP"; then
  if test "${ac_cv_prog_CPP+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
      # Double quotes because CPP needs to be expanded
    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
    do
      ac_preproc_ok=false
for ac_c_preproc_warn_flag in '' yes
do
  # Use a header file that comes with gcc, so configuring glibc
  # with a fresh cross-compiler works.
  # On the NeXT, cc -E runs the code through the compiler's parser,
  # not just through cpp. "Syntax error" is here to catch this case.
  cat >conftest.$ac_ext <<_ACEOF
#line 2192 "configure"
#include "confdefs.h"
#include 
                     Syntax error
_ACEOF
if { (eval echo "$as_me:2197: \"$ac_cpp conftest.$ac_ext\"") >&5
  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
  ac_status=$?
  egrep -v '^ *\+' conftest.er1 >conftest.err
  rm -f conftest.er1
  cat conftest.err >&5
  echo "$as_me:2203: \$? = $ac_status" >&5
  (exit $ac_status); } >/dev/null; then
  if test -s conftest.err; then
    ac_cpp_err=$ac_c_preproc_warn_flag
  else
    ac_cpp_err=
  fi
else
  ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
  :
else
  echo "$as_me: failed program was:" >&5
  cat conftest.$ac_ext >&5
  # Broken: fails on valid input.
continue
fi
rm -f conftest.err conftest.$ac_ext

  # OK, works on sane cases.  Now check whether non-existent headers
  # can be detected and how.
  cat >conftest.$ac_ext <<_ACEOF
#line 2226 "configure"
#include "confdefs.h"
#include 
_ACEOF
if { (eval echo "$as_me:2230: \"$ac_cpp conftest.$ac_ext\"") >&5
  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
  ac_status=$?
  egrep -v '^ *\+' conftest.er1 >conftest.err
  rm -f conftest.er1
  cat conftest.err >&5
  echo "$as_me:2236: \$? = $ac_status" >&5
  (exit $ac_status); } >/dev/null; then
  if test -s conftest.err; then
    ac_cpp_err=$ac_c_preproc_warn_flag
  else
    ac_cpp_err=
  fi
else
  ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
  # Broken: success on invalid input.
continue
else
  echo "$as_me: failed program was:" >&5
  cat conftest.$ac_ext >&5
  # Passes both tests.
ac_preproc_ok=:
break
fi
rm -f conftest.err conftest.$ac_ext

done
# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
rm -f conftest.err conftest.$ac_ext
if $ac_preproc_ok; then
  break
fi

    done
    ac_cv_prog_CPP=$CPP

fi
  CPP=$ac_cv_prog_CPP
else
  ac_cv_prog_CPP=$CPP
fi
echo "$as_me:2273: result: $CPP" >&5
echo "${ECHO_T}$CPP" >&6
ac_preproc_ok=false
for ac_c_preproc_warn_flag in '' yes
do
  # Use a header file that comes with gcc, so configuring glibc
  # with a fresh cross-compiler works.
  # On the NeXT, cc -E runs the code through the compiler's parser,
  # not just through cpp. "Syntax error" is here to catch this case.
  cat >conftest.$ac_ext <<_ACEOF
#line 2283 "configure"
#include "confdefs.h"
#include 
                     Syntax error
_ACEOF
if { (eval echo "$as_me:2288: \"$ac_cpp conftest.$ac_ext\"") >&5
  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
  ac_status=$?
  egrep -v '^ *\+' conftest.er1 >conftest.err
  rm -f conftest.er1
  cat conftest.err >&5
  echo "$as_me:2294: \$? = $ac_status" >&5
  (exit $ac_status); } >/dev/null; then
  if test -s conftest.err; then
    ac_cpp_err=$ac_c_preproc_warn_flag
  else
    ac_cpp_err=
  fi
else
  ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
  :
else
  echo "$as_me: failed program was:" >&5
  cat conftest.$ac_ext >&5
  # Broken: fails on valid input.
continue
fi
rm -f conftest.err conftest.$ac_ext

  # OK, works on sane cases.  Now check whether non-existent headers
  # can be detected and how.
  cat >conftest.$ac_ext <<_ACEOF
#line 2317 "configure"
#include "confdefs.h"
#include 
_ACEOF
if { (eval echo "$as_me:2321: \"$ac_cpp conftest.$ac_ext\"") >&5
  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
  ac_status=$?
  egrep -v '^ *\+' conftest.er1 >conftest.err
  rm -f conftest.er1
  cat conftest.err >&5
  echo "$as_me:2327: \$? = $ac_status" >&5
  (exit $ac_status); } >/dev/null; then
  if test -s conftest.err; then
    ac_cpp_err=$ac_c_preproc_warn_flag
  else
    ac_cpp_err=
  fi
else
  ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
  # Broken: success on invalid input.
continue
else
  echo "$as_me: failed program was:" >&5
  cat conftest.$ac_ext >&5
  # Passes both tests.
ac_preproc_ok=:
break
fi
rm -f conftest.err conftest.$ac_ext

done
# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
rm -f conftest.err conftest.$ac_ext
if $ac_preproc_ok; then
  :
else
  { { echo "$as_me:2355: error: C preprocessor \"$CPP\" fails sanity check" >&5
echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check" >&2;}
   { (exit 1); exit 1; }; }
fi

ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_main_return=return

for ac_prog in mawk gawk nawk awk
do
  # Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo "$as_me:2371: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_AWK+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  if test -n "$AWK"; then
  ac_cv_prog_AWK="$AWK" # Let the user override the test.
else
  ac_save_IFS=$IFS; IFS=$ac_path_separator
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
  IFS=$ac_save_IFS
  test -z "$ac_dir" && ac_dir=.
  $as_executable_p "$ac_dir/$ac_word" || continue
ac_cv_prog_AWK="$ac_prog"
echo "$as_me:2386: found $ac_dir/$ac_word" >&5
break
done

fi
fi
AWK=$ac_cv_prog_AWK
if test -n "$AWK"; then
  echo "$as_me:2394: result: $AWK" >&5
echo "${ECHO_T}$AWK" >&6
else
  echo "$as_me:2397: result: no" >&5
echo "${ECHO_T}no" >&6
fi

  test -n "$AWK" && break
done

# Find a good install program.  We prefer a C program (faster),
# so one script is as good as another.  But avoid the broken or
# incompatible versions:
# SysV /etc/install, /usr/sbin/install
# SunOS /usr/etc/install
# IRIX /sbin/install
# AIX /bin/install
# AmigaOS /C/install, which installs bootblocks on floppy discs
# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
# AFS /usr/afsws/bin/install, which mishandles nonexistent args
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo "$as_me:2416: checking for a BSD compatible install" >&5
echo $ECHO_N "checking for a BSD compatible install... $ECHO_C" >&6
if test -z "$INSTALL"; then
if test "${ac_cv_path_install+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
    ac_save_IFS=$IFS; IFS=$ac_path_separator
  for ac_dir in $PATH; do
    IFS=$ac_save_IFS
    # Account for people who put trailing slashes in PATH elements.
    case $ac_dir/ in
    / | ./ | .// | /cC/* \
    | /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* \
    | /usr/ucb/* ) ;;
    *)
      # OSF1 and SCO ODT 3.0 have their own names for install.
      # Don't use installbsd from OSF since it installs stuff as root
      # by default.
      for ac_prog in ginstall scoinst install; do
        if $as_executable_p "$ac_dir/$ac_prog"; then
	  if test $ac_prog = install &&
            grep dspmsg "$ac_dir/$ac_prog" >/dev/null 2>&1; then
	    # AIX install.  It has an incompatible calling convention.
	    :
	  elif test $ac_prog = install &&
	    grep pwplus "$ac_dir/$ac_prog" >/dev/null 2>&1; then
	    # program-specific install script used by HP pwplus--don't use.
	    :
	  else
	    ac_cv_path_install="$ac_dir/$ac_prog -c"
	    break 2
	  fi
	fi
      done
      ;;
    esac
  done

fi
  if test "${ac_cv_path_install+set}" = set; then
    INSTALL=$ac_cv_path_install
  else
    # As a last resort, use the slow shell script.  We don't cache a
    # path for INSTALL within a source directory, because that will
    # break other packages using the cache if that directory is
    # removed, or if the path is relative.
    INSTALL=$ac_install_sh
  fi
fi
echo "$as_me:2465: result: $INSTALL" >&5
echo "${ECHO_T}$INSTALL" >&6

# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
# It thinks the first close brace ends the variable substitution.
test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'

test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'

test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'

echo "$as_me:2476: checking whether ln -s works" >&5
echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6
LN_S=$as_ln_s
if test "$LN_S" = "ln -s"; then
  echo "$as_me:2480: result: yes" >&5
echo "${ECHO_T}yes" >&6
else
  echo "$as_me:2483: result: no, using $LN_S" >&5
echo "${ECHO_T}no, using $LN_S" >&6
fi

test "$program_prefix" != NONE &&
  program_transform_name="s,^,$program_prefix,;$program_transform_name"
# Use a double $ so make ignores it.
test "$program_suffix" != NONE &&
  program_transform_name="s,\$,$program_suffix,;$program_transform_name"
# Double any \ or $.  echo might interpret backslashes.
# By default was `s,x,x', remove it if useless.
cat <<\_ACEOF >conftest.sed
s/[\\$]/&&/g;s/;s,x,x,$//
_ACEOF
program_transform_name=`echo $program_transform_name | sed -f conftest.sed`
rm conftest.sed

for ac_prog in lint cppcheck splint
do
  # Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo "$as_me:2504: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_LINT+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  if test -n "$LINT"; then
  ac_cv_prog_LINT="$LINT" # Let the user override the test.
else
  ac_save_IFS=$IFS; IFS=$ac_path_separator
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
  IFS=$ac_save_IFS
  test -z "$ac_dir" && ac_dir=.
  $as_executable_p "$ac_dir/$ac_word" || continue
ac_cv_prog_LINT="$ac_prog"
echo "$as_me:2519: found $ac_dir/$ac_word" >&5
break
done

fi
fi
LINT=$ac_cv_prog_LINT
if test -n "$LINT"; then
  echo "$as_me:2527: result: $LINT" >&5
echo "${ECHO_T}$LINT" >&6
else
  echo "$as_me:2530: result: no" >&5
echo "${ECHO_T}no" >&6
fi

  test -n "$LINT" && break
done

###	checks for compiler characteristics

cf_XOPEN_SOURCE=700
cf_POSIX_C_SOURCE=199506L
cf_xopen_source=

case $host_os in
(aix[4-7]*)
	cf_xopen_source="-D_ALL_SOURCE"
	;;
(msys)
	cf_XOPEN_SOURCE=600
	;;
(darwin[0-8].*)
	cf_xopen_source="-D_APPLE_C_SOURCE"
	;;
(darwin*)
	cf_xopen_source="-D_DARWIN_C_SOURCE"
	cf_XOPEN_SOURCE=
	;;
(freebsd*|dragonfly*)
	# 5.x headers associate
	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
	cf_POSIX_C_SOURCE=200112L
	cf_XOPEN_SOURCE=600
	cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
	;;
(hpux11*)
	cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
	;;
(hpux*)
	cf_xopen_source="-D_HPUX_SOURCE"
	;;
(irix[56].*)
	cf_xopen_source="-D_SGI_SOURCE"
	cf_XOPEN_SOURCE=
	;;
(linux*|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin)

echo "$as_me:2577: checking if we must define _GNU_SOURCE" >&5
echo $ECHO_N "checking if we must define _GNU_SOURCE... $ECHO_C" >&6
if test "${cf_cv_gnu_source+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

cat >conftest.$ac_ext <<_ACEOF
#line 2584 "configure"
#include "confdefs.h"
#include 
int
main (void)
{

#ifndef _XOPEN_SOURCE
make an error
#endif
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:2599: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:2602: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:2605: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:2608: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_gnu_source=no
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_save="$CPPFLAGS"
	 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
	 cat >conftest.$ac_ext <<_ACEOF
#line 2617 "configure"
#include "confdefs.h"
#include 
int
main (void)
{

#ifdef _XOPEN_SOURCE
make an error
#endif
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:2632: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:2635: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:2638: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:2641: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_gnu_source=no
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_gnu_source=yes
fi
rm -f conftest.$ac_objext conftest.$ac_ext
	CPPFLAGS="$cf_save"

fi
rm -f conftest.$ac_objext conftest.$ac_ext

fi
echo "$as_me:2656: result: $cf_cv_gnu_source" >&5
echo "${ECHO_T}$cf_cv_gnu_source" >&6

if test "$cf_cv_gnu_source" = yes
then
echo "$as_me:2661: checking if we should also define _DEFAULT_SOURCE" >&5
echo $ECHO_N "checking if we should also define _DEFAULT_SOURCE... $ECHO_C" >&6
if test "${cf_cv_default_source+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
	cat >conftest.$ac_ext <<_ACEOF
#line 2669 "configure"
#include "confdefs.h"
#include 
int
main (void)
{

#ifdef _DEFAULT_SOURCE
make an error
#endif
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:2684: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:2687: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:2690: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:2693: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_default_source=no
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_default_source=yes
fi
rm -f conftest.$ac_objext conftest.$ac_ext

fi
echo "$as_me:2704: result: $cf_cv_default_source" >&5
echo "${ECHO_T}$cf_cv_default_source" >&6
test "$cf_cv_default_source" = yes && CPPFLAGS="$CPPFLAGS -D_DEFAULT_SOURCE"
fi

	;;
(minix*)
	cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
	;;
(mirbsd*)
	# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks  and other headers which use u_int / u_short types
	cf_XOPEN_SOURCE=

cf_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE

cf_save_CFLAGS="$CFLAGS"
cf_save_CPPFLAGS="$CPPFLAGS"

cf_trim_CFLAGS=`echo "$cf_save_CFLAGS" | \
	sed	-e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ 	]*\)\?$//g'`

cf_trim_CPPFLAGS=`echo "$cf_save_CPPFLAGS" | \
	sed	-e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ 	]*\)\?$//g'`

echo "$as_me:2730: checking if we should define _POSIX_C_SOURCE" >&5
echo $ECHO_N "checking if we should define _POSIX_C_SOURCE... $ECHO_C" >&6
if test "${cf_cv_posix_c_source+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

echo "${as_me:-configure}:2736: testing if the symbol is already defined go no further ..." 1>&5

	cat >conftest.$ac_ext <<_ACEOF
#line 2739 "configure"
#include "confdefs.h"
#include 
int
main (void)
{

#ifndef _POSIX_C_SOURCE
make an error
#endif
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:2754: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:2757: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:2760: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:2763: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_posix_c_source=no
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_want_posix_source=no
	 case .$cf_POSIX_C_SOURCE in
	 (.[12]??*)
		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
		;;
	 (.2)
		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
		cf_want_posix_source=yes
		;;
	 (.*)
		cf_want_posix_source=yes
		;;
	 esac
	 if test "$cf_want_posix_source" = yes ; then
		cat >conftest.$ac_ext <<_ACEOF
#line 2784 "configure"
#include "confdefs.h"
#include 
int
main (void)
{

#ifdef _POSIX_SOURCE
make an error
#endif
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:2799: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:2802: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:2805: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:2808: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  :
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE"
fi
rm -f conftest.$ac_objext conftest.$ac_ext
	 fi

echo "${as_me:-configure}:2819: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5

	 CFLAGS="$cf_trim_CFLAGS"
	 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"

echo "${as_me:-configure}:2824: testing if the second compile does not leave our definition intact error ..." 1>&5

	 cat >conftest.$ac_ext <<_ACEOF
#line 2827 "configure"
#include "confdefs.h"
#include 
int
main (void)
{

#ifndef _POSIX_C_SOURCE
make an error
#endif
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:2842: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:2845: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:2848: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:2851: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  :
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_posix_c_source=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext
	 CFLAGS="$cf_save_CFLAGS"
	 CPPFLAGS="$cf_save_CPPFLAGS"

fi
rm -f conftest.$ac_objext conftest.$ac_ext

fi
echo "$as_me:2867: result: $cf_cv_posix_c_source" >&5
echo "${ECHO_T}$cf_cv_posix_c_source" >&6

if test "$cf_cv_posix_c_source" != no ; then
	CFLAGS="$cf_trim_CFLAGS"
	CPPFLAGS="$cf_trim_CPPFLAGS"

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_cv_posix_c_source
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

fi

	;;
(netbsd*)
	cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
	;;
(openbsd[4-9]*)
	# setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
	cf_xopen_source="-D_BSD_SOURCE"
	cf_XOPEN_SOURCE=600
	;;
(openbsd*)
	# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
	;;
(osf[45]*)
	cf_xopen_source="-D_OSF_SOURCE"
	;;
(nto-qnx*)
	cf_xopen_source="-D_QNX_SOURCE"
	;;
(sco*)
	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
	;;
(solaris2.*)
	cf_xopen_source="-D__EXTENSIONS__"
	cf_cv_xopen_source=broken
	;;
(sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2)
	cf_XOPEN_SOURCE=
	cf_POSIX_C_SOURCE=
	;;
(*)

echo "$as_me:3005: checking if we should define _XOPEN_SOURCE" >&5
echo $ECHO_N "checking if we should define _XOPEN_SOURCE... $ECHO_C" >&6
if test "${cf_cv_xopen_source+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

	cat >conftest.$ac_ext <<_ACEOF
#line 3012 "configure"
#include "confdefs.h"

#include 
#include 
#include 

int
main (void)
{

#ifndef _XOPEN_SOURCE
make an error
#endif
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:3031: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:3034: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:3037: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:3040: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_xopen_source=no
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_save="$CPPFLAGS"
	 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
	 cat >conftest.$ac_ext <<_ACEOF
#line 3049 "configure"
#include "confdefs.h"

#include 
#include 
#include 

int
main (void)
{

#ifdef _XOPEN_SOURCE
make an error
#endif
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:3068: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:3071: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:3074: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:3077: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_xopen_source=no
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_xopen_source=$cf_XOPEN_SOURCE
fi
rm -f conftest.$ac_objext conftest.$ac_ext
	CPPFLAGS="$cf_save"

fi
rm -f conftest.$ac_objext conftest.$ac_ext

fi
echo "$as_me:3092: result: $cf_cv_xopen_source" >&5
echo "${ECHO_T}$cf_cv_xopen_source" >&6

if test "$cf_cv_xopen_source" != no ; then

CFLAGS=`echo "$CFLAGS" | \
	sed	-e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ 	]*\)\?$//g'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ 	]*\)\?$//g'`

	cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_temp_xopen_source
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

fi

cf_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE

cf_save_CFLAGS="$CFLAGS"
cf_save_CPPFLAGS="$CPPFLAGS"

cf_trim_CFLAGS=`echo "$cf_save_CFLAGS" | \
	sed	-e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ 	]*\)\?$//g'`

cf_trim_CPPFLAGS=`echo "$cf_save_CPPFLAGS" | \
	sed	-e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"_POSIX_C_SOURCE"'\(=[^ 	]*\)\?$//g'`

echo "$as_me:3220: checking if we should define _POSIX_C_SOURCE" >&5
echo $ECHO_N "checking if we should define _POSIX_C_SOURCE... $ECHO_C" >&6
if test "${cf_cv_posix_c_source+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

echo "${as_me:-configure}:3226: testing if the symbol is already defined go no further ..." 1>&5

	cat >conftest.$ac_ext <<_ACEOF
#line 3229 "configure"
#include "confdefs.h"
#include 
int
main (void)
{

#ifndef _POSIX_C_SOURCE
make an error
#endif
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:3244: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:3247: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:3250: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:3253: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_posix_c_source=no
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_want_posix_source=no
	 case .$cf_POSIX_C_SOURCE in
	 (.[12]??*)
		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
		;;
	 (.2)
		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
		cf_want_posix_source=yes
		;;
	 (.*)
		cf_want_posix_source=yes
		;;
	 esac
	 if test "$cf_want_posix_source" = yes ; then
		cat >conftest.$ac_ext <<_ACEOF
#line 3274 "configure"
#include "confdefs.h"
#include 
int
main (void)
{

#ifdef _POSIX_SOURCE
make an error
#endif
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:3289: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:3292: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:3295: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:3298: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  :
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE"
fi
rm -f conftest.$ac_objext conftest.$ac_ext
	 fi

echo "${as_me:-configure}:3309: testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5

	 CFLAGS="$cf_trim_CFLAGS"
	 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"

echo "${as_me:-configure}:3314: testing if the second compile does not leave our definition intact error ..." 1>&5

	 cat >conftest.$ac_ext <<_ACEOF
#line 3317 "configure"
#include "confdefs.h"
#include 
int
main (void)
{

#ifndef _POSIX_C_SOURCE
make an error
#endif
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:3332: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:3335: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:3338: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:3341: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  :
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_posix_c_source=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext
	 CFLAGS="$cf_save_CFLAGS"
	 CPPFLAGS="$cf_save_CPPFLAGS"

fi
rm -f conftest.$ac_objext conftest.$ac_ext

fi
echo "$as_me:3357: result: $cf_cv_posix_c_source" >&5
echo "${ECHO_T}$cf_cv_posix_c_source" >&6

if test "$cf_cv_posix_c_source" != no ; then
	CFLAGS="$cf_trim_CFLAGS"
	CPPFLAGS="$cf_trim_CPPFLAGS"

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_cv_posix_c_source
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

fi

	;;
esac

if test -n "$cf_xopen_source" ; then

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_xopen_source
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then
	test -n "$verbose" && echo "	add to \$CFLAGS $cf_new_cflags" 1>&6

echo "${as_me:-configure}:3549: testing add to \$CFLAGS $cf_new_cflags ..." 1>&5

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then
	test -n "$verbose" && echo "	add to \$CPPFLAGS $cf_new_cppflags" 1>&6

echo "${as_me:-configure}:3559: testing add to \$CPPFLAGS $cf_new_cppflags ..." 1>&5

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then
	test -n "$verbose" && echo "	add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags" 1>&6

echo "${as_me:-configure}:3569: testing add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags ..." 1>&5

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

fi

if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
	echo "$as_me:3579: checking if _XOPEN_SOURCE really is set" >&5
echo $ECHO_N "checking if _XOPEN_SOURCE really is set... $ECHO_C" >&6
	cat >conftest.$ac_ext <<_ACEOF
#line 3582 "configure"
#include "confdefs.h"
#include 
int
main (void)
{

#ifndef _XOPEN_SOURCE
make an error
#endif
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:3597: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:3600: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:3603: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:3606: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_XOPEN_SOURCE_set=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_XOPEN_SOURCE_set=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext
	echo "$as_me:3615: result: $cf_XOPEN_SOURCE_set" >&5
echo "${ECHO_T}$cf_XOPEN_SOURCE_set" >&6
	if test $cf_XOPEN_SOURCE_set = yes
	then
		cat >conftest.$ac_ext <<_ACEOF
#line 3620 "configure"
#include "confdefs.h"
#include 
int
main (void)
{

#if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
make an error
#endif
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:3635: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:3638: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:3641: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:3644: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_XOPEN_SOURCE_set_ok=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_XOPEN_SOURCE_set_ok=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext
		if test $cf_XOPEN_SOURCE_set_ok = no
		then
			{ echo "$as_me:3655: WARNING: _XOPEN_SOURCE is lower than requested" >&5
echo "$as_me: WARNING: _XOPEN_SOURCE is lower than requested" >&2;}
		fi
	else

echo "$as_me:3660: checking if we should define _XOPEN_SOURCE" >&5
echo $ECHO_N "checking if we should define _XOPEN_SOURCE... $ECHO_C" >&6
if test "${cf_cv_xopen_source+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

	cat >conftest.$ac_ext <<_ACEOF
#line 3667 "configure"
#include "confdefs.h"

#include 
#include 
#include 

int
main (void)
{

#ifndef _XOPEN_SOURCE
make an error
#endif
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:3686: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:3689: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:3692: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:3695: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_xopen_source=no
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_save="$CPPFLAGS"
	 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
	 cat >conftest.$ac_ext <<_ACEOF
#line 3704 "configure"
#include "confdefs.h"

#include 
#include 
#include 

int
main (void)
{

#ifdef _XOPEN_SOURCE
make an error
#endif
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:3723: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:3726: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:3729: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:3732: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_xopen_source=no
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_xopen_source=$cf_XOPEN_SOURCE
fi
rm -f conftest.$ac_objext conftest.$ac_ext
	CPPFLAGS="$cf_save"

fi
rm -f conftest.$ac_objext conftest.$ac_ext

fi
echo "$as_me:3747: result: $cf_cv_xopen_source" >&5
echo "${ECHO_T}$cf_cv_xopen_source" >&6

if test "$cf_cv_xopen_source" != no ; then

CFLAGS=`echo "$CFLAGS" | \
	sed	-e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ 	]*\)\?$//g'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"_XOPEN_SOURCE"'\(=[^ 	]*\)\?$//g'`

	cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_temp_xopen_source
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

fi

	fi
fi

echo "$as_me:3865: checking if SIGWINCH is defined" >&5
echo $ECHO_N "checking if SIGWINCH is defined... $ECHO_C" >&6
if test "${cf_cv_define_sigwinch+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

	cat >conftest.$ac_ext <<_ACEOF
#line 3872 "configure"
#include "confdefs.h"

#include 
#include 

int
main (void)
{
int x = SIGWINCH
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:3887: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:3890: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:3893: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:3896: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_define_sigwinch=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cat >conftest.$ac_ext <<_ACEOF
#line 3903 "configure"
#include "confdefs.h"

#undef _XOPEN_SOURCE
#undef _POSIX_SOURCE
#undef _POSIX_C_SOURCE
#include 
#include 

int
main (void)
{
int x = SIGWINCH
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:3921: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:3924: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:3927: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:3930: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_define_sigwinch=maybe
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_define_sigwinch=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext

fi
rm -f conftest.$ac_objext conftest.$ac_ext

fi
echo "$as_me:3944: result: $cf_cv_define_sigwinch" >&5
echo "${ECHO_T}$cf_cv_define_sigwinch" >&6

if test "$cf_cv_define_sigwinch" = maybe ; then
echo "$as_me:3948: checking for actual SIGWINCH definition" >&5
echo $ECHO_N "checking for actual SIGWINCH definition... $ECHO_C" >&6
if test "${cf_cv_fixup_sigwinch+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

cf_cv_fixup_sigwinch=unknown
cf_sigwinch=32
while test $cf_sigwinch != 1
do
	cat >conftest.$ac_ext <<_ACEOF
#line 3959 "configure"
#include "confdefs.h"

#undef _XOPEN_SOURCE
#undef _POSIX_SOURCE
#undef _POSIX_C_SOURCE
#include 
#include 

int
main (void)
{

#if SIGWINCH != $cf_sigwinch
make an error
#endif
int x = SIGWINCH
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:3981: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:3984: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:3987: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:3990: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_fixup_sigwinch=$cf_sigwinch
	 break
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
fi
rm -f conftest.$ac_objext conftest.$ac_ext

cf_sigwinch=`expr $cf_sigwinch - 1`
done

fi
echo "$as_me:4004: result: $cf_cv_fixup_sigwinch" >&5
echo "${ECHO_T}$cf_cv_fixup_sigwinch" >&6

	if test "$cf_cv_fixup_sigwinch" != unknown ; then
		CPPFLAGS="$CPPFLAGS -DSIGWINCH=$cf_cv_fixup_sigwinch"
	fi
fi

###	checks for header files

for ac_header in \
ncurses/curses.h \
ncurses/term.h \
stdlib.h \
sys/ptem.h sys/ttydefaults.h \
term.h \
termios.h \
unistd.h \
wchar.h \

do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
echo "$as_me:4026: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 4032 "configure"
#include "confdefs.h"
#include <$ac_header>
_ACEOF
if { (eval echo "$as_me:4036: \"$ac_cpp conftest.$ac_ext\"") >&5
  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
  ac_status=$?
  egrep -v '^ *\+' conftest.er1 >conftest.err
  rm -f conftest.er1
  cat conftest.err >&5
  echo "$as_me:4042: \$? = $ac_status" >&5
  (exit $ac_status); } >/dev/null; then
  if test -s conftest.err; then
    ac_cpp_err=$ac_c_preproc_warn_flag
  else
    ac_cpp_err=
  fi
else
  ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
  eval "$as_ac_Header=yes"
else
  echo "$as_me: failed program was:" >&5
  cat conftest.$ac_ext >&5
  eval "$as_ac_Header=no"
fi
rm -f conftest.err conftest.$ac_ext
fi
echo "$as_me:4061: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
if test `eval echo '${'$as_ac_Header'}'` = yes; then
  cat >>confdefs.h <&5
echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6
if test "${ac_cv_header_time+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 4077 "configure"
#include "confdefs.h"
#include 
#include 
#include 

int
main (void)
{
if ((struct tm *) 0)
return 0;
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:4093: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:4096: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:4099: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:4102: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_header_time=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_header_time=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:4112: result: $ac_cv_header_time" >&5
echo "${ECHO_T}$ac_cv_header_time" >&6
if test $ac_cv_header_time = yes; then

cat >>confdefs.h <<\EOF
#define TIME_WITH_SYS_TIME 1
EOF

fi

echo "$as_me:4122: checking for nl_langinfo and CODESET" >&5
echo $ECHO_N "checking for nl_langinfo and CODESET... $ECHO_C" >&6
if test "${am_cv_langinfo_codeset+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 4128 "configure"
#include "confdefs.h"
#include 
int
main (void)
{
char* cs = nl_langinfo(CODESET);
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:4140: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:4143: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:4146: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:4149: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  am_cv_langinfo_codeset=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
am_cv_langinfo_codeset=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext

fi
echo "$as_me:4160: result: $am_cv_langinfo_codeset" >&5
echo "${ECHO_T}$am_cv_langinfo_codeset" >&6
	if test $am_cv_langinfo_codeset = yes; then

cat >>confdefs.h <<\EOF
#define HAVE_LANGINFO_CODESET 1
EOF

	fi

###	checks for typedefs

echo "$as_me:4172: checking for signal global datatype" >&5
echo $ECHO_N "checking for signal global datatype... $ECHO_C" >&6
if test "${cf_cv_sig_atomic_t+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

	for cf_type in \
		"volatile sig_atomic_t" \
		"sig_atomic_t" \
		"int"
	do
	cat >conftest.$ac_ext <<_ACEOF
#line 4184 "configure"
#include "confdefs.h"

#include 
#include 
#include 

extern $cf_type x;
$cf_type x;
static void handler(int sig)
{
	x = 5;
}
int
main (void)
{
signal(SIGINT, handler);
		 x = 1
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:4207: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:4210: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:4213: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:4216: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_sig_atomic_t=$cf_type
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_sig_atomic_t=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext
		test "$cf_cv_sig_atomic_t" != no && break
	done

fi

echo "$as_me:4230: result: $cf_cv_sig_atomic_t" >&5
echo "${ECHO_T}$cf_cv_sig_atomic_t" >&6
test "$cf_cv_sig_atomic_t" != no &&
cat >>confdefs.h <&5
echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
if test "${ac_cv_header_stdc+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 4243 "configure"
#include "confdefs.h"
#include 
#include 
#include 
#include 

_ACEOF
if { (eval echo "$as_me:4251: \"$ac_cpp conftest.$ac_ext\"") >&5
  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
  ac_status=$?
  egrep -v '^ *\+' conftest.er1 >conftest.err
  rm -f conftest.er1
  cat conftest.err >&5
  echo "$as_me:4257: \$? = $ac_status" >&5
  (exit $ac_status); } >/dev/null; then
  if test -s conftest.err; then
    ac_cpp_err=$ac_c_preproc_warn_flag
  else
    ac_cpp_err=
  fi
else
  ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
  ac_cv_header_stdc=yes
else
  echo "$as_me: failed program was:" >&5
  cat conftest.$ac_ext >&5
  ac_cv_header_stdc=no
fi
rm -f conftest.err conftest.$ac_ext

if test $ac_cv_header_stdc = yes; then
  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
  cat >conftest.$ac_ext <<_ACEOF
#line 4279 "configure"
#include "confdefs.h"
#include 

_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
  egrep "memchr" >/dev/null 2>&1; then
  :
else
  ac_cv_header_stdc=no
fi
rm -rf conftest*

fi

if test $ac_cv_header_stdc = yes; then
  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
  cat >conftest.$ac_ext <<_ACEOF
#line 4297 "configure"
#include "confdefs.h"
#include 

_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
  egrep "free" >/dev/null 2>&1; then
  :
else
  ac_cv_header_stdc=no
fi
rm -rf conftest*

fi

if test $ac_cv_header_stdc = yes; then
  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
  if test "$cross_compiling" = yes; then
  :
else
  cat >conftest.$ac_ext <<_ACEOF
#line 4318 "configure"
#include "confdefs.h"
#include 
#if ((' ' & 0x0FF) == 0x020)
# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
#else
# define ISLOWER(c) (('a' <= (c) && (c) <= 'i') \
                     || ('j' <= (c) && (c) <= 'r') \
                     || ('s' <= (c) && (c) <= 'z'))
# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
#endif

#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
int
main (void)
{
  int i;
  for (i = 0; i < 256; i++)
    if (XOR (islower (i), ISLOWER (i))
        || toupper (i) != TOUPPER (i))
      $ac_main_return(2);
  $ac_main_return (0);
}
_ACEOF
rm -f conftest$ac_exeext
if { (eval echo "$as_me:4344: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:4347: \$? = $ac_status" >&5
  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
  { (eval echo "$as_me:4349: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:4352: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  :
else
  echo "$as_me: program exited with status $ac_status" >&5
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_header_stdc=no
fi
rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi
fi
fi
echo "$as_me:4365: result: $ac_cv_header_stdc" >&5
echo "${ECHO_T}$ac_cv_header_stdc" >&6
if test $ac_cv_header_stdc = yes; then

cat >>confdefs.h <<\EOF
#define STDC_HEADERS 1
EOF

fi

# On IRIX 5.3, sys/types and inttypes.h are conflicting.

for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
                  inttypes.h stdint.h unistd.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
echo "$as_me:4381: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 4387 "configure"
#include "confdefs.h"
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:4393: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:4396: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:4399: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:4402: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  eval "$as_ac_Header=yes"
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
eval "$as_ac_Header=no"
fi
rm -f conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:4412: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
if test `eval echo '${'$as_ac_Header'}'` = yes; then
  cat >>confdefs.h <&5
echo $ECHO_N "checking for time_t... $ECHO_C" >&6
if test "${ac_cv_type_time_t+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 4428 "configure"
#include "confdefs.h"
$ac_includes_default
int
main (void)
{
if ((time_t *) 0)
  return 0;
if (sizeof (time_t))
  return 0;
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:4443: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:4446: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:4449: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:4452: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_type_time_t=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_type_time_t=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:4462: result: $ac_cv_type_time_t" >&5
echo "${ECHO_T}$ac_cv_type_time_t" >&6
if test $ac_cv_type_time_t = yes; then
  :
else

cat >>confdefs.h < or " >&5
echo $ECHO_N "checking for cc_t in  or ... $ECHO_C" >&6
if test "${cf_cv_type_cc_t+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

	cat >conftest.$ac_ext <<_ACEOF
#line 4481 "configure"
#include "confdefs.h"

#include 
#if defined(HAVE_TERMIOS_H)
#include 
#else
#include 
#include 
#endif

int
main (void)
{
cc_t x
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:4501: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:4504: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:4507: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:4510: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_type_cc_t=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_type_cc_t=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext

fi

echo "$as_me:4522: result: $cf_cv_type_cc_t" >&5
echo "${ECHO_T}$cf_cv_type_cc_t" >&6
test $cf_cv_type_cc_t = no &&
cat >>confdefs.h <<\EOF
#define cc_t unsigned char
EOF

echo "$as_me:4529: checking for mode_t" >&5
echo $ECHO_N "checking for mode_t... $ECHO_C" >&6
if test "${ac_cv_type_mode_t+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 4535 "configure"
#include "confdefs.h"
$ac_includes_default
int
main (void)
{
if ((mode_t *) 0)
  return 0;
if (sizeof (mode_t))
  return 0;
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:4550: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:4553: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:4556: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:4559: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_type_mode_t=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_type_mode_t=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:4569: result: $ac_cv_type_mode_t" >&5
echo "${ECHO_T}$ac_cv_type_mode_t" >&6
if test $ac_cv_type_mode_t = yes; then
  :
else

cat >>confdefs.h <&5
echo $ECHO_N "checking for pid_t... $ECHO_C" >&6
if test "${ac_cv_type_pid_t+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 4587 "configure"
#include "confdefs.h"
$ac_includes_default
int
main (void)
{
if ((pid_t *) 0)
  return 0;
if (sizeof (pid_t))
  return 0;
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:4602: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:4605: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:4608: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:4611: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_type_pid_t=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_type_pid_t=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:4621: result: $ac_cv_type_pid_t" >&5
echo "${ECHO_T}$ac_cv_type_pid_t" >&6
if test $ac_cv_type_pid_t = yes; then
  :
else

cat >>confdefs.h <&5
echo $ECHO_N "checking for uid_t in sys/types.h... $ECHO_C" >&6
if test "${ac_cv_type_uid_t+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 4639 "configure"
#include "confdefs.h"
#include 

_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
  egrep "uid_t" >/dev/null 2>&1; then
  ac_cv_type_uid_t=yes
else
  ac_cv_type_uid_t=no
fi
rm -rf conftest*

fi
echo "$as_me:4653: result: $ac_cv_type_uid_t" >&5
echo "${ECHO_T}$ac_cv_type_uid_t" >&6
if test $ac_cv_type_uid_t = no; then

cat >>confdefs.h <<\EOF
#define uid_t int
EOF

cat >>confdefs.h <<\EOF
#define gid_t int
EOF

fi

echo "$as_me:4667: checking for off_t" >&5
echo $ECHO_N "checking for off_t... $ECHO_C" >&6
if test "${ac_cv_type_off_t+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 4673 "configure"
#include "confdefs.h"
$ac_includes_default
int
main (void)
{
if ((off_t *) 0)
  return 0;
if (sizeof (off_t))
  return 0;
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:4688: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:4691: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:4694: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:4697: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_type_off_t=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_type_off_t=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:4707: result: $ac_cv_type_off_t" >&5
echo "${ECHO_T}$ac_cv_type_off_t" >&6
if test $ac_cv_type_off_t = yes; then
  :
else

cat >>confdefs.h <&5
echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
if eval "test \"\${$as_ac_var+set}\" = set"; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 4743 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
    which can conflict with char $ac_func (); below.  */
#include 
/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char $ac_func ();
char (*f) ();

int
main (void)
{
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
choke me
#else
f = $ac_func; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
#endif

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:4774: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:4777: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:4780: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:4783: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  eval "$as_ac_var=yes"
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
eval "$as_ac_var=no"
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:4793: result: `eval echo '${'$as_ac_var'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
if test `eval echo '${'$as_ac_var'}'` = yes; then
  cat >>confdefs.h <&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 4812 "configure"
#include "confdefs.h"
#include <$ac_header>
_ACEOF
if { (eval echo "$as_me:4816: \"$ac_cpp conftest.$ac_ext\"") >&5
  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
  ac_status=$?
  egrep -v '^ *\+' conftest.er1 >conftest.err
  rm -f conftest.er1
  cat conftest.err >&5
  echo "$as_me:4822: \$? = $ac_status" >&5
  (exit $ac_status); } >/dev/null; then
  if test -s conftest.err; then
    ac_cpp_err=$ac_c_preproc_warn_flag
  else
    ac_cpp_err=
  fi
else
  ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
  eval "$as_ac_Header=yes"
else
  echo "$as_me: failed program was:" >&5
  cat conftest.$ac_ext >&5
  eval "$as_ac_Header=no"
fi
rm -f conftest.err conftest.$ac_ext
fi
echo "$as_me:4841: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
if test `eval echo '${'$as_ac_Header'}'` = yes; then
  cat >>confdefs.h <&5
echo $ECHO_N "checking for lastlog path... $ECHO_C" >&6
if test "${cf_cv_path_lastlog+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

cat >conftest.$ac_ext <<_ACEOF
#line 4858 "configure"
#include "confdefs.h"

#include 
#ifdef HAVE_LASTLOG_H
#include 
#else
#ifdef HAVE_PATHS_H
#include 
#endif
#endif
int
main (void)
{
char *path = _PATH_LASTLOG
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:4878: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:4881: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:4884: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:4887: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_path_lastlog="_PATH_LASTLOG"
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
if test -f /usr/adm/lastlog ; then
	 	cf_cv_path_lastlog=/usr/adm/lastlog
	else
		cf_cv_path_lastlog=no
	fi
fi
rm -f conftest.$ac_objext conftest.$ac_ext

fi
echo "$as_me:4902: result: $cf_cv_path_lastlog" >&5
echo "${ECHO_T}$cf_cv_path_lastlog" >&6
test $cf_cv_path_lastlog != no &&
cat >>confdefs.h <<\EOF
#define USE_LASTLOG 1
EOF

echo "$as_me:4909: checking for utmp implementation" >&5
echo $ECHO_N "checking for utmp implementation... $ECHO_C" >&6
if test "${cf_cv_have_utmp+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

	cf_cv_have_utmp=no
for cf_header in utmpx utmp ; do
cf_utmp_includes="
#include 
#include <${cf_header}.h>
#define getutent getutxent
#ifdef USE_LASTLOG
#include 	/* may conflict with utmpx.h on Linux */
#endif
"
	cat >conftest.$ac_ext <<_ACEOF
#line 4926 "configure"
#include "confdefs.h"
$cf_utmp_includes
int
main (void)
{
struct $cf_header x;
	 char *name = x.ut_name; /* utmp.h and compatible definitions */

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:4940: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:4943: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:4946: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:4949: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_have_utmp=$cf_header
	 break
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5

	cat >conftest.$ac_ext <<_ACEOF
#line 4958 "configure"
#include "confdefs.h"
$cf_utmp_includes
int
main (void)
{
struct $cf_header x;
	 char *name = x.ut_user; /* utmpx.h must declare this */

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:4972: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:4975: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:4978: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:4981: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_have_utmp=$cf_header
	 break

else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
fi
rm -f conftest.$ac_objext conftest.$ac_ext
fi
rm -f conftest.$ac_objext conftest.$ac_ext
done

fi
echo "$as_me:4996: result: $cf_cv_have_utmp" >&5
echo "${ECHO_T}$cf_cv_have_utmp" >&6

if test $cf_cv_have_utmp != no ; then

cat >>confdefs.h <<\EOF
#define HAVE_UTMP 1
EOF

	test $cf_cv_have_utmp = utmpx &&
cat >>confdefs.h <<\EOF
#define UTMPX_FOR_UTMP 1
EOF

if test $cf_cv_have_utmp != no ; then
echo "$as_me:5011: checking if ${cf_cv_have_utmp}.ut_host is declared" >&5
echo $ECHO_N "checking if ${cf_cv_have_utmp}.ut_host is declared... $ECHO_C" >&6
if test "${cf_cv_have_utmp_ut_host+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

	cat >conftest.$ac_ext <<_ACEOF
#line 5018 "configure"
#include "confdefs.h"

#include 
#include <${cf_cv_have_utmp}.h>
int
main (void)
{
struct $cf_cv_have_utmp x; char *y = &x.ut_host[0]
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:5032: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:5035: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:5038: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:5041: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_have_utmp_ut_host=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_have_utmp_ut_host=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext

fi

echo "$as_me:5053: result: $cf_cv_have_utmp_ut_host" >&5
echo "${ECHO_T}$cf_cv_have_utmp_ut_host" >&6
test $cf_cv_have_utmp_ut_host != no &&
cat >>confdefs.h <<\EOF
#define HAVE_UTMP_UT_HOST 1
EOF

fi

if test $cf_cv_have_utmp != no ; then
echo "$as_me:5063: checking if ${cf_cv_have_utmp}.ut_syslen is declared" >&5
echo $ECHO_N "checking if ${cf_cv_have_utmp}.ut_syslen is declared... $ECHO_C" >&6
if test "${cf_cv_have_utmp_ut_syslen+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

	cat >conftest.$ac_ext <<_ACEOF
#line 5070 "configure"
#include "confdefs.h"

#include 
#include <${cf_cv_have_utmp}.h>
int
main (void)
{
struct $cf_cv_have_utmp x; int y = x.ut_syslen
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:5084: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:5087: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:5090: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:5093: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_have_utmp_ut_syslen=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_have_utmp_ut_syslen=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext

fi

echo "$as_me:5105: result: $cf_cv_have_utmp_ut_syslen" >&5
echo "${ECHO_T}$cf_cv_have_utmp_ut_syslen" >&6
test $cf_cv_have_utmp_ut_syslen != no &&
cat >>confdefs.h <<\EOF
#define HAVE_UTMP_UT_SYSLEN 1
EOF

fi

if test $cf_cv_have_utmp != no ; then
echo "$as_me:5115: checking if ${cf_cv_have_utmp}.ut_name is declared" >&5
echo $ECHO_N "checking if ${cf_cv_have_utmp}.ut_name is declared... $ECHO_C" >&6
if test "${cf_cv_have_utmp_ut_name+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

	cf_cv_have_utmp_ut_name=no
cf_utmp_includes="
#include 
#include <${cf_cv_have_utmp}.h>
#define getutent getutxent
#ifdef USE_LASTLOG
#include 		/* may conflict with utmpx.h on Linux */
#endif
"
for cf_header in ut_name ut_user ; do
	cat >conftest.$ac_ext <<_ACEOF
#line 5132 "configure"
#include "confdefs.h"
$cf_utmp_includes
int
main (void)
{
struct $cf_cv_have_utmp x;
	 char *name = x.$cf_header;

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:5146: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:5149: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:5152: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:5155: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_have_utmp_ut_name=$cf_header
	 break
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
fi
rm -f conftest.$ac_objext conftest.$ac_ext
done

fi
echo "$as_me:5167: result: $cf_cv_have_utmp_ut_name" >&5
echo "${ECHO_T}$cf_cv_have_utmp_ut_name" >&6

case $cf_cv_have_utmp_ut_name in
(no)
	{ { echo "$as_me:5172: error: Cannot find declaration for ut.ut_name" >&5
echo "$as_me: error: Cannot find declaration for ut.ut_name" >&2;}
   { (exit 1); exit 1; }; }
	;;
(ut_user)

cat >>confdefs.h <<\EOF
#define ut_name ut_user
EOF

	;;
esac
fi

if test $cf_cv_have_utmp != no ; then
echo "$as_me:5187: checking for exit-status in $cf_cv_have_utmp" >&5
echo $ECHO_N "checking for exit-status in $cf_cv_have_utmp... $ECHO_C" >&6
if test "${cf_cv_have_utmp_ut_xstatus+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

for cf_result in \
	ut_exit.__e_exit \
	ut_exit.e_exit \
	ut_exit.ut_e_exit \
	ut_exit.ut_exit
do
cat >conftest.$ac_ext <<_ACEOF
#line 5200 "configure"
#include "confdefs.h"

#include 
#include <${cf_cv_have_utmp}.h>
int
main (void)
{
struct $cf_cv_have_utmp x; long y = x.$cf_result = 0
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:5214: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:5217: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:5220: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:5223: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_have_utmp_ut_xstatus=$cf_result
	 break
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_have_utmp_ut_xstatus=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext
done

fi
echo "$as_me:5236: result: $cf_cv_have_utmp_ut_xstatus" >&5
echo "${ECHO_T}$cf_cv_have_utmp_ut_xstatus" >&6
if test $cf_cv_have_utmp_ut_xstatus != no ; then

cat >>confdefs.h <<\EOF
#define HAVE_UTMP_UT_XSTATUS 1
EOF

cat >>confdefs.h <&5
echo $ECHO_N "checking if ${cf_cv_have_utmp}.ut_xtime is declared... $ECHO_C" >&6
if test "${cf_cv_have_utmp_ut_xtime+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

	cat >conftest.$ac_ext <<_ACEOF
#line 5259 "configure"
#include "confdefs.h"

#include 
#include <${cf_cv_have_utmp}.h>
int
main (void)
{
struct $cf_cv_have_utmp x; long y = x.ut_xtime = 0
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:5273: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:5276: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:5279: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:5282: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_have_utmp_ut_xtime=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cat >conftest.$ac_ext <<_ACEOF
#line 5289 "configure"
#include "confdefs.h"

#include 
#include <${cf_cv_have_utmp}.h>
int
main (void)
{
struct $cf_cv_have_utmp x; long y = x.ut_tv.tv_sec
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:5303: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:5306: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:5309: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:5312: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_have_utmp_ut_xtime=define
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_have_utmp_ut_xtime=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext

fi
rm -f conftest.$ac_objext conftest.$ac_ext

fi
echo "$as_me:5326: result: $cf_cv_have_utmp_ut_xtime" >&5
echo "${ECHO_T}$cf_cv_have_utmp_ut_xtime" >&6
if test $cf_cv_have_utmp_ut_xtime != no ; then

cat >>confdefs.h <<\EOF
#define HAVE_UTMP_UT_XTIME 1
EOF

	if test $cf_cv_have_utmp_ut_xtime = define ; then

cat >>confdefs.h <<\EOF
#define ut_xtime ut_tv.tv_sec
EOF

	fi
fi
fi

if test $cf_cv_have_utmp != no ; then
echo "$as_me:5345: checking if ${cf_cv_have_utmp}.ut_session is declared" >&5
echo $ECHO_N "checking if ${cf_cv_have_utmp}.ut_session is declared... $ECHO_C" >&6
if test "${cf_cv_have_utmp_ut_session+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

	cat >conftest.$ac_ext <<_ACEOF
#line 5352 "configure"
#include "confdefs.h"

#include 
#include <${cf_cv_have_utmp}.h>
int
main (void)
{
struct $cf_cv_have_utmp x; long y = x.ut_session
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:5366: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:5369: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:5372: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:5375: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_have_utmp_ut_session=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_have_utmp_ut_session=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext

fi
echo "$as_me:5386: result: $cf_cv_have_utmp_ut_session" >&5
echo "${ECHO_T}$cf_cv_have_utmp_ut_session" >&6
if test $cf_cv_have_utmp_ut_session != no ; then

cat >>confdefs.h <<\EOF
#define HAVE_UTMP_UT_SESSION 1
EOF

fi
fi

echo "$as_me:5397: checking if $cf_cv_have_utmp is SYSV flavor" >&5
echo $ECHO_N "checking if $cf_cv_have_utmp is SYSV flavor... $ECHO_C" >&6
if test "${cf_cv_sysv_utmp+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

test "$cf_cv_have_utmp" = "utmp" && cf_prefix="ut" || cf_prefix="utx"
cat >conftest.$ac_ext <<_ACEOF
#line 5405 "configure"
#include "confdefs.h"

#include 
#include <${cf_cv_have_utmp}.h>
int
main (void)
{

struct $cf_cv_have_utmp x;
	set${cf_prefix}ent ();
	get${cf_prefix}id(&x);
	put${cf_prefix}line(&x);
	end${cf_prefix}ent();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:5424: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:5427: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:5430: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:5433: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_sysv_utmp=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_sysv_utmp=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext

fi
echo "$as_me:5444: result: $cf_cv_sysv_utmp" >&5
echo "${ECHO_T}$cf_cv_sysv_utmp" >&6
test $cf_cv_sysv_utmp = yes &&
cat >>confdefs.h <<\EOF
#define USE_SYSV_UTMP 1
EOF

fi

for ac_header in lastlog.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
echo "$as_me:5456: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 5462 "configure"
#include "confdefs.h"
#include <$ac_header>
_ACEOF
if { (eval echo "$as_me:5466: \"$ac_cpp conftest.$ac_ext\"") >&5
  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
  ac_status=$?
  egrep -v '^ *\+' conftest.er1 >conftest.err
  rm -f conftest.er1
  cat conftest.err >&5
  echo "$as_me:5472: \$? = $ac_status" >&5
  (exit $ac_status); } >/dev/null; then
  if test -s conftest.err; then
    ac_cpp_err=$ac_c_preproc_warn_flag
  else
    ac_cpp_err=
  fi
else
  ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
  eval "$as_ac_Header=yes"
else
  echo "$as_me: failed program was:" >&5
  cat conftest.$ac_ext >&5
  eval "$as_ac_Header=no"
fi
rm -f conftest.err conftest.$ac_ext
fi
echo "$as_me:5491: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
if test `eval echo '${'$as_ac_Header'}'` = yes; then
  cat >>confdefs.h <&5
echo $ECHO_N "checking for struct lastlog... $ECHO_C" >&6
if test "${cf_cv_struct_lastlog+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

if test "$cross_compiling" = yes; then

cf_cv_struct_lastlog=unknown
else
  cat >conftest.$ac_ext <<_ACEOF
#line 5512 "configure"
#include "confdefs.h"

#include 
#include 
#include 

int main()
{
	struct lastlog data;
	return (sizeof(data.ll_time) != sizeof(time_t));
}
_ACEOF
rm -f conftest$ac_exeext
if { (eval echo "$as_me:5526: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:5529: \$? = $ac_status" >&5
  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
  { (eval echo "$as_me:5531: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:5534: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then

cf_cv_struct_lastlog=yes
else
  echo "$as_me: program exited with status $ac_status" >&5
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5

cf_cv_struct_lastlog=no
fi
rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi
fi
echo "$as_me:5548: result: $cf_cv_struct_lastlog" >&5
echo "${ECHO_T}$cf_cv_struct_lastlog" >&6

test $cf_cv_struct_lastlog != no &&
cat >>confdefs.h <<\EOF
#define USE_STRUCT_LASTLOG 1
EOF

for ac_header in \
sys/param.h \

do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
echo "$as_me:5561: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 5567 "configure"
#include "confdefs.h"
#include <$ac_header>
_ACEOF
if { (eval echo "$as_me:5571: \"$ac_cpp conftest.$ac_ext\"") >&5
  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
  ac_status=$?
  egrep -v '^ *\+' conftest.er1 >conftest.err
  rm -f conftest.er1
  cat conftest.err >&5
  echo "$as_me:5577: \$? = $ac_status" >&5
  (exit $ac_status); } >/dev/null; then
  if test -s conftest.err; then
    ac_cpp_err=$ac_c_preproc_warn_flag
  else
    ac_cpp_err=
  fi
else
  ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
  eval "$as_ac_Header=yes"
else
  echo "$as_me: failed program was:" >&5
  cat conftest.$ac_ext >&5
  eval "$as_ac_Header=no"
fi
rm -f conftest.err conftest.$ac_ext
fi
echo "$as_me:5596: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
if test `eval echo '${'$as_ac_Header'}'` = yes; then
  cat >>confdefs.h <&5
echo $ECHO_N "checking if POSIX saved-ids are supported... $ECHO_C" >&6
if test "${cf_cv_posix_saved_ids+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

cat >conftest.$ac_ext <<_ACEOF
#line 5613 "configure"
#include "confdefs.h"

#include 
#ifdef HAVE_SYS_PARAM_H
#include 		/* this may define "BSD" */
#endif

int
main (void)
{

#if defined(_POSIX_SAVED_IDS) && (_POSIX_SAVED_IDS > 0)
	void *p = (void *) seteuid;
	int x = seteuid(geteuid());
#elif defined(BSD) && (BSD >= 199103)
/* The BSD's may implement the runtime check - and it fails.
 * However, saved-ids work almost like POSIX (close enough for most uses).
 */
#else
make an error
#endif

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:5641: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:5644: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:5647: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:5650: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_posix_saved_ids=yes

else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5

if test "$cross_compiling" = yes; then
  cf_cv_posix_saved_ids=unknown
else
  cat >conftest.$ac_ext <<_ACEOF
#line 5662 "configure"
#include "confdefs.h"

#ifdef HAVE_STDLIB_H
#include 
#endif
#include 
int main()
{
	void *p = (void *) seteuid;
	long code = sysconf(_SC_SAVED_IDS);
	${cf_cv_main_return:-return}  ((code > 0) ? 0 : 1);
}
_ACEOF
rm -f conftest$ac_exeext
if { (eval echo "$as_me:5677: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:5680: \$? = $ac_status" >&5
  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
  { (eval echo "$as_me:5682: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:5685: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_posix_saved_ids=yes
else
  echo "$as_me: program exited with status $ac_status" >&5
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_posix_saved_ids=no
fi
rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi

fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext

fi
echo "$as_me:5701: result: $cf_cv_posix_saved_ids" >&5
echo "${ECHO_T}$cf_cv_posix_saved_ids" >&6

test "$cf_cv_posix_saved_ids" = yes &&
cat >>confdefs.h <<\EOF
#define HAVE_POSIX_SAVED_IDS 1
EOF

# compute a reasonable value for $TERM to give tgetent(), since we may be
# running in 'screen', which sets $TERMCAP to a specific entry that is not
# necessarily in /etc/termcap - unsetenv is not portable, so we cannot simply
# discard $TERMCAP.
cf_TERMVAR=vt100
if test -n "$TERMCAP"
then
	cf_TERMCAP=`echo "$TERMCAP" | tr '\n' ' ' | sed -e 's/^..|//' -e 's/|.*//'`
	case "$cf_TERMCAP" in
	(screen*.*)
		;;
	(*)
		cf_TERMVAR="$cf_TERMCAP"
		;;
	esac
fi
test -z "$cf_TERMVAR" && cf_TERMVAR=vt100

echo "$as_me:5727: checking if we want full tgetent function" >&5
echo $ECHO_N "checking if we want full tgetent function... $ECHO_C" >&6

# Check whether --enable-full-tgetent or --disable-full-tgetent was given.
if test "${enable_full_tgetent+set}" = set; then
  enableval="$enable_full_tgetent"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    cf_full_tgetent=no
	else
		cf_full_tgetent=yes
	fi
else
  enableval=yes
	cf_full_tgetent=yes

fi;
echo "$as_me:5744: result: $cf_full_tgetent" >&5
echo "${ECHO_T}$cf_full_tgetent" >&6

if test "$cf_full_tgetent" = yes ; then
	cf_test_message="full tgetent"
else
	cf_test_message="tgetent"
fi

echo "$as_me:5753: checking for $cf_test_message function" >&5
echo $ECHO_N "checking for $cf_test_message function... $ECHO_C" >&6
if test "${cf_cv_lib_tgetent+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

cf_save_LIBS="$LIBS"
cf_cv_lib_tgetent=no
if test "$cf_full_tgetent" = yes ; then
	cf_TERMLIB="otermcap termcap termlib ncurses curses"
	cf_TERMTST="buffer[0] == 0"
else
	cf_TERMLIB="termlib ncurses curses"
	cf_TERMTST="0"
fi
for cf_termlib in '' $cf_TERMLIB ; do
	LIBS="$cf_save_LIBS"
	test -n "$cf_termlib" && {
cf_add_libs="-l$cf_termlib"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"
 }
	if test "$cross_compiling" = yes; then
  echo "cross-compiling, cannot verify if a termcap/tgetent is present in $cf_termlib" 1>&5
else
  cat >conftest.$ac_ext <<_ACEOF
#line 5791 "configure"
#include "confdefs.h"

/* terminfo implementations ignore the buffer argument, making it useless for
 * the xterm application, which uses this information to make a new TERMCAP
 * environment variable.
 */
int main()
{
	char buffer[1024];
	buffer[0] = 0;
	tgetent(buffer, "$cf_TERMVAR");
	${cf_cv_main_return:-return} ($cf_TERMTST); }
_ACEOF
rm -f conftest$ac_exeext
if { (eval echo "$as_me:5806: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:5809: \$? = $ac_status" >&5
  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
  { (eval echo "$as_me:5811: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:5814: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  echo "yes, there is a termcap/tgetent in $cf_termlib" 1>&5
	 if test -n "$cf_termlib" ; then
	 	cf_cv_lib_tgetent="-l$cf_termlib"
	 else
	 	cf_cv_lib_tgetent=yes
	 fi
	 break
else
  echo "$as_me: program exited with status $ac_status" >&5
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
echo "no, there is no termcap/tgetent in $cf_termlib" 1>&5
fi
rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi
done
LIBS="$cf_save_LIBS"

fi
echo "$as_me:5835: result: $cf_cv_lib_tgetent" >&5
echo "${ECHO_T}$cf_cv_lib_tgetent" >&6

# If we found a working tgetent(), set LIBS and check for termcap.h.
# (LIBS cannot be set inside AC_CACHE_CHECK; the commands there should
# not have side effects other than setting the cache variable, because
# they are not executed when a cached value exists.)
if test "x$cf_cv_lib_tgetent" != xno ; then
	test "x$cf_cv_lib_tgetent" != xyes && {
cf_add_libs="$cf_cv_lib_tgetent"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"
 }

cat >>confdefs.h <<\EOF
#define USE_TERMCAP 1
EOF

	if test "$cf_full_tgetent" = no ; then
		cat >conftest.$ac_ext <<_ACEOF
#line 5867 "configure"
#include "confdefs.h"

#include 
int
main (void)
{

#ifdef NCURSES_VERSION
make an error
#endif
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:5883: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:5886: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:5889: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:5892: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cat >>confdefs.h <<\EOF
#define HAVE_TERMCAP_H 1
EOF

else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
fi
rm -f conftest.$ac_objext conftest.$ac_ext
	else

for ac_header in termcap.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
echo "$as_me:5908: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 5914 "configure"
#include "confdefs.h"
#include <$ac_header>
_ACEOF
if { (eval echo "$as_me:5918: \"$ac_cpp conftest.$ac_ext\"") >&5
  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
  ac_status=$?
  egrep -v '^ *\+' conftest.er1 >conftest.err
  rm -f conftest.er1
  cat conftest.err >&5
  echo "$as_me:5924: \$? = $ac_status" >&5
  (exit $ac_status); } >/dev/null; then
  if test -s conftest.err; then
    ac_cpp_err=$ac_c_preproc_warn_flag
  else
    ac_cpp_err=
  fi
else
  ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
  eval "$as_ac_Header=yes"
else
  echo "$as_me: failed program was:" >&5
  cat conftest.$ac_ext >&5
  eval "$as_ac_Header=no"
fi
rm -f conftest.err conftest.$ac_ext
fi
echo "$as_me:5943: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
if test `eval echo '${'$as_ac_Header'}'` = yes; then
  cat >>confdefs.h <&5
echo $ECHO_N "checking for partial tgetent function... $ECHO_C" >&6
if test "${cf_cv_lib_part_tgetent+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

	cf_cv_lib_part_tgetent=no
	for cf_termlib in $cf_TERMLIB ; do
		LIBS="$cf_save_LIBS -l$cf_termlib"
		cat >conftest.$ac_ext <<_ACEOF
#line 5970 "configure"
#include "confdefs.h"

int
main (void)
{
tgetent(0, "$cf_TERMVAR")
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:5982: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:5985: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:5988: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:5991: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  echo "there is a terminfo/tgetent in $cf_termlib" 1>&5
			 cf_cv_lib_part_tgetent="-l$cf_termlib"
			 break
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
	done
	LIBS="$cf_save_LIBS"

fi
echo "$as_me:6005: result: $cf_cv_lib_part_tgetent" >&5
echo "${ECHO_T}$cf_cv_lib_part_tgetent" >&6

	if test "$cf_cv_lib_part_tgetent" != no ; then

cf_add_libs="$cf_cv_lib_part_tgetent"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

for ac_header in termcap.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
echo "$as_me:6029: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 6035 "configure"
#include "confdefs.h"
#include <$ac_header>
_ACEOF
if { (eval echo "$as_me:6039: \"$ac_cpp conftest.$ac_ext\"") >&5
  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
  ac_status=$?
  egrep -v '^ *\+' conftest.er1 >conftest.err
  rm -f conftest.er1
  cat conftest.err >&5
  echo "$as_me:6045: \$? = $ac_status" >&5
  (exit $ac_status); } >/dev/null; then
  if test -s conftest.err; then
    ac_cpp_err=$ac_c_preproc_warn_flag
  else
    ac_cpp_err=
  fi
else
  ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
  eval "$as_ac_Header=yes"
else
  echo "$as_me: failed program was:" >&5
  cat conftest.$ac_ext >&5
  eval "$as_ac_Header=no"
fi
rm -f conftest.err conftest.$ac_ext
fi
echo "$as_me:6064: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
if test `eval echo '${'$as_ac_Header'}'` = yes; then
  cat >>confdefs.h <>confdefs.h <<\EOF
#define USE_TERMINFO 1
EOF

	fi
fi

echo "$as_me:6084: checking for X applications class" >&5
echo $ECHO_N "checking for X applications class... $ECHO_C" >&6

# Check whether --with-app-class or --without-app-class was given.
if test "${with_app_class+set}" = set; then
  withval="$with_app_class"
  APP_CLASS=$withval
else
  APP_CLASS=XTerm
fi;

case x$APP_CLASS in
(*[/@,%]*)
	{ echo "$as_me:6097: WARNING: X applications class cannot contain punctuation" >&5
echo "$as_me: WARNING: X applications class cannot contain punctuation" >&2;}
	APP_CLASS=XTerm
	;;
(x[A-Z]*)
	;;
(*)
	{ echo "$as_me:6104: WARNING: X applications class must start with capital, ignoring $APP_CLASS" >&5
echo "$as_me: WARNING: X applications class must start with capital, ignoring $APP_CLASS" >&2;}
	APP_CLASS=XTerm
	;;
esac

echo "$as_me:6110: result: $APP_CLASS" >&5
echo "${ECHO_T}$APP_CLASS" >&6

echo "$as_me:6113: checking for directory to install resource files" >&5
echo $ECHO_N "checking for directory to install resource files... $ECHO_C" >&6

# Check whether --with-app-defaults or --without-app-defaults was given.
if test "${with_app_defaults+set}" = set; then
  withval="$with_app_defaults"
  APPSDIR=$withval
else
  APPSDIR='${exec_prefix}/lib/X11/app-defaults'
fi;

if test "x$APPSDIR" = xauto
then
	APPSDIR='${exec_prefix}/lib/X11/app-defaults'
	for cf_path in \
		/opt/local/share/X11/app-defaults \
		/opt/X11/share/X11/app-defaults \
		/usr/share/X11/app-defaults \
		/usr/X11/share/X11/app-defaults \
		/usr/X11/lib/X11/app-defaults \
		/usr/lib/X11/app-defaults \
		/etc/X11/app-defaults \
		/usr/pkg/lib/X11/app-defaults \
		/usr/X11R7/lib/X11/app-defaults \
		/usr/X11R6/lib/X11/app-defaults \
		/usr/X11R5/lib/X11/app-defaults \
		/usr/X11R4/lib/X11/app-defaults \
		/usr/local/lib/X11/app-defaults \
		/usr/local/share/X11/app-defaults \
		/usr/lib64/X11/app-defaults
	do
		if test -d "$cf_path" ; then
			APPSDIR="$cf_path"
			break
		fi
	done
else
	cf_path=$APPSDIR

if test "x$prefix" != xNONE; then
	cf_path_syntax="$prefix"
else
	cf_path_syntax="$ac_default_prefix"
fi

case ".$cf_path" in
(.\$\(*\)*|.\'*\'*)
	;;
(..|./*|.\\*)
	;;
(.[a-zA-Z]:[\\/]*) # OS/2 EMX
	;;
(.\${*prefix}*|.\${*dir}*)
	eval cf_path="$cf_path"
	case ".$cf_path" in
	(.NONE/*)
		cf_path=`echo $cf_path | sed -e s%NONE%$cf_path_syntax%`
		;;
	esac
	;;
(.no|.NONE/*)
	cf_path=`echo $cf_path | sed -e s%NONE%$cf_path_syntax%`
	;;
(*)
	{ { echo "$as_me:6177: error: expected a pathname, not \"$cf_path\"" >&5
echo "$as_me: error: expected a pathname, not \"$cf_path\"" >&2;}
   { (exit 1); exit 1; }; }
	;;
esac

fi

echo "$as_me:6185: result: $APPSDIR" >&5
echo "${ECHO_T}$APPSDIR" >&6

no_appsdir=
if test "$APPSDIR" = no
then
	no_appsdir="#"
else
	EXTRA_INSTALL_DIRS="$EXTRA_INSTALL_DIRS \$(APPSDIR)"
fi

echo "$as_me:6196: checking for the icon name" >&5
echo $ECHO_N "checking for the icon name... $ECHO_C" >&6

# Check whether --with-icon-name or --without-icon-name was given.
if test "${with_icon_name+set}" = set; then
  withval="$with_icon_name"
  ICON_NAME="$withval"
else
  ICON_NAME=xterm-color
fi;
case "x$ICON_NAME" in
(xyes|xno|x)
	ICON_NAME=xterm-color
	;;
esac

echo "$as_me:6212: result: $ICON_NAME" >&5
echo "${ECHO_T}$ICON_NAME" >&6

echo "$as_me:6215: checking for icon symlink to use" >&5
echo $ECHO_N "checking for icon symlink to use... $ECHO_C" >&6

# Check whether --with-icon-symlink or --without-icon-symlink was given.
if test "${with_icon_symlink+set}" = set; then
  withval="$with_icon_symlink"
  ICON_SYMLINK="$withval"
else
  ICON_SYMLINK=NONE
fi;
case "x$ICON_SYMLINK" in
(xyes)
	ICON_SYMLINK=xterm
	;;
(xno|x)
	ICON_SYMLINK=NONE
	;;
esac

echo "$as_me:6234: result: $ICON_SYMLINK" >&5
echo "${ECHO_T}$ICON_SYMLINK" >&6

echo "$as_me:6237: checking for directory to install pixmaps" >&5
echo $ECHO_N "checking for directory to install pixmaps... $ECHO_C" >&6

# Check whether --with-pixmapdir or --without-pixmapdir was given.
if test "${with_pixmapdir+set}" = set; then
  withval="$with_pixmapdir"
  PIXMAPDIR=$withval
else
  test -z "$PIXMAPDIR" && PIXMAPDIR='${datadir}/pixmaps'
fi;

if test "x$PIXMAPDIR" = xauto
then
	PIXMAPDIR='${datadir}/pixmaps'
	for cf_path in \
		/usr/share/pixmaps \
		/usr/X11R6/share/pixmaps
	do
		if test -d "$cf_path" ; then
			PIXMAPDIR="$cf_path"
			break
		fi
	done
else
	cf_path=$PIXMAPDIR

if test "x$prefix" != xNONE; then
	cf_path_syntax="$prefix"
else
	cf_path_syntax="$ac_default_prefix"
fi

case ".$cf_path" in
(.\$\(*\)*|.\'*\'*)
	;;
(..|./*|.\\*)
	;;
(.[a-zA-Z]:[\\/]*) # OS/2 EMX
	;;
(.\${*prefix}*|.\${*dir}*)
	eval cf_path="$cf_path"
	case ".$cf_path" in
	(.NONE/*)
		cf_path=`echo $cf_path | sed -e s%NONE%$cf_path_syntax%`
		;;
	esac
	;;
(.no|.NONE/*)
	cf_path=`echo $cf_path | sed -e s%NONE%$cf_path_syntax%`
	;;
(*)
	{ { echo "$as_me:6288: error: expected a pathname, not \"$cf_path\"" >&5
echo "$as_me: error: expected a pathname, not \"$cf_path\"" >&2;}
   { (exit 1); exit 1; }; }
	;;
esac

fi
echo "$as_me:6295: result: $PIXMAPDIR" >&5
echo "${ECHO_T}$PIXMAPDIR" >&6

no_pixmapdir=
if test "$PIXMAPDIR" = no
then
	no_pixmapdir="#"
else
	EXTRA_INSTALL_DIRS="$EXTRA_INSTALL_DIRS \$(PIXMAPDIR)"
fi

echo "$as_me:6306: checking for directory to install icons" >&5
echo $ECHO_N "checking for directory to install icons... $ECHO_C" >&6

# Check whether --with-icondir or --without-icondir was given.
if test "${with_icondir+set}" = set; then
  withval="$with_icondir"
  ICONDIR=$withval
else
  test -z "$ICONDIR" && ICONDIR=no
fi;

if test "x$ICONDIR" = xauto
then
	ICONDIR='${datadir}/icons'
	for cf_path in \
		/usr/share/icons \
		/usr/X11R6/share/icons
	do
		if test -d "$cf_path" ; then
			ICONDIR="$cf_path"
			break
		fi
	done
else
	cf_path=$ICONDIR

if test "x$prefix" != xNONE; then
	cf_path_syntax="$prefix"
else
	cf_path_syntax="$ac_default_prefix"
fi

case ".$cf_path" in
(.\$\(*\)*|.\'*\'*)
	;;
(..|./*|.\\*)
	;;
(.[a-zA-Z]:[\\/]*) # OS/2 EMX
	;;
(.\${*prefix}*|.\${*dir}*)
	eval cf_path="$cf_path"
	case ".$cf_path" in
	(.NONE/*)
		cf_path=`echo $cf_path | sed -e s%NONE%$cf_path_syntax%`
		;;
	esac
	;;
(.no|.NONE/*)
	cf_path=`echo $cf_path | sed -e s%NONE%$cf_path_syntax%`
	;;
(*)
	{ { echo "$as_me:6357: error: expected a pathname, not \"$cf_path\"" >&5
echo "$as_me: error: expected a pathname, not \"$cf_path\"" >&2;}
   { (exit 1); exit 1; }; }
	;;
esac

fi
echo "$as_me:6364: result: $ICONDIR" >&5
echo "${ECHO_T}$ICONDIR" >&6

no_icondir=
if test "$ICONDIR" = no
then
	no_icondir="#"
else
	EXTRA_INSTALL_DIRS="$EXTRA_INSTALL_DIRS \$(ICONDIR)"
fi

echo "$as_me:6375: checking if icon theme should be used" >&5
echo $ECHO_N "checking if icon theme should be used... $ECHO_C" >&6

# Check whether --with-icon-theme or --without-icon-theme was given.
if test "${with_icon_theme+set}" = set; then
  withval="$with_icon_theme"
  ICON_THEME=$withval
else
  ICON_THEME=no
fi;

case "x$ICON_THEME" in
(xno)
	;;
(x|xyes)
	ICON_THEME=hicolor
	;;
esac
echo "$as_me:6393: result: $ICON_THEME" >&5
echo "${ECHO_T}$ICON_THEME" >&6

if test "x$ICON_THEME" = xno
then
	if test "x$ICONDIR" != xno
	then
		test -n "$verbose" && echo "	ignoring icondir without theme" 1>&6

echo "${as_me:-configure}:6402: testing ignoring icondir without theme ..." 1>&5

		no_icondir="#"
	fi
else
	if test "x$ICONDIR" = xno
	then
		{ { echo "$as_me:6409: error: icondir must be set for icon theme" >&5
echo "$as_me: error: icondir must be set for icon theme" >&2;}
   { (exit 1); exit 1; }; }
	fi
fi

: ${ICON_FORMAT:=".svg .png .xpm"}

# ICON_NAME=
ICON_LIST=

if test "x$ICON_THEME" != xno
then
	cf_icon_list="icons/$ICON_NAME icons/${ICON_NAME}_48x48"
else
	cf_icon_list="icons/${ICON_NAME}_48x48"
fi

echo "$as_me:6427: checking for icon(s) to install" >&5
echo $ECHO_N "checking for icon(s) to install... $ECHO_C" >&6
for cf_name in $cf_icon_list
do
	test -n "$verbose" && echo "	using $ICON_FORMAT" 1>&6

echo "${as_me:-configure}:6433: testing using $ICON_FORMAT ..." 1>&5

	for cf_suffix in $ICON_FORMAT
	do
		cf_icon="${cf_name}${cf_suffix}"
		cf_left=`echo "$cf_icon" | sed -e 's/:.*//'`
		if test ! -f "${cf_left}"
		then
			if test "x$srcdir" != "x."
			then
				cf_icon="${srcdir}/${cf_left}"
				cf_left=`echo "$cf_icon" | sed -e 's/:.*//'`
				if test ! -f "${cf_left}"
				then
					continue
				fi
			else
				continue
			fi
		fi
		if test "x$ICON_THEME" != xno
		then
			cf_base=`basename $cf_left`
			cf_trim=`echo "$cf_base" | sed -e 's/_[0-9][0-9]x[0-9][0-9]\././'`
			case "x${cf_base}" in
			(*:*)
				cf_next=$cf_base
				# user-defined mapping
				;;
			(*.png)
				cf_size=`file "$cf_left"|sed -e 's/^[^:]*://' -e 's/^.*[^0-9]\([0-9][0-9]* x [0-9][0-9]*\)[^0-9].*$/\1/' -e 's/ //g'`
				if test -z "$cf_size"
				then
					{ echo "$as_me:6466: WARNING: cannot determine size of $cf_left" >&5
echo "$as_me: WARNING: cannot determine size of $cf_left" >&2;}
					continue
				fi
				cf_next="$cf_size/apps/$cf_trim"
				;;
			(*.svg)
				cf_next="scalable/apps/$cf_trim"
				;;
			(*.xpm)
				test -n "$verbose" && echo "	ignored XPM file in icon theme" 1>&6

echo "${as_me:-configure}:6478: testing ignored XPM file in icon theme ..." 1>&5

				continue
				;;
			(*_[0-9][0-9]*x[0-9][0-9]*.*)
				cf_size=`echo "$cf_left"|sed -e 's/^.*_\([0-9][0-9]*x[0-9][0-9]*\)\..*$/\1/'`
				cf_left=`echo "$cf_left"|sed -e 's/^\(.*\)_\([0-9][0-9]*x[0-9][0-9]*\)\(\..*\)$/\1\3/'`
				cf_next="$cf_size/apps/$cf_base"
				;;
			esac
			test -n "$verbose" && echo "	adding $cf_next" 1>&6

echo "${as_me:-configure}:6490: testing adding $cf_next ..." 1>&5

			cf_icon="${cf_icon}:${cf_next}"
		fi
		test -n "$ICON_LIST" && ICON_LIST="$ICON_LIST "
		ICON_LIST="$ICON_LIST${cf_icon}"
		if test -z "$ICON_NAME"
		then
			ICON_NAME=`basename $cf_icon | sed -e 's/[.:].*//'`
		fi
	done
done

if test -n "$verbose"
then
	echo "$as_me:6505: checking result" >&5
echo $ECHO_N "checking result... $ECHO_C" >&6
fi
echo "$as_me:6508: result: $ICON_LIST" >&5
echo "${ECHO_T}$ICON_LIST" >&6

if test -z "$ICON_LIST"
then
	{ { echo "$as_me:6513: error: no icons found" >&5
echo "$as_me: error: no icons found" >&2;}
   { (exit 1); exit 1; }; }
fi

echo "$as_me:6518: checking for icon name" >&5
echo $ECHO_N "checking for icon name... $ECHO_C" >&6
echo "$as_me:6520: result: $ICON_NAME" >&5
echo "${ECHO_T}$ICON_NAME" >&6

# Comment-out the install-desktop rule if the desktop-utils are not found.
echo "$as_me:6524: checking if you want to install desktop files" >&5
echo $ECHO_N "checking if you want to install desktop files... $ECHO_C" >&6

# Check whether --enable-desktop or --disable-desktop was given.
if test "${enable_desktop+set}" = set; then
  enableval="$enable_desktop"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_desktop=$enableval
	else
		enable_desktop=$enableval
	fi
else
  enableval=yes
	enable_desktop=$enableval

fi;
echo "$as_me:6541: result: $enable_desktop" >&5
echo "${ECHO_T}$enable_desktop" >&6

desktop_utils=
if test "$enable_desktop" = yes ; then
# Extract the first word of "desktop-file-install", so it can be a program name with args.
set dummy desktop-file-install; ac_word=$2
echo "$as_me:6548: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_desktop_utils+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  if test -n "$desktop_utils"; then
  ac_cv_prog_desktop_utils="$desktop_utils" # Let the user override the test.
else
  ac_save_IFS=$IFS; IFS=$ac_path_separator
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
  IFS=$ac_save_IFS
  test -z "$ac_dir" && ac_dir=.
  $as_executable_p "$ac_dir/$ac_word" || continue
ac_cv_prog_desktop_utils="yes"
echo "$as_me:6563: found $ac_dir/$ac_word" >&5
break
done

  test -z "$ac_cv_prog_desktop_utils" && ac_cv_prog_desktop_utils="no"
fi
fi
desktop_utils=$ac_cv_prog_desktop_utils
if test -n "$desktop_utils"; then
  echo "$as_me:6572: result: $desktop_utils" >&5
echo "${ECHO_T}$desktop_utils" >&6
else
  echo "$as_me:6575: result: no" >&5
echo "${ECHO_T}no" >&6
fi

fi

test "$desktop_utils" = yes && desktop_utils= || desktop_utils="#"

if test -z "$desktop_utils"
then
	echo "$as_me:6585: checking for requested desktop-category" >&5
echo $ECHO_N "checking for requested desktop-category... $ECHO_C" >&6

# Check whether --with-desktop-category or --without-desktop-category was given.
if test "${with_desktop_category+set}" = set; then
  withval="$with_desktop_category"
  cf_desktop_want=$withval
else
  cf_desktop_want=auto
fi;
	echo "$as_me:6595: result: $cf_desktop_want" >&5
echo "${ECHO_T}$cf_desktop_want" >&6

	if test "$cf_desktop_want" = auto
	then
		rm -rf conftest*
		cf_desktop_also=
		for cf_desktop_dir in  \
			/usr/share/app-install \
			/usr/share/applications
		do
			if test -d $cf_desktop_dir
			then
				find $cf_desktop_dir -name '*.desktop' | \
				while true
				do
					read cf_desktop_path
					test -z "$cf_desktop_path" && break
					cf_desktop_name=`basename $cf_desktop_path .desktop`
					case $cf_desktop_name in
					(xterm|*-xterm|*rxvt*|*konsole|*[Tt]erminal)
						test -n "$verbose" && echo "	inspect $cf_desktop_path" 1>&6

echo "${as_me:-configure}:6618: testing inspect $cf_desktop_path ..." 1>&5

						egrep '^Categories=' $cf_desktop_path | \
							tr ';' '\n' | \
							sed -e 's%^.*=%%' -e '/^$/d' >>conftest.1
						;;
					esac
				done
			fi
		done
		if test -s conftest.1
		then
			cf_desktop_last=
			sort conftest.1 | \
			while true
			do
				read cf_desktop_this
				test -z "$cf_desktop_this" && break
				case $cf_desktop_this in
				(Qt*|GTK*|KDE*|GNOME*|*XFCE*|*Xfce*)
					;;
				(System|TerminalEmulator|*)
					test "x$cf_desktop_last" != "x$cf_desktop_this" && echo $cf_desktop_this >>conftest.2
					;;
				esac
				cf_desktop_last=$cf_desktop_this
			done
			cf_desktop_want=`cat conftest.2 | tr '\n' ';'`
		fi
		if test -n "$cf_desktop_want"
		then
			if test "$cf_desktop_want" = auto
			then
				cf_desktop_want=
			else
				# do a sanity check on the semicolon-separated list, ignore on failure
				cf_desktop_test=`echo "$cf_desktop_want" | sed -e 's/[^;]//g'`
				test -z "$cf_desktop_test" && cf_desktop_want=
				cf_desktop_test=`echo "$cf_desktop_want" | sed -e 's/^.*;$/./g'`
				test -z "$cf_desktop_test" && cf_desktop_want=
			fi
		fi
		if test -z "$cf_desktop_want"
		then
			cf_desktop_want="`echo "System|TerminalEmulator|*" | sed -e 's/\*//g' -e 's/|/;/g' -e 's/;*$/;/g'`"
			test -n "$verbose" && echo "	no usable value found for desktop category" 1>&6

echo "${as_me:-configure}:6665: testing no usable value found for desktop category ..." 1>&5

		fi
	fi
	DESKTOP_CATEGORY=`echo "$cf_desktop_want" | sed -e 's/[ ,]/;/g'`
	test -n "$verbose" && echo "	will use Categories=$DESKTOP_CATEGORY" 1>&6

echo "${as_me:-configure}:6672: testing will use Categories=$DESKTOP_CATEGORY ..." 1>&5

fi

echo "$as_me:6676: checking for install-permissions reference" >&5
echo $ECHO_N "checking for install-permissions reference... $ECHO_C" >&6

# Check whether --with-reference or --without-reference was given.
if test "${with_reference+set}" = set; then
  withval="$with_reference"
  with_reference=$withval
else
  with_reference=xterm
fi;
echo "$as_me:6686: result: $with_reference" >&5
echo "${ECHO_T}$with_reference" >&6

with_full_paths=yes

	echo "$as_me:6691: checking for PATH separator" >&5
echo $ECHO_N "checking for PATH separator... $ECHO_C" >&6
	case $cf_cv_system_name in
	(os2*)	PATH_SEPARATOR=';'  ;;
	(*)	${PATH_SEPARATOR:=':'}  ;;
	esac

	echo "$as_me:6698: result: $PATH_SEPARATOR" >&5
echo "${ECHO_T}$PATH_SEPARATOR" >&6

test -z "$XTERM_PATH" && XTERM_PATH=$with_reference
for ac_prog in $XTERM_PATH $with_reference
do
  # Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo "$as_me:6706: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_path_XTERM_PATH+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  case $XTERM_PATH in
  [\\/]* | ?:[\\/]*)
  ac_cv_path_XTERM_PATH="$XTERM_PATH" # Let the user override the test with a path.
  ;;
  *)
  ac_save_IFS=$IFS; IFS=$ac_path_separator
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
  IFS=$ac_save_IFS
  test -z "$ac_dir" && ac_dir=.
  if $as_executable_p "$ac_dir/$ac_word"; then
   ac_cv_path_XTERM_PATH="$ac_dir/$ac_word"
   echo "$as_me:6723: found $ac_dir/$ac_word" >&5
   break
fi
done

  ;;
esac
fi
XTERM_PATH=$ac_cv_path_XTERM_PATH

if test -n "$XTERM_PATH"; then
  echo "$as_me:6734: result: $XTERM_PATH" >&5
echo "${ECHO_T}$XTERM_PATH" >&6
else
  echo "$as_me:6737: result: no" >&5
echo "${ECHO_T}no" >&6
fi

  test -n "$XTERM_PATH" && break
done
test -n "$XTERM_PATH" || XTERM_PATH="$XTERM_PATH"

cf_path_prog=""
cf_path_args=""
IFS="${IFS:- 	}"; cf_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR"
for cf_temp in $ac_cv_path_XTERM_PATH
do
	if test -z "$cf_path_prog" ; then
		if test "$with_full_paths" = yes ; then

if test "x$prefix" != xNONE; then
	cf_path_syntax="$prefix"
else
	cf_path_syntax="$ac_default_prefix"
fi

case ".$cf_temp" in
(.\$\(*\)*|.\'*\'*)
	;;
(..|./*|.\\*)
	;;
(.[a-zA-Z]:[\\/]*) # OS/2 EMX
	;;
(.\${*prefix}*|.\${*dir}*)
	eval cf_temp="$cf_temp"
	case ".$cf_temp" in
	(.NONE/*)
		cf_temp=`echo $cf_temp | sed -e s%NONE%$cf_path_syntax%`
		;;
	esac
	;;
(.no|.NONE/*)
	cf_temp=`echo $cf_temp | sed -e s%NONE%$cf_path_syntax%`
	;;
(*)
	break
	;;
esac

			cf_path_prog="$cf_temp"
		else
			cf_path_prog="`basename $cf_temp`"
		fi
	elif test -z "$cf_path_args" ; then
		cf_path_args="$cf_temp"
	else
		cf_path_args="$cf_path_args $cf_temp"
	fi
done
IFS="$cf_save_ifs"

if test -n "$cf_path_prog" ; then

echo "${as_me:-configure}:6796: testing defining path for ${cf_path_prog} ..." 1>&5

cat >>confdefs.h <>confdefs.h <&5
echo $ECHO_N "checking for symbolic link to create to $cf_name... $ECHO_C" >&6

# Check whether --with-xterm-symlink or --without-xterm-symlink was given.
if test "${with_xterm_symlink+set}" = set; then
  withval="$with_xterm_symlink"
  with_symlink=$withval
else
  with_symlink=xterm
fi;
echo "$as_me:6827: result: $with_symlink" >&5
echo "${ECHO_T}$with_symlink" >&6
test "$with_symlink" = yes && with_symlink=xterm
test -n "$with_symlink" && \
	test "$with_symlink" != no && \
	test "$with_symlink" != $cf_name && \
	XTERM_SYMLINK="$with_symlink"
fi

echo "$as_me:6836: checking if you want to disable openpty" >&5
echo $ECHO_N "checking if you want to disable openpty... $ECHO_C" >&6

# Check whether --enable-openpty or --disable-openpty was given.
if test "${enable_openpty+set}" = set; then
  enableval="$enable_openpty"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    disable_openpty=yes
	else
		disable_openpty=no
	fi
else
  enableval=yes
	disable_openpty=no

fi;
echo "$as_me:6853: result: $disable_openpty" >&5
echo "${ECHO_T}$disable_openpty" >&6

echo "$as_me:6856: checking if you want to disable setuid" >&5
echo $ECHO_N "checking if you want to disable setuid... $ECHO_C" >&6

# Check whether --enable-setuid or --disable-setuid was given.
if test "${enable_setuid+set}" = set; then
  enableval="$enable_setuid"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    disable_setuid=yes
	else
		disable_setuid=no
	fi
else
  enableval=yes
	disable_setuid=no

fi;
echo "$as_me:6873: result: $disable_setuid" >&5
echo "${ECHO_T}$disable_setuid" >&6

echo "$as_me:6876: checking if you want to disable setgid" >&5
echo $ECHO_N "checking if you want to disable setgid... $ECHO_C" >&6

# Check whether --enable-setgid or --disable-setgid was given.
if test "${enable_setgid+set}" = set; then
  enableval="$enable_setgid"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    disable_setgid=yes
	else
		disable_setgid=no
	fi
else
  enableval=yes
	disable_setgid=no

fi;
echo "$as_me:6893: result: $disable_setgid" >&5
echo "${ECHO_T}$disable_setgid" >&6

echo "$as_me:6896: checking if you want to run xterm setuid to a given user" >&5
echo $ECHO_N "checking if you want to run xterm setuid to a given user... $ECHO_C" >&6

# Check whether --with-setuid or --without-setuid was given.
if test "${with_setuid+set}" = set; then
  withval="$with_setuid"
  use_given_setuid=$withval
else
  use_given_setuid=no
fi;
echo "$as_me:6906: result: $use_given_setuid" >&5
echo "${ECHO_T}$use_given_setuid" >&6

if test "$use_given_setuid" != no ; then
	if test "$use_given_setuid" = yes ; then
		cf_cv_given_setuid=root
	else
		cf_cv_given_setuid=$use_given_setuid
	fi
	# inherit SINSTALL_OPTS from environment to allow packager to customize it.
	SINSTALL_OPTS="$SINSTALL_OPTS u+s -u $cf_cv_given_setuid"
fi

echo "$as_me:6919: checking if you want to run xterm setgid to match utmp/utmpx file" >&5
echo $ECHO_N "checking if you want to run xterm setgid to match utmp/utmpx file... $ECHO_C" >&6

# Check whether --with-utmp-setgid or --without-utmp-setgid was given.
if test "${with_utmp_setgid+set}" = set; then
  withval="$with_utmp_setgid"
  use_utmp_setgid=$withval
else
  use_utmp_setgid=no
fi;
echo "$as_me:6929: result: $use_utmp_setgid" >&5
echo "${ECHO_T}$use_utmp_setgid" >&6

if test "$use_utmp_setgid" != no ; then
	if test "$use_utmp_setgid" = yes ; then

if test $cf_cv_have_utmp != no ; then
echo "$as_me:6936: checking for utmp/utmpx group" >&5
echo $ECHO_N "checking for utmp/utmpx group... $ECHO_C" >&6
if test "${cf_cv_utmp_group+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

for cf_utmp_path in /var/adm /var/run
do
	for cf_utmp_file in utmpx utmp
	do
		if test -f $cf_utmp_path/$cf_utmp_file
		then
			cf_cv_utmp_group=root

			cf_option="-l -L"

			# Expect listing to have fields like this:
			#-r--r--r--   1 user      group       34293 Jul 18 16:29 pathname
			ls $cf_option $cf_utmp_path/$cf_utmp_file >conftest
			read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest conftest
				read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest &5
echo "${ECHO_T}$cf_cv_utmp_group" >&6
else
	{ { echo "$as_me:6981: error: cannot find utmp group" >&5
echo "$as_me: error: cannot find utmp group" >&2;}
   { (exit 1); exit 1; }; }
fi

	else
		cf_cv_utmp_group=$use_utmp_setgid
	fi
	if test "$cf_cv_posix_saved_ids" != yes ; then
		{ { echo "$as_me:6990: error: Your system does not support POSIX saved-ids" >&5
echo "$as_me: error: Your system does not support POSIX saved-ids" >&2;}
   { (exit 1); exit 1; }; }
	fi

cat >>confdefs.h <<\EOF
#define USE_UTMP_SETGID 1
EOF

	SINSTALL_OPTS="$SINSTALL_OPTS g+s -g $cf_cv_utmp_group"
fi

echo "$as_me:7002: checking if you want to link with utempter" >&5
echo $ECHO_N "checking if you want to link with utempter... $ECHO_C" >&6

# Check whether --with-utempter or --without-utempter was given.
if test "${with_utempter+set}" = set; then
  withval="$with_utempter"
  use_utempter=$withval
else
  use_utempter=no
fi;
echo "$as_me:7012: result: $use_utempter" >&5
echo "${ECHO_T}$use_utempter" >&6

if test "$use_utempter" = yes ; then

echo "$as_me:7017: checking if we can link with utempter library" >&5
echo $ECHO_N "checking if we can link with utempter library... $ECHO_C" >&6
if test "${cf_cv_have_utempter+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

cf_save_LIBS="$LIBS"

cf_add_libs="-lutempter"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

cat >conftest.$ac_ext <<_ACEOF
#line 7042 "configure"
#include "confdefs.h"

#include 

int
main (void)
{

	addToUtmp("/dev/tty", 0, 1);
	removeFromUtmp();

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:7059: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:7062: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:7065: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:7068: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then

	cf_cv_have_utempter=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5

	cf_cv_have_utempter=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS="$cf_save_LIBS"

fi
echo "$as_me:7082: result: $cf_cv_have_utempter" >&5
echo "${ECHO_T}$cf_cv_have_utempter" >&6
if test "$cf_cv_have_utempter" = yes ; then

cat >>confdefs.h <<\EOF
#define USE_UTEMPTER 1
EOF

cf_add_libs="-lutempter"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

fi

	test "$cf_cv_have_utempter" != yes && use_utempter=no
else
	use_utempter=no
fi

# Some configurations permit (or require) either setuid or setgid mode.
# Let the user decide.
if test "$use_utempter" = yes ; then
	if test "${enable_setuid+set}" != set ; then
		disable_setuid=yes
		test -n "$verbose" && echo "	No --disable-setuid option given, force to yes" 1>&6

echo "${as_me:-configure}:7120: testing No --disable-setuid option given, force to yes ..." 1>&5

	fi
fi

###	checks for external data

echo "$as_me:7127: checking if external errno is declared" >&5
echo $ECHO_N "checking if external errno is declared... $ECHO_C" >&6
if test "${cf_cv_dcl_errno+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

	cat >conftest.$ac_ext <<_ACEOF
#line 7134 "configure"
#include "confdefs.h"

#ifdef HAVE_STDLIB_H
#include 
#endif
#include 
#include 
#include 
int
main (void)
{
int x = (int) errno
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:7152: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:7155: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:7158: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:7161: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_dcl_errno=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_dcl_errno=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext

fi
echo "$as_me:7172: result: $cf_cv_dcl_errno" >&5
echo "${ECHO_T}$cf_cv_dcl_errno" >&6

if test "$cf_cv_dcl_errno" = no ; then

cf_result=`echo "decl_errno" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`

	cat >>confdefs.h <&5
echo $ECHO_N "checking if external errno exists... $ECHO_C" >&6
if test "${cf_cv_have_errno+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

	cat >conftest.$ac_ext <<_ACEOF
#line 7194 "configure"
#include "confdefs.h"

#undef errno
extern int errno;

int
main (void)
{
errno = 2
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:7209: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:7212: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:7215: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:7218: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_have_errno=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_have_errno=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext

fi
echo "$as_me:7229: result: $cf_cv_have_errno" >&5
echo "${ECHO_T}$cf_cv_have_errno" >&6

if test "$cf_cv_have_errno" = yes ; then

cf_result=`echo "have_errno" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`

	cat >>confdefs.h <&5
echo $ECHO_N "checking for explicit tty group name... $ECHO_C" >&6

# Check whether --with-tty-group or --without-tty-group was given.
if test "${with_tty_group+set}" = set; then
  withval="$with_tty_group"
  cf_tty_group=$withval
else
  cf_tty_group=auto...
fi;
test -z "$cf_tty_group"    && cf_tty_group=auto...
test "$cf_tty_group" = yes && cf_tty_group=auto...
echo "$as_me:7254: result: $cf_tty_group" >&5
echo "${ECHO_T}$cf_tty_group" >&6

if test "$cf_tty_group" = "auto..." ; then
echo "$as_me:7258: checking for tty group name" >&5
echo $ECHO_N "checking for tty group name... $ECHO_C" >&6
if test "${cf_cv_tty_group_name+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

# If we are configuring as root, it is hard to get a clue about the tty group.
# But we'll guess based on how our connection is set up - assuming it is done
# properly.

cf_uid=`id | sed -e 's/^^=*=//' -e 's/(.*$//'`
# )vi
if test "$cf_uid" != 0 ; then
cf_cv_tty_group_name=
cf_tty_name=`tty`
test "$cf_tty_name" = "not a tty" && cf_tty_name=/dev/tty
test -z "$cf_tty_name" && cf_tty_name=/dev/tty
if test -c "$cf_tty_name"
then
	cf_option="-l -L"

	# Expect listing to have fields like this:
	#-rwxrwxrwx   1 user      group       34293 Jul 18 16:29 pathname
	ls $cf_option $cf_tty_name >conftest.out
	read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest conftest.out
		read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest /dev/null 1>/dev/null ) then
		cf_cv_tty_group_name="tty"
	fi
	;;
esac
fi

fi
echo "$as_me:7311: result: $cf_cv_tty_group_name" >&5
echo "${ECHO_T}$cf_cv_tty_group_name" >&6
cf_tty_group="$cf_cv_tty_group_name"
else
	# if configure option, always do this

cat >>confdefs.h <<\EOF
#define USE_TTY_GROUP 1
EOF

fi

cat >>confdefs.h <&5
echo $ECHO_N "checking if we may use the $cf_tty_group group... $ECHO_C" >&6
if test "${cf_cv_tty_group+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

cf_tty_name=`tty`
if test "$cf_tty_name" != "not a tty"
then
if test "$cross_compiling" = yes; then
  cf_cv_tty_group=unknown
else
  cat >conftest.$ac_ext <<_ACEOF
#line 7344 "configure"
#include "confdefs.h"

#include 
#include 
#include 
#include 
int main()
{
	struct stat sb;
	struct group *ttygrp = getgrnam(TTY_GROUP_NAME);
	char *name = ttyname(0);

	endgrent();
	if (ttygrp != 0
	 && name != 0
	 && stat(name, &sb) == 0
	 && sb.st_gid != getgid()
	 && sb.st_gid == ttygrp->gr_gid) {
		${cf_cv_main_return:-return} (0);
	}
	${cf_cv_main_return:-return} (1);
}

_ACEOF
rm -f conftest$ac_exeext
if { (eval echo "$as_me:7370: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:7373: \$? = $ac_status" >&5
  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
  { (eval echo "$as_me:7375: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:7378: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_tty_group=yes
else
  echo "$as_me: program exited with status $ac_status" >&5
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_tty_group=no
fi
rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi
elif test "$cross_compiling" = yes; then
	cf_cv_tty_group=unknown
else
	cf_cv_tty_group=yes
fi

fi
echo "$as_me:7396: result: $cf_cv_tty_group" >&5
echo "${ECHO_T}$cf_cv_tty_group" >&6

if test $cf_cv_tty_group = no ; then
	{ echo "$as_me:7400: WARNING: Cannot use $cf_tty_group group" >&5
echo "$as_me: WARNING: Cannot use $cf_tty_group group" >&2;}
else
	cat >>confdefs.h <<\EOF
#define USE_TTY_GROUP 1
EOF

fi

###	checks for system services and user specified options

echo "$as_me:7411: checking for sys/wait.h that is POSIX.1 compatible" >&5
echo $ECHO_N "checking for sys/wait.h that is POSIX.1 compatible... $ECHO_C" >&6
if test "${ac_cv_header_sys_wait_h+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 7417 "configure"
#include "confdefs.h"
#include 
#include 
#ifndef WEXITSTATUS
# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
#endif
#ifndef WIFEXITED
# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
#endif

int
main (void)
{
  int s;
  wait (&s);
  s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:7439: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:7442: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:7445: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:7448: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_header_sys_wait_h=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_header_sys_wait_h=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:7458: result: $ac_cv_header_sys_wait_h" >&5
echo "${ECHO_T}$ac_cv_header_sys_wait_h" >&6
if test $ac_cv_header_sys_wait_h = yes; then

cat >>confdefs.h <<\EOF
#define HAVE_SYS_WAIT_H 1
EOF

fi

echo "$as_me:7468: checking for POSIX wait functions" >&5
echo $ECHO_N "checking for POSIX wait functions... $ECHO_C" >&6
if test "${cf_cv_posix_wait+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

cat >conftest.$ac_ext <<_ACEOF
#line 7475 "configure"
#include "confdefs.h"

#include 
#include 
#include 
#ifdef HAVE_SYS_WAIT_H
#include 
#endif

int
main (void)
{

	int stat_loc;
	pid_t pid = waitpid(-1, &stat_loc, WNOHANG|WUNTRACED);
	pid_t pid2 = wait(&stat_loc);

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:7498: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:7501: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:7504: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:7507: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_posix_wait=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_posix_wait=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext

fi
echo "$as_me:7518: result: $cf_cv_posix_wait" >&5
echo "${ECHO_T}$cf_cv_posix_wait" >&6
test "$cf_cv_posix_wait" = yes &&
cat >>confdefs.h <<\EOF
#define USE_POSIX_WAIT 1
EOF

echo "$as_me:7525: checking if external sys_nerr is declared" >&5
echo $ECHO_N "checking if external sys_nerr is declared... $ECHO_C" >&6
if test "${cf_cv_dcl_sys_nerr+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

	cat >conftest.$ac_ext <<_ACEOF
#line 7532 "configure"
#include "confdefs.h"

#ifdef HAVE_STDLIB_H
#include 
#endif
#include 
#include 
#include 
int
main (void)
{
int x = (int) sys_nerr
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:7550: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:7553: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:7556: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:7559: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_dcl_sys_nerr=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_dcl_sys_nerr=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext

fi
echo "$as_me:7570: result: $cf_cv_dcl_sys_nerr" >&5
echo "${ECHO_T}$cf_cv_dcl_sys_nerr" >&6

if test "$cf_cv_dcl_sys_nerr" = no ; then

cf_result=`echo "decl_sys_nerr" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`

	cat >>confdefs.h <&5
echo $ECHO_N "checking if external sys_nerr exists... $ECHO_C" >&6
if test "${cf_cv_have_sys_nerr+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

	cat >conftest.$ac_ext <<_ACEOF
#line 7592 "configure"
#include "confdefs.h"

#undef sys_nerr
extern int sys_nerr;

int
main (void)
{
sys_nerr = 2
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:7607: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:7610: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:7613: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:7616: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_have_sys_nerr=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_have_sys_nerr=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext

fi
echo "$as_me:7627: result: $cf_cv_have_sys_nerr" >&5
echo "${ECHO_T}$cf_cv_have_sys_nerr" >&6

if test "$cf_cv_have_sys_nerr" = yes ; then

cf_result=`echo "have_sys_nerr" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`

	cat >>confdefs.h <&5
echo $ECHO_N "checking if external sys_errlist is declared... $ECHO_C" >&6
if test "${cf_cv_dcl_sys_errlist+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

	cat >conftest.$ac_ext <<_ACEOF
#line 7647 "configure"
#include "confdefs.h"

#ifdef HAVE_STDLIB_H
#include 
#endif
#include 
#include 
#include 
int
main (void)
{
int x = (int) sys_errlist
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:7665: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:7668: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:7671: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:7674: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_dcl_sys_errlist=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_dcl_sys_errlist=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext

fi
echo "$as_me:7685: result: $cf_cv_dcl_sys_errlist" >&5
echo "${ECHO_T}$cf_cv_dcl_sys_errlist" >&6

if test "$cf_cv_dcl_sys_errlist" = no ; then

cf_result=`echo "decl_sys_errlist" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`

	cat >>confdefs.h <&5
echo $ECHO_N "checking if external sys_errlist exists... $ECHO_C" >&6
if test "${cf_cv_have_sys_errlist+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

	cat >conftest.$ac_ext <<_ACEOF
#line 7707 "configure"
#include "confdefs.h"

#undef sys_errlist
extern int sys_errlist;

int
main (void)
{
sys_errlist = 2
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:7722: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:7725: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:7728: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:7731: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_have_sys_errlist=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_have_sys_errlist=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext

fi
echo "$as_me:7742: result: $cf_cv_have_sys_errlist" >&5
echo "${ECHO_T}$cf_cv_have_sys_errlist" >&6

if test "$cf_cv_have_sys_errlist" = yes ; then

cf_result=`echo "have_sys_errlist" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`

	cat >>confdefs.h <&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 7768 "configure"
#include "confdefs.h"
#include <$ac_header>
_ACEOF
if { (eval echo "$as_me:7772: \"$ac_cpp conftest.$ac_ext\"") >&5
  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
  ac_status=$?
  egrep -v '^ *\+' conftest.er1 >conftest.err
  rm -f conftest.er1
  cat conftest.err >&5
  echo "$as_me:7778: \$? = $ac_status" >&5
  (exit $ac_status); } >/dev/null; then
  if test -s conftest.err; then
    ac_cpp_err=$ac_c_preproc_warn_flag
  else
    ac_cpp_err=
  fi
else
  ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
  eval "$as_ac_Header=yes"
else
  echo "$as_me: failed program was:" >&5
  cat conftest.$ac_ext >&5
  eval "$as_ac_Header=no"
fi
rm -f conftest.err conftest.$ac_ext
fi
echo "$as_me:7797: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
if test `eval echo '${'$as_ac_Header'}'` = yes; then
  cat >>confdefs.h <&5
echo $ECHO_N "checking if we should define SYSV... $ECHO_C" >&6
if test "${cf_cv_sysv+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

cat >conftest.$ac_ext <<_ACEOF
#line 7814 "configure"
#include "confdefs.h"

#undef  SYSV
#define SYSV 1			/* get Xos.h to declare sys_errlist[] */
#ifdef HAVE_STDLIB_H
#include 		/* look for wchar_t */
#endif
#ifdef HAVE_X11_INTRINSIC_H
#include 	/* Intrinsic.h has other traps... */
#endif
#ifdef HAVE_TERMIOS_H		/* needed for HPUX 10.20 */
#include 
#define STRUCT_TERMIOS struct termios
#else
#define STRUCT_TERMIOS struct termio
#endif
#include 
#include 		/* eliminate most BSD hacks */
#include 		/* declare sys_errlist on older systems */
#include 		/* eliminate most of the remaining ones */

int
main (void)
{

static STRUCT_TERMIOS d_tio;
	d_tio.c_cc[VINTR] = 0;
	d_tio.c_cc[VQUIT] = 0;
	d_tio.c_cc[VERASE] = 0;
	d_tio.c_cc[VKILL] = 0;
	d_tio.c_cc[VEOF] = 0;
	d_tio.c_cc[VEOL] = 0;
	d_tio.c_cc[VMIN] = 0;
	d_tio.c_cc[VTIME] = 0;
#if defined(HAVE_SYS_ERRLIST) && !defined(DECL_SYS_ERRLIST)
sys_errlist[0] = "";		/* Cygwin mis-declares this */
#endif

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:7858: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:7861: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:7864: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:7867: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_sysv=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_sysv=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext

fi
echo "$as_me:7878: result: $cf_cv_sysv" >&5
echo "${ECHO_T}$cf_cv_sysv" >&6
test "$cf_cv_sysv" = yes &&
cat >>confdefs.h <<\EOF
#define SYSV 1
EOF

echo "$as_me:7885: checking for elf_begin in -lelf" >&5
echo $ECHO_N "checking for elf_begin in -lelf... $ECHO_C" >&6
if test "${ac_cv_lib_elf_elf_begin+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lelf  $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line 7893 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char elf_begin ();
int
main (void)
{
elf_begin ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:7912: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:7915: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:7918: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:7921: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_lib_elf_elf_begin=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_lib_elf_elf_begin=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:7932: result: $ac_cv_lib_elf_elf_begin" >&5
echo "${ECHO_T}$ac_cv_lib_elf_elf_begin" >&6
if test $ac_cv_lib_elf_elf_begin = yes; then

echo "$as_me:7936: checking if this is an SVR4 system" >&5
echo $ECHO_N "checking if this is an SVR4 system... $ECHO_C" >&6
if test "${cf_cv_svr4+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

cat >conftest.$ac_ext <<_ACEOF
#line 7943 "configure"
#include "confdefs.h"

#if defined(__CYGWIN__)
make an error
#endif
#include 
#include 

int
main (void)
{

static struct termio d_tio;
	d_tio.c_cc[VINTR] = 0;
	d_tio.c_cc[VQUIT] = 0;
	d_tio.c_cc[VERASE] = 0;
	d_tio.c_cc[VKILL] = 0;
	d_tio.c_cc[VEOF] = 0;
	d_tio.c_cc[VEOL] = 0;
	d_tio.c_cc[VMIN] = 0;
	d_tio.c_cc[VTIME] = 0;
	d_tio.c_cc[VLNEXT] = 0;

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:7972: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:7975: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:7978: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:7981: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_svr4=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_svr4=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext

fi
echo "$as_me:7992: result: $cf_cv_svr4" >&5
echo "${ECHO_T}$cf_cv_svr4" >&6

fi

test "$cf_cv_svr4" = yes &&
cat >>confdefs.h <<\EOF
#define SVR4 1
EOF

echo "$as_me:8002: checking for X" >&5
echo $ECHO_N "checking for X... $ECHO_C" >&6

# Check whether --with-x or --without-x was given.
if test "${with_x+set}" = set; then
  withval="$with_x"

fi;
# $have_x is `yes', `no', `disabled', or empty when we do not yet know.
if test "x$with_x" = xno; then
  # The user explicitly disabled X.
  have_x=disabled
else
  if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then
    # Both variables are already set.
    have_x=yes
  else
    if test "${ac_cv_have_x+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  # One or both of the vars are not set, and there is no cached value.
ac_x_includes=no ac_x_libraries=no
rm -fr conftest.dir
if mkdir conftest.dir; then
  cd conftest.dir
  # Make sure to not put "make" in the Imakefile rules, since we grep it out.
  cat >Imakefile <<'EOF'
acfindx:
	@echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"'
EOF
  if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
    # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
    eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
    # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
    for ac_extension in a so sl dylib dll; do
      if test ! -f $ac_im_usrlibdir/libX11.$ac_extension &&
         test -f $ac_im_libdir/libX11.$ac_extension; then
        ac_im_usrlibdir=$ac_im_libdir; break
      fi
    done
    # Screen out bogus values from the imake configuration.  They are
    # bogus both because they are the default anyway, and because
    # using them would break gcc on systems where it needs fixed includes.
    case $ac_im_incroot in
	/usr/include) ;;
	*) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;;
    esac
    case $ac_im_usrlibdir in
	/usr/lib | /lib) ;;
	*) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;;
    esac
  fi
  cd ..
  rm -fr conftest.dir
fi

# Standard set of common directories for X headers.
# Check X11 before X11Rn because it is often a symlink to the current release.
ac_x_header_dirs='
/usr/X11/include
/usr/X11R6/include
/usr/X11R5/include
/usr/X11R4/include

/usr/include/X11
/usr/include/X11R6
/usr/include/X11R5
/usr/include/X11R4

/usr/local/X11/include
/usr/local/X11R6/include
/usr/local/X11R5/include
/usr/local/X11R4/include

/usr/local/include/X11
/usr/local/include/X11R6
/usr/local/include/X11R5
/usr/local/include/X11R4

/usr/X386/include
/usr/x386/include
/usr/XFree86/include/X11

/usr/include
/usr/local/include
/usr/unsupported/include
/usr/athena/include
/usr/local/x11r5/include
/usr/lpp/Xamples/include

/usr/openwin/include
/usr/openwin/share/include'

if test "$ac_x_includes" = no; then
  # Guess where to find include files, by looking for Intrinsic.h.
  # First, try using that file with no special directory specified.
  cat >conftest.$ac_ext <<_ACEOF
#line 8099 "configure"
#include "confdefs.h"
#include 
_ACEOF
if { (eval echo "$as_me:8103: \"$ac_cpp conftest.$ac_ext\"") >&5
  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
  ac_status=$?
  egrep -v '^ *\+' conftest.er1 >conftest.err
  rm -f conftest.er1
  cat conftest.err >&5
  echo "$as_me:8109: \$? = $ac_status" >&5
  (exit $ac_status); } >/dev/null; then
  if test -s conftest.err; then
    ac_cpp_err=$ac_c_preproc_warn_flag
  else
    ac_cpp_err=
  fi
else
  ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
  # We can compile using X headers with no special include directory.
ac_x_includes=
else
  echo "$as_me: failed program was:" >&5
  cat conftest.$ac_ext >&5
  for ac_dir in $ac_x_header_dirs; do
  if test -r "$ac_dir/X11/Intrinsic.h"; then
    ac_x_includes=$ac_dir
    break
  fi
done
fi
rm -f conftest.err conftest.$ac_ext
fi # $ac_x_includes = no

if test "$ac_x_libraries" = no; then
  # Check for the libraries.
  # See if we find them without any special options.
  # Don't add to $LIBS permanently.
  ac_save_LIBS=$LIBS
  LIBS="-lXt $LIBS"
  cat >conftest.$ac_ext <<_ACEOF
#line 8142 "configure"
#include "confdefs.h"
#include 
int
main (void)
{
XtMalloc (0)
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:8154: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:8157: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:8160: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:8163: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  LIBS=$ac_save_LIBS
# We can link X programs with no special library path.
ac_x_libraries=
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
LIBS=$ac_save_LIBS
for ac_dir in `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`
do
  # Don't even attempt the hair of trying to link an X program!
  for ac_extension in a so sl dylib dll; do
    if test -r $ac_dir/libXt.$ac_extension; then
      ac_x_libraries=$ac_dir
      break 2
    fi
  done
done
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi # $ac_x_libraries = no

if test "$ac_x_includes" = no || test "$ac_x_libraries" = no; then
  # Didn't find X anywhere.  Cache the known absence of X.
  ac_cv_have_x="have_x=no"
else
  # Record where we found X for the cache.
  ac_cv_have_x="have_x=yes \
	        ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries"
fi
fi

  fi
  eval "$ac_cv_have_x"
fi # $with_x != no

if test "$have_x" != yes; then
  echo "$as_me:8201: result: $have_x" >&5
echo "${ECHO_T}$have_x" >&6
  no_x=yes
else
  # If each of the values was on the command line, it overrides each guess.
  test "x$x_includes" = xNONE && x_includes=$ac_x_includes
  test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
  # Update the cache value to reflect the command line values.
  ac_cv_have_x="have_x=yes \
		ac_x_includes=$x_includes ac_x_libraries=$x_libraries"
  echo "$as_me:8211: result: libraries $x_libraries, headers $x_includes" >&5
echo "${ECHO_T}libraries $x_libraries, headers $x_includes" >&6
fi

if test "$no_x" = yes; then
  # Not all programs may use this symbol, but it does not hurt to define it.

cat >>confdefs.h <<\EOF
#define X_DISPLAY_MISSING 1
EOF

  X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS=
else
  if test -n "$x_includes"; then
    X_CFLAGS="$X_CFLAGS -I$x_includes"
  fi

  # It would also be nice to do this for all -L options, not just this one.
  if test -n "$x_libraries"; then
    X_LIBS="$X_LIBS -L$x_libraries"
    # For Solaris; some versions of Sun CC require a space after -R and
    # others require no space.  Words are not sufficient . . . .
    case `(uname -sr) 2>/dev/null` in
    "SunOS 5"*)
      echo "$as_me:8235: checking whether -R must be followed by a space" >&5
echo $ECHO_N "checking whether -R must be followed by a space... $ECHO_C" >&6
      ac_xsave_LIBS=$LIBS; LIBS="$LIBS -R$x_libraries"
      cat >conftest.$ac_ext <<_ACEOF
#line 8239 "configure"
#include "confdefs.h"

int
main (void)
{

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:8251: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:8254: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:8257: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:8260: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_R_nospace=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_R_nospace=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
      if test $ac_R_nospace = yes; then
	echo "$as_me:8270: result: no" >&5
echo "${ECHO_T}no" >&6
	X_LIBS="$X_LIBS -R$x_libraries"
      else
	LIBS="$ac_xsave_LIBS -R $x_libraries"
	cat >conftest.$ac_ext <<_ACEOF
#line 8276 "configure"
#include "confdefs.h"

int
main (void)
{

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:8288: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:8291: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:8294: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:8297: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_R_space=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_R_space=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
	if test $ac_R_space = yes; then
	  echo "$as_me:8307: result: yes" >&5
echo "${ECHO_T}yes" >&6
	  X_LIBS="$X_LIBS -R $x_libraries"
	else
	  echo "$as_me:8311: result: neither works" >&5
echo "${ECHO_T}neither works" >&6
	fi
      fi
      LIBS=$ac_xsave_LIBS
    esac
  fi

  # Check for system-dependent libraries X programs must link with.
  # Do this before checking for the system-independent R6 libraries
  # (-lICE), since we may need -lsocket or whatever for X linking.

  if test "$ISC" = yes; then
    X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet"
  else
    # Martyn Johnson says this is needed for Ultrix, if the X
    # libraries were built with DECnet support.  And Karl Berry says
    # the Alpha needs dnet_stub (dnet does not exist).
    ac_xsave_LIBS="$LIBS"; LIBS="$LIBS $X_LIBS -lX11"
    cat >conftest.$ac_ext <<_ACEOF
#line 8331 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char XOpenDisplay ();
int
main (void)
{
XOpenDisplay ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:8350: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:8353: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:8356: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:8359: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  :
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
echo "$as_me:8365: checking for dnet_ntoa in -ldnet" >&5
echo $ECHO_N "checking for dnet_ntoa in -ldnet... $ECHO_C" >&6
if test "${ac_cv_lib_dnet_dnet_ntoa+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-ldnet  $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line 8373 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char dnet_ntoa ();
int
main (void)
{
dnet_ntoa ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:8392: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:8395: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:8398: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:8401: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_lib_dnet_dnet_ntoa=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_lib_dnet_dnet_ntoa=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:8412: result: $ac_cv_lib_dnet_dnet_ntoa" >&5
echo "${ECHO_T}$ac_cv_lib_dnet_dnet_ntoa" >&6
if test $ac_cv_lib_dnet_dnet_ntoa = yes; then
  X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"
fi

    if test $ac_cv_lib_dnet_dnet_ntoa = no; then
      echo "$as_me:8419: checking for dnet_ntoa in -ldnet_stub" >&5
echo $ECHO_N "checking for dnet_ntoa in -ldnet_stub... $ECHO_C" >&6
if test "${ac_cv_lib_dnet_stub_dnet_ntoa+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-ldnet_stub  $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line 8427 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char dnet_ntoa ();
int
main (void)
{
dnet_ntoa ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:8446: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:8449: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:8452: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:8455: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_lib_dnet_stub_dnet_ntoa=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_lib_dnet_stub_dnet_ntoa=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:8466: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5
echo "${ECHO_T}$ac_cv_lib_dnet_stub_dnet_ntoa" >&6
if test $ac_cv_lib_dnet_stub_dnet_ntoa = yes; then
  X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"
fi

    fi
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
    LIBS="$ac_xsave_LIBS"

    # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT,
    # to get the SysV transport functions.
    # Chad R. Larson says the Pyramis MIS-ES running DC/OSx (SVR4)
    # needs -lnsl.
    # The nsl library prevents programs from opening the X display
    # on Irix 5.2, according to T.E. Dickey.
    # The functions gethostbyname, getservbyname, and inet_addr are
    # in -lbsd on LynxOS 3.0.1/i386, according to Lars Hecking.
    echo "$as_me:8485: checking for gethostbyname" >&5
echo $ECHO_N "checking for gethostbyname... $ECHO_C" >&6
if test "${ac_cv_func_gethostbyname+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 8491 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
    which can conflict with char gethostbyname (); below.  */
#include 
/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char gethostbyname ();
char (*f) ();

int
main (void)
{
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_gethostbyname) || defined (__stub___gethostbyname)
choke me
#else
f = gethostbyname; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
#endif

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:8522: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:8525: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:8528: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:8531: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_func_gethostbyname=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_func_gethostbyname=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:8541: result: $ac_cv_func_gethostbyname" >&5
echo "${ECHO_T}$ac_cv_func_gethostbyname" >&6

    if test $ac_cv_func_gethostbyname = no; then
      echo "$as_me:8545: checking for gethostbyname in -lnsl" >&5
echo $ECHO_N "checking for gethostbyname in -lnsl... $ECHO_C" >&6
if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lnsl  $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line 8553 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char gethostbyname ();
int
main (void)
{
gethostbyname ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:8572: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:8575: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:8578: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:8581: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_lib_nsl_gethostbyname=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_lib_nsl_gethostbyname=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:8592: result: $ac_cv_lib_nsl_gethostbyname" >&5
echo "${ECHO_T}$ac_cv_lib_nsl_gethostbyname" >&6
if test $ac_cv_lib_nsl_gethostbyname = yes; then
  X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl"
fi

      if test $ac_cv_lib_nsl_gethostbyname = no; then
        echo "$as_me:8599: checking for gethostbyname in -lbsd" >&5
echo $ECHO_N "checking for gethostbyname in -lbsd... $ECHO_C" >&6
if test "${ac_cv_lib_bsd_gethostbyname+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lbsd  $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line 8607 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char gethostbyname ();
int
main (void)
{
gethostbyname ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:8626: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:8629: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:8632: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:8635: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_lib_bsd_gethostbyname=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_lib_bsd_gethostbyname=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:8646: result: $ac_cv_lib_bsd_gethostbyname" >&5
echo "${ECHO_T}$ac_cv_lib_bsd_gethostbyname" >&6
if test $ac_cv_lib_bsd_gethostbyname = yes; then
  X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd"
fi

      fi
    fi

    # lieder@skyler.mavd.honeywell.com says without -lsocket,
    # socket/setsockopt and other routines are undefined under SCO ODT
    # 2.0.  But -lsocket is broken on IRIX 5.2 (and is not necessary
    # on later versions), says Simon Leinen: it contains gethostby*
    # variants that don't use the nameserver (or something).  -lsocket
    # must be given before -lnsl if both are needed.  We assume that
    # if connect needs -lnsl, so does gethostbyname.
    echo "$as_me:8662: checking for connect" >&5
echo $ECHO_N "checking for connect... $ECHO_C" >&6
if test "${ac_cv_func_connect+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 8668 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
    which can conflict with char connect (); below.  */
#include 
/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char connect ();
char (*f) ();

int
main (void)
{
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_connect) || defined (__stub___connect)
choke me
#else
f = connect; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
#endif

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:8699: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:8702: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:8705: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:8708: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_func_connect=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_func_connect=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:8718: result: $ac_cv_func_connect" >&5
echo "${ECHO_T}$ac_cv_func_connect" >&6

    if test $ac_cv_func_connect = no; then
      echo "$as_me:8722: checking for connect in -lsocket" >&5
echo $ECHO_N "checking for connect in -lsocket... $ECHO_C" >&6
if test "${ac_cv_lib_socket_connect+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lsocket $X_EXTRA_LIBS $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line 8730 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char connect ();
int
main (void)
{
connect ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:8749: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:8752: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:8755: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:8758: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_lib_socket_connect=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_lib_socket_connect=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:8769: result: $ac_cv_lib_socket_connect" >&5
echo "${ECHO_T}$ac_cv_lib_socket_connect" >&6
if test $ac_cv_lib_socket_connect = yes; then
  X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS"
fi

    fi

    # Guillermo Gomez says -lposix is necessary on A/UX.
    echo "$as_me:8778: checking for remove" >&5
echo $ECHO_N "checking for remove... $ECHO_C" >&6
if test "${ac_cv_func_remove+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 8784 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
    which can conflict with char remove (); below.  */
#include 
/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char remove ();
char (*f) ();

int
main (void)
{
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_remove) || defined (__stub___remove)
choke me
#else
f = remove; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
#endif

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:8815: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:8818: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:8821: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:8824: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_func_remove=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_func_remove=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:8834: result: $ac_cv_func_remove" >&5
echo "${ECHO_T}$ac_cv_func_remove" >&6

    if test $ac_cv_func_remove = no; then
      echo "$as_me:8838: checking for remove in -lposix" >&5
echo $ECHO_N "checking for remove in -lposix... $ECHO_C" >&6
if test "${ac_cv_lib_posix_remove+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lposix  $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line 8846 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char remove ();
int
main (void)
{
remove ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:8865: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:8868: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:8871: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:8874: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_lib_posix_remove=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_lib_posix_remove=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:8885: result: $ac_cv_lib_posix_remove" >&5
echo "${ECHO_T}$ac_cv_lib_posix_remove" >&6
if test $ac_cv_lib_posix_remove = yes; then
  X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix"
fi

    fi

    # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
    echo "$as_me:8894: checking for shmat" >&5
echo $ECHO_N "checking for shmat... $ECHO_C" >&6
if test "${ac_cv_func_shmat+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 8900 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
    which can conflict with char shmat (); below.  */
#include 
/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char shmat ();
char (*f) ();

int
main (void)
{
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_shmat) || defined (__stub___shmat)
choke me
#else
f = shmat; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
#endif

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:8931: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:8934: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:8937: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:8940: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_func_shmat=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_func_shmat=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:8950: result: $ac_cv_func_shmat" >&5
echo "${ECHO_T}$ac_cv_func_shmat" >&6

    if test $ac_cv_func_shmat = no; then
      echo "$as_me:8954: checking for shmat in -lipc" >&5
echo $ECHO_N "checking for shmat in -lipc... $ECHO_C" >&6
if test "${ac_cv_lib_ipc_shmat+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lipc  $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line 8962 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char shmat ();
int
main (void)
{
shmat ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:8981: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:8984: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:8987: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:8990: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_lib_ipc_shmat=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_lib_ipc_shmat=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:9001: result: $ac_cv_lib_ipc_shmat" >&5
echo "${ECHO_T}$ac_cv_lib_ipc_shmat" >&6
if test $ac_cv_lib_ipc_shmat = yes; then
  X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc"
fi

    fi
  fi

  # Check for libraries that X11R6 Xt/Xaw programs need.
  ac_save_LDFLAGS=$LDFLAGS
  test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries"
  # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to
  # check for ICE first), but we must link in the order -lSM -lICE or
  # we get undefined symbols.  So assume we have SM if we have ICE.
  # These have to be linked with before -lX11, unlike the other
  # libraries we check for below, so use a different variable.
  # John Interrante, Karl Berry
  echo "$as_me:9019: checking for IceConnectionNumber in -lICE" >&5
echo $ECHO_N "checking for IceConnectionNumber in -lICE... $ECHO_C" >&6
if test "${ac_cv_lib_ICE_IceConnectionNumber+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lICE $X_EXTRA_LIBS $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line 9027 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char IceConnectionNumber ();
int
main (void)
{
IceConnectionNumber ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:9046: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:9049: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:9052: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:9055: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_lib_ICE_IceConnectionNumber=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_lib_ICE_IceConnectionNumber=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:9066: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5
echo "${ECHO_T}$ac_cv_lib_ICE_IceConnectionNumber" >&6
if test $ac_cv_lib_ICE_IceConnectionNumber = yes; then
  X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE"
fi

  LDFLAGS=$ac_save_LDFLAGS

fi

echo "$as_me:9076: checking if you want to use pkg-config" >&5
echo $ECHO_N "checking if you want to use pkg-config... $ECHO_C" >&6

# Check whether --with-pkg-config or --without-pkg-config was given.
if test "${with_pkg_config+set}" = set; then
  withval="$with_pkg_config"
  cf_pkg_config=$withval
else
  cf_pkg_config=yes
fi;
echo "$as_me:9086: result: $cf_pkg_config" >&5
echo "${ECHO_T}$cf_pkg_config" >&6

case $cf_pkg_config in
(no)
	PKG_CONFIG=none
	;;
(yes)

if test -n "$ac_tool_prefix"; then
  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
echo "$as_me:9098: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_path_PKG_CONFIG+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  case $PKG_CONFIG in
  [\\/]* | ?:[\\/]*)
  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
  ;;
  *)
  ac_save_IFS=$IFS; IFS=$ac_path_separator
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
  IFS=$ac_save_IFS
  test -z "$ac_dir" && ac_dir=.
  if $as_executable_p "$ac_dir/$ac_word"; then
   ac_cv_path_PKG_CONFIG="$ac_dir/$ac_word"
   echo "$as_me:9115: found $ac_dir/$ac_word" >&5
   break
fi
done

  ;;
esac
fi
PKG_CONFIG=$ac_cv_path_PKG_CONFIG

if test -n "$PKG_CONFIG"; then
  echo "$as_me:9126: result: $PKG_CONFIG" >&5
echo "${ECHO_T}$PKG_CONFIG" >&6
else
  echo "$as_me:9129: result: no" >&5
echo "${ECHO_T}no" >&6
fi

fi
if test -z "$ac_cv_path_PKG_CONFIG"; then
  ac_pt_PKG_CONFIG=$PKG_CONFIG
  # Extract the first word of "pkg-config", so it can be a program name with args.
set dummy pkg-config; ac_word=$2
echo "$as_me:9138: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  case $ac_pt_PKG_CONFIG in
  [\\/]* | ?:[\\/]*)
  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
  ;;
  *)
  ac_save_IFS=$IFS; IFS=$ac_path_separator
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
  IFS=$ac_save_IFS
  test -z "$ac_dir" && ac_dir=.
  if $as_executable_p "$ac_dir/$ac_word"; then
   ac_cv_path_ac_pt_PKG_CONFIG="$ac_dir/$ac_word"
   echo "$as_me:9155: found $ac_dir/$ac_word" >&5
   break
fi
done

  test -z "$ac_cv_path_ac_pt_PKG_CONFIG" && ac_cv_path_ac_pt_PKG_CONFIG="none"
  ;;
esac
fi
ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG

if test -n "$ac_pt_PKG_CONFIG"; then
  echo "$as_me:9167: result: $ac_pt_PKG_CONFIG" >&5
echo "${ECHO_T}$ac_pt_PKG_CONFIG" >&6
else
  echo "$as_me:9170: result: no" >&5
echo "${ECHO_T}no" >&6
fi

  PKG_CONFIG=$ac_pt_PKG_CONFIG
else
  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
fi

	;;
(*)
	PKG_CONFIG=$withval
	;;
esac

test -z "$PKG_CONFIG" && PKG_CONFIG=none
if test "$PKG_CONFIG" != none ; then

if test "x$prefix" != xNONE; then
	cf_path_syntax="$prefix"
else
	cf_path_syntax="$ac_default_prefix"
fi

case ".$PKG_CONFIG" in
(.\$\(*\)*|.\'*\'*)
	;;
(..|./*|.\\*)
	;;
(.[a-zA-Z]:[\\/]*) # OS/2 EMX
	;;
(.\${*prefix}*|.\${*dir}*)
	eval PKG_CONFIG="$PKG_CONFIG"
	case ".$PKG_CONFIG" in
	(.NONE/*)
		PKG_CONFIG=`echo $PKG_CONFIG | sed -e s%NONE%$cf_path_syntax%`
		;;
	esac
	;;
(.no|.NONE/*)
	PKG_CONFIG=`echo $PKG_CONFIG | sed -e s%NONE%$cf_path_syntax%`
	;;
(*)
	{ { echo "$as_me:9213: error: expected a pathname, not \"$PKG_CONFIG\"" >&5
echo "$as_me: error: expected a pathname, not \"$PKG_CONFIG\"" >&2;}
   { (exit 1); exit 1; }; }
	;;
esac

elif test "x$cf_pkg_config" != xno ; then
	{ echo "$as_me:9220: WARNING: pkg-config is not installed" >&5
echo "$as_me: WARNING: pkg-config is not installed" >&2;}
fi

# OSX is schizoid about who owns /usr/X11 (old) versus /opt/X11 (new), and (and
# in some cases has installed dummy files in the former, other cases replaced
# it with a link to the new location).  This complicates the configure script.
# Check for that pitfall, and recover using pkg-config
#
# If none of these are set, the configuration is almost certainly broken.
if test -z "${X_CFLAGS}${X_PRE_LIBS}${X_LIBS}${X_EXTRA_LIBS}"
then

if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists x11; then
	test -n "$verbose" && echo "	found package x11" 1>&6

echo "${as_me:-configure}:9236: testing found package x11 ..." 1>&5

	cf_pkgconfig_incs="`$PKG_CONFIG --cflags x11 2>/dev/null`"
	cf_pkgconfig_libs="`$PKG_CONFIG --libs   x11 2>/dev/null`"
	test -n "$verbose" && echo "	package x11 CFLAGS: $cf_pkgconfig_incs" 1>&6

echo "${as_me:-configure}:9242: testing package x11 CFLAGS: $cf_pkgconfig_incs ..." 1>&5

	test -n "$verbose" && echo "	package x11 LIBS: $cf_pkgconfig_libs" 1>&6

echo "${as_me:-configure}:9246: testing package x11 LIBS: $cf_pkgconfig_libs ..." 1>&5

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_pkgconfig_incs
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

cf_add_libs="$cf_pkgconfig_libs"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

	:
else
	cf_pkgconfig_incs=
	cf_pkgconfig_libs=
	{ echo "$as_me:9366: WARNING: unable to find X11 library" >&5
echo "$as_me: WARNING: unable to find X11 library" >&2;}
fi

if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists ice; then
	test -n "$verbose" && echo "	found package ice" 1>&6

echo "${as_me:-configure}:9373: testing found package ice ..." 1>&5

	cf_pkgconfig_incs="`$PKG_CONFIG --cflags ice 2>/dev/null`"
	cf_pkgconfig_libs="`$PKG_CONFIG --libs   ice 2>/dev/null`"
	test -n "$verbose" && echo "	package ice CFLAGS: $cf_pkgconfig_incs" 1>&6

echo "${as_me:-configure}:9379: testing package ice CFLAGS: $cf_pkgconfig_incs ..." 1>&5

	test -n "$verbose" && echo "	package ice LIBS: $cf_pkgconfig_libs" 1>&6

echo "${as_me:-configure}:9383: testing package ice LIBS: $cf_pkgconfig_libs ..." 1>&5

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_pkgconfig_incs
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

cf_add_libs="$cf_pkgconfig_libs"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

	:
else
	cf_pkgconfig_incs=
	cf_pkgconfig_libs=
	{ echo "$as_me:9503: WARNING: unable to find ICE library" >&5
echo "$as_me: WARNING: unable to find ICE library" >&2;}
fi

if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists sm; then
	test -n "$verbose" && echo "	found package sm" 1>&6

echo "${as_me:-configure}:9510: testing found package sm ..." 1>&5

	cf_pkgconfig_incs="`$PKG_CONFIG --cflags sm 2>/dev/null`"
	cf_pkgconfig_libs="`$PKG_CONFIG --libs   sm 2>/dev/null`"
	test -n "$verbose" && echo "	package sm CFLAGS: $cf_pkgconfig_incs" 1>&6

echo "${as_me:-configure}:9516: testing package sm CFLAGS: $cf_pkgconfig_incs ..." 1>&5

	test -n "$verbose" && echo "	package sm LIBS: $cf_pkgconfig_libs" 1>&6

echo "${as_me:-configure}:9520: testing package sm LIBS: $cf_pkgconfig_libs ..." 1>&5

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_pkgconfig_incs
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

cf_add_libs="$cf_pkgconfig_libs"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

	:
else
	cf_pkgconfig_incs=
	cf_pkgconfig_libs=
	{ echo "$as_me:9640: WARNING: unable to find SM library" >&5
echo "$as_me: WARNING: unable to find SM library" >&2;}
fi

if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xt; then
	test -n "$verbose" && echo "	found package xt" 1>&6

echo "${as_me:-configure}:9647: testing found package xt ..." 1>&5

	cf_pkgconfig_incs="`$PKG_CONFIG --cflags xt 2>/dev/null`"
	cf_pkgconfig_libs="`$PKG_CONFIG --libs   xt 2>/dev/null`"
	test -n "$verbose" && echo "	package xt CFLAGS: $cf_pkgconfig_incs" 1>&6

echo "${as_me:-configure}:9653: testing package xt CFLAGS: $cf_pkgconfig_incs ..." 1>&5

	test -n "$verbose" && echo "	package xt LIBS: $cf_pkgconfig_libs" 1>&6

echo "${as_me:-configure}:9657: testing package xt LIBS: $cf_pkgconfig_libs ..." 1>&5

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_pkgconfig_incs
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

cf_add_libs="$cf_pkgconfig_libs"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

	:
else
	cf_pkgconfig_incs=
	cf_pkgconfig_libs=
	{ echo "$as_me:9777: WARNING: unable to find Xt library" >&5
echo "$as_me: WARNING: unable to find Xt library" >&2;}
fi

fi

cf_have_X_LIBS=no

if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xt; then
	test -n "$verbose" && echo "	found package xt" 1>&6

echo "${as_me:-configure}:9788: testing found package xt ..." 1>&5

	cf_pkgconfig_incs="`$PKG_CONFIG --cflags xt 2>/dev/null`"
	cf_pkgconfig_libs="`$PKG_CONFIG --libs   xt 2>/dev/null`"
	test -n "$verbose" && echo "	package xt CFLAGS: $cf_pkgconfig_incs" 1>&6

echo "${as_me:-configure}:9794: testing package xt CFLAGS: $cf_pkgconfig_incs ..." 1>&5

	test -n "$verbose" && echo "	package xt LIBS: $cf_pkgconfig_libs" 1>&6

echo "${as_me:-configure}:9798: testing package xt LIBS: $cf_pkgconfig_libs ..." 1>&5

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_pkgconfig_incs
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

cf_add_libs="$cf_pkgconfig_libs"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

	case "x$LIBS" in
	(*-lX11*)
		;;
	(*)
# we have an "xt" package, but it may omit Xt's dependency on X11
echo "$as_me:9919: checking for usable X dependency" >&5
echo $ECHO_N "checking for usable X dependency... $ECHO_C" >&6
if test "${cf_cv_xt_x11_compat+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

cat >conftest.$ac_ext <<_ACEOF
#line 9926 "configure"
#include "confdefs.h"

#include 

int
main (void)
{

	int rc1 = XDrawLine((Display*) 0, (Drawable) 0, (GC) 0, 0, 0, 0, 0);
	int rc2 = XClearWindow((Display*) 0, (Window) 0);
	int rc3 = XMoveWindow((Display*) 0, (Window) 0, 0, 0);
	int rc4 = XMoveResizeWindow((Display*)0, (Window)0, 0, 0, 0, 0);

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:9945: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:9948: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:9951: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:9954: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_xt_x11_compat=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_xt_x11_compat=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:9964: result: $cf_cv_xt_x11_compat" >&5
echo "${ECHO_T}$cf_cv_xt_x11_compat" >&6
		if test "$cf_cv_xt_x11_compat" = no
		then
			test -n "$verbose" && echo "	work around broken X11 dependency" 1>&6

echo "${as_me:-configure}:9970: testing work around broken X11 dependency ..." 1>&5

			# 2010/11/19 - good enough until a working Xt on Xcb is delivered.

if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists x11; then
	test -n "$verbose" && echo "	found package x11" 1>&6

echo "${as_me:-configure}:9977: testing found package x11 ..." 1>&5

	cf_pkgconfig_incs="`$PKG_CONFIG --cflags x11 2>/dev/null`"
	cf_pkgconfig_libs="`$PKG_CONFIG --libs   x11 2>/dev/null`"
	test -n "$verbose" && echo "	package x11 CFLAGS: $cf_pkgconfig_incs" 1>&6

echo "${as_me:-configure}:9983: testing package x11 CFLAGS: $cf_pkgconfig_incs ..." 1>&5

	test -n "$verbose" && echo "	package x11 LIBS: $cf_pkgconfig_libs" 1>&6

echo "${as_me:-configure}:9987: testing package x11 LIBS: $cf_pkgconfig_libs ..." 1>&5

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_pkgconfig_incs
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

cf_add_libs="$cf_pkgconfig_libs"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

	:
else
	cf_pkgconfig_incs=
	cf_pkgconfig_libs=

test -n "$verbose" && echo "	...before $LIBS" 1>&6

echo "${as_me:-configure}:10110: testing ...before $LIBS ..." 1>&5

LIBS=`echo "$LIBS" | sed -e "s/[ 	][ 	]*/ /g" -e "s%-lXt %-lXt -lX11 %" -e 's%  % %g'`
test -n "$verbose" && echo "	...after  $LIBS" 1>&6

echo "${as_me:-configure}:10115: testing ...after  $LIBS ..." 1>&5

fi

		fi
		;;
	esac

echo "$as_me:10123: checking for usable X Toolkit package" >&5
echo $ECHO_N "checking for usable X Toolkit package... $ECHO_C" >&6
if test "${cf_cv_xt_ice_compat+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

cat >conftest.$ac_ext <<_ACEOF
#line 10130 "configure"
#include "confdefs.h"

#include 

int
main (void)
{
int num = IceConnectionNumber(0)

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:10145: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:10148: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:10151: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:10154: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_xt_ice_compat=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_xt_ice_compat=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:10164: result: $cf_cv_xt_ice_compat" >&5
echo "${ECHO_T}$cf_cv_xt_ice_compat" >&6

	if test "$cf_cv_xt_ice_compat" = no
	then
		# workaround for broken ".pc" files used for X Toolkit.
		case "x$X_PRE_LIBS" in
		(*-lICE*)
			case "x$LIBS" in
			(*-lICE*)
				;;
			(*)
				test -n "$verbose" && echo "	work around broken ICE dependency" 1>&6

echo "${as_me:-configure}:10178: testing work around broken ICE dependency ..." 1>&5

if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists ice; then
	test -n "$verbose" && echo "	found package ice" 1>&6

echo "${as_me:-configure}:10183: testing found package ice ..." 1>&5

	cf_pkgconfig_incs="`$PKG_CONFIG --cflags ice 2>/dev/null`"
	cf_pkgconfig_libs="`$PKG_CONFIG --libs   ice 2>/dev/null`"
	test -n "$verbose" && echo "	package ice CFLAGS: $cf_pkgconfig_incs" 1>&6

echo "${as_me:-configure}:10189: testing package ice CFLAGS: $cf_pkgconfig_incs ..." 1>&5

	test -n "$verbose" && echo "	package ice LIBS: $cf_pkgconfig_libs" 1>&6

echo "${as_me:-configure}:10193: testing package ice LIBS: $cf_pkgconfig_libs ..." 1>&5

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_pkgconfig_incs
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

cf_add_libs="$cf_pkgconfig_libs"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists sm; then
	test -n "$verbose" && echo "	found package sm" 1>&6

echo "${as_me:-configure}:10312: testing found package sm ..." 1>&5

	cf_pkgconfig_incs="`$PKG_CONFIG --cflags sm 2>/dev/null`"
	cf_pkgconfig_libs="`$PKG_CONFIG --libs   sm 2>/dev/null`"
	test -n "$verbose" && echo "	package sm CFLAGS: $cf_pkgconfig_incs" 1>&6

echo "${as_me:-configure}:10318: testing package sm CFLAGS: $cf_pkgconfig_incs ..." 1>&5

	test -n "$verbose" && echo "	package sm LIBS: $cf_pkgconfig_libs" 1>&6

echo "${as_me:-configure}:10322: testing package sm LIBS: $cf_pkgconfig_libs ..." 1>&5

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_pkgconfig_incs
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

cf_add_libs="$cf_pkgconfig_libs"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

	:
else
	cf_pkgconfig_incs=
	cf_pkgconfig_libs=
	:
fi

else
	cf_pkgconfig_incs=
	cf_pkgconfig_libs=

test -n "$verbose" && echo "	...before $LIBS" 1>&6

echo "${as_me:-configure}:10451: testing ...before $LIBS ..." 1>&5

LIBS=`echo "$LIBS" | sed -e "s/[ 	][ 	]*/ /g" -e "s%-lXt %-lXt $X_PRE_LIBS %" -e 's%  % %g'`
test -n "$verbose" && echo "	...after  $LIBS" 1>&6

echo "${as_me:-configure}:10456: testing ...after  $LIBS ..." 1>&5

fi

				;;
			esac
			;;
		esac
	fi

	cf_have_X_LIBS=yes

else
	cf_pkgconfig_incs=
	cf_pkgconfig_libs=

	LDFLAGS="$X_LIBS $LDFLAGS"

test -n "$verbose" && echo "	checking additions to CFLAGS" 1>&6

echo "${as_me:-configure}:10476: testing checking additions to CFLAGS ..." 1>&5

cf_check_cflags="$CFLAGS"
cf_check_cppflags="$CPPFLAGS"

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $X_CFLAGS
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then
	test -n "$verbose" && echo "	add to \$CFLAGS $cf_new_cflags" 1>&6

echo "${as_me:-configure}:10561: testing add to \$CFLAGS $cf_new_cflags ..." 1>&5

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then
	test -n "$verbose" && echo "	add to \$CPPFLAGS $cf_new_cppflags" 1>&6

echo "${as_me:-configure}:10571: testing add to \$CPPFLAGS $cf_new_cppflags ..." 1>&5

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then
	test -n "$verbose" && echo "	add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags" 1>&6

echo "${as_me:-configure}:10581: testing add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags ..." 1>&5

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

if test "x$cf_check_cflags" != "x$CFLAGS" ; then
cat >conftest.$ac_ext <<_ACEOF
#line 10590 "configure"
#include "confdefs.h"
#include 
int
main (void)
{
printf("Hello world");
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:10602: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:10605: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:10608: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:10611: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  :
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
test -n "$verbose" && echo "	test-compile failed.  Undoing change to \$CFLAGS" 1>&6

echo "${as_me:-configure}:10619: testing test-compile failed.  Undoing change to \$CFLAGS ..." 1>&5

	 if test "x$cf_check_cppflags" != "x$CPPFLAGS" ; then
		 test -n "$verbose" && echo "	but keeping change to \$CPPFLAGS" 1>&6

echo "${as_me:-configure}:10624: testing but keeping change to \$CPPFLAGS ..." 1>&5

	 fi
	 CFLAGS="$cf_check_flags"
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi

	echo "$as_me:10632: checking for XOpenDisplay" >&5
echo $ECHO_N "checking for XOpenDisplay... $ECHO_C" >&6
if test "${ac_cv_func_XOpenDisplay+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 10638 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
    which can conflict with char XOpenDisplay (); below.  */
#include 
/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char XOpenDisplay ();
char (*f) ();

int
main (void)
{
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_XOpenDisplay) || defined (__stub___XOpenDisplay)
choke me
#else
f = XOpenDisplay; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
#endif

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:10669: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:10672: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:10675: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:10678: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_func_XOpenDisplay=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_func_XOpenDisplay=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:10688: result: $ac_cv_func_XOpenDisplay" >&5
echo "${ECHO_T}$ac_cv_func_XOpenDisplay" >&6
if test $ac_cv_func_XOpenDisplay = yes; then
  :
else

	echo "$as_me:10694: checking for XOpenDisplay in -lX11" >&5
echo $ECHO_N "checking for XOpenDisplay in -lX11... $ECHO_C" >&6
if test "${ac_cv_lib_X11_XOpenDisplay+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lX11 $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line 10702 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char XOpenDisplay ();
int
main (void)
{
XOpenDisplay ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:10721: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:10724: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:10727: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:10730: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_lib_X11_XOpenDisplay=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_lib_X11_XOpenDisplay=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:10741: result: $ac_cv_lib_X11_XOpenDisplay" >&5
echo "${ECHO_T}$ac_cv_lib_X11_XOpenDisplay" >&6
if test $ac_cv_lib_X11_XOpenDisplay = yes; then

cf_add_libs="-lX11"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

fi

fi

	echo "$as_me:10765: checking for XtAppInitialize" >&5
echo $ECHO_N "checking for XtAppInitialize... $ECHO_C" >&6
if test "${ac_cv_func_XtAppInitialize+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 10771 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
    which can conflict with char XtAppInitialize (); below.  */
#include 
/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char XtAppInitialize ();
char (*f) ();

int
main (void)
{
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_XtAppInitialize) || defined (__stub___XtAppInitialize)
choke me
#else
f = XtAppInitialize; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
#endif

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:10802: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:10805: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:10808: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:10811: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_func_XtAppInitialize=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_func_XtAppInitialize=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:10821: result: $ac_cv_func_XtAppInitialize" >&5
echo "${ECHO_T}$ac_cv_func_XtAppInitialize" >&6
if test $ac_cv_func_XtAppInitialize = yes; then
  :
else

	echo "$as_me:10827: checking for XtAppInitialize in -lXt" >&5
echo $ECHO_N "checking for XtAppInitialize in -lXt... $ECHO_C" >&6
if test "${ac_cv_lib_Xt_XtAppInitialize+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line 10835 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char XtAppInitialize ();
int
main (void)
{
XtAppInitialize ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:10854: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:10857: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:10860: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:10863: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_lib_Xt_XtAppInitialize=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_lib_Xt_XtAppInitialize=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:10874: result: $ac_cv_lib_Xt_XtAppInitialize" >&5
echo "${ECHO_T}$ac_cv_lib_Xt_XtAppInitialize" >&6
if test $ac_cv_lib_Xt_XtAppInitialize = yes; then

cat >>confdefs.h <<\EOF
#define HAVE_LIBXT 1
EOF

		 cf_have_X_LIBS=Xt
		 LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"
fi

fi

fi

if test $cf_have_X_LIBS = no ; then
	{ echo "$as_me:10891: WARNING: Unable to successfully link X Toolkit library (-lXt) with
test program.  You will have to check and add the proper libraries by hand
to makefile." >&5
echo "$as_me: WARNING: Unable to successfully link X Toolkit library (-lXt) with
test program.  You will have to check and add the proper libraries by hand
to makefile." >&2;}
fi

for ac_header in \
	X11/DECkeysym.h \
	X11/Sunkeysym.h \
	X11/XF86keysym.h \
	X11/XKBlib.h \
	X11/Xpoll.h \
	X11/extensions/XKB.h \

do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
echo "$as_me:10909: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 10915 "configure"
#include "confdefs.h"
#include <$ac_header>
_ACEOF
if { (eval echo "$as_me:10919: \"$ac_cpp conftest.$ac_ext\"") >&5
  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
  ac_status=$?
  egrep -v '^ *\+' conftest.er1 >conftest.err
  rm -f conftest.er1
  cat conftest.err >&5
  echo "$as_me:10925: \$? = $ac_status" >&5
  (exit $ac_status); } >/dev/null; then
  if test -s conftest.err; then
    ac_cpp_err=$ac_c_preproc_warn_flag
  else
    ac_cpp_err=
  fi
else
  ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
  eval "$as_ac_Header=yes"
else
  echo "$as_me: failed program was:" >&5
  cat conftest.$ac_ext >&5
  eval "$as_ac_Header=no"
fi
rm -f conftest.err conftest.$ac_ext
fi
echo "$as_me:10944: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
if test `eval echo '${'$as_ac_Header'}'` = yes; then
  cat >>confdefs.h <&5
echo $ECHO_N "checking if you want to use the Xpm library for colored icon... $ECHO_C" >&6

# Check whether --with-xpm or --without-xpm was given.
if test "${with_xpm+set}" = set; then
  withval="$with_xpm"
  cf_Xpm_library="$withval"
else
  cf_Xpm_library=yes
fi;
echo "$as_me:10969: result: $cf_Xpm_library" >&5
echo "${ECHO_T}$cf_Xpm_library" >&6

if test "$cf_Xpm_library" != no ; then
    if test "$cf_Xpm_library" != yes ; then
	CPPFLAGS="$CPPFLAGS -I$withval/include"
	LDFLAGS="$LDFLAGS -L$withval/lib"
    fi
    echo "$as_me:10977: checking for X11/xpm.h" >&5
echo $ECHO_N "checking for X11/xpm.h... $ECHO_C" >&6
if test "${ac_cv_header_X11_xpm_h+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 10983 "configure"
#include "confdefs.h"
#include 
_ACEOF
if { (eval echo "$as_me:10987: \"$ac_cpp conftest.$ac_ext\"") >&5
  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
  ac_status=$?
  egrep -v '^ *\+' conftest.er1 >conftest.err
  rm -f conftest.er1
  cat conftest.err >&5
  echo "$as_me:10993: \$? = $ac_status" >&5
  (exit $ac_status); } >/dev/null; then
  if test -s conftest.err; then
    ac_cpp_err=$ac_c_preproc_warn_flag
  else
    ac_cpp_err=
  fi
else
  ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
  ac_cv_header_X11_xpm_h=yes
else
  echo "$as_me: failed program was:" >&5
  cat conftest.$ac_ext >&5
  ac_cv_header_X11_xpm_h=no
fi
rm -f conftest.err conftest.$ac_ext
fi
echo "$as_me:11012: result: $ac_cv_header_X11_xpm_h" >&5
echo "${ECHO_T}$ac_cv_header_X11_xpm_h" >&6
if test $ac_cv_header_X11_xpm_h = yes; then

	echo "$as_me:11016: checking for XpmCreatePixmapFromData in -lXpm" >&5
echo $ECHO_N "checking for XpmCreatePixmapFromData in -lXpm... $ECHO_C" >&6
if test "${ac_cv_lib_Xpm_XpmCreatePixmapFromData+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lXpm -lX11 $X_LIBS $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line 11024 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char XpmCreatePixmapFromData ();
int
main (void)
{
XpmCreatePixmapFromData ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:11043: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:11046: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:11049: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:11052: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_lib_Xpm_XpmCreatePixmapFromData=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_lib_Xpm_XpmCreatePixmapFromData=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:11063: result: $ac_cv_lib_Xpm_XpmCreatePixmapFromData" >&5
echo "${ECHO_T}$ac_cv_lib_Xpm_XpmCreatePixmapFromData" >&6
if test $ac_cv_lib_Xpm_XpmCreatePixmapFromData = yes; then

cat >>confdefs.h <<\EOF
#define HAVE_LIBXPM 1
EOF

	    ICON_SUFFIX=.xpm
	    LIBS="-lXpm $LIBS"
else
  CPPFLAGS="${cf_save_cppflags}" LDFLAGS="${cf_save_ldflags}"
fi

else
  CPPFLAGS="${cf_save_cppflags}" LDFLAGS="${cf_save_ldflags}"
fi

fi

echo "$as_me:11083: checking if you want to use the Xinerama extension" >&5
echo $ECHO_N "checking if you want to use the Xinerama extension... $ECHO_C" >&6

# Check whether --with-xinerama or --without-xinerama was given.
if test "${with_xinerama+set}" = set; then
  withval="$with_xinerama"
  cf_with_xinerama="$withval"
else
  cf_with_xinerama=yes
fi;
echo "$as_me:11093: result: $cf_with_xinerama" >&5
echo "${ECHO_T}$cf_with_xinerama" >&6
if test "$cf_with_xinerama" = yes; then

if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xinerama; then
	test -n "$verbose" && echo "	found package xinerama" 1>&6

echo "${as_me:-configure}:11100: testing found package xinerama ..." 1>&5

	cf_pkgconfig_incs="`$PKG_CONFIG --cflags xinerama 2>/dev/null`"
	cf_pkgconfig_libs="`$PKG_CONFIG --libs   xinerama 2>/dev/null`"
	test -n "$verbose" && echo "	package xinerama CFLAGS: $cf_pkgconfig_incs" 1>&6

echo "${as_me:-configure}:11106: testing package xinerama CFLAGS: $cf_pkgconfig_incs ..." 1>&5

	test -n "$verbose" && echo "	package xinerama LIBS: $cf_pkgconfig_libs" 1>&6

echo "${as_me:-configure}:11110: testing package xinerama LIBS: $cf_pkgconfig_libs ..." 1>&5

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_pkgconfig_incs
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

cf_add_libs="$cf_pkgconfig_libs"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

	cat >>confdefs.h <<\EOF
#define HAVE_X11_EXTENSIONS_XINERAMA_H 1
EOF

else
	cf_pkgconfig_incs=
	cf_pkgconfig_libs=

	echo "$as_me:11234: checking for XineramaQueryScreens in -lXinerama" >&5
echo $ECHO_N "checking for XineramaQueryScreens in -lXinerama... $ECHO_C" >&6
if test "${ac_cv_lib_Xinerama_XineramaQueryScreens+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lXinerama  $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line 11242 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char XineramaQueryScreens ();
int
main (void)
{
XineramaQueryScreens ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:11261: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:11264: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:11267: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:11270: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_lib_Xinerama_XineramaQueryScreens=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_lib_Xinerama_XineramaQueryScreens=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:11281: result: $ac_cv_lib_Xinerama_XineramaQueryScreens" >&5
echo "${ECHO_T}$ac_cv_lib_Xinerama_XineramaQueryScreens" >&6
if test $ac_cv_lib_Xinerama_XineramaQueryScreens = yes; then

cf_add_libs="-lXinerama"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

for ac_header in \
			X11/extensions/Xinerama.h \

do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
echo "$as_me:11306: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 11312 "configure"
#include "confdefs.h"
#include <$ac_header>
_ACEOF
if { (eval echo "$as_me:11316: \"$ac_cpp conftest.$ac_ext\"") >&5
  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
  ac_status=$?
  egrep -v '^ *\+' conftest.er1 >conftest.err
  rm -f conftest.er1
  cat conftest.err >&5
  echo "$as_me:11322: \$? = $ac_status" >&5
  (exit $ac_status); } >/dev/null; then
  if test -s conftest.err; then
    ac_cpp_err=$ac_c_preproc_warn_flag
  else
    ac_cpp_err=
  fi
else
  ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
  eval "$as_ac_Header=yes"
else
  echo "$as_me: failed program was:" >&5
  cat conftest.$ac_ext >&5
  eval "$as_ac_Header=no"
fi
rm -f conftest.err conftest.$ac_ext
fi
echo "$as_me:11341: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
if test `eval echo '${'$as_ac_Header'}'` = yes; then
  cat >>confdefs.h <&5
echo $ECHO_N "checking if you want to link with Xaw 3d library... $ECHO_C" >&6
withval=

# Check whether --with-Xaw3d or --without-Xaw3d was given.
if test "${with_Xaw3d+set}" = set; then
  withval="$with_Xaw3d"

fi;
if test "$withval" = yes ; then
	cf_x_athena=Xaw3d
	echo "$as_me:11370: result: yes" >&5
echo "${ECHO_T}yes" >&6
else
	echo "$as_me:11373: result: no" >&5
echo "${ECHO_T}no" >&6
fi

echo "$as_me:11377: checking if you want to link with Xaw 3d xft library" >&5
echo $ECHO_N "checking if you want to link with Xaw 3d xft library... $ECHO_C" >&6
withval=

# Check whether --with-Xaw3dxft or --without-Xaw3dxft was given.
if test "${with_Xaw3dxft+set}" = set; then
  withval="$with_Xaw3dxft"

fi;
if test "$withval" = yes ; then
	cf_x_athena=Xaw3dxft
	echo "$as_me:11388: result: yes" >&5
echo "${ECHO_T}yes" >&6
else
	echo "$as_me:11391: result: no" >&5
echo "${ECHO_T}no" >&6
fi

echo "$as_me:11395: checking if you want to link with neXT Athena library" >&5
echo $ECHO_N "checking if you want to link with neXT Athena library... $ECHO_C" >&6
withval=

# Check whether --with-neXtaw or --without-neXtaw was given.
if test "${with_neXtaw+set}" = set; then
  withval="$with_neXtaw"

fi;
if test "$withval" = yes ; then
	cf_x_athena=neXtaw
	echo "$as_me:11406: result: yes" >&5
echo "${ECHO_T}yes" >&6
else
	echo "$as_me:11409: result: no" >&5
echo "${ECHO_T}no" >&6
fi

echo "$as_me:11413: checking if you want to link with Athena-Plus library" >&5
echo $ECHO_N "checking if you want to link with Athena-Plus library... $ECHO_C" >&6
withval=

# Check whether --with-XawPlus or --without-XawPlus was given.
if test "${with_XawPlus+set}" = set; then
  withval="$with_XawPlus"

fi;
if test "$withval" = yes ; then
	cf_x_athena=XawPlus
	echo "$as_me:11424: result: yes" >&5
echo "${ECHO_T}yes" >&6
else
	echo "$as_me:11427: result: no" >&5
echo "${ECHO_T}no" >&6
fi

cf_x_athena_lib=""

if test "$PKG_CONFIG" != none ; then
	cf_athena_list=
	test "$cf_x_athena" = Xaw && cf_athena_list="xaw8 xaw7 xaw6"
	for cf_athena_pkg in \
		$cf_athena_list \
		${cf_x_athena} \
		${cf_x_athena}-devel \
		lib${cf_x_athena} \
		lib${cf_x_athena}-devel
	do

if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists $cf_athena_pkg; then
	test -n "$verbose" && echo "	found package $cf_athena_pkg" 1>&6

echo "${as_me:-configure}:11447: testing found package $cf_athena_pkg ..." 1>&5

	cf_pkgconfig_incs="`$PKG_CONFIG --cflags $cf_athena_pkg 2>/dev/null`"
	cf_pkgconfig_libs="`$PKG_CONFIG --libs   $cf_athena_pkg 2>/dev/null`"
	test -n "$verbose" && echo "	package $cf_athena_pkg CFLAGS: $cf_pkgconfig_incs" 1>&6

echo "${as_me:-configure}:11453: testing package $cf_athena_pkg CFLAGS: $cf_pkgconfig_incs ..." 1>&5

	test -n "$verbose" && echo "	package $cf_athena_pkg LIBS: $cf_pkgconfig_libs" 1>&6

echo "${as_me:-configure}:11457: testing package $cf_athena_pkg LIBS: $cf_pkgconfig_libs ..." 1>&5

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_pkgconfig_incs
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

cf_add_libs="$cf_pkgconfig_libs"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

			cf_x_athena_lib="$cf_pkgconfig_libs"

cf_x_athena_LIBS=`echo "HAVE_LIB_$cf_x_athena" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`

			cat >>confdefs.h <&6

echo "${as_me:-configure}:11588: testing ..trimmed $LIBS ..." 1>&5

			;;
		esac
	done

echo "$as_me:11594: checking for usable $cf_x_athena/Xmu package" >&5
echo $ECHO_N "checking for usable $cf_x_athena/Xmu package... $ECHO_C" >&6
if test "${cf_cv_xaw_compat+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

cat >conftest.$ac_ext <<_ACEOF
#line 11601 "configure"
#include "confdefs.h"

#include 

int
main (void)
{

int check = XmuCompareISOLatin1("big", "small")

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:11617: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:11620: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:11623: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:11626: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_xaw_compat=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_xaw_compat=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:11636: result: $cf_cv_xaw_compat" >&5
echo "${ECHO_T}$cf_cv_xaw_compat" >&6

			if test "$cf_cv_xaw_compat" = no
			then
				# workaround for broken ".pc" files...
				case "$cf_x_athena_lib" in
				(*-lXmu*)
					;;
				(*)
					test -n "$verbose" && echo "	work around broken package" 1>&6

echo "${as_me:-configure}:11648: testing work around broken package ..." 1>&5

					cf_save_xmu="$LIBS"
					cf_first_lib=`echo "$cf_save_xmu" | sed -e 's/^  *//' -e 's/ .*//'`

if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xmu; then
	test -n "$verbose" && echo "	found package xmu" 1>&6

echo "${as_me:-configure}:11656: testing found package xmu ..." 1>&5

	cf_pkgconfig_incs="`$PKG_CONFIG --cflags xmu 2>/dev/null`"
	cf_pkgconfig_libs="`$PKG_CONFIG --libs   xmu 2>/dev/null`"
	test -n "$verbose" && echo "	package xmu CFLAGS: $cf_pkgconfig_incs" 1>&6

echo "${as_me:-configure}:11662: testing package xmu CFLAGS: $cf_pkgconfig_incs ..." 1>&5

	test -n "$verbose" && echo "	package xmu LIBS: $cf_pkgconfig_libs" 1>&6

echo "${as_me:-configure}:11666: testing package xmu LIBS: $cf_pkgconfig_libs ..." 1>&5

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_pkgconfig_incs
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

cf_add_libs="$cf_pkgconfig_libs"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

							LIBS="$cf_save_xmu"

test -n "$verbose" && echo "	...before $LIBS" 1>&6

echo "${as_me:-configure}:11786: testing ...before $LIBS ..." 1>&5

LIBS=`echo "$LIBS" | sed -e "s/[ 	][ 	]*/ /g" -e "s%$cf_first_lib %$cf_first_lib $cf_pkgconfig_libs %" -e 's%  % %g'`
test -n "$verbose" && echo "	...after  $LIBS" 1>&6

echo "${as_me:-configure}:11791: testing ...after  $LIBS ..." 1>&5

else
	cf_pkgconfig_incs=
	cf_pkgconfig_libs=

test -n "$verbose" && echo "	...before $LIBS" 1>&6

echo "${as_me:-configure}:11799: testing ...before $LIBS ..." 1>&5

LIBS=`echo "$LIBS" | sed -e "s/[ 	][ 	]*/ /g" -e "s%$cf_first_lib %$cf_first_lib -lXmu %" -e 's%  % %g'`
test -n "$verbose" && echo "	...after  $LIBS" 1>&6

echo "${as_me:-configure}:11804: testing ...after  $LIBS ..." 1>&5

fi

	for cf_trim_lib in Xmu Xt X11
	do
		case "$LIBS" in
		(*-l$cf_trim_lib\ *-l$cf_trim_lib*)
			LIBS=`echo "$LIBS " | sed -e 's/  / /g' -e 's%-l'"$cf_trim_lib"' %%' -e 's/ $//'`
			test -n "$verbose" && echo "	..trimmed $LIBS" 1>&6

echo "${as_me:-configure}:11815: testing ..trimmed $LIBS ..." 1>&5

			;;
		esac
	done

					;;
				esac
			fi

			break
else
	cf_pkgconfig_incs=
	cf_pkgconfig_libs=
	:
fi

	done
fi

if test -z "$cf_x_athena_lib" ; then

if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists Xext; then
	test -n "$verbose" && echo "	found package Xext" 1>&6

echo "${as_me:-configure}:11840: testing found package Xext ..." 1>&5

	cf_pkgconfig_incs="`$PKG_CONFIG --cflags Xext 2>/dev/null`"
	cf_pkgconfig_libs="`$PKG_CONFIG --libs   Xext 2>/dev/null`"
	test -n "$verbose" && echo "	package Xext CFLAGS: $cf_pkgconfig_incs" 1>&6

echo "${as_me:-configure}:11846: testing package Xext CFLAGS: $cf_pkgconfig_incs ..." 1>&5

	test -n "$verbose" && echo "	package Xext LIBS: $cf_pkgconfig_libs" 1>&6

echo "${as_me:-configure}:11850: testing package Xext LIBS: $cf_pkgconfig_libs ..." 1>&5

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_pkgconfig_incs
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

cf_add_libs="$cf_pkgconfig_libs"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

	:
else
	cf_pkgconfig_incs=
	cf_pkgconfig_libs=

	echo "$as_me:11971: checking for XextCreateExtension in -lXext" >&5
echo $ECHO_N "checking for XextCreateExtension in -lXext... $ECHO_C" >&6
if test "${ac_cv_lib_Xext_XextCreateExtension+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lXext  $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line 11979 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char XextCreateExtension ();
int
main (void)
{
XextCreateExtension ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:11998: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:12001: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:12004: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:12007: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_lib_Xext_XextCreateExtension=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_lib_Xext_XextCreateExtension=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:12018: result: $ac_cv_lib_Xext_XextCreateExtension" >&5
echo "${ECHO_T}$ac_cv_lib_Xext_XextCreateExtension" >&6
if test $ac_cv_lib_Xext_XextCreateExtension = yes; then

cf_add_libs="-lXext"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

fi

fi

# OSX is schizoid about who owns /usr/X11 (old) versus /opt/X11 (new), and (and
# in some cases has installed dummy files in the former, other cases replaced
# it with a link to the new location).  This complicates the configure script.
# Check for that pitfall, and recover using pkg-config
#
# If none of these are set, the configuration is almost certainly broken.
if test -z "${X_CFLAGS}${X_PRE_LIBS}${X_LIBS}${X_EXTRA_LIBS}"
then

if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists x11; then
	test -n "$verbose" && echo "	found package x11" 1>&6

echo "${as_me:-configure}:12054: testing found package x11 ..." 1>&5

	cf_pkgconfig_incs="`$PKG_CONFIG --cflags x11 2>/dev/null`"
	cf_pkgconfig_libs="`$PKG_CONFIG --libs   x11 2>/dev/null`"
	test -n "$verbose" && echo "	package x11 CFLAGS: $cf_pkgconfig_incs" 1>&6

echo "${as_me:-configure}:12060: testing package x11 CFLAGS: $cf_pkgconfig_incs ..." 1>&5

	test -n "$verbose" && echo "	package x11 LIBS: $cf_pkgconfig_libs" 1>&6

echo "${as_me:-configure}:12064: testing package x11 LIBS: $cf_pkgconfig_libs ..." 1>&5

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_pkgconfig_incs
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

cf_add_libs="$cf_pkgconfig_libs"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

	:
else
	cf_pkgconfig_incs=
	cf_pkgconfig_libs=
	{ echo "$as_me:12184: WARNING: unable to find X11 library" >&5
echo "$as_me: WARNING: unable to find X11 library" >&2;}
fi

if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists ice; then
	test -n "$verbose" && echo "	found package ice" 1>&6

echo "${as_me:-configure}:12191: testing found package ice ..." 1>&5

	cf_pkgconfig_incs="`$PKG_CONFIG --cflags ice 2>/dev/null`"
	cf_pkgconfig_libs="`$PKG_CONFIG --libs   ice 2>/dev/null`"
	test -n "$verbose" && echo "	package ice CFLAGS: $cf_pkgconfig_incs" 1>&6

echo "${as_me:-configure}:12197: testing package ice CFLAGS: $cf_pkgconfig_incs ..." 1>&5

	test -n "$verbose" && echo "	package ice LIBS: $cf_pkgconfig_libs" 1>&6

echo "${as_me:-configure}:12201: testing package ice LIBS: $cf_pkgconfig_libs ..." 1>&5

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_pkgconfig_incs
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

cf_add_libs="$cf_pkgconfig_libs"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

	:
else
	cf_pkgconfig_incs=
	cf_pkgconfig_libs=
	{ echo "$as_me:12321: WARNING: unable to find ICE library" >&5
echo "$as_me: WARNING: unable to find ICE library" >&2;}
fi

if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists sm; then
	test -n "$verbose" && echo "	found package sm" 1>&6

echo "${as_me:-configure}:12328: testing found package sm ..." 1>&5

	cf_pkgconfig_incs="`$PKG_CONFIG --cflags sm 2>/dev/null`"
	cf_pkgconfig_libs="`$PKG_CONFIG --libs   sm 2>/dev/null`"
	test -n "$verbose" && echo "	package sm CFLAGS: $cf_pkgconfig_incs" 1>&6

echo "${as_me:-configure}:12334: testing package sm CFLAGS: $cf_pkgconfig_incs ..." 1>&5

	test -n "$verbose" && echo "	package sm LIBS: $cf_pkgconfig_libs" 1>&6

echo "${as_me:-configure}:12338: testing package sm LIBS: $cf_pkgconfig_libs ..." 1>&5

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_pkgconfig_incs
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

cf_add_libs="$cf_pkgconfig_libs"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

	:
else
	cf_pkgconfig_incs=
	cf_pkgconfig_libs=
	{ echo "$as_me:12458: WARNING: unable to find SM library" >&5
echo "$as_me: WARNING: unable to find SM library" >&2;}
fi

if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xt; then
	test -n "$verbose" && echo "	found package xt" 1>&6

echo "${as_me:-configure}:12465: testing found package xt ..." 1>&5

	cf_pkgconfig_incs="`$PKG_CONFIG --cflags xt 2>/dev/null`"
	cf_pkgconfig_libs="`$PKG_CONFIG --libs   xt 2>/dev/null`"
	test -n "$verbose" && echo "	package xt CFLAGS: $cf_pkgconfig_incs" 1>&6

echo "${as_me:-configure}:12471: testing package xt CFLAGS: $cf_pkgconfig_incs ..." 1>&5

	test -n "$verbose" && echo "	package xt LIBS: $cf_pkgconfig_libs" 1>&6

echo "${as_me:-configure}:12475: testing package xt LIBS: $cf_pkgconfig_libs ..." 1>&5

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_pkgconfig_incs
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

cf_add_libs="$cf_pkgconfig_libs"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

	:
else
	cf_pkgconfig_incs=
	cf_pkgconfig_libs=
	{ echo "$as_me:12595: WARNING: unable to find Xt library" >&5
echo "$as_me: WARNING: unable to find Xt library" >&2;}
fi

fi

cf_have_X_LIBS=no

if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xt; then
	test -n "$verbose" && echo "	found package xt" 1>&6

echo "${as_me:-configure}:12606: testing found package xt ..." 1>&5

	cf_pkgconfig_incs="`$PKG_CONFIG --cflags xt 2>/dev/null`"
	cf_pkgconfig_libs="`$PKG_CONFIG --libs   xt 2>/dev/null`"
	test -n "$verbose" && echo "	package xt CFLAGS: $cf_pkgconfig_incs" 1>&6

echo "${as_me:-configure}:12612: testing package xt CFLAGS: $cf_pkgconfig_incs ..." 1>&5

	test -n "$verbose" && echo "	package xt LIBS: $cf_pkgconfig_libs" 1>&6

echo "${as_me:-configure}:12616: testing package xt LIBS: $cf_pkgconfig_libs ..." 1>&5

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_pkgconfig_incs
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

cf_add_libs="$cf_pkgconfig_libs"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

	case "x$LIBS" in
	(*-lX11*)
		;;
	(*)
# we have an "xt" package, but it may omit Xt's dependency on X11
echo "$as_me:12737: checking for usable X dependency" >&5
echo $ECHO_N "checking for usable X dependency... $ECHO_C" >&6
if test "${cf_cv_xt_x11_compat+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

cat >conftest.$ac_ext <<_ACEOF
#line 12744 "configure"
#include "confdefs.h"

#include 

int
main (void)
{

	int rc1 = XDrawLine((Display*) 0, (Drawable) 0, (GC) 0, 0, 0, 0, 0);
	int rc2 = XClearWindow((Display*) 0, (Window) 0);
	int rc3 = XMoveWindow((Display*) 0, (Window) 0, 0, 0);
	int rc4 = XMoveResizeWindow((Display*)0, (Window)0, 0, 0, 0, 0);

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:12763: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:12766: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:12769: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:12772: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_xt_x11_compat=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_xt_x11_compat=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:12782: result: $cf_cv_xt_x11_compat" >&5
echo "${ECHO_T}$cf_cv_xt_x11_compat" >&6
		if test "$cf_cv_xt_x11_compat" = no
		then
			test -n "$verbose" && echo "	work around broken X11 dependency" 1>&6

echo "${as_me:-configure}:12788: testing work around broken X11 dependency ..." 1>&5

			# 2010/11/19 - good enough until a working Xt on Xcb is delivered.

if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists x11; then
	test -n "$verbose" && echo "	found package x11" 1>&6

echo "${as_me:-configure}:12795: testing found package x11 ..." 1>&5

	cf_pkgconfig_incs="`$PKG_CONFIG --cflags x11 2>/dev/null`"
	cf_pkgconfig_libs="`$PKG_CONFIG --libs   x11 2>/dev/null`"
	test -n "$verbose" && echo "	package x11 CFLAGS: $cf_pkgconfig_incs" 1>&6

echo "${as_me:-configure}:12801: testing package x11 CFLAGS: $cf_pkgconfig_incs ..." 1>&5

	test -n "$verbose" && echo "	package x11 LIBS: $cf_pkgconfig_libs" 1>&6

echo "${as_me:-configure}:12805: testing package x11 LIBS: $cf_pkgconfig_libs ..." 1>&5

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_pkgconfig_incs
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

cf_add_libs="$cf_pkgconfig_libs"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

	:
else
	cf_pkgconfig_incs=
	cf_pkgconfig_libs=

test -n "$verbose" && echo "	...before $LIBS" 1>&6

echo "${as_me:-configure}:12928: testing ...before $LIBS ..." 1>&5

LIBS=`echo "$LIBS" | sed -e "s/[ 	][ 	]*/ /g" -e "s%-lXt %-lXt -lX11 %" -e 's%  % %g'`
test -n "$verbose" && echo "	...after  $LIBS" 1>&6

echo "${as_me:-configure}:12933: testing ...after  $LIBS ..." 1>&5

fi

		fi
		;;
	esac

echo "$as_me:12941: checking for usable X Toolkit package" >&5
echo $ECHO_N "checking for usable X Toolkit package... $ECHO_C" >&6
if test "${cf_cv_xt_ice_compat+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

cat >conftest.$ac_ext <<_ACEOF
#line 12948 "configure"
#include "confdefs.h"

#include 

int
main (void)
{
int num = IceConnectionNumber(0)

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:12963: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:12966: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:12969: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:12972: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_xt_ice_compat=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_xt_ice_compat=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:12982: result: $cf_cv_xt_ice_compat" >&5
echo "${ECHO_T}$cf_cv_xt_ice_compat" >&6

	if test "$cf_cv_xt_ice_compat" = no
	then
		# workaround for broken ".pc" files used for X Toolkit.
		case "x$X_PRE_LIBS" in
		(*-lICE*)
			case "x$LIBS" in
			(*-lICE*)
				;;
			(*)
				test -n "$verbose" && echo "	work around broken ICE dependency" 1>&6

echo "${as_me:-configure}:12996: testing work around broken ICE dependency ..." 1>&5

if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists ice; then
	test -n "$verbose" && echo "	found package ice" 1>&6

echo "${as_me:-configure}:13001: testing found package ice ..." 1>&5

	cf_pkgconfig_incs="`$PKG_CONFIG --cflags ice 2>/dev/null`"
	cf_pkgconfig_libs="`$PKG_CONFIG --libs   ice 2>/dev/null`"
	test -n "$verbose" && echo "	package ice CFLAGS: $cf_pkgconfig_incs" 1>&6

echo "${as_me:-configure}:13007: testing package ice CFLAGS: $cf_pkgconfig_incs ..." 1>&5

	test -n "$verbose" && echo "	package ice LIBS: $cf_pkgconfig_libs" 1>&6

echo "${as_me:-configure}:13011: testing package ice LIBS: $cf_pkgconfig_libs ..." 1>&5

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_pkgconfig_incs
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

cf_add_libs="$cf_pkgconfig_libs"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists sm; then
	test -n "$verbose" && echo "	found package sm" 1>&6

echo "${as_me:-configure}:13130: testing found package sm ..." 1>&5

	cf_pkgconfig_incs="`$PKG_CONFIG --cflags sm 2>/dev/null`"
	cf_pkgconfig_libs="`$PKG_CONFIG --libs   sm 2>/dev/null`"
	test -n "$verbose" && echo "	package sm CFLAGS: $cf_pkgconfig_incs" 1>&6

echo "${as_me:-configure}:13136: testing package sm CFLAGS: $cf_pkgconfig_incs ..." 1>&5

	test -n "$verbose" && echo "	package sm LIBS: $cf_pkgconfig_libs" 1>&6

echo "${as_me:-configure}:13140: testing package sm LIBS: $cf_pkgconfig_libs ..." 1>&5

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_pkgconfig_incs
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

cf_add_libs="$cf_pkgconfig_libs"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

	:
else
	cf_pkgconfig_incs=
	cf_pkgconfig_libs=
	:
fi

else
	cf_pkgconfig_incs=
	cf_pkgconfig_libs=

test -n "$verbose" && echo "	...before $LIBS" 1>&6

echo "${as_me:-configure}:13269: testing ...before $LIBS ..." 1>&5

LIBS=`echo "$LIBS" | sed -e "s/[ 	][ 	]*/ /g" -e "s%-lXt %-lXt $X_PRE_LIBS %" -e 's%  % %g'`
test -n "$verbose" && echo "	...after  $LIBS" 1>&6

echo "${as_me:-configure}:13274: testing ...after  $LIBS ..." 1>&5

fi

				;;
			esac
			;;
		esac
	fi

	cf_have_X_LIBS=yes

else
	cf_pkgconfig_incs=
	cf_pkgconfig_libs=

	LDFLAGS="$X_LIBS $LDFLAGS"

test -n "$verbose" && echo "	checking additions to CFLAGS" 1>&6

echo "${as_me:-configure}:13294: testing checking additions to CFLAGS ..." 1>&5

cf_check_cflags="$CFLAGS"
cf_check_cppflags="$CPPFLAGS"

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $X_CFLAGS
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then
	test -n "$verbose" && echo "	add to \$CFLAGS $cf_new_cflags" 1>&6

echo "${as_me:-configure}:13379: testing add to \$CFLAGS $cf_new_cflags ..." 1>&5

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then
	test -n "$verbose" && echo "	add to \$CPPFLAGS $cf_new_cppflags" 1>&6

echo "${as_me:-configure}:13389: testing add to \$CPPFLAGS $cf_new_cppflags ..." 1>&5

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then
	test -n "$verbose" && echo "	add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags" 1>&6

echo "${as_me:-configure}:13399: testing add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags ..." 1>&5

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

if test "x$cf_check_cflags" != "x$CFLAGS" ; then
cat >conftest.$ac_ext <<_ACEOF
#line 13408 "configure"
#include "confdefs.h"
#include 
int
main (void)
{
printf("Hello world");
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:13420: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:13423: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:13426: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:13429: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  :
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
test -n "$verbose" && echo "	test-compile failed.  Undoing change to \$CFLAGS" 1>&6

echo "${as_me:-configure}:13437: testing test-compile failed.  Undoing change to \$CFLAGS ..." 1>&5

	 if test "x$cf_check_cppflags" != "x$CPPFLAGS" ; then
		 test -n "$verbose" && echo "	but keeping change to \$CPPFLAGS" 1>&6

echo "${as_me:-configure}:13442: testing but keeping change to \$CPPFLAGS ..." 1>&5

	 fi
	 CFLAGS="$cf_check_flags"
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi

	echo "$as_me:13450: checking for XOpenDisplay" >&5
echo $ECHO_N "checking for XOpenDisplay... $ECHO_C" >&6
if test "${ac_cv_func_XOpenDisplay+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 13456 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
    which can conflict with char XOpenDisplay (); below.  */
#include 
/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char XOpenDisplay ();
char (*f) ();

int
main (void)
{
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_XOpenDisplay) || defined (__stub___XOpenDisplay)
choke me
#else
f = XOpenDisplay; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
#endif

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:13487: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:13490: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:13493: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:13496: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_func_XOpenDisplay=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_func_XOpenDisplay=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:13506: result: $ac_cv_func_XOpenDisplay" >&5
echo "${ECHO_T}$ac_cv_func_XOpenDisplay" >&6
if test $ac_cv_func_XOpenDisplay = yes; then
  :
else

	echo "$as_me:13512: checking for XOpenDisplay in -lX11" >&5
echo $ECHO_N "checking for XOpenDisplay in -lX11... $ECHO_C" >&6
if test "${ac_cv_lib_X11_XOpenDisplay+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lX11 $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line 13520 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char XOpenDisplay ();
int
main (void)
{
XOpenDisplay ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:13539: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:13542: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:13545: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:13548: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_lib_X11_XOpenDisplay=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_lib_X11_XOpenDisplay=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:13559: result: $ac_cv_lib_X11_XOpenDisplay" >&5
echo "${ECHO_T}$ac_cv_lib_X11_XOpenDisplay" >&6
if test $ac_cv_lib_X11_XOpenDisplay = yes; then

cf_add_libs="-lX11"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

fi

fi

	echo "$as_me:13583: checking for XtAppInitialize" >&5
echo $ECHO_N "checking for XtAppInitialize... $ECHO_C" >&6
if test "${ac_cv_func_XtAppInitialize+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 13589 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
    which can conflict with char XtAppInitialize (); below.  */
#include 
/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char XtAppInitialize ();
char (*f) ();

int
main (void)
{
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_XtAppInitialize) || defined (__stub___XtAppInitialize)
choke me
#else
f = XtAppInitialize; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
#endif

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:13620: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:13623: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:13626: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:13629: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_func_XtAppInitialize=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_func_XtAppInitialize=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:13639: result: $ac_cv_func_XtAppInitialize" >&5
echo "${ECHO_T}$ac_cv_func_XtAppInitialize" >&6
if test $ac_cv_func_XtAppInitialize = yes; then
  :
else

	echo "$as_me:13645: checking for XtAppInitialize in -lXt" >&5
echo $ECHO_N "checking for XtAppInitialize in -lXt... $ECHO_C" >&6
if test "${ac_cv_lib_Xt_XtAppInitialize+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line 13653 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char XtAppInitialize ();
int
main (void)
{
XtAppInitialize ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:13672: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:13675: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:13678: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:13681: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_lib_Xt_XtAppInitialize=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_lib_Xt_XtAppInitialize=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:13692: result: $ac_cv_lib_Xt_XtAppInitialize" >&5
echo "${ECHO_T}$ac_cv_lib_Xt_XtAppInitialize" >&6
if test $ac_cv_lib_Xt_XtAppInitialize = yes; then

cat >>confdefs.h <<\EOF
#define HAVE_LIBXT 1
EOF

		 cf_have_X_LIBS=Xt
		 LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"
fi

fi

fi

if test $cf_have_X_LIBS = no ; then
	{ echo "$as_me:13709: WARNING: Unable to successfully link X Toolkit library (-lXt) with
test program.  You will have to check and add the proper libraries by hand
to makefile." >&5
echo "$as_me: WARNING: Unable to successfully link X Toolkit library (-lXt) with
test program.  You will have to check and add the proper libraries by hand
to makefile." >&2;}
fi

cf_x_athena_root=$cf_x_athena
cf_x_athena_inc=""

for cf_path in default \
	/usr/contrib/X11R6 \
	/usr/contrib/X11R5 \
	/usr/lib/X11R5 \
	/usr/local
do
	if test -z "$cf_x_athena_inc" ; then
		cf_save="$CPPFLAGS"
		cf_test=X11/$cf_x_athena_root/SimpleMenu.h
		if test $cf_path != default ; then
			CPPFLAGS="$cf_save -I$cf_path/include"
			echo "$as_me:13731: checking for $cf_test in $cf_path" >&5
echo $ECHO_N "checking for $cf_test in $cf_path... $ECHO_C" >&6
		else
			echo "$as_me:13734: checking for $cf_test" >&5
echo $ECHO_N "checking for $cf_test... $ECHO_C" >&6
		fi
		cat >conftest.$ac_ext <<_ACEOF
#line 13738 "configure"
#include "confdefs.h"

#include 
#include <$cf_test>
int
main (void)
{

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:13752: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:13755: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:13758: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:13761: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_result=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_result=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext
		echo "$as_me:13770: result: $cf_result" >&5
echo "${ECHO_T}$cf_result" >&6
		if test "$cf_result" = yes ; then
			cf_x_athena_inc=$cf_path
			break
		else
			CPPFLAGS="$cf_save"
		fi
	fi
done

if test -z "$cf_x_athena_inc" ; then
	{ echo "$as_me:13782: WARNING: Unable to successfully find Athena header files with test program" >&5
echo "$as_me: WARNING: Unable to successfully find Athena header files with test program" >&2;}
elif test "$cf_x_athena_inc" != default ; then
	CPPFLAGS="$CPPFLAGS -I$cf_x_athena_inc"
fi

cf_x_athena_root=$cf_x_athena
cf_x_athena_lib=""

for cf_path in default \
	/usr/contrib/X11R6 \
	/usr/contrib/X11R5 \
	/usr/lib/X11R5 \
	/usr/local
do
	for cf_lib in \
		${cf_x_athena_root} \
		${cf_x_athena_root}7 \
		${cf_x_athena_root}6
	do
	for cf_libs in \
		"-l$cf_lib -lXmu" \
		"-l$cf_lib -lXpm -lXmu" \
		"-l${cf_lib}_s -lXmu_s"
	do
		if test -z "$cf_x_athena_lib" ; then
			cf_save="$LIBS"
			cf_test=XawSimpleMenuAddGlobalActions
			if test $cf_path != default ; then

cf_add_libs="-L$cf_path/lib $cf_libs"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

				echo "$as_me:13828: checking for $cf_libs in $cf_path" >&5
echo $ECHO_N "checking for $cf_libs in $cf_path... $ECHO_C" >&6
			else

cf_add_libs="$cf_libs"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

				echo "$as_me:13848: checking for $cf_test in $cf_libs" >&5
echo $ECHO_N "checking for $cf_test in $cf_libs... $ECHO_C" >&6
			fi
			cat >conftest.$ac_ext <<_ACEOF
#line 13852 "configure"
#include "confdefs.h"

#include 
#include 

int
main (void)
{

$cf_test((XtAppContext) 0)
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:13868: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:13871: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:13874: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:13877: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_result=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_result=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
			echo "$as_me:13886: result: $cf_result" >&5
echo "${ECHO_T}$cf_result" >&6
			if test "$cf_result" = yes ; then
				cf_x_athena_lib="$cf_libs"
				break
			fi
			LIBS="$cf_save"
		fi
	done # cf_libs
		test -n "$cf_x_athena_lib" && break
	done # cf_lib
done

if test -z "$cf_x_athena_lib" ; then
	{ { echo "$as_me:13900: error: Unable to successfully link Athena library (-l$cf_x_athena_root) with test program" >&5
echo "$as_me: error: Unable to successfully link Athena library (-l$cf_x_athena_root) with test program" >&2;}
   { (exit 1); exit 1; }; }
fi

cf_x_athena_LIBS=`echo "HAVE_LIB_$cf_x_athena" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`

cat >>confdefs.h <&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 13922 "configure"
#include "confdefs.h"
#include <$ac_header>
_ACEOF
if { (eval echo "$as_me:13926: \"$ac_cpp conftest.$ac_ext\"") >&5
  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
  ac_status=$?
  egrep -v '^ *\+' conftest.er1 >conftest.err
  rm -f conftest.er1
  cat conftest.err >&5
  echo "$as_me:13932: \$? = $ac_status" >&5
  (exit $ac_status); } >/dev/null; then
  if test -s conftest.err; then
    ac_cpp_err=$ac_c_preproc_warn_flag
  else
    ac_cpp_err=
  fi
else
  ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
  eval "$as_ac_Header=yes"
else
  echo "$as_me: failed program was:" >&5
  cat conftest.$ac_ext >&5
  eval "$as_ac_Header=no"
fi
rm -f conftest.err conftest.$ac_ext
fi
echo "$as_me:13951: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
if test `eval echo '${'$as_ac_Header'}'` = yes; then
  cat >>confdefs.h <&5
echo $ECHO_N "checking for declaration of fd_set... $ECHO_C" >&6
if test "${cf_cv_type_fd_set+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

echo "${as_me:-configure}:13967: testing sys/types alone ..." 1>&5

cat >conftest.$ac_ext <<_ACEOF
#line 13970 "configure"
#include "confdefs.h"

#include 
int
main (void)
{
fd_set x
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:13983: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:13986: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:13989: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:13992: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_type_fd_set=sys/types.h
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5

echo "${as_me:-configure}:13999: testing X11/Xpoll.h ..." 1>&5

cat >conftest.$ac_ext <<_ACEOF
#line 14002 "configure"
#include "confdefs.h"

#ifdef HAVE_X11_XPOLL_H
#include 
#endif
int
main (void)
{
fd_set x
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:14017: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:14020: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:14023: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:14026: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_type_fd_set=X11/Xpoll.h
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5

echo "${as_me:-configure}:14033: testing sys/select.h ..." 1>&5

cat >conftest.$ac_ext <<_ACEOF
#line 14036 "configure"
#include "confdefs.h"

#include 
#include 
int
main (void)
{
fd_set x
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:14050: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:14053: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:14056: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:14059: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_type_fd_set=sys/select.h
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_type_fd_set=unknown
fi
rm -f conftest.$ac_objext conftest.$ac_ext
fi
rm -f conftest.$ac_objext conftest.$ac_ext
fi
rm -f conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:14073: result: $cf_cv_type_fd_set" >&5
echo "${ECHO_T}$cf_cv_type_fd_set" >&6
if test $cf_cv_type_fd_set = sys/select.h ; then

cat >>confdefs.h <<\EOF
#define USE_SYS_SELECT_H 1
EOF

fi

echo "$as_me:14083: checking for declaration of fd_mask" >&5
echo $ECHO_N "checking for declaration of fd_mask... $ECHO_C" >&6
if test "${cf_cv_type_fd_mask+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

    if test x$cf_cv_type_fd_set = xX11/Xpoll.h ; then
        cat >conftest.$ac_ext <<_ACEOF
#line 14091 "configure"
#include "confdefs.h"

#include 
int
main (void)
{
fd_mask x
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:14104: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:14107: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:14110: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:14113: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  :
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5

echo "${as_me:-configure}:14120: testing if we must define CSRG_BASED ..." 1>&5

# Xosdefs.h on Mac OS X may not define this (but it should).
            cat >conftest.$ac_ext <<_ACEOF
#line 14124 "configure"
#include "confdefs.h"

#define CSRG_BASED
#include 
int
main (void)
{
fd_mask x
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:14138: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:14141: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:14144: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:14147: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_type_fd_mask=CSRG_BASED
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
fi
rm -f conftest.$ac_objext conftest.$ac_ext
fi
rm -f conftest.$ac_objext conftest.$ac_ext
    else
        cf_cv_type_fd_mask=$cf_cv_type_fd_set
    fi

fi
echo "$as_me:14162: result: $cf_cv_type_fd_mask" >&5
echo "${ECHO_T}$cf_cv_type_fd_mask" >&6
if test x$cf_cv_type_fd_mask = xCSRG_BASED ; then

cat >>confdefs.h <<\EOF
#define CSRG_BASED 1
EOF

fi

echo "$as_me:14172: checking for IRIX 6.5 baud-rate redefinitions" >&5
echo $ECHO_N "checking for IRIX 6.5 baud-rate redefinitions... $ECHO_C" >&6
if test "${cf_cv_termio_c_ispeed+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

cat >conftest.$ac_ext <<_ACEOF
#line 14179 "configure"
#include "confdefs.h"

#include 
#include 
int
main (void)
{

struct termio foo;
foo.c_ispeed = B38400;
foo.c_ospeed = B9600;

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:14197: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:14200: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:14203: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:14206: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_termio_c_ispeed=yes

else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_termio_c_ispeed=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext

fi
echo "$as_me:14218: result: $cf_cv_termio_c_ispeed" >&5
echo "${ECHO_T}$cf_cv_termio_c_ispeed" >&6
test "$cf_cv_termio_c_ispeed" = yes &&
cat >>confdefs.h <<\EOF
#define HAVE_TERMIO_C_ISPEED 1
EOF

# If we notice Xcursor, there is a workaround needed.
echo "$as_me:14226: checking for XcursorGetTheme in -lXcursor" >&5
echo $ECHO_N "checking for XcursorGetTheme in -lXcursor... $ECHO_C" >&6
if test "${ac_cv_lib_Xcursor_XcursorGetTheme+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lXcursor  $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line 14234 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char XcursorGetTheme ();
int
main (void)
{
XcursorGetTheme ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:14253: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:14256: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:14259: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:14262: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_lib_Xcursor_XcursorGetTheme=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_lib_Xcursor_XcursorGetTheme=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:14273: result: $ac_cv_lib_Xcursor_XcursorGetTheme" >&5
echo "${ECHO_T}$ac_cv_lib_Xcursor_XcursorGetTheme" >&6
if test $ac_cv_lib_Xcursor_XcursorGetTheme = yes; then
  cat >>confdefs.h <<\EOF
#define HAVE_LIB_XCURSOR 1
EOF

fi

LIBS="$LIBS $X_EXTRA_LIBS"

for ac_header in \
stropts.h \

do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
echo "$as_me:14289: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 14295 "configure"
#include "confdefs.h"
#include <$ac_header>
_ACEOF
if { (eval echo "$as_me:14299: \"$ac_cpp conftest.$ac_ext\"") >&5
  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
  ac_status=$?
  egrep -v '^ *\+' conftest.er1 >conftest.err
  rm -f conftest.er1
  cat conftest.err >&5
  echo "$as_me:14305: \$? = $ac_status" >&5
  (exit $ac_status); } >/dev/null; then
  if test -s conftest.err; then
    ac_cpp_err=$ac_c_preproc_warn_flag
  else
    ac_cpp_err=
  fi
else
  ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
  eval "$as_ac_Header=yes"
else
  echo "$as_me: failed program was:" >&5
  cat conftest.$ac_ext >&5
  eval "$as_ac_Header=no"
fi
rm -f conftest.err conftest.$ac_ext
fi
echo "$as_me:14324: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
if test `eval echo '${'$as_ac_Header'}'` = yes; then
  cat >>confdefs.h <&5
echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
if eval "test \"\${$as_ac_var+set}\" = set"; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 14352 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
    which can conflict with char $ac_func (); below.  */
#include 
/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char $ac_func ();
char (*f) ();

int
main (void)
{
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
choke me
#else
f = $ac_func; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
#endif

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:14383: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:14386: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:14389: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:14392: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  eval "$as_ac_var=yes"
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
eval "$as_ac_var=no"
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:14402: result: `eval echo '${'$as_ac_var'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
if test `eval echo '${'$as_ac_var'}'` = yes; then
  cat >>confdefs.h <&5
echo $ECHO_N "checking if grantpt really works... $ECHO_C" >&6
	cat >conftest.$ac_ext <<_ACEOF
#line 14417 "configure"
#include "confdefs.h"

#include 
#include 
#include 
#include 
#include 
#include 

#ifndef HAVE_POSIX_OPENPT
#undef posix_openpt
#define posix_openpt(mode) open("/dev/ptmx", mode)
#endif

#ifdef HAVE_STROPTS_H
#include 
#endif

static void failed(int code)
{
	perror("conftest");
	exit(code);
}

static void my_timeout(int sig)
{
	exit(99);
}

int
main (void)
{

	int code = 0;
	int rc;
	int pty;
	int tty;
	char *slave;
	struct termios tio;

	signal(SIGALRM, my_timeout);

	if (alarm(2) == 9)
		failed(9);
	else if ((pty = posix_openpt(O_RDWR)) < 0)
		failed(1);
	else if ((rc = grantpt(pty)) < 0)
		failed(2);
	else if ((rc = unlockpt(pty)) < 0)
		failed(3);
	else if ((slave = ptsname(pty)) == 0)
		failed(4);
#if (CONFTEST == 3) || defined(CONFTEST_isatty)
	else if (!isatty(pty))
		failed(4);
#endif
#if CONFTEST >= 4
    else if ((rc = tcgetattr(pty, &tio)) < 0)
		failed(20);
    else if ((rc = tcsetattr(pty, TCSAFLUSH, &tio)) < 0)
		failed(21);
#endif
	/* BSD posix_openpt does not treat pty as a terminal until slave is opened.
	 * Linux does treat it that way.
	 */
	else if ((tty = open(slave, O_RDWR)) < 0)
		failed(5);
#ifdef CONFTEST
#ifdef I_PUSH
#if (CONFTEST == 0) || defined(CONFTEST_ptem)
    else if ((rc = ioctl(tty, I_PUSH, "ptem")) < 0)
		failed(10);
#endif
#if (CONFTEST == 1) || defined(CONFTEST_ldterm)
    else if ((rc = ioctl(tty, I_PUSH, "ldterm")) < 0)
		failed(11);
#endif
#if (CONFTEST == 2) || defined(CONFTEST_ttcompat)
    else if ((rc = ioctl(tty, I_PUSH, "ttcompat")) < 0)
		failed(12);
#endif
#endif /* I_PUSH */
#if CONFTEST >= 5
    else if ((rc = tcgetattr(tty, &tio)) < 0)
		failed(30);
    else if ((rc = tcsetattr(tty, TCSAFLUSH, &tio)) < 0)
		failed(31);
#endif
#endif /* CONFTEST */

	${cf_cv_main_return:-return}(code);

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:14515: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:14518: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:14521: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:14524: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then

	if test "$cross_compiling" = yes; then
  ac_cv_func_grantpt=maybe
else
  cat >conftest.$ac_ext <<_ACEOF
#line 14531 "configure"
#include "confdefs.h"

#include 
#include 
#include 
#include 
#include 
#include 

#ifndef HAVE_POSIX_OPENPT
#undef posix_openpt
#define posix_openpt(mode) open("/dev/ptmx", mode)
#endif

#ifdef HAVE_STROPTS_H
#include 
#endif

static void failed(int code)
{
	perror("conftest");
	exit(code);
}

static void my_timeout(int sig)
{
	exit(99);
}

int main(void)
{

	int code = 0;
	int rc;
	int pty;
	int tty;
	char *slave;
	struct termios tio;

	signal(SIGALRM, my_timeout);

	if (alarm(2) == 9)
		failed(9);
	else if ((pty = posix_openpt(O_RDWR)) < 0)
		failed(1);
	else if ((rc = grantpt(pty)) < 0)
		failed(2);
	else if ((rc = unlockpt(pty)) < 0)
		failed(3);
	else if ((slave = ptsname(pty)) == 0)
		failed(4);
#if (CONFTEST == 3) || defined(CONFTEST_isatty)
	else if (!isatty(pty))
		failed(4);
#endif
#if CONFTEST >= 4
    else if ((rc = tcgetattr(pty, &tio)) < 0)
		failed(20);
    else if ((rc = tcsetattr(pty, TCSAFLUSH, &tio)) < 0)
		failed(21);
#endif
	/* BSD posix_openpt does not treat pty as a terminal until slave is opened.
	 * Linux does treat it that way.
	 */
	else if ((tty = open(slave, O_RDWR)) < 0)
		failed(5);
#ifdef CONFTEST
#ifdef I_PUSH
#if (CONFTEST == 0) || defined(CONFTEST_ptem)
    else if ((rc = ioctl(tty, I_PUSH, "ptem")) < 0)
		failed(10);
#endif
#if (CONFTEST == 1) || defined(CONFTEST_ldterm)
    else if ((rc = ioctl(tty, I_PUSH, "ldterm")) < 0)
		failed(11);
#endif
#if (CONFTEST == 2) || defined(CONFTEST_ttcompat)
    else if ((rc = ioctl(tty, I_PUSH, "ttcompat")) < 0)
		failed(12);
#endif
#endif /* I_PUSH */
#if CONFTEST >= 5
    else if ((rc = tcgetattr(tty, &tio)) < 0)
		failed(30);
    else if ((rc = tcsetattr(tty, TCSAFLUSH, &tio)) < 0)
		failed(31);
#endif
#endif /* CONFTEST */

	${cf_cv_main_return:-return}(code);

}

_ACEOF
rm -f conftest$ac_exeext
if { (eval echo "$as_me:14627: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:14630: \$? = $ac_status" >&5
  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
  { (eval echo "$as_me:14632: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:14635: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  :
else
  echo "$as_me: program exited with status $ac_status" >&5
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_func_grantpt=no

fi
rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi

else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_func_grantpt=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
	echo "$as_me:14654: result: $ac_cv_func_grantpt" >&5
echo "${ECHO_T}$ac_cv_func_grantpt" >&6

	if test "x$ac_cv_func_grantpt" != "xno" ; then

		if test "x$ac_cv_func_grantpt" = "xyes" ; then
			echo "$as_me:14660: checking for pty features" >&5
echo $ECHO_N "checking for pty features... $ECHO_C" >&6
			if test "x$ac_cv_header_stropts_h" = xyes
			then
				cf_pty_this=0
			else
				cf_pty_this=3
			fi

			cf_pty_defines=
			while test $cf_pty_this != 6
			do

				cf_pty_feature=
				cf_pty_next=`expr $cf_pty_this + 1`

echo "${as_me:-configure}:14676: testing pty feature test $cf_pty_next:5 ..." 1>&5

				if test "$cross_compiling" = yes; then
  { { echo "$as_me:14679: error: cannot run test program while cross compiling" >&5
echo "$as_me: error: cannot run test program while cross compiling" >&2;}
   { (exit 1); exit 1; }; }
else
  cat >conftest.$ac_ext <<_ACEOF
#line 14684 "configure"
#include "confdefs.h"
#define CONFTEST $cf_pty_this
$cf_pty_defines

#include 
#include 
#include 
#include 
#include 
#include 

#ifndef HAVE_POSIX_OPENPT
#undef posix_openpt
#define posix_openpt(mode) open("/dev/ptmx", mode)
#endif

#ifdef HAVE_STROPTS_H
#include 
#endif

static void failed(int code)
{
	perror("conftest");
	exit(code);
}

static void my_timeout(int sig)
{
	exit(99);
}

int main(void)
{

	int code = 0;
	int rc;
	int pty;
	int tty;
	char *slave;
	struct termios tio;

	signal(SIGALRM, my_timeout);

	if (alarm(2) == 9)
		failed(9);
	else if ((pty = posix_openpt(O_RDWR)) < 0)
		failed(1);
	else if ((rc = grantpt(pty)) < 0)
		failed(2);
	else if ((rc = unlockpt(pty)) < 0)
		failed(3);
	else if ((slave = ptsname(pty)) == 0)
		failed(4);
#if (CONFTEST == 3) || defined(CONFTEST_isatty)
	else if (!isatty(pty))
		failed(4);
#endif
#if CONFTEST >= 4
    else if ((rc = tcgetattr(pty, &tio)) < 0)
		failed(20);
    else if ((rc = tcsetattr(pty, TCSAFLUSH, &tio)) < 0)
		failed(21);
#endif
	/* BSD posix_openpt does not treat pty as a terminal until slave is opened.
	 * Linux does treat it that way.
	 */
	else if ((tty = open(slave, O_RDWR)) < 0)
		failed(5);
#ifdef CONFTEST
#ifdef I_PUSH
#if (CONFTEST == 0) || defined(CONFTEST_ptem)
    else if ((rc = ioctl(tty, I_PUSH, "ptem")) < 0)
		failed(10);
#endif
#if (CONFTEST == 1) || defined(CONFTEST_ldterm)
    else if ((rc = ioctl(tty, I_PUSH, "ldterm")) < 0)
		failed(11);
#endif
#if (CONFTEST == 2) || defined(CONFTEST_ttcompat)
    else if ((rc = ioctl(tty, I_PUSH, "ttcompat")) < 0)
		failed(12);
#endif
#endif /* I_PUSH */
#if CONFTEST >= 5
    else if ((rc = tcgetattr(tty, &tio)) < 0)
		failed(30);
    else if ((rc = tcsetattr(tty, TCSAFLUSH, &tio)) < 0)
		failed(31);
#endif
#endif /* CONFTEST */

	${cf_cv_main_return:-return}(code);

}

_ACEOF
rm -f conftest$ac_exeext
if { (eval echo "$as_me:14782: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:14785: \$? = $ac_status" >&5
  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
  { (eval echo "$as_me:14787: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:14790: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then

				case $cf_pty_next in
				(1) # - streams
					cf_pty_feature=ptem
					;;
				(2) # - streams
					cf_pty_feature=ldterm
					;;
				(3) # - streams
					cf_pty_feature=ttcompat
					;;
				(4)
					cf_pty_feature=pty_isatty
					;;
				(5)
					cf_pty_feature=pty_tcsetattr
					;;
				(6)
					cf_pty_feature=tty_tcsetattr
					;;
				esac

else
  echo "$as_me: program exited with status $ac_status" >&5
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5

				case $cf_pty_next in
				(1|2|3)

echo "${as_me:-configure}:14822: testing skipping remaining streams features $cf_pty_this..2 ..." 1>&5

					cf_pty_next=3
					;;
				esac

fi
rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi
				if test -n "$cf_pty_feature"
				then
					cf_pty_defines="$cf_pty_defines
#define CONFTEST_$cf_pty_feature 1
"
					cf_grantpt_opts="$cf_grantpt_opts $cf_pty_feature"
				fi

				cf_pty_this=$cf_pty_next
			done
			echo "$as_me:14841: result: $cf_grantpt_opts" >&5
echo "${ECHO_T}$cf_grantpt_opts" >&6
			cf_grantpt_opts=`echo "$cf_grantpt_opts" | sed -e 's/ isatty//'`
		fi
	fi
fi

if test "x$disable_openpty" != "xyes" || test -z "$cf_grantpt_opts" ; then
	echo "$as_me:14849: checking for openpty in -lutil" >&5
echo $ECHO_N "checking for openpty in -lutil... $ECHO_C" >&6
if test "${ac_cv_lib_util_openpty+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lutil  $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line 14857 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char openpty ();
int
main (void)
{
openpty ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:14876: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:14879: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:14882: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:14885: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_lib_util_openpty=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_lib_util_openpty=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:14896: result: $ac_cv_lib_util_openpty" >&5
echo "${ECHO_T}$ac_cv_lib_util_openpty" >&6
if test $ac_cv_lib_util_openpty = yes; then
  cf_have_openpty=yes
else
  cf_have_openpty=no
fi

	if test "$cf_have_openpty" = yes ; then
		ac_cv_func_grantpt=no
		LIBS="-lutil $LIBS"

cat >>confdefs.h <<\EOF
#define HAVE_OPENPTY 1
EOF

for ac_header in \
			util.h \
			libutil.h \
			pty.h \

do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
echo "$as_me:14919: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 14925 "configure"
#include "confdefs.h"
#include <$ac_header>
_ACEOF
if { (eval echo "$as_me:14929: \"$ac_cpp conftest.$ac_ext\"") >&5
  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
  ac_status=$?
  egrep -v '^ *\+' conftest.er1 >conftest.err
  rm -f conftest.er1
  cat conftest.err >&5
  echo "$as_me:14935: \$? = $ac_status" >&5
  (exit $ac_status); } >/dev/null; then
  if test -s conftest.err; then
    ac_cpp_err=$ac_c_preproc_warn_flag
  else
    ac_cpp_err=
  fi
else
  ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
  eval "$as_ac_Header=yes"
else
  echo "$as_me: failed program was:" >&5
  cat conftest.$ac_ext >&5
  eval "$as_ac_Header=no"
fi
rm -f conftest.err conftest.$ac_ext
fi
echo "$as_me:14954: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
if test `eval echo '${'$as_ac_Header'}'` = yes; then
  cat >>confdefs.h <&6

echo "${as_me:-configure}:14971: testing will rely upon grantpt ..." 1>&5

cat >>confdefs.h <<\EOF
#define HAVE_WORKING_GRANTPT 1
EOF

	for cf_feature in $cf_grantpt_opts
	do
		cf_feature=`echo "$cf_feature" | sed -e 's/ //g'`

cf_FEATURE=`echo "$cf_feature" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`

		cat >>confdefs.h <&6

echo "${as_me:-configure}:14992: testing will rely upon BSD-pseudoterminals ..." 1>&5

else
	test -n "$verbose" && echo "	will rely upon openpty" 1>&6

echo "${as_me:-configure}:14997: testing will rely upon openpty ..." 1>&5

fi

echo "$as_me:15001: checking if we can use XkbQueryExtension" >&5
echo $ECHO_N "checking if we can use XkbQueryExtension... $ECHO_C" >&6
if test "${cf_cv_xkb_query_extension+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

cat >conftest.$ac_ext <<_ACEOF
#line 15008 "configure"
#include "confdefs.h"

#include 
#include 
#include 

int
main (void)
{

	int xkbmajor = XkbMajorVersion;
	int xkbminor = XkbMinorVersion;
	int xkbopcode, xkbevent, xkberror;

	if (XkbLibraryVersion(&xkbmajor, &xkbminor)
	    && XkbQueryExtension((Display *)0,
				 &xkbopcode,
				 &xkbevent,
				 &xkberror,
				 &xkbmajor,
				 &xkbminor))
		 return 0;

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:15037: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:15040: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:15043: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:15046: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then

cf_cv_xkb_query_extension=yes

else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5

cf_cv_xkb_query_extension=no

fi
rm -f conftest.$ac_objext conftest.$ac_ext

fi
echo "$as_me:15061: result: $cf_cv_xkb_query_extension" >&5
echo "${ECHO_T}$cf_cv_xkb_query_extension" >&6

if test $cf_cv_xkb_query_extension = yes
then

for ac_func in XkbQueryExtension
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:15070: checking for $ac_func" >&5
echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
if eval "test \"\${$as_ac_var+set}\" = set"; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 15076 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
    which can conflict with char $ac_func (); below.  */
#include 
/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char $ac_func ();
char (*f) ();

int
main (void)
{
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
choke me
#else
f = $ac_func; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
#endif

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:15107: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:15110: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:15113: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:15116: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  eval "$as_ac_var=yes"
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
eval "$as_ac_var=no"
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:15126: result: `eval echo '${'$as_ac_var'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
if test `eval echo '${'$as_ac_var'}'` = yes; then
  cat >>confdefs.h <&5
echo $ECHO_N "checking if we can use XkbKeycodeToKeysym... $ECHO_C" >&6
if test "${cf_cv_xkb_keycode_to_keysym+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

cat >conftest.$ac_ext <<_ACEOF
#line 15145 "configure"
#include "confdefs.h"

#include 
#include 

int
main (void)
{

    KeySym keysym = XkbKeycodeToKeysym((Display *)0, 0, 0, 0);

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:15162: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:15165: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:15168: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:15171: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then

cf_cv_xkb_keycode_to_keysym=yes

else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5

cf_cv_xkb_keycode_to_keysym=no

fi
rm -f conftest.$ac_objext conftest.$ac_ext

fi
echo "$as_me:15186: result: $cf_cv_xkb_keycode_to_keysym" >&5
echo "${ECHO_T}$cf_cv_xkb_keycode_to_keysym" >&6

if test $cf_cv_xkb_keycode_to_keysym = yes
then

for ac_func in XkbKeycodeToKeysym
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:15195: checking for $ac_func" >&5
echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
if eval "test \"\${$as_ac_var+set}\" = set"; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 15201 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
    which can conflict with char $ac_func (); below.  */
#include 
/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char $ac_func ();
char (*f) ();

int
main (void)
{
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
choke me
#else
f = $ac_func; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
#endif

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:15232: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:15235: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:15238: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:15241: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  eval "$as_ac_var=yes"
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
eval "$as_ac_var=no"
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:15251: result: `eval echo '${'$as_ac_var'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
if test `eval echo '${'$as_ac_var'}'` = yes; then
  cat >>confdefs.h <&5
echo $ECHO_N "checking for XKB Bell extension... $ECHO_C" >&6
if test "${cf_cv_xkb_bell_ext+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

cat >conftest.$ac_ext <<_ACEOF
#line 15270 "configure"
#include "confdefs.h"

#include 
#include 		/* has the prototype */
#include 	/* has the XkbBI_xxx definitions */

int
main (void)
{

	int x = (XkbBI_Info |XkbBI_MinorError |XkbBI_MajorError |XkbBI_TerminalBell |XkbBI_MarginBell);
	Atom y;
	XkbBell((Display *)0, (Widget)0, 0, y);

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:15290: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:15293: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:15296: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:15299: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_xkb_bell_ext=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_xkb_bell_ext=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext

fi
echo "$as_me:15310: result: $cf_cv_xkb_bell_ext" >&5
echo "${ECHO_T}$cf_cv_xkb_bell_ext" >&6
test "$cf_cv_xkb_bell_ext" = yes &&
cat >>confdefs.h <<\EOF
#define HAVE_XKB_BELL_EXT 1
EOF

for ac_func in Xutf8LookupString
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:15320: checking for $ac_func" >&5
echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
if eval "test \"\${$as_ac_var+set}\" = set"; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 15326 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
    which can conflict with char $ac_func (); below.  */
#include 
/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char $ac_func ();
char (*f) ();

int
main (void)
{
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
choke me
#else
f = $ac_func; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
#endif

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:15357: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:15360: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:15363: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:15366: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  eval "$as_ac_var=yes"
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
eval "$as_ac_var=no"
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:15376: result: `eval echo '${'$as_ac_var'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
if test `eval echo '${'$as_ac_var'}'` = yes; then
  cat >>confdefs.h <&5
echo $ECHO_N "checking if you want narrow prototypes for X libraries... $ECHO_C" >&6

case `$ac_config_guess` in
(*freebsd*|*gnu*|*irix5*|*irix6*|*linux-gnu*|*netbsd*|*openbsd*|*qnx*|*sco*|*sgi*)
	cf_default_narrowproto=yes
	;;
(*)
	cf_default_narrowproto=no
	;;
esac

# Check whether --enable-narrowproto or --disable-narrowproto was given.
if test "${enable_narrowproto+set}" = set; then
  enableval="$enable_narrowproto"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "$cf_default_narrowproto" ; then
    enable_narrowproto=$enableval
	else
		enable_narrowproto=$cf_default_narrowproto
	fi
else
  enableval=$cf_default_narrowproto
	enable_narrowproto=$cf_default_narrowproto

fi;
echo "$as_me:15418: result: $enable_narrowproto" >&5
echo "${ECHO_T}$enable_narrowproto" >&6

echo "$as_me:15421: checking if we should use imake to help" >&5
echo $ECHO_N "checking if we should use imake to help... $ECHO_C" >&6

# Check whether --enable-imake or --disable-imake was given.
if test "${enable_imake+set}" = set; then
  enableval="$enable_imake"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_imake=no
	else
		enable_imake=yes
	fi
else
  enableval=yes
	enable_imake=yes

fi;
echo "$as_me:15438: result: $enable_imake" >&5
echo "${ECHO_T}$enable_imake" >&6

if test "$enable_imake" = yes ; then

for ac_prog in xmkmf imake
do
  # Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo "$as_me:15447: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_path_IMAKE+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  case $IMAKE in
  [\\/]* | ?:[\\/]*)
  ac_cv_path_IMAKE="$IMAKE" # Let the user override the test with a path.
  ;;
  *)
  ac_save_IFS=$IFS; IFS=$ac_path_separator
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
  IFS=$ac_save_IFS
  test -z "$ac_dir" && ac_dir=.
  if $as_executable_p "$ac_dir/$ac_word"; then
   ac_cv_path_IMAKE="$ac_dir/$ac_word"
   echo "$as_me:15464: found $ac_dir/$ac_word" >&5
   break
fi
done

  ;;
esac
fi
IMAKE=$ac_cv_path_IMAKE

if test -n "$IMAKE"; then
  echo "$as_me:15475: result: $IMAKE" >&5
echo "${ECHO_T}$IMAKE" >&6
else
  echo "$as_me:15478: result: no" >&5
echo "${ECHO_T}no" >&6
fi

  test -n "$IMAKE" && break
done

if test -n "$IMAKE" ; then

case $IMAKE in
(*/imake)
	cf_imake_opts="-DUseInstalled=YES"
	;;
(*/util/xmkmf)
	# A single parameter tells xmkmf where the config-files are:
	cf_imake_opts="`echo $IMAKE|sed -e s,/config/util/xmkmf,,`"
	;;
(*)
	cf_imake_opts=
	;;
esac

# If it's installed properly, imake (or its wrapper, xmkmf) will point to the
# config directory.
if mkdir conftestdir; then
	CDPATH=; export CDPATH
	cf_makefile=`cd $srcdir;pwd`/Imakefile
	cd conftestdir

	cat >fix_cflags.sed <<'CF_EOF'
s/\\//g
s/[ 	][ 	]*/ /g
s/"//g
:pack
s/\(=[^ ][^ ]*\) \([^-]\)/\1	\2/g
t pack
s/\(-D[a-zA-Z0-9_][a-zA-Z0-9_]*\)=\([^\'0-9 ][^ ]*\)/\1='\\"\2\\"'/g
s/^IMAKE[ ]/IMAKE_CFLAGS="/
s/	/ /g
s/$/"/
CF_EOF

	cat >fix_lflags.sed <<'CF_EOF'
s/^IMAKE[ 	]*/IMAKE_LOADFLAGS="/
s/$/"/
CF_EOF

	echo >./Imakefile
	test -f $cf_makefile && cat $cf_makefile >>./Imakefile

	cat >> ./Imakefile <<'CF_EOF'
findstddefs:
	@echo IMAKE ${ALLDEFINES} $(MAIN_DEFINES) $(VENDORMANDEFS)       | sed -f fix_cflags.sed
	@echo IMAKE ${EXTRA_LOAD_FLAGS} | sed -f fix_lflags.sed
CF_EOF

	if ( $IMAKE $cf_imake_opts 1>/dev/null 2>&5 && test -f Makefile)
	then
		test -n "$verbose" && echo "	Using $IMAKE $cf_imake_opts" 1>&6

echo "${as_me:-configure}:15538: testing Using $IMAKE $cf_imake_opts ..." 1>&5

	else
		# sometimes imake doesn't have the config path compiled in.  Find it.
		cf_config=
		for cf_libpath in $X_LIBS $LIBS ; do
			case $cf_libpath in
			(-L*)
				cf_libpath=`echo .$cf_libpath | sed -e 's/^...//'`
				cf_libpath=$cf_libpath/X11/config
				if test -d $cf_libpath ; then
					cf_config=$cf_libpath
					break
				fi
				;;
			esac
		done
		if test -z "$cf_config" ; then
			{ echo "$as_me:15556: WARNING: Could not find imake config-directory" >&5
echo "$as_me: WARNING: Could not find imake config-directory" >&2;}
		else
			cf_imake_opts="$cf_imake_opts -I$cf_config"
			if ( $IMAKE -v $cf_imake_opts 2>&5)
			then
				test -n "$verbose" && echo "	Using $IMAKE $cf_config" 1>&6

echo "${as_me:-configure}:15564: testing Using $IMAKE $cf_config ..." 1>&5

			else
				{ echo "$as_me:15567: WARNING: Cannot run $IMAKE" >&5
echo "$as_me: WARNING: Cannot run $IMAKE" >&2;}
			fi
		fi
	fi

	# GNU make sometimes prints "make[1]: Entering...", which
	# would confuse us.
	eval `make findstddefs 2>/dev/null | grep -v make`

	cd ..
	rm -rf conftestdir

	# We use ${ALLDEFINES} rather than ${STD_DEFINES} because the former
	# declares XTFUNCPROTO there.  However, some vendors (e.g., SGI) have
	# modified it to support site.cf, adding a kludge for the /usr/include
	# directory.  Try to filter that out, otherwise gcc won't find its
	# headers.
	if test -n "$GCC" ; then
	    if test -n "$IMAKE_CFLAGS" ; then
		cf_nostdinc=""
		cf_std_incl=""
		cf_cpp_opts=""
		for cf_opt in $IMAKE_CFLAGS
		do
		    case "$cf_opt" in
		    (-nostdinc)
			cf_nostdinc="$cf_opt"
			;;
		    (-I/usr/include)
			cf_std_incl="$cf_opt"
			;;
		    (*)
			cf_cpp_opts="$cf_cpp_opts $cf_opt"
			;;
		    esac
		done
		if test -z "$cf_nostdinc" ; then
		    IMAKE_CFLAGS="$cf_cpp_opts $cf_std_incl"
		elif test -z "$cf_std_incl" ; then
		    IMAKE_CFLAGS="$cf_cpp_opts $cf_nostdinc"
		else
		    test -n "$verbose" && echo "	suppressed \"$cf_nostdinc\" and \"$cf_std_incl\"" 1>&6

echo "${as_me:-configure}:15611: testing suppressed \"$cf_nostdinc\" and \"$cf_std_incl\" ..." 1>&5

		    IMAKE_CFLAGS="$cf_cpp_opts"
		fi
	    fi
	fi
fi

# Some imake configurations define PROJECTROOT with an empty value.  Remove
# the empty definition.
case $IMAKE_CFLAGS in
(*-DPROJECTROOT=/*)
	;;
(*)
	IMAKE_CFLAGS=`echo "$IMAKE_CFLAGS" |sed -e "s,-DPROJECTROOT=[ 	], ,"`
	;;
esac

fi

test -n "$verbose" && echo "	IMAKE_CFLAGS $IMAKE_CFLAGS" 1>&6

echo "${as_me:-configure}:15633: testing IMAKE_CFLAGS $IMAKE_CFLAGS ..." 1>&5

test -n "$verbose" && echo "	IMAKE_LOADFLAGS $IMAKE_LOADFLAGS" 1>&6

echo "${as_me:-configure}:15637: testing IMAKE_LOADFLAGS $IMAKE_LOADFLAGS ..." 1>&5

fi

if test -n "$IMAKE" && test -n "$IMAKE_CFLAGS" ; then

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $IMAKE_CFLAGS
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

else
	IMAKE_CFLAGS=
	IMAKE_LOADFLAGS=
	test -n "$verbose" && echo "	make fallback definitions" 1>&6

echo "${as_me:-configure}:15746: testing make fallback definitions ..." 1>&5

	# We prefer config.guess' values when we can get them, to avoid
	# inconsistent results with uname (AIX for instance).  However,
	# config.guess is not always consistent either.
	case $host_os in
	(*[0-9].[0-9]*)
		UNAME_RELEASE="$host_os"
		;;
	(*)
		UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
		;;
	esac

	case .$UNAME_RELEASE in
	(*[0-9].[0-9]*)
		OSMAJORVERSION=`echo "$UNAME_RELEASE" |sed -e 's/^[^0-9]*//' -e 's/\..*//'`
		OSMINORVERSION=`echo "$UNAME_RELEASE" |sed -e 's/^[^0-9]*//' -e 's/^[^.]*\.//' -e 's/\..*//' -e 's/[^0-9].*//' `
		test -z "$OSMAJORVERSION" && OSMAJORVERSION=1
		test -z "$OSMINORVERSION" && OSMINORVERSION=0
		IMAKE_CFLAGS="-DOSMAJORVERSION=$OSMAJORVERSION -DOSMINORVERSION=$OSMINORVERSION $IMAKE_CFLAGS"
		;;
	esac

	# FUNCPROTO is standard with X11R6, but XFree86 drops it, leaving some
	# fallback/fragments for NeedPrototypes, etc.
	IMAKE_CFLAGS="-DFUNCPROTO=15 $IMAKE_CFLAGS"

	# If this is not set properly, Xaw's scrollbars will not work
	if test "$enable_narrowproto" = yes ; then
		IMAKE_CFLAGS="-DNARROWPROTO=1 $IMAKE_CFLAGS"
	fi

	# Other special definitions:
	case $host_os in
	(aix*)
		# imake on AIX 5.1 defines AIXV3.  really.
		IMAKE_CFLAGS="-DAIXV3 -DAIXV4 $IMAKE_CFLAGS"
		;;
	(irix[56].*)
		# these are needed to make SIGWINCH work in xterm
		IMAKE_CFLAGS="-DSYSV -DSVR4 $IMAKE_CFLAGS"
		;;
	esac

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $IMAKE_CFLAGS
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

fi

# Extract the first word of "groff", so it can be a program name with args.
set dummy groff; ac_word=$2
echo "$as_me:15893: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_path_GROFF_PATH+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  case $GROFF_PATH in
  [\\/]* | ?:[\\/]*)
  ac_cv_path_GROFF_PATH="$GROFF_PATH" # Let the user override the test with a path.
  ;;
  *)
  ac_save_IFS=$IFS; IFS=$ac_path_separator
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
  IFS=$ac_save_IFS
  test -z "$ac_dir" && ac_dir=.
  if $as_executable_p "$ac_dir/$ac_word"; then
   ac_cv_path_GROFF_PATH="$ac_dir/$ac_word"
   echo "$as_me:15910: found $ac_dir/$ac_word" >&5
   break
fi
done

  test -z "$ac_cv_path_GROFF_PATH" && ac_cv_path_GROFF_PATH="no"
  ;;
esac
fi
GROFF_PATH=$ac_cv_path_GROFF_PATH

if test -n "$GROFF_PATH"; then
  echo "$as_me:15922: result: $GROFF_PATH" >&5
echo "${ECHO_T}$GROFF_PATH" >&6
else
  echo "$as_me:15925: result: no" >&5
echo "${ECHO_T}no" >&6
fi

# Extract the first word of "nroff", so it can be a program name with args.
set dummy nroff; ac_word=$2
echo "$as_me:15931: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_path_NROFF_PATH+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  case $NROFF_PATH in
  [\\/]* | ?:[\\/]*)
  ac_cv_path_NROFF_PATH="$NROFF_PATH" # Let the user override the test with a path.
  ;;
  *)
  ac_save_IFS=$IFS; IFS=$ac_path_separator
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
  IFS=$ac_save_IFS
  test -z "$ac_dir" && ac_dir=.
  if $as_executable_p "$ac_dir/$ac_word"; then
   ac_cv_path_NROFF_PATH="$ac_dir/$ac_word"
   echo "$as_me:15948: found $ac_dir/$ac_word" >&5
   break
fi
done

  test -z "$ac_cv_path_NROFF_PATH" && ac_cv_path_NROFF_PATH="no"
  ;;
esac
fi
NROFF_PATH=$ac_cv_path_NROFF_PATH

if test -n "$NROFF_PATH"; then
  echo "$as_me:15960: result: $NROFF_PATH" >&5
echo "${ECHO_T}$NROFF_PATH" >&6
else
  echo "$as_me:15963: result: no" >&5
echo "${ECHO_T}no" >&6
fi

if test "x$GROFF_PATH" = xno
then
	NROFF_NOTE=
	GROFF_NOTE="#"
else
	NROFF_NOTE="#"
	GROFF_NOTE=
fi

echo "$as_me:15976: checking for program to convert manpage to html" >&5
echo $ECHO_N "checking for program to convert manpage to html... $ECHO_C" >&6

# Check whether --with-man2html or --without-man2html was given.
if test "${with_man2html+set}" = set; then
  withval="$with_man2html"
  cf_man2html=$withval
else
  cf_man2html=$GROFF_PATH
fi;

cf_with_groff=no

case $cf_man2html in
(yes)
	echo "$as_me:15991: result: man2html" >&5
echo "${ECHO_T}man2html" >&6
	# Extract the first word of "man2html", so it can be a program name with args.
set dummy man2html; ac_word=$2
echo "$as_me:15995: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_path_cf_man2html+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  case $cf_man2html in
  [\\/]* | ?:[\\/]*)
  ac_cv_path_cf_man2html="$cf_man2html" # Let the user override the test with a path.
  ;;
  *)
  ac_save_IFS=$IFS; IFS=$ac_path_separator
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
  IFS=$ac_save_IFS
  test -z "$ac_dir" && ac_dir=.
  if $as_executable_p "$ac_dir/$ac_word"; then
   ac_cv_path_cf_man2html="$ac_dir/$ac_word"
   echo "$as_me:16012: found $ac_dir/$ac_word" >&5
   break
fi
done

  test -z "$ac_cv_path_cf_man2html" && ac_cv_path_cf_man2html="no"
  ;;
esac
fi
cf_man2html=$ac_cv_path_cf_man2html

if test -n "$cf_man2html"; then
  echo "$as_me:16024: result: $cf_man2html" >&5
echo "${ECHO_T}$cf_man2html" >&6
else
  echo "$as_me:16027: result: no" >&5
echo "${ECHO_T}no" >&6
fi

	;;
(no|groff|*/groff*)
	cf_with_groff=yes
	cf_man2html=$GROFF_PATH
	echo "$as_me:16035: result: $cf_man2html" >&5
echo "${ECHO_T}$cf_man2html" >&6
	;;
(*)
	echo "$as_me:16039: result: $cf_man2html" >&5
echo "${ECHO_T}$cf_man2html" >&6
	;;
esac

MAN2HTML_TEMP="man2html.tmp"
	cat >$MAN2HTML_TEMP <>$MAN2HTML_TEMP <&5
echo "$as_me: error: expected a pathname, not \"$cf_man2html\"" >&2;}
   { (exit 1); exit 1; }; }
	;;
esac

	MAN2HTML_PATH="$cf_man2html"
	echo "$as_me:16110: checking for $cf_man2html top/bottom margins" >&5
echo $ECHO_N "checking for $cf_man2html top/bottom margins... $ECHO_C" >&6

	# for this example, expect 3 lines of content, the remainder is head/foot
	cat >conftest.in <conftest.out

	cf_man2html_1st=`fgrep -n MARKER conftest.out |sed -e 's/^[^0-9]*://' -e 's/:.*//'`
	cf_man2html_top=`expr $cf_man2html_1st - 2`
	cf_man2html_bot=`wc -l conftest.out |sed -e 's/[^0-9]//g'`
	cf_man2html_bot=`expr $cf_man2html_bot - 2 - $cf_man2html_top`
	cf_man2html_top_bot="-topm=$cf_man2html_top -botm=$cf_man2html_bot"

	echo "$as_me:16128: result: $cf_man2html_top_bot" >&5
echo "${ECHO_T}$cf_man2html_top_bot" >&6

	echo "$as_me:16131: checking for pagesize to use" >&5
echo $ECHO_N "checking for pagesize to use... $ECHO_C" >&6
	for cf_block in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
	do
	cat >>conftest.in <conftest.out
	cf_man2html_page=`fgrep -n HEAD1 conftest.out |tail -n 1 |sed -e 's/^[^0-9]*://' -e 's/:.*//'`
	test -z "$cf_man2html_page" && cf_man2html_page=99999
	test "$cf_man2html_page" -gt 100 && cf_man2html_page=99999

	rm -rf conftest*
	echo "$as_me:16156: result: $cf_man2html_page" >&5
echo "${ECHO_T}$cf_man2html_page" >&6

	cat >>$MAN2HTML_TEMP <&6

echo "${as_me:-configure}:16184: testing removing terminfo flags from IMAKE_CFLAGS ..." 1>&5

	IMAKE_CFLAGS=`echo "$IMAKE_CFLAGS" | sed -e 's/-DUSE_TERMINFO[ 	]*-DHAVE_TIGETSTR[ 	]*//'`
	test -n "$verbose" && echo "	...result $IMAKE_CFLAGS" 1>&6

echo "${as_me:-configure}:16189: testing ...result $IMAKE_CFLAGS ..." 1>&5

	test -n "$verbose" && echo "	removing terminfo flags from CPPFLAGS" 1>&6

echo "${as_me:-configure}:16193: testing removing terminfo flags from CPPFLAGS ..." 1>&5

	CPPFLAGS=`echo "$CPPFLAGS" | sed -e 's/-DUSE_TERMINFO[ 	]*-DHAVE_TIGETSTR[ 	]*//'`
	test -n "$verbose" && echo "	...result $CPPFLAGS" 1>&6

echo "${as_me:-configure}:16198: testing ...result $CPPFLAGS ..." 1>&5

		;;
	esac
fi

echo "$as_me:16204: checking for default terminal-id" >&5
echo $ECHO_N "checking for default terminal-id... $ECHO_C" >&6

# Check whether --with-terminal-id or --without-terminal-id was given.
if test "${with_terminal_id+set}" = set; then
  withval="$with_terminal_id"
  default_termid=$withval
else
  default_termid=vt420
fi;
echo "$as_me:16214: result: $default_termid" >&5
echo "${ECHO_T}$default_termid" >&6
case $default_termid in
(vt*)	default_termid=`echo $default_termid | sed -e 's/^..//'`
	;;
esac

cat >>confdefs.h <&5
echo $ECHO_N "checking for default terminal-type... $ECHO_C" >&6

# Check whether --with-terminal-type or --without-terminal-type was given.
if test "${with_terminal_type+set}" = set; then
  withval="$with_terminal_type"
  default_TERM=$withval
else
  default_TERM=xterm
fi;
echo "$as_me:16235: result: $default_TERM" >&5
echo "${ECHO_T}$default_TERM" >&6

cat >>confdefs.h <&5
echo $ECHO_N "checking if backarrow-key should be BS... $ECHO_C" >&6

# Check whether --enable-backarrow-key or --disable-backarrow-key was given.
if test "${enable_backarrow_key+set}" = set; then
  enableval="$enable_backarrow_key"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    backarrow_is_bs=$enableval
	else
		backarrow_is_bs=yes
	fi
else
  enableval=yes
	backarrow_is_bs=yes

fi;

echo "$as_me:16261: result: $backarrow_is_bs" >&5
echo "${ECHO_T}$backarrow_is_bs" >&6
case $backarrow_is_bs in
(yes)
	backarrow_is_bs=true
	;;
(no)
	backarrow_is_bs=false
	;;
esac
cf_xbool1=`echo "$backarrow_is_bs"|sed -e 's/^\(.\).*/\1/'`

cf_xbool1=`echo "$cf_xbool1" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`

cf_xbool2=`echo "$backarrow_is_bs"|sed -e 's/^.//'`
backarrow_is_bs=${cf_xbool1}${cf_xbool2}

cat >>confdefs.h <&5
echo $ECHO_N "checking if backarrow-key should be treated as erase... $ECHO_C" >&6

# Check whether --enable-backarrow-is-erase or --disable-backarrow-is-erase was given.
if test "${enable_backarrow_is_erase+set}" = set; then
  enableval="$enable_backarrow_is_erase"
  test "$enableval" != yes && enableval=no
	if test "$enableval" != "no" ; then
    backarrow_is_erase=$enableval
	else
		backarrow_is_erase=no
	fi
else
  enableval=no
	backarrow_is_erase=no

fi;

echo "$as_me:16300: result: $backarrow_is_erase" >&5
echo "${ECHO_T}$backarrow_is_erase" >&6
case $backarrow_is_erase in
(yes)
	backarrow_is_erase=true
	;;
(no)
	backarrow_is_erase=false
	;;
esac
cf_xbool1=`echo "$backarrow_is_erase"|sed -e 's/^\(.\).*/\1/'`

cf_xbool1=`echo "$cf_xbool1" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`

cf_xbool2=`echo "$backarrow_is_erase"|sed -e 's/^.//'`
backarrow_is_erase=${cf_xbool1}${cf_xbool2}

cat >>confdefs.h <&5
echo $ECHO_N "checking for default backspace/DEL setting... $ECHO_C" >&6

# Check whether --enable-delete-is-del or --disable-delete-is-del was given.
if test "${enable_delete_is_del+set}" = set; then
  enableval="$enable_delete_is_del"
  delete_is_del=$enableval
else
  delete_is_del=maybe
fi;

echo "$as_me:16332: result: $delete_is_del" >&5
echo "${ECHO_T}$delete_is_del" >&6
case $delete_is_del in
(yes)
	delete_is_del=true
	;;
(no)
	delete_is_del=false
	;;
esac
cf_xbool1=`echo "$delete_is_del"|sed -e 's/^\(.\).*/\1/'`

cf_xbool1=`echo "$cf_xbool1" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`

cf_xbool2=`echo "$delete_is_del"|sed -e 's/^.//'`
delete_is_del=${cf_xbool1}${cf_xbool2}

cat >>confdefs.h <&5
echo $ECHO_N "checking for default pty initial erase setting... $ECHO_C" >&6

# Check whether --enable-pty-erase or --disable-pty-erase was given.
if test "${enable_pty_erase+set}" = set; then
  enableval="$enable_pty_erase"
  initial_erase=$enableval
else
  initial_erase=False
fi;

echo "$as_me:16364: result: $initial_erase" >&5
echo "${ECHO_T}$initial_erase" >&6
case $initial_erase in
(yes)
	initial_erase=true
	;;
(no)
	initial_erase=false
	;;
esac
cf_xbool1=`echo "$initial_erase"|sed -e 's/^\(.\).*/\1/'`

cf_xbool1=`echo "$cf_xbool1" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`

cf_xbool2=`echo "$initial_erase"|sed -e 's/^.//'`
initial_erase=${cf_xbool1}${cf_xbool2}

cat >>confdefs.h <&5
echo $ECHO_N "checking if alt should send ESC... $ECHO_C" >&6

# Check whether --enable-alt-sends-esc or --disable-alt-sends-esc was given.
if test "${enable_alt_sends_esc+set}" = set; then
  enableval="$enable_alt_sends_esc"
  test "$enableval" != yes && enableval=no
	if test "$enableval" != "no" ; then
    alt_sends_esc=$enableval
	else
		alt_sends_esc=no
	fi
else
  enableval=no
	alt_sends_esc=no

fi;

echo "$as_me:16403: result: $alt_sends_esc" >&5
echo "${ECHO_T}$alt_sends_esc" >&6
case $alt_sends_esc in
(yes)
	alt_sends_esc=true
	;;
(no)
	alt_sends_esc=false
	;;
esac
cf_xbool1=`echo "$alt_sends_esc"|sed -e 's/^\(.\).*/\1/'`

cf_xbool1=`echo "$cf_xbool1" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`

cf_xbool2=`echo "$alt_sends_esc"|sed -e 's/^.//'`
alt_sends_esc=${cf_xbool1}${cf_xbool2}

cat >>confdefs.h <&5
echo $ECHO_N "checking if meta should send ESC... $ECHO_C" >&6

# Check whether --enable-meta-sends-esc or --disable-meta-sends-esc was given.
if test "${enable_meta_sends_esc+set}" = set; then
  enableval="$enable_meta_sends_esc"
  test "$enableval" != yes && enableval=no
	if test "$enableval" != "no" ; then
    meta_sends_esc=$enableval
	else
		meta_sends_esc=no
	fi
else
  enableval=no
	meta_sends_esc=no

fi;

echo "$as_me:16442: result: $meta_sends_esc" >&5
echo "${ECHO_T}$meta_sends_esc" >&6
case $meta_sends_esc in
(yes)
	meta_sends_esc=true
	;;
(no)
	meta_sends_esc=false
	;;
esac
cf_xbool1=`echo "$meta_sends_esc"|sed -e 's/^\(.\).*/\1/'`

cf_xbool1=`echo "$cf_xbool1" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`

cf_xbool2=`echo "$meta_sends_esc"|sed -e 's/^.//'`
meta_sends_esc=${cf_xbool1}${cf_xbool2}

cat >>confdefs.h <&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_cf_tic_prog+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  if test -n "$cf_tic_prog"; then
  ac_cv_prog_cf_tic_prog="$cf_tic_prog" # Let the user override the test.
else
  ac_save_IFS=$IFS; IFS=$ac_path_separator
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
  IFS=$ac_save_IFS
  test -z "$ac_dir" && ac_dir=.
  $as_executable_p "$ac_dir/$ac_word" || continue
ac_cv_prog_cf_tic_prog="yes"
echo "$as_me:16481: found $ac_dir/$ac_word" >&5
break
done

  test -z "$ac_cv_prog_cf_tic_prog" && ac_cv_prog_cf_tic_prog="no"
fi
fi
cf_tic_prog=$ac_cv_prog_cf_tic_prog
if test -n "$cf_tic_prog"; then
  echo "$as_me:16490: result: $cf_tic_prog" >&5
echo "${ECHO_T}$cf_tic_prog" >&6
else
  echo "$as_me:16493: result: no" >&5
echo "${ECHO_T}no" >&6
fi

if test "$cf_tic_prog" = yes ; then
	echo "$as_me:16498: checking for private terminfo-directory" >&5
echo $ECHO_N "checking for private terminfo-directory... $ECHO_C" >&6

# Check whether --with-own-terminfo or --without-own-terminfo was given.
if test "${with_own_terminfo+set}" = set; then
  withval="$with_own_terminfo"
  TERMINFO_DIR=$withval
else
  TERMINFO_DIR=${TERMINFO-none}
fi;
	echo "$as_me:16508: result: $TERMINFO_DIR" >&5
echo "${ECHO_T}$TERMINFO_DIR" >&6
	if test "$TERMINFO_DIR" = yes ; then
		{ echo "$as_me:16511: WARNING: no value given" >&5
echo "$as_me: WARNING: no value given" >&2;}
	elif test "$TERMINFO_DIR" != none ; then
		if test -d $TERMINFO_DIR ; then

cat >>confdefs.h <&5
echo $ECHO_N "checking if \$TERMINFO should also be set... $ECHO_C" >&6

# Check whether --enable-env-terminfo or --disable-env-terminfo was given.
if test "${enable_env_terminfo+set}" = set; then
  enableval="$enable_env_terminfo"
  cf_env_terminfo=yes
else
  cf_env_terminfo=no
fi;
			echo "$as_me:16530: result: $cf_env_terminfo" >&5
echo "${ECHO_T}$cf_env_terminfo" >&6
			test $cf_env_terminfo = yes &&

cat >>confdefs.h <<\EOF
#define OWN_TERMINFO_ENV 1
EOF

		else
			{ echo "$as_me:16539: WARNING: not a directory" >&5
echo "$as_me: WARNING: not a directory" >&2;}
		fi
	elif test "$prefix" != NONE ; then
		TERMINFO_DIR='${prefix}/lib/terminfo'
	elif test -d /usr/lib/terminfo ; then
		TERMINFO_DIR=/usr/lib/terminfo
	else
		TERMINFO_DIR=
	fi
	SET_TERMINFO=
	if test -n "$TERMINFO_DIR" ; then
		TERMINFO_DIR='$(DESTDIR)'$TERMINFO_DIR
		SET_TERMINFO='TERMINFO=$(TERMINFO_DIR)'
	fi
	no_ticprog=
else
	no_ticprog="#"
	TERMINFO_DIR=
	SET_TERMINFO=
fi

###############################################################################

echo "$as_me:16563: checking if you want active-icons" >&5
echo $ECHO_N "checking if you want active-icons... $ECHO_C" >&6

# Check whether --enable-active-icon or --disable-active-icon was given.
if test "${enable_active_icon+set}" = set; then
  enableval="$enable_active_icon"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_active_icon=no
	else
		enable_active_icon=yes
	fi
else
  enableval=yes
	enable_active_icon=yes

fi;
echo "$as_me:16580: result: $enable_active_icon" >&5
echo "${ECHO_T}$enable_active_icon" >&6
if test "$enable_active_icon" = no ; then

cat >>confdefs.h <<\EOF
#define NO_ACTIVE_ICON 1
EOF

fi

echo "$as_me:16590: checking if you want ANSI color" >&5
echo $ECHO_N "checking if you want ANSI color... $ECHO_C" >&6

# Check whether --enable-ansi-color or --disable-ansi-color was given.
if test "${enable_ansi_color+set}" = set; then
  enableval="$enable_ansi_color"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_ansi_color=no
	else
		enable_ansi_color=yes
	fi
else
  enableval=yes
	enable_ansi_color=yes

fi;
echo "$as_me:16607: result: $enable_ansi_color" >&5
echo "${ECHO_T}$enable_ansi_color" >&6
test "$enable_ansi_color" = no &&
cat >>confdefs.h <<\EOF
#define OPT_ISO_COLORS 0
EOF

if test "$enable_ansi_color" = yes ; then

	echo "$as_me:16616: checking if you want 16 colors like aixterm" >&5
echo $ECHO_N "checking if you want 16 colors like aixterm... $ECHO_C" >&6

# Check whether --enable-16-color or --disable-16-color was given.
if test "${enable_16_color+set}" = set; then
  enableval="$enable_16_color"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_16_color=no
	else
		enable_16_color=yes
	fi
else
  enableval=yes
	enable_16_color=yes

fi;
	echo "$as_me:16633: result: $enable_16_color" >&5
echo "${ECHO_T}$enable_16_color" >&6
	test "$enable_16_color" = no &&
cat >>confdefs.h <<\EOF
#define OPT_AIX_COLORS 0
EOF

	echo "$as_me:16640: checking if you want 256 colors" >&5
echo $ECHO_N "checking if you want 256 colors... $ECHO_C" >&6

# Check whether --enable-256-color or --disable-256-color was given.
if test "${enable_256_color+set}" = set; then
  enableval="$enable_256_color"
  test "$enableval" != yes && enableval=no
	if test "$enableval" != "no" ; then
    enable_256_color=yes
	else
		enable_256_color=no
	fi
else
  enableval=no
	enable_256_color=no

fi;
	echo "$as_me:16657: result: $enable_256_color" >&5
echo "${ECHO_T}$enable_256_color" >&6
	if test "$enable_256_color" = yes ; then
		CHARPROC_DEPS="$CHARPROC_DEPS 256colres.h"
		EXTRAHDRS="$EXTRAHDRS 256colres.h"

cat >>confdefs.h <<\EOF
#define OPT_256_COLORS 1
EOF

	else
	echo "$as_me:16668: checking if you want 88 colors" >&5
echo $ECHO_N "checking if you want 88 colors... $ECHO_C" >&6

# Check whether --enable-88-color or --disable-88-color was given.
if test "${enable_88_color+set}" = set; then
  enableval="$enable_88_color"
  test "$enableval" != yes && enableval=no
	if test "$enableval" != "no" ; then
    enable_88_color=yes
	else
		enable_88_color=no
	fi
else
  enableval=no
	enable_88_color=no

fi;
	echo "$as_me:16685: result: $enable_88_color" >&5
echo "${ECHO_T}$enable_88_color" >&6
	if test "$enable_88_color" = yes ; then
		CHARPROC_DEPS="$CHARPROC_DEPS 88colres.h"
		EXTRAHDRS="$EXTRAHDRS 88colres.h"

cat >>confdefs.h <<\EOF
#define OPT_88_COLORS 1
EOF

	fi
	fi

fi

echo "$as_me:16700: checking if you want blinking cursor" >&5
echo $ECHO_N "checking if you want blinking cursor... $ECHO_C" >&6

# Check whether --enable-blink-cursor or --disable-blink-cursor was given.
if test "${enable_blink_cursor+set}" = set; then
  enableval="$enable_blink_cursor"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_blink_curs=no
	else
		enable_blink_curs=yes
	fi
else
  enableval=yes
	enable_blink_curs=yes

fi;
echo "$as_me:16717: result: $enable_blink_curs" >&5
echo "${ECHO_T}$enable_blink_curs" >&6
test "$enable_blink_curs" = no &&
cat >>confdefs.h <<\EOF
#define OPT_BLINK_CURS 0
EOF

echo "$as_me:16724: checking if you want to ignore Linux's broken palette-strings" >&5
echo $ECHO_N "checking if you want to ignore Linux's broken palette-strings... $ECHO_C" >&6

case $host_os in
(linux*)
	assume_broken_osc=yes ;;
(*)
	assume_broken_osc=no ;;
esac

# Check whether --enable-broken-osc or --disable-broken-osc was given.
if test "${enable_broken_osc+set}" = set; then
  enableval="$enable_broken_osc"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "$assume_broken_osc" ; then
    enable_broken_osc=$enableval
	else
		enable_broken_osc=$enableval
	fi
else
  enableval=$assume_broken_osc
	enable_broken_osc=$enableval

fi;
echo "$as_me:16748: result: $enable_broken_osc" >&5
echo "${ECHO_T}$enable_broken_osc" >&6
if test "$enable_broken_osc" = yes ; then

cat >>confdefs.h <<\EOF
#define OPT_BROKEN_OSC 1
EOF

else

cat >>confdefs.h <<\EOF
#define OPT_BROKEN_OSC 0
EOF

fi

echo "$as_me:16764: checking if you want to allow broken string-terminators" >&5
echo $ECHO_N "checking if you want to allow broken string-terminators... $ECHO_C" >&6

# Check whether --enable-broken-st or --disable-broken-st was given.
if test "${enable_broken_st+set}" = set; then
  enableval="$enable_broken_st"
  test "$enableval" != yes && enableval=no
	if test "$enableval" != "no" ; then
    enable_broken_st=no
	else
		enable_broken_st=yes
	fi
else
  enableval=no
	enable_broken_st=yes

fi;
echo "$as_me:16781: result: $enable_broken_st" >&5
echo "${ECHO_T}$enable_broken_st" >&6
test "$enable_broken_st" = no &&
cat >>confdefs.h <<\EOF
#define OPT_BROKEN_ST 0
EOF

echo "$as_me:16788: checking if you want to compile-in icon data" >&5
echo $ECHO_N "checking if you want to compile-in icon data... $ECHO_C" >&6

# Check whether --enable-builtin-xpms or --disable-builtin-xpms was given.
if test "${enable_builtin_xpms+set}" = set; then
  enableval="$enable_builtin_xpms"
  test "$enableval" != yes && enableval=no
	if test "$enableval" != "no" ; then
    enable_builtin_xpms=yes
	else
		enable_builtin_xpms=no
	fi
else
  enableval=no
	enable_builtin_xpms=no

fi;
echo "$as_me:16805: result: $enable_builtin_xpms" >&5
echo "${ECHO_T}$enable_builtin_xpms" >&6
test "$enable_builtin_xpms" = yes &&
cat >>confdefs.h <<\EOF
#define OPT_BUILTIN_XPMS 1
EOF

echo "$as_me:16812: checking if you want printable 128-159" >&5
echo $ECHO_N "checking if you want printable 128-159... $ECHO_C" >&6

# Check whether --enable-c1-print or --disable-c1-print was given.
if test "${enable_c1_print+set}" = set; then
  enableval="$enable_c1_print"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_c1_print=no
	else
		enable_c1_print=yes
	fi
else
  enableval=yes
	enable_c1_print=yes

fi;
echo "$as_me:16829: result: $enable_c1_print" >&5
echo "${ECHO_T}$enable_c1_print" >&6
test "$enable_c1_print" = no &&
cat >>confdefs.h <<\EOF
#define OPT_C1_PRINT 0
EOF

if test "$enable_ansi_color" = yes ; then

	echo "$as_me:16838: checking if you want bold colors mapped like IBM PC" >&5
echo $ECHO_N "checking if you want bold colors mapped like IBM PC... $ECHO_C" >&6

# Check whether --enable-bold-color or --disable-bold-color was given.
if test "${enable_bold_color+set}" = set; then
  enableval="$enable_bold_color"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_pc_color=no
	else
		enable_pc_color=yes
	fi
else
  enableval=yes
	enable_pc_color=yes

fi;
	echo "$as_me:16855: result: $enable_pc_color" >&5
echo "${ECHO_T}$enable_pc_color" >&6
	test "$enable_pc_color" = no &&
cat >>confdefs.h <<\EOF
#define OPT_PC_COLORS 0
EOF

	echo "$as_me:16862: checking if you want separate color-classes" >&5
echo $ECHO_N "checking if you want separate color-classes... $ECHO_C" >&6

# Check whether --enable-color-class or --disable-color-class was given.
if test "${enable_color_class+set}" = set; then
  enableval="$enable_color_class"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_color_class=no
	else
		enable_color_class=yes
	fi
else
  enableval=yes
	enable_color_class=yes

fi;
	echo "$as_me:16879: result: $enable_color_class" >&5
echo "${ECHO_T}$enable_color_class" >&6
	test "$enable_color_class" = no &&
cat >>confdefs.h <<\EOF
#define OPT_COLOR_CLASS 0
EOF

	echo "$as_me:16886: checking if you want color-mode enabled by default" >&5
echo $ECHO_N "checking if you want color-mode enabled by default... $ECHO_C" >&6

# Check whether --enable-color-mode or --disable-color-mode was given.
if test "${enable_color_mode+set}" = set; then
  enableval="$enable_color_mode"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    default_colormode=no
	else
		default_colormode=yes
	fi
else
  enableval=yes
	default_colormode=yes

fi;
	echo "$as_me:16903: result: $default_colormode" >&5
echo "${ECHO_T}$default_colormode" >&6
	test "$default_colormode" = no &&
cat >>confdefs.h <<\EOF
#define DFT_COLORMODE 0
EOF

fi

echo "$as_me:16912: checking if you want support for color highlighting" >&5
echo $ECHO_N "checking if you want support for color highlighting... $ECHO_C" >&6

# Check whether --enable-highlighting or --disable-highlighting was given.
if test "${enable_highlighting+set}" = set; then
  enableval="$enable_highlighting"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    default_highlight=no
	else
		default_highlight=yes
	fi
else
  enableval=yes
	default_highlight=yes

fi;
echo "$as_me:16929: result: $default_highlight" >&5
echo "${ECHO_T}$default_highlight" >&6
test "$default_highlight" = no &&
cat >>confdefs.h <<\EOF
#define OPT_HIGHLIGHT_COLOR 0
EOF

echo "$as_me:16936: checking if you want support for doublesize characters" >&5
echo $ECHO_N "checking if you want support for doublesize characters... $ECHO_C" >&6

# Check whether --enable-doublechars or --disable-doublechars was given.
if test "${enable_doublechars+set}" = set; then
  enableval="$enable_doublechars"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_doublechars=no
	else
		enable_doublechars=yes
	fi
else
  enableval=yes
	enable_doublechars=yes

fi;
echo "$as_me:16953: result: $enable_doublechars" >&5
echo "${ECHO_T}$enable_doublechars" >&6
test "$enable_doublechars" = no &&
cat >>confdefs.h <<\EOF
#define OPT_DEC_CHRSET 0
EOF

echo "$as_me:16960: checking if you want fallback-support for box characters" >&5
echo $ECHO_N "checking if you want fallback-support for box characters... $ECHO_C" >&6

# Check whether --enable-boxchars or --disable-boxchars was given.
if test "${enable_boxchars+set}" = set; then
  enableval="$enable_boxchars"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_boxchars=no
	else
		enable_boxchars=yes
	fi
else
  enableval=yes
	enable_boxchars=yes

fi;
echo "$as_me:16977: result: $enable_boxchars" >&5
echo "${ECHO_T}$enable_boxchars" >&6
test "$enable_boxchars" = no &&
cat >>confdefs.h <<\EOF
#define OPT_BOX_CHARS 0
EOF

echo "$as_me:16984: checking if you want to allow spawning new xterms" >&5
echo $ECHO_N "checking if you want to allow spawning new xterms... $ECHO_C" >&6

# Check whether --enable-exec-xterm or --disable-exec-xterm was given.
if test "${enable_exec_xterm+set}" = set; then
  enableval="$enable_exec_xterm"
  test "$enableval" != yes && enableval=no
	if test "$enableval" != "no" ; then
    enable_exec_xterm=yes
	else
		enable_exec_xterm=no
	fi
else
  enableval=no
	enable_exec_xterm=no

fi;
echo "$as_me:17001: result: $enable_exec_xterm" >&5
echo "${ECHO_T}$enable_exec_xterm" >&6
if test "$enable_exec_xterm" = yes ; then

echo "$as_me:17005: checking for proc tree with cwd-support" >&5
echo $ECHO_N "checking for proc tree with cwd-support... $ECHO_C" >&6
if test "${cf_cv_procfs_cwd+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

cf_cv_procfs_cwd=no
for cf_path in /proc /compat/linux/proc /usr/compat/linux/proc
do
	if test -d $cf_path && \
	   test -d $cf_path/$$ && \
	   ( test -d $cf_path/$$/cwd || \
	     test -L $cf_path/$$/cwd ); then
		cf_cv_procfs_cwd=$cf_path
		break
	fi
done

fi
echo "$as_me:17024: result: $cf_cv_procfs_cwd" >&5
echo "${ECHO_T}$cf_cv_procfs_cwd" >&6

	if test "$cf_cv_procfs_cwd" = no ; then
		{ echo "$as_me:17028: WARNING: no suitable proc filesystem found" >&5
echo "$as_me: WARNING: no suitable proc filesystem found" >&2;}
	else

cat >>confdefs.h <>confdefs.h <<\EOF
#define OPT_EXEC_XTERM 1
EOF

	fi
fi

echo "$as_me:17043: checking if you want to use double-buffering" >&5
echo $ECHO_N "checking if you want to use double-buffering... $ECHO_C" >&6

# Check whether --enable-double-buffer or --disable-double-buffer was given.
if test "${enable_double_buffer+set}" = set; then
  enableval="$enable_double_buffer"
  test "$enableval" != yes && enableval=no
	if test "$enableval" != "no" ; then
    enable_double_bfr=yes
	else
		enable_double_bfr=no
	fi
else
  enableval=no
	enable_double_bfr=no

fi;
echo "$as_me:17060: result: $enable_double_bfr" >&5
echo "${ECHO_T}$enable_double_bfr" >&6
if test "$enable_double_bfr" = yes ; then
	case "x$LIBS" in
	(*Xext*)
		;;
	(*)

if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists Xext; then
	test -n "$verbose" && echo "	found package Xext" 1>&6

echo "${as_me:-configure}:17071: testing found package Xext ..." 1>&5

	cf_pkgconfig_incs="`$PKG_CONFIG --cflags Xext 2>/dev/null`"
	cf_pkgconfig_libs="`$PKG_CONFIG --libs   Xext 2>/dev/null`"
	test -n "$verbose" && echo "	package Xext CFLAGS: $cf_pkgconfig_incs" 1>&6

echo "${as_me:-configure}:17077: testing package Xext CFLAGS: $cf_pkgconfig_incs ..." 1>&5

	test -n "$verbose" && echo "	package Xext LIBS: $cf_pkgconfig_libs" 1>&6

echo "${as_me:-configure}:17081: testing package Xext LIBS: $cf_pkgconfig_libs ..." 1>&5

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_pkgconfig_incs
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

cf_add_libs="$cf_pkgconfig_libs"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

	:
else
	cf_pkgconfig_incs=
	cf_pkgconfig_libs=

	echo "$as_me:17202: checking for XextCreateExtension in -lXext" >&5
echo $ECHO_N "checking for XextCreateExtension in -lXext... $ECHO_C" >&6
if test "${ac_cv_lib_Xext_XextCreateExtension+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lXext  $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line 17210 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char XextCreateExtension ();
int
main (void)
{
XextCreateExtension ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:17229: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:17232: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:17235: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:17238: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_lib_Xext_XextCreateExtension=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_lib_Xext_XextCreateExtension=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:17249: result: $ac_cv_lib_Xext_XextCreateExtension" >&5
echo "${ECHO_T}$ac_cv_lib_Xext_XextCreateExtension" >&6
if test $ac_cv_lib_Xext_XextCreateExtension = yes; then

cf_add_libs="-lXext"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

fi

fi

		;;
	esac

cat >>confdefs.h <<\EOF
#define OPT_DOUBLE_BUFFER 1
EOF

fi

echo "$as_me:17282: checking if you want to use FreeType library" >&5
echo $ECHO_N "checking if you want to use FreeType library... $ECHO_C" >&6

# Check whether --enable-freetype or --disable-freetype was given.
if test "${enable_freetype+set}" = set; then
  enableval="$enable_freetype"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_freetype=no
	else
		enable_freetype=yes
	fi
else
  enableval=yes
	enable_freetype=yes

fi;
echo "$as_me:17299: result: $enable_freetype" >&5
echo "${ECHO_T}$enable_freetype" >&6
if test "$enable_freetype" = yes ; then

cf_cv_x_freetype_incs=no
cf_cv_x_freetype_libs=no
cf_extra_freetype_libs=
FREETYPE_CONFIG=none
FREETYPE_PARAMS=

echo "$as_me:17309: checking for FreeType configuration script" >&5
echo $ECHO_N "checking for FreeType configuration script... $ECHO_C" >&6

# Check whether --with-freetype-config or --without-freetype-config was given.
if test "${with_freetype_config+set}" = set; then
  withval="$with_freetype_config"
  cf_cv_x_freetype_cfgs="$withval"
else
  cf_cv_x_freetype_cfgs=auto
fi;
test -z $cf_cv_x_freetype_cfgs && cf_cv_x_freetype_cfgs=auto
test $cf_cv_x_freetype_cfgs = no && cf_cv_x_freetype_cfgs=none
echo "$as_me:17321: result: $cf_cv_x_freetype_cfgs" >&5
echo "${ECHO_T}$cf_cv_x_freetype_cfgs" >&6

case $cf_cv_x_freetype_cfgs in
(none)
	echo "$as_me:17326: checking if you specified -D/-I options for FreeType" >&5
echo $ECHO_N "checking if you specified -D/-I options for FreeType... $ECHO_C" >&6

# Check whether --with-freetype-cflags or --without-freetype-cflags was given.
if test "${with_freetype_cflags+set}" = set; then
  withval="$with_freetype_cflags"
  cf_cv_x_freetype_incs="$with_freetype_cflags"
else
  cf_cv_x_freetype_incs=no
fi;
	echo "$as_me:17336: result: $cf_cv_x_freetype_incs" >&5
echo "${ECHO_T}$cf_cv_x_freetype_incs" >&6

	echo "$as_me:17339: checking if you specified -L/-l options for FreeType" >&5
echo $ECHO_N "checking if you specified -L/-l options for FreeType... $ECHO_C" >&6

# Check whether --with-freetype-libs or --without-freetype-libs was given.
if test "${with_freetype_libs+set}" = set; then
  withval="$with_freetype_libs"
  cf_cv_x_freetype_libs="$with_freetype_libs"
else
  cf_cv_x_freetype_libs=no
fi;
	echo "$as_me:17349: result: $cf_cv_x_freetype_libs" >&5
echo "${ECHO_T}$cf_cv_x_freetype_libs" >&6
	;;
(auto)
	if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xft; then
		FREETYPE_CONFIG=$PKG_CONFIG
		FREETYPE_PARAMS=xft
	else
		# Extract the first word of "freetype-config", so it can be a program name with args.
set dummy freetype-config; ac_word=$2
echo "$as_me:17359: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_path_FREETYPE_CONFIG+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  case $FREETYPE_CONFIG in
  [\\/]* | ?:[\\/]*)
  ac_cv_path_FREETYPE_CONFIG="$FREETYPE_CONFIG" # Let the user override the test with a path.
  ;;
  *)
  ac_save_IFS=$IFS; IFS=$ac_path_separator
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
  IFS=$ac_save_IFS
  test -z "$ac_dir" && ac_dir=.
  if $as_executable_p "$ac_dir/$ac_word"; then
   ac_cv_path_FREETYPE_CONFIG="$ac_dir/$ac_word"
   echo "$as_me:17376: found $ac_dir/$ac_word" >&5
   break
fi
done

  test -z "$ac_cv_path_FREETYPE_CONFIG" && ac_cv_path_FREETYPE_CONFIG="none"
  ;;
esac
fi
FREETYPE_CONFIG=$ac_cv_path_FREETYPE_CONFIG

if test -n "$FREETYPE_CONFIG"; then
  echo "$as_me:17388: result: $FREETYPE_CONFIG" >&5
echo "${ECHO_T}$FREETYPE_CONFIG" >&6
else
  echo "$as_me:17391: result: no" >&5
echo "${ECHO_T}no" >&6
fi

		if test "$FREETYPE_CONFIG" != none; then
			FREETYPE_CONFIG=$FREETYPE_CONFIG
			cf_extra_freetype_libs="-lXft"
		else
			# Extract the first word of "xft-config", so it can be a program name with args.
set dummy xft-config; ac_word=$2
echo "$as_me:17401: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_path_FREETYPE_OLD_CONFIG+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  case $FREETYPE_OLD_CONFIG in
  [\\/]* | ?:[\\/]*)
  ac_cv_path_FREETYPE_OLD_CONFIG="$FREETYPE_OLD_CONFIG" # Let the user override the test with a path.
  ;;
  *)
  ac_save_IFS=$IFS; IFS=$ac_path_separator
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
  IFS=$ac_save_IFS
  test -z "$ac_dir" && ac_dir=.
  if $as_executable_p "$ac_dir/$ac_word"; then
   ac_cv_path_FREETYPE_OLD_CONFIG="$ac_dir/$ac_word"
   echo "$as_me:17418: found $ac_dir/$ac_word" >&5
   break
fi
done

  test -z "$ac_cv_path_FREETYPE_OLD_CONFIG" && ac_cv_path_FREETYPE_OLD_CONFIG="none"
  ;;
esac
fi
FREETYPE_OLD_CONFIG=$ac_cv_path_FREETYPE_OLD_CONFIG

if test -n "$FREETYPE_OLD_CONFIG"; then
  echo "$as_me:17430: result: $FREETYPE_OLD_CONFIG" >&5
echo "${ECHO_T}$FREETYPE_OLD_CONFIG" >&6
else
  echo "$as_me:17433: result: no" >&5
echo "${ECHO_T}no" >&6
fi

			if test "$FREETYPE_OLD_CONFIG" != none; then
				FREETYPE_CONFIG=$FREETYPE_OLD_CONFIG
			fi
		fi
	fi
	;;
(pkg*)
	if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xft; then
		FREETYPE_CONFIG=$cf_cv_x_freetype_cfgs
		FREETYPE_PARAMS=xft
	else
		{ echo "$as_me:17448: WARNING: cannot find pkg-config for Xft" >&5
echo "$as_me: WARNING: cannot find pkg-config for Xft" >&2;}
	fi
	;;
(*)
	# Extract the first word of "$cf_cv_x_freetype_cfgs", so it can be a program name with args.
set dummy $cf_cv_x_freetype_cfgs; ac_word=$2
echo "$as_me:17455: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_path_FREETYPE_XFT_CONFIG+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  case $FREETYPE_XFT_CONFIG in
  [\\/]* | ?:[\\/]*)
  ac_cv_path_FREETYPE_XFT_CONFIG="$FREETYPE_XFT_CONFIG" # Let the user override the test with a path.
  ;;
  *)
  ac_save_IFS=$IFS; IFS=$ac_path_separator
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
  IFS=$ac_save_IFS
  test -z "$ac_dir" && ac_dir=.
  if $as_executable_p "$ac_dir/$ac_word"; then
   ac_cv_path_FREETYPE_XFT_CONFIG="$ac_dir/$ac_word"
   echo "$as_me:17472: found $ac_dir/$ac_word" >&5
   break
fi
done

  test -z "$ac_cv_path_FREETYPE_XFT_CONFIG" && ac_cv_path_FREETYPE_XFT_CONFIG="none"
  ;;
esac
fi
FREETYPE_XFT_CONFIG=$ac_cv_path_FREETYPE_XFT_CONFIG

if test -n "$FREETYPE_XFT_CONFIG"; then
  echo "$as_me:17484: result: $FREETYPE_XFT_CONFIG" >&5
echo "${ECHO_T}$FREETYPE_XFT_CONFIG" >&6
else
  echo "$as_me:17487: result: no" >&5
echo "${ECHO_T}no" >&6
fi

	if test "$FREETYPE_XFT_CONFIG" != none; then
		FREETYPE_CONFIG=$FREETYPE_XFT_CONFIG
	else
		{ echo "$as_me:17494: WARNING: cannot find config script for Xft" >&5
echo "$as_me: WARNING: cannot find config script for Xft" >&2;}
	fi
	;;
esac

if test "$FREETYPE_CONFIG" != none ; then
	echo "$as_me:17501: checking for FreeType config" >&5
echo $ECHO_N "checking for FreeType config... $ECHO_C" >&6
	echo "$as_me:17503: result: $FREETYPE_CONFIG $FREETYPE_PARAMS" >&5
echo "${ECHO_T}$FREETYPE_CONFIG $FREETYPE_PARAMS" >&6

	if test "$cf_cv_x_freetype_incs" = no ; then
		echo "$as_me:17507: checking for $FREETYPE_CONFIG cflags" >&5
echo $ECHO_N "checking for $FREETYPE_CONFIG cflags... $ECHO_C" >&6
		cf_cv_x_freetype_incs="`$FREETYPE_CONFIG $FREETYPE_PARAMS --cflags 2>/dev/null`"
		echo "$as_me:17510: result: $cf_cv_x_freetype_incs" >&5
echo "${ECHO_T}$cf_cv_x_freetype_incs" >&6
	fi

	if test "$cf_cv_x_freetype_libs" = no ; then
		echo "$as_me:17515: checking for $FREETYPE_CONFIG libs" >&5
echo $ECHO_N "checking for $FREETYPE_CONFIG libs... $ECHO_C" >&6
		cf_cv_x_freetype_libs="$cf_extra_freetype_libs `$FREETYPE_CONFIG $FREETYPE_PARAMS --libs 2>/dev/null`"
		echo "$as_me:17518: result: $cf_cv_x_freetype_libs" >&5
echo "${ECHO_T}$cf_cv_x_freetype_libs" >&6
	fi
fi

if test "$cf_cv_x_freetype_incs" = no ; then
	cf_cv_x_freetype_incs=
fi

if test "$cf_cv_x_freetype_libs" = no ; then
	cf_cv_x_freetype_libs=-lXft
fi

echo "$as_me:17531: checking if we can link with FreeType libraries" >&5
echo $ECHO_N "checking if we can link with FreeType libraries... $ECHO_C" >&6

cf_save_LIBS="$LIBS"
cf_save_INCS="$CPPFLAGS"

cf_add_libs="$cf_cv_x_freetype_libs"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

CPPFLAGS="$CPPFLAGS $cf_cv_x_freetype_incs"

cat >conftest.$ac_ext <<_ACEOF
#line 17556 "configure"
#include "confdefs.h"

#include 
#include 
#include 
int
main (void)
{

	XftPattern  *pat = XftNameParse ("name");
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:17572: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:17575: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:17578: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:17581: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_found_freetype=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_found_freetype=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
echo "$as_me:17590: result: $cf_cv_found_freetype" >&5
echo "${ECHO_T}$cf_cv_found_freetype" >&6

LIBS="$cf_save_LIBS"
CPPFLAGS="$cf_save_INCS"

if test "$cf_cv_found_freetype" = yes ; then

cf_add_libs="$cf_cv_x_freetype_libs"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_cv_x_freetype_incs
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

cat >>confdefs.h <<\EOF
#define XRENDERFONT 1
EOF

for ac_func in \
	XftDrawCharSpec \
	XftDrawSetClip \
	XftDrawSetClipRectangles \

do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:17723: checking for $ac_func" >&5
echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
if eval "test \"\${$as_ac_var+set}\" = set"; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 17729 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
    which can conflict with char $ac_func (); below.  */
#include 
/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char $ac_func ();
char (*f) ();

int
main (void)
{
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
choke me
#else
f = $ac_func; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
#endif

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:17760: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:17763: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:17766: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:17769: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  eval "$as_ac_var=yes"
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
eval "$as_ac_var=no"
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:17779: result: `eval echo '${'$as_ac_var'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
if test `eval echo '${'$as_ac_var'}'` = yes; then
  cat >>confdefs.h <&5
echo "$as_me: WARNING: No libraries found for FreeType" >&2;}
	CPPFLAGS=`echo "$CPPFLAGS" | sed -e s/-DXRENDERFONT//`
fi

# FIXME: revisit this if needed

if test "$cf_cv_found_freetype" = yes ; then
echo "$as_me:17798: checking for usable Xft/fontconfig package" >&5
echo $ECHO_N "checking for usable Xft/fontconfig package... $ECHO_C" >&6
if test "${cf_cv_xft_compat+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

cat >conftest.$ac_ext <<_ACEOF
#line 17805 "configure"
#include "confdefs.h"

#include 

int
main (void)
{

	XftPattern *pat;
	XftPatternBuild(pat,
					XFT_FAMILY, XftTypeString, "mono",
					(void *) 0);

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:17824: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:17827: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:17830: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:17833: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_xft_compat=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_xft_compat=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext

fi
echo "$as_me:17844: result: $cf_cv_xft_compat" >&5
echo "${ECHO_T}$cf_cv_xft_compat" >&6

if test "$cf_cv_xft_compat" = no
then
	# workaround for broken ".pc" files used for Xft.
	case "$cf_cv_x_freetype_libs" in
	(*-lfontconfig*)
		;;
	(*)
		test -n "$verbose" && echo "	work around broken package" 1>&6

echo "${as_me:-configure}:17856: testing work around broken package ..." 1>&5

		cf_save_fontconfig="$LIBS"

if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists fontconfig; then
	test -n "$verbose" && echo "	found package fontconfig" 1>&6

echo "${as_me:-configure}:17863: testing found package fontconfig ..." 1>&5

	cf_pkgconfig_incs="`$PKG_CONFIG --cflags fontconfig 2>/dev/null`"
	cf_pkgconfig_libs="`$PKG_CONFIG --libs   fontconfig 2>/dev/null`"
	test -n "$verbose" && echo "	package fontconfig CFLAGS: $cf_pkgconfig_incs" 1>&6

echo "${as_me:-configure}:17869: testing package fontconfig CFLAGS: $cf_pkgconfig_incs ..." 1>&5

	test -n "$verbose" && echo "	package fontconfig LIBS: $cf_pkgconfig_libs" 1>&6

echo "${as_me:-configure}:17873: testing package fontconfig LIBS: $cf_pkgconfig_libs ..." 1>&5

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_pkgconfig_incs
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

cf_add_libs="$cf_pkgconfig_libs"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_pkgconfig_incs
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

				LIBS="$cf_save_fontconfig"

test -n "$verbose" && echo "	...before $LIBS" 1>&6

echo "${as_me:-configure}:18091: testing ...before $LIBS ..." 1>&5

LIBS=`echo "$LIBS" | sed -e "s/[ 	][ 	]*/ /g" -e "s%-lXft %-lXft $cf_pkgconfig_libs %" -e 's%  % %g'`
test -n "$verbose" && echo "	...after  $LIBS" 1>&6

echo "${as_me:-configure}:18096: testing ...after  $LIBS ..." 1>&5

else
	cf_pkgconfig_incs=
	cf_pkgconfig_libs=

test -n "$verbose" && echo "	...before $LIBS" 1>&6

echo "${as_me:-configure}:18104: testing ...before $LIBS ..." 1>&5

LIBS=`echo "$LIBS" | sed -e "s/[ 	][ 	]*/ /g" -e "s%-lXft %-lXft -lfontconfig %" -e 's%  % %g'`
test -n "$verbose" && echo "	...after  $LIBS" 1>&6

echo "${as_me:-configure}:18109: testing ...after  $LIBS ..." 1>&5

fi

		;;
	esac
fi
fi

else
	CPPFLAGS=`echo "$CPPFLAGS" | sed -e s/-DXRENDERFONT//`
fi

echo "$as_me:18122: checking if you want support for HP-style function keys" >&5
echo $ECHO_N "checking if you want support for HP-style function keys... $ECHO_C" >&6

# Check whether --enable-hp-fkeys or --disable-hp-fkeys was given.
if test "${enable_hp_fkeys+set}" = set; then
  enableval="$enable_hp_fkeys"
  test "$enableval" != yes && enableval=no
	if test "$enableval" != "no" ; then
    enable_hp_fkeys=yes
	else
		enable_hp_fkeys=no
	fi
else
  enableval=no
	enable_hp_fkeys=no

fi;
echo "$as_me:18139: result: $enable_hp_fkeys" >&5
echo "${ECHO_T}$enable_hp_fkeys" >&6
if test "$enable_hp_fkeys" = yes ; then

cat >>confdefs.h <<\EOF
#define OPT_HP_FUNC_KEYS 1
EOF

fi

echo "$as_me:18149: checking if you want support for SCO-style function keys" >&5
echo $ECHO_N "checking if you want support for SCO-style function keys... $ECHO_C" >&6

# Check whether --enable-sco-fkeys or --disable-sco-fkeys was given.
if test "${enable_sco_fkeys+set}" = set; then
  enableval="$enable_sco_fkeys"
  test "$enableval" != yes && enableval=no
	if test "$enableval" != "no" ; then
    enable_sco_fkeys=yes
	else
		enable_sco_fkeys=no
	fi
else
  enableval=no
	enable_sco_fkeys=no

fi;
echo "$as_me:18166: result: $enable_sco_fkeys" >&5
echo "${ECHO_T}$enable_sco_fkeys" >&6
if test "$enable_sco_fkeys" = yes ; then

cat >>confdefs.h <<\EOF
#define OPT_SCO_FUNC_KEYS 1
EOF

fi

echo "$as_me:18176: checking if you want support for Sun-style function keys" >&5
echo $ECHO_N "checking if you want support for Sun-style function keys... $ECHO_C" >&6

# Check whether --enable-sun-fkeys or --disable-sun-fkeys was given.
if test "${enable_sun_fkeys+set}" = set; then
  enableval="$enable_sun_fkeys"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_sun_fkeys=no
	else
		enable_sun_fkeys=yes
	fi
else
  enableval=yes
	enable_sun_fkeys=yes

fi;
echo "$as_me:18193: result: $enable_sun_fkeys" >&5
echo "${ECHO_T}$enable_sun_fkeys" >&6
if test "$enable_sun_fkeys" = no ; then

cat >>confdefs.h <<\EOF
#define OPT_SUN_FUNC_KEYS 0
EOF

fi

echo "$as_me:18203: checking if you want saved-lines stored as a FIFO" >&5
echo $ECHO_N "checking if you want saved-lines stored as a FIFO... $ECHO_C" >&6

# Check whether --enable-fifo-lines or --disable-fifo-lines was given.
if test "${enable_fifo_lines+set}" = set; then
  enableval="$enable_fifo_lines"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_fifo_lines=no
	else
		enable_fifo_lines=yes
	fi
else
  enableval=yes
	enable_fifo_lines=yes

fi;
echo "$as_me:18220: result: $enable_fifo_lines" >&5
echo "${ECHO_T}$enable_fifo_lines" >&6
if test "$enable_fifo_lines" = yes ; then

cat >>confdefs.h <<\EOF
#define OPT_FIFO_LINES 1
EOF

fi

echo "$as_me:18230: checking if you want support for internationalization" >&5
echo $ECHO_N "checking if you want support for internationalization... $ECHO_C" >&6

# Check whether --enable-i18n or --disable-i18n was given.
if test "${enable_i18n+set}" = set; then
  enableval="$enable_i18n"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_i18n=no
	else
		enable_i18n=yes
	fi
else
  enableval=yes
	enable_i18n=yes

fi;
echo "$as_me:18247: result: $enable_i18n" >&5
echo "${ECHO_T}$enable_i18n" >&6
if test "$enable_i18n" = no ; then

cat >>confdefs.h <<\EOF
#define OPT_I18N_SUPPORT 0
EOF

fi

echo "$as_me:18257: checking if you want support for initial-erase setup" >&5
echo $ECHO_N "checking if you want support for initial-erase setup... $ECHO_C" >&6

# Check whether --enable-initial-erase or --disable-initial-erase was given.
if test "${enable_initial_erase+set}" = set; then
  enableval="$enable_initial_erase"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_ie=no
	else
		enable_ie=yes
	fi
else
  enableval=yes
	enable_ie=yes

fi;
echo "$as_me:18274: result: $enable_ie" >&5
echo "${ECHO_T}$enable_ie" >&6
if test "$enable_ie" = no ; then

cat >>confdefs.h <<\EOF
#define OPT_INITIAL_ERASE 0
EOF

fi

echo "$as_me:18284: checking if you want support for input-method" >&5
echo $ECHO_N "checking if you want support for input-method... $ECHO_C" >&6

# Check whether --enable-input-method or --disable-input-method was given.
if test "${enable_input_method+set}" = set; then
  enableval="$enable_input_method"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_ximp=no
	else
		enable_ximp=yes
	fi
else
  enableval=yes
	enable_ximp=yes

fi;
echo "$as_me:18301: result: $enable_ximp" >&5
echo "${ECHO_T}$enable_ximp" >&6

echo "$as_me:18304: checking if X libraries support input-method" >&5
echo $ECHO_N "checking if X libraries support input-method... $ECHO_C" >&6
if test "${cf_cv_input_method+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

cat >conftest.$ac_ext <<_ACEOF
#line 18311 "configure"
#include "confdefs.h"

#include 
#include 
#include 
#include 
#include 
#include 

int
main (void)
{

{
	XIM xim;
	XIMStyles *xim_styles = 0;
	XIMStyle input_style;
	Widget w = 0;

	XSetLocaleModifiers("@im=none");
	xim = XOpenIM(XtDisplay(w), NULL, NULL, NULL);
	XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL);
	XCloseIM(xim);
	input_style = (XIMPreeditNothing | XIMStatusNothing);
}

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:18343: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:18346: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:18349: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:18352: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_input_method=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_input_method=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:18362: result: $cf_cv_input_method" >&5
echo "${ECHO_T}$cf_cv_input_method" >&6

test "$cf_cv_input_method" = no && enable_ximp=no
if test "$enable_ximp" = no ; then

cat >>confdefs.h <<\EOF
#define OPT_INPUT_METHOD 0
EOF

fi

echo "$as_me:18374: checking if you want support for load-vt-fonts" >&5
echo $ECHO_N "checking if you want support for load-vt-fonts... $ECHO_C" >&6

# Check whether --enable-load-vt-fonts or --disable-load-vt-fonts was given.
if test "${enable_load_vt_fonts+set}" = set; then
  enableval="$enable_load_vt_fonts"
  test "$enableval" != yes && enableval=no
	if test "$enableval" != "no" ; then
    enable_load_vt_fonts=yes
	else
		enable_load_vt_fonts=no
	fi
else
  enableval=no
	enable_load_vt_fonts=no

fi;
echo "$as_me:18391: result: $enable_load_vt_fonts" >&5
echo "${ECHO_T}$enable_load_vt_fonts" >&6
if test "$enable_load_vt_fonts" = yes ; then

cat >>confdefs.h <<\EOF
#define OPT_LOAD_VTFONTS 1
EOF

fi

echo "$as_me:18401: checking if you want support for logging" >&5
echo $ECHO_N "checking if you want support for logging... $ECHO_C" >&6

# Check whether --enable-logging or --disable-logging was given.
if test "${enable_logging+set}" = set; then
  enableval="$enable_logging"
  test "$enableval" != yes && enableval=no
	if test "$enableval" != "no" ; then
    enable_logging=yes
	else
		enable_logging=no
	fi
else
  enableval=no
	enable_logging=no

fi;
echo "$as_me:18418: result: $enable_logging" >&5
echo "${ECHO_T}$enable_logging" >&6
if test "$enable_logging" = yes ; then

cat >>confdefs.h <<\EOF
#define ALLOWLOGGING 1
EOF

	echo "$as_me:18426: checking if you want to allow logging via a pipe" >&5
echo $ECHO_N "checking if you want to allow logging via a pipe... $ECHO_C" >&6

# Check whether --enable-logfile-exec or --disable-logfile-exec was given.
if test "${enable_logfile_exec+set}" = set; then
  enableval="$enable_logfile_exec"
  test "$enableval" != yes && enableval=no
	if test "$enableval" != "no" ; then
    enable_log_exec=yes
	else
		enable_log_exec=no
	fi
else
  enableval=no
	enable_log_exec=no

fi;
	echo "$as_me:18443: result: $enable_log_exec" >&5
echo "${ECHO_T}$enable_log_exec" >&6
	if test "$enable_log_exec" = yes ; then

cat >>confdefs.h <<\EOF
#define ALLOWLOGFILEEXEC 1
EOF

	fi
fi

echo "$as_me:18454: checking if you want support for iconify/maximize translations" >&5
echo $ECHO_N "checking if you want support for iconify/maximize translations... $ECHO_C" >&6

# Check whether --enable-maximize or --disable-maximize was given.
if test "${enable_maximize+set}" = set; then
  enableval="$enable_maximize"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_maximize=no
	else
		enable_maximize=yes
	fi
else
  enableval=yes
	enable_maximize=yes

fi;
echo "$as_me:18471: result: $enable_maximize" >&5
echo "${ECHO_T}$enable_maximize" >&6
test "$enable_maximize" = no &&
cat >>confdefs.h <<\EOF
#define OPT_MAXIMIZE 0
EOF

echo "$as_me:18478: checking if you want NumLock to override keyboard tables" >&5
echo $ECHO_N "checking if you want NumLock to override keyboard tables... $ECHO_C" >&6

# Check whether --enable-num-lock or --disable-num-lock was given.
if test "${enable_num_lock+set}" = set; then
  enableval="$enable_num_lock"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_numlock=no
	else
		enable_numlock=yes
	fi
else
  enableval=yes
	enable_numlock=yes

fi;
echo "$as_me:18495: result: $enable_numlock" >&5
echo "${ECHO_T}$enable_numlock" >&6
test "$enable_numlock" = no &&
cat >>confdefs.h <<\EOF
#define OPT_NUM_LOCK 0
EOF

echo "$as_me:18502: checking if you want support for get/set of base64 selection data" >&5
echo $ECHO_N "checking if you want support for get/set of base64 selection data... $ECHO_C" >&6

# Check whether --enable-paste64 or --disable-paste64 was given.
if test "${enable_paste64+set}" = set; then
  enableval="$enable_paste64"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_paste64=no
	else
		enable_paste64=yes
	fi
else
  enableval=yes
	enable_paste64=yes

fi;
echo "$as_me:18519: result: $enable_paste64" >&5
echo "${ECHO_T}$enable_paste64" >&6
if test "$enable_paste64" = yes ; then

cat >>confdefs.h <<\EOF
#define OPT_PASTE64 1
EOF

else

cat >>confdefs.h <<\EOF
#define OPT_PASTE64 0
EOF

fi

echo "$as_me:18535: checking if you want support for pty-handshaking" >&5
echo $ECHO_N "checking if you want support for pty-handshaking... $ECHO_C" >&6

# Check whether --enable-pty-handshake or --disable-pty-handshake was given.
if test "${enable_pty_handshake+set}" = set; then
  enableval="$enable_pty_handshake"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_pty_handshake=no
	else
		enable_pty_handshake=yes
	fi
else
  enableval=yes
	enable_pty_handshake=yes

fi;
echo "$as_me:18552: result: $enable_pty_handshake" >&5
echo "${ECHO_T}$enable_pty_handshake" >&6
if test "$enable_pty_handshake" = yes ; then

cat >>confdefs.h <<\EOF
#define OPT_PTY_HANDSHAKE 1
EOF

else

cat >>confdefs.h <<\EOF
#define OPT_PTY_HANDSHAKE 0
EOF

fi

echo "$as_me:18568: checking if you want support for mouse in readline applications" >&5
echo $ECHO_N "checking if you want support for mouse in readline applications... $ECHO_C" >&6

# Check whether --enable-readline-mouse or --disable-readline-mouse was given.
if test "${enable_readline_mouse+set}" = set; then
  enableval="$enable_readline_mouse"
  test "$enableval" != yes && enableval=no
	if test "$enableval" != "no" ; then
    enable_readline_mouse=yes
	else
		enable_readline_mouse=no
	fi
else
  enableval=no
	enable_readline_mouse=no

fi;
echo "$as_me:18585: result: $enable_readline_mouse" >&5
echo "${ECHO_T}$enable_readline_mouse" >&6
if test "$enable_readline_mouse" = yes ; then

cat >>confdefs.h <<\EOF
#define OPT_READLINE 1
EOF

fi

echo "$as_me:18595: checking if you want support for regular-expression selections" >&5
echo $ECHO_N "checking if you want support for regular-expression selections... $ECHO_C" >&6

# Check whether --enable-regex or --disable-regex was given.
if test "${enable_regex+set}" = set; then
  enableval="$enable_regex"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_regex=no
	else
		enable_regex=yes
	fi
else
  enableval=yes
	enable_regex=yes

fi;
echo "$as_me:18612: result: $enable_regex" >&5
echo "${ECHO_T}$enable_regex" >&6
if test "$enable_regex" = yes ; then

echo "$as_me:18616: checking if you want to use PCRE for regular-expressions" >&5
echo $ECHO_N "checking if you want to use PCRE for regular-expressions... $ECHO_C" >&6

# Check whether --with-pcre or --without-pcre was given.
if test "${with_pcre+set}" = set; then
  withval="$with_pcre"

fi;
test -z "$with_pcre" && with_pcre=no
echo "$as_me:18625: result: $with_pcre" >&5
echo "${ECHO_T}$with_pcre" >&6

if test "$with_pcre" != no ; then

if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists libpcre; then
	test -n "$verbose" && echo "	found package libpcre" 1>&6

echo "${as_me:-configure}:18633: testing found package libpcre ..." 1>&5

	cf_pkgconfig_incs="`$PKG_CONFIG --cflags libpcre 2>/dev/null`"
	cf_pkgconfig_libs="`$PKG_CONFIG --libs   libpcre 2>/dev/null`"
	test -n "$verbose" && echo "	package libpcre CFLAGS: $cf_pkgconfig_incs" 1>&6

echo "${as_me:-configure}:18639: testing package libpcre CFLAGS: $cf_pkgconfig_incs ..." 1>&5

	test -n "$verbose" && echo "	package libpcre LIBS: $cf_pkgconfig_libs" 1>&6

echo "${as_me:-configure}:18643: testing package libpcre LIBS: $cf_pkgconfig_libs ..." 1>&5

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in $cf_pkgconfig_incs
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

cf_add_libs="$cf_pkgconfig_libs"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

	:
else
	cf_pkgconfig_incs=
	cf_pkgconfig_libs=

echo "$as_me:18764: checking for pcre_compile in -lpcre" >&5
echo $ECHO_N "checking for pcre_compile in -lpcre... $ECHO_C" >&6
if test "${ac_cv_lib_pcre_pcre_compile+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lpcre  $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line 18772 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char pcre_compile ();
int
main (void)
{
pcre_compile ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:18791: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:18794: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:18797: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:18800: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_lib_pcre_pcre_compile=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_lib_pcre_pcre_compile=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:18811: result: $ac_cv_lib_pcre_pcre_compile" >&5
echo "${ECHO_T}$ac_cv_lib_pcre_pcre_compile" >&6
if test $ac_cv_lib_pcre_pcre_compile = yes; then
  cat >>confdefs.h <&5
echo "$as_me: error: Cannot find PCRE library" >&2;}
   { (exit 1); exit 1; }; }
fi

fi

cat >>confdefs.h <<\EOF
#define HAVE_LIB_PCRE 1
EOF

		case $LIBS in
		(*pcreposix*)
			;;
		(*)
			echo "$as_me:18836: checking for pcreposix_regcomp in -lpcreposix" >&5
echo $ECHO_N "checking for pcreposix_regcomp in -lpcreposix... $ECHO_C" >&6
if test "${ac_cv_lib_pcreposix_pcreposix_regcomp+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lpcreposix  $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line 18844 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char pcreposix_regcomp ();
int
main (void)
{
pcreposix_regcomp ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:18863: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:18866: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:18869: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:18872: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_lib_pcreposix_pcreposix_regcomp=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_lib_pcreposix_pcreposix_regcomp=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:18883: result: $ac_cv_lib_pcreposix_pcreposix_regcomp" >&5
echo "${ECHO_T}$ac_cv_lib_pcreposix_pcreposix_regcomp" >&6
if test $ac_cv_lib_pcreposix_pcreposix_regcomp = yes; then

cat >>confdefs.h <<\EOF
#define HAVE_PCREPOSIX_H 1
EOF

cf_add_libs="-lpcreposix"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

else
  echo "$as_me:18908: checking for regcomp in -lpcreposix" >&5
echo $ECHO_N "checking for regcomp in -lpcreposix... $ECHO_C" >&6
if test "${ac_cv_lib_pcreposix_regcomp+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lpcreposix  $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line 18916 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char regcomp ();
int
main (void)
{
regcomp ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:18935: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:18938: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:18941: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:18944: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_lib_pcreposix_regcomp=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_lib_pcreposix_regcomp=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:18955: result: $ac_cv_lib_pcreposix_regcomp" >&5
echo "${ECHO_T}$ac_cv_lib_pcreposix_regcomp" >&6
if test $ac_cv_lib_pcreposix_regcomp = yes; then

cat >>confdefs.h <<\EOF
#define HAVE_PCREPOSIX_H 1
EOF

cf_add_libs="-lpcreposix"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

else
  { { echo "$as_me:18980: error: Cannot find PCRE POSIX library" >&5
echo "$as_me: error: Cannot find PCRE POSIX library" >&2;}
   { (exit 1); exit 1; }; }
fi

fi

			;;
		esac
fi

	if test "$with_pcre" = no ; then

cf_regex_func=no

cf_regex_libs="regex re"
case $host_os in
(mingw*)
	cf_regex_libs="gnurx $cf_regex_libs"
	;;
esac

echo "$as_me:19002: checking for regcomp" >&5
echo $ECHO_N "checking for regcomp... $ECHO_C" >&6
if test "${ac_cv_func_regcomp+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 19008 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
    which can conflict with char regcomp (); below.  */
#include 
/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char regcomp ();
char (*f) ();

int
main (void)
{
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_regcomp) || defined (__stub___regcomp)
choke me
#else
f = regcomp; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
#endif

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:19039: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:19042: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:19045: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:19048: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_func_regcomp=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_func_regcomp=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:19058: result: $ac_cv_func_regcomp" >&5
echo "${ECHO_T}$ac_cv_func_regcomp" >&6
if test $ac_cv_func_regcomp = yes; then
  cf_regex_func=regcomp
else

	for cf_regex_lib in $cf_regex_libs
	do
		as_ac_Lib=`echo "ac_cv_lib_$cf_regex_lib''_regcomp" | $as_tr_sh`
echo "$as_me:19067: checking for regcomp in -l$cf_regex_lib" >&5
echo $ECHO_N "checking for regcomp in -l$cf_regex_lib... $ECHO_C" >&6
if eval "test \"\${$as_ac_Lib+set}\" = set"; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-l$cf_regex_lib  $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line 19075 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char regcomp ();
int
main (void)
{
regcomp ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:19094: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:19097: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:19100: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:19103: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  eval "$as_ac_Lib=yes"
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
eval "$as_ac_Lib=no"
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:19114: result: `eval echo '${'$as_ac_Lib'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
if test `eval echo '${'$as_ac_Lib'}'` = yes; then

cf_add_libs="-l$cf_regex_lib"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

				cf_regex_func=regcomp
				break
fi

	done

fi

if test "$cf_regex_func" = no ; then
	echo "$as_me:19143: checking for compile" >&5
echo $ECHO_N "checking for compile... $ECHO_C" >&6
if test "${ac_cv_func_compile+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 19149 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
    which can conflict with char compile (); below.  */
#include 
/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char compile ();
char (*f) ();

int
main (void)
{
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_compile) || defined (__stub___compile)
choke me
#else
f = compile; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
#endif

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:19180: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:19183: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:19186: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:19189: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_func_compile=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_func_compile=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:19199: result: $ac_cv_func_compile" >&5
echo "${ECHO_T}$ac_cv_func_compile" >&6
if test $ac_cv_func_compile = yes; then
  cf_regex_func=compile
else

		echo "$as_me:19205: checking for compile in -lgen" >&5
echo $ECHO_N "checking for compile in -lgen... $ECHO_C" >&6
if test "${ac_cv_lib_gen_compile+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lgen  $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line 19213 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char compile ();
int
main (void)
{
compile ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:19232: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:19235: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:19238: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:19241: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_lib_gen_compile=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_lib_gen_compile=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:19252: result: $ac_cv_lib_gen_compile" >&5
echo "${ECHO_T}$ac_cv_lib_gen_compile" >&6
if test $ac_cv_lib_gen_compile = yes; then

cf_add_libs="-lgen"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

				cf_regex_func=compile
fi

fi

fi

if test "$cf_regex_func" = no ; then
	{ echo "$as_me:19280: WARNING: cannot find regular expression library" >&5
echo "$as_me: WARNING: cannot find regular expression library" >&2;}
fi

echo "$as_me:19284: checking for regular-expression headers" >&5
echo $ECHO_N "checking for regular-expression headers... $ECHO_C" >&6
if test "${cf_cv_regex_hdrs+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

cf_cv_regex_hdrs=no
case $cf_regex_func in
(compile)
	for cf_regex_hdr in regexp.h regexpr.h
	do
		cat >conftest.$ac_ext <<_ACEOF
#line 19296 "configure"
#include "confdefs.h"
#include <$cf_regex_hdr>
int
main (void)
{

			char *p = compile("", "", "", 0);
			int x = step("", "");

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:19311: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:19314: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:19317: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:19320: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then

			cf_cv_regex_hdrs=$cf_regex_hdr
			break

else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
	done
	;;
(*)
	for cf_regex_hdr in regex.h
	do
		cat >conftest.$ac_ext <<_ACEOF
#line 19337 "configure"
#include "confdefs.h"
#include 
#include <$cf_regex_hdr>
int
main (void)
{

			regex_t *p;
			int x = regcomp(p, "", 0);
			int y = regexec(p, "", 0, 0, 0);
			regfree(p);

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:19355: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:19358: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:19361: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:19364: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then

			cf_cv_regex_hdrs=$cf_regex_hdr
			break

else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
	done
	;;
esac

fi
echo "$as_me:19380: result: $cf_cv_regex_hdrs" >&5
echo "${ECHO_T}$cf_cv_regex_hdrs" >&6

case $cf_cv_regex_hdrs in
	(no)		{ echo "$as_me:19384: WARNING: no regular expression header found" >&5
echo "$as_me: WARNING: no regular expression header found" >&2;} ;;
	(regex.h)
cat >>confdefs.h <<\EOF
#define HAVE_REGEX_H_FUNCS 1
EOF
 ;;
	(regexp.h)
cat >>confdefs.h <<\EOF
#define HAVE_REGEXP_H_FUNCS 1
EOF
 ;;
	(regexpr.h)
cat >>confdefs.h <<\EOF
#define HAVE_REGEXPR_H_FUNCS 1
EOF
 ;;
esac

		if test "X$cf_cv_regex_hdrs" != "Xregex.h" ; then
			{ { echo "$as_me:19404: error: Only POSIX or PCRE regular expressions are supported" >&5
echo "$as_me: error: Only POSIX or PCRE regular expressions are supported" >&2;}
   { (exit 1); exit 1; }; }
		fi
	fi

cat >>confdefs.h <<\EOF
#define OPT_SELECT_REGEX 1
EOF

fi

echo "$as_me:19416: checking if you want support for right-scrollbar" >&5
echo $ECHO_N "checking if you want support for right-scrollbar... $ECHO_C" >&6

# Check whether --enable-rightbar or --disable-rightbar was given.
if test "${enable_rightbar+set}" = set; then
  enableval="$enable_rightbar"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_rightbar=no
	else
		enable_rightbar=yes
	fi
else
  enableval=yes
	enable_rightbar=yes

fi;
echo "$as_me:19433: result: $enable_rightbar" >&5
echo "${ECHO_T}$enable_rightbar" >&6
if test "$enable_rightbar" = yes ; then

cat >>confdefs.h <<\EOF
#define SCROLLBAR_RIGHT 1
EOF

fi

echo "$as_me:19443: checking if you want check for redundant name-change" >&5
echo $ECHO_N "checking if you want check for redundant name-change... $ECHO_C" >&6

# Check whether --enable-samename or --disable-samename was given.
if test "${enable_samename+set}" = set; then
  enableval="$enable_samename"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_samename=no
	else
		enable_samename=yes
	fi
else
  enableval=yes
	enable_samename=yes

fi;
echo "$as_me:19460: result: $enable_samename" >&5
echo "${ECHO_T}$enable_samename" >&6
test "$enable_samename" = no &&
cat >>confdefs.h <<\EOF
#define OPT_SAME_NAME 0
EOF

echo "$as_me:19467: checking if you want support for selection-actions" >&5
echo $ECHO_N "checking if you want support for selection-actions... $ECHO_C" >&6

# Check whether --enable-selection-ops or --disable-selection-ops was given.
if test "${enable_selection_ops+set}" = set; then
  enableval="$enable_selection_ops"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_selection_ops=no
	else
		enable_selection_ops=yes
	fi
else
  enableval=yes
	enable_selection_ops=yes

fi;
echo "$as_me:19484: result: $enable_selection_ops" >&5
echo "${ECHO_T}$enable_selection_ops" >&6
test "$enable_selection_ops" = no &&
cat >>confdefs.h <<\EOF
#define OPT_SELECTION_OPS 0
EOF

echo "$as_me:19491: checking if you want support for session management" >&5
echo $ECHO_N "checking if you want support for session management... $ECHO_C" >&6

# Check whether --enable-session-mgt or --disable-session-mgt was given.
if test "${enable_session_mgt+set}" = set; then
  enableval="$enable_session_mgt"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_session_mgt=no
	else
		enable_session_mgt=yes
	fi
else
  enableval=yes
	enable_session_mgt=yes

fi;
echo "$as_me:19508: result: $enable_session_mgt" >&5
echo "${ECHO_T}$enable_session_mgt" >&6
test "$enable_session_mgt" = no &&
cat >>confdefs.h <<\EOF
#define OPT_SESSION_MGT 0
EOF

echo "$as_me:19515: checking if you want to use termcap function-keys" >&5
echo $ECHO_N "checking if you want to use termcap function-keys... $ECHO_C" >&6

# Check whether --enable-tcap-fkeys or --disable-tcap-fkeys was given.
if test "${enable_tcap_fkeys+set}" = set; then
  enableval="$enable_tcap_fkeys"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_tcap_fkeys=no
	else
		enable_tcap_fkeys=yes
	fi
else
  enableval=yes
	enable_tcap_fkeys=yes

fi;
echo "$as_me:19532: result: $enable_tcap_fkeys" >&5
echo "${ECHO_T}$enable_tcap_fkeys" >&6
test "$enable_tcap_fkeys" = yes &&
cat >>confdefs.h <<\EOF
#define OPT_TCAP_FKEYS 1
EOF

echo "$as_me:19539: checking if you want to use termcap-query/report" >&5
echo $ECHO_N "checking if you want to use termcap-query/report... $ECHO_C" >&6

# Check whether --enable-tcap-query or --disable-tcap-query was given.
if test "${enable_tcap_query+set}" = set; then
  enableval="$enable_tcap_query"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_tcap_query=no
	else
		enable_tcap_query=yes
	fi
else
  enableval=yes
	enable_tcap_query=yes

fi;
echo "$as_me:19556: result: $enable_tcap_query" >&5
echo "${ECHO_T}$enable_tcap_query" >&6
test "$enable_tcap_query" = yes &&
cat >>confdefs.h <<\EOF
#define OPT_TCAP_QUERY 1
EOF

echo "$as_me:19563: checking if you want support for tek4014" >&5
echo $ECHO_N "checking if you want support for tek4014... $ECHO_C" >&6

# Check whether --enable-tek4014 or --disable-tek4014 was given.
if test "${enable_tek4014+set}" = set; then
  enableval="$enable_tek4014"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_tek4014=no
	else
		enable_tek4014=yes
	fi
else
  enableval=yes
	enable_tek4014=yes

fi;
echo "$as_me:19580: result: $enable_tek4014" >&5
echo "${ECHO_T}$enable_tek4014" >&6
if test "$enable_tek4014" = no ; then

cat >>confdefs.h <<\EOF
#define OPT_TEK4014 0
EOF

else
	EXTRAHDRS="$EXTRAHDRS Tekparse.h"
	EXTRASRCS="$EXTRASRCS TekPrsTbl.c Tekproc.c"
	EXTRAOBJS="$EXTRAOBJS TekPrsTbl.o Tekproc.o"
fi

echo "$as_me:19594: checking if you want pulldown menus with a toolbar" >&5
echo $ECHO_N "checking if you want pulldown menus with a toolbar... $ECHO_C" >&6

# Check whether --enable-toolbar or --disable-toolbar was given.
if test "${enable_toolbar+set}" = set; then
  enableval="$enable_toolbar"
  test "$enableval" != yes && enableval=no
	if test "$enableval" != "no" ; then
    enable_toolbar=yes
	else
		enable_toolbar=no
	fi
else
  enableval=no
	enable_toolbar=no

fi;
echo "$as_me:19611: result: $enable_toolbar" >&5
echo "${ECHO_T}$enable_toolbar" >&6
if test "$enable_toolbar" = yes ; then

cat >>confdefs.h <<\EOF
#define OPT_TOOLBAR 1
EOF

fi

echo "$as_me:19621: checking if you want VT52 emulation" >&5
echo $ECHO_N "checking if you want VT52 emulation... $ECHO_C" >&6

# Check whether --enable-vt52 or --disable-vt52 was given.
if test "${enable_vt52+set}" = set; then
  enableval="$enable_vt52"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_vt52=no
	else
		enable_vt52=yes
	fi
else
  enableval=yes
	enable_vt52=yes

fi;
echo "$as_me:19638: result: $enable_vt52" >&5
echo "${ECHO_T}$enable_vt52" >&6
test "$enable_vt52" = no &&
cat >>confdefs.h <<\EOF
#define OPT_VT52_MODE 0
EOF

echo "$as_me:19645: checking if you want wide-attribute support" >&5
echo $ECHO_N "checking if you want wide-attribute support... $ECHO_C" >&6

# Check whether --enable-wide-attrs or --disable-wide-attrs was given.
if test "${enable_wide_attrs+set}" = set; then
  enableval="$enable_wide_attrs"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_wattr=no
	else
		enable_wattr=yes
	fi
else
  enableval=yes
	enable_wattr=yes

fi;
echo "$as_me:19662: result: $enable_wattr" >&5
echo "${ECHO_T}$enable_wattr" >&6

echo "$as_me:19665: checking if you want wide-character support" >&5
echo $ECHO_N "checking if you want wide-character support... $ECHO_C" >&6

# Check whether --enable-wide-chars or --disable-wide-chars was given.
if test "${enable_wide_chars+set}" = set; then
  enableval="$enable_wide_chars"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_wchar=no
	else
		enable_wchar=yes
	fi
else
  enableval=yes
	enable_wchar=yes

fi;
echo "$as_me:19682: result: $enable_wchar" >&5
echo "${ECHO_T}$enable_wchar" >&6
test "$enable_wattr" = no &&
cat >>confdefs.h <<\EOF
#define OPT_WIDE_ATTRS 0
EOF

echo "$as_me:19689: checking if you want only 16-bit character support" >&5
echo $ECHO_N "checking if you want only 16-bit character support... $ECHO_C" >&6

# Check whether --enable-16bit-chars or --disable-16bit-chars was given.
if test "${enable_16bit_chars+set}" = set; then
  enableval="$enable_16bit_chars"
  test "$enableval" != yes && enableval=no
	if test "$enableval" != "no" ; then
    enable_16bit_chars=yes
	else
		enable_16bit_chars=no
	fi
else
  enableval=no
	enable_16bit_chars=no

fi;
echo "$as_me:19706: result: $enable_16bit_chars" >&5
echo "${ECHO_T}$enable_16bit_chars" >&6

if test "$enable_16bit_chars" = yes ; then

cat >>confdefs.h <<\EOF
#define OPT_WIDER_ICHAR 0
EOF

	enable_wchar=yes
fi

if test "$enable_wchar" = yes ; then

echo "$as_me:19720: checking if you want to use mini-luit/Latin9 built-in support" >&5
echo $ECHO_N "checking if you want to use mini-luit/Latin9 built-in support... $ECHO_C" >&6

# Check whether --enable-mini-luit or --disable-mini-luit was given.
if test "${enable_mini_luit+set}" = set; then
  enableval="$enable_mini_luit"
  test "$enableval" != yes && enableval=no
	if test "$enableval" != "no" ; then
    enable_mini_luit=yes
	else
		enable_mini_luit=no
	fi
else
  enableval=no
	enable_mini_luit=no

fi;
echo "$as_me:19737: result: $enable_mini_luit" >&5
echo "${ECHO_T}$enable_mini_luit" >&6
if test "$enable_mini_luit" = yes ; then

cat >>confdefs.h <<\EOF
#define OPT_MINI_LUIT 1
EOF

fi

echo "$as_me:19747: checking if you want to use luit" >&5
echo $ECHO_N "checking if you want to use luit... $ECHO_C" >&6

# Check whether --enable-luit or --disable-luit was given.
if test "${enable_luit+set}" = set; then
  enableval="$enable_luit"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_luit=no
	else
		enable_luit=yes
	fi
else
  enableval=yes
	enable_luit=yes

fi;
echo "$as_me:19764: result: $enable_luit" >&5
echo "${ECHO_T}$enable_luit" >&6
if test "$enable_luit" = yes ; then

cat >>confdefs.h <<\EOF
#define OPT_LUIT_PROG 1
EOF

test -z "$LUIT" && LUIT=xterm-filter
for ac_prog in $LUIT xterm-filter bluit luit
do
  # Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo "$as_me:19777: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_path_LUIT+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  case $LUIT in
  [\\/]* | ?:[\\/]*)
  ac_cv_path_LUIT="$LUIT" # Let the user override the test with a path.
  ;;
  *)
  ac_save_IFS=$IFS; IFS=$ac_path_separator
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
  IFS=$ac_save_IFS
  test -z "$ac_dir" && ac_dir=.
  if $as_executable_p "$ac_dir/$ac_word"; then
   ac_cv_path_LUIT="$ac_dir/$ac_word"
   echo "$as_me:19794: found $ac_dir/$ac_word" >&5
   break
fi
done

  ;;
esac
fi
LUIT=$ac_cv_path_LUIT

if test -n "$LUIT"; then
  echo "$as_me:19805: result: $LUIT" >&5
echo "${ECHO_T}$LUIT" >&6
else
  echo "$as_me:19808: result: no" >&5
echo "${ECHO_T}no" >&6
fi

  test -n "$LUIT" && break
done
test -n "$LUIT" || LUIT="$LUIT"

cf_path_prog=""
cf_path_args=""
IFS="${IFS:- 	}"; cf_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR"
for cf_temp in $ac_cv_path_LUIT
do
	if test -z "$cf_path_prog" ; then
		if test "$with_full_paths" = yes ; then

if test "x$prefix" != xNONE; then
	cf_path_syntax="$prefix"
else
	cf_path_syntax="$ac_default_prefix"
fi

case ".$cf_temp" in
(.\$\(*\)*|.\'*\'*)
	;;
(..|./*|.\\*)
	;;
(.[a-zA-Z]:[\\/]*) # OS/2 EMX
	;;
(.\${*prefix}*|.\${*dir}*)
	eval cf_temp="$cf_temp"
	case ".$cf_temp" in
	(.NONE/*)
		cf_temp=`echo $cf_temp | sed -e s%NONE%$cf_path_syntax%`
		;;
	esac
	;;
(.no|.NONE/*)
	cf_temp=`echo $cf_temp | sed -e s%NONE%$cf_path_syntax%`
	;;
(*)
	break
	;;
esac

			cf_path_prog="$cf_temp"
		else
			cf_path_prog="`basename $cf_temp`"
		fi
	elif test -z "$cf_path_args" ; then
		cf_path_args="$cf_temp"
	else
		cf_path_args="$cf_path_args $cf_temp"
	fi
done
IFS="$cf_save_ifs"

if test -n "$cf_path_prog" ; then

echo "${as_me:-configure}:19867: testing defining path for ${cf_path_prog} ..." 1>&5

cat >>confdefs.h <>confdefs.h <>confdefs.h <<\EOF
#define OPT_WIDE_CHARS 1
EOF

	EXTRAHDRS="$EXTRAHDRS charclass.h precompose.h wcwidth.h"
	EXTRASRCS="$EXTRASRCS charclass.c precompose.c wcwidth.c"
	EXTRAOBJS="$EXTRAOBJS charclass.o precompose.o wcwidth.o"
fi

echo "$as_me:19891: checking if you want dynamic-abbreviation support" >&5
echo $ECHO_N "checking if you want dynamic-abbreviation support... $ECHO_C" >&6

# Check whether --enable-dabbrev or --disable-dabbrev was given.
if test "${enable_dabbrev+set}" = set; then
  enableval="$enable_dabbrev"
  test "$enableval" != yes && enableval=no
	if test "$enableval" != "no" ; then
    enable_dabbrev=yes
	else
		enable_dabbrev=no
	fi
else
  enableval=no
	enable_dabbrev=no

fi;
echo "$as_me:19908: result: $enable_dabbrev" >&5
echo "${ECHO_T}$enable_dabbrev" >&6
if test "$enable_dabbrev" = yes ; then

cat >>confdefs.h <<\EOF
#define OPT_DABBREV 1
EOF

fi

echo "$as_me:19918: checking if you want DECterm Locator support" >&5
echo $ECHO_N "checking if you want DECterm Locator support... $ECHO_C" >&6

# Check whether --enable-dec-locator or --disable-dec-locator was given.
if test "${enable_dec_locator+set}" = set; then
  enableval="$enable_dec_locator"
  test "$enableval" != yes && enableval=no
	if test "$enableval" != "no" ; then
    enable_dec_locator=yes
	else
		enable_dec_locator=no
	fi
else
  enableval=no
	enable_dec_locator=no

fi;
echo "$as_me:19935: result: $enable_dec_locator" >&5
echo "${ECHO_T}$enable_dec_locator" >&6
if test "$enable_dec_locator" = yes ; then

cat >>confdefs.h <<\EOF
#define OPT_DEC_LOCATOR 1
EOF

fi

echo "$as_me:19945: checking if you want XHTML and SVG screen dump support" >&5
echo $ECHO_N "checking if you want XHTML and SVG screen dump support... $ECHO_C" >&6

# Check whether --enable-screen-dumps or --disable-screen-dumps was given.
if test "${enable_screen_dumps+set}" = set; then
  enableval="$enable_screen_dumps"
  test "$enableval" != yes && enableval=no
	if test "$enableval" != "no" ; then
    enable_screen_dumps=yes
	else
		enable_screen_dumps=no
	fi
else
  enableval=no
	enable_screen_dumps=no

fi;
echo "$as_me:19962: result: $enable_screen_dumps" >&5
echo "${ECHO_T}$enable_screen_dumps" >&6
if test "$enable_screen_dumps" = yes ; then

cat >>confdefs.h <<\EOF
#define OPT_SCREEN_DUMPS 1
EOF

	EXTRASRCS="$EXTRASRCS html.c svg.c"
	EXTRAOBJS="$EXTRAOBJS html.o svg.o"
fi

echo "$as_me:19974: checking if you want ReGIS graphics support" >&5
echo $ECHO_N "checking if you want ReGIS graphics support... $ECHO_C" >&6

# Check whether --enable-regis-graphics or --disable-regis-graphics was given.
if test "${enable_regis_graphics+set}" = set; then
  enableval="$enable_regis_graphics"
  test "$enableval" != yes && enableval=no
	if test "$enableval" != "no" ; then
    enable_regis_graphics=yes
	else
		enable_regis_graphics=no
	fi
else
  enableval=no
	enable_regis_graphics=no

fi;
echo "$as_me:19991: result: $enable_regis_graphics" >&5
echo "${ECHO_T}$enable_regis_graphics" >&6
if test "$enable_regis_graphics" = yes ; then

cat >>confdefs.h <<\EOF
#define OPT_REGIS_GRAPHICS 1
EOF

	EXTRAHDRS="$EXTRAHDRS graphics_regis.h"
	EXTRASRCS="$EXTRASRCS graphics_regis.c"
	EXTRAOBJS="$EXTRAOBJS graphics_regis.o"

echo "$as_me:20003: checking if -lm needed for math functions" >&5
echo $ECHO_N "checking if -lm needed for math functions... $ECHO_C" >&6
if test "${cf_cv_need_libm+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

	cat >conftest.$ac_ext <<_ACEOF
#line 20010 "configure"
#include "confdefs.h"

	#include 
	#include 
	#include 

int
main (void)
{
double x = rand(); printf("result = %g\n", sin(x))
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:20026: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:20029: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:20032: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:20035: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_cv_need_libm=no
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_cv_need_libm=yes
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:20045: result: $cf_cv_need_libm" >&5
echo "${ECHO_T}$cf_cv_need_libm" >&6
if test "$cf_cv_need_libm" = yes
then

cf_add_libs="-lm"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

fi

fi

echo "$as_me:20070: checking if you want sixel graphics support" >&5
echo $ECHO_N "checking if you want sixel graphics support... $ECHO_C" >&6

# Check whether --enable-sixel-graphics or --disable-sixel-graphics was given.
if test "${enable_sixel_graphics+set}" = set; then
  enableval="$enable_sixel_graphics"
  test "$enableval" != yes && enableval=no
	if test "$enableval" != "no" ; then
    enable_sixel_graphics=yes
	else
		enable_sixel_graphics=no
	fi
else
  enableval=no
	enable_sixel_graphics=no

fi;
echo "$as_me:20087: result: $enable_sixel_graphics" >&5
echo "${ECHO_T}$enable_sixel_graphics" >&6
if test "$enable_sixel_graphics" = yes ; then

cat >>confdefs.h <<\EOF
#define OPT_SIXEL_GRAPHICS 1
EOF

	EXTRAHDRS="$EXTRAHDRS graphics_sixel.h"
	EXTRASRCS="$EXTRASRCS graphics_sixel.c"
	EXTRAOBJS="$EXTRAOBJS graphics_sixel.o"
fi

if test "$enable_regis_graphics" = yes || test "$enable_sixel_graphics" = yes ; then

cat >>confdefs.h <<\EOF
#define OPT_GRAPHICS 1
EOF

	EXTRAHDRS="$EXTRAHDRS graphics.h"
	EXTRASRCS="$EXTRASRCS graphics.c"
	EXTRAOBJS="$EXTRAOBJS graphics.o"
fi

echo "$as_me:20111: checking if you want VT420 rectangle support" >&5
echo $ECHO_N "checking if you want VT420 rectangle support... $ECHO_C" >&6

# Check whether --enable-rectangles or --disable-rectangles was given.
if test "${enable_rectangles+set}" = set; then
  enableval="$enable_rectangles"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_rectangles=no
	else
		enable_rectangles=yes
	fi
else
  enableval=yes
	enable_rectangles=yes

fi;
echo "$as_me:20128: result: $enable_rectangles" >&5
echo "${ECHO_T}$enable_rectangles" >&6
if test "$enable_rectangles" = yes ; then

cat >>confdefs.h <<\EOF
#define OPT_DEC_RECTOPS 1
EOF

fi

echo "$as_me:20138: checking if you want -ziconbeep option" >&5
echo $ECHO_N "checking if you want -ziconbeep option... $ECHO_C" >&6

# Check whether --enable-ziconbeep or --disable-ziconbeep was given.
if test "${enable_ziconbeep+set}" = set; then
  enableval="$enable_ziconbeep"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    enable_ziconbeep=no
	else
		enable_ziconbeep=yes
	fi
else
  enableval=yes
	enable_ziconbeep=yes

fi;
echo "$as_me:20155: result: $enable_ziconbeep" >&5
echo "${ECHO_T}$enable_ziconbeep" >&6
test "$enable_ziconbeep" = no &&
cat >>confdefs.h <<\EOF
#define OPT_ZICONBEEP 0
EOF

###############################################################################

echo "$as_me:20164: checking if you want debugging traces" >&5
echo $ECHO_N "checking if you want debugging traces... $ECHO_C" >&6

# Check whether --enable-trace or --disable-trace was given.
if test "${enable_trace+set}" = set; then
  enableval="$enable_trace"
  test "$enableval" != yes && enableval=no
	if test "$enableval" != "no" ; then
    enable_trace=yes
	else
		enable_trace=no
	fi
else
  enableval=no
	enable_trace=no

fi;
echo "$as_me:20181: result: $enable_trace" >&5
echo "${ECHO_T}$enable_trace" >&6
if test "$enable_trace" = yes ; then

cat >>confdefs.h <<\EOF
#define OPT_TRACE 1
EOF

	EXTRASRCS="$EXTRASRCS trace.c"
	EXTRAOBJS="$EXTRAOBJS trace.o"
fi

echo "$as_me:20193: checking if you want to use dmalloc for testing" >&5
echo $ECHO_N "checking if you want to use dmalloc for testing... $ECHO_C" >&6

# Check whether --with-dmalloc or --without-dmalloc was given.
if test "${with_dmalloc+set}" = set; then
  withval="$with_dmalloc"

cat >>confdefs.h <&5
echo "${ECHO_T}${with_dmalloc:-no}" >&6

case .$with_cflags in
(.*-g*)
	case .$CFLAGS in
	(.*-g*)
		;;
	(*)

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in -g
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

		;;
	esac
	;;
esac

if test "$with_dmalloc" = yes ; then
	echo "$as_me:20324: checking for dmalloc.h" >&5
echo $ECHO_N "checking for dmalloc.h... $ECHO_C" >&6
if test "${ac_cv_header_dmalloc_h+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 20330 "configure"
#include "confdefs.h"
#include 
_ACEOF
if { (eval echo "$as_me:20334: \"$ac_cpp conftest.$ac_ext\"") >&5
  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
  ac_status=$?
  egrep -v '^ *\+' conftest.er1 >conftest.err
  rm -f conftest.er1
  cat conftest.err >&5
  echo "$as_me:20340: \$? = $ac_status" >&5
  (exit $ac_status); } >/dev/null; then
  if test -s conftest.err; then
    ac_cpp_err=$ac_c_preproc_warn_flag
  else
    ac_cpp_err=
  fi
else
  ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
  ac_cv_header_dmalloc_h=yes
else
  echo "$as_me: failed program was:" >&5
  cat conftest.$ac_ext >&5
  ac_cv_header_dmalloc_h=no
fi
rm -f conftest.err conftest.$ac_ext
fi
echo "$as_me:20359: result: $ac_cv_header_dmalloc_h" >&5
echo "${ECHO_T}$ac_cv_header_dmalloc_h" >&6
if test $ac_cv_header_dmalloc_h = yes; then

echo "$as_me:20363: checking for dmalloc_debug in -ldmalloc" >&5
echo $ECHO_N "checking for dmalloc_debug in -ldmalloc... $ECHO_C" >&6
if test "${ac_cv_lib_dmalloc_dmalloc_debug+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-ldmalloc  $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line 20371 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char dmalloc_debug ();
int
main (void)
{
dmalloc_debug ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:20390: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:20393: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:20396: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:20399: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_lib_dmalloc_dmalloc_debug=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_lib_dmalloc_dmalloc_debug=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:20410: result: $ac_cv_lib_dmalloc_dmalloc_debug" >&5
echo "${ECHO_T}$ac_cv_lib_dmalloc_dmalloc_debug" >&6
if test $ac_cv_lib_dmalloc_dmalloc_debug = yes; then
  cat >>confdefs.h <&5
echo $ECHO_N "checking if you want to use dbmalloc for testing... $ECHO_C" >&6

# Check whether --with-dbmalloc or --without-dbmalloc was given.
if test "${with_dbmalloc+set}" = set; then
  withval="$with_dbmalloc"

cat >>confdefs.h <&5
echo "${ECHO_T}${with_dbmalloc:-no}" >&6

case .$with_cflags in
(.*-g*)
	case .$CFLAGS in
	(.*-g*)
		;;
	(*)

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in -g
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

		;;
	esac
	;;
esac

if test "$with_dbmalloc" = yes ; then
	echo "$as_me:20556: checking for dbmalloc.h" >&5
echo $ECHO_N "checking for dbmalloc.h... $ECHO_C" >&6
if test "${ac_cv_header_dbmalloc_h+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 20562 "configure"
#include "confdefs.h"
#include 
_ACEOF
if { (eval echo "$as_me:20566: \"$ac_cpp conftest.$ac_ext\"") >&5
  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
  ac_status=$?
  egrep -v '^ *\+' conftest.er1 >conftest.err
  rm -f conftest.er1
  cat conftest.err >&5
  echo "$as_me:20572: \$? = $ac_status" >&5
  (exit $ac_status); } >/dev/null; then
  if test -s conftest.err; then
    ac_cpp_err=$ac_c_preproc_warn_flag
  else
    ac_cpp_err=
  fi
else
  ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
  ac_cv_header_dbmalloc_h=yes
else
  echo "$as_me: failed program was:" >&5
  cat conftest.$ac_ext >&5
  ac_cv_header_dbmalloc_h=no
fi
rm -f conftest.err conftest.$ac_ext
fi
echo "$as_me:20591: result: $ac_cv_header_dbmalloc_h" >&5
echo "${ECHO_T}$ac_cv_header_dbmalloc_h" >&6
if test $ac_cv_header_dbmalloc_h = yes; then

echo "$as_me:20595: checking for debug_malloc in -ldbmalloc" >&5
echo $ECHO_N "checking for debug_malloc in -ldbmalloc... $ECHO_C" >&6
if test "${ac_cv_lib_dbmalloc_debug_malloc+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-ldbmalloc  $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line 20603 "configure"
#include "confdefs.h"

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char debug_malloc ();
int
main (void)
{
debug_malloc ();
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:20622: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:20625: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:20628: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:20631: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  ac_cv_lib_dbmalloc_debug_malloc=yes
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_lib_dbmalloc_debug_malloc=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:20642: result: $ac_cv_lib_dbmalloc_debug_malloc" >&5
echo "${ECHO_T}$ac_cv_lib_dbmalloc_debug_malloc" >&6
if test $ac_cv_lib_dbmalloc_debug_malloc = yes; then
  cat >>confdefs.h <&5
echo $ECHO_N "checking if you want to use valgrind for testing... $ECHO_C" >&6

# Check whether --with-valgrind or --without-valgrind was given.
if test "${with_valgrind+set}" = set; then
  withval="$with_valgrind"

cat >>confdefs.h <&5
echo "${ECHO_T}${with_valgrind:-no}" >&6

case .$with_cflags in
(.*-g*)
	case .$CFLAGS in
	(.*-g*)
		;;
	(*)

cf_fix_cppflags=no
cf_new_cflags=
cf_new_cppflags=
cf_new_extra_cppflags=

for cf_add_cflags in -g
do
case $cf_fix_cppflags in
(no)
	case $cf_add_cflags in
	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
		case $cf_add_cflags in
		(-D*)
			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`

			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
				&& test -z "${cf_tst_cflags}" \
				&& cf_fix_cppflags=yes

			if test $cf_fix_cppflags = yes ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			elif test "${cf_tst_cflags}" = "\"'" ; then

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

				continue
			fi
			;;
		esac
		case "$CPPFLAGS" in
		(*$cf_add_cflags)
			;;
		(*)
			case $cf_add_cflags in
			(-D*)
				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`

CPPFLAGS=`echo "$CPPFLAGS" | \
	sed	-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?[ 	]/ /g' \
		-e 's/-[UD]'"$cf_tst_cppflags"'\(=[^ 	]*\)\?$//g'`

				;;
			esac

	test -n "$cf_new_cppflags" && cf_new_cppflags="$cf_new_cppflags "
	cf_new_cppflags="${cf_new_cppflags}$cf_add_cflags"

			;;
		esac
		;;
	(*)

	test -n "$cf_new_cflags" && cf_new_cflags="$cf_new_cflags "
	cf_new_cflags="${cf_new_cflags}$cf_add_cflags"

		;;
	esac
	;;
(yes)

	test -n "$cf_new_extra_cppflags" && cf_new_extra_cppflags="$cf_new_extra_cppflags "
	cf_new_extra_cppflags="${cf_new_extra_cppflags}$cf_add_cflags"

	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`

	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
		&& test -z "${cf_tst_cflags}" \
		&& cf_fix_cppflags=no
	;;
esac
done

if test -n "$cf_new_cflags" ; then

	test -n "$CFLAGS" && CFLAGS="$CFLAGS "
	CFLAGS="${CFLAGS}$cf_new_cflags"

fi

if test -n "$cf_new_cppflags" ; then

	test -n "$CPPFLAGS" && CPPFLAGS="$CPPFLAGS "
	CPPFLAGS="${CPPFLAGS}$cf_new_cppflags"

fi

if test -n "$cf_new_extra_cppflags" ; then

	test -n "$EXTRA_CPPFLAGS" && EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS "
	EXTRA_CPPFLAGS="${EXTRA_CPPFLAGS}$cf_new_extra_cppflags"

fi

		;;
	esac
	;;
esac

echo "$as_me:20787: checking if you want to perform memory-leak testing" >&5
echo $ECHO_N "checking if you want to perform memory-leak testing... $ECHO_C" >&6

# Check whether --enable-leaks or --disable-leaks was given.
if test "${enable_leaks+set}" = set; then
  enableval="$enable_leaks"
  if test "x$enableval" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi
else
  : ${with_no_leaks:=no}
fi;
echo "$as_me:20797: result: $with_no_leaks" >&5
echo "${ECHO_T}$with_no_leaks" >&6

if test "$with_no_leaks" = yes ; then

cat >>confdefs.h <<\EOF
#define NO_LEAKS 1
EOF

cat >>confdefs.h <<\EOF
#define YY_NO_LEAKS 1
EOF

fi

echo "$as_me:20812: checking if you want to see long compiling messages" >&5
echo $ECHO_N "checking if you want to see long compiling messages... $ECHO_C" >&6

# Check whether --enable-echo or --disable-echo was given.
if test "${enable_echo+set}" = set; then
  enableval="$enable_echo"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then

	ECHO_LT='--silent'
	ECHO_LD='@echo linking $@;'
	RULE_CC='@echo compiling $<'
	SHOW_CC='@echo compiling $@'
	ECHO_CC='@'

	else

	ECHO_LT=''
	ECHO_LD=''
	RULE_CC=''
	SHOW_CC=''
	ECHO_CC=''

	fi
else
  enableval=yes

	ECHO_LT=''
	ECHO_LD=''
	RULE_CC=''
	SHOW_CC=''
	ECHO_CC=''

fi;
echo "$as_me:20846: result: $enableval" >&5
echo "${ECHO_T}$enableval" >&6

echo "$as_me:20849: checking if you want magic cookie emulation" >&5
echo $ECHO_N "checking if you want magic cookie emulation... $ECHO_C" >&6

# Check whether --enable-xmc-glitch or --disable-xmc-glitch was given.
if test "${enable_xmc_glitch+set}" = set; then
  enableval="$enable_xmc_glitch"
  test "$enableval" != yes && enableval=no
	if test "$enableval" != "no" ; then
    enable_xmc=yes
	else
		enable_xmc=no
	fi
else
  enableval=no
	enable_xmc=no

fi;
echo "$as_me:20866: result: $enable_xmc" >&5
echo "${ECHO_T}$enable_xmc" >&6
if test "$enable_xmc" = yes ; then

cat >>confdefs.h <<\EOF
#define OPT_XMC_GLITCH 1
EOF

	EXTRASRCS="$EXTRASRCS testxmc.c"
	EXTRAOBJS="$EXTRAOBJS testxmc.o"
fi

for ac_func in tigetstr
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:20881: checking for $ac_func" >&5
echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
if eval "test \"\${$as_ac_var+set}\" = set"; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 20887 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
    which can conflict with char $ac_func (); below.  */
#include 
/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char $ac_func ();
char (*f) ();

int
main (void)
{
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
choke me
#else
f = $ac_func; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
#endif

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:20918: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:20921: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:20924: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:20927: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  eval "$as_ac_var=yes"
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
eval "$as_ac_var=no"
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:20937: result: `eval echo '${'$as_ac_var'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
if test `eval echo '${'$as_ac_var'}'` = yes; then
  cat >>confdefs.h <&5
echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
if eval "test \"\${$as_ac_var+set}\" = set"; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  cat >conftest.$ac_ext <<_ACEOF
#line 20958 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
    which can conflict with char $ac_func (); below.  */
#include 
/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char $ac_func ();
char (*f) ();

int
main (void)
{
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
choke me
#else
f = $ac_func; /* workaround for ICC 12.0.3 */ if (f == 0) return 1;
#endif

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:20989: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:20992: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:20995: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:20998: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  eval "$as_ac_var=yes"
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
eval "$as_ac_var=no"
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:21008: result: `eval echo '${'$as_ac_var'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
if test `eval echo '${'$as_ac_var'}'` = yes; then
  cat >>confdefs.h <&5
echo $ECHO_N "checking if you want to turn on gcc warnings... $ECHO_C" >&6

# Check whether --enable-warnings or --disable-warnings was given.
if test "${enable_warnings+set}" = set; then
  enableval="$enable_warnings"
  test "$enableval" != yes && enableval=no
	if test "$enableval" != "no" ; then
    with_warnings=yes
	else
		with_warnings=no
	fi
else
  enableval=no
	with_warnings=no

fi;
echo "$as_me:21038: result: $with_warnings" >&5
echo "${ECHO_T}$with_warnings" >&6
if test "$with_warnings" = yes
then

if test "$GCC" = yes
then
cat > conftest.i <&5
echo "$as_me: checking for $CC __attribute__ directives..." >&6;}
cat > conftest.$ac_ext <&5

		case $cf_attribute in
		(printf)
			cf_printf_attribute=yes
			cat >conftest.h <conftest.h <conftest.h <&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:21116: \$? = $ac_status" >&5
  (exit $ac_status); }; then
			test -n "$verbose" && echo "$as_me:21118: result: ... $cf_attribute" >&5
echo "${ECHO_T}... $cf_attribute" >&6
			cat conftest.h >>confdefs.h
			case $cf_attribute in
			(noreturn)

cat >>confdefs.h <>confdefs.h <<\EOF
#define GCC_PRINTF 1
EOF

				fi

cat >>confdefs.h <>confdefs.h <<\EOF
#define GCC_SCANF 1
EOF

				fi

cat >>confdefs.h <>confdefs.h <>confdefs.h
fi
rm -rf conftest*
fi

INTEL_COMPILER=no

if test "$GCC" = yes ; then
	case $host_os in
	(linux*|gnu*)
		echo "$as_me:21182: checking if this is really Intel C compiler" >&5
echo $ECHO_N "checking if this is really Intel C compiler... $ECHO_C" >&6
		cf_save_CFLAGS="$CFLAGS"
		CFLAGS="$CFLAGS -no-gcc"
		cat >conftest.$ac_ext <<_ACEOF
#line 21187 "configure"
#include "confdefs.h"

int
main (void)
{

#ifdef __INTEL_COMPILER
#else
make an error
#endif

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:21204: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:21207: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:21210: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:21213: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  INTEL_COMPILER=yes
cf_save_CFLAGS="$cf_save_CFLAGS -we147"

else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
fi
rm -f conftest.$ac_objext conftest.$ac_ext
		CFLAGS="$cf_save_CFLAGS"
		echo "$as_me:21224: result: $INTEL_COMPILER" >&5
echo "${ECHO_T}$INTEL_COMPILER" >&6
		;;
	esac
fi

CLANG_COMPILER=no

if test "$GCC" = yes ; then
	echo "$as_me:21233: checking if this is really Clang C compiler" >&5
echo $ECHO_N "checking if this is really Clang C compiler... $ECHO_C" >&6
	cf_save_CFLAGS="$CFLAGS"
	CFLAGS="$CFLAGS -Qunused-arguments"
	cat >conftest.$ac_ext <<_ACEOF
#line 21238 "configure"
#include "confdefs.h"

int
main (void)
{

#ifdef __clang__
#else
make an error
#endif

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:21255: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:21258: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest.$ac_objext'
  { (eval echo "$as_me:21261: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:21264: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  CLANG_COMPILER=yes
cf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments"

else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
fi
rm -f conftest.$ac_objext conftest.$ac_ext
	CFLAGS="$cf_save_CFLAGS"
	echo "$as_me:21275: result: $CLANG_COMPILER" >&5
echo "${ECHO_T}$CLANG_COMPILER" >&6
fi

cat > conftest.$ac_ext <&5
echo "$as_me: checking for $CC warning options..." >&6;}
	cf_save_CFLAGS="$CFLAGS"
	EXTRA_CFLAGS="-Wall"
	for cf_opt in \
		wd1419 \
		wd1683 \
		wd1684 \
		wd193 \
		wd593 \
		wd279 \
		wd810 \
		wd869 \
		wd981
	do
		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
		if { (eval echo "$as_me:21313: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:21316: \$? = $ac_status" >&5
  (exit $ac_status); }; then
			test -n "$verbose" && echo "$as_me:21318: result: ... -$cf_opt" >&5
echo "${ECHO_T}... -$cf_opt" >&6
			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
		fi
	done
	CFLAGS="$cf_save_CFLAGS"

elif test "$GCC" = yes
then
	{ echo "$as_me:21327: checking for $CC warning options..." >&5
echo "$as_me: checking for $CC warning options..." >&6;}
	cf_save_CFLAGS="$CFLAGS"
	EXTRA_CFLAGS=
	cf_warn_CONST=""
	test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
	cf_gcc_warnings="Wignored-qualifiers Wlogical-op Wvarargs"
	test "x$CLANG_COMPILER" = xyes && cf_gcc_warnings=
	for cf_opt in W Wall \
		Wbad-function-cast \
		Wcast-align \
		Wcast-qual \
		Wdeclaration-after-statement \
		Wextra \
		Winline \
		Wmissing-declarations \
		Wmissing-prototypes \
		Wnested-externs \
		Wpointer-arith \
		Wshadow \
		Wstrict-prototypes \
		Wundef $cf_gcc_warnings $cf_warn_CONST Wdeclaration-after-statement Wextra Wno-unknown-pragmas Wswitch-enum
	do
		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
		if { (eval echo "$as_me:21351: \"$ac_compile\"") >&5
  (eval $ac_compile) 2>&5
  ac_status=$?
  echo "$as_me:21354: \$? = $ac_status" >&5
  (exit $ac_status); }; then
			test -n "$verbose" && echo "$as_me:21356: result: ... -$cf_opt" >&5
echo "${ECHO_T}... -$cf_opt" >&6
			case $cf_opt in
			(Wcast-qual)
				CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
				;;
			(Winline)
				case $GCC_VERSION in
				([34].*)
					test -n "$verbose" && echo "	feature is broken in gcc $GCC_VERSION" 1>&6

echo "${as_me:-configure}:21367: testing feature is broken in gcc $GCC_VERSION ..." 1>&5

					continue;;
				esac
				;;
			(Wpointer-arith)
				case $GCC_VERSION in
				([12].*)
					test -n "$verbose" && echo "	feature is broken in gcc $GCC_VERSION" 1>&6

echo "${as_me:-configure}:21377: testing feature is broken in gcc $GCC_VERSION ..." 1>&5

					continue;;
				esac
				;;
			esac
			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
		fi
	done
	CFLAGS="$cf_save_CFLAGS"
fi
rm -rf conftest*

fi
fi

test "$disable_setuid" = yes &&
cat >>confdefs.h <<\EOF
#define DISABLE_SETUID 1
EOF

test "$disable_setgid" = yes &&
cat >>confdefs.h <<\EOF
#define DISABLE_SETGID 1
EOF

if test $disable_setuid = yes ; then
	MAY_SETUID="#"
	NOT_SETUID=
elif test $disable_setgid = yes ; then
	MAY_SETUID="#"
	NOT_SETUID=
else
	MAY_SETUID=
	NOT_SETUID="#"
fi

###	remove from CPPFLAGS the optional features we define in xtermcfg.h
###	or other conflicting symbols that may be defined via imake:
for cf_def in \
	__STDC__ \
	ALLOWLOGGING \
	ALLOWLOGFILEEXEC \
	OPT_LUIT_PROG \
	OPT_WIDE_CHARS \
	SCROLLBAR_RIGHT \
	USE_TTY_GROUP \
	USE_UTEMPTER \
	XRENDERFONT
do
	CPPFLAGS=`echo "$CPPFLAGS" | sed -e s/-D$cf_def//`
done

echo "$as_me:21430: checking if filesystem supports mixed-case filenames" >&5
echo $ECHO_N "checking if filesystem supports mixed-case filenames... $ECHO_C" >&6
if test "${cf_cv_mixedcase+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else

if test "$cross_compiling" = yes ; then
	case $target_alias in
	(*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*)
		cf_cv_mixedcase=no
		;;
	(*)
		cf_cv_mixedcase=yes
		;;
	esac
else
	rm -f conftest CONFTEST
	echo test >conftest
	if test -f CONFTEST ; then
		cf_cv_mixedcase=no
	else
		cf_cv_mixedcase=yes
	fi
	rm -f conftest CONFTEST
fi

fi
echo "$as_me:21457: result: $cf_cv_mixedcase" >&5
echo "${ECHO_T}$cf_cv_mixedcase" >&6
test "$cf_cv_mixedcase" = yes &&
cat >>confdefs.h <<\EOF
#define MIXEDCASE_FILENAMES 1
EOF

for ac_prog in exctags ctags
do
  # Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo "$as_me:21468: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_CTAGS+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  if test -n "$CTAGS"; then
  ac_cv_prog_CTAGS="$CTAGS" # Let the user override the test.
else
  ac_save_IFS=$IFS; IFS=$ac_path_separator
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
  IFS=$ac_save_IFS
  test -z "$ac_dir" && ac_dir=.
  $as_executable_p "$ac_dir/$ac_word" || continue
ac_cv_prog_CTAGS="$ac_prog"
echo "$as_me:21483: found $ac_dir/$ac_word" >&5
break
done

fi
fi
CTAGS=$ac_cv_prog_CTAGS
if test -n "$CTAGS"; then
  echo "$as_me:21491: result: $CTAGS" >&5
echo "${ECHO_T}$CTAGS" >&6
else
  echo "$as_me:21494: result: no" >&5
echo "${ECHO_T}no" >&6
fi

  test -n "$CTAGS" && break
done

for ac_prog in exetags etags
do
  # Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo "$as_me:21505: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_ETAGS+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  if test -n "$ETAGS"; then
  ac_cv_prog_ETAGS="$ETAGS" # Let the user override the test.
else
  ac_save_IFS=$IFS; IFS=$ac_path_separator
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
  IFS=$ac_save_IFS
  test -z "$ac_dir" && ac_dir=.
  $as_executable_p "$ac_dir/$ac_word" || continue
ac_cv_prog_ETAGS="$ac_prog"
echo "$as_me:21520: found $ac_dir/$ac_word" >&5
break
done

fi
fi
ETAGS=$ac_cv_prog_ETAGS
if test -n "$ETAGS"; then
  echo "$as_me:21528: result: $ETAGS" >&5
echo "${ECHO_T}$ETAGS" >&6
else
  echo "$as_me:21531: result: no" >&5
echo "${ECHO_T}no" >&6
fi

  test -n "$ETAGS" && break
done

# Extract the first word of "${CTAGS:-ctags}", so it can be a program name with args.
set dummy ${CTAGS:-ctags}; ac_word=$2
echo "$as_me:21540: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_MAKE_LOWER_TAGS+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  if test -n "$MAKE_LOWER_TAGS"; then
  ac_cv_prog_MAKE_LOWER_TAGS="$MAKE_LOWER_TAGS" # Let the user override the test.
else
  ac_save_IFS=$IFS; IFS=$ac_path_separator
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
  IFS=$ac_save_IFS
  test -z "$ac_dir" && ac_dir=.
  $as_executable_p "$ac_dir/$ac_word" || continue
ac_cv_prog_MAKE_LOWER_TAGS="yes"
echo "$as_me:21555: found $ac_dir/$ac_word" >&5
break
done

  test -z "$ac_cv_prog_MAKE_LOWER_TAGS" && ac_cv_prog_MAKE_LOWER_TAGS="no"
fi
fi
MAKE_LOWER_TAGS=$ac_cv_prog_MAKE_LOWER_TAGS
if test -n "$MAKE_LOWER_TAGS"; then
  echo "$as_me:21564: result: $MAKE_LOWER_TAGS" >&5
echo "${ECHO_T}$MAKE_LOWER_TAGS" >&6
else
  echo "$as_me:21567: result: no" >&5
echo "${ECHO_T}no" >&6
fi

if test "$cf_cv_mixedcase" = yes ; then
	# Extract the first word of "${ETAGS:-etags}", so it can be a program name with args.
set dummy ${ETAGS:-etags}; ac_word=$2
echo "$as_me:21574: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_MAKE_UPPER_TAGS+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  if test -n "$MAKE_UPPER_TAGS"; then
  ac_cv_prog_MAKE_UPPER_TAGS="$MAKE_UPPER_TAGS" # Let the user override the test.
else
  ac_save_IFS=$IFS; IFS=$ac_path_separator
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
  IFS=$ac_save_IFS
  test -z "$ac_dir" && ac_dir=.
  $as_executable_p "$ac_dir/$ac_word" || continue
ac_cv_prog_MAKE_UPPER_TAGS="yes"
echo "$as_me:21589: found $ac_dir/$ac_word" >&5
break
done

  test -z "$ac_cv_prog_MAKE_UPPER_TAGS" && ac_cv_prog_MAKE_UPPER_TAGS="no"
fi
fi
MAKE_UPPER_TAGS=$ac_cv_prog_MAKE_UPPER_TAGS
if test -n "$MAKE_UPPER_TAGS"; then
  echo "$as_me:21598: result: $MAKE_UPPER_TAGS" >&5
echo "${ECHO_T}$MAKE_UPPER_TAGS" >&6
else
  echo "$as_me:21601: result: no" >&5
echo "${ECHO_T}no" >&6
fi

else
	MAKE_UPPER_TAGS=no
fi

if test "$MAKE_UPPER_TAGS" = yes ; then
	MAKE_UPPER_TAGS=
else
	MAKE_UPPER_TAGS="#"
fi

if test "$MAKE_LOWER_TAGS" = yes ; then
	MAKE_LOWER_TAGS=
else
	MAKE_LOWER_TAGS="#"
fi

LD_RPATH_OPT=
echo "$as_me:21622: checking for an rpath option" >&5
echo $ECHO_N "checking for an rpath option... $ECHO_C" >&6
case $cf_cv_system_name in
(irix*)
	if test "$GCC" = yes; then
		LD_RPATH_OPT="-Wl,-rpath,"
	else
		LD_RPATH_OPT="-rpath "
	fi
	;;
(linux*|gnu*|k*bsd*-gnu|freebsd*)
	LD_RPATH_OPT="-Wl,-rpath,"
	;;
(openbsd[2-9].*|mirbsd*)
	LD_RPATH_OPT="-Wl,-rpath,"
	;;
(dragonfly*)
	LD_RPATH_OPT="-rpath "
	;;
(netbsd*)
	LD_RPATH_OPT="-Wl,-rpath,"
	;;
(osf*|mls+*)
	LD_RPATH_OPT="-rpath "
	;;
(solaris2*)
	LD_RPATH_OPT="-R"
	;;
(*)
	;;
esac
echo "$as_me:21653: result: $LD_RPATH_OPT" >&5
echo "${ECHO_T}$LD_RPATH_OPT" >&6

case "x$LD_RPATH_OPT" in
(x-R*)
	echo "$as_me:21658: checking if we need a space after rpath option" >&5
echo $ECHO_N "checking if we need a space after rpath option... $ECHO_C" >&6
	cf_save_LIBS="$LIBS"

cf_add_libs="${LD_RPATH_OPT}$libdir"
# Filter out duplicates - this happens with badly-designed ".pc" files...
for cf_add_1lib in $LIBS
do
	for cf_add_2lib in $cf_add_libs
	do
		if test "x$cf_add_1lib" = "x$cf_add_2lib"
		then
			cf_add_1lib=
			break
		fi
	done
	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
done
LIBS="$cf_add_libs"

	cat >conftest.$ac_ext <<_ACEOF
#line 21679 "configure"
#include "confdefs.h"

int
main (void)
{

  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:21691: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:21694: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:21697: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:21700: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_rpath_space=no
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
cf_rpath_space=yes
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
	LIBS="$cf_save_LIBS"
	echo "$as_me:21710: result: $cf_rpath_space" >&5
echo "${ECHO_T}$cf_rpath_space" >&6
	test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
	;;
esac

echo "$as_me:21716: checking if rpath-hack should be disabled" >&5
echo $ECHO_N "checking if rpath-hack should be disabled... $ECHO_C" >&6

# Check whether --enable-rpath-hack or --disable-rpath-hack was given.
if test "${enable_rpath_hack+set}" = set; then
  enableval="$enable_rpath_hack"
  test "$enableval" != no && enableval=yes
	if test "$enableval" != "yes" ; then
    cf_disable_rpath_hack=yes
	else
		cf_disable_rpath_hack=no
	fi
else
  enableval=yes
	cf_disable_rpath_hack=no

fi;
echo "$as_me:21733: result: $cf_disable_rpath_hack" >&5
echo "${ECHO_T}$cf_disable_rpath_hack" >&6
if test "$cf_disable_rpath_hack" = no ; then

echo "$as_me:21737: checking for updated LDFLAGS" >&5
echo $ECHO_N "checking for updated LDFLAGS... $ECHO_C" >&6
if test -n "$LD_RPATH_OPT" ; then
	echo "$as_me:21740: result: maybe" >&5
echo "${ECHO_T}maybe" >&6

	for ac_prog in ldd
do
  # Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo "$as_me:21747: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_cf_ldd_prog+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  if test -n "$cf_ldd_prog"; then
  ac_cv_prog_cf_ldd_prog="$cf_ldd_prog" # Let the user override the test.
else
  ac_save_IFS=$IFS; IFS=$ac_path_separator
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
  IFS=$ac_save_IFS
  test -z "$ac_dir" && ac_dir=.
  $as_executable_p "$ac_dir/$ac_word" || continue
ac_cv_prog_cf_ldd_prog="$ac_prog"
echo "$as_me:21762: found $ac_dir/$ac_word" >&5
break
done

fi
fi
cf_ldd_prog=$ac_cv_prog_cf_ldd_prog
if test -n "$cf_ldd_prog"; then
  echo "$as_me:21770: result: $cf_ldd_prog" >&5
echo "${ECHO_T}$cf_ldd_prog" >&6
else
  echo "$as_me:21773: result: no" >&5
echo "${ECHO_T}no" >&6
fi

  test -n "$cf_ldd_prog" && break
done
test -n "$cf_ldd_prog" || cf_ldd_prog="no"

	cf_rpath_list="/usr/lib /lib"
	if test "$cf_ldd_prog" != no
	then
		cf_rpath_oops=

cat >conftest.$ac_ext <<_ACEOF
#line 21787 "configure"
#include "confdefs.h"
#include 
int
main (void)
{
printf("Hello");
  ;
  return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:21799: \"$ac_link\"") >&5
  (eval $ac_link) 2>&5
  ac_status=$?
  echo "$as_me:21802: \$? = $ac_status" >&5
  (exit $ac_status); } &&
         { ac_try='test -s conftest$ac_exeext'
  { (eval echo "$as_me:21805: \"$ac_try\"") >&5
  (eval $ac_try) 2>&5
  ac_status=$?
  echo "$as_me:21808: \$? = $ac_status" >&5
  (exit $ac_status); }; }; then
  cf_rpath_oops=`$cf_ldd_prog conftest$ac_exeext | fgrep ' not found' | sed -e 's% =>.*$%%' |sort | uniq`
		 cf_rpath_list=`$cf_ldd_prog conftest$ac_exeext | fgrep / | sed -e 's%^.*[ 	]/%/%' -e 's%/[^/][^/]*$%%' |sort | uniq`
else
  echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext

		# If we passed the link-test, but get a "not found" on a given library,
		# this could be due to inept reconfiguration of gcc to make it only
		# partly honor /usr/local/lib (or whatever).  Sometimes this behavior
		# is intentional, e.g., installing gcc in /usr/bin and suppressing the
		# /usr/local libraries.
		if test -n "$cf_rpath_oops"
		then
			for cf_rpath_src in $cf_rpath_oops
			do
				for cf_rpath_dir in \
					/usr/local \
					/usr/pkg \
					/opt/sfw
				do
					if test -f $cf_rpath_dir/lib/$cf_rpath_src
					then
						test -n "$verbose" && echo "	...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src" 1>&6

echo "${as_me:-configure}:21836: testing ...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src ..." 1>&5

						LDFLAGS="$LDFLAGS -L$cf_rpath_dir/lib"
						break
					fi
				done
			done
		fi
	fi

	test -n "$verbose" && echo "	...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS" 1>&6

echo "${as_me:-configure}:21848: testing ...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS ..." 1>&5

test -n "$verbose" && echo "	...checking LDFLAGS $LDFLAGS" 1>&6

echo "${as_me:-configure}:21852: testing ...checking LDFLAGS $LDFLAGS ..." 1>&5

cf_rpath_dst=
for cf_rpath_src in $LDFLAGS
do
	case $cf_rpath_src in
	(-L*)

		# check if this refers to a directory which we will ignore
		cf_rpath_skip=no
		if test -n "$cf_rpath_list"
		then
			for cf_rpath_item in $cf_rpath_list
			do
				if test "x$cf_rpath_src" = "x-L$cf_rpath_item"
				then
					cf_rpath_skip=yes
					break
				fi
			done
		fi

		if test "$cf_rpath_skip" = no
		then
			# transform the option
			if test "$LD_RPATH_OPT" = "-R " ; then
				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%-R %"`
			else
				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%$LD_RPATH_OPT%"`
			fi

			# if we have not already added this, add it now
			cf_rpath_tst=`echo "$EXTRA_LDFLAGS" | sed -e "s%$cf_rpath_tmp %%"`
			if test "x$cf_rpath_tst" = "x$EXTRA_LDFLAGS"
			then
				test -n "$verbose" && echo "	...Filter $cf_rpath_src ->$cf_rpath_tmp" 1>&6

echo "${as_me:-configure}:21889: testing ...Filter $cf_rpath_src ->$cf_rpath_tmp ..." 1>&5

				EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
			fi
		fi
		;;
	esac
	cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
done
LDFLAGS=$cf_rpath_dst

test -n "$verbose" && echo "	...checked LDFLAGS $LDFLAGS" 1>&6

echo "${as_me:-configure}:21902: testing ...checked LDFLAGS $LDFLAGS ..." 1>&5

test -n "$verbose" && echo "	...checking LIBS $LIBS" 1>&6

echo "${as_me:-configure}:21906: testing ...checking LIBS $LIBS ..." 1>&5

cf_rpath_dst=
for cf_rpath_src in $LIBS
do
	case $cf_rpath_src in
	(-L*)

		# check if this refers to a directory which we will ignore
		cf_rpath_skip=no
		if test -n "$cf_rpath_list"
		then
			for cf_rpath_item in $cf_rpath_list
			do
				if test "x$cf_rpath_src" = "x-L$cf_rpath_item"
				then
					cf_rpath_skip=yes
					break
				fi
			done
		fi

		if test "$cf_rpath_skip" = no
		then
			# transform the option
			if test "$LD_RPATH_OPT" = "-R " ; then
				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%-R %"`
			else
				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%$LD_RPATH_OPT%"`
			fi

			# if we have not already added this, add it now
			cf_rpath_tst=`echo "$EXTRA_LDFLAGS" | sed -e "s%$cf_rpath_tmp %%"`
			if test "x$cf_rpath_tst" = "x$EXTRA_LDFLAGS"
			then
				test -n "$verbose" && echo "	...Filter $cf_rpath_src ->$cf_rpath_tmp" 1>&6

echo "${as_me:-configure}:21943: testing ...Filter $cf_rpath_src ->$cf_rpath_tmp ..." 1>&5

				EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
			fi
		fi
		;;
	esac
	cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
done
LIBS=$cf_rpath_dst

test -n "$verbose" && echo "	...checked LIBS $LIBS" 1>&6

echo "${as_me:-configure}:21956: testing ...checked LIBS $LIBS ..." 1>&5

	test -n "$verbose" && echo "	...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS" 1>&6

echo "${as_me:-configure}:21960: testing ...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS ..." 1>&5

else
	echo "$as_me:21963: result: no" >&5
echo "${ECHO_T}no" >&6
fi

fi

# Force plink.sh to not trim pcre's libraries, which have the same symbol
# names as the system regexp.
if test "$with_pcre" != no
then
	LIBS=`echo "$LIBS" | sed -e 's/-lpcre/-kpcre/g'`
fi

###	output xtermcfg.h, etc
ac_config_files="$ac_config_files Makefile df-install minstall:minstall.in"

cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
# scripts and configure runs, see configure's option --config-cache.
# It is not useful on other systems.  If it contains results you don't
# want to keep, you may remove or edit it.
#
# config.status only pays attention to the cache file if you give it
# the --recheck option to rerun configure.
#
# `ac_cv_env_foo' variables (set or unset) will be overriden when
# loading this file, other *unset* `ac_cv_foo' will be assigned the
# following values.

_ACEOF

# The following way of writing the cache mishandles newlines in values,
# but we know of no workaround that is simple, portable, and efficient.
# So, don't put newlines in cache variables' values.
# Ultrix sh set writes to stderr and can't be redirected directly,
# and sets the high bit in the cache file unless we assign to the vars.
{
  (set) 2>&1 |
    case `(ac_space=' '; set | grep ac_space) 2>&1` in
    *ac_space=\ *)
      # `set' does not quote correctly, so add quotes (double-quote
      # substitution turns \\\\ into \\, and sed turns \\ into \).
      sed -n \
        "s/'/'\\\\''/g;
    	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
      ;;
    *)
      # `set' quotes correctly as required by POSIX, so do not add quotes.
      sed -n \
        "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
      ;;
    esac;
} |
  sed '
     t clear
     : clear
     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
     t end
     /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
     : end' >>confcache
if cmp -s $cache_file confcache; then :; else
  if test -w $cache_file; then
    test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
    cat confcache >$cache_file
  else
    echo "not updating unwritable cache $cache_file"
  fi
fi
rm -f confcache

test "x$prefix" = xNONE && prefix=$ac_default_prefix
# Let make expand exec_prefix.
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'

# VPATH may cause trouble with some makes, so we remove $(srcdir),
# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
# trailing colons and then remove the whole line if VPATH becomes empty
# (actually we leave an empty line to preserve line numbers).
if test "x$srcdir" = x.; then
  ac_vpsub='/^[ 	]*VPATH[ 	]*=/{
s/:*\$(srcdir):*/:/;
s/:*\${srcdir}:*/:/;
s/:*@srcdir@:*/:/;
s/^\([^=]*=[ 	]*\):*/\1/;
s/:*$//;
s/^[^=]*=[ 	]*$//;
}'
fi

DEFS=-DHAVE_CONFIG_H

: ${CONFIG_STATUS=./config.status}
ac_clean_files_save=$ac_clean_files
ac_clean_files="$ac_clean_files $CONFIG_STATUS"
{ echo "$as_me:22058: creating $CONFIG_STATUS" >&5
echo "$as_me: creating $CONFIG_STATUS" >&6;}
cat >$CONFIG_STATUS <<_ACEOF
#! $SHELL
# Generated automatically by configure.
# Run this file to recreate the current configuration.
# Compiler output produced by configure, useful for debugging
# configure, is in config.log if it exists.

debug=false
SHELL=\${CONFIG_SHELL-$SHELL}
ac_cs_invocation="\$0 \$@"

_ACEOF

cat >>$CONFIG_STATUS <<\_ACEOF
# Be Bourne compatible
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
  emulate sh
  NULLCMD=:
elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
  set -o posix
fi

# Name of the executable.
as_me=`echo "$0" |sed 's,.*[\\/],,'`

if expr a : '\(a\)' >/dev/null 2>&1; then
  as_expr=expr
else
  as_expr=false
fi

rm -f conf$$ conf$$.exe conf$$.file
echo >conf$$.file
if ln -s conf$$.file conf$$ 2>/dev/null; then
  # We could just check for DJGPP; but this test a) works b) is more generic
  # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
  if test -f conf$$.exe; then
    # Don't use ln at all; we don't have any links
    as_ln_s='cp -p'
  else
    as_ln_s='ln -s'
  fi
elif ln conf$$.file conf$$ 2>/dev/null; then
  as_ln_s=ln
else
  as_ln_s='cp -p'
fi
rm -f conf$$ conf$$.exe conf$$.file

as_executable_p="test -f"

# Support unset when possible.
if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
  as_unset=unset
else
  as_unset=false
fi

# NLS nuisances.
$as_unset LANG || test "${LANG+set}" != set || { LANG=C; export LANG; }
$as_unset LC_ALL || test "${LC_ALL+set}" != set || { LC_ALL=C; export LC_ALL; }
$as_unset LC_TIME || test "${LC_TIME+set}" != set || { LC_TIME=C; export LC_TIME; }
$as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set || { LC_CTYPE=C; export LC_CTYPE; }
$as_unset LANGUAGE || test "${LANGUAGE+set}" != set || { LANGUAGE=C; export LANGUAGE; }
$as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set || { LC_COLLATE=C; export LC_COLLATE; }
$as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set || { LC_NUMERIC=C; export LC_NUMERIC; }
$as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set || { LC_MESSAGES=C; export LC_MESSAGES; }

# IFS
# We need space, tab and new line, in precisely that order.
as_nl='
'
IFS=" 	$as_nl"

# CDPATH.
$as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=:; export CDPATH; }

exec 6>&1

_ACEOF

# Files that config.status was made for.
if test -n "$ac_config_files"; then
  echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS
fi

if test -n "$ac_config_headers"; then
  echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS
fi

if test -n "$ac_config_links"; then
  echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS
fi

if test -n "$ac_config_commands"; then
  echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
fi

cat >>$CONFIG_STATUS <<\EOF

ac_cs_usage="\
\`$as_me' instantiates files from templates according to the
current configuration.

Usage: $0 [OPTIONS] [FILE]...

  -h, --help       print this help, then exit
  -V, --version    print version number, then exit
  -d, --debug      don't remove temporary files
      --recheck    update $as_me by reconfiguring in the same conditions
  --file=FILE[:TEMPLATE]
                   instantiate the configuration file FILE
  --header=FILE[:TEMPLATE]
                   instantiate the configuration header FILE

Configuration files:
$config_files

Configuration headers:
$config_headers

Report bugs to ."
EOF

cat >>$CONFIG_STATUS <>$CONFIG_STATUS <<\EOF
# If no file are specified by the user, then we need to provide default
# value.  By we need to know if files were specified by the user.
ac_need_defaults=:
while test $# != 0
do
  case $1 in
  --*=*)
    ac_option=`expr "x$1" : 'x\([^=]*\)='`
    ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
    shift
    set dummy "$ac_option" "$ac_optarg" ${1+"$@"}
    shift
    ;;
  -*);;
  *) # This is not an option, so the user has probably given explicit
     # arguments.
     ac_need_defaults=false;;
  esac

  case $1 in
  # Handling of the options.
EOF
cat >>$CONFIG_STATUS <>$CONFIG_STATUS <<\EOF
  --version | --vers* | -V )
    echo "$ac_cs_version"; exit 0 ;;
  --he | --h)
    # Conflict between --help and --header
    { { echo "$as_me:22231: error: ambiguous option: $1
Try \`$0 --help' for more information." >&5
echo "$as_me: error: ambiguous option: $1
Try \`$0 --help' for more information." >&2;}
   { (exit 1); exit 1; }; };;
  --help | --hel | -h )
    echo "$ac_cs_usage"; exit 0 ;;
  --debug | --d* | -d )
    debug=: ;;
  --file | --fil | --fi | --f )
    shift
    CONFIG_FILES="$CONFIG_FILES $1"
    ac_need_defaults=false;;
  --header | --heade | --head | --hea )
    shift
    CONFIG_HEADERS="$CONFIG_HEADERS $1"
    ac_need_defaults=false;;

  # This is an error.
  -*) { { echo "$as_me:22250: error: unrecognized option: $1
Try \`$0 --help' for more information." >&5
echo "$as_me: error: unrecognized option: $1
Try \`$0 --help' for more information." >&2;}
   { (exit 1); exit 1; }; } ;;

  *) ac_config_targets="$ac_config_targets $1" ;;

  esac
  shift
done

exec 5>>config.log
cat >&5 << _ACEOF

## ----------------------- ##
## Running config.status.  ##
## ----------------------- ##

This file was extended by $as_me 2.52.20170501, executed with
  CONFIG_FILES    = $CONFIG_FILES
  CONFIG_HEADERS  = $CONFIG_HEADERS
  CONFIG_LINKS    = $CONFIG_LINKS
  CONFIG_COMMANDS = $CONFIG_COMMANDS
  > $ac_cs_invocation
on `(hostname || uname -n) 2>/dev/null | sed 1q`

_ACEOF
EOF

cat >>$CONFIG_STATUS <<\EOF
for ac_config_target in $ac_config_targets
do
  case "$ac_config_target" in
  # Handling of arguments.
  "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
  "df-install" ) CONFIG_FILES="$CONFIG_FILES df-install" ;;
  "minstall" ) CONFIG_FILES="$CONFIG_FILES minstall:minstall.in" ;;
  "xtermcfg.h" ) CONFIG_HEADERS="$CONFIG_HEADERS xtermcfg.h:xtermcfg.hin" ;;
  *) { { echo "$as_me:22289: error: invalid argument: $ac_config_target" >&5
echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
   { (exit 1); exit 1; }; };;
  esac
done

# If the user did not use the arguments to specify the items to instantiate,
# then the envvar interface is used.  Set only those that are not.
# We use the long form for the default assignment because of an extremely
# bizarre bug on SunOS 4.1.3.
if $ac_need_defaults; then
  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
fi

# Create a temporary directory, and hook for its removal unless debugging.
$debug ||
{
  trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
  trap '{ (exit 1); exit 1; }' 1 2 13 15
}

# Create a (secure) tmp directory for tmp files.
: ${TMPDIR=/tmp}
{
  tmp=`(umask 077 && mktemp -d -q "$TMPDIR/csXXXXXX") 2>/dev/null` &&
  test -n "$tmp" && test -d "$tmp"
}  ||
{
  tmp=$TMPDIR/cs$$-$RANDOM
  (umask 077 && mkdir $tmp)
} ||
{
   echo "$me: cannot create a temporary directory in $TMPDIR" >&2
   { (exit 1); exit 1; }
}

EOF

cat >>$CONFIG_STATUS <\$tmp/subs.sed <<\\CEOF
s,@SHELL@,$SHELL,;t t
s,@exec_prefix@,$exec_prefix,;t t
s,@prefix@,$prefix,;t t
s,@program_transform_name@,$program_transform_name,;t t
s,@bindir@,$bindir,;t t
s,@sbindir@,$sbindir,;t t
s,@libexecdir@,$libexecdir,;t t
s,@datarootdir@,$datarootdir,;t t
s,@datadir@,$datadir,;t t
s,@sysconfdir@,$sysconfdir,;t t
s,@sharedstatedir@,$sharedstatedir,;t t
s,@localstatedir@,$localstatedir,;t t
s,@libdir@,$libdir,;t t
s,@includedir@,$includedir,;t t
s,@oldincludedir@,$oldincludedir,;t t
s,@infodir@,$infodir,;t t
s,@mandir@,$mandir,;t t
s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t
s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t
s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
s,@build_alias@,$build_alias,;t t
s,@host_alias@,$host_alias,;t t
s,@target_alias@,$target_alias,;t t
s,@ECHO_C@,$ECHO_C,;t t
s,@ECHO_N@,$ECHO_N,;t t
s,@ECHO_T@,$ECHO_T,;t t
s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
s,@DEFS@,$DEFS,;t t
s,@LIBS@,$LIBS,;t t
s,@build@,$build,;t t
s,@build_cpu@,$build_cpu,;t t
s,@build_vendor@,$build_vendor,;t t
s,@build_os@,$build_os,;t t
s,@host@,$host,;t t
s,@host_cpu@,$host_cpu,;t t
s,@host_vendor@,$host_vendor,;t t
s,@host_os@,$host_os,;t t
s,@CC@,$CC,;t t
s,@CFLAGS@,$CFLAGS,;t t
s,@LDFLAGS@,$LDFLAGS,;t t
s,@CPPFLAGS@,$CPPFLAGS,;t t
s,@ac_ct_CC@,$ac_ct_CC,;t t
s,@EXEEXT@,$EXEEXT,;t t
s,@OBJEXT@,$OBJEXT,;t t
s,@EXTRA_CPPFLAGS@,$EXTRA_CPPFLAGS,;t t
s,@CPP@,$CPP,;t t
s,@AWK@,$AWK,;t t
s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t
s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t
s,@INSTALL_DATA@,$INSTALL_DATA,;t t
s,@LN_S@,$LN_S,;t t
s,@LINT@,$LINT,;t t
s,@LINT_OPTS@,$LINT_OPTS,;t t
s,@APP_CLASS@,$APP_CLASS,;t t
s,@APPSDIR@,$APPSDIR,;t t
s,@no_appsdir@,$no_appsdir,;t t
s,@ICON_NAME@,$ICON_NAME,;t t
s,@ICON_SYMLINK@,$ICON_SYMLINK,;t t
s,@PIXMAPDIR@,$PIXMAPDIR,;t t
s,@no_pixmapdir@,$no_pixmapdir,;t t
s,@ICONDIR@,$ICONDIR,;t t
s,@no_icondir@,$no_icondir,;t t
s,@ICON_FORMAT@,$ICON_FORMAT,;t t
s,@ICON_THEME@,$ICON_THEME,;t t
s,@ICON_LIST@,$ICON_LIST,;t t
s,@desktop_utils@,$desktop_utils,;t t
s,@DESKTOP_FLAGS@,$DESKTOP_FLAGS,;t t
s,@DESKTOP_CATEGORY@,$DESKTOP_CATEGORY,;t t
s,@XTERM_PATH@,$XTERM_PATH,;t t
s,@XTERM_SYMLINK@,$XTERM_SYMLINK,;t t
s,@SINSTALL_OPTS@,$SINSTALL_OPTS,;t t
s,@X_CFLAGS@,$X_CFLAGS,;t t
s,@X_PRE_LIBS@,$X_PRE_LIBS,;t t
s,@X_LIBS@,$X_LIBS,;t t
s,@X_EXTRA_LIBS@,$X_EXTRA_LIBS,;t t
s,@PKG_CONFIG@,$PKG_CONFIG,;t t
s,@ac_pt_PKG_CONFIG@,$ac_pt_PKG_CONFIG,;t t
s,@ICON_SUFFIX@,$ICON_SUFFIX,;t t
s,@IMAKE@,$IMAKE,;t t
s,@IMAKE_CFLAGS@,$IMAKE_CFLAGS,;t t
s,@IMAKE_LOADFLAGS@,$IMAKE_LOADFLAGS,;t t
s,@GROFF_PATH@,$GROFF_PATH,;t t
s,@NROFF_PATH@,$NROFF_PATH,;t t
s,@GROFF_NOTE@,$GROFF_NOTE,;t t
s,@NROFF_NOTE@,$NROFF_NOTE,;t t
s,@cf_man2html@,$cf_man2html,;t t
s,@MAN2HTML_NOTE@,$MAN2HTML_NOTE,;t t
s,@MAN2HTML_PATH@,$MAN2HTML_PATH,;t t
s,@MAN2HTML_TEMP@,$MAN2HTML_TEMP,;t t
s,@default_termid@,$default_termid,;t t
s,@default_TERM@,$default_TERM,;t t
s,@backarrow_is_bs@,$backarrow_is_bs,;t t
s,@backarrow_is_erase@,$backarrow_is_erase,;t t
s,@delete_is_del@,$delete_is_del,;t t
s,@initial_erase@,$initial_erase,;t t
s,@alt_sends_esc@,$alt_sends_esc,;t t
s,@meta_sends_esc@,$meta_sends_esc,;t t
s,@cf_tic_prog@,$cf_tic_prog,;t t
s,@no_ticprog@,$no_ticprog,;t t
s,@TERMINFO_DIR@,$TERMINFO_DIR,;t t
s,@SET_TERMINFO@,$SET_TERMINFO,;t t
s,@FREETYPE_CONFIG@,$FREETYPE_CONFIG,;t t
s,@FREETYPE_OLD_CONFIG@,$FREETYPE_OLD_CONFIG,;t t
s,@FREETYPE_XFT_CONFIG@,$FREETYPE_XFT_CONFIG,;t t
s,@HAVE_TYPE_FCCHAR32@,$HAVE_TYPE_FCCHAR32,;t t
s,@HAVE_TYPE_XFTCHARSPEC@,$HAVE_TYPE_XFTCHARSPEC,;t t
s,@LUIT@,$LUIT,;t t
s,@ECHO_LT@,$ECHO_LT,;t t
s,@ECHO_LD@,$ECHO_LD,;t t
s,@RULE_CC@,$RULE_CC,;t t
s,@SHOW_CC@,$SHOW_CC,;t t
s,@ECHO_CC@,$ECHO_CC,;t t
s,@EXTRA_CFLAGS@,$EXTRA_CFLAGS,;t t
s,@CHARPROC_DEPS@,$CHARPROC_DEPS,;t t
s,@EXTRAHDRS@,$EXTRAHDRS,;t t
s,@EXTRASRCS@,$EXTRASRCS,;t t
s,@EXTRAOBJS@,$EXTRAOBJS,;t t
s,@MAY_SETUID@,$MAY_SETUID,;t t
s,@NOT_SETUID@,$NOT_SETUID,;t t
s,@CTAGS@,$CTAGS,;t t
s,@ETAGS@,$ETAGS,;t t
s,@MAKE_LOWER_TAGS@,$MAKE_LOWER_TAGS,;t t
s,@MAKE_UPPER_TAGS@,$MAKE_UPPER_TAGS,;t t
s,@cf_ldd_prog@,$cf_ldd_prog,;t t
s,@EXTRA_LDFLAGS@,$EXTRA_LDFLAGS,;t t
CEOF

EOF

  cat >>$CONFIG_STATUS <<\EOF
  # Split the substitutions into bite-sized pieces for seds with
  # small command number limits, like on Digital OSF/1 and HP-UX.
  ac_max_sed_lines=48
  ac_sed_frag=1 # Number of current file.
  ac_beg=1 # First line for current file.
  ac_end=$ac_max_sed_lines # Line after last line for current file.
  ac_more_lines=:
  ac_sed_cmds=
  while $ac_more_lines; do
    if test $ac_beg -gt 1; then
      sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
    else
      sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
    fi
    if test ! -s $tmp/subs.frag; then
      ac_more_lines=false
    else
      # The purpose of the label and of the branching condition is to
      # speed up the sed processing (if there are no `@' at all, there
      # is no need to browse any of the substitutions).
      # These are the two extra sed commands mentioned above.
      (echo ':t
  /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
      # It is possible to make a multiline substitution using escaped newlines.
      # Ensure that we do not split the substitution between script fragments.
      ac_BEG=$ac_end
      ac_END=`expr $ac_end + $ac_max_sed_lines`
      sed "1,${ac_BEG}d; ${ac_END}p; q" $tmp/subs.sed >$tmp/subs.next
      if test -s $tmp/subs.next; then
        grep '^s,@[^@,][^@,]*@,.*\\$' $tmp/subs.next >$tmp/subs.edit
        if test ! -s $tmp/subs.edit; then
          grep "^s,@[^@,][^@,]*@,.*,;t t$" $tmp/subs.next >$tmp/subs.edit
          if test ! -s $tmp/subs.edit; then
            if test $ac_beg -gt 1; then
              ac_end=`expr $ac_end - 1`
              continue
            fi
          fi
        fi
      fi

      if test -z "$ac_sed_cmds"; then
        ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
      else
        ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
      fi
      ac_sed_frag=`expr $ac_sed_frag + 1`
      ac_beg=$ac_end
      ac_end=`expr $ac_end + $ac_max_sed_lines`
    fi
  done
  if test -z "$ac_sed_cmds"; then
    ac_sed_cmds=cat
  fi
fi # test -n "$CONFIG_FILES"

EOF
cat >>$CONFIG_STATUS <<\EOF
for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
  # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
  case $ac_file in
  - | *:- | *:-:* ) # input from stdin
        cat >$tmp/stdin
        ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
        ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
  *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
        ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
  * )   ac_file_in=$ac_file.in ;;
  esac

  # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
  ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
         X"$ac_file" : 'X\(//\)[^/]' \| \
         X"$ac_file" : 'X\(//\)$' \| \
         X"$ac_file" : 'X\(/\)' \| \
         .     : '\(.\)' 2>/dev/null ||
echo X"$ac_file" |
    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
  	  /^X\(\/\/\)$/{ s//\1/; q; }
  	  /^X\(\/\).*/{ s//\1/; q; }
  	  s/.*/./; q'`
  if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
    { case "$ac_dir" in
  [\\/]* | ?:[\\/]* ) as_incr_dir=;;
  *)                      as_incr_dir=.;;
esac
as_dummy="$ac_dir"
for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do
  case $as_mkdir_dir in
    # Skip DOS drivespec
    ?:) as_incr_dir=$as_mkdir_dir ;;
    *)
      as_incr_dir=$as_incr_dir/$as_mkdir_dir
      test -d "$as_incr_dir" || mkdir "$as_incr_dir"
    ;;
  esac
done; }

    ac_dir_suffix="/`echo $ac_dir|sed 's,^\./,,'`"
    # A "../" for each directory in $ac_dir_suffix.
    ac_dots=`echo "$ac_dir_suffix" | sed 's,/[^/]*,../,g'`
  else
    ac_dir_suffix= ac_dots=
  fi

  case $srcdir in
  .)  ac_srcdir=.
      if test -z "$ac_dots"; then
         ac_top_srcdir=.
      else
         ac_top_srcdir=`echo $ac_dots | sed 's,/$,,'`
      fi ;;
  [\\/]* | ?:[\\/]* )
      ac_srcdir=$srcdir$ac_dir_suffix;
      ac_top_srcdir=$srcdir ;;
  *) # Relative path.
    ac_srcdir=$ac_dots$srcdir$ac_dir_suffix
    ac_top_srcdir=$ac_dots$srcdir ;;
  esac

  case $INSTALL in
  [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
  *) ac_INSTALL=$ac_dots$INSTALL ;;
  esac

  if test x"$ac_file" != x-; then
    { echo "$as_me:22599: creating $ac_file" >&5
echo "$as_me: creating $ac_file" >&6;}
    rm -f "$ac_file"
  fi
  # Let's still pretend it is `configure' which instantiates (i.e., don't
  # use $as_me), people would be surprised to read:
  #    /* config.h.  Generated automatically by config.status.  */
  configure_input="Generated automatically from `echo $ac_file_in |
                                                 sed 's,.*/,,'` by configure."

  # First look for the input files in the build tree, otherwise in the
  # src tree.
  ac_file_inputs=`IFS=:
    for f in $ac_file_in; do
      case $f in
      -) echo $tmp/stdin ;;
      [\\/$]*)
         # Absolute (can't be DOS-style, as IFS=:)
         test -f "$f" || { { echo "$as_me:22617: error: cannot find input file: $f" >&5
echo "$as_me: error: cannot find input file: $f" >&2;}
   { (exit 1); exit 1; }; }
         echo $f;;
      *) # Relative
         if test -f "$f"; then
           # Build tree
           echo $f
         elif test -f "$srcdir/$f"; then
           # Source tree
           echo $srcdir/$f
         else
           # /dev/null tree
           { { echo "$as_me:22630: error: cannot find input file: $f" >&5
echo "$as_me: error: cannot find input file: $f" >&2;}
   { (exit 1); exit 1; }; }
         fi;;
      esac
    done` || { (exit 1); exit 1; }
EOF
cat >>$CONFIG_STATUS <<\EOF
  ac_warn_datarootdir=no
  if test x"$ac_file" != x-; then
    for ac_item in $ac_file_inputs
    do
      ac_seen=`grep '@\(datadir\|mandir\|infodir\)@' $ac_item`
      if test -n "$ac_seen"; then
        ac_used=`grep '@datarootdir@' $ac_item`
        if test -z "$ac_used"; then
          { echo "$as_me:22646: WARNING: datarootdir was used implicitly but not set:
$ac_seen" >&5
echo "$as_me: WARNING: datarootdir was used implicitly but not set:
$ac_seen" >&2;}
          ac_warn_datarootdir=yes
        fi
      fi
      ac_seen=`grep '${datarootdir}' $ac_item`
      if test -n "$ac_seen"; then
        { echo "$as_me:22655: WARNING: datarootdir was used explicitly but not set:
$ac_seen" >&5
echo "$as_me: WARNING: datarootdir was used explicitly but not set:
$ac_seen" >&2;}
        ac_warn_datarootdir=yes
      fi
    done
  fi

if test "x$ac_warn_datarootdir" = xyes; then
  ac_sed_cmds="$ac_sed_cmds | sed -e 's,@datarootdir@,\${prefix}/share,g' -e 's,\${datarootdir},\${prefix}/share,g'"
fi

EOF
cat >>$CONFIG_STATUS <>$CONFIG_STATUS <<\EOF
:t
/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
s,@configure_input@,$configure_input,;t t
s,@srcdir@,$ac_srcdir,;t t
s,@top_srcdir@,$ac_top_srcdir,;t t
s,@INSTALL@,$ac_INSTALL,;t t
" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
  rm -f $tmp/stdin
  if test x"$ac_file" != x-; then
    cp $tmp/out $ac_file

    for ac_name in prefix exec_prefix datarootdir
    do
        ac_seen=`fgrep -n '${'$ac_name'[:=].*}' $ac_file`
        if test -n "$ac_seen"; then
            ac_init=`egrep '[ 	]*'$ac_name'[ 	]*=' $ac_file`
            if test -z "$ac_init"; then
              ac_seen=`echo "$ac_seen" |sed -e 's,^,'$ac_file':,'`
              { echo "$as_me:22692: WARNING: Variable $ac_name is used but was not set:
$ac_seen" >&5
echo "$as_me: WARNING: Variable $ac_name is used but was not set:
$ac_seen" >&2;}
            fi
        fi
    done
    egrep -n '@[a-z_][a-z_0-9]+@' $ac_file >$tmp/out
    egrep -n '@[A-Z_][A-Z_0-9]+@' $ac_file >>$tmp/out
    if test -s $tmp/out; then
      ac_seen=`sed -e 's,^,'$ac_file':,' < $tmp/out`
      { echo "$as_me:22703: WARNING: Some variables may not be substituted:
$ac_seen" >&5
echo "$as_me: WARNING: Some variables may not be substituted:
$ac_seen" >&2;}
    fi
  else
    cat $tmp/out
  fi
  rm -f $tmp/out

done
EOF
cat >>$CONFIG_STATUS <<\EOF

#
# CONFIG_HEADER section.
#

# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
# NAME is the cpp macro being defined and VALUE is the value it is being given.
#
# ac_d sets the value in "#define NAME VALUE" lines.
ac_dA='s,^\([ 	]*\)#\([ 	]*define[ 	][ 	]*\)'
ac_dB='[ 	].*$,\1#\2'
ac_dC=' '
ac_dD=',;t'
# ac_i turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
ac_iA='s,^\([ 	]*\)#\([ 	]*\)undef\([ 	][ 	]*\)'
ac_iB='\([ 	]\),\1#\2define\3'
ac_iC=' '
ac_iD='\4,;t'
# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
ac_uA='s,^\([ 	]*\)#\([ 	]*\)undef\([ 	][ 	]*\)'
ac_uB='$,\1#\2define\3'
ac_uC=' '
ac_uD=',;t'

for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
  # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
  case $ac_file in
  - | *:- | *:-:* ) # input from stdin
        cat >$tmp/stdin
        ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
        ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
  *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
        ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
  * )   ac_file_in=$ac_file.in ;;
  esac

  test x"$ac_file" != x- && { echo "$as_me:22752: creating $ac_file" >&5
echo "$as_me: creating $ac_file" >&6;}

  # First look for the input files in the build tree, otherwise in the
  # src tree.
  ac_file_inputs=`IFS=:
    for f in $ac_file_in; do
      case $f in
      -) echo $tmp/stdin ;;
      [\\/$]*)
         # Absolute (can't be DOS-style, as IFS=:)
         test -f "$f" || { { echo "$as_me:22763: error: cannot find input file: $f" >&5
echo "$as_me: error: cannot find input file: $f" >&2;}
   { (exit 1); exit 1; }; }
         echo $f;;
      *) # Relative
         if test -f "$f"; then
           # Build tree
           echo $f
         elif test -f "$srcdir/$f"; then
           # Source tree
           echo $srcdir/$f
         else
           # /dev/null tree
           { { echo "$as_me:22776: error: cannot find input file: $f" >&5
echo "$as_me: error: cannot find input file: $f" >&2;}
   { (exit 1); exit 1; }; }
         fi;;
      esac
    done` || { (exit 1); exit 1; }
  # Remove the trailing spaces.
  sed 's/[ 	]*$//' $ac_file_inputs >$tmp/in

EOF

# Transform confdefs.h into two sed scripts, `conftest.defines' and
# `conftest.undefs', that substitutes the proper values into
# config.h.in to produce config.h.  The first handles `#define'
# templates, and the second `#undef' templates.
# And first: Protect against being on the right side of a sed subst in
# config.status.  Protect against being in an unquoted here document
# in config.status.
rm -f conftest.defines conftest.undefs
# Using a here document instead of a string reduces the quoting nightmare.
# Putting comments in sed scripts is not portable.
#
# `end' is used to avoid that the second main sed command (meant for
# 0-ary CPP macros) applies to n-ary macro definitions.
# See the Autoconf documentation for `clear'.
cat >confdef2sed.sed <<\EOF
s/[\\&,]/\\&/g
s,[\\$`],\\&,g
t clear
: clear
s,^[ 	]*#[ 	]*define[ 	][ 	]*\(\([^ 	(][^ 	(]*\)([^)]*)\)[ 	]*\(.*\)$,${ac_dA}\2${ac_dB}\1${ac_dC}\3${ac_dD},gp
t end
s,^[ 	]*#[ 	]*define[ 	][ 	]*\([^ 	][^ 	]*\)[ 	]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp
: end
EOF
# If some macros were called several times there might be several times
# the same #defines, which is useless.  Nevertheless, we may not want to
# sort them, since we want the *last* AC-DEFINE to be honored.
uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines
sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs
sed 's/ac_d/ac_i/g' conftest.defines >>conftest.undefs
rm -f confdef2sed.sed

# This sed command replaces #undef with comments.  This is necessary, for
# example, in the case of _POSIX_SOURCE, which is predefined and required
# on some systems where configure will not decide to define it.
cat >>conftest.undefs <<\EOF
s,^[ 	]*#[ 	]*undef[ 	][ 	]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
EOF

# Break up conftest.defines because some shells have a limit on the size
# of here documents, and old seds have small limits too (100 cmds).
echo '  # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS
echo '  if egrep "^[ 	]*#[ 	]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS
echo '  # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS
echo '  :' >>$CONFIG_STATUS
rm -f conftest.tail
while grep . conftest.defines >/dev/null
do
  # Write a limited-size here document to $tmp/defines.sed.
  echo '  cat >$tmp/defines.sed <>$CONFIG_STATUS
  # Speed up: don't consider the non `#define' lines.
  echo '/^[ 	]*#[ 	]*define/!b' >>$CONFIG_STATUS
  # Work around the forget-to-reset-the-flag bug.
  echo 't clr' >>$CONFIG_STATUS
  echo ': clr' >>$CONFIG_STATUS
  sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS
  echo 'CEOF
  sed -f $tmp/defines.sed $tmp/in >$tmp/out
  rm -f $tmp/in
  mv $tmp/out $tmp/in
' >>$CONFIG_STATUS
  sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail
  rm -f conftest.defines
  mv conftest.tail conftest.defines
done
rm -f conftest.defines
echo '  fi # egrep' >>$CONFIG_STATUS
echo >>$CONFIG_STATUS

# Break up conftest.undefs because some shells have a limit on the size
# of here documents, and old seds have small limits too (100 cmds).
echo '  # Handle all the #undef templates' >>$CONFIG_STATUS
rm -f conftest.tail
while grep . conftest.undefs >/dev/null
do
  # Write a limited-size here document to $tmp/undefs.sed.
  echo '  cat >$tmp/undefs.sed <>$CONFIG_STATUS
  # Speed up: don't consider the non `#undef'
  echo '/^[ 	]*#[ 	]*undef/!b' >>$CONFIG_STATUS
  # Work around the forget-to-reset-the-flag bug.
  echo 't clr' >>$CONFIG_STATUS
  echo ': clr' >>$CONFIG_STATUS
  sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS
  echo 'CEOF
  sed -f $tmp/undefs.sed $tmp/in >$tmp/out
  rm -f $tmp/in
  mv $tmp/out $tmp/in
' >>$CONFIG_STATUS
  sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail
  rm -f conftest.undefs
  mv conftest.tail conftest.undefs
done
rm -f conftest.undefs

cat >>$CONFIG_STATUS <<\EOF
  # Let's still pretend it is `configure' which instantiates (i.e., don't
  # use $as_me), people would be surprised to read:
  #    /* config.h.  Generated automatically by config.status.  */
  if test x"$ac_file" = x-; then
    echo "/* Generated automatically by configure.  */" >$tmp/config.h
  else
    echo "/* $ac_file.  Generated automatically by configure.  */" >$tmp/config.h
  fi
  cat $tmp/in >>$tmp/config.h
  rm -f $tmp/in
  if test x"$ac_file" != x-; then
    if cmp -s $ac_file $tmp/config.h 2>/dev/null; then
      { echo "$as_me:22894: $ac_file is unchanged" >&5
echo "$as_me: $ac_file is unchanged" >&6;}
    else
      ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
         X"$ac_file" : 'X\(//\)[^/]' \| \
         X"$ac_file" : 'X\(//\)$' \| \
         X"$ac_file" : 'X\(/\)' \| \
         .     : '\(.\)' 2>/dev/null ||
echo X"$ac_file" |
    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
  	  /^X\(\/\/\)$/{ s//\1/; q; }
  	  /^X\(\/\).*/{ s//\1/; q; }
  	  s/.*/./; q'`
      if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
        { case "$ac_dir" in
  [\\/]* | ?:[\\/]* ) as_incr_dir=;;
  *)                      as_incr_dir=.;;
esac
as_dummy="$ac_dir"
for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do
  case $as_mkdir_dir in
    # Skip DOS drivespec
    ?:) as_incr_dir=$as_mkdir_dir ;;
    *)
      as_incr_dir=$as_incr_dir/$as_mkdir_dir
      test -d "$as_incr_dir" || mkdir "$as_incr_dir"
    ;;
  esac
done; }

      fi
      rm -f $ac_file
      mv $tmp/config.h $ac_file
    fi
  else
    cat $tmp/config.h
    rm -f $tmp/config.h
  fi
done
EOF

cat >>$CONFIG_STATUS <<\EOF

{ (exit 0); exit 0; }
EOF
chmod +x $CONFIG_STATUS
ac_clean_files=$ac_clean_files_save

# configure is writing to config.log, and then calls config.status.
# config.status does its own redirection, appending to config.log.
# Unfortunately, on DOS this fails, as config.log is still kept open
# by configure, so config.status won't be able to write to it; its
# output is simply discarded.  So we exec the FD to /dev/null,
# effectively closing config.log, so it can be properly (re)opened and
# appended to by config.status.  When coming back to configure, we
# need to make the FD available again.
if test "$no_create" != yes; then
  ac_cs_success=:
  exec 5>/dev/null
  $SHELL $CONFIG_STATUS || ac_cs_success=false
  exec 5>>config.log
  # Use ||, not &&, to avoid exiting from the if with $? = 1, which
  # would make configure fail if this is the last instruction.
  $ac_cs_success || { (exit 1); exit 1; }
fi

xterm-330/resize.c0000644000175100001440000003702613113502720012706 0ustar  tomusers/* $XTermId: resize.c,v 1.139 2017/05/31 08:58:56 tom Exp $ */

/*
 * Copyright 2003-2015,2017 by Thomas E. Dickey
 *
 *                         All Rights Reserved
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name(s) of the above copyright
 * holders shall not be used in advertising or otherwise to promote the
 * sale, use or other dealings in this Software without prior written
 * authorization.
 *
 *
 * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
 *
 *                         All Rights Reserved
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose and without fee is hereby granted,
 * provided that the above copyright notice appear in all copies and that
 * both that copyright notice and this permission notice appear in
 * supporting documentation, and that the name of Digital Equipment
 * Corporation not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written prior permission.
 *
 *
 * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */

/* resize.c */

#include 
#include 

#include 
#include 
#include 
#include 
#include 

#ifndef USE_TERMINFO		/* avoid conflict with configure script */
#if defined(__QNX__) || defined(__SCO__) || defined(linux) || defined(__OpenBSD__) || defined(__UNIXWARE__)
#define USE_TERMINFO
#endif
#endif

#if defined(__QNX__)
#include 
#endif

/*
 * Some OS's may want to use both, like SCO for example.  We catch here anyone
 * who hasn't decided what they want.
 */
#if !defined(USE_TERMCAP) && !defined(USE_TERMINFO)
#define USE_TERMINFO
#endif

#include 
#include 

#ifdef USE_IGNORE_RC
int ignore_unused;
#endif

#ifdef __MVS__
#define ESCAPE(string) "\047" string
#else
#define ESCAPE(string) "\033" string
#endif

#define	EMULATIONS	2
#define	SUN		1
#define	VT100		0

#define	TIMEOUT		10

#define	SHELL_UNKNOWN	0
#define	SHELL_C		1
#define	SHELL_BOURNE	2
/* *INDENT-OFF* */
static struct {
    const char *name;
    int type;
} shell_list[] = {
    { "csh",	SHELL_C },	/* vanilla cshell */
    { "jcsh",   SHELL_C },
    { "tcsh",   SHELL_C },
    { "sh",	SHELL_BOURNE }, /* vanilla Bourne shell */
    { "ash",    SHELL_BOURNE },
    { "bash",	SHELL_BOURNE }, /* GNU Bourne again shell */
    { "dash",	SHELL_BOURNE },
    { "jsh",    SHELL_BOURNE },
    { "ksh",	SHELL_BOURNE }, /* Korn shell (from AT&T toolchest) */
    { "ksh-i",	SHELL_BOURNE }, /* another name for Korn shell */
    { "ksh93",	SHELL_BOURNE }, /* Korn shell */
    { "mksh",   SHELL_BOURNE },
    { "pdksh",  SHELL_BOURNE },
    { "zsh",    SHELL_BOURNE },
    { NULL,	SHELL_BOURNE }	/* default (same as xterm's) */
};
/* *INDENT-ON* */

static const char *const emuname[EMULATIONS] =
{
    "VT100",
    "Sun",
};
static char *myname;
static int shell_type = SHELL_UNKNOWN;
static const char *const getsize[EMULATIONS] =
{
    ESCAPE("7") ESCAPE("[r") ESCAPE("[9999;9999H") ESCAPE("[6n"),
    ESCAPE("[18t"),
};
#if defined(USE_STRUCT_WINSIZE)
static const char *const getwsize[EMULATIONS] =
{				/* size in pixels */
    0,
    ESCAPE("[14t"),
};
#endif /* USE_STRUCT_WINSIZE */
static const char *const restore[EMULATIONS] =
{
    ESCAPE("8"),
    0,
};
static const char *const setsize[EMULATIONS] =
{
    0,
    ESCAPE("[8;%s;%st"),
};

#ifdef USE_ANY_SYSV_TERMIO
static struct termio tioorig;
#elif defined(USE_TERMIOS)
static struct termios tioorig;
#else
static struct sgttyb sgorig;
#endif /* USE_ANY_SYSV_TERMIO/USE_TERMIOS */

static const char *const size[EMULATIONS] =
{
    ESCAPE("[%d;%dR"),
    ESCAPE("[8;%d;%dt"),
};
static const char sunname[] = "sunsize";
static int tty;
static FILE *ttyfp;

#if defined(USE_STRUCT_WINSIZE)
static const char *wsize[EMULATIONS] =
{
    0,
    ESCAPE("[4;%hd;%hdt"),
};
#endif /* USE_STRUCT_WINSIZE */

static void
failed(const char *s)
{
    int save = errno;
    IGNORE_RC(write(2, myname, strlen(myname)));
    IGNORE_RC(write(2, ": ", (size_t) 2));
    errno = save;
    perror(s);
    exit(EXIT_FAILURE);
}

/* ARGSUSED */
static void
onintr(int sig GCC_UNUSED)
{
#ifdef USE_ANY_SYSV_TERMIO
    (void) ioctl(tty, TCSETAW, &tioorig);
#elif defined(USE_TERMIOS)
    (void) tcsetattr(tty, TCSADRAIN, &tioorig);
#else /* not USE_TERMIOS */
    (void) ioctl(tty, TIOCSETP, &sgorig);
#endif /* USE_ANY_SYSV_TERMIO/USE_TERMIOS */
    exit(EXIT_FAILURE);
}

static void
resize_timeout(int sig)
{
    fprintf(stderr, "\n%s: Time out occurred\r\n", myname);
    onintr(sig);
}

static void
Usage(void)
{
    fprintf(stderr, strcmp(myname, sunname) == 0 ?
	    "Usage: %s [rows cols]\n" :
	    "Usage: %s [-v] [-u] [-c] [-s [rows cols]]\n", myname);
    exit(EXIT_FAILURE);
}

#ifdef USE_TERMCAP
static void
print_termcap(const char *termcap)
{
    int ch;

    putchar('\'');
    while ((ch = *termcap++) != '\0') {
	switch (ch & 0xff) {
	case 127:		/* undo bug in GNU termcap */
	    printf("^?");
	    break;
	case '\'':		/* must escape anyway (unlikely) */
	    /* FALLTHRU */
	case '!':		/* must escape for SunOS csh */
	    putchar('\\');
	    /* FALLTHRU */
	default:
	    putchar(ch);
	    break;
	}
    }
    putchar('\'');
}
#endif /* USE_TERMCAP */

static int
checkdigits(char *str)
{
    while (*str) {
	if (!isdigit(CharOf(*str)))
	    return (0);
	str++;
    }
    return (1);
}

static void
readstring(FILE *fp, char *buf, const char *str)
{
    int last, c;
#if !defined(USG) && !defined(__minix)
    /* What is the advantage of setitimer() over alarm()? */
    struct itimerval it;
#endif

    signal(SIGALRM, resize_timeout);
#if defined(USG) || defined(__minix)
    alarm(TIMEOUT);
#else
    memset((char *) &it, 0, sizeof(struct itimerval));
    it.it_value.tv_sec = TIMEOUT;
    setitimer(ITIMER_REAL, &it, (struct itimerval *) NULL);
#endif
    if ((c = getc(fp)) == 0233) {	/* meta-escape, CSI */
	c = ESCAPE("")[0];
	*buf++ = (char) c;
	*buf++ = '[';
    } else {
	*buf++ = (char) c;
    }
    if (c != *str) {
	fprintf(stderr, "%s: unknown character, exiting.\r\n", myname);
	onintr(0);
    }
    last = str[strlen(str) - 1];
    while ((*buf++ = (char) getc(fp)) != last) {
	;
    }
#if defined(USG) || defined(__minix)
    alarm(0);
#else
    memset((char *) &it, 0, sizeof(struct itimerval));
    setitimer(ITIMER_REAL, &it, (struct itimerval *) NULL);
#endif
    *buf = 0;
}

/*
   resets termcap string to reflect current screen size
 */
int
main(int argc, char **argv ENVP_ARG)
{
#ifdef USE_TERMCAP
    char *env;
#endif
    char *ptr;
    int emu = VT100;
    char *shell;
    int i;
    int rc;
    int rows, cols;
#ifdef USE_ANY_SYSV_TERMIO
    struct termio tio;
#elif defined(USE_TERMIOS)
    struct termios tio;
#else
    struct sgttyb sg;
#endif /* USE_ANY_SYSV_TERMIO/USE_TERMIOS */
#ifdef USE_TERMCAP
    int ok_tcap = 1;
    char termcap[TERMCAP_SIZE];
    char newtc[TERMCAP_SIZE];
#endif /* USE_TERMCAP */
    char buf[BUFSIZ];
#ifdef TTYSIZE_STRUCT
    TTYSIZE_STRUCT ts;
#endif
    char *name_of_tty;
#ifdef CANT_OPEN_DEV_TTY
    extern char *ttyname();
#endif
    const char *setname = "";

    myname = x_basename(argv[0]);
    if (strcmp(myname, sunname) == 0)
	emu = SUN;
    for (argv++, argc--; argc > 0 && **argv == '-'; argv++, argc--) {
	switch ((*argv)[1]) {
	case 's':		/* Sun emulation */
	    if (emu == SUN)
		Usage();	/* Never returns */
	    emu = SUN;
	    break;
	case 'u':		/* Bourne (Unix) shell */
	    shell_type = SHELL_BOURNE;
	    break;
	case 'c':		/* C shell */
	    shell_type = SHELL_C;
	    break;
	case 'v':
	    printf("%s\n", xtermVersion());
	    exit(EXIT_SUCCESS);
	default:
	    Usage();		/* Never returns */
	}
    }

    if (SHELL_UNKNOWN == shell_type) {
	/* Find out what kind of shell this user is running.
	 * This is the same algorithm that xterm uses.
	 */
	if ((ptr = x_getenv("SHELL")) == NULL) {
	    uid_t uid = getuid();
	    struct passwd pw;

	    if (x_getpwuid(uid, &pw)) {
		(void) x_getlogin(uid, &pw);
	    }
	    if (!OkPasswd(&pw)
		|| *(ptr = pw.pw_shell) == 0) {
		/* this is the same default that xterm uses */
		ptr = x_strdup("/bin/sh");
	    }
	}

	shell = x_basename(ptr);

	/* now that we know, what kind is it? */
	for (i = 0; shell_list[i].name; i++) {
	    if (!strcmp(shell_list[i].name, shell)) {
		break;
	    }
	}
	shell_type = shell_list[i].type;
    }

    if (argc == 2) {
	if (!setsize[emu]) {
	    fprintf(stderr,
		    "%s: Can't set window size under %s emulation\n",
		    myname, emuname[emu]);
	    exit(EXIT_FAILURE);
	}
	if (!checkdigits(argv[0]) || !checkdigits(argv[1])) {
	    Usage();		/* Never returns */
	}
    } else if (argc != 0) {
	Usage();		/* Never returns */
    }
#ifdef CANT_OPEN_DEV_TTY
    if ((name_of_tty = ttyname(fileno(stderr))) == NULL)
#endif
	name_of_tty = x_strdup("/dev/tty");

    if ((ttyfp = fopen(name_of_tty, "r+")) == NULL) {
	fprintf(stderr, "%s:  can't open terminal %s\n",
		myname, name_of_tty);
	exit(EXIT_FAILURE);
    }
    tty = fileno(ttyfp);
#ifdef USE_TERMCAP
    if ((env = x_getenv("TERM")) == 0) {
	env = DFT_TERMTYPE;
	if (SHELL_BOURNE == shell_type) {
	    setname = "TERM=" DFT_TERMTYPE ";\nexport TERM;\n";
	} else {
	    setname = "setenv TERM " DFT_TERMTYPE ";\n";
	}
    }
    termcap[0] = 0;		/* ...just in case we've accidentally gotten terminfo */
    if (tgetent(termcap, env) <= 0 || termcap[0] == 0) {
	ok_tcap = 0;
    }
#endif /* USE_TERMCAP */
#ifdef USE_TERMINFO
    if (x_getenv("TERM") == 0) {
	if (SHELL_BOURNE == shell_type) {
	    setname = "TERM=" DFT_TERMTYPE ";\nexport TERM;\n";
	} else {
	    setname = "setenv TERM " DFT_TERMTYPE ";\n";
	}
    }
#endif /* USE_TERMINFO */

#ifdef USE_ANY_SYSV_TERMIO
    rc = ioctl(tty, TCGETA, &tioorig);
    tio = tioorig;
    UIntClr(tio.c_iflag, (ICRNL | IUCLC));
    UIntClr(tio.c_lflag, (ICANON | ECHO));
    tio.c_cflag |= CS8;
    tio.c_cc[VMIN] = 6;
    tio.c_cc[VTIME] = 1;
#elif defined(USE_TERMIOS)
    rc = tcgetattr(tty, &tioorig);
    tio = tioorig;
    UIntClr(tio.c_iflag, ICRNL);
    UIntClr(tio.c_lflag, (ICANON | ECHO));
    tio.c_cflag |= CS8;
    tio.c_cc[VMIN] = 6;
    tio.c_cc[VTIME] = 1;
#else /* not USE_TERMIOS */
    rc = ioctl(tty, TIOCGETP, &sgorig);
    sg = sgorig;
    sg.sg_flags |= RAW;
    UIntClr(sg.sg_flags, ECHO);
#endif /* USE_ANY_SYSV_TERMIO/USE_TERMIOS */
    if (rc != 0)
	failed("get tty settings");

    signal(SIGINT, onintr);
    signal(SIGQUIT, onintr);
    signal(SIGTERM, onintr);

#ifdef USE_ANY_SYSV_TERMIO
    rc = ioctl(tty, TCSETAW, &tio);
#elif defined(USE_TERMIOS)
    rc = tcsetattr(tty, TCSADRAIN, &tio);
#else /* not USE_TERMIOS */
    rc = ioctl(tty, TIOCSETP, &sg);
#endif /* USE_ANY_SYSV_TERMIO/USE_TERMIOS */
    if (rc != 0)
	failed("set tty settings");

    if (argc == 2) {		/* look for optional parameters of "-s" */
	char *tmpbuf = TypeMallocN(char,
				   strlen(setsize[emu]) +
				   strlen(argv[0]) +
				   strlen(argv[1]) +
				   1);
	if (tmpbuf == 0) {
	    fprintf(stderr, "%s: Cannot query size\n", myname);
	    onintr(0);
	} else {
	    sprintf(tmpbuf, setsize[emu], argv[0], argv[1]);
	    IGNORE_RC(write(tty, tmpbuf, strlen(tmpbuf)));
	    free(tmpbuf);
	}
    }
    IGNORE_RC(write(tty, getsize[emu], strlen(getsize[emu])));
    readstring(ttyfp, buf, size[emu]);
    if (sscanf(buf, size[emu], &rows, &cols) != 2) {
	fprintf(stderr, "%s: Can't get rows and columns\r\n", myname);
	onintr(0);
    }
    if (restore[emu])
	IGNORE_RC(write(tty, restore[emu], strlen(restore[emu])));
#if defined(USE_STRUCT_WINSIZE)
    /* finally, set the tty's window size */
    if (getwsize[emu]) {
	/* get the window size in pixels */
	IGNORE_RC(write(tty, getwsize[emu], strlen(getwsize[emu])));
	readstring(ttyfp, buf, wsize[emu]);
	if (sscanf(buf, wsize[emu], &ts.ws_xpixel, &ts.ws_ypixel) != 2) {
	    fprintf(stderr, "%s: Can't get window size\r\n", myname);
	    onintr(0);
	}
	setup_winsize(ts, rows, cols, 0, 0);
	SET_TTYSIZE(tty, ts);
    } else if (ioctl(tty, TIOCGWINSZ, &ts) != -1) {
	/* we don't have any way of directly finding out
	   the current height & width of the window in pixels.  We try
	   our best by computing the font height and width from the "old"
	   window-size values, and multiplying by these ratios... */
#define scaled(old,new,len) (old)?((unsigned)(new)*(len)/(old)):(len)
	setup_winsize(ts, rows, cols,
		      scaled(TTYSIZE_ROWS(ts), rows, ts.ws_ypixel),
		      scaled(TTYSIZE_COLS(ts), cols, ts.ws_xpixel));
	SET_TTYSIZE(tty, ts);
    }
#endif /* USE_STRUCT_WINSIZE */

#ifdef USE_ANY_SYSV_TERMIO
    rc = ioctl(tty, TCSETAW, &tioorig);
#elif defined(USE_TERMIOS)
    rc = tcsetattr(tty, TCSADRAIN, &tioorig);
#else /* not USE_TERMIOS */
    rc = ioctl(tty, TIOCSETP, &sgorig);
#endif /* USE_ANY_SYSV_TERMIO/USE_TERMIOS */
    if (rc != 0)
	failed("set tty settings");

    signal(SIGINT, SIG_DFL);
    signal(SIGQUIT, SIG_DFL);
    signal(SIGTERM, SIG_DFL);

#ifdef USE_TERMCAP
    if (ok_tcap) {
	/* update termcap string */
	/* first do columns */
	if ((ptr = x_strindex(termcap, "co#")) == NULL) {
	    fprintf(stderr, "%s: No `co#'\n", myname);
	    exit(EXIT_FAILURE);
	}

	i = (int) (ptr - termcap) + 3;
	strncpy(newtc, termcap, (size_t) i);
	sprintf(newtc + i, "%d", cols);
	if ((ptr = strchr(ptr, ':')) != 0)
	    strcat(newtc, ptr);

	/* now do lines */
	if ((ptr = x_strindex(newtc, "li#")) == NULL) {
	    fprintf(stderr, "%s: No `li#'\n", myname);
	    exit(EXIT_FAILURE);
	}

	i = (int) (ptr - newtc) + 3;
	strncpy(termcap, newtc, (size_t) i);
	sprintf(termcap + i, "%d", rows);
	if ((ptr = strchr(ptr, ':')) != 0)
	    strcat(termcap, ptr);
    }
#endif /* USE_TERMCAP */

    if (SHELL_BOURNE == shell_type) {

#ifdef USE_TERMCAP
	if (ok_tcap) {
	    printf("%sTERMCAP=", setname);
	    print_termcap(termcap);
	    printf(";\nexport TERMCAP;\n");
	}
#endif /* USE_TERMCAP */
#ifdef USE_TERMINFO
	printf("%sCOLUMNS=%d;\nLINES=%d;\nexport COLUMNS LINES;\n",
	       setname, cols, rows);
#endif /* USE_TERMINFO */

    } else {			/* not Bourne shell */

#ifdef USE_TERMCAP
	if (ok_tcap) {
	    printf("set noglob;\n%ssetenv TERMCAP ", setname);
	    print_termcap(termcap);
	    printf(";\nunset noglob;\n");
	}
#endif /* USE_TERMCAP */
#ifdef USE_TERMINFO
	printf("set noglob;\n%ssetenv COLUMNS '%d';\nsetenv LINES '%d';\nunset noglob;\n",
	       setname, cols, rows);
#endif /* USE_TERMINFO */
    }
    exit(EXIT_SUCCESS);
}
xterm-330/xterm.log.html0000644000175100001440000176606513122341131014060 0ustar  tomusers




  

  XTERM - Change Log
  
  
  
  
  



  

Copyright © 1997-2016,2017 by Thomas E. Dickey


Contents

Here is the latest version of this file.

It began as a list of the changes that I made for xterm, using the notes that I added when submitting a patch. You should note that other changes were made as well, by other people, to fix bugs and correct ifdef's for portability. Until mid-2006, most of these were summarized in the XFree86 CHANGELOG).

Patch #330 - 2017/06/20

  • updates for ReGIS (Ross Combs):
    • remove redundant text command error check which broke T(B) and T(E).
    • retain the loading alphabet number across multiple “L” commands.
    • add S(T) delay handler.
    • fix some color handling error messages.
    • add stubbed-out macrograph handling.
    • use fragment_remaining() and fragment_consumed() instead of manually checking position / length in various places.
    • rename some local variables in string / extent / option parsing
    • wrap some long lines.
    • move macrograph command handling out of the top-level.
  • add a summary of the italic fonts loaded to -report-fonts option.
  • modify the font-lookup for italics to allow for “-i-” if no match is found with slant “-o-” (prompted by patch by Ben Wong).
  • change default values for mkSamplePass and mkSampleSize to reflect generally-improved locale support in various operating systems (FreeBSD #219800).
  • modify wcwidth.c to return -1 for non-Unicode values, and adjust a couple of blocks to better match assumptions about ambiguous-width characters in other implementations. Also modify wcwidth.c to support configurable soft-hyphen, so there is no drawback to using this version rather than a system wcwidth.
  • amend change made in patch #328 for cursor-visibility to handle case where an application is updating the reverse-video state (FreeBSD #219800).
  • update tables of combining and ambiguous-width characters in wcwidth.c based on Unicode 10.0.0.
  • build-fix for --enable-sixel-graphics without --enable-regis-graphics (reports by Sven Joachim, FreeBSD #219945).

Patch #329 - 2017/06/12

  • add control sequences for reading the Sixel and ReGIS graphics sizes (suggested by Ben Wong).
  • add a workaround for wcwidth returning -1 for characters which should have been printable (FreeBSD #219800).
  • fix a bug in font initialization from patch #328 (FreeBSD #219800).
  • fix a special case in HideCursor which assigned a bold font to the slot used for normal font in changes for italics in patch #307 (Debian #858304).
  • updates for ReGIS (Ross Combs):
    • Strings specified with no command are used as "comments". Print these in the log when tracing.
    • Catch attempts to use "alternate display" mode (AKA "blink") from the GIGI, but do not implement it.
    • The T(M) command should only multiply the height by 10, not 20.
    • Make the S(E) command reset more state than just the screen contents.
    • Remove two rotation variables which were only being printed.
    • Numerous minor fixes and comment updates in the R command.
    • Unknown R command option names trigger an empty response.
    • Fix the output position after printing rotated text (it was missing the the sign before).
    • Fix the position change with pixelvectors and rotated text (the rotation transform was not being applied).
    • Update the TODO list and remove a verification FIXME (slanted text positioning is correct as is).
    • Emulate the approximately 1.4x enlargement for text which isn't rotated at right angles.
    • Only update the color planes specified in the plane mask (the W command's F option).
  • fix a bug introduced by the changes to font information in patch #328. When processing the "checkfont" option of the locale resource, the program referred to the request data, to an array which was only allocated in the new/result widget (report by H Merijn Brand).
  • fix a missing assignment initialization to make the utf8 resource control whether escape sequences to enable/disable UTF-8 mode are allowed.

Patch #328 - 2017/06/01

  • revise parser for charClass resource, making these improvements:
    • accept octal and hexadecimal values
    • allow embedded whitespace
    • allow the class after colon to be optional, e.g., to clear class settings for a range of characters.
  • add command-line option -report-charclass.
  • fix most lintian warnings about test-package
  • add eraseSavedLines resource.
  • document DECSED 3 in ctlseqs.ms (report by Ben Longmans).
  • improve integration between configure-events and updates for reported screensize, in particular when switching between vt100 and tek4014 modes.
  • modify selection-highlighting of reverse-video text to keep that distinct, e.g., by reversing the selection foreground and background colors as one would expect. This fixes a "useless" case in the description of highlightColorMode.
  • improve fix for Debian #759734, addressing a case where non-colored cursor would be invisible against reverse-video (see patch #311).
  • updates for ReGIS (Ross Combs):
    • the "H" option of the "T" command should multiply by 10, not 20.
    • display unknown glyphs as a solid block.
    • given a succession of text-direction options, use the last.
    • fix the direction of ReGIS slanted text so that negative values produce oblique output .
    • fix the ReGIS text direction option to only rotate characters when no following size option is used.
  • update terminfo to better match corresponding entries in ncurses, e.g., u8 pattern to match the VT220, VT420, etc., primary responses, as well as adding smxx and rmxx.
  • fixes from Jörg Sommer:
    • corrected a trace-message regarding maximum graphics-size; it used the similar ReGIS maximum size which might not be configured.
    • in do_select_regex, clear selection if there is no match. If the regex does not match anything around the cursor, the selection returned must be empty, otherwise the whole line is treated as a match. This way the command defined by exec-selectable will not be executed if there is no match.
    • modify limit in do_select_regex to include the character at the cursor in the match, making it easier to type something and then hit the key to trigger exec-selectable.
    • If exec-selectable or insert-selection is triggered by a mouse button click, the position of the mouse pointer should be used. This makes it easier to address any position on the window and it makes it possible to use the mouse, e.g., for applications such as mutt where you cannot move the cursor.
  • modify DECRC to save/restore xterm's last-column flag used to control wrapping behavior rather than manipulating DECAWM (report/analysis by Mattias Engdegård).
  • add configure option --enable-terminfo-env to use the value set by --with-own-terminfo for the $TERMINFO environment variable. That variable was set automatically for HPUX, but would be useful in other systems, e.g., for Solaris (request by Jeff Wieland).
  • fix a race condition when setting up a signal handler to timeout if opening /dev/tty hangs (patch by Tobias Stoeckmann).
  • review/cleanup resources which were not in the manual page (report by Maxwell Anselm):
    • add manual page description as needed.
    • drop resource name for menuBar, as unnecessary.
    • modify fallback numeric value for regisScreenSize resource to match that for maxGraphicSize.
  • updated configure macros CF_ADD_CFLAGS, CF_CC_ENV_FLAGS, CF_GNU_SOURCE, CF_MATH_LIB, and CF_XOPEN_SOURCE from other program-changes.
  • update config.guess, config.sub
  • change “maximum screensize” assumed by resize to 9999x9999, to accommodate people using the Unreadable font.
  • drop Utility from default value of --with-desktop-category (Debian #780176).
  • widen the configure script pattern used for finding related ".desktop" files, including “Terminal”
  • several minor improvements to font utility functions:
    • provide for later modification to implement font-sets by parsing the font resources as comma-separated lists.
    • parse -fn and -fa similarly, using “x:” and “xft:” prefixes for font name/family strings to distinguish between XLFD and Xft font specifications.
    • use loops to iterate over font classes
    • use getters/setters for font data to allow for on-demand lookups.
    • make the debugging trace for missing glyph less verbose since that interferes with the -report-fonts option.
    • refactor xtermLoadFont to make it clearer how some fonts are derived from others, e.g., bold, wide.
    • make the triggering and suppressing of font-warnings more consistent by storing the last state in the widget.
    • reduce font-warnings by checking for repeated warnings.
  • add vttests/query-status.pl
  • add vttests/closest-rgb
  • add special case for displaying soft-hyphen if it happens to fall at the right margin, and omitting similar case such as the BIDI markers, where a zero-width character is neither a control character nor a combining character (Debian #844325).
  • modify logic for OSC 52, manipulate selection data, to update the selection-time to include the latest X events. This fixes some cases where the selection was invalid, e.g., after an event due to focus-follows-mouse (report/testcase by Stephane Chauveau).
  • revise macro CastMallocN as new macro TextAlloc to make explicit use of sizeof(char) (prompted by patch by Cade Foster).
  • add “Mouse Ops” menu entry and related resources to allow runtime disabling/enabling of the mouse protocol escape sequences (discussion with Bob Proulx).
  • improve discussion of mouse actions versus protocol in the manual (discussion with Bob Proulx).
  • improve discussion of environment variables in the manual, pointing out where some features (such as termcap and the System5 COLUMNS and LINES variables) are used rarely, mainly to support legacy applications.
  • add examples of translations resource for select/paste, and for font-size changes to the manual.
  • minor reordering of some entries in ctlseqs.ms for consistency (report by Arran Ubels).
  • add -s option to 256colors2.pl and 88colors2.pl, to demonstrate modifying the “system” colors 0–15.
  • omit XFT_SPACING property from call to XftPatternBuild, to work around a bug in fontconfig for handling Google Go fonts, whose names sort in an order not expected by fontconfig, causing the request for a monospaced font to return italics, e.g.,
    $ fc-match 'Go Mono:spacing=monospace'
    Go-Mono-Italic.ttf: "Go Mono" "Italic"
    (report by Giacomo Boffi on Stackoverflow).
    
    
  • modify minstall.in to improve a workaround added to the manual page in patch #182 to avoid having the C preprocessor used in the imake configuration strip out the comments in the character classes section (reports by Ted Unangst, Anthony J Bentley).

Patch #327 - 2016/10/07

  • add a check in the function which handles end-of-line wrapping to ensure that C1 controls are allocated one column when allowC1Printable is set (Debian #738794).
  • use consistent error-checking after strtol calls, fixes a case where a query with OSC 6 did not ensure there was a valid color number (report by Alex Smith).
  • add -baudrate option, for testing ncurses.
  • always generate the CASE_xxx symbols in VTparse.h and Tekparse.h, as part of a change to improve debug-logging. This makes the build always depend upon awk.
  • modify allowC1Printable to disallow codes 160-254 as being equivalent to codes 32-126 when parsing escape sequences (Debian #839220).
  • amend fix from patch #326 for TrueType fonts to exclude the hidden character used for double-width cells (report by Grady Martin).
  • fix a typo in ctlseqs.ms

Patch #326 - 2016/09/25

  • updated appdata file (report by Richard Hughes).
  • improve discussion of the different terminal emulations provided by xterm in the manual page.
  • add examples of setting the icon title with/without the window title in the manual (Debian #833984).
  • correct a limit-check when using a numeric value for extended Booleans e.g., *fullscreen:3 rather than a name such as *fullscreen:never.
  • add action allow-bold-fonts
  • improved formatting fixes for manual page, using script to find mismatches in spelling of resources, actions and menu entries.
  • improve documentation of logging resources.
  • fix a special case of flickering cursor by adding GraphicsExpose to the list of event types that should not trigger making the mouse cursor visible (patch by Joe Peterson).
  • correct initialization of line-drawing in VT52-mode, overlooked in changes for patch #297 (report/patch by Ben Wiley Sittler).
  • minor clarification of form-feed versus line-feed in ctlseqs.ms (suggested by David Kemper).
  • amend fix for Debian #738794 to restore a check for missing characters which are not combining characters. Also fill in a corresponding special case for TrueType fonts (Debian #827905).

Patch #325 - 2016/06/05

  • improve manual page discussion of function keys (discussion with Ross Combs).
  • further improve fix for Debian #545220 in patch #248, to avoid conflict with combining characters (Debian #738794).
  • improve -hold option to avoid 100% CPU usage with NetBSD after closing the shell, which makes subsequent checks for X input events fail (prompted by patch by Pierre Pronchery).
  • review #ifdef statements, listed those which do not have a configure option in xtermcfg.hin.
  • fixed one case where the menu sensistivity for Print-All Immediately and Print-All on Error was not properly ifdef'd.
  • modify terminfo entries for 16-, 88- and 256-color to reset palette with rs1 capability.
  • accept legacy value of -kt as synonym for the oldXtermFKeys resource, and extend the full-reset logic to use the keyboard type set via -kt.
  • modify ioctl calls for I_PUSH to first check if the module has been added, using I_FIND. This is needed for newer Solaris libraries with c11 support (adapted from patch by Alan Coopersmith).
  • add check in getXtermCombining to ensure that combining characters were allocated (report by Tor Andersson).
  • add configure option --without-xinerama to allow suppressing the extension (Gentoo #580936).
  • update keysym2ucs.c based on Unicode 9.0
  • fixed most cppcheck --enable=all warnings, including for style (prompted by report by David Binderman). There was one bug-fix:
    • RGB least-squares computation in allocateClosestRGB used only one ordinate
  • add cppcheck to lint-like programs in configure script and makefile.
  • fix some const correctness issues and point out an array lifetime issue (Ross Combs).
  • updates for SIXEL and ReGIS (Ross Combs):
    • Sixel drawing should still happen after an error if some commands have been processed
    • Tiny steps toward reporting ReGIS input

Patch #324 - 2016/03/10

  • updated configure macro CF_LD_RPATH_OPT from ncurses changes.
  • provide alternate fix for Juha Nurmela's report by turning on POSIX signals if _POSIX_C_SOURCE is at least one. This is done to improve the behavior if a direct child process receives a STOP signal.
  • revert change to CF_POSIX_C_SOURCE from patch #323 (reports by Ashish Shukla, Christian Weisgerber).

Patch #323 - 2016/03/07

  • updated appdata and desktop files to add keywords (report by Richard Hughes).
  • modify configure macro CF_POSIX_C_SOURCE to accommodate some systems, e.g., FreeBSD, which have separated their implementation specific preprocessor symbols from the POSIX ones, requiring both to be defined (report by Juha Nurmela).
  • change the directory to the current working dir of the child process in exec-formatted and exec-selectable actions (patch by Alexander Pohoyda).
  • correct typo in xterm.man (patch by Larry Hynes).
  • correct typo in ctlseqs.ms (report by Shriramana Sharma).
  • add feature to support XHTML and SVG screen dumps (patch by Jens Schweikhardt).
  • correct response to DECRQSS when terminal id is less than 400 (patch by Iwamoto Kouichi).

Patch #322 - 2016/01/02

  • fix regression due to incorrect fix for compiler warning when allocating storage for /etc/shells (reports by Ashish Shukla, Debian #809646).

Patch #321 - 2015/12/31

  • add resource keepClipboard, escape sequence and action keep-clipboard.
  • add optional feature to capture text copied to clipboard at the time of copying rather than at the time the clipboard contents are requested for pasting (patch by Milan Mehner).
  • improve a special case where the -e option was used to pass a single-quoted command via luit, by wrapping it in a “sh -c” (report by Keith Hedger).
  • minor fix for type-cleanliness when allocating storage for /etc/shells (Tobias Stoeckmann).
  • fix a typo in manual page (Dan Church).
  • fix minor file-descriptor leak; after calling openpty, the slave's file descriptor is not needed (report by Juha Nurmela).
  • editorial change to ctlseqs.ms (report by David Gomboc).
  • minor updates for autoconf macros.
  • update config.guess, config.sub

Patch #320 - 2015/08/28

  • correct documentation for %t format (report by Martin Tournoij).
  • add %R for consistency to exec-formatted() and insert-formatted() actions.
  • add %r format to exec-formatted() and insert-formatted() actions (patch by Martin Tournoij).
  • Amend fix for Debian #794201 (report forwarded from Christian Jachmann by Emanuel Haupt, Debian #797008).

Patch #319 - 2015/08/19

  • add a section to ctlseqs.ms discussing control sequences and ECMA-48, to explain why C1 controls do not occur in the decoded characters from UTF-8 byte streams (prompted by discussion with Poul-Henning Kamp).
  • modify check for cursor-theme from patch #301 to also check if the resource Xcursor.theme is set to a nonempty value before fallback to xterm's own dummy theme (request by Robert Kloefkorn).
  • explain in ctlseqs.ms that some keys which normally send SS3-prefixes are changed to CSI-prefixes if key-modifiers are passed as parameters (report by George Nachman).
  • correct double-free of font information when multiple problems are found, particularly for the wide fonts loaded via the -wc option (report/testcase by Nelson Beebe).
  • make configure option --enable-builtin-xpms actually work (report by William Bulley).
  • correct combination of -ls and -e options for utempter configuration (Debian #794201).
  • NetBSD build-fix for OPT_RENDERFONT versus OPT_SHIFT_FONTS (patch by Matthew Green, forwarded by Thomas Klausner).
  • fix a few minor bugs found with Coverity.
  • update pixelvector handling (Ross Combs):
    • split pixel-based and coord-based functions with common parts factored out to a "raw" function
    • add a "step" variant which loads a single PV digit
  • make the graphic dirty upon resize or clear, fixing some missing refreshes (patch by Ross Combs)
  • fixes scrolling to use user coordinates and move in the correct direction (patch by Ross Combs)
  • several fixes/improvements for ReGIS whitespace and page-handling (patch by Ross Combs).

Patch #318 - 2015/04/12

  • rename new(er) configure option --enable-initial-erase to --enable-pty-erase, since that conflicted with an existing option (report by Jens Schweikhardt).
  • fix cut/paste error in --with-builtin-xpms configure option (reports by Jens Schweikhardt, Ross Combs).
  • fix minor formatting issue in xterm manual (report by Jens Schweikhardt).
  • eliminate unnecessary "#(vi" markers in autoconf macros by using "(" to begin case-statement cases (suggested by Jens Schweikhardt).
  • minor fixes to improve const usage (Ross Combs).

Patch #317 - 2015/03/27

  • adapt example for exec-formatted from Lukáš Zapletal's webpage to manual (Debian #780008).
  • add a short usage section to the xterm manual, including notes on setting the window title (Debian #742477).
  • revise a change made to ICH in patch #314 to address limit-checks (reports/testcases by Zoltán Kéri and Joe Peterson, also reported by Christian Weisgerber).

Patch #316 - 2015/03/07

  • revert change to make DCH honor top/bottom scrolling margins. For the record, both the VT420 and VT520 reference manuals incorrectly state that "DCH has no effect outside the scrolling margins."
  • fix regression in DCH introduced in adjustment for limit-check in patch #315 (report/testcase by Zoltán Kéri, also reported by Christian Weisgerber).
  • correct default value for configure option --enable-initial-erase; it should be "False", but in patch #315 it was "Maybe", which differed from default set in patch #192.

Patch #315 - 2015/03/02

  • change default for --enable-narrowproto for Cygwin to "no" to better match contemporary configurations (report by Jens Schweikhardt, prompted by discussion).
  • provide OSC 106 as an alternative to OSC 6, avoiding conflict with one of Terminal.app's undocumented escape sequences (report by Egmont Koblinger).
  • fix an off-by-one in comparison when autowrap and left/right margins are combined (report by George Nachman).
  • modify DECBI and DECFI to work outside the left/right margins, since the vague VT520 reference manual could support that interpretation (suggested by George Nachman).
  • correct response for DECSCUSR in DECRQSS (report/analysis by George Nachman).
  • add DECSLRM to list for DECRQSS in ctlseqs.ms (report by George Nachman).
  • improve limit-checks versus assert's in the debugging version (reports by George Nachman).
  • correct a problem with multiple writes to the right-margin when autowrap is turned off (report by George Nachman, also reported in Gnome #744819 by Ulf Magnusson).
  • modify DCH to honor top/bottom and left/right margins (report by George Nachman).
  • correct off-by-one in comparison so that DL honors left/right margins (report by George Nachman).
  • correct logic of DECSCL, which always set 8-bit controls as a side-effect (report by George Nachman).
  • correct loop limit for DECSED 1, when DECSCA is enabled (report by George Nachman).
  • fix a entry in csi_table for “$”, needed for CSI [ $ z (report by George Nachman).
  • remove restriction from patch #279 changes on DECIC and DECDC to left-right mode (report by George Nachman).
  • correct PID value returned in response to DECRQCRA (report/analysis by George Nachman).
  • fix an ifdef'ing problem, where --disable-dec-locator would turn off logic needed for DECIC and DECDC (report by George Nachman).
  • correct order of parameters in report for CSI 1 9 t, which gives the screensize in characters (report by George Nachman).
  • add null pointer checks for a case in DECCRA where part of the target rectangle lies outside the screen limits (report by George Nachman).
  • remove extra "6" for selective erase from DA1 response (report by George Nachman).
  • support Xinerama screen specification in geometry parsing (patch by Nicolas George).
  • add configure option --enable-initial-erase to set ptyInitialErase consistently with manpage, as well as adding a table in manpage to clarify the relationship between the resources related to the backarrow key (Debian #775952).
  • add configure --enable-builtin-xpms to simplify compiling-in the icons introduced in patch #284 (prompted by discussion with William Bulley).
  • fix/improve autoconf macros:
    • CF_WITH_APP_DEFAULTS, add paths for OSX
    • CF_WITH_MAN2HTML, configure option "--with-man2html" provides "man2html" as alternative to groff's man/html conversion
  • fix some minor issues in manpage (Jens Schweikhardt).

Patch #314 - 2014/12/28

  • fix a minor bug in the termcap-specific version of resize when the lines or columns values are at the very end of an incomplete termcap string (prompted by coverity report).
  • improve paste64 feature (report by Olaf Rogalsky)
    • fix “p;” command in paste64.pl example.
    • modify _OwnSelection to allow the paste64 control to cause primary/clipboard selections to be disowned and cleared.
    • omit an extra "=" used in padding, to make the base64 response a multiple of four characters.
    • modify _ConvertSelectionHelper to not stop converting on embedded nulls in the primary or clipboard selection. That makes the behavior consistent with cut-buffers. Nulls are not passed on to the application because they are used for separators in the X library calls that convert XTextProperty values.
  • add configure option --with-man2html to allow an alternative to groff's man/html conversion.
  • review and modify resource-settings which can be set via control sequences, etc:
    • add OSC 6, to enable/disable colors set via OSC 5, without changing the color assignments (prompted by patch by Ingo Brückl).
    • add command-line option -itc for italics.
    • add colorIT and colorITMode for italics, like colorBD, etc.
    • guard allowPasteControls against modification by editres.
  • change passedPty from fixed-length to allocated to ensure that it is long enough to hold the -S option value (report by Ben Longbons).
  • improve ReGIS graphics initialization (Ross Combs):
    • add a new string resource to set the default ReGIS font.
    • fix a caching problem where the font name wasn't taken into consideration when looking up cached metrics.
    • enables use of fractional values in coordinates (which in turn allows setting the coordinates to something like [0,1][1,0])
    • doubles the minimum ReGIS graphic to 200x200
    • set the default ReGIS image size to "auto"
    • fix some swapped width/height parameters in TRACE messages
    • add support for scaling and mirrored coordinate systems to the screen address command
    • sets a minimum ReGIS graphics size of 100x100 -- smaller address ranges will be scaled up
    • reset the image if either the width or height is zero (which should happen together or not at all, but switching the logic gets rid of some parentheses)
    • adds support for alternate screen coordinates (just offsets, not inverted coordinates or scaling)
    • keeps the graphics state across ReGIS calls unless P1 or P3 entry codes are used
    • changes loops to continue after parsing whitespace to allow trailing whitespace
    • fixes some incorrect character casts

Patch #313 - 2014/11/28

  • add regisScreenSize resource setting to allow custom screensizes for ReGIS graphics (prompted by discussion with Scott Froebe).
  • fix some minor issues in manpage (Jens Schweikhardt).
  • improve ReGIS font-handling (Ross Combs):
    • remove "random junk" generation for unknown characters
    • add xterm extension to load user glyphs for alphabet 0
    • add xterm extension to specify loading an alphabet from a font by name
    • fix bug with use of empty alphabet slots which caused slot 0 to be clobbered
    • update/clarify ReGIS-related comments
    • add DECprint extension for printing/clearing the screen (only clearing is performed)
  • improve ReGIS colorspec conversion (Ross Combs):
    • avoid some floating point math for colorspace conversion
    • move two copies of colorspec parsing to a single function
    • change colorspec parsing to handle components being out of order or with spaces and commas between them
    • add support for an extension where RGB components can be given instead of HLS
  • improve use of const, e.g., for the LineData pointers (patch by Ross Combs).
  • clip of graphics that overlap the scrollback buffer and alt screen (patch by Ross Combs).
  • amend change to focus-change events in patch #287 to limit it to suppressing the reset of the urgency-hint, because some useful FocusOut events were lost (report by Joe Peterson).
  • modify dpkg build-script to configure xterm-dev as an x-terminal-emulator alternative.
  • extend the --with-xterm-symlink feature to make symbolic links for the other programs and scripts.
  • minor fix to vttests/resize.pl to avoid undefined variable when receiving broken/missing response, e.g., from mrxvt.
  • change the way that ReGIS graphics are refreshed (patch by Ross Combs):
    • it pre-composes any overlapping graphics to avoid unnecessary and flickering draws
    • it adds a three-dimensional lookup table for RGB -> pixel values and uses this across all graphics
    • it draws in line segments when there is a run of the same color
    • in cases where there are no transparent parts, it uses an XImage to draw
    • it hooks into the double-buffering support if it is enabled (though this doesn't seem to get rid of all flicker).
    This has the effect of reducing flicker and speeding up redraws.

Patch #312 - 2014/09/28

  • undo change to do_select_regex() in patch #311 (reports by H Merijn Brand, Sven-Haegar Koch, Debian #762978).

Patch #311 - 2014/09/18

  • mention xclip in manpage as an alternative workaround for copying clipboard data, noting that selectToClipboard (see patch #209) is the recommended approach (Debian #639094).
  • correct comparison in do_select_regex() of working position against starting column.
  • correct initialization for regular-expression feature of exec-selectable and insert-selectable actions (Debian #758633).
  • modify logic for exec-formatted and insert-formatted actions to ensure that the formatting occurs just after the selection is received (Debian #758633).
  • account for state of reverse-video in special case of cursor coloring (Debian #759734).
  • fix a sign-extension problem in ReGIS support, as well as correcting a case where ignored-characters were not really ignored (patch by Ross Combs).
  • Enable the "Escape Sequence" menu entry when an OSC 50 is received. Also disable it if the escape sequence specifies no font (Debian #760208).
  • improve fix for the fontsel menu entry from patch #304: because the recovery used the "current font", it would fail if one first selected a valid font, then an invalid font (Debian #760207).
  • correct an off-by-one in limit-check for ScrnLimitChar function (report by Egmont Koblinger).

Patch #310 - 2014/07/25

  • update package/freebsd files based on xterm #309 port.
  • adapt changes from Minux3.2 which ported xterm #197, to allow building on that platform both using imake as well as using the configure script.
  • update precompose.c based on Unicode 7.0
  • build-fix for --with-Xaw3dxft option (report by Emanuel Haupt).

Patch #309 - 2014/07/13

  • modify configure script to work around debris left by XQuartz upgrades.
  • modify test-package scripts to enable ReGIS graphics.
  • improvements/additions to ReGIS graphics, e.g., drawing text (Ross Combs).
  • add --with-Xaw3dxft, to link with Xaw 3d xft library (Stephen P Wall).
  • amend reset for cursor-shape to take into account cursorUnderline resource (report by Christian Weisgerber).
  • update config.guess, config.sub

Patch #308 - 2014/06/19

  • corrected font used for clipping double-width bitmap fonts from patch #307 changes to work around mis-scaled fonts (Debian #752947).
  • improve wording of a warning message.

Patch #307 - 2014/06/17

  • fill background for top/bottom parts of double-width/double-height characters, to cover occasional gaps due to bitmap font-scaling (report by Egmont Koblinger).
  • amend resets for keyboard-type, pointer-mode and title-modes from xterm #305 changes to account for resource settings (Debian #751351).
  • modify printAttributes feature to include new SGR codes.
  • modify cursor show/hide logic to work with italic fonts.
  • do clipping and filling for a case with bitmap-fonts and italics when the font server returns only a "close" match (report/testcase by Egmont Koblinger).
  • adjust loop comparison for underlining to display underlines on 5x8 font as in patch #304 (Debian #750733).
  • amend fix for Freedesktop #15979 (Debian #750733).
  • amend xterm.appdata.xml, making it validate with current schema.

Patch #306 - 2014/06/03

  • fixes for display-errors in new SGR codes (report by Egmont Koblinger).

Patch #305 - 2014/06/02

  • add xterm.appdata.xml (request by Richard Hughes). By the way, none of the released validators yet handle <licence> tags (or <metadata_license>, etc).
  • fix memory leaks in bitmap font-name caching.
  • other changes to hard-reset behavior:
    • reset keyboard-type on hard-reset.
    • reset pointer-mode (pointerMode) on hard-reset
    • reset title-modes (titleModes) on hard-reset
    • reset cursor-shape on hard or soft-reset
    • reset LEDs on hard-reset.
    • reset DECSACE on hard-reset.
  • reset bracketed-paste mode on hard-reset (suggested by Egmont Koblinger).
  • modify UTF-8 decoder to account for allowC1Printable resource.
  • revise getXftColor to ensure that its sequence number will not overflow in long-running sessions.
  • minor fix to selection to prevent hidden character from being returned in selection data (report by Egmont Koblinger).
  • add -sh to help-message.
  • amend check for incomplete fonts to always decide that a character is missing if the font lacks per-character metrics (prompted by Freedesktop #15979).
  • minor reorganization to implement “filler” SGR features. There are no established applications which rely upon these; some people find them amusing.
    • separate bits used to manage drawing state from attribute-bits.
    • implement SGR codes 2, 3, 9, 21 and their corresponding resets.
    • add configure option --disable-wide-attrs to disable the feature.
  • additional changes for ReGIS support (Ross Combs):
    • fix some arc drawing bugs and add support for pattern shading.

Patch #304 - 2014/05/03

  • add debugging check for parsing table entries, fixed a few inconsistencies.
  • handle utmp/utmpx strings consistently with new function that null-pads unused locations.
  • build-fix for imake configuration with FreeBSD 9 and later, to account for replacing utmp with utmpx.
  • improve handling of the fontsel (font-selection) menu item:
    • initialize the menu entry differently if the toolbar configuration is used, i.e., enabling it without attempting to use the current selection as a font name. Because of the way in which the toolbar is setup, this attempt usually failed, and would result in a warning.
    • if the menu action fails, e.g., no font can be loaded for the given selected name, then recover by resuming with the current font. Before, the recovery went to the default font. That was done to work around missing bitmap font in patch #276.
  • document OSC 119 in the control sequences listing (report by Egmont Koblinger).
  • modify special handling of XF86Paste or SunPaste keysyms (see patch #227) to use the standard shift/lock modifiers in case those are, for example, used in level 3 in an XKB file (patch by Matthieu Herrb).
  • configure macro updates:
    • drop the -no-gcc option from CF_INTEL_COMPILER
    • modify CF_XOPEN_SOURCE to suppress the check for defining _XOPEN_SOURCE on Solaris
  • reduce bss storage used for ReGIS/Sixel modules, as well as cleanup storage usage in other modules.
  • initial changes for ReGIS support (Ross Combs):
    • document control-sequences
    • separate ifdef's for sixel and color-register features
    • add configuration for VT382

Patch #303 - 2014/03/06

  • improve check for /etc/shells to allow its entries to be symbolic links.
  • fix a regression in patch #302 fixes relating to interaction of SHELL and XTERM_SHELL variables (Debian #740919).
  • improve manpage discussion of use of /etc/shells for validating the SHELL environment variable.
  • further improve the approximation for color map by ignoring bits which would not be applied by the rgb masks for the current visual (report by Joe Peterson).
  • add -report-colors to usage-message (report by Joe Peterson).

Patch #302 - 2014/03/02

  • amend approximation for color map introduced in patch #277 to make that apply only to TrueColor (adapted from patch by Joe Peterson).
  • add -report-colors option, to show colors as they are allocated.
  • fix some gcc -Wcast-qual warnings.
  • correct app-defaults location for CentOS-4 in xterm.spec
  • improve check in minstall.sh for X manpage's section number; add sample dependencies for the relevant documentation package to packaging test-scripts (prompted by Novell #779474).
  • modify sample build-scripts for dpkg and rpm to ensure that vttests scripts are uncompressed and executable.
  • modify Perl scripts in vttests to use env to find Perl rather than relying on /usr/bin/perl This makes the sample scripts usable with NetBSD and other systems using pkgsrc.
  • amend check from patch #301 for valid shell to permit existing SHELL value to specify the shell; clarify the behavior in the manpage (report by Emmanuel Thomé).
  • amend change to wide-character processing from patch #257 to allow switching to/from UTF-8 encoding if the utf8 resource was not set to “always” (report by Honza Maly).
  • fix incorrect free from patch #301 changes, if explicit program without -e option is a valid shell (patch by Romain Francoise).

Patch #301 - 2014/01/19

  • OSC 104 and 105 did not accept parameter to reset a specific color (patch by Egmont Koblinger).
  • add configure check for initgroups, and use that function to complement its use of setgid (prompted by patch by Miroslav Lichvar).
  • improve manpage description of scrollbar translations versus the vt100 translations (Debian #723573).
  • add a few paragraphs to manpage explaining the implications of xterm's reliance on X Toolkit for command-line parsing.
  • modify cursor-theme logic to check if the environment variable XCURSOR_THEME is set to a nonempty value before constructing a dummy them (prompted by similar check added in OpenBSD CVS).
  • add check for a case where TrueType bold font is missing a glyph where the non-bold font has it. Temporarily switch to the non-bold font to draw the glyph (report by David Demelier).
  • minor documentation fixes for ctlseqs.ms
  • only set SHELL environment variable to programs found in /etc/shells (prompted by patch/report by Al Poole).
  • build-fix, when --disable-wide-chars --disable-boxchar is used (prompted by patch by Andrey Panov).

Patch #300 - 2013/12/03

  • amend workaround for Xcursor library from patch #298; the suggested solution for Debian #466704 fell afoul of a bug in Xcursor which treated an empty value for Inherits= as a valid theme—and resulted in a stack overflow due to unbounded recursion. Certain environments such as XFCE4 exposed the bug. A related report in Debian #531679 was closed without following the recommendation to limit stack recursion in this library (reported by Sergey V Dyatko, Debian #731269).

Patch #299 - 2013/12/01

  • fix regression in line-drawing from patch #297 changes for NRCS exposed by change to assumeAllChars resource in patch #298 (report by Markus Waldeck).

Patch #298 - 2013/11/27

  • quiet a warning about ambiguity when -h command-line option is parsed, since -help is used rather than the options mentioned in the message. This warning was caused by fixes in patch #272.
  • remove an extra check for keypad-mode which interfered with the patch #280 modifyKeyboard feature for the numeric keypad (report by David Conners).
  • change default for assumeAllChars resource (Debian #725682). There are unresolved issues with Terminus fonts, e.g., Debian #722017.
  • add -report-fonts command-line option and reportFonts resource to optionally report the fonts which are loaded, and their metrics such as the number of missing glyphs.
  • work around Xcursor library to make pointerColor resource work as documented (Debian #466704, analysis by Vincent Lefèvre).
  • amend change from patch #297 for ASCII-equivalents to ensure that missing characters which happen to be double-width are padded to the expected number of columns. Also, correct the choice between normal/wide Xft fonts used when checking for missing characters (reported by WU Yue, Debian #728949, Gentoo #491334).
  • modify sixel-graphics drawing to account for scrollbar width (report by Mario Edelmann).
  • fix remaining issue with DECNRCM; the British character set was confused with ISO Latin-1 (report by Hayaki Saito).
  • build-fix for --disable-boxchars configure option.
  • updated configure macros, from ongoing work on lynx and ncurses.
  • update config.guess, config.sub

Patch #297 - 2013/09/10

  • modify check for missing cells in bitmap font to work around terminus 10646 encoding, which is mostly missing, add assumeAllChars resource to provide the older behavior.
  • modify macros used to check for missing cells in bitmap fonts to pick up a long-overlooked improvement made to xfd in XFree86.
  • improve workaround for groff versus ASCII-equivalents; patch #185 had overlooked Xft configuration (reported by anonymous user on Arch Linux forum).
  • review/extend DECNRCM support (prompted by report by Hayaki Saito asking about the two "A" codes).
    • make pasting of DECNRCM data work by translating the pasted data into the selected encoding.
    • limit mode changes to VT220 and up.
    • ignore SCS for National Replacement Characters if DECNRCM is not set.
    • add tables and logic to decode SCS controls ending with "%" and one additional character. This expects the parsing of SCS to VT320.
    • also added parsing for SCS of DEC Supplemental and DEC Technical, which are for VT2xx and VT3xx respectively.
    • implement VT220 Multinational character set "GR" aka "DEC Supplemental Graphic".
    • DEC Technical character set based on vt100.net description.
    • implement Portuguese NRC.
    • provide for temporarily switching to/from NRC mode from UTF-8 mode when DECNRCM is set or reset.
  • minor fix to assert's found while testing examples from ttdoda's slrm-test1.txt.
  • modify DECLRMM to not update the cursor position (report by Iwamoto Kouichi forwarded by Hayaki Saito).
  • modify cursor-position report to take origin-mode into account (report by Hayaki Saito, see also iTerm2 pull request 129).
  • correct off-by-one comparison in when handling carriage-return at left margin (patch by Iwamoto Kouichi, forwarded by Hayaki Saito).
  • improve handling of faceName resource when a "size=" property is embedded in it, by using that size to replace the default faceSize resource. This lets xterm honor the other faceSize resources (report by Jens Schweikhardt).
  • improve OSC 52 selection-data by setting its timestamp to correspond to the most-recent event received by xterm, to ensure that calls to XtOwnSelect succeed even if the selection is manipulated solely through the keyboard (prompted by patch by Richard Tollerton).
  • change configure-script defaults for "luit" and "wide-chars" options to match the values used in the imake configuration, to lessen user surprise if they are accustomed to building xterm using imake(report by Andries E Brouwer).
  • improve the imake-related configuration's check if xterm is started in a locale that uses UTF-8 encoding. Before, this checked the locale settings only for "UTF-8", now it checks ignoring case for "UTF-8" and "UTF-8" (report by Andries E Brouwer).

Patch #296 - 2013/07/10

  • improve experimental sixel feature (Ross Combs).
  • modify delimiter in configure macro used to add a library after a given library to avoid confusion with -Wl pass-through options to linker (NetBSD #48031).
  • fix quoting in expression used to trim extra libraries from patch #295 changes (report by Thomas Klausner).

Patch #295 - 2013/07/06

  • adjust order of libraries to work around incomplete symbol resolution when using --as-needed option (ArchLinux #36047).
  • minor fix for plink.sh, for IRIX64.

Patch #294 - 2013/07/05

  • add note in ctlseqs.ms for CPR response pointing out a potential point of confusion with the string sent by a modified F1 key (suggested by Bram Moolenaar).
  • improve plink.sh by checking if the linker supports the --as-needed option (suggested by David Philippi).
  • improve clearing for private mode 1049 when switching to the alternate screen (Debian #711758).
  • amend fix from patch #292 by removing now-unneeded chunk which introduced problem in selection (Debian #714527).
  • add definition to optionally override compiled-in class for xterm from makefile, needed for test-packages.
  • add configure option --enable-sixel-graphics
  • add experimental support for sixel graphics (Ross Combs).

Patch #293 - 2013/05/27

  • modify sample xterm.spec to use newer icon
  • add configure option --with-icon-symlink to work around systems which map icon requests for to a single "xterm" icon, but neglect to install the icon needed for window decorations (report by H Merijn Brand).
  • improve parameterizing of sample xterm.spec
  • amend fix for printer from patch #280, removing a reset of the signal handler for SIGCHLD (report by Joe Julian).
  • set environment variable XTERM_FILTER if a locale-filter is used.
  • enable DEBUG logic when --enable-trace configure option is given.
  • improve description of initialFont, set-vt-font and set-tex-text in manpage (Debian #707899).
  • fix regression from patch #292; selecting a word that ended at the right margin without wrapping would not select the last cell (report by Christian Weisgerber).

Patch #292 - 2013/04/25

  • add limit-check when double-click selects a word; if the saved-lines were scrolled back and the word selected wrapped at the screen's lower right corner, an assertion was triggered (patch by Taketo Kabe).
  • correct limit-check in unsaveEditBufLines, fixing a case where enlarging the terminal size could show a blank line where there actually is available text (patch by Bertram Felgenhauer).
  • add PasteControls feature to allowWindowOps which by default disallows pasting control characters other than formatting such as carriage return (discussion with Hayaki Saito).
  • fix typo in ctlseqs.ms for DECRQM response (patch by Emanuele Giaquinta).
  • update default shown in configure --help message for --with-terminal-id option (patch by Andres Perera).
  • rename script/preprocessor variables used for substituting the backarrowKey default value for consistency (patch by Andres Perera).
  • set umask to 077 before creating debugging-trace files.
  • add configure option --disable-openpty to control whether openpty() may be used in preference to posix_openpt().
  • improve workaround from patch #279 for BSD systems which do not complete initialization until both sides of the pseudoterminal are opened, by preferring openpty() function over posix_openpt() when available (report by Christian Weisgerber).

Patch #291 - 2013/02/26

  • add validity check for xterm widget parameter to AlternateScroll function, needed to handle wheel mouse events in the scrollbar area since patch #282 changes which introduced alternateScroll feature (Redhat #874327).

Patch #290 - 2013/02/12

  • revert of patch #282 change was incomplete (report by Jim Reisert).
  • fix typo in manpage (report by Vincent Lefevre).

Patch #289 - 2013/02/08

  • revert the patch #282 change which restored "lost" text after shrinking/growing the screen size. If the screen was updated between the two resizing operations, unexpected text might be shown at the end (report/testcase by Joe Peterson).
  • reverse the arrow-keys sent for alternateScroll to match the usage in browsers (suggested by Dieter Roelants).
  • modify mouse reports to consistently indicate motion events whether or not a button is pressed. Old behavior (since patch #127 modified encoding for wheel mouse) showed only that the button was released if no button had been pressed (report by Andy Koppe).
  • correct and improve behavior for SGR 1006 mouse protocol on button release in any-event mode. Initial implementation in patch #277 left internal state showing the last button pressed when reporting motion events. It now keeps track of all buttons which have been pressed and released, showing the lowest remaining button by number in the response (reports by Hayaki Saito, Andy Koppe).
  • fix inconsistency between TermColors and OscTextColors enums which interchanged values for tektronix cursor color and highlight foreground in control sequences in patch #225 (report/patch by Peder Stray).
  • fix inconsistent use of noreturn-attribute in Exit function which interfered with clang --analyze.
  • remove incorrect free used in computation of XTERM_SHELL variable, from Coverity fixes in patch #288 (FreeBSD #175782).
  • add --with-valgrind option to configure script for consistency with my other programs.
  • update table of ambiguous width characters in wcwidth.c based on Unicode 6.2.0
  • update table of combining characters in wcwidth.c based on Unicode 6.2.0
  • update precompose.c based on Unicode 6.2.0

Patch #288 - 2013/01/09

  • fix a special case in ShowCursor where the foreground and background colors of the current position are the same. In that case, choose the further of the window's foreground and background colors for the cursor color.
  • modify alternateScroll feature added in patch #282 to use either CSI or SS3 according to the cursor keys application mode setting, to simplify using it in vi, etc. (suggested by Dietar Roelants).
  • revise manpage for resize to clarify the changes which resize may make to the terminal settings as well as to the terminal itself.
  • remove code such as struct ttysize, used for SunOS 3 and 4.
  • modify configure script and makefile to check for groff and suppress groff-specific rules if groff is not found.
  • modify ctlseqs.ms and makefile to work around bugs in grohtml which cause ".png" files to be truncated when producing html documentation.
  • modify suffix rules for "make docs" to make the names of the generated ".png" files predictable, helping to work around longstanding problems with this feature of groff—none of its releases work for all of xterm's tables..
  • correct typo in ctlseqs.ms for DECIC and DECDC; the character preceding the final "~" is an ASCII single-quote "'" rather than a space (report by Paul LeoNerd Evans).
  • update CF_GCC_VERSION macro, handling both Debian and Darwin.
  • improve configure script checks for the --with-desktop-category option. After patch #280 changes, if no value was given for this option, and no existing desktop files found for comparison, the incorrect "auto" value was passed into the generated desktop file (report by Julien Cristau).
  • modify sample build-scripts to disable check for imake due to code-rot in Xorg.
  • add -v command-line option to resize, reporting the same version string as xterm and the two shell-wrappers.
  • make name-transformation apply to other occurrences of resize, other manpages.
  • special-case the name-transformation in xterm's manpage in the NAME section so that the result works with makewhatis (report by Julien Cristau).
  • modify install-rules for manpages to put each program's respective transformed name into the header rather than xterm's.
  • remove deprecated files: proto.h, os2main.c
  • minor fixes based on Coverity scan, including:
    • correct caching of Atom value for the font menu's "Selection" entry.
    • ensure that utmp/utmpx calls do not depend upon trailing nulls in the ut_id and ut_line values.

Patch #287 - 2012/11/25

  • fix a case where in_put() loop could continue when it has found an X event rather than the pty, causing the pty-read to be delayed (patch by Balazs Kezes).
  • add option to pointerMode resource and corresponding control sequences to allow text-cursor to remain hidden if the pointer leaves/enters the window via accelerator keys. Ordinary motion within the window restores the pointer (prompted by patch by Balazs Kezes).
  • remove special case of modifiers for the Mode_switch and XK_ISO_Level3_Shift from patch #223. Verified that the conflict which this was intended to resolve does not happen for normal compose- or modeswitch-handling (prompted by patch by Balazs Kezes, Debian #638694).
  • modify the handling of focus-change events to ignore those whose detail is NotifyPointer, since those are sent in addition to focus-change events directed to the old/new windows having focus. In particular, this prevents the urgency-hint from being reset inadvertantly (prompted by patch by Balazs Kezes).
  • modify description of iconName in manpage to make it clearer that this resource does not specify the filename of an icon (discussion with Ian Collier).
  • modify iconHint resource to allow suppressing the built-in icon by setting this to "none" (discussion with Ian Collier).
  • make -iconic option work with the toolbar configuration.
  • correct initialization of window manager hints used to set the icon-pixmap. That detail from patch #282 overwrote state used to control the -iconic command-line option (report by Ian Collier).
  • fix paste64 feature for the case where the selection comes from the current terminal. The selection callback can happen after the reply is partly built, making it necessary to flush the reply-buffer to keep things in the proper order (report by Ailin Nemui).
  • reject command-line options which are longer than the options in xterm's table, to avoid mismatches (Redhat #875305).
  • correct attribution for patch #282 changes.

Patch #286 - 2012/10/29

  • fix minstall.in to work with "make docs" rule, so that patch number appears in the corresponding generated documentation.
  • modify minstall.in to keep the name shown in the heading consistent with any renaming, e.g., for test-builds.
  • check for misconfigured printerCommand resource on the first use, warn and disable it if it does not specify an executable command (Debian #691642).
  • improve check for window-manager name needed to establish usable default for activeIcon resource. This works around a scenario where gdm does incomplete cleanup, leaving window properties that refer to windows which no longer exist (Redhat #869959).

Patch #285 - 2012/10/23

  • add/adapt FreeBSD ports files for test-building.
  • modify minstall.sh to use the patch-number and date in the manpage footer.
  • add check for failure to allocate the fg/bg colors at startup, e.g., misconfiguration. Work around by setting both to the default colors (suggested by Scott Bertilson).
  • amend change for patch #280 which added modifyKeyboard, to make modifyOtherKeys work (report by Ailin Nemui).
  • add query-colors.pl example for OSC 4.
  • correct mis-applied fix for minstall.sh (report by Miroslav Lichvar).

Patch #284 - 2012/10/14

  • amend configurability changes for icons from patch #283, moving the new functionality to the iconHint resource to avoid conflict with existing uses of the iconName resource in the Shell widget (report by Emanuel Haupt).
  • fix documentation errata reported by Miroslav Lichvar:
    • correct manpage default for allowTcapOps (see patch #243
    • modify documentation for configure --enable-backarrow-key to match the script (see patch #280).
    • fix typo in minstall.sh in patch #283, which made the leading-cap "Xterm" become "xterm" (patch by Miroslav).
  • fix two typos in configure.in from patch #283 changes; one broke the --regex configure option (report by H Merijn Brand).

Patch #283 - 2012/10/09

  • modify makefile and script to generate appropriate renaming s/xterm/xterm-dev/ for test-package's manpage.
  • improve makefile rules for installing/uninstalling pixmap files, to include the newer mini- and filled- variants.
  • clarify change in manpage regarding patch #282 change to always set a window-decoration icon, even if iconName is not set.
  • add a fourth flavor of window-decoration icons, "filled-xterm" for a monochrome xterm with filled interior.
  • use shape-mask to improve contrast of the window-decoration icons.
  • minor changes to icon colors to improve contrast on bright-mud backgrounds.
  • drop configure checks for memmove versus bcopy, and strerror function; all currently tested platforms support these.
  • cleanup configure macros, as done in byacc 20121003.
  • improve configurability of the built-in icon selectable via the iconName resource.
  • update config.guess, config.sub

Patch #282 - 2012/09/28

  • improve configure check for XkbKeycodeToKeysym, fixing a regression on some older systems in the patch #280 changes.
  • add clarification in manpage for alwaysBoldMode and veryBoldColors resources (prompted by Derek Martin question about using the former with TrueType fonts).
  • add alternateScroll resource and corresponding control sequences which modify the scroll-forw and scroll-back actions: when the alternate screen is displayed, wheel mouse up/down will send cursor keys (Debian #683942).
  • improve rendering for the case when a Unicode character is absent in the bold font but present in the normal font by temporarily falling back to the normal font (Debian #359006, Debian #408666).
  • provide configure option --enable-double-buffer and ifdef's to allow comparisons with/without double-buffering. The default uses normal buffering.
  • add feature to optionally scroll current page before clearing, controlled by resource setting cdXtraScroll (prompted by patch by Balazs Kezes):
  • integrated patches from Arch Linux forum posting (patches by Balazs Kezes):
    • modify reallocation limit of line-data when resizing screen so that "lost" text will be restored if the screen is first shrunk and then grown.
    • modify output to use double-buffering to reduce flicker.
  • modify scroll-lock action to handle on/off/toggle keywords like other actions. Previously the optional parameter was interpreted as an integer.
  • extend DECSCUSR to provide a way to set the cursor to a vertical bar (patch by Paul Bolle).
  • add -8, -c, -d and -u options to 88colors2.pl and 256colors2.pl scripts. No current terminal emulator recognizes C1 controls while handling UTF-8 encoding—see notes in patch #119 and patch #109 regarding utf8controls—but the -u and -8 options are useful for demonstrating this point.
  • improve speed when changing color palettes using OSC controls by deferring repaint while followup controls might be additional color palette changes.
  • modify SGR 38 and SGR 48 to accept RGB index, matching the closest entry in xterm's palette.
  • extend SGR 38 and SGR 48 to accept colon as parameter separator (request by Paul LeoNerd Evans).
  • modify fullscreen action to allow it to toggle the full-screen mode rather than only set or unset it (prompted by Eeri Kask's suggestion to support _NET_WM_TOGGLE). This implementation does not yet use _NET_WM_TOGGLE.
  • add support for _NET_WM_STATE_MAXIMIZED_VERT and _NET_WM_STATE_MAXIMIZED_HORZ EWMH properties (suggested by Eeri Kask).
  • make fullscreen mode work with the tek4014 window. This change makes only the currently active window to be changed to fullscreen rather than changing both windows.
  • modify TekClear function to discard pending output before clearing the tek4014 display (patch by Kevin Ryde).
  • fix deleteIsDEL feature, broken in patch #280 changes (report by Mike Thornburg, forwarded by Jeremy Huddleston).
  • fix a special case of wrapping double-width characters (report/test-case by Ken Winstein).
  • add E3 extended capability to xterm-basic to match ncurses 20120728 patch.
  • fix incorrect transformation of row-parameter for ClearCurBackground in patch #279 which caused incorrect painting in some scrolling scenarios (report by Chuck Silvers).
  • fix typo in manpage description of +maximized option (Paul Maier).
  • change default for configure option --with-xpm, turning it on unless requested otherwise.
  • add configure option --with-icon-name which can be used to override the default icon used in icon-themes.
  • extend activeIcon resource to provide default value which tells xterm to determine the window manager's name and automatically enable the feature for fvwm and window maker. The explicit true/false values can be used to override this behavior.
  • add "mini" xterm icon, which scales better than the standard xterm icon, e.g., for the gnome/kde "panel" feature.
  • extend iconName resource to search for icon named according to resource value and use that if found. If not found, use compiled-in pixmap. Both set the WM_ICON_NAME property which is used by various window managers, usually for window decoration.
  • updated autoconf patch, adding support for --datarootdir, which changes the default location of manpages.
  • further improved autoconf macros for configuring icons, from vile 9.8h

Patch #281 - 2012/06/26

  • remove "$(srcdir)/" from install-icon rule to fix builds when --srcdir configuration option is used.
  • fix for configure script's search for icon file when it is not found in the current directory, e.g., when building out of tree (patch by Thierry Reding).
  • undo the XK_Home / XK_End change from patch #280 which broke the non-VT220 keyboard for those keys (report by H Merijn Brand).

Patch #280 - 2012/06/24

  • add configure check to work around warning from desktop-file-install for "Encoding", noting that it emits deprecation warnings without providing its version information.
  • add configure option --with-icon-theme to tell xterm whether to install into an icon theme, defaulting to "hicolor" (Redhat #755206, Redhat #799614 and Redhat #804279).
  • change --with-icondir to look for "icons" directory rather than "pixmaps" by default. Add new option --with-pixmapdir to allow these two uses to be installed concurrently.
  • modify configure options --with-app-defaults and --with-icondir to accept "auto" as value to look for existing directory from well-known locations.
  • add missing codes for secondary DA response which tell the type of terminal as in the primary DA response.
  • update primary DA response for VT420 to include user windows and horizontal scrolling.
  • add modifyKeyboard resource to support keypad-modifier changes per request by Thomas Wolff.
  • add XK_Home / XK_End to editing-keypad checks
  • add back-tab key kB to termcap entries to match the terminfo.
  • update terminfo to match corresponding entries in ncurses, e.g., add XT and adjust sgr string for xterm-bold entry.
  • add configure options to predefine the most commonly customized resources for terminal-settings, use those to substitute into the manpage the corresponding compiled-in values: altSendsEscape, backarrowKey, backarrowKeyIsErase, deleteIsDEL, metaSendsEscape (Redhat #819588).
  • change default emulation level to VT420 (discussion with Ailin Nemui).
  • improve logic for DECSCL; patch 279 partly enforced limitation of this to higher-level emulations. This patch finishes that change.
  • improve check for base of combining characters, preventing combination when cursor movement has intervened. Mosh's webpage gives two different examples of this, with other causes ascribed to the behavior.
  • modify IL/DL to set cursor to first column on row for better VT102/VT220 compatibility (prompted by code review of mosh).
  • separate state-table entries for DECSC/DECRC from the ANSI.SYS save/restore cursor, since the latter conflicts with DECSLRM when DECLRMM is enabled since patch #279 (report/analysis by Ailin Nemui).
  • fixes to avoid using SIGCHLD handler of main program in printer's subprocess (report by Joe Julian).
  • correct restore-parameter for mouse-modes from patch #279 changes.
  • add null-pointer checks to input-method caching added in patch #277 to fix a problem in the exposure code, when deselecting a window (report by Kriston Rehberg).
  • unset DESKTOP_STARTUP_ID environment variable to lessen confusion on the part of GTK applications which use the variable without checking it (report by John Little).

Patch #279 - 2012/05/10

  • fill in missing cases in the save/restore modes feature (report by Thomas Wolff).
  • add check to ensure that combining characters are precomposed in the order given (report/analysis by Andries E Brouwer).
  • improve workability check for posix_openpt(), to take into account BSD systems which do not complete initialization until both sides of the pseudoterminal are opened (report by Christian Weisgerber).
  • amend fix for Debian #650291 in patch #277 changes to account for different data returned by vnc4server (Debian #670638).
  • add check in DECCRA operation to make copies of blinking text also blink by updating a line-level flag.
  • modify rectangle operations to work with DECOM.
  • modify DECSERA to use the current protected state rather than preserving it.
  • add precompose resource to allow storing character data in Normalized Form D as described in http://unicode.org/reports/tr15/ (report/discussion with Andries E Brouwer).
  • modify CBT, other ISO-6429 controls which are used by VT520 to work with DECOM.
  • add HPR and VPR controls, ISO 6429 cursor movement used in VT520.
  • remove "linux" restriction for IUTF8 ifdef in main.c (prompted by Matthew Dempsky posting on mailing.openbsd.tech).
  • implement the remaining VT420-level device status reports.
  • change DECXCPR to return page 1, rather than 0.
  • improve VT-level checks on reporting functions, such as DECXCPR.
  • change limit on decTerminalID to 525.
  • fixes to improve vttest vt52 screen when running as a VT420:
    • add checks for some VT2xx and up controls for consistency: DECSCL, S1C8T, S1C7T.
    • modify DECRQSS return for DECSCL to only return that when running as VT2xx and up.
    • when exiting from VT52-mode, resume in VT100 level rather than the level before starting VT52-mode.
  • implement DECLRMM, DECSLRMM and DECNCSM (prompted by discussions with Ailin Nemui and Paul LeoNerd Evans). This modifies several controls to obey top/bottom and left/right margins.
  • correct macro definition used for testing modes used in ANSI/DEC request-mode controls introduced in patch #262.
  • modify x_getlogin to check $LOGNAME and $USER before fallback to getlogin, so that user's choice for these variables can be carried forward to the xterm process (Debian #611487).
  • document DECSCUSR response for DECRQSS in ctlseqs.ms
  • add zIconTitleFormat resource to allow customizing the "*** " prefixed to the icon title when the zIconBeep feature is activated (request by Thomas Adam).
  • modify DECSCUSR to update the same internal variable as RM/SM 12, and document in manpage the two variables used for controlling blinking cursor (report by Paul LeoNerd Evans).
  • correct response data for DECSCUSR in reply for DECRQSS response, which had inverted the blink-value (reports by Ailin Nemui, Paul LeoNerd Evans).
  • add a null-pointer check in OkPasswd macro to fix a problem in resize with Fedora 17 and a serial console (report/patch by Daniel Drake).
  • add workaround for Mac OS X, which loses the window size of a pseudo-terminal when the tty device is opened (report/analysis by Egmont Koblinger).
  • updated configure check for workable posix_openpt versus grantpt, from luit fixes.
  • modify DECIC/DECDC/DECBI/DECFI implemented in patch #277 to enable them only in VT4xx mode and up (report by Ailin Nemui).
  • update config.guess, config.sub

Patch #278 - 2012/01/18

  • correct initialization for eightBitMeta resource (FreeBSD #164101).
  • make special check for Darwin 9 (and lower) to not use posix_openpt (report by Christian Ebert).
  • minor fixes (adding ".ne" directives) to reduce the cases where groff's utility for generating images for tables dumps core. Most versions of groff (I've found 1.19.2 to be the most stable) dump core when attempting to report that there are too few lines on a page for a table to be shown.

Patch #277 - 2012/01/07

  • remove special case for ISC pseudo-terminals which attempts to open the pty in two different ways.
  • move call to grantpt before asking utempter to add a record, to work with kFreeBSD which does not update the terminal's ownership until this point (Debian #652907).
  • document limitation of XIM interface in manpage (Debian #230787).
  • cleanup error reporting with new xtermWarning function.
  • add configure option --disable-selection-ops to make the new actions optional.
  • add four new actions for making the selection or data directly copied from the screen (prompted by discussion in Debian #637001, as well as report by Arjen van Tol):
    • exec-formatted
    • exec-selectable
    • insert-formatted
    • insert-selectable
  • add visualBellLine resource to allow visualBell to flash only the current line (prompted by patch by Gertjan Halkes).
  • add eightBitMeta resource to control the features which modify or interpret the eighth bit of a key when the meta modifier key is pressed (prompted by Debian #326200).
  • improve discussion of eightBitInput in the manpage (prompted by Debian #326200).
  • correct logic for alt-sends-escape action, overlooked when implementing altSendsEscape resource, which still used eightBitInput resource value.
  • add a workaround for XAllocColor(), which does not actually allocate "a read-only colormap entry corresponding to the closest RGB value supported by the hardware", but rather a rough approximation (Debian #650291).
  • undo parameter checks for RequestResize() added in patch #251 and amended in patch #270, because zeros also are special cases (report by John S Urban).
  • modify some test-scripts to use /bin/echo rather than the shell's possibly-builtin echo, to work around broken configuration on Mac OS X, i.e., neither honoring the option nor flagging an error.
  • add SGR 1006, as a better technical solution than SGR 1015:
    • the responses will not be confused with line-deletion and scrolling controls.
    • the button encoding is a little simpler, since it does not add an unnecessary 32 because the integer parameter does not have to be represented as a printable character.
    • the control responses for pressing and releasing a mouse button differ, allowing an application to tell which button was released.

    Besides these improvements, in discussion, it was noted that urxvt's implementation of 1005 is incorrect, relying upon a locale that provides UTF-8 encoding. In contrast, vttest demonstrates a correct decoding, independent of locale.

  • add support for urxvt SGR 1015 to address shortcoming of SGR 1005 with luit (patch by Egmont Koblinger).
  • add ISO and DEC controls useful for left/right scrolling.
  • add some changes for OpenBSD and MirBSD (adapted from patch by Thorsten Glaser):
    • disable search for non-Unix96 ptys.
    • fix a gcc warning in timestamp_filename
    • modify Imakefile to install xterm setgid to utmp.
  • add/use/prefer posix_openpt() for opening pseudo-terminal.
  • modify special errno handling case in ptydata.c from patch #158 to allow for the possibility that any platform may have special cases where "/dev/tty" is absent. For example, this can happen in a FreeBSD jail (patch by David Wolfskill).
  • add keyboard logic to map shift-tab into XK_ISO_Left_Tab, which is usually, not always, done by the X keyboard configuration.
  • portability fixes for some configure macros: CF_XOPEN_SOURCE

Patch #276 - 2011/10/10

  • modify clipping limits for TrueType fonts to account for the scaleHeight resource setting, to work around another problem due to recent FreeType changes. In this case, the DejaVu Sans Mono set to pixelsize=13.5 is truncated because the font descent is reduced by FreeType to match an incorrect height metric (report by Adam Lee).
  • improve recovery when bitmap fonts are not installed, e.g., so that switching font-sizes works for TrueType fonts.
  • modify lookup for XTERM_SHELL feature to allow relative pathnames.
  • modify abbreviation disambiguation check for command-line parameters to account for -geometry, whose parameter may begin with "+" or "-" (report by Scott Bertilson).

Patch #275 - 2011/09/11

  • add ash, zsh to known shells for resize.
  • modify resize to reuse the logic from xterm which determines the actual logon-user's shell if $SHELL is not set.
  • revert the unsetenv("SHELL") added in patch #272.
  • an unsetenv("SHELL") added in patch #272 to help ensure that luit would get the user's shell consistently did not work as expected for cases where multiple names are in the password-file for a given uid. That was because changes in patch #157 to handle this situation did not take into account that repeated calls to getpwnam and getpwuid return a pointer to the same static buffer. Fixed the older logic to work as intended, by ensuring that the passwd-data from each call is stored separately (report by Paul Keusemann).
  • adjust ifdef's for putenv and unsetenv in case only one of those is provided on a given platform.
  • correct comparison used in ExposeContains macro from patch #274 changes, to handle window-dragging (patch by Todd Eigenschink).

Patch #274 - 2011/09/05

  • portability fixes for cygwin: do not define SVR4, and work around nonstandard header location.
  • ifdef'd use of unsetenv from patch #273 changes to work with Solaris 9 (report by Waldemar Rachwal).
  • modify logic for XtAppPending to merge adjacent Expose and ConfigureNotify events which are redundant (report by Edward McGuire).
  • fix an unneeded warning message when -r option is given.
  • remove a few redundant entries from table used for helping abbreviation-checking of command-line options, makes -geom work again after patch #272 changes as an abbreviation of -geometry.
  • add scaleHeight resource and command-line option -sh as workaround for some font-configurations broken by changes in FreeType 2.4.6 (report by Miroslav Hodak).
  • portability fixes for some configure macros: CF_FUNC_TGETENT, CF_XOPEN_SOURCE, CF_X_ATHENA_LIBS.
  • add configure option --with-freetype-config to improve selection over the plethora of configuration options which freetype has so far provided.
  • build-fix for configure --enable-load-vt-fonts when --enable-widec is not specified.
  • build-fixes for suppressing various features, needed after changes in patches 270, 271 and 272 (report by Brian Lindholm)

Patch #273 - 2011/08/25

  • build-fix for out-of-tree "make docs" rule.
  • correct a typo in x_strdup, from patch #198 changes.
  • correct initialization for -e option, broken in patch #272 changes (report by Gabriele Balducci).
  • build-fix for out-of-tree builds to address minstall script changes in patch #272 (patch by Thierry Reding).

Patch #272 - 2011/08/24

  • document limitation of Gtk in connection with xterm's -into option, in the manpage (Ubuntu #806969).
  • improve -into by checking for and using the size of the window within which xterm is embedded, overriding other clues.
  • modify logic for localeFilter resource to allow that to include command-line options of luit.
  • improve -into by checking for invalid window-id, and allowing hexadecimal/decimal/octal values.
  • improve keepSelection, adding the case where the highlighting is cleared, overlooked in patch #230 (patch by Marco Peereboom).
  • improve command-line parsing to make abbreviate options work consistently across xterm-specific versus standard X toolkit options, and report cases where an abbreviated option happens to be ambiguous. In particular, -d now works as an abbreviation for -display.
  • fix regression in command-line parsing introduced in patch #271 changes for Debian #629358, (Debian #637910).
  • split-out new termcap/terminfo building block xterm+kbs for configurability.
  • modify terminfo file to reflect changes in ncurses for xterm-16color and xterm-256color.
  • modify minstall.sh, etc., to reflect the default default class, $TERM and decTerminalID values.
  • reword resize manpage to reflect the fact that $TERMCAP is not set on all systems (patch by Alan Coopersmith).
  • work around combined Xaw6/Xaw7 package in DragonFlyBSD which omits the usual symbolic link to the preferred library name.
  • further improve build-fix for termcap systems by checking for some which are only partial implementations, e.g., termcap 2.08 in CentOS 5.2

Patch #271 - 2011/07/14

  • omit permissions adjustments to pty on exit except for pre-Unix98 ptys, since modern implementations handle this (report by Sean C Farley).
  • modify logic for switching fonts between UTF-8 and non-UTF-8 encoding to not merge the derivable bold-, wide- and widebold values from the VT100 fonts. Also suppress warning when not using UTF-8 fonts if wide- and widebold-fonts cannot be derived or otherwise loaded (report by Werner Scheinast).
  • modify menu-creation to suppress entries which will never be used in the current configuration, rather than simply disabling them.
  • add resource printModeImmediate and menu item to allow print of screen plus saved lines to a file.
  • add menu item to allow runtime enable/disable of the printFileOnXError feature.
  • append a timestamp to filename used in printFileOnXError feature, and restrict its permissions (request by Vincent Lefevre).
  • add a check when cancelling cursor-blinking, in case the cursor is blinked off. Fix so that the cursor is repainted without waiting for other events, e.g., keypress (report by Ailin Nemui).
  • add configure --with-app-class option, to simplify building "xterm-dev" packages with filenames that do not conflict with conventional "xterm" packages.
  • corrected logic flow for DECSCL, which prevented the updated operating level from being reported via DECRQSS (report by Ailin Nemui).
  • corrected default for brokenStringTerm resource to match manpage.
  • add vttests/dynamic.pl
  • add runtime check for locale not supported by X libraries, and fallback to XA_STRING in this case (request by Bryan Henderson).
  • fix a special case in configure script after no FreeType libraries are found. The script was proceeding to check for a usable configuration.
  • add xterm+tmux building block to terminfo (adapted from changes proposed by Ailin Nemui and Nicholas Marriott).
  • improve discussion of faceName resource in manpage (adapted from suggestions by Jens Schweikhardt).
  • correct mapping of shifted up/down cursor-keys in termcap function-keys mode, i.e., resource tcapFunctionKeys (patch by Gertjan Halkes).
  • update AIX case in CF_XOPEN_SOURCE configure macro to add release 7.x.
  • modify ifdef's in xterm_io.h for __hpux to force that to use the hacked SYSV support in that file. This fixes a problem with a non-blocking socket call (patch by Paul Lampert).
  • improve filtering of desktop category scanning, to exclude XFCE.
  • modify configure script to work with systems that have both ncurses (or other terminfo) as well as a real termcap library, e.g., Slackware (report by Andrew Watts).
  • modify configure script to work around special case where user's environment adds compiler flags to the CC variable (prompted by report by Paul Lampert).
  • amend change for Debian #110226 so that "-h" or "-v" options cause an exit, rather than simply printing to stdout while the window is displayed (Debian #629358).
  • add response for DECRQSS which gives the setting for DECSCUSR.
  • modify AllocateTermColor() to handle XtDefaultForeground and XtDefaultBackground, which are not recognized by XParseColor. For example, this fixes the use of OSC 112 when no explicit cursor color was set (report by Ailin Nemui).
  • handle special-case of KeyPress translated to popup-menu action (Ubuntu #756273).

Patch #270 - 2011/04/26

  • build-fix, e.g., for using imake on platforms which use the termcap library.
  • modify utf8 resource to accept a name.
  • mention default for fontWarnings in manpage (report by Werner Scheinast).
  • split "UTF-8" menu entry into "UTF-8 Encoding" and "UTF-8 Fonts" (prompted by discussion with Werner Scheinast).
  • gray-out font-menu entries when a font fails to load, e.g., a bitmap font is not installed.
  • improve behavior when there is no app-defaults file:
    • set the toolBar resource to false
    • gray-out the font menu entries where no resource is found.
  • add configure option --with-desktop-category to allow customization of the ".desktop" files.
  • build-fix for the install-desktop makefile-rule, when the source/build directories differ (patch by Loïc Minier).
  • add menu entry and corresponding resource which can be used to suppress all bold-fonts (discussion with Jan Engelhardt).
  • make internal line-size value consistent with allocated sizes of character and related arrays to ensure that bulk copying of line data, e.g., in scrolling, accounts for the padding used for pointer alignment (adapted from patch by Rajesh Mandalemula, also reported by Ali Bahar).
  • widen ifdef for screen-resizing logic from patch #176 changes to send SIGWINCH to process group to include any system supporting ioctl(*,TIOCGPGRP,*) (prompted by linux-specific patch in OpenSUSE rpm package).
  • add printModeOnXError and printFileOnXError resources, which allow the user to specify that xterm will write the contents of its screen to a file if it is exiting due to an X error (Debian #280457).
  • restore logic that made reverse-video apply to the scrollbar's foreground/background, broken in patch #158 (report by Bryan Ischo).
  • amend some of the window operations parameter-checks added in patch #251 for the push/pop title feature, to allow the parameters used for window resizing to be -1's, which makes the corresponding values ignored rather than using the window's maximum width/height (report by Noah Friedman).
  • correct order of initialization for translations vs fullscreen resources to enable a special case which omits the Alt-Enter translation when fullscreen is disabled (Debian #612978).
  • update config.guess, config.sub

Patch #269 - 2011/02/19

  • build-fixes for imake (report by Heiko Berges).
  • modify autoconf macro CF_PKG_CONFIG to work with cross-compile environments (patch by Thierry Reding).
  • modify MapToColorMode() to favor bold over underline, matching the precedence used before patch #252 (report/analysis by Nicolas George).
  • add omitTranslation resource, which can be used to suppress the default translations for these features:
    • fullscreen
    • scroll-lock
    • shift-fonts
    • wheel-mouse
  • make the fullscreen feature configurable (Debian #612978)
    • add it to the configurable list disallowedWindowOps.
    • add command-line option -fullscreen to allow the feature to be enabled at startup.
    • add resource fullscreen to control whether the feature is active or may be enabled.
  • modify probe_netwm_fullscreen_capability for 64-bit machines. Contrary to XGetWindowProperty manpage, that function returns 32-bit data packed as long's.
  • eliminate copy of name resource, which was otherwise used only to give the terminal-description name for the tcap-query feature. Use the actual $TERM value instead, as derived from termName resource, etc.
  • eliminate an old inconsistency with error messages, some used the -name option, while others used argv[0]. The latter is now used consistently.
  • improve configure check for rpath-hack, to improve builds on systems where gcc will not search /usr/local/lib, etc.
  • build-fix for Xaw3d configuration (report by H Merijn Brand).
  • update config.guess, config.sub

Patch #268 - 2011/02/10

  • fix an inconsistency of the "Enable Reverse Video" checkbox in the VT Options menu. This also removes a special case added in patch #217 which limited the effect of the reverseVideo resource (Debian #603808).
  • amend decoding of misformed UTF-8 sequences to avoid absorbing valid characters as documented in Unicode 6.0 section 3.9 (report by Keith Winstein).
  • do not set urgency hint when window already has focus (patch by Dimitrios Christidis).
  • amend extended mouse-coordinate mode from patch #262 changes to include the Cb button-code, which also may be greater than 127 (report by Ailin Nemui).
  • ensure that underline-cursor is visible when an application happens to set the background color (report by Christian Weisgerber).
  • add feature for full-screen toggling using either Alt-Enter or a menu selection (integrated patch by Dave Simmons).
  • add missing logic to handle reallocation of FIFO index for the "UTF-8" menu entry (report by David Holland, NetBSD #44344).
  • add makefile rules docs-ctlseqs, docs-xterm, etc.
  • correct typo in description of DECRPM in control sequences document (report by Ailin Nemui).

Patch #267 - 2010/11/20

  • minor formatting changes to ctlseqs.ms to simplify a script which extracts the feature information. See the results in Comparing versions, by counting controls in the xterm FAQ.
  • add docs-clean makefile rule.
  • add copy-selection action (request by Timo Juhani Lindfors, Debian #588785).
  • trim leading/trailing blanks from string used for "Selection" font-menu data.
  • trim leading/trailing blanks from color resource values.
  • configure script improvements:
    • add workaround for removal of X11 dependency from Xt's package file (report by Robert Hooker).
    • add workaround for removal of fontconfig dependency from Xft's package file (report by Jeremy Huddleston).
    • add workaround for removal of Xmu dependency from Xaw's package file (report by Jeremy Huddleston).
    • improve workaround in CF_X_TOOLKIT macro, checking for other possible packages where Xt's dependencies may be given.
    • prefer ${name:=value} to ${name-value}, since recent bash changes break legacy support for that feature.

Patch #266 - 2010/10/24

  • add rpm and dpkg scripts, for testing.
  • more fixes for Debian #600707 (report by Cyril Brulebois).

Patch #265 - 2010/10/22

  • fix a regression in fontname logic from patch #263 changes (Debian #600707, reported by Vincent Lefevre).
  • revert modification of any-event/any-button protocol from patch #263 changes. It interferes with selection using a shifted mouse button (reports by Neil Bird, Bram Moolenaar).

Patch #264 - 2010/10/14

  • replace a null-pointer check with check for empty string in xtermOpenFont, to eliminate a warning message from patch #263 changes.
  • build-fix for patch #263 when toolbar is not configured (patch by Chris Clayton) (reports by Robby Workman, David Wood).

Patch #263 - 2010/10/13

  • corrected initialization of "misc" resource values, to ensure that xterm has allocated a copy of strings which may not have been malloc'd by the X library (Debian #600129).
  • modify handling of any-event/any-button mouse protocol; it now is active with any combination of key-modifiers.
  • add debugging feature showWrapMarks, which marks lines which xterm knows are wrapped, showing where a double-click will select past the end of a line.
  • build-fix to address change in include-guards for Xlib.h in ongoing Xorg edits (patch by Jeremy Huddleston).
  • improve pointerMode by continuing to watch for motion events after mouse tracking is disabled if the pointer is hidden (Debian #594856).
  • further extend initialization for active-icon font to check if the font was not loaded succesfully, to retry with font1, or as even (if TrueType fonts are used) to use a TrueType font. The retries are to help with cases as in patch #241 where the bitmap fonts are not available.
  • fix special case of active-icon used when TrueType font is specified for the xterm window, from patch #261 change. In that case, the default font's size was used for layout of the active icon's window (Debian #591265).

Patch #262 - 2010/8/30

  • fix a case where changing the cursor color via escape sequences did not immediately update the screen (report by Andreas Wagner).
  • implement ANSI and DEC request-mode control sequences. The latter includes the xterm-specific private modes such as the mouse mode. The feature is ifdef'd with the rectangle operations since its decoding overlaps that feature.
  • correct typo in ctlseqs.ms for response of OSC 21 (patch by Kevin Schoedel).
  • improve discussion of mouse tracking in ctlseqs.ms
  • increase an array limit used in reporting mouse events (report by Ryan Johnson).
  • add extended mouse-coordinates mode, allowing up to 2015x2015 windows, using UTF-8 encoding (patch by Ryan Johnson).
  • modify manpage hyphens to conform with Debian.

Patch #261 - 2010/6/28

  • fix regression in renderFont logic, from patch #260 changes (report by Joseph Quinsey).

Patch #260 - 2010/6/20

  • modify plink.sh to work around problem linking to recent PCRE libraries.
  • extend renderFont resource to allow deferred switch to TrueType fonts without affecting existing resource settings (Debian #585620).
  • modify configure macro CF_X_TOOLKIT to work around omission of ICE library from ".pc" file (report by Miroslav Lichvar).
  • change configure script default for --enable-broken-st i.e., the brokenStringTerm feature) to normally enable it. If the corresponding resource is enabled, this feature eliminates an apparent freeze of xterm when sending mis-encoded data to the screen (Debian #584801).
  • document in manpage some actions which were overlooked:
    • readline-button
    • scroll-lock
    • set-8-bit-control
  • undo a change to limit-check in ScrnRefresh in patch #257, which broke fastScroll feature (Debian #584841).
  • modify handling of brokenLinuxOSC and brokenStringTerm to also sound the bell.
  • add control/D and control/Q to controls which will cause early exit from control string per brokenStringTerm resource.
  • improve documentation of brokenStringTerm resource in manpage.

Patch #259 - 2010/6/5

  • modify configure check for luit to include new aliases for the program (xterm-filter and bluit).
  • add workaround in xtermClearLEDs() to account for Xkb's override, making vttest's LED demo reset the scroll lock.
  • filter out client-message events when deciding whether to hide cursor, e.g., when using SCIM (patch/report by anonymous user).
  • improve description of -bd option in manpage (report by Guy Daniel Clotilde).
  • modify configure checks for PCRE and other libraries to use pkg-config, if available.
  • amend change from patch #252, to take veryColorColors resource into account when checking colorBDMode resource for TrueType fonts (report by anonymous user).
  • add vttests/query-fonts.pl script for demonstrating the OSC 50 font query.
  • improve manpage discussion of Scroll Lock feature.
  • improve configure macros CF_GCC_VERSION and CF_GCC_WARNINGS.
  • fix warnings for "clang --analyze".
  • change default for allowScrollLock resource to false, noting that the supposedly unused key has been useful for various rebindings (Debian #580946).

Patch #258 - 2010/5/1

  • add pointer-checks in ScrnRefresh to fix a case in rapid scrolling where an empty record is fetched from the scrollback FIFO.

Patch #257 - 2010/4/22

  • correct ctlseqs.ms description of OSC 17 and OSC 19 (patch by Emanuele Giaquinta).
  • corrected logic for menuLocale resource; the setlocale function returns the original locale only when querying.
  • improve filtering of translations resource, narrowing the scope of the alwaysUseMods to address only the translations that would cause a key to be sent to the host (report by Andrew Gaylard).
  • change default value of menuLocale resource to "C", to work around longstanding Xorg bug.
  • modify handling of scrollKey feature to ignore XON/XOFF keys.
  • implement scroll-lock feature.
  • revise memory allocation in UTF8toLatin1() to fix an out-of-bounds index (Mandriva #54531).
  • compute value for first wide-character rather than assuming it is 256, fixes problem with -cjk_width introduced in patches 242 and 249 (report by Thomas Wolff).
  • improve configure script:
    • corrected check for _XOPEN_SOURCE for OpenSolaris.
    • when possible, add rpath option for libraries in unusual places
    • add configure option --disable-rpath-hack to control whether the rpath option can be added.
  • modify AllocateTermColor() to separate initialization from control sequences, fixing problem from patch #254 changes where enabling allowSendEvents resource prevents setting cursor color on command-line (Debian #572928).
  • amend logic from patch #185 to not reallocate cell-array if processing ESC % G to switch from UTF-8 if already in ISO-8859-1 character set (report by Michael Koehne).
  • fix to avoid calling XmuInternStrings() with zero count (report by Johan Bockgård).
  • fix build when --disable-ansi-color configure option is used.
  • fix build when neither OPT_TCAP_QUERY or OPT_TCAP_FKEYS is defined (patch by Matthieu Herrb)

Patch #256 - 2010/3/6

  • add TerminalEmulator to desktop category files.
  • modify sinstall.sh to ignore the "." appended to permissions by selinux.
  • change app-defaults organization, installing UXTerm-color and KOI8XTerm-color for consistent behavior regarding customization: color (prompted by discussion in Ubuntu #421261).
  • fix typo in minstall.sh from patch #255 changes, and add case for /var/run needed for full path of utmp (report by Julien Cristau).
  • minor fix to xterm manpage, remove a comment stating that margin bell can be changed via the VT Options menu. That was replaced in patch #225
  • add a "docs" rule to makefile.
  • fix initialization of Atom used for XkbBell feature from patch 243 changes. Unlike the other calls to XInternAtom(), in this case the flag telling X to create the Atom was unset (patch by Chris Adams).

Patch #255 - 2010/1/21

  • rename install.sh to install-sh in case suffix-rules might interfere.
  • extend range for convertToUTF8 function to full 31-bits, to use with printing, etc.
  • improve manpage by checking for actual locations of utmp/wtmp files (Debian #562640).
  • modify configure macro CF_XOPEN_SOURCE to remove -D's before adding the same name rather than relying on -U's, to reduce redefinition warnings for some platforms that have conflicting definitions in headers.
  • correct logic used to switch to alternate screen using FIFO-lines configuration (Debian #565772).
  • update config.guess, config.sub

Patch #254 - 2010/1/6

  • add a configure-check to eliminate install-ti rule from Makefile when the system has no tic (terminfo compiler) program. This lets one use the install-full rule more consistently.
  • amend change to WriteText() function in patch #252 to take into account the colorAttrMode resource (report by Krzysztof Kotlenga).
  • document titleModes resource in manpage, added in patch #252.
  • modify tcap-query table entries for shifted up/down cursor keys to match ncurses convention.
  • improve lookup of termcap-query data, allowing for duplicate keycodes versus missing entries.
  • add control sequence which can be used to modify the terminal data used for the termcap-keyboard.
  • improve portability of tcap-query feature, using terminfo functions in preference to termcap on systems having terminfo.
  • improve font-setting/querying control (OSC 50):
    • when TrueType font is selected, the TrueType faceName will be set, rather than the bitmap font.
    • when TrueType font is selected, querying returns the name of the TrueType font.
    • querying a font recognizes the relative-font convention that setting a font could use.
  • add menu-entry for allowColorOps.
  • add new resources for fine-tuning menu entries: allowColorOps, disallowedColorOps, disallowedFontOps and disallowedTcapOps.
  • correct logic for disabling the "TrueType Fonts" menu item; it was not ensuring that the faceName resource value was non-empty.
  • implement VT520-style controls DECSMBV and DECSWBV for setting the margin- and warning-bell volume.
  • fix a minor error from patch #243 which made the zIconBeep feature use a minor-error tone rather than an informational tone.
  • add a null-pointer check for the case where renderFont resource is true, but faceName resource is unset, used in logic to strip "xft:" prefix from patch #251 changes (patch by Michael Riepe).
  • add special case to configure CF_XOPEN_SOURCE macro to use extensions on Darwin (patch by Dennis Preiser).
  • improve configure checks for regular expressions header and library
  • update config.guess, config.sub

Patch #253 - 2009/12/10

  • add a null-pointer check in getPrinterFlags() per changes in patch #252.
  • add a null-pointer check, needed in UTF-8 mode for Xft fonts after changes in patch #252 (patch by Alan Coopersmith).
  • correct size when clearing struct for tek4014 (patch by Jochen Voss).
  • parenthesize expression in MoreRows macro, fixing a limit check added in patch #251 (Debian #560039).

Patch #252 - 2009/12/7

  • modify title-querying logic to support retrieval of titles encoded using UTF-8.
  • add new "title-modes" control sequence for controlling whether window/icon titles can be set or queried using UTF-8, optionally encoded in a hexadecimal string.
  • use mkdir -p rather than mkdirs.sh (prompted by discussion of mawk by Aleksey Cheusov).
  • add appropriate copyright/license notices to the bulk of files lacking same, and modify to use identical terms in others which used different wording. The main exceptions are the files contributed by Markus Kuhn, who appears to prefer public domain distribution, noting that I have modified/improved several of these without changing the terms of distribution (request by Jari Aalto).
  • add control sequences for resetting the "dynamic" colors to their default values.
  • add control sequences for resetting the "special" colors to their default values.
  • add control sequences for setting the "special" colors such as colorBD (bold).
  • add overlooked case for setting highlight foreground color with the dynamic-colors control.
  • add OSC 104, for resetting ANSI/16/88/256 colors to default.
  • reset ANSI/16/88/256 colors to default in soft/hard reset functions.
  • strip "xft:" prefix from faceName and faceNameDoublesize resource values,
  • add DECSCUSR (discussion with Andy Koppe).
  • add check/warning on failure to load font, to see if the name looks like an Xft pattern rather than XLFD. This can happen if someone happens to modify their X resource settings for programs that read data from xterm's namespace.
  • modify handling of print and print-everything actions to allow the various printer flags to be overridden by supplying parameters.
  • add resource printerNewLine (request by Ovidiu Gheorghioiu).
  • minor cleanup, finish using TScreenOf() and TekScreenOf() macros introduced in patch #224.
  • improve checks in ShowCursor/HideCursor to get the background color, particularly when highlightReverse resource is used (reports by Jan Engelhardt, Christian Weisgerber).
  • correct checkVeryBoldAttr to omit comparison of foreground color to special color values used for color<XX> resources (report by Jan Engelhardt).
  • make colorBDMode and colorULMode resources work with TrueType configuration (report by Jan Engelhardt).

Patch #251 - 2009/11/11

  • add window-ops controls to push/pop icon and/or window labels on a stack.
  • minor fixes to align termcap file with terminfo.
  • add resource disallowedWindowOps, to allow fine-tuning of features to suppress with the allowWindowOps resource (prompted by discussion with Bram Moolenaar).
  • add makefile rules for resize-manpage to pdf, etc.
  • further improve limit-checks in select/paste (Mandriva #54531).

Patch #250 - 2009/10/13

  • add check and error-message for fonts that have no printable values in the ISO-8859-1 range (Debian #542434).
  • some compiler-warning cleanup, in particular workaround for defective implementation of gcc's attribute warn_unused_result (report by Bram Moolenaar).
  • improve estimate of single-column width for packed TrueType fonts by ignoring extents for codes 127 and 159.
  • improve line-drawing for TrueType fonts which happen to have defined glyphs which are not line-drawing in 0..31 by assuming they're not, and just checking the existence of the Unicode codepoints. This makes it more likely that the user can override a misconfigured font using the "Line-Drawing Characters" menu entry.
  • limit minimum cell-width for packed font to maximum-advance reported by Xft. Some fonts are wider than that, even in the Latin-1 range (Debian #550497).
  • add list of direct-contributors in "THANKS" file.
  • stylistic changes to this file to help scripted extraction of list of contributors.
  • correct off-by-one in okPosition fix from patch #249 limit-checks which prevented double-click selection on the bottom line of the screen (reports by Rajeev V. Pillai, Debian #550368).
  • add -q option to vttest/256colors2.pl and vttest/88colors2.pl to demonstrate bulk initialization of color palette.
  • improve the workaround from patch #188 by enabling resources for the 88-color model.
  • document in xterm manpage the limited availability of resources color16 to color255 as noted in patch #188 (Ubuntu #438850).

Patch #249 - 2009/10/1

  • change default for allowWindowOps resource to false.
  • add limit-checks for result of visual_width() function, needed from patch #242 and exposed by #244 changes (Debian #548321).
  • improve limit-checks in select/paste.
  • fix a remaining bug from patch #230 changes for displaying multi-column characters in a proportional font (report by Chris Jones).
  • add new resource forcePackedFont and menu entry "Packed Font" to control whether to use the font's minimum (default) or maximum width when those differ. The workaround which xterm uses to accommodate proportional fonts is not necessary with certain fonts such as unifont which happen to store a mixture of multicolumn glyphs (report by Chris Jones).
  • fix an (old) bug which did not restart the timer for blinking text if the only blinking text was temporarily scrolled out of view, e.g., using the scrollbar.
  • fix an (old) flaw in the delete-line operation where the text which is scrolled into view while the display is scrolled up was not repainted.
  • improve delete-line and insert-line operations, retaining selection when the selection does not intersect the deleted/inserted lines.
  • fix an (old) off-by-one error when an application cleared above the cursor position while the display was scrolled up, that would leave an extra line of text uncleared.
  • fix a similar problem where the double-size attribute would not be reset when clearing the screen while the display was scrolled up.
  • fix an indexing error which would occur if an application cleared a line while the display was scrolled up and was also in UTF-8 mode (Redhat #524503). The error was from patch #228 but more visible after changes from patch #244.

Patch #248 - 2009/9/11

  • fix an overlooked adjustment for selecting double-width characters in the narrow-character configuration.
  • eliminate uses of XTERM_CELL and XTERM_CELLC where an appropriate LineData pointer is available.
  • correct expression in okScrnRow macro, making selections give the length of lines below the visible screen (report by Stuart Henderson).
  • correct logic used to improve performance of missing-glyph check, which did not handle line-drawing characters (Debian #545220).

Patch #247 - 2009/8/30

  • add ifdef's and check for openpty() on DragonFly (patch by Alex Hornung).
  • correct calculation for size of line's data block, which was sometimes off-by-one when configured using --enable-16bit-chars (report by H Merijn Brand).
  • fix indexing error in print-everything feature from patch #246 (patch by Ovidiu Gheorghioiu).

Patch #246 - 2009/8/16

  • remove obsolete logic for saving/restoring wrapping flags, which did not work on 64-bit platform. Wrapping flags (stored in the line-index) are now copied with line-data (Debian #541160).
  • modify comments in app-defaults files to avoid problem with C preprocessor used by xrdb (Debian #541603).
  • restore special case in makeColorPair, needed for colorBDMode resource (Debian #541089).
  • correct SetLineFlags() macro, broken in patch #244 when recoding to avoid gcc-specific bitfields (Debian #541236).
  • modify initialization of screen buffers to ensure that pointers align to int-boundaries. This fixes a problem introduced in patch #244 where the color- and character-arrays (stored after the video-attributes in each row) might be misaligned (report by Rajeev V Pillai).
  • add limit-check in ScrnRefresh for handling saved-lines from the circular buffer which are repainted on a screen whose width has increased. To improve performance, circular buffer entries are not resized (report by Rajeev V Pillai).
  • correct type for CellColor (a late change in patch #244 to avoid gcc-specifc enums made that unsigned rather than unsigned short, for the 256-color option).
  • fix typo in configure option --enable-16bit-chars (report by Rajeev V. Pillai).

Patch #245 - 2009/8/12

  • correct a special case in saving FIFO-lines from patch #244. If the screen was shrunk, xterm used the wrong amount for copying to FIFO-lines, and then used this amount to adjust the current row on the screen. That was both a visible defect (Debian #541109) as well as a potential addressing error (Debian #541132, Debian #541160, and Debian #541236).
  • add clarification in xterm manual about the various allowXXXOps resources, which are disabled when the allowSendEvents resource is active (patch by Julien Cristau, Debian #531597).

Patch #244 - 2009/8/9

  • refactored storage of saved-lines, providing a configure option to manage them as a FIFO (actually a circular buffer), improving performance. Added configure option --enable-fifo-lines to enable/disable the new feature (it is enabled by default).
  • added fastScroll resource, to amuse people who measure terminal emulator performance by cat'ing large files to the screen.
  • modify check in readPtyData from return values to provide exit on zero-bytes read from pty for FreeBSD, or eliminate high-CPU in "xterm-hold" processing (discussion with Ulrich Spoerlein, FreeBSD ports/136686). The check was originally modified to combine negative/zero values in XFree86-3.1.2E, 1996/05/06.
  • add configure option --enable-16bit-chars to provide wide-characters with 16-bits (rather than the default 32-bits).
  • add retryInputMethod resource to allow configuring out the retries xterm uses to connect to non-responsive XIM server, to work around defective X configurations as noted in NetBSD mailing list.
  • make regular-expression selection work for VT100 double-sized characters.
  • improve layout when drawing missing characters in a proportional font, e.g., as boxes, to take into account whether they are double-width (report by Guilbert Stabilo on comp.unix.shell).
  • add capability for keypad-center (kb2/KA2) to termcap entry for xterm-new, as well as xterm-8bit, xterm-sun and xterm-vt220 (FreeBSD conf/136336).
  • change default for keepSelection resource to true (prompted by discussion with David Muir Sharnoff).
  • remove a limit-check in ptydata.c, allowing Unicode values past 64k to be displayed using TrueType fonts (Debian #458432).
  • remove a vt52-specific ifdef to allow mapping F1-F4 to PF1-PF4 when vt52 support is not compiled (report by Olaf 'Rhialto' Seibert).
  • save/restore line-wrapping flags when converting from ISO-8859-1 encoding to UTF-8 encoding, as well as when resizing screen.
  • remove extra adjustment of position in fix for Debian #418324.
  • modify default check for mkWidth resource to check for line-drawing characters, which are categorized as double-width in Solaris 10 (report by Sebastian Kayser).
  • add "print-everything" action (patch by Ovidiu Gheorghioiu).
  • start refactoring scrollback data using new getLineData() function.
  • demote recent change to Debian #252873 fix to experimental, ifdef'd out as EXP_BOGUS_FG (Debian #522141).
  • work around groff mapping of ASCII quotes using macros (requested by Reuben Thomas based on Colin Watson advice, fixes Debian #378700).
  • correct symbol used for default of allowWindowOps which was DEF_ALLOW_FONT rather than DEF_ALLOW_WINDOW (report by Matthieu Herrb).
  • amend fix for tek4014 from patch #243 to make it only apply to the Tek Options menu.

Patch #243 - 2009/3/28

  • revert change to default for allowTcapOps (request by Bram Moolenaar).
  • reallocate result returned by xtermEnvLocale() to avoid reference to freed memory after handling menuLocale resource.
  • fix an old (X11R5) bug in tek4014 for switching fontsizes.
  • add resource defaultString to make configurable the use of "#" when pastes of UTF-8 text fail due to limitations in the current locale settings.
  • make the set of selection target Atom's configurable by two new resources eightBitSelectTypes and utf8SelectTypes, e.g., to use the TEXT Atom in preference to UTF8_STRING (discussion with Stanislav Sedov regarding koi8rxterm and the FreeBSD port).
  • modify handling of TARGETS Atom by making it return exactly the set of targets as those which xterm is currently providing.
  • set MANPAGER and PAGER explicitly to /bin/cat in minstall.sh to work around /etc/man.conf's with those variables already set (report by Марьясин Семён).
  • improve error-checking of tcap-query parser.
  • add check for keyboard tcap), which ensures that terminal descriptions containing the same string for shifted/unshifted keys will be seen by tcap-query as only the unshifted key. (This would only happen with an incorrect terminal description).
  • fix conversion for input event-state to modifier-parameter which made tcap-query feature not work with tcapFunctionKeys (keyboard type tcap).
  • add "DEF_ALLOW_XXX" definitions to main.h to allow overriding the default compiled-in values for "allowxxx" resources.
  • remove check on bell-percentage added in patch #242, which disallowed zero/negative values (Redhat Bugzilla #487829).

Patch #242 - 2009/2/15

  • fix configure check for XkbBell and provide appropriate parameter for it.
  • fix a caching problem with double-size fonts versus reverse video that could cause core dump.
  • repair double-size fonts from workaround used in patch #240.
  • add new section to the VT Fonts menu which allows enabling or disabling the font, termcap (tcap-query), title and window operations.
  • add fontWarnings resource, to control whether to show warnings on failure to load a font.
  • improve warnings for unloadable fonts introduced in patch #240 by limiting those to the cases where a font would be specified directly by a resource setting rather than a derived fontname.
  • further amend fix for Debian #252873 from patch #197 to treat a blank cell which does not have both foreground and background colored as a non-colored cell. This improves a special case where the cursor is on a blank cell which had foreground color scrolled in (report by Miroslav Lichvar).

    Also add the same logic when hiding cursor, so the outline matches the in-focus cursor.

  • modify internals to reduce places PAIRED_CHARS() is used, making WriteText() and ScrnWriteText() accept IChar array, as well as providing a wrapper for drawXtermText().
  • change default XIM font from "*" to "fixed" to improve startup time in zh_CN.UTF-8 locale (Mike Fabian, SuSE Bugzilla #464930).
  • typo in #240 log (Slava Semushin)

Patch #241 - 2009/1/26

  • improve checks for missing bitmap fonts, fallback to "fixed" as needed to work around broken font-packages (report by Jacek Luczak).
  • fix breakage from patch #240 changes for xtermAddInput() (patches by Jeff Chua, Julien Cristau).

Patch #240 - 2009/1/25

  • use plink.sh for linking xterm (suggested by Larry Doolittle).
  • add resource descriptions for input method to xterm manpage.
  • update configure script; consistently append to $CFLAGS rather than prepend.
  • add install-scripts rule to makefile, to allow koi8rxterm and uxterm scripts to be altered independently of install-bin
  • add -maximized command-line option and corresponding resource (prompted by alt.os.linux newsgroup comment).
  • modify translations of scrollbar widget using xtermAddInput() (see patch #181) to accept the actions that the vt100 widget accepts, such as shift-insert to perform a paste operation (request by Martin Zwickel).
  • change default for allowTcapsOps resource to false, since it causes unexpected behavior for vim users with AltGr.
  • update config.guess, config.sub

Patch #239 - 2009/1/8

  • correct a cast in input.c, which broke translation of numeric keypad codes to pageup, pagedown, etc., on 64-bit platform (Debian #511138, report by Larry Doolittle).

Patch #238 - 2008/12/30

  • update configure macro CF_XOPEN_SOURCE for AIX 6.x and Mint platforms.
  • reset the screen wrapping-flag at the end of ClearRight to fix an occasional case where the last character of a scrolled and wrapped line would be cleared (patch by Joe Peterson).
  • modify to use POSIX coding for comparing resource settings such as locale, to work with locales such as Turkish (report by M Vefa Bicakci).
  • turn on configure paste64 feature by default (request by Jean-Philippe Bernardy). It is runtime enabled/disabled with allowWindowOps.
  • turn on configure tcap-query feature by default, add resource allowTcapOps to make this runtime enabled/disabled.
  • make OSC 3 (change X property, from patch #110) subject to allowWindowOps resource.
  • make VT220 DSR responses inactive in VT100-mode.
  • make DECUDK feature inactive in VT100-mode.
  • respond to incorrectly formatted DECRQSS with a cancel.
  • add allowFontOps resource to allow the fontsize-switching and font query/set control sequences to be enabled/disabled (prompted by Debian #510030).
  • some code cleanup based on gcc 4.x -Wconversion warnings in button.c and charproc.c
  • modify tcap-query feature to not return data for shifted cursor-keys when the keyboard type is set to vt220, since returning the same string for shifted/unshifted keys may confuse some applications (Gentoo #212546).

Patch #237 - 2008/09/14

  • improve usability of TrueType fonts by making the font-size switching for shifted keypad plus/minus use the faceSize resources to determine the order of fonts (when TrueType fonts are used) rather than the bitmap fonts, since their sizes may not be in the same order (report by H Merijn Brand)
  • remove an optimization of ConfigureNotify events from patch #236 which seems to interfere with passing SIGWINCH to applications (Gentoo #233836).
  • modify handling of altSendsEscape to reset the eightBitInput mode, like metaSendsEscape (patch by Ted Phelps).
  • add feature to show the text-cursor as an underline rather than a box, plus command-line options -uc and +uc and resource cursorUnderLine to control the feature (patch by Paul Lampert).
  • update config.guess, config.sub

Patch #236 - 2008/07/27

  • correct memory reallocation when handling a paste of UTF-8 text from patch #225 changes (report/patch by Max Mikhanosha).
  • correct allocation of temporary buffer in xtermFindShell in case the user's $PATH contains no ":" (report/analysis by Victor Stinner, Freedesktop.Org Bugzilla #16790).
  • modify CF_XOPEN_SOURCE to add case for DragonFly BSD, to fix new compile problem exposed by fix for fd_mask (patch by Hasso Tepper).
  • add configure-check for ncurses use_extended_names, (report by Martin Mokrejs).
  • correct computation for toolbar height; layout manager already takes into account borderWidth resource.
  • implement VT320-style SCS (select character set) for ISO Latin-1 supplemental.
  • fixes for vt100-style character sets in UTF-8 mode (Ubuntu #230919).
  • fix to make luit work with xterm's -ls option (report/patch by Marius Tolzmann).
  • update config.guess, config.sub

Patch #235 - 2008/04/20

  • add control sequences for some of the recent resource/menu settings:
    • altSendsEscape (private mode 1039)
    • keepSelection (private mode 1040)
    • selectToClipboard (private mode 1041)
    • bellIsUrgent (private mode 1042)
    • popOnBell (private mode 1043)
  • add resource formatOtherKeys to provide an alternate escape sequence format for the modifyOtherKeys resource (request by Paul LeoNerd Evans).
  • adjust saved-cursor position if the window is resized while displaying the alternate screen (Novell #196880, Debian #383384).
  • improve pointer-checks to fix a bug exposed by resizing during initialization under StumpWM window manager (Fedora Bugzilla #437928).
  • modify unselectwindow() to ensure that the mouse pointer is not hidden after xterm loses focus (report by Jeremy Huddleston).
  • add special check for fd_mask on Mac OS X (report by Jeremy Huddleston).
  • add dylib to autoconf's suffix list used for checking the result from xmkmf, to work with Mac OS X (report by Jeremy Huddleston).
  • correct initialization of bold- and wide-, wide-bold fonts which may be set via the utf8Fonts subresource (Debian #347790).

Patch #234 - 2008/03/02

  • modify sinstall.sh to use POSIX locale to bypass GNU ls changes to date-format.
  • improved/refined changes for closing bitmap font (patch by Andrea Odetti).
  • improve resize computation for situations where the negotiation fails, by invoking the xterm widget's core-class resize method (Debian #365602, patch by Jim Paris).
  • restore initialization of terminal's VMIN and VTIME settings, from patch #232 changes (patch by Matthieu Herrb).

Patch #233 - 2008/02/24

  • add configure check for ttydefaults.h, include if needed, e.g., for systems where defining _POSIX_C_SOURCE, etc., prevents it from being included via termios.h (prompted by comments by Robert Delius Royar and Jeremy Huddleston).
  • bug-fixes for bugs.opensolaris.org (patches from Alan Coopersmith)
    4029911
    fix a typo in manpage
    4045962
    xterm doesn't properly set ut_syslen
    4192572
    left-left-right misinterpreted as triple click
  • minor optimization to tab-initialization (patch by Németh Márton).
  • fix a case where an incorrect font was freed during initialization from patch #232 changes (patch by Andrea Odetti).
  • improve comparison used in SameFont function for GC-caching (Julien Cristau).
  • correct macro name used for default CKILL definition to work with Mac OS X (report by Jeremy Huddleston).

Patch #232 - 2008/01/30

  • corrected logic in a font-cache used for reverse-video (Debian #404079).
  • add control sequence to alter pointerMode at runtime.
  • add limit-checks for rectangle operation parameters (report by Martin Pirker).
  • modify minstall.sh to suppress $MANPAGER and $PAGER environment variables, which may interfere with redirecting output of man to a shell variable (report/patch by Zdenek Sekera).
  • do not try to hide mouse pointer in the tek4014 window, fixes broken "-t" option at startup from patch #230 changes (report by Robert K. Nelson).
  • correct datatype used when drawing tek4014 data using xterm compiled for wide-characters, on big-endian machines (reports by Jeremy Huddleston, Harald Hanche-Olsen, Martin Costabel, Merle Reinhart).
  • modify to cache the font-names along with the bitmap font data, to improve comparison of fonts.
  • modify to allow building with configure options --disable-ansi-color and --disable-leaks (Debian #459817, report/patch by Németh Márton).
  • modify to allow building with configure options --enable-wide-chars and --disable-c1-print (Debian #459816, report/patch by Németh Márton).
  • add pointerMode resource to control whether and when the pointer cursor is hidden as the user types.
  • simplify initialization of ttyMode- and related characters using a table.
  • modify initialization-logic for stty values that correspond to ltchars structure and the BSD TIOCSLTC ioctl (susp, dsusp, rprnt flush, werase, lnext). These were reset to constants for both termios and legacy interfaces immediately after asking the system for the existing values since X11R6.1, rather than using them to provide inherited values. While the legacy interface has some constraints, e.g., on HPUX, the POSIX or termios interface should not. Your shell may reset these anyway (prompted by patch by Ed Schouten).
  • improve logic for hiding/displaying pointer-cursor (report by Mark Brukhartz).
  • add limit-checks to tabs.c, increase maximum column for setting tab-stops from 320 to 1024 (report by Németh Márton).
  • correct length, i.e., number of types of selection targets, computed by ConvertSelection() when not handling wide characters for the XA_TARGETS() case. This leaves an extra Atom on the end of the list which is not handled by Java applications. The problem was introduced in patch #151 (report by David Wood).

Patch #231 - 2008/01/05

  • undo change to getXtermCell() from patch #230 using PACK_PAIR macro (Debian #459014, analysis by Caetano Jimenez Carezzato).
  • minor documentation fixes (patch by Slava Semushin)
  • add makefile actions to install KOI8RXTerm app-defaults file (patch by Julien Cristau).

Patch #230 - 2007/12/31

  • add quietGrab resource, which when true, suppresses cursor repainting when NotifyGrab and NotifyUngrab event types are received during change of focus (request by Nicolas George).
  • do not treat Unicode BIDI control characters as combining characters (Debian #457634).
  • add koi8rxterm, from Debian.
  • add manpage for uxterm, from Debian (Ubuntu #128136, Debian #438645)
  • remove ".xpm" suffixes from Icon filenames in desktop files since it confuses some lookups following the Icon Theme Specification (report by Slava Semushin)
  • correct width-calculation used for adjusting proportional fonts, to work with wide-characters (Debian #441354).
  • fixes/improvements for double-size characters:
    • correct old clipping calculation which used total height of glyphs where ascent was needed.
    • if bold font is unavailable, fall back to normal font
    • adjust to "work" with Xft (which does not support double-width single-height characters).
    • restore reset of doublesize for a line when it is cleared, broken in patch #228.
  • modify logic for forceBoxChars resource when using TrueType fonts to be consistent with bitmap fonts
  • modify logic for forceBoxChars resource to make the "Line-Drawing Characters" menu entry use xterm's line-drawing characters even asked to draw wide line-drawing characters which are available in the font.
  • modify rectangle-support functions to preserve colors when filling/erasing to match WRQ Reflection behavior (request by Enzo Toscano).
  • add getopt-parsing to tcapquery.pl, including feature to test the extended cursor/editing keys.
  • make missing double-width glyphs display as double-width (Debian #456236).
  • change tcap-fkeys and rectangles configure options to enable them by default.
  • hide the mouse pointer while user is typing (request by Rodolfo Borges).
  • extend configure options --enable-tcap-query and --enable-tcap-fkeys to send cursor- and editing-keypad keys modified according to the keyboard (or termcap) selection for shift, alt, control, meta.
  • modify kdch1 in termcap, e.g., xterm-r6 to match the terminfo file.
  • add -hm option to turn highlightColorMode on or off.
  • add highlightColorMode resource to separate the new (since patch #225) highlighting with both text- and background-colors (prompted by report/example by Thomas Wolff).
  • add Keep Selection menu entry to turn the keepSelection resource on/off at runtime.
  • add keepSelection resource, which when enabled, tells xterm to retain the X selection even after it stops highlighting it (patch by Sergey Vlasov).
  • extend the CSI > n sequence to allow disabling all types of modified-keys that the CSI > m sequence affects.
  • move include for <xtermcap.h> in resize.c to avoid redefinition of termios structure on OpenSolaris (report by Rahul Gopinathan Nair).
  • extend terminfo building blocks for modified editing keys to include all six keys.
  • synchronize terminfo with ncurses (report by Stephane Chazelas)
    • equate xterm-xfree86 and xterm-xf86-v44.
    • add ncurses extensions OTbs, AX, for termcap conversions.
    • make old/legacy entries such as xterm-24, xterm-65 and aliases xterms, vs100 inherit from xterm-old.
    • make xterm-r5 and xterm-r6 the same, ignoring historical errors in X Consortium's version.
  • fix an ifdef in logic for selecting regular expressions while in a narrow-character locale (Debian #449227).

Patch #229 - 2007/8/12

  • override locale in minstall.sh; change in patch #226 does not work in UTF-8 locale (report by Zdenek Sekera).
  • undo an incorrect fix for a memory leak in patch #209 (Debian #435858).

Patch #228 - 2007/7/22

  • modify configure script to permit combining --with-utempter and --enable-setuid, e.g., for using xterm with the utempter library on FreeBSD (report by Andriy Gapon).
  • modify "Quit" menu entry to override the -hold command-line option.
  • add a check in the startup error-reporting to avoid writing to pipe when it has not been opened. In that case, report errors directly to the standard error.
  • add OPT_READLINE definition to xtermcfg.hin, overlooked in patch #205 (report by Kalle Olavi Niemitalo).
  • modify 88colors2.pl and 256colors2.pl, adding -r option to reverse the palettes for the extended colors.
  • check for partial overwrite or deletion of multi-column characters in several cases, e.g., insert-character, delete-character, etc., and fill the remainder of the cells used by the multi-column characters affected with blanks.
  • correct character-class codes in wide-character mode for characters 215, 247 (see also patch #165).
  • fix missing assignment for UTF-8 parsing in widget initialization (Debian #403360).
  • correct index expression used to set line-wrapping flag, making selection from scrollback work consistently (Debian #430121, report by Vincent Lefevre).
  • amend changes to handshake in patch #226 to accommodate Solaris, which relies on the extra setting of the terminal size after I/O initialization. Do this by adding new resource ptySttySize, which is false for Linux and MacOS X, i.e., true for for Solaris and other SVR4 platforms, as well as FreeBSD (reports by David Wood, Renato Botelho).
  • check for X events after cursor-left, and carriage return, consistent with indexing operations (comments by Vegard Nossum and Ingo Molnar on a mailing-list).
  • initialize the .keyboard structure, needed for some platforms (such as Solaris) after patch #227 fixes for keysyms (patch by David Wood).
  • update config.guess, config.sub

Patch #227 - 2007/6/27

  • exclude the Intel compiler from the extra gcc warning options added in patch #226.
  • modify change for Debian #422521 from patch #226 to work with configurations where the X server does not recognize the XF86Paste or SunPaste keysyms (report by Paolo Pumilia).
  • fix incorrect free in fix for "Selection" menu entry in patch #226.

Patch #226 - 2007/6/17

  • add configure check to use -Wno-unknown-pragmas for Solaris, and a few other new gcc warning options to address regressions in its warning options.
  • add sample desktop and icon files, along with configure options for manipulating them.
  • fix an infinite loop when showing a 2-column character in a 1-column screen (Debian #426863).
  • add XF86Paste and SunPaste to the default translations (Debian #422521, patch by Bernhard R Link).
  • update wcwidth.c (partly based on/prompted by mailing list comment).
  • update/improve keysym2ucs.c based on Unicode 5.0.1d3 and Xorg 7.1 keysymdef.h file.
  • improve gen-pc-fkeys.pl, making it show all of the building-block terminfo entries used by xterm.
  • correct strings used for modifiers applied to F1-F4 in xterm+pcf1 terminfo entry.
  • improve session management by adding the ICE connection number to the select call rather than waking up once per second (patch by Miroslav Lichvar).
  • add environment variable $XTERM_LOCALE to help with shell initialization, e.g., to set a specific locale for xterm on systems where a global locale is set in the shell startup scripts.
  • add resource settings mkSampleSize and mkSamplePass to modify the mkWidth added in patch #201. In patch #202, xterm would also check if the system's wcwidth matched its built-in tables "well enough" to be used when mkWidth was false, and if not would use the built-in tables anyway. These resources allow the user to customize the decision (prompted by comments by Emanuele Giaquinta)
  • modify logic which resets/updates the screensize on the child process side of the pseudo-terminal to do this only if a successful handshake was received, e.g., as determined by the waitForMap resource (prompted by reports by Emanuele Giaquinta and Bernhard R Link, but see also patch #177 and patch #159.
  • improve permissions logic when closing pseudo-terminal (Debian #12261, patch by Nathanael Nerode, analysis by Richard Braakman).
  • add resource highlightReverse which controls whether xterm will allow selection highlighting to hide reverse-video or use the older behavior which inverts the foreground and background colors when selected text with reverse-video attribute (report by Adam M Costello, comments by Victor Vaile).
  • restore a special case for cursor-color in ReverseVideo() lost in rewrite for patch #224 (report by Adam Sulmicki).
  • correct initialization for menu entry for bellIsUrgent (patch by Emanuele Giaquinta).
  • correct length of underlining for double-width Xft fonts (report by Shidai Liu "Leo").
  • correct clipping for double-width Xft fonts (report by Shidai Liu "Leo").
  • modify initialization for italicULMode to avoid XftPatternBuild reusing bold attributes (report by Shidai Liu "Leo").
  • add a check in case someone tries to call the popup-menu() action on a menu which is not initialized (Debian #426364).
  • improve CF_IMAKE_CFLAGS to work with Solaris sed (report by Peter Bray).
  • improve guess for X's manpage section in minstall.sh, (prompted by comment by Miroslav Lichvar).
  • modify minstall.sh to handle manpage patch with more than one dot (patch by Miroslav Lichvar).
  • fix configure message for --disable-setgid option (patch by Miroslav Lichvar).
  • add allowTitleOps resource to allow users to prevent the title- and icon-names from changing (request by John Bashinski).
  • fix "spawn-new-terminal" action, for the case where no parameter is passed to the action (patch by Daniel Colascione).
  • fix error-checking on internal font switching for "Selection" menu entry (Debian #421523).
  • amend select/paste change from patch #225 by limiting it to non-UTF-8/non-KOI8-R encoding (Debian #420974).
  • add workaround for groff ".URL" codes which are not present in some commonly-used bitmap fonts (Debian #418324).

Patch #225 - 2007/3/24

  • add useClipping resource to allow clipping to be disabled.
  • use XftDrawSetClipRectangles to work around Xft pixel-trash (report by Reuben Thomas).
  • add configure option --enable-tcap-fkeys, and resource tcapFunctionKeys, which can be used to tell xterm to use function-key definitions from the termcap (or terminfo) which it uses to set $TERM on startup.
  • add resources altIsNotMeta and altSendsEscape to allow one to use Alt-keys like the meta-key even if they are bound to different keycodes (prompted by discussion with Daniel Jacobowitz).
  • revert a change from patch #216 that unnecessarily made the meta modifier override the eightBitInput resource if the alt- and meta-modifiers happened to overlap (report/patch by Daniel Jacobowitz).
  • correct associated font for active icon for colored text (broken in patch #224).
  • correct ifdef's for Darwin (patch by Emanuele Giaquinta).
  • add highlightTextColor resource, and options -selfg, -selbg like xwsh (adapted from patch by Victor Vaile).
  • revise find_closest_color() function to address concern about borrowing from Tcl/Tk (request by Dan McNichol).
  • add "spawn-new-terminal" action, which can be assigned to key translation, allowing one to spawn a new copy of xterm using the current process' working directory (adapted from patch by Daniel Colascione).
  • improve select/paste between UTF-8 and Latin1 xterms by adapting the translations from patch #185. Extend that to include Unicode fullwidth forms FF00-FF5E. Also modify select/paste of DEC line-drawing characters in Latin1 mode to use ASCII characters.
  • add "Enable Bell Urgency" to VT Options menu, removed "Enable Margin Bell".
  • add bellIsUrgent resource to control whether the Urgency hint is set/reset.
  • modify to set Urgency window manager hint on bell, reset it on Focus-In event (patch by Emanuele Giaquinta).
  • add --disable-setgid configure option (request by Miroslav Lichvar).
  • fix a possible infinite loop in last change to dabbrev-expand() (patch by Emanuele Giaquinta).
  • modify initialization to set the pty erase value if the erase is set in the ttyModes resource. This overrides the ptyInitialErase setting (request by Lluís Batlle i Rossell).
  • add initialFont resource to xterm widget, like tek-widget (Debian #299669).
  • amend change to boldMode from patch #223 for Debian #347790. As noted in Debian #412599, that made xterm no longer match the documented behavior. Add new resource alwaysBoldMode to allow overriding the comparison between normal/bold fonts when deciding whether to use overstriking to simulate bold fonts.
  • restore background color in ClearCurBackground(), omitted in changes for patch #223 (report by Miroslav Lichvar).
  • correct logic for repainting double-width TrueType characters (prompted by test-case for Novell #246573).
  • add a check to avoid trying to repeat a multibyte character (report by Sami Farin).
  • modify parameter to XftNameParse() to select wide face-name as needed, to make -fd option work (patch by Mike Fabian, Novell #246573).
  • correct logic for mouse highlight tracking's abort sequence, broken in a restructuring modification from patch #224 (report by Thomas Wolff).
  • revert the simplification of blinking cursor, since that broke the xor'ing introduced in patch #193 (report by Thomas Wolff).

Patch #224 - 2007/2/11

  • simplify code for set/reset mode for blinking cursor (patch by Emanuele Giaquinta).
  • modify dabbrev-expand() to restart after the last match (patch by Emanuele Giaquinta).
  • add control sequences for enabling/disabling focus in/out event reporting (request by Bram Moolenaar).
  • improve startup performance of menus by adding resource setting menuLocale which can be set to override X's lengthy initialization of fontsets - which are seldom used for the Xaw popup menus (adapted from patch by Dave Coffin).
  • modify do_precomposition() function and make-compose.sh to handle 21-bit codes vs the 16-bit codes those were written for, and fix a few mis-sorted codes (patch by Thomas Wolff).
  • handle special case in -cjk_width which unexpectedly caused a character's width to change when a combining character (patch by Thomas Wolff)
  • fix build for GNU/KFreeBSD (Debian #40111).
  • consolidate GC creation/updating into a single module to reduce GC manipulation (prompted by Debian #389476, though a complete fix would involve optimizing the scrolling behavior).
  • fix ifdef of xtermCellWidth(), which broke for a case without TrueType and without wide-character support (report by Martin Pirker).
  • undo a comparison in handle_translated_exposure which did not work due to X server optimization. That caused the inner border to be repainted with unexpected colors when handling a repaint, e.g., after switching to/from another workspace (Debian #401726, Redhat Bugzilla #223027).
  • allow -cr option to override cursor color when -ah option is used (Debian #406502).
  • add a note in xterm's manpage explaining that the -bw (or -w) option is only used by the window manager, if at all (Debian #405043).
  • make Selection of VT Fonts work with selectToClipboard resource.
  • correct length calculation for Selection entry of VT Fonts menu, broken since it ignored the actual selection length since X11R4.
  • fixes for fontsize changes with -fa option (Redhat Bugzilla #222340).

Patch #223 - 2006/11/30

  • add --enable-rectangles configure option (request by Martin Pirker).
  • correct default value for --with-symlink configure option.
  • fixes configure script macros that use $X_EXTRA_LIBS.
  • modify configure script to provide support for pre-package config versions of Xft aka "FreeType".
  • add the Xaw scrollbar translations resource to the xterm manpage, add an example showing how to change the mouse button assignments (Debian #382225).
  • amend a change from patch #216, which omitted modifiers for control, meta, etc., if they were mixed with any other modifiers. The intent of the change was to avoid confusion with XK_Mode_switch and XK_ISO_Level3_Shift; the check is now done explicitly (report by Daniel Jacobowitz).
  • interpret a negative value for modifyCursorKeys or modifyFunctionKeys resources to disable the respective features (prompted by Novell #220728).
  • amend cell-width computation for FreeType from patch #217, which did not work for VT100 line-drawing characters (Debian #399638, Gentoo #147111).
  • amend a change from patch #216, which made alt-modifier on a cursor-key send a modifier parameter (Novell #220728).
  • correct an off-by-one that made DECCRA not work (report/patch by Martin Pirker).
  • revert an optimization in SGR_Foreground() and SGR_Background from patch #209 (Debian #347722, analysis by Pierre Lombard).
  • fix for boldMode (Debian #347790, patch by Tim Pope).
  • amend fix for -iconic in patch #208, which broke the positioning part of -geom with toolbar configuration.
  • fix to prevent indexing error in regular expressions (patch by Dennis Schneider).
  • fixes to make the internalBorder area not change color due to reverseVideo and/or related exposure events. The latter was a very old bug exposed in patch #196 (report by Neil Hoggarth, also Debian #397624).

Patch #222 - 2006/10/17

  • minor optimization for recoloring cursor via dynamic colors.
  • fix a bug caused by restructuring of tek4014 widget (report by Paul Schenkeveld)

Patch #221 - 2006/10/1

  • fix for regular expressions: the code which converted the column offset within a line did not check properly for the end of a line, and if allowed to match the whole line, would select the beginning of the following line. If the following line were empty, in turn it would select from the next, etc. (report by Sean Reifschneider).
  • minor optimization of color allocation to avoid repainting the screen if the corresponding color had not been allocated.
  • fixes for vttests/256colors.pl (report by Egmont Koblinger).
  • add terminfo building block entries for modifiers of the 6-key editing keypad.
  • fix for initialization of tek4014 which broke on QNX 6.1

Patch #220 - 2006/9/10

  • make "xterm -t -iconic" work as expected, i.e., start in tek4014 mode, but iconified.

Patch #219 - 2006/9/4

  • some internal restructuring to separate data for vt100 and tek4014 widgets.
  • fix a few cases where form-events would be seen by the vt100 widget when built with the toolbar configuration.

Patch #218 - 2006/8/27

  • change behavior when encountering an illegal character in a title string. Rather than reject the string, translate illegal characters into "?" and use the string (requested by Thomas Wolff).
  • improve checks for nonprinting characters in title strings (report by Samuel Thibault).
  • correct typo in menu labels, changing print-redirect to print-redir, making it follow the manpage and match the usage for the actions table (report by Samuel Thibault).
  • correct a typo that prevents building with some older systems such as Solaris 2.6 (report by Julian Bridle).

Patch #217 - 2006/8/20

  • minor improvements to FreeType font layout and drawing.
  • add a check in the ptyInitialErase logic to ensure that the termcap was read (Redhat Bugzilla #201246).
  • limit changes for reverse-video from patch #216 to cases where the reverse-video command-line option is used (report by Zdenek Sekera).
  • correct bitmap-derived pointsizes for TrueType fonts; they should be proportional to the square root of the area of the bitmap fonts.
  • add resources to specify pointsize of TrueType fonts (request by Reuben Thomas).
  • improve install of terminfo by filtering out harmless messages related to extended capabilities. At the same time, use ncurses tic to compile the extended capabilities if possible (report by Zdenek Sekera).
  • update "xterm+pcfkeys" terminfo entry to correspond to patch #216.

Patch #216 - 2006/8/3

  • improve handling of ConfigureNotify events by checking if there are further events in the queue which obsolete the current one (adapted from rxvt 2.7.5). Only the normal normal (non-toolbar) configuration is addressed in this patch.
  • several changes to terminfo:
    • incorporate some minor changes from ncurses to help keep these synchronized:
      2005-02-26
      modify sgr/sgr0 in xterm-new to improve tgetent's derived "me".
      2006-02-18
      remove ncv flag from xterm-16color
      2006-06-24
      improve xterm-256color by combining the 16-color setaf/setab strings with SGR 48, and cancelling the setf/setb strings.
    • use extended function-key definitions for xterm-sun, xterm-sco entries.
    • add terminfo building-blocks corresponding to the modifyFunctionKeys and modifyCursorKeys resources.
  • ifdef'd Sun function-key feature to make it optional, like HP and SCO.
  • extend table for termcap-query feature through F63, and updated tcapquery.pl to match.
  • modify logic for function-key input processing to allow function key numbers which are constructed by control- and shift-modifiers to extend beyond X's hardcoded limit of 35.
  • add control sequence to set or reset the eightBitInput resource.
  • change default resource modifyFunctionKeys to 2 to avoid sending SS3 with parameters (report by Kalle Olavi Niemitalo).
  • add control sequences for setting and resetting the values of the modifyCursorKeys, modifyFunctionKeys and modifyOtherKeys resources.
  • add modifyFunctionKeys resource like modifyCursorKeys. Setting this to zero allows one to use the control- and shift-modifiers to construct function key strings, for terminals using many function keys, e.g., for xterm-sun or xterm-sco.
  • modify screen responses and function-key logic to reduce the number of writes made, to make it less likely that an application would read only part of a function-key in a read operation (suggested by John E Urbanczyk).
  • add combiningChars resource, which allows the user to specify the maximum number of combining characters that xterm will store for each cell in wide-character mode (prompted by request by Markus Kuhn to increase the limit from 2).
  • improve logic in metaSendsEscape in case the Alt- and Meta-keys are mapped to different modifiers. That allows one to use the Alt-key for shifting in the eightBitInput and use a Meta-key modifier to prefix the result with an <ESC>.
  • improve modifyCursorKeys logic to prevent it from modifying codes where eightBitInput or metaSendsEscape are set (request by Dan Nicolaescu).
  • improve modifyCursorKeys logic to prevent it from changing the user input when other modifiers such as AltGr are used (report by Thomas Wolff).
  • extend modifyCursorKeys to include the numeric keypad when in application mode.
  • improve -reverse (-rv) option (patch by Jason Vas Dias, Redhat #189161).
  • workaround for color resources on Fedora-5 which made the toolbar colors inconsistent.
  • corrected calls used for --disable-setuid option, add debugging traces to help diagnose this area.
  • modify configure script to ensure that USE_UTMP_SETGID is defined only if the check for POSIX saved-ids succeeds, or corresponds to one of the BSD systems known to have a workable setegid function.
  • extend configure check for POSIX saved-ids to include BSD systems
  • modify CF_SYSV configure macro to work with gcc on HPUX 10.20, whose broken <term.h> relies on including <termios.h>.
  • change order of setuid/setgid ifdef checks in Imakefile to make it simpler to produce a setgid install, allowing the latter to override the former (prompted by an XFree86 commit).
  • adapt a fix for setgid support from subsequent XFree86 changes (patch by Emanuele Giaquinta).
  • further improve setgid support (patches by Emanuele Giaquinta).

Patch #215 - 2006/6/19 - XFree86 4.6.99.2

  • improve setgid support by exploiting the saved-ids feature on which it relies (patch by Emanuele Giaquinta).
  • make the modifyOtherKeys resource disabled by default since the intermediate setting altered some common bindings (report by Emanuele Giaquinta).

Patch #214 - 2006/6/18 - XFree86 4.6.99.2

  • modify makefile rule for ctlseqs.txt to strip backspace/overstrikes, and add a copy of ctlseqs.txt to the source tarballs (requests by Bram Moolenaar, Emanuele Giaquinta).
  • add modifyOtherKeys resource, analogous to the modifyCursorKeys resource. This applies to keys that normally would transmit nothing when a given modifier is applied (request by Dan Nicolaescu).
  • add default to the acceptable values for the keyboardType resource, allowing the -kt command-line option to override app-defaults resource settings of sunKeyboard, etc.
  • correct ifdef's for XkbBell() which used the header file but not the corresponding function in patch #175 (report by Zach Beane).
  • add xterm manpage to the --with-symlink logic.
  • regenerated configure script to omit some debugging artifacts of the SIGWINCH test.
  • fix install-man rule in Makefile.in to avoid including the $(DESTDIR) value in substitutions made on the manpages (patch by Emanuele Giaquinta).
  • improved fix for cursor deallocation (Redhat #186935, patch by Jason Vas Dias).
  • improve checks for setuid/setgid operation to accommodate limited resource management in some kernels (Gentoo #193238).
  • update config.guess, config.sub

Patch #213 - 2006/4/30 - XFree86 4.5.99.905

  • minor optimization to cell layout; will use that to simplify some logic and allow for more than two combining characters in another patch.
  • add utf8Latin1 resource to make optional the feature from patch #209 which allowed ISO-8859-1 fonts to be used in cases where a wide font was given. This would only work for the special case where the user normally used Latin-1 and wanted some wide characters (report by Rostislav Krasny).
  • add utf8Title resource to manpage (Novell #52655).
  • fix typo in table entry for utf8Title resource which made it treated as an integer rather than boolean (patch by Mike Fabian, Novell #52655).

Patch #212 - 2006/4/9 - XFree86 4.5.99.904

  • improve description of forceBoxChars in manpage (discussion with Joe Wells).
  • set checkmark for "Select To Clipboard" menu entry on startup, from resource setting.
  • update manpage to note that *customization:color is not needed, though it is useful (Redhat #188034).
  • add underscore to sample pattern for URL in XTerm.ad (Redhat #188037).
  • modify install rule for manpage to use the configured app-defaults directory (Redhat #188031).
  • add checks in releaseCursorGCs() to ensure GC's are distinct, needed since memory leak changes for patch #208 (Redhat #186935, patch by Jason Vas Dias).
  • modify Imakefile definitions to allow imake to set InstallXtermSetGID. Add symbol InstGidFlags.
  • add configure script check to ensure that SIGWINCH if defined even when headers undefine this as a side-effect of _POSIX_C_SOURCE, etc.
  • resync with XFree86 CVS
    • ifdef-out chmod of terminal device for OS/2 (XFree86 #1663, Frank Giessler).
    • move new Imakefile chunk which defines $(CSGIDFLAGS) before DEFINES, e.g., for IRIX64 (Marc La France).

Patch #211 - 2006/3/19 - XFree86 4.5.99.902

  • modify prefix/suffix transformation in makefile to make uxterm install properly on Cygwin.
  • restore the sizeof-comparison for struct lastlog added in patch #208, rendered (mostly) obsolete in patch #210, since an imake configuration can still turn that code on (prompted by comment by David Dawes).
  • remove feature for FreeBSDArchitecture from Imakefile which would install xterm using the utmp group since a standard FreeBSD system has no such group, though it would support this configuration. FreeBSD packager uses the configure script, which can make the appropriate check (prompted by comment by David Dawes).
  • fixes for gcc redefinition warnings when built using imake (reports by David Dawes, Marc La France).

Patch #210 - 2006/3/12 - XFree86 4.5.99.902

  • add configure check for workaround in patch #208 for Solaris' inconsistent support for struct lastlog to quiet compiler warnings (prompted by David Dawes commit message for XFree86).
  • fixes for BASE64 selection manipulation, e.g., ensure that the string terminator is written after cut-buffer data (report by Joe Allen).
  • add vttests/paste64.pl script to test experimental option for setting/getting selection data.
  • add some error-checking in fontutils.c (prompted by David Dawes commit message for XFree86).
  • change xterm manpage to show the actual color resource names XtDefaultForeground and XtDefaultBackground rather than black and white (prompted by discussion with Emanuele Giaquinta).
  • add utf8Title resource and menu entry, allowing the user to control whether title strings are interpreted as ISO-8859-1 or UTF-8 encoding (Novell #52655, Novell #113206).
  • change order of ifdef's for utempter versus platforms in Imakefile to ensure a proper value for InstallXtermSetGID (prompted by Marc La France commit message for XFree86).
  • update the cursor GCs when menu entry for reverse video is toggled. (Redhat #183993).
  • a memory-leak fix for set_cursor_gcs() in patch #208 broke the -cm option (Redhat #182382).

Patch #209 - 2006/2/12 - XFree86 4.5.99.22

  • remove setf and setb from xterm-256color terminfo entry to avoid issues with applications that ignore the ANSI strings (report by Emanuele Giaquinta).
  • remove obsolete references to "Xorg" to avoid confusion with "X.org" (prompted by David Dawes commit message for XFree86).
  • improve initial layout performance for the toolbar configuration by precalculating the height of the toolbar.
  • remove menu entry for "Enable Curses Emulation" (to make room for "Select To Clipboard").
  • add resource selectToClipboard, action set-select and a menu entry to allow users to switch between PRIMARY and CLIPBOARD for select/paste.
  • allow cursor to have the same color as foreground (text), since it is rendered as reverse (Debian #350664).
  • amend change for loading utf8Fonts resource from patch #204 to allow an ISO-8859-1 "normal" font to be combined with an ISO-10646 font if the latter is given via the -fw option or its corresponding resource value (prompted by comment in Novell #49305).
  • add TIOCSCTTY ioctl() ifdef'd for __GNU__ to set the controlling terminal (Debian #348457).
  • add configure option --disable-leaks.
  • add a check in Bell to ensure that the VT100 widget is realized, since it may be called by xtermLoadFont given an incorrect font resource (Redhat #180450).
  • improve initialization of wide-bold font by not using the derived value when it happens to have few glyphs (report by Mboso Sampson).
  • improve dynamic colors by not repainting the screen if only the cursor color changes (request by Bram Moolenaar).
  • fix menu initialization for tek4014 window broken in patch #206.
  • typo in manpage (Debian #351425).
  • correct loop logic in dotext to prevent an infinite loop if a wide character was just at the right margin when wrapping was disabled (report by Serge van den Boom).
  • initialize the saved-cursor data so a restore-cursor operation without a preceding save-cursor operation will not modify the foreground color.
  • add a new selection feature: regular expressions, and new resources which specify what happens on multiple mouse clicks: on2Clicks, on3Clicks, on4Clicks and on5Clicks.
  • revert the XTerm.ad change from patch #208 (Debian #348384).
  • fixes for the print-window to make it handle combining characters in UTF-8 mode.
  • add check to ensure that double-clicking to extend selection will not extend it into the scrollback area. This still allows users to scroll back and select text (Debian #347415).
  • add configure option --with-tty-group to help work around deficiencies in packager's build environment (Debian #349142).
  • fix typo in configure script option --disable-narrowproto (report by David Martínez Moreno).
  • amend CF_X_FREETYPE changes for pkg-config check to ensure that Xft is known to that tool (report and patch by Emanuele Giaquinta).
  • add an ifdef to allow ./configure --disable-active-icon to work, broken by new code for testing memory leaks in patch #208 (report by Brian Lindholm).

Patch #208 - 2006/1/3 - XFree86 4.5.99.19

  • add charClass resource to XTerm.ad and UXTerm.ad which simplifies selecting URLs (prompted by Kirill Ponomarew).
  • modify install rule for uxterm to account for the --program-prefix, etc., options by invoking the transformed name of xterm rather than simply "xterm".
  • modify configure --with-app-defaults option to allow --without-app-defaults.
  • add configure --with-symlink option to make it simpler to install successive versions of xterm renamed using the --program-prefix, etc., options with a symbolic link pointing to the most recent.
  • make -iconic option work with toolbar configuration (Gentoo #113604).
  • suppress lastlog feature for 64-bit Solaris configuration since that platform provides only a 32-bit interface (report by Peter Bray).
  • fix memory reallocation for the "UTF-8" menu entry when xterm is started using the +u8 option (reported by Jan Willem Stumpel).
  • add a configure check for the actual path of luit, to work around broken imake configurations.
  • add a configure check for pkg-config (Redhat Bugzilla #173541).
  • modify install-rule for uxterm to omit executable suffix, e.g., for Cygwin.
  • modify sinstall.sh to work around quirks in Cygwin configuration.

Patch #207 - 2005/11/13 - XFree86 4.5.99.16

  • enable lastlogx support for NetBSD (was added, but not enabled in patch #186).
  • work around broken lastlog.h in glibc 2.3.5, which includes utmp.h.
  • revert part of recent XFree86 Imakefile change, restoring the -I. needed for xmkmf builds of xterm (XFree86 Bugzilla #1633, reports by Alexander Pohoyda, Matthieu Herrb).
  • change compiled-in default for printerCommand resource to an empty string. People who want to use the printer should be able to read the manual (Debian #311490).
  • modify Imakefile to work around old problems in imake configuration to allow test-builds using xmkmf on Linux. (This was not noticed since several releases had broken definitions relating to Xft which were harder to work around).
  • link resize for SCO platforms (Kean Johnston).

Patch #206 - 2005/11/3 - XFree86 4.5.99.15

  • add configure --with-app-defaults option to allow app-defaults directory for install-rules to be customized.
  • remove default translations for dabbrev-expand() due to conflicts with existing keyboard arrangements.
  • remove redundant check for _NET_WM_PID (report by Emanuele Giaquinta).
  • set icon border width explicitly to work around fvwm problem with active icon resizing (report by Steve Morris, analysis by Dominik Vogt).
  • modify resource files to make the font-resources a little more specific, e.g., changing "*VT100*" to "*VT100.", to make the distinction between VT100.font and VT100.utf8Fonts.font sharper, in case a packager modifies one of those.
  • expanded comments in UXTerm.ad regarding the font resources (Debian #319179).
  • add --enable-narrowproto configure option to accommodate X.org "modular" build (report by Stephan Hermann, Gentoo #17220).
  • fix typo in xterm.man description of +wf (patch by Tobias Stoeckmann).
  • add scrollBarBorder resource (request by Floyd L Davidson).
  • modify xterm-new terminfo entry to use capabilities for shifted scroll forward/reverse as shifted cursor up/down.
  • correct updating of checkmark for toolbar entry in popup menu (report by Emanuele Giaquinta).
  • fix ifdef's to allow compiling with toolbar and without tek4014 (patch by Emanuele Giaquinta).
  • use openpty() for Darwin port (patch by Emanuele Giaquinta).
  • fix Gentoo #90697 a different way, postponing the logic in SetupToolbar until the toolbar is actually needed, i.e., the +tb option is handled as expected.
  • revert fix made in patch #203 for Gentoo #90697. That introduced a problem with the control mouse click-popups, while most of the performance problems can be resolved by restricting the menu fonts (report by Emanuele Giaquinta).
  • fix a file-descriptor leak when calling openpty() (OpenBSD system/4561).
  • make a special case of resizing work like vt100: a hard reset also resets the 132/80 mode. The code to support this was present since X11R5, but not used because the corresponding initial state of the -132 option was not saved.
  • restore window manager hints after XtMakeResizeRequest() calls. One instance from patch #205 resulted in the window manager displaying pixels rather than than characters after selecting a different font size (FreeBSD ports/87424).
  • remove special case for Darwin in CF_XOPEN_SOURCE (Emanuele Giaquinta).
  • modify parsing of control sequence CSI T to allow scroll-down to be sent while mouse tracking is enabled (request by D Hugh Redelmeier).
  • correct termcap "me" (mode-end) string so it does not modify the alternate character set (report by Andrey Chernov).
  • correct size-comparison in HandleInterpret() broken in changes from patch #201 to allocate input buffer (Debian #334317).
  • amend adjustments for scrollbar layout from patch #204 to make this apply only to the toolbar configuration. In the non-toolbar configuration, the resulting scrollbar was shifted by its borderwidth (report by Matthieu Herrb).
  • add select-cursor-extend() action.
  • fix some broken href's in xterm.log.html, and typo in the INSTALL file (report/patch by David Martínez Moreno).
  • modify Imakefile to use setgid mode for installing with Linux, OpenBSD and FreeBSD.
  • add configure --with-setuid and --with-reference options to allow packagers more flexibility in customizing install permissions.
  • generalize and make optional (configure --with-utmp-setgid) the change made for XFree86 Bugzilla #878 in patch #205 (FreeBSD bug report #ports/86663).

Patch #205 - 2005/9/18 - XFree86 4.5.99.12

  • correct a typo in CF_FUNC_TGETENT introduced in patch #198 fix for Gentoo #69926.
  • implement logic in termcap query to process multiple parameters as documented in ctlseqs.ms
  • fix buffer size used for termcap query, which was not long enough for the terminfo "colors" name (patch by Bradd W. Szonye).
  • add configure option --enable-readline-mouse, which turns on the experimental OPT_READLINE code (patch by Ilya Zakharevich).
  • for FreeBSD, drop setuid privileges after startup (XFree86 Bugzilla #878, report/patch by Alexander Pohoyda)
  • add menu entry (alt-esc) and corresponding action (alt-sends-esc) to toggle the eightBitInput resource setting.
  • generate configure script with autoconf 2.52 (patched) to use the feature therein which forces the script's locale to POSIX (Gentoo Bugzilla #105369).
  • modify computation of rows/columns on resize to avoid extending beyond the given limits, e.g., if resizing in response to a "maximize" in Gnome or KDE which do not use the window manager hints for this case (Debian #289123, Novell #61153).
  • modifications to work with z/OS 1.4 (Paul Giordano).
  • improve error-reporting when chown/chmod of the pseudo-terminal fails, e.g., if a copy of xterm which was designed to work with old-style pseudo-terminals is not installed setuid or setgid (report by Jeremy C. Reed).
  • patches from Emanuele Giaquinta:
    • ctlseqs.ms says that primary and secondary DA accept a nonzero parameter, which is incorrect. Also modify code to agree with this.
    • correct a comment in 88colres.pl
    • ctlseqs.ms says that the DEC Set/Reset control sequences for the backarrow key make it send DEL/BS, respectively, while it's the opposite.
    • update the menu entries for the metaSendsEscape, deleteIsDEL and numLock resources when changing them with the corresponding DEC Set/Reset control sequences.
  • fixes for configure script:
    • add special case for QNX, defining _QNX_SOURCE.
    • check for preprocessors which do not perform -U and -D options in the given order.
    • improve macro to determine gcc version
    • improve check for Intel compiler and related warning options
  • update config.guess, config.sub
  • improve fix from patch #198 for Cleanup() by ensuring it is not called from the SIGCHLD handler (patch by Todd Miller (OpenBSD CVS)).
  • eliminate a retry for a better-matching bold font, to work around recent font server changes.
  • fixes for Novell #113277:
    • specify weight for wide font which may be derived from normal fontname.
    • cache the derived wide- and widebolt-fontnames.
  • workaround for Gentoo Bugzilla #100728.
  • add menubar's border width to layout computation. Normally this is zero, but patterns such as XTerm*borderWidth:1 would give poor layout for the toolbar configuration.

Patch #204 - 2005/8/4 - XFree86 4.5.99.9

  • work around quirk in shell which allowed user to "run" uxterm script when there was no UTF-8 locale installed by entering "sh -x uxterm". Also popup an xmessage to show the problem for users who run this via a GUI (Debian #318513).
  • disallow changes to fonts, toolbar and scrollbar when the vt100 window is iconified, to simplify management of the active icon.
  • fixes to make -geom option work properly with the toolbar configuration (Gentoo #90717, Gentoo #91967).
  • minor improvements to scrollbar layout: ensure that the scrollbar border is zero if the vt100 border is zero.
  • improve initialization due to utf8 resource by loading the utf8Fonts resource in the case where locale resource is false. Also in this case, do not disable switching UTF-8 mode on/off.
  • minor optimization of TrueType font-loading, loads italic font only when needed.
  • correct variable used to store temporary result from lookup of bold font, when initializing the wide-bold-font data and no immediate match is found by asking for a bold variant of the wide-font. The result was to use overstriking rather than the actual bold font (Debian #318162, patch by Eugene Konev).
  • add checks to ensure vt100 widget is realized when it might be updated via actions handled from a tek4014-only configuration.

Patch #203 - 2005/7/6 - XFree86 4.5.99.7

  • modify initialization of allowSendEvents and allowWindowOps to prevent modification with the editres protocol.
  • fix compiler warning for NetBSD by including util.h in main.c (XFree86 Bugzilla #1596).
  • fix to build on Darwin 8.x, which no longer provides setpgrp() (patch by Min Sik Kim).
  • adapted fixes for Legend (SCO) from diffs attached to Freedesktop.Org Bugzilla #3180.
  • fix typo in xterm manpage description of -ls option (Freedesktop.Org Bugzilla #3543).
  • add support for interpreting the underline attribute as an italic font in Xft mode (patch by Chuck Blake).
  • improve initialization of toolbar so that individual pulldown menus are initialized on demand, as they are in the scenario where they are invoked as popup menus (Gentoo Bugzilla #90697).
  • fix logic in find_utmp, which did not reset result in getutid(), causing an infinite loop in some conditions (report by Emil Mikulic).
  • set the _NET_WM_PID property (Gentoo Bugzilla #91008).
  • modify ifdef's in ptyx.h and xterm_io.h to build with DragonFly (patch by Jeroen Ruigrok).
  • change default values for minBufSize and maxBufSize to 4096 and 32768 respectively so that the initial read request will match the value from before changes to use sched_yield().
  • make paste of UTF-8 faster for Western character sets by checking range of incoming data (patch by Joe Allen).
  • add experimental option to allow applications to get or set the selection data as a BASE64 string (adapted from patch by Joe Allen).
  • fix an off-by-one error parsing -S/nn option (Debian #311438, report/fix by Peter Chubb).
  • fix an initialization bug from patch #201 that broke logging (report by Rodney Thayer).
  • amend change to command-line processing in patch #201 to avoid conflict with -e option (report by Servatius Brandt).
  • suppress configure check for _XOPEN_SOURCE on darwin.
  • update config.guess, config.sub

Patch #202 - 2005/5/2 - XFree86 4.5.99.3

  • add extended shift- and control-modifier cursor keys to "xterm+pcfkeys" terminfo entry to correspond to ncurses 20050430 patch.
  • fix a rare case where text would be written with the wrong colors because output of scrolled text would reset the colors and the new text would be written with the same colors (report/testcase by Thomas Glanzmann).
  • rename $CMD variable in plink.sh because it is a reserved symbol in bash 3.00.16 (report by Ted Taylor).
  • add environment variables $XTERM_SHELL and $XTERM_VERSION (request by Zdenek Sekera).
  • corrected workaround for background color of menubar, which gave a too-broad expression, coloring the background of the VT100 widget unless overridden by another resource setting.
  • correct an error in the logic which decides when sched_yield() is run; it would occasionally hang when contending with other pseudo-terminal applications such as screen (report by Kirill Ponomarew).
  • modify initialization to decide whether to default to built-in wcwidth() versus system's version based on the starting locale and whether the system's version is poor quality (suggested by Bram Moolenaar).
  • update table for mk_width() from UnicodeData 4.1.0 using Markus Kuhn's uniset script.

Patch #201 - 2005/4/21 - XFree86 4.5.99.2

  • improve resource files to show how the menubar and popup menus can be colored (prompted by report by Joe Wells).
  • modify parsing of OSC (and SOS, etc), strings so their contents are not interpreted as UTF-8. This allows non-ASCII title strings to be set, provided that the window manager complies (report by Thomas Wolff).
  • improved some of the built-in line-drawing glyphs.
  • correct color of "box" character drawn for line-drawing glyph 1 (report by Nicolas George).
  • improve behavior when switching to UTF-8 mode after startup so xterm will check if the current fonts are already wide (ISO10646-1). If they are not, xterm will use the utf8Fonts subresource to load appropriate fonts (request by Bram Moolenaar).
  • modify logic for setting title-string so it applies to the current widget rather than the vt100 widget.
  • modify initialization for wide-bold fontname, to search for one if none is given (report by Michael Schroeder).
  • add resource mkWidth and command-line option -mk_width to control whether xterm uses the built-in version of wcwidth().
  • add resource settings for minimum/maximum input buffer size, and call to sched_yield to improve performance with newer Linux kernels (adapted from patch by Nicolas George).
  • correct computation of width for wide characters with the invisible attribute (report by Thomas Wolff).
  • modify interaction between +u8 and locale resource to allow the command-line option to override the resource (requested by Thomas Wolff).
  • add a limit check for scrolling margins in a one-line screen, overlooked in fixes for patch #198 (Debian #297430).
  • correct treatment of iconBorderWidth for resizing an active-icon, and its description in manpage (Debian #296592).
  • modify configure script --disable-imake to use the script's definitions anyway if it cannot detect imake (prompted by FreeBSD bug 77408).
  • ignore error in the I/O initialization that tries to set the tty to 7-bit input for the case where eightBitInput resource is false (Debian #298551).
  • modify command-processing to accept an optional parameter that tells xterm which shell program to use (request by Zdenek Sekera).
  • add simpler resource keyboardType which, when set, overrides the individual keyboard-type resources and eliminates the possibility of conflict between them.
  • add initialization for scoFunctionKeys resource (report by Rick K).
  • correct logic of ReallocateBufOffsets() which did not copy the content of the old screen buffer to the proper location, making a repaint clear after switching to wide-character mode (report by Bram Moolenaar):
  • implement the remaining pieces to make xterm allocate cells for wide-characters when the "UTF-8" menu entry is selected. Also, load the UTF-8 font when that menu entry is selected, or the escape sequence for UTF-8 mode is received (report by Bram Moolenaar):
  • add command-line options (-tb, +tb) and resource toolBar to allow menu/toolbar to disabled or enabled at startup (prompted by reports by Joe Wells).
  • correct typo in configure script's --enable-dec-locator option (report by Bram Moolenaar).

Patch #200 - 2005/2/6 - XFree86 4.4.99.23

  • increase color pairs value for xterm-256color and xterm-88color to match ncurses, which has an experimental option to support this.
  • modify ifdef's to make AIX use termios rather than termio; the struct sizes for the two were not the same.
  • improve CF_WITH_IMAKE_CFLAGS configure macro script for OSMAJORVERSION and OSMINORVERSION values, e.g., for Tru64 and AIX.
  • modify ifdef to define USE_POSIX_TERMIOS for Darwin (patch by Min Sik Kim).
  • modify find_utmp() to initialize the whole utmpx struct (except ut_id), since that is needed for OSF1 4.0D to prevent an infinite loop on exit.
  • add configure check before adding -D_POSIX_SOURCE since some platforms predefine it, e.g., cygwin.
  • add simplified sed expressions in CF_IMAKE_CFLAGS configure script macro to ensure value for PROJECTROOT is quoted on Solaris, i.e., when nested \( and \) are not interpreted correctly.
  • correct DEC rectangle operations to reset state after completing the operations.
  • modify CASE_ST handling in charproc.c to ensure that the parse state is reset even if xterm is not currently processing an OSC or other string (patch by Johnny Billquist forwarded by Matthias Scheler, NetBSD xsrc/29003).
  • fix OS/2 build for innotek_libc (patch by David Yeo).
  • fix a regression from patch #197 fix for Debian #277832 which disowned the selection if it was scrolled, e.g., by the user pressing return at the bottom of the screen (Debian #291787).
  • move the warning/exit for missing $DISPLAY into the error handler in case -display is given, and the connect fails for some other reason.

Patch #199 - 2005/1/17 - XFree86 4.4.99.22

  • instead of setting $DISPLAY, check for the unset variable and warn/exit on this condition (comments by H Merijn Brand and Bernhard R Link).
  • fix a typo in Imakefile from patch #198 (reports/patches by Stefan Dirsch, Mike Castle).

Patch #198 - 2005/1/13 - XFree86 4.4.99.21

  • set $DISPLAY to ":0" if it is not set.
  • add utmpDisplayId resource to allow users to control whether the display identifier (display number and screen number) are retained in the connection information recorded in utmp (discussion with Edoardo Tirtarahardja).
  • add bellOnReset resource to allow users to disable bell which sounds on hard reset since patch #183 changes to DECSCL (discussion with Danek Duvall).
  • improve $WINDOWID for configuration with toolbar by making it refer to the top-level shell rather than the parent of the current window. For that case, the parent is a form widget, which does not have a name, which made the $WINDOWID not very useful as a parameter for xwininfo (suggested by Dave Bodenstab).
  • fix a typo in WhichVFont() macro from patch #197 changes which broke the --disable-active-icon configuration (report by Ralf S. Engelschall).
  • improve some limit checks (Gentoo Bugzilla #75604).
  • add --disable-setuid option to configure script (Gentoo Bugzilla #76543).
  • add --disable-full-tgetent option to configure script, allowing one to ignore a termcap library in favor of ncurses/curses (Gentoo Bugzilla #69926).
  • modify configure script to choose useful warning options for Intel version 8.0 compiler.
  • update config.guess, config.sub
  • make active-icon work properly when TrueType fonts are used (Debian #286068).
  • correct change from patch #157 which uses getlogin() to check for an alias; the storage used for the related getpwuid() call was overwritten by the data used for comparison (patch by Per Hedeland).
  • correct case of SCS for character set 0 (line-drawing) to allow it to be selected into GR.
  • fix a file-descriptor leak (Redhat Bugzilla #139597).
  • modify creat_as() to only fork if xterm is actually running as setuid and/or setgid. This works around a Cygwin bug which hangs when logging is enabled and makes xterm a little faster for systems using interfaces such as utempter (report by Al Goodman).
  • modify Cleanup() to avoid operations such as X calls that might use unsafe functions when it is called by a signal handler (report by Michiel Boland).
  • fix bugs in patch #191 and in SRM changes from patch #197 that broke DECSET 38: switch to Tek4014 emulation (report by Dave Bodenstab).
  • fix for manpage escapes (Marc La France).
  • improve on IRIX-specific change for Imakefile in XFree86 CVS versus resize linking against termcap library to reflect definitions for USE_TERMCAP in resize.c

Patch #197 - 2004/11/30 - XFree86 4.4.99.19

  • modify configure script to remove empty "-DPROJECTROOT=" definition which resulted unusable values for luit's default path.
  • update precompose.c based on Unicode 4.0.1
  • several minor fixes based on Intel compiler warnings.
  • change default translations so a BtnDown which is not recognized is simply ignored rather than emitting a bell. That makes it less obtrusive when the user tries to use a mouse which provides more capabilities than the X mouse driver supports, e.g., one with a horizontal scroll wheel (Debian #265133).
  • note in xterm's manpage that translations is not specific to xterm (Debian #278897).
  • modify uxterm script to use locale program to verify if the derived locale is installed (Debian #246398).
  • correct font handling for active icon when in UTF-8 mode (report by Paolo Liberatore).
  • make active-icon and toolbar configurations work together.
  • modify the criteria for disowning primary selection. Previously, this happened anytime the cursor was moved before the end of the selection. That would ensure that any insert/delete of char or line, as well as scrolling, would disown the selection. The new criteria change this to checking if the operations would modify the data which is highlighted (Debian #277832).
  • reimplement DECALN with functions for vt420 rectangles, fixes selection for this case.
  • implement vt420 rectangle operations.
  • add parsing, for debug/test of vt220 soft-fonts.
  • add menu entry, actions and escape sequence to allow enabling/disabling toolbars at runtime.
  • improve rendering for Xft, allow it to draw non-linedrawing characters such as "pi", which were drawn from internal tables with patch #180 (Freedesktop.org Bugzilla #1260).
  • add configure option --enable-mini-luit, ifdef'd the mini-luit feature with OPT_MINI_LUIT.
  • add mini-luit feature, which supports Latin9 directly rather than via luit, provided that Unicode fonts are used (Freedesktop.org Bugzilla #1571, request by Stefan Dirsch, patch by Michael Schroeder).
  • for Linux, if IUTF8 is defined, e.g., on recent 2.6.x kernels, set the corresponding flag for the slave pty, to enable UTF-8 interpretation of backspace in cooked mode (Freedesktop.org Bugzilla #1578, request by Stefan Dirsch).
  • modify faceSize resource to use a floating-point internal value (adapted from patch by Sam Stephenson).
  • correct handling selection of tabs over cleared space in UTF-8 mode. In this special case, xterm represents the whitespace with a null rather than a space character (Debian #276447).
  • amend fix for infinite loop from patch #192 to check if there is wrapped text to output in a following iteration (Debian #273202).
  • fixes ifdef'd with __INTERIX to allow building with Interix (Windows Services for UNIX) 3.5 using the xlibs libraries from freedesktop.org (patch by Min Sik Kim).
  • amend solution for Debian #252873, Debian #260471 from patch #194 by making the cursor not explicitly colored if only the foreground color is set, and the cursor is on a blank space (Debian #275473).
  • correct logic for send/receive mode (SRM) with regard to control characters.
  • fix masking of invisible text in wide-character mode, which did not work for line-drawing characters.
  • incorporate CF_XOPEN_SOURCE into configure script, replacing CF_GNU_SOURCE.

Patch #196 - 2004/8/15 - XFree86 4.4.99.12

  • add a special case to configure script to ignore NetBSD's grantpt() which was recently added (but not part of a release), until someone is able to ensure that xterm can use it (report by Min Sik Kim).
  • clear the buffer returned by getutid(). This fixes an infinite loop on some platforms introduced in patch #193 by Debian #256468 fix (report by David Ellement).

Patch #195 - 2004/8/8 - XFree86 4.4.99.11

  • correct length used for blinking text, make the last column blink (patch by Alexander V Lukyanov).
  • start changes to make doublesize characters work with TrueType fonts (see patch #44).
  • trim leading/trailing blanks from color resources as done for other strings in patch #167.
  • fixes for showBlinkAsBold resource (report by Christoph Berg).

Patch #194 - 2004/7/27 - XFree86 4.4.99.11

  • change clearing operations so foreground color attribute is not set. Usually this is benign, but in some cases when the cursor color is not set explicitly, the cursor would show this color (Debian #252873, Debian #260471).
  • add extra state (cursor-moved) to guard against deciding that the cursor did not require repainting after an indexing operation that leaves the cursor in the same location on the screen.
  • fix a case where a full-screen indexing operation would not restore the cursor-busy state.
  • fix a repainting bug introduced in patch #180: when using a font lacking line-drawing characters, a repaint of the screen could skip horizontally an extra amount after filling in the missing character (reports by Nicolas George, Hans de Goede, Redhat Bugzilla #128341).
  • rename terminfo fragment "xterm-pc-fkeys" to "xterm+pcfkeys" for consistency with ncurses.

Patch #193 - 2004/7/19 - XFree86 4.4.99.10

  • fix for wide-character selection from OpenBSD CVS (report/patch by Matthieu Herrb).
  • modify initialization and cleanup of utmp data to also compare the ut_line member (Debian #256468).
  • modify check on focus-change to ignore FocusOut events generated by XGrabKeyboard. This fixes a case where the text cursor would act as if focus were lost when selecting the "Secure Keyboard" menu option.
  • add gen-pc-fkeys.pl script, use that to generate terminfo fragment corresponding to the pc-style function keys.
  • fix a case where the checkmark by the "VT220 Keyboard" menu entry was not set on startup.
  • separated two methods for making the cursor blink (menu and escape sequence) by using the menu as the primary method and XOR'ing the state of the escape sequence against that.
  • modify logic for enabling blinking cursor via escape sequence as well as the related save/restore operations so this is only available if the cursorBlink resource was set on startup.

Patch #192 - 2004/7/12 - XFree86 4.4.99.9

  • change resource settings for color4 and color12, add some discussion in XTerm-col.ad (Debian #241717).
  • add a note in xterm manpage discussing the difference between alt- and meta-keys, and the way the latter is used in the eightBitInput resource.
  • add a note in xterm manpage regarding possible conflict between resource settings for xterm.vt100.font and xterm.vt100.utf8Fonts.font (Debian #254650).
  • add compile-time customization of backarrowKeyIsErase and ptyInitialErase default resource values (adapted from OpenBSD CVS).
  • change parameter of FIONREAD ioctl() call from long to int (discussion on tech-x11@netbsd.org regarding LP64 by John Heasley and Matthias Scheler).
  • modify configure script options for Athena widgets to work as expected for "--without-Xaw3d", etc., (Gentoo Bugzilla #53455).
  • add case to uxterm to accommodate locales ending with "@euro", e.g., fr_FR.UTF-8@euro (Debian #255197, report/analysis by Matthieu Lagouge).
  • add special case for VT100 graphic's "box" character (discussion with Ben Armstrong).
  • add missing initialization for bitmap-font sizes needed to make fonts menu work with TrueType fonts (report by Ben Armstrong).
  • save the fontnames for bold fonts that are derived from normal fonts, or from the boldFont resource, so the same value is restored when switching with the VT Fonts menu (Debian #256086).
  • fix manpage preprocessing (Marc La France).
  • fix typo in manpage's description of character classes (Debian #257073).
  • modify terminfo to accommodate luit, which relies on G1 being used via an ISO-2022 escape sequence (Debian #254316, analysis by Juliusz Chroboczek).
  • modify Makefile.in rule for ctlseqs.txt to work around groff SGR misfeature.
  • modify XTerm.ad to set saveLines default to 1024 (Redhat Bugzilla #127132).
  • add a limit-check in dotext() to prevent infinite loop in a corner case of UTF-8 configuration.
  • update config.guess, config.sub

Patch #191 - 2004/6/6 - XFree86 4.4.99.7

  • correct options parsing for -into option so it can be combined with -e (Redhat Bugzilla #124518, report/patch by James Armstrong).
  • fix ifdef's for OPT_COLOR_RES2 so that the fake resource table introduced in patch #188 is not compiled if it is empty. This happened to work with gcc (report by Joel Konkle-Parker).
  • reorganize ptydata.c to use one input buffer shared between the VTxxx and tek4014 emulators. In the new scheme, UTF-8 decoding is performed on characters as they are needed by the state machine rather than on buffers as they are read.
  • work around change in quoting of PROJECTROOT symbol when using configure script, from changes made in patch #187 for CF_IMAKE_CFLAGS (Gentoo Bugzilla #50982).

Patch #190 - 2004/5/25 - XFree86 4.4.99.6

  • correct state for values in the range 128-159 after translating from UTF-8: this should be ignored unless the user overrides it with the allowC1Printable resource (reported by Simon Strandgaard).
  • add configure-script check for nl_langinfo(CODESET), use this to replace check of environment variables for UTF-8.
  • change Makefile.in rules for 256colres.h and 88colres.h so they are only made if they do not exist. The maintainer-clean rule will remove these files; they require perl to be made.
  • remove check in configure script --enable-toolbar that suppressed this option when building with Xaw7.
  • apply fixes to Tektronix widget used for VT100 widget to make toolbar work with Xaw7 (XFree86 4.x).

Patch #189 - 2004/5/16 - XFree86 4.4.99.6

  • do not call xim_real_init() if openIm resource is false (Debian #249025).
  • minor improvements to built-in line-drawing.
  • fix a few portability issues with dynamic abbreviation support, i.e., did not compile on Tru64.
  • modify constraints in form used to layout toolbar, to work with newer Xaw in XFree86 4.x.

Patch #188 - 2004/5/12 - XFree86 4.4.99.6

  • correct table entry for DEL in the ground state, which marked it as a printable character from patch #171 (report by D Hugh Redelmeier).
  • improve fix in patch #186 for failure in xim_real_init() by adding a sleep.
  • fix a typo in os2main.c (XFree86 Bugzilla #1358, report/patch by Frank Giessler).
  • make escape sequence reporting dynamic colors consistent with the logic that sets it; choosing the opposite color when reverse video is set (XFree86 Bugzilla #1361, reported by Bradd W Szonye).
  • modify initialization of 256- and 88-colors so that colors beyond 16 are normally not X resources. This works around a hard-coded limit in Xt which breaks xterm when 256-colors and luit are both configured (report by Noah Friedman).
  • remove ncv from xterm-256color terminfo entry since it is no longer needed (report by Eli Zaretskii).
  • add "erase2" and "eol2" keywords to ttyModes resource, for recent/current FreeBSD.
  • improve ifdef's for utempter library to omit direct calls to setutent() or getutent() (adapted from patch by Christian Biere).
  • add dynamic abbreviation support like Emacs (patch by Tomasz Cholewo). This is ifdef'd with OPT_DABBREV, and enabled via the configure script --enable-dabbrev option.
  • fix problem responding to session management events, e.g., which would make logging out very slow (patch by Eddy De Greef, Debian #233883).
  • work around a newer bug in toolbar with XFree86 by forcing menus to be fully initialized at startup. In older versions of XFree86 and X11R6, it was possible to delay initialization of the menu contents until it was popped up. (The longstanding bug with XFree86 4.x layout for toolbar still exists, though).
  • modify xtermAddInput to work around core dump on IRIX64 when initializing scrollbar translations if toolbar is compiled-in.
  • fix some minor conflicts in the 2-character entry names in the termcap file.

Patch #187 - 2004/4/27 - XFree86 4.4.99.4

  • change xterm version string to use __vendorversion__ where that is available, and "XTerm" otherwise.
  • improve description of utf8 resource in manpage (Debian #179407).
  • modify configure macros CF_IMAKE_CFLAGS and CF_ADD_CFLAGS to handle -D options that define string values, e.g., for XVENDORNAME.
  • modify configure macro CF_IMAKE_CFLAGS to allow (if $PATH is set accordingly) to use the xmkmf script within an X build tree.
  • add missing #undef OPT_SESSION_MGT to xtermcfg.hin to make the configure script's --disable-session-mgt option work.
  • update config.guess, config.sub

Patch #186 - 2004/4/18 - XFree86 4.4.99.4

  • change reset on DECSCL to a soft-reset (appears some DEC manuals have errors).
  • add a section to ctlseqs.ms elaborating on normal/alternate screens.
  • modify initialization of Acolors[] so that any XtDefaultForeground or XtDefaultBackground values are translated as in the Tcolors[], to use the window's foreground/background colors. This affects the colorBD and similar resources which normally have no explicit color assigned.
  • modify initialization of Tektronix window so that control sequences setting its color before the window is popped up will apply to its initial colors.
  • add control sequence to set Tektronix window's text-cursor.
  • modify initialization of terminal colors, e.g., mouse pointer and text cursor, to treat XtDefaultForeground and XtDefaultBackground values as the actual foreground and background colors of the terminal rather than white and black (Debian #241717).
  • remove an incorrect comparison against PTYCHARLEN in parsing the -S option (report by Michael B Taylor).
  • minor restructuring of terminfo/termcap files, having noted some packager's customizations which caused the structure to be confused.
  • eliminate an isolated use of MIN/MAX in charproc.c
  • replace XtExtdefaultfont and XtExtdefaultbackground by their more familiar equivalents XtDefaultFont and XtDefaultBackground.
  • replace ifdef's using SCO, sco and SCO325 with __SCO__ (XFree86 Bugzilla #1301, Kean Johnston). But ensure that it still builds on platforms where this symbol is not defined.
  • add scoFunctionKeys resource, to match manpage.
  • update manpage discussion of menus and related resources.
  • enable utmpx support for NetBSD 1.6C and newer (patch by Matthias Scheler).
  • add a note in the manpage discussing xterm's treatment of open file-descriptors (request by Dan Shearer).
  • modify Help() to make "xterm -h" write to standard output rather than standard error (patch by Bram Moolenaar).
  • check for type of failure in xim_real_init() to avoid looping when the problem is an unsupported input method rather than a failure to connect to the XIM server. Problem was introduced in patch #175 (XFree86 Bugzilla #1306).
  • modify Imakefile to remove dependency of "install" target on the xterm executable to make installs from tree without attempting to rebuild anything (commit by David Dawes, report/patch from Lee Olsen).
  • remove call to ShowCursor from SetCursorBlink() since that is redundant, and can cause display glitches if the cursor is already blinking (XFree86 Bugzilla #1158, patch/report by Andreas Schwab).

Patch #185 - 2004/3/3 - XFree86 4.4

  • fix tcap-query logic for the backspace key (XFree86 Bugzilla #1233, report/patch by Anton Kovalenko).
  • add test-scripts resize.pl and tcapquery.pl
  • add translation to ASCII of commonly-used characters that groff translates to Unicode, when the font in use does not provide the corresponding glyphs (Debian #219551).
  • modify RequestMaximize(), which performs maximize/restore via control sequences, to account for window-frame (patch by Jess Thrysoee).
  • improve pattern used in uxterm to check for UTF-8 locale, e.g., for HPUX (patch by H Merijn Brand).
  • add -fd option and resource faceNameDoublesize to specify double-wide fonts with Xft (adapted from patch by Zarick Lau).
  • change a couple of resource classes from "Boolean" to specific values: freeBoldBox, forceBoxChars.
  • add resource showMissingGlyphs to outline places on the screen where a font lacks the corresponding glyph.
  • add resource showBlinkAsBold to control whether blinking text should be shown as bold or actual blinking text.
  • improve logic in ShowCursor() to avoid repainting the cursor when it is already visible, e.g., in response to the DECTCEM escape sequence. This also addresses XFree86 Bugzilla #1158.
  • implement blinking text, using the timer for blinking cursor.
  • modify FreeType support to allow resizing the font, in the same ways the window can be resized if fixed fonts are used. The relative font sizes are derived from the fixed font sizes.
  • add menu items and corresponding actions for switching on/off the UTF-8 mode and Xft (TrueType) support.
  • add logic to handle switching UTF-8 mode on/off. It worked if the escape sequences were flushed, but if data was mixed in with the same write, some were not handled properly (report by Nicolas George).
  • modify to allow turning UTF-8 mode on/off via escape sequence even if -wc option was not given at startup (patch by Peter Berg Larsen).
  • amend fix for XFree86 Bugzilla #981, adjusting for savedlines value (report by Tim Adye).
  • fix a typo in computing relative font size (Jess Thrysoee).

Patch #184 - 2003/12/31 - XFree86 4.3.99.903

  • improve configure-script checks for FreeType and related libraries, using xft-config or freetype-config scripts when available.
  • fix configure-script check for SYSV definition by ensuring whether sys_errlist[] is declared, and by modifying the test program to include X11/Intrinsic.h to check that wchar_t is declared consistently (report by H Merijn Brand).

Patch #183 - 2003/12/26 - XFree86 4.3.99.903

  • correct logic for configurations that may attempt to open both old/new-style pseudoterminals. In this case, the old-style are preferred. Logic was broken in patch #145 (XFree86 Bugzilla #997, report/patch by Kean Johnston).
  • modify handling of eightBitInput resource in UTF-8 mode to translate the value into UTF-8. Otherwise an illegal UTF-8 code is sent to the application (report by Bram Moolenaar).
  • modify uxterm script to interpret help and version options so xterm does not always create a window when the user requests this information (Debian #223926).
  • add a limit check to ScrnTstWrapped() (XFree86 Bugzilla #981).
  • modify DECSCL to perform a hard reset (RIS) as per DEC manuals. Extended DECSCL to accept parameters for vt4XX and vt5xx terminals.
  • correct logic for ANSI conformance level escape sequences, which were confused with DEC conformance level escape sequences.
  • correct state for vt52 shift-in/shift-out, which was not reset properly after patch #171.
  • correct handling of graphics characters for vt52 mode, which did not display line-drawing characters after G1 fix from patch #182.
  • fixes for configure script to work with current Cygwin headers and libraries.
  • modify Imakefile to put the current directory at the beginning of the include searchpath (patch by David Dawes).

Patch #182 - 2003/12/2 - XFree86 4.3.99.901

  • correct logic for metaSendsEscape resource to allow for the meta-right key to be tested. Improve check for meta/alt modifiers by dropping the assumption that a keysym is associated with only one modifier, and by ignoring NoSymbol entries in the xmodmap data (XFree86 Bugzilla #924, patch by David Dawes).
  • correct wrapping logic for line-drawing characters written in non-UTF-8 mode of xterm build for wide-characters (XFree86 Bugzilla #918, report/patch by Jürgen Keil).
  • improve manpage description of resources, in particular the utf8Fonts class (XFree86 Bugzilla #905).
  • add definitions to compile with glibc-based GNU/Hurd, GNU/KFreeBSD and GNU/KNetBSD (XFree86 Bugzilla #893).
  • compiler-warning fixes (patch by Christian Biere).
  • add README.i18n (Tomohiro Kubota).
  • correct initialization of G1 character set mapping, which used line-drawing set as a result of confusion between "DEC Supplemental Graphic" and "DEC Special Graphic" character sets (see patch #34 regarding DECSTR).
  • correct ifdef in main.c for variable utret (patch by Bernhard Rosenkraenzer).
  • document in xterm's manpage how to use XFree86 ":unscaled" keyword to suppress scaling of bold fonts.
  • when deriving bold fontname from normal fontname, use the normal font's average width to avoid for example selecting 7x13bold from an 8x13 normal font (Debian #107769).

Patch #181 - 2003/10/26 - XFree86 4.3.99.15

  • implement boldMode for wide-character logic in drawXtermText() (report by Michael Schroeder).
  • modify UXTerm.ad resource file to include "XTerm-color" rather than "XTerm", in case the latter file contains no color resource definitions, e.g., after patch #180.
  • add action load-vt-fonts() and configure option --enable-load-vt-fonts which allows users to define additional sets of VT-fonts which can be loaded at runtime.
  • add logic to wide-character support which attempts to load fonts specified by utf8Fonts subresources at startup. The subresources have the same names as the fonts which they replace, e.g., font, font1, etc., so that the ISO-10646-1 fonts can be specified in the XTerm app-defaults file (adapted from patch by Tomohiro Kubota).
  • improve Set Font escape string handling by making the relative settings apply to the size of the font, as in shift keypad plus/minus rather than the menu index.
  • simplify parameter passing for the set-vt-font action and related code.
  • cleanup some include-ordering, moving some recently-added hardcoded stuff into xterm.h where it will not interfere with the configure script.
  • modify xtermAddInput() (see note on augmentation in patch #158) to use the complete set of default keyboard translations so that one can use shifted pageup, wheel mouse, etc., while the mouse pointer is over the scrollbar. (Debian #178812).
  • make save/restore mode controls apply to show/blink cursor states.
  • add escape sequence to start/stop blinking cursor, which allows implementing cvvis terminfo capability (request by Nate Bargmann).
  • add indp and rin to terminfo entry.
  • fix an out-of-bounds array reference in ScrnRefresh() for wide characters (report by Dan Harnett, patch by Todd Miller). This bug dates from patch #141.

Patch #180 - 2003/10/12 - XFree86 4.3.99.15

  • several fixes for rendering using Xft via option -fa:
    • translate Unicode values, i.e,. from UTF-8 output to xterm, for line-drawing to xterm's internal code, etc., since TrueType fonts generally do not have either set of line-drawing glyphs. xterm can draw these directly (report by Abigail Brady).
    • pass 16-bit values rather than 8-bit values to xtermXftDrawString() to allow for wide-characters.
    • remove spurious check for colorBDMode resource in logic that does bold fonts.
    • implement underlining.
  • patches by Ilya Zakharevich:
    • improve drawXtermText() by making the recursive calls communicate through arguments, and not through saving/restoring global variables.
    • make double-width characters work with -u8 option.
    • modify lookup of double-sized fonts by checking for a match ignoring x/y resolution if the first check fails.
  • make height of TrueType fonts match ascent+descent (patch by Keith Packard).
  • correct configure-script check for imake $CFLAGS, which did not check properly if imake was not available.
  • correct install rule in Makefile.in for uxterm, which was attempting to strip the script (newsgroup posting by Fernan Aguero).
  • correct AF/AB strings in termcap for xterm-256color and xterm-88color entries (report by Josh Howard).
  • update wcwidth.c to incorporate changes from Markus Kuhn's 2003-05-20 (Unicode 4.0) version of that file.
  • modify scroll-back and scroll-forw actions to accept an adjustment value, e.g.,
                  scroll-back(1, page-2)
    
    to scroll back by 2 lines less than a page (patch by Greg Klanderman).
  • use color resource setting from Debian package for xterm VT100 widget, since the choice of blues provides better contrast.
  • remove color resources from XTerm.ad, leaving them only in XTerm-col.ad (prompted by Debian package for xterm).
  • correct configure script option --enable-pty-handshake (report by Paul Gilmartin).
  • add visualBellDelay resource to modify the length of time used for visual bell, for very slow displays or very fast computers (reports by Ingo van Lil and Doug Toppin).
  • correct logic for initializing dynamic highlight color (patch by Jess Thrysoee).
  • add a check for non-zero size in call to XCopyArea() to accommodate a Solaris bug.
  • correct typo in example for character classes in xterm manpage (Debian #198910).
  • link xterm with bind_on_load option on Darwin to work around a deadlock in the dynamic loader when a signal is received while the dynamic loader is looking up symbols (patches by Rob Braun, Torrey Lyons).
  • modify configure script to avoid using "head -1".
  • update config.guess, config.sub
  • modify ifdef's to work around inclusion of types FcChar32 and XftCharSpec with FreeType 2.0 (see patch #175).
  • modify the predictable version of the generated logfile name (see patch #171) to append the process-id rather than a random value.
  • resync with XFree86 CVS
    • Enable SCO function keys in xterm
    • Make Delete key send DEL by default on SCO in xterm

Patch #179 - 2003/5/21 - XFree86 4.3.99.5

  • modify ifdef's for WTMPX_FILE to allow building on cygwin again.
  • change the default of pty-handshaking configure option (and related default for imake) to assume this feature is needed.
  • add ifdef's so configure option for XawPlus library works (patch by Pavel Roskin).
  • add $(MAIN_DEFINES) to the variables checked by the configure script that may contain information set by imake. This allows xterm to build/run properly using the configure script on IRIX64.
  • add configure check for ".exe" suffix on cygwin.

Patch #178 - 2003/5/18 - XFree86 4.3.99.5

  • modify default for configure --enable-pty-handshake option to enable it for Solaris (report by Nelson Beebe).
  • modify in_put() function to call PreeditPosition() only when the cursor's position has changed. This addresses report by Stefan Baums of high CPU usage while xterm with chinput are running in the background (patch by Yong Li).
  • improved explanation of -ls conflict with -e option in xterm manpage (adapted from comments by Henning Makholm).
  • correct comment in terminfo file regarding modifier used for kDC (Debian #189764, report by Henning Makholm).
  • correct/extend some of the keypad description in ctlseqs.ms (report by Henning Makholm).
  • correct keypad-mapping table in input.c so XK_KP_Equal works (report by Henning Makholm).
  • modified to work with CJK double-width (bi-width/monospace) fonts. They're similar to Roman Czbora and David Starner's gnuunifonts in that Latin letters and numbers have all the same width which is exactly the half of the width of East Asian characters. (patch by Jungshik Shin <jshin@mailaps.org>).
  • add configure option --enable-broken-osc and resource brokenLinuxOSC to accommodate scripts which do not distinguish between running in the Linux console and running in X. Linux console recognizes malformed control strings which start with an OSC, but are fixed-length, with no terminator.
  • add configure option --enable-broken-st and resource brokenStringTerm to allow user to revert one part of the parsing table corrections from patch #171. (reports by Matthias Scheler and Kirill Ponomarew indicate that someone's network firmware sends an <escape>X).
  • modify configure --disable-imake to provide values for OSMAJORVERSION, OSMINORVERSION, FUNCPROTO and NARROWPROTO (report by Heiko Schlichting).
  • correct vttests/16colors.sh, which omitted the $SUF variable in output strings (patch by Paul Gilmartin).
  • modify shell scripts in vttests directory to attempt to use named signals in the trap statement, making this portable to OS/390 (report by Paul Gilmartin). Tested on SunOS 4.1.4, which implements only numbers.

Patch #177 - 2003/3/23 - XFree86 4.3.0

  • fix definition of USE_HANDSHAKE, must be numeric (reported by Jens Schleusener).

Patch #176 - 2003/3/22 - XFree86 4.3.0

  • add configure option --enable-pty-handshake to allow one to compile-in support for the pty handshaking logic, and resource ptyHandshake to enable or disable it (suggested by Ian Collier).
  • restore USE_HANDSHAKE ifdef removed in patch #159 to address Debian #39964.
  • move ifdef's for ttysize/winsize into xterm_io.h
  • simplify loop on tgetent, check if the successive entries in the lookup table are the same. That makes xterm do one less lookup if there is no "xterm" entry in the termcap file (report by Derek Martin).
  • correct manpage discussion of $TERM and $TERMCAP variables, which omitted the Tektronix emulation and a note of the final "dumb" fallback.
  • broaden ifdef for XRegisterIMInstantiateCallback() from patch #175 (XIM fix) to exclude non-XFree86 (report by Nelson Beebe indicates this breaks for Solaris, IRIX and OSF/1).
  • correct resource-size for iconFont (this was added by X11R6.3).
  • improve configure check for XKB bell extension, to work around inconsistent implementation of this feature (reports by Nelson Beebe, Kriston Rehberg and David Ellement).
  • modify configure-check for tty group to be less strict in batch mode (report by Nelson Beebe).
  • modify to allow building with g++, to use its compiler warnings (suggested by Nelson Beebe).
  • modify dec2ucs[] table to reflect newer codes available for scanlines 1, 3, 7, 9 (report by Michael Schroeder).
  • add configure option for XawPlus library.

Patch #175 - 2003/3/9 - XFree86 4.3.0

  • fix a SIGSEGV which could occur if xterm is connecting to XIM server, and the XIM server is destroyed (patch by Nam SungHyun).
  • modify to use built-in line-drawing characters for Xft fonts (patch by Andrew Tipton).
  • make menu reflect the state of the tekInhibit resource.
  • make signalInhibit resource work, i.e., disable the menu entries that would send signals to, or exit xterm. This was probably broken in X11R5 when logging was disabled (report by Sven Mascheck).
  • changed classes of colorBDMode and similar resources that override colors when a video attribute is set to ColorAttrMode, to make them distinct from ColorMode. This avoids an unexpected rendering of reverse video, for example (report by Paul Fox).
  • changed class of veryBoldColors to VeryBoldColors, since ColorMode is associated with boolean resources.
  • add option -k8 and resource allowC1Printable to allow users of non-VTxxx character sets such as KOI-8 to treat the C1 control area (character codes 128-159) as printable rather than control characters.
  • add a null-pointer check for return-value of ptsname() in HPUX-specific code (report by David Ellement).
  • revise the ifdef's used for XKB bell support. The code was using a nonstandard call XkbStdBell(). Changed to use XkbBell() (based on patch by <derek@signalmarketing.com>).
  • add a null-pointer check in xtermLoadFont() in case there is no wide-bold font (Nam SungHyun).
  • change Makefile.in to use autoconf's bindir, libdir and mandir variables (report by Nam SungHyun).
  • add le to termcap xterm-basic entry. Though missing from older termcaps for xterm, some applications check for it (report by Matthias Buelow).
  • modify uxterm script to strip modifiers such as "@euro" from the locale setting before adding ".UTF-8" (Debian #179929).
  • modify the remaining places where tek4014 emulation uses XDefineCursor(), to make it work as originally implemented, e.g., when switching back to alpha mode. Added test-screen in vttest to test this feature properly.

Patch #174 - 2003/2/25 - XFree86 4.2.99.903

  • work-around for XFree86 bug which made XDefineCursor() on a shell-window no longer work. The tek4014 emulation used this. Use the next lower window (report by Karl Rudolf Bauchspiess).
  • add a resource setting allowWindowOps to control whether the extended window operations should be allowed, e.g., resize, iconify, report window attributes. This is to accommodate people who are not capable of using a pager to view log-files.

Patch #173 - 2003/2/6 - XFree86 4.2.99.902

  • reset mouse mode to normal on a full reset. This does not apply to mouse hilite tracking mode, of course (see ctlseqs.ms).
  • add a time-delay at the point where mouse hilite tracking mode choses to not handle X events, to avoid runaway CPU usage (report by D Hugh Redelmeier).
  • check for illegal character in DECUDK string, quit if detected.

Patch #172 - 2002/12/27 - XFree86 4.2.99.3

  • fixes to make repainting of 256-color example work properly (reports by Abigail Brady and Scott A Crosby).
    • set flag in AllocateAnsiColor() to ensure the color is allocated once only.
    • fix check in ScrnRefresh, which was comparing background colors only if the ANSI foreground colors also were set.
  • merge Error() calls and some exit() calls into SysError(), and change that to add the brief explanation for each error code which is provided in the manpage. Change a few SysError(), calls to avoid using code 1, to avoid confusion with exit status from places that do not use SysError().
  • simplify logic used to open a debug logfile as the standard error.
  • modify the -e option so that if it fails, xterm will check if only one argument follows, e.g., it was quoted, and then retry using sh -c.
  • modify parsing of DECUDK string parameter to allow a comma between pairs of hexadecimal digits (Ray Neuman <raymond@one.com.au> reports that "real" terminals accept this; perhaps they simply ignore unexpected characters).
  • fix a few problems with the $TERMCAP string generated by resize:
    • for Bourne shell, add an export command. This was missing as far back as X11R5.
    • escape exclamation marks, used in xterm's reset string.
    • translate literal \177\ to "^?".
  • improve configure check for tgetent() to work when $TERMCAP has been set to a specific entry.
  • modify minstall.sh to use "%" rather than "@", to avoid problems with AFS (report by Zdenek Sekera).
  • list fatal error codes from error.h in the manpage, remove unused codes in error.h.
  • use more explicit wording for manpage list of color resources, since at least one user confused the generic names such as "black" with the names in rgb.txt (the latter are now used).
  • minor fix to description of 1003 mouse mode in ctlseqs.ms (Larry Riedel).

Patch #171 - 2002/12/12 - XFree86 4.2.99.3

  • modify parser tables to improve detection of malformed control sequences, making xterm behave more like a real DEC terminal (patch by Paul Williams).
  • update comment in input.c to document Meta as a modifier for escape sequences (patch by D Roland Walker).
  • add ifdef'd code for logging option which adds the hostname and a timestamp to the generated logfile name. The ifdef's are setup with the configure script (patch by Nelson Beebe).
  • remove xevents() call from the end of BlinkCursor(), to fix an occasional problem which caused xterm to pause until a key was pressed. The reason for this was that there was no check to ensure that there really were events for xevents() to process. (patch by Semen A Ustimenko <semenu@FreeBSD.org>).
  • remove unused mode-params from open() calls that do not create a file.
  • modify configure script to put new items first on $CPPFLAGS and $CFLAGS to avoid conflict with environment's -I and -D options.
  • update config.guess, config.sub
  • resync with XFree86 CVS
    • fix va_args glitches for xterm/libfontconfig: 0 == (void*)0 isn't true for all platforms (Egbert Eich).
    • initialise ProgramName in xterm's main before referencing it (XFree86 #5473, Peter Valchev).
    • some cleanup of Imakefile ifdef's (Marc La France).

Patch #170 - 2002/10/13 - XFree86 4.2.1

  • correct an off-by-one allocating data for sorted help message.
  • modify configure script to check for Xpm library, on which XFree86 Xaw library depends.
  • update config.guess, config.sub

Patch #169 - 2002/10/5 - XFree86 4.2.1

  • modify wording of some options in help message to make them use -/+ consistently with respect to "on/off" or "off/on".
  • sort options list which is displayed in help- and syntax-messages at runtime to simplify maintenance.
  • remove support for Amoeba and Minix (Juliusz Chroboczek noted it was removed from XFree86 server; there have been no users since 1996).
  • add configure script option --disable-session-mgt to control whether the session management code should be compiled-in (request by H Merijn Brand).
  • ifdef'd the session-management changes with OPT_SESSION_MGT, to accommodate X11R5 which predates the related definitions.
  • fix decode_keyvalue(), which did not properly parse multiple settings as needed for the ttyModes resource, since it did not skip over the parsed data.
  • fix an option-parsing conflict between -class and -cjk_width (Nam SungHyun)
  • add a missing null in XtVaSetValues() call used in Cleanup() (Nam SungHyun)

Patch #168 - 2002/9/29 - XFree86 4.2.1

  • improve data reported for control sequence that requests window position by taking into account the window decorations, e.g., border and title (patch by Jess Thrysoee <jess@thrysoee.dk>).
  • add -cjk_width and corresponding resource cjkWidth (patch by Jungshik Shin <jshin@mailaps.org>).
  • add -into option, for embedding xterm in a Tcl/Tk application (patch by George Peter Staplin <georgeps@xmission.com>).
  • add simple session management (XSM) client capabilities to xterm. So a session manager such as, e.g., xsm, should be able to respawn or kill xterms without the help of an SM proxy (like smproxy), which is a hack and almost always buggy (patch by David Madore).
  • fix conflict between ifdef's for OPT_DEC_LOCATOR and OPT_READLINE in button.c (reported by Ilya Zakharevich).
  • fix for inconsistent use of struct utmp versus struct utmpx introduced in patch #167 (patches by Paul Gilmartin, Marc La France).
  • modify logic for metaSendsEscape to allow it to work in a setup where the Meta-key is not recognized as a modifier by the key-translations logic (discussion of eightBitInput with H.J.Lu). Note however that Vincent Lefevre reported this in January).
  • use null pointer values consistently, rather than literal "0", for ending variable-length argument lists, e.g., for execlp() (based on patch by Matthieu Herrb).
  • correct logic of ChangeAnsiColorRequest(), which would do a screen repaint after replying to a request for information.
  • improve scripts in vttests to work with systems whose shells support echo -n and have, as does Debian, an unrelated print utility.
  • add vttests/acolors.sh to demonstrate OSC 4, which queries or sets ANSI colors.
  • fixes for ctlseqs.ms (Pavel Roskin, Ilya Zakharevich).
  • typos in xterm manpage (Jens Schweikhardt)
  • remove a redundant GCC_UNUSED from InitPopup() (Nam SungHyun)

Patch #167 - 2002/8/24 - XFree86 4.2.0

  • correct ifdef's for USE_TERMCAP to match cygwin configuration.
  • fix several places in ctlseqs.ms which had no boxes around the literal text (report by Ilya Zakharevich).
  • extend mouse support for readline, ifdef'd with OPT_READLINE (integrated patch from Ilya Zakharevich).
  • modify terminfo description to match default for modifyCursorKeys resource.
  • add modifyCursorKeys resource to control how the shift- and similar modifiers are used to make a cursor escape sequence. The default makes a modified escape sequence always start with CSI and puts the modifier as the second parameter, to avoid confusing applications that would interpret the first parameter as a repeat count. The original behavior can be obtained by setting the resource to 0 (newsgroup discussion with Stephen J Turnbull, Jeffrey Altman).
  • correct missing initializations for appdefaultCursor and appdefaultKeypad resources.
  • add configure option --enable-luit and ifdef'd the luit-related code with OPT_LUIT_PROG.
  • modify xterm to invoke luit (integrated patch by Tomohiro Kubota)
  • update wcwidth.c to match Markus Kuhn's 2002-05-18 version.
  • correct limit-checking in ComputeSelect() to handle selections that extend off the visible area; rather than modify the parameters to TrackText(), use ScrollSelection() to update the highlighting limits. (reported by Yegappan Lakshmanan and Nelson Beebe, patch by Alexander V Lukyanov).
  • correct manpage description of tiXtraScroll resource (reported by Tony Finch).
  • changes from OpenBSD:
    • Make xterm setgid utmp to be able to update utmp even with root privileges revoked.
    • If not updating utmp, revoke group privileges totally too.
  • changes from NetBSD:
    • Check that the return value from ttyslot() is greater than 0 before writing the utmp file. Fixes w's "w: Stale utmp entry: <user> <tty> <pty>" errors.
    • Use openpty() to deal with new pty naming scheme.
  • add print-redir action and menu entry to allow user to switch terminal in/out of printer controller mode. It appears from the manual that a real vt220 would not switch back to normal mode, so another mechanism is used (addresses Debian #37517).
  • check if printerCommand resource string is empty, use this to allow user to disable printer function.
  • trim trailing blanks from resource strings.
  • check return value from ptsname(), which may return null for example if someone has changed the permissions of /dev/pts to zero (Debian #121899).
  • modify OS/2 version to use __UNIXOS2__ definition rather than __EMX__, related cleanup (patch by Holger Veit).
  • used modified indent 2.0 (patch 20020428) to reformat most of the C source files, to simplify maintenance.
  • fix a couple of places where there were leading tabs on symbol-definition lines in Imakefile (Marc La France from report by Tony Finch)
  • add imake variable (TraceXTerm) to allow building debug version (Egbert Eich).

Patch #166 - 2002/3/25 - XFree86 4.2.0

  • correct a bug in selection: double clicking on a word which was partly scrolled off the screen may select that text (report by Vincent Lefevre <vincent@vinc17.org>).
  • implement veryBoldColors resource to control whether the corresponding video attribute such as bold is displayed when using colorBDMode, etc. (request by Josh Howard <jrh@vicor-nb.com>).
  • define escape sequences for function keys F21-F35 (patch by Stephen P Wall).
  • change the colors for the 256-color model, making them less skewed toward black (patch by Stephen P Wall).
  • add vt100Graphics resource (see patch #115, based on discussion with Glenn Maynard).
  • ifdef'd Xaw/Xaw3d/neXtaw includes separately to avoid potential incompatibilities between these flavors of Athena widgets.
  • add configure check for XFree86 4.x Xaw library, whose geometry management is broken, to avoid trying to use it for toolbar configuration.
  • updates to configure script from vile and lynx to allow configure.in to be compiled with autoconf 2.5x
  • add a check for null pointer return by ptsname() (newsgroup posting from Mike Silva <mikesilva@lucent.com>).
  • fill in a few details needed to allow UTF-8 mode to switch on/off after startup. This requires that wideChars resource be set. (based on comments in 4 Aug 2001 by Alexey Marinichev <lyosha@lyosha.2y.net>).
  • remove duplicate install rules that make directories, e.g., so installing manpage will not create app-defaults directory.
  • add comment in in do_osc(), reserving cases 30 and 31 for for Konsole (request by Stephan Binner <Stephan.Binner@gmx.de>).
  • fixes for ctlseqs.ms and xterm.man (patch by Werner Lemberg <wl@gnu.org>).
  • add check for monochrome display, disabling colorMode in that case (fixes Debian #134130).
  • resync with XFree86 CVS
    • Fix some xterm build warnings on *BSD (patch by David Dawes).
    • Only use SA_RESTART in xterm when it's available (patch by Frank Liu).
    • Fix incorrect code in signal handlers in most of the clients, xterm and xdm not done yet (patch by Matthieu Herrb).

Patch #165 - 2002/1/5 - XFree86 4.1.0

  • modify uxterm script to strip encoding part from environment variable before adding ".UTF-8" (based on Debian #125947, but using a more portable solution).
  • add an assignment statement in VTInitialize() to make awaitInput resource work.
  • use new macros init_Bres(), etc., in VTInitialize() to add trace of the initialization of resources.
  • modify checks for $LC_ALL, related environment variables to ensure the resulting strings are nonempty (report by Markus Kuhn).
  • add an ifdef in charproc.c for num_ptrs variable in case all configure options are disabled.
  • modify definition of getXtermBackground() to avoid negative array index warning on Tru64 (report by Jeremie Petit).
  • improve fix from patch #165 (still Debian #117184, report by Matt Zimmerman <mdz@debian.org>)
  • correct install rule for uxterm in Makefile.in, to handle the case where building in a different directory than xterm's source (patch by Paul Gilmartin).
  • documented ANSI.SYS-style cursor save/restore escape sequences in ctlseqs.ms, which are in xterm since X11R5.
  • correct two entries in the default charClass table, which did not follow the manpage comment about the character number corresponding to the class (patch by Marc Bevand <bevand_m@epita.fr>).
  • fix a couple of typos in comments in the app-defaults files (David Krause <xfree86@davidkrause.com>).
  • resync with XFree86 CVS
    • update language of copyrights in some files to reflect the fact that they were reassigned from X Consortium to The Open Group in 1998. Note that this xterm source is derived from the 1996 version from X Consortium, does not incorporate changes made by X Consortium or The Open Group after that date, hence we do not add The Open Group's 1998 copyright date to related files.
    • save/restore errno in signal catcher (patch by Matthieu Herrb).
    • modify UXTerm.ad's font5 resource so that xterm can display double width characters using a font distributed with XFree86 (Tomohiro Kubota).

Patch #164 - 2001/11/13 - XFree86 4.1.0

  • correct a case where ptyInitialErase and backarrowKeyIsErase resources combine to set DECBKM mode, but a reset command would not reset xterm to that state, making the erase character revert to ^H (Debian #117184)

Patch #163 - 2001/11/04 - XFree86 4.1.0

  • correct ifdef's for __QNX__ and USE_SYSV_PGRP in main.c call to tcsetpgrp, which broke bash behavior around patch #140 (report/patch by Frank Liu <fliu@mail.vipstage.com>).
  • modify trace.c to fix missing definition of GCC_UNUSED for compilers other than gcc when configured for trace code (report/patch by Paul Gilmartin).
  • change format in TraceOptions() to use long rather than int, since the latter could lose precision on 64-bit machines (report/patch by Nelson Beebe).
  • modify xterm manual page and minstall.sh to allow imake rules to define location of app-defaults directory (Debian #87611).
  • review/update list of conflicting preprocesor symbols to remove from $CPPFLAGS at the end of the configure script. In particular, this allows one to configure xterm without the utempter library on Redhat 7.1 (report/patch by Adam Sulmicki).

Patch #162 - 2001/10/23 - XFree86 4.1.0

  • correct logic that processes -class option, so that a following -e option is handled (Debian #116297).
  • improve options-decoding to allow -version and -help options to be combined (Debian #110226).
  • add a 10 millisecond delay in event loop when processing -hold option, to avoid using too much CPU time (Debian #116213).
  • prefix final program execution in uxterm with "exec" to avoid a useless shell hanging around (Christian Weisgerber).

Patch #161 - 2001/10/10 - XFree86 4.1.0

  • modify logic that resets keypad application mode to avoid doing this if there is no modifier associated with the Num_Lock keysym (report by John E Davis <davis@space.mit.edu> and Alan W Irwin <irwin@beluga.phys.uvic.ca>).
  • add built-in translation for Control/KP_Separator to KP_Subtract, to accommodate users who wish to use xmodmap to reassign the top row of the numeric keypad.
  • correct Imakefile install-rule for uxname script (reported by Nam SungHyun <namsh@lge.com>).
  • resync with XFree86 CVS – correct typo in <ncurses/term.h> ifdef.

Patch #160 - 2001/10/7 - XFree86 4.1.0

  • modify logic in main.c (see patch #145) to avoid generating the same identifier, for example, for /dev/tty1 and /dev/pts/1, which is used to denote an entry in the utmp file (Debian bug report #84676), A similar fix was also sent by Jerome Borsboom <borsboom@westbrabant.net> in May, but I overlooked it when reviewing bug reports.
  • add configure check for <ncurses/term.h> to get rid of hardcoded __CYGWIN__ ifdef in resize.c

    NOTE: The CYGWIN port should not be linking resize with ncurses. It appears that the only reason it is, is because both the ncurses and termcap ports on that platform are badly misconfigured (essential pieces have been removed, etc). Checking for <ncurses/term.h> does not hurt anything, since there are some correct installations that are set up that way.

  • add a sample uxterm script, which uses the UXTerm application defaults for UTF-8 environments.
  • undo change to xterm application defaults, since this introduced an unnecessary incompatibility. The intended functionality was already addressed by the UXTerm app-defaults file.
  • resync with XFree86 CVS
    • Modified xterm app default to use LFD fontnames instead of old type (Michael Schroeder).
    • Fix xterm when XIM is disabled - caused a segfault (Tomohiro Kubota).

Patch #159 - 2001/9/19 - XFree86 4.1.0

  • remove an ifdef for USE_HANDSHAKE added in patch #158 from the second TIOCSSIZE ioctl call in the initialization code. Paul Gilmartin reports that for Solaris 2.6 (sparc), stty does not show that xterm sets rows and columns unless the second ioctl is executed.
  • correct treatment of empty parameter list for some OSC strings (report by Sami Farin <sfarin@ratol.fi>).

Patch #158 - 2001/9/8 - XFree86 4.1.0

  • augment key translations for scrollbar widget to ensure that keystrokes intended for the text area are not lost if the mouse pointer happens to fall on the scrollbar. This can happen, for instance, if the user's app-defaults or .Xdefaults file contains a translations resource, though it may also happen through unrelated resource settings: probably a bug in libXt (reported by Paul Fox <pgf@foxharp.boston.ma.us> and Dmitry Yu. Bolkhovityanov <D.Yu.Bolkhovityanov@inp.nsk.su>).
  • widen ifdef's in xterm.h to define __EXTENSIONS__ on Solaris, for compilers other than gcc. This was added along _POSIX_C_SOURCE with in patch #151, but is not sufficient since Sun's compiler does not define __STDC__ by default (report by Matthias Scheler <tron@zhadum.de>).
  • modify xterm to obtain the closest matching color if an exact color is not available, e.g., on 8-bit displays (patch by Stephen P Wall)
  • implement "OverTheSpot" preedit type of XIM input (patch by Tomohiro Kubota):
    • This preedit type is a reasonable compromise between simpleness of implementation and usefulness. "Root" preedit type is easy to implement but not useful; "OnTheSpot" preedit type is the best in the point of view of user interface but very complex. And more, "OverTheSpot" is the preedit type which the most XIM servers support. Thus, to achieve reasonable usability, support of "OverTheSpot" preedit type is needed.
    • In "OverTheSpot" preedit type, the preedit (preconversion) string is displayed at the position of the cursor. On the other hand, it is XIM server's responsibility to display the preedit string. Thus, it is needed for XIM client (here XTerm) to inform the XIM server of the cursor position. And more, to achieve good visual proportion, preedit string must be written using proper font. Thus, it is XIM client's responsibility to inform the XIM server of the proper font. The font must be supplied by "fontset". Fontset is a set of fonts with charsets which are specified by the current locale. Since XTerm uses ISO10646 fonts regardless of the current locale, the fonts for XIM must be prepared separately. It is difficult to prepare fonts which are similar to XTerm font. Thus, my patch uses a simple way - the default font is "*" which matches every fonts and X library will automatically choose fonts with proper charsets. I added "-fx" command option and "ximFont" resource to override this default font setting.
    • changed the definition of "OverTheSpot" preedit type from XIMPreeditPosition|XIMStatusArea to XIMPreeditPosition|XIMStatusNothing. This matches the behavior of other programs such as Rxvt, Kterm, Gedit.
    • A tiny XIM bugfix is also included. By calling XSetLocaleModifiers() with parameter of "", it can consier XMODIFIERS environmental variable which is a standard way for users to specify XIM server to be used.
  • adjust configure script to accommodate repackaging of keysym2ucs.c as include-file for xutf8.c (patch by Tomohiro Kubota).
  • add the UXTerm app-defaults file to makefile install rules (request by Juliusz Chroboczek).
  • correct logic in get_termcap(), which returned false if the tgetent() call indicated that xterm was linked with terminfo. Although the $TERMCAP variable cannot be adjusted in this case, xterm still needs information from this call to extract data to initialize the erase-mode when the ptyInitialErase resource is false.
  • modify ScrollbarReverseVideo() function to cache the original border color, so it can restore that when an application flashes the screen (Bugzilla #38872).
  • resync with XFree86 CVS
    • remove ifdef's for X_NOT_STDC_ENV (patch by David Dawes).
    • add Cygwin to special errno handling case in ptydata.c (Alan Hourihane)
    • set screen size earlier in initialization, to address a race with window manager resizing its clients (Keith Packard).

Patch #157 - 2001/6/18 - XFree86 4.1.0

  • clean up button.c and input.c (patch by Juliusz Chroboczek). The basic idea is to use a single set of APIs in the XTerm core, and put a set of workarounds in a separate file. As you will notice, this drastically simplifies parts of the code; in particular, the only remaining ifdefs related to the differences between Xutf8 and legacy systems are related to the selection provider logic. This defines two new files, xutf8.h and xutf8.c, provide some half-hearted but fully portable emulation for the three Xutf8* functions that XTerm uses. Putting these in a separate file will allow people to experiment with more complex versions without making the core of XTerm more difficult to maintain. The functionality of the emulation is as follows.
    • Xutf8TextListToTextProperty fully handles XStringstyle and XUTF8StringStyle. It will only generate STRING for XStdICCTextStyle, and wil only generate Latin-1 in XCompoundTextStyle (but label it as COMPOUND_TEXT, as the spec requires). (I have hesitated to make this function fail for XStdICCTextStyle and XCompoundTextStyle; this might be a smart thing to do, in the hope that the selection requestor will try UTF8_STRING afterwards; opinions?)
    • Xutf8TextPropertyToTextList fully handles STRING and UTF8_STRING. It systematically fails for COMPOUND_TEXT.
    • Xutf8LookupString will properly handle single-keystroke input for the keysyms covered by Markus' keysym2ucs function. It will not handle either compose key input or external input methods.
  • add an ifdef for SunXK_F36, used in xtermcapKeycode() (patch by Mark Waggoner <waggoner@ichips.intel.com>).
  • modify check for login name to try getlogin() and $LOGNAME, $USER environment variables to detect if the user has logged in under an alias, i.e., an account with the same user id but a different name (Debian bug report #70084).
  • add resource tiXtraScroll, which can be used to preserve the screen contents in the scrollback rather than erasing it when starting a fullscreen application such as vi (patch by Ken Martin <fletcher@catsreach.org>).
  • two patches by Denis Zaitsev <zzz@cd-club.ru>:
    • added forceBoxChars resource to control the "line-drawing characters" option.
    • added freeBoldBox resource, which, when set true, suppresses check in same_font_size(), so xterm does not attempt to ensure that the bold font is the same size as the normal font.
  • change the color class for ANSI colors and similar ones such as bold-color, etc., to follow the convention that the classname is the instance name with a leading capital (e.g., color0 and Color0 rather than color0 and Foreground). There was little use for Foreground as a class other than to create occasional confusion and bug reports, most recently by Nelson Beebe who reports that it disables colors in xterm but not on Linux, which is probably due to a difference in resource evaluation order. A configure script option (--disable-color-class) is provided for anyone who did use the older behavior.
  • fix a signal-handling bug. When running xterm with ksh or similar shell such as bash 2.05, xterm will hang and not respond to keystrokes after the user types suspend. Additionally the popup menus do not respond, so it is not possible to send SIGCONT to the shell. What is happening is that the shell is sending itself SIGSTOP, and it is being stopped. Per specification it also means that the operating system is sending SIGCHLD to parent to the bash (XTERM). Now the issue is that xterm assumes it cannot happen and it expects to receive SIGCHLD only upon termination of its children. This causes a deadlock with xterm waiting for the child to die, and the child waiting for SIGCONT. (report/patch by Adam Sulmicki), analysis/testing by Sven Mascheck <sven.mascheck@student.uni-ulm.de>).
  • correct some inconsistent checks for XtReleaseGC() calls in xtermLoadFont() (patch by Nam SungHyun <namsh@lge.com>).
  • updated wcwidth.c and keysym2ucs.c to versions dated 2001/1/12 and 2001/4/18, respectively from http://www.cl.cam.ac.uk/~mgk25/ucs/
  • correction to change from patch #90, which was intended to reset the saved cursor position for normal/alternate screens on a soft reset, but actually wiped out all of the saved cursor information. Just reset the saved position for the current screen (report by Michael Schroeder).
  • modify ShowCursor() and HideCursor() so that if the cursor points to the second part of a wide character, make the show/hide operate on the first position of the wide character (patch by Sven Verdoolaege).
  • scrolling in the alternate screen just before switching back to the main screen can cause extra blank lines to be inserted into the scrollback buffer (patch by Paul Vojta <vojta@math.berkeley.edu>).
  • resync with XFree86 4.1.0:
    • Use TermcapLibrary as -lncurses instead of -ltermcap, fixes problem building xterm/resize on Cygwin/XFree86 (Harold Hunt).
    • Install xterm.termcap and xterm.terminfo when installing xterm (Torrey T. Lyons).
    • Fix some build issues on Cygwin/XFree86 (Suhaib Siddiqi).
    • Define CBAUD, when it's missing in xterm, on LynxOS (Stuart Lissaman).

Patch #156 - 2001/4/28 - XFree86 4.0.3

  • change order of selection-target types to make 8-bit xterm prefer UTF8_STRING to COMPOUND_TEXT (patch by Juliusz Chroboczek).
  • document -fa, -fs command-line options and faceName, faceSize resources which are used by the freetype library support.
  • if configure script finds freetype libraries, but imake definitions do not have the XRENDERFONT definition, define it anyway.
  • modify configure script check for freetype libraries to include <Xlib.h>, since an older version of the related headers relies on this (patch by Adam Sulmicki).

Patch #155 - 2001/4/20 - XFree86 4.0.3

  • correct return type of in_put() from patch #153 changes, which left it not wide enough for UTF-8 (patch by Bruno Haible).

Patch #154 - 2001/4/11 - XFree86 4.0.3

  • undo check for return value from pututline (used for debugging) since that function does not return a value on Slackware 3.6.
  • correct length in ScreenWrite, when rendering invisible text (patch by Sven Verdoolaege <skimo@kotnet.org>).
  • fixes/improvements for the i18nSelection resource from patch #153, by Bruno Haible:
    • add missing initialization for i18nSelection resource.
    • split-out the non-ICCM aspect of the i18nSelection resource as a new resource, brokenSelections.
  • add configure check for <time.h> and <sys/time.h>, to allow for Unixware 7, which requires both. If the configure script is not used, only <time.h> will be included as before (report by Thanh Ma).
  • fix redefinition of dup2, getutent, getutid, getutline and sleep functions on Unixware 7 (report by Thanh Ma <Thanh.Ma@casi-rusco.com>)
  • add a fall-back definition for __hpux, which is apparently not defined in some compilers on HPUX 11.0 (reported by Clint Olsen).
  • change VAL_INITIAL_ERASE, which is used as a fallback for the "kb" termcap string to 8, since that matches the xterm terminal description (request by Alexander V Lukyanov).
  • correct an off-by-one in ClearInLine, which caused the erase-characters (ECH) control to display incorrectly (patch by Alexander V Lukyanov).
  • correct escape sequences shown in terminfo for shifted editing keys. The modifier code was for the control key rather than the shift key.

Patch #153 - 2001/3/29 - XFree86 4.0.3

  • increase PTYCHARLEN to 8 for os390, add some debugging traces for UTMP functions (patch by Paul Gilmartin).
  • correct an misplaced brace in SelectionReceived() (patch by Bruno Haible).
  • correct an assignment dropped in SelectionReceived() which made it not compile for wide-characters combined with debug traces.
  • correct typo, clarify description of 88- and 256-color controls (report by Bram Moolenaar).
  • correct a typo in ctlseqs.ms which caused DEC Locator control sequences using single quote "'" display grave "`" instead (reported by Paul Williams, apparently in patch #114).

Patch #152 - 2001/3/13 - XFree86 4.0.2

  • correct index in inner loop in VTInitI18N() from patch #151 changes, which resulted in infinite loop under some conditions (report/analysis by Paul Gilmartin).
  • remove spurious "%|" from terminfo sgr capabilities (report/analysis by Adam M Costello, Debian #89222).
  • add shell script to adjust list of dynamic libraries linked by resize when building with the standalone configure script. Otherwise it uses the same list as for xterm, which is excessive.
  • fix a few compiler warnings reported by the 20010305 gcc snapshot.

Patch #151 - 2001/3/10 - XFree86 4.0.2

  • alter the behaviour of selections in XTerm (patch by Juliusz Chroboczek). It is believed to follow the ICCCM + UTF8_STRING to the letter, both in UTF-8 and in eight-bit mode. From his description:
    • When compiled against XFree86 4.0.2, the patched XTerm will make the selection available as COMPOUND_TEXT, STRING or UTF8_STRING in both modes. It will request selections in the following order:

      UTF-8 mode: UTF8_STRING, TEXT, COMPOUND_TEXT, STRING.
      eight-bit mode: TEXT, COMPOUND_TEXT, UTF8_STRING, STRING.

    • When compiled against an earlier version of XFree86 (or compiled with OPT_UTF8_API=0), it will still obey the ICCCM, but will neither request nor provide UTF8_STRING in eight-bit mode, and neither TEXT nor COMPOUND_TEXT in UTF-8 mode.
    • For compatibility with previous versions of XTerm, a resource i18nSelections is provided, please see the manpage for details. However, due to an unexpected combination of ICCCM extensions by various bits and pieces of the libraries, interacting with previous versions of XTerm will work in many locales even without this flag. (Please do not set this resource to true by default, as this would violate the ICCCM.)
  • improved error checking/reporting in VTInitI18N(), ensuring that lack of input method styles is treated distinctly from a mismatch.
  • remove an incorrect ifdef from patch #141 which suppressed overstriking to simulate bold font when xterm was compiled to support wide characters (report/analysis by Adam M Costello <amc@cs.berkeley.edu>, Debian #76404, Debian #77575).
  • modify RequestResize() function to save/restore window manager hints. Its call to XtMakeResizeRequest() had the undesirable side-effect of clearing window manager hints, e.g., when switching to 132-columns via DECCOLM escape sequence. Window manager hints make it simple to resize xterm in terms of character cells rather than pixels (reports by Christian Weisgerber, Debian #79939).

    This applies to the normal configuration. When built with toolbar support, the hints are applied to a different widget level (more work will be needed to make hints work with the toolbar).

  • fix a redefinition warning for resize.c on OpenBSD (patch by Christian Weisgerber).
  • change resource corresponding to -T option to match Xt library's -title, i.e., .title rather than *title so the command-line options are interchangeable as documented (Debian bug report #68843).
  • add script used from autoconf'd makefile for installing manpages, since recent XFree86 changing the way section numbers are represented makes the install dependent on extra scripts.
  • add configure check for freetype libraries and configure option --disable-freetype to override this feature.
  • modify some configure script macros to avoid using changequote(), which has been rendered useless in the latest autoconf alpha 2.49c
  • update config.guess, config.sub to 2001-2-13
  • remove redundant/contradictory __CYGWIN__ definitions from resize.c
  • correct manpage typo introduced by X11R6.5 resync.

Changes from XFree86 4.0.2:

  • add definition of _POSIX_C_SOURCE for Solaris to make this compile with gcc -ansi -pedantic (report by <mark@zang.com>.

Patch #150 - 2000/12/29 - XFree86 4.0.2

  • move the binding for shifted keypad plus/minus, which invokes the larger-vt-font() and smaller-vt-font() actions, respectively, into the translations resource (suggested by Marius Gedminas <mgedmin@puni.osf.lt>).
  • modify configure script to support the --program-prefix, --program-suffix and --program-transform-name options (request by Alison Winters <alison@mirrabooka.com>).
  • fixes for wide/combining characters (Robert Brady):
    • fix a scrolling / combining characters display anomaly
    • fix a problem with double-width characters where if the primary font had no box-drawing characters, the right hand half of double-width characters was erased (reported by Yao Zhang <yzhang@sharemedia.com>).
    • fix special case of null byte for key handling in UTF-8 locales.
  • modify logic that compares sizes of normal and bold fonts to be more forgiving of the font server's choice of bold font which must match the normal font's size. Now same_font_size() compares the height of the fonts rather than individually ascent and descent, and allows the bold font to be one pixel smaller than the normal font (addresses a report by Alan Citterman <alan@mticket.com>, who says that something in patches #146 to #148 made xterm more likely to overstrike bold fonts, and indirectly Debian bug report #76404, which reports the opposite).
  • make configure script use $CFLAGS and $CPPFLAGS consistently, including removing a chunk from configure.in which attempted to save/restore $CPPFLAGS while processing value set by the --x-includes option, but lost values set in an intervening AC_CHECK_HEADERS. This change modifies macros CF_ADD_CFLAGS, CF_ANSI_CC_CHECK and CF_X_TOOLKIT, as well as removing variables IMAKE_CFLAGS and X_CFLAGS from the generated makefile (the AC_CHECK_HEADERS problem was reported by Albert Chin-A-Young <china@thewrittenword.com<).
  • correct a comparison in SELECTWORD case of ComputeSelect(), which resulted in a word-selection wrapping past the first column without checking the first column's character class (reported by Christian Lacunza <celacunza@netscape.net>
  • correct a logic in UTF-8 mode for selecting double-width characters; a combining character was omitted (patch by Markus Kuhn).
  • add feature to pop (raise) window when a bell is received (patch by Gael Roualland <gael.roualland@dial.oleane.com>).
  • add __NetBSD__ and __OpenBSD__ to special-case in xterm_io.h for USE_POSIX_TERMIOS definition (patch by Christian Weisgerber).
  • move special-case HPUX include for <sys/bsdtty.h> to xterm_io.h to define TIOCSLTC, making HAS_LTCHARS defined for HPUX 10.20 (report by Bruno Betro).

Patch #149 - 2000/12/6 - XFree86 4.0.1h

  • restructured includes for termios.h, termio.h and related definitions for main.c, os2main.c, screen.c and resize.c so they will share equivalent definitions in a new header xterm_io.h. This is intended to solve some problems mainly for HPUX which appear to arise from inconsistent definitions for SIGWINCH- and HAS_LTCHARS-related symbols (reports by Bruno Betro, Jeremie Petit and Clint Olsen).
  • improve usability of double-width fonts by allowing normal fonts to be given as double-width (from a patch by Fabrice Bellard <bellard@email.enst.fr>).
  • correct a few compiler warnings in TRACE() macros for signed/unsigned variable differences (reported by Clint Olsen).
  • make configure script use $CFLAGS and $CPPFLAGS more consistently, i.e., by using CF_ADD_CFLAGS in CF_ANSI_CC macro.
  • expanded description of environment variables in manual-page.
  • modify OPT_TCAP_QUERY feature to always return the termcap or terminfo capability string in the response, and to read/write the names in hexadecimal form to allow for the special case of termcap's k; name (patch by Bram Moolenaar).
  • add OPT_SAME_NAME and OPT_TCAP_QUERY to xtermcfg.hin, so the corresponding configure options work (patch by Bram Moolenaar).
  • resync with XFree86 4.0.1g:
    • Rewrite Xft library for Render extension/core text and font management Change xterm to use new interface (Keith Packard).

Patch #148 - 2000/10/31 - XFree86 4.0.1d

  • document logfile options in man-page.
  • correct spelling of -samename option in help message.
  • add configure script option --enable-tcap-query (request by Bram Moolenaar).
  • add a "Co" or "colors" entry to the OPT_TCAP_QUERY feature (patch by Bram Moolenaar).
  • patch by Kiyokazu Suto <suto@ks-and-ks.ne.jp>:
    • add support for bold font for double width characters. The font name may be specified with the command line option -fwb or with resource wideBoldFont (class WideBoldFont).
    • correct underlining of double width character string, which was drawn only half width.
    • correct binary search of precomposed character table, which may return wrong result when int is just 32 bits.
  • some changes to align terminfo with ncurses 5.2:
    • remove xtermm description, retaining xterm-mono since the former conflicts with ncurses.
    • modify initialization and reset strings to avoid putting the save/restore cursor operations bracketing changes to video attributes, since the changes could be lost when the cursor is restored. This affects xterm-r6 and xterm-8bit (the xterm-xfree86 entry uses the soft-reset feature which resets scrolling margins and origin mode without requiring us to save/restore the cursor position).
    • make a few entries explicitly inherit from xterm-xfree86 rather than xterm: xterm-rep, xterm-xmc, xterm-nrc
  • ensure that sign-extension does not affect ctype macros by using CharOf() macro to coerce the parameter to an unsigned char.
  • resync with XFree86 4.0.1d:
    • Add primitive support in xterm for Xft based fonts (Keith Packard). The changes are ifdef'd with -DXRENDERFONT.

Patch #147 - 2000/10/26 - XFree86 4.0.1c

  • correct implementation of ptyInitialErase: the value assigned to initial_erase was for the control terminal, which is correct as far as it goes. But there was no following test for the pseudo-terminal's erase value, which would overwrite the default obtained from the control terminal (reported by Christian Weisgerber <naddy@mips.inka.de>).
  • modify check for printable-characters in OSC string to use xterm's ansi_table rather than isprint() macro, to isolate this check from locale settings. This fixes a problem using 8-bit characters to set the title (reported by Ricardas Cepas <rch@richard.eu.org>).
  • modify sample scripts to check for printf before print, since the latter is not as well standardized (e.g., on Linux).
  • updated config.sub, config.guess to reflect changes on subversions.gnu.org

Patch #146 - 2000/9/12 - XFree86 4.0.1c

  • correct two instances overlooked from patch #141 which assumed UTF-8 mode without checking, causing a core dump in non-UTF-8 mode (one instance was reported by Tommi Virtanen <tv@debian.org>).
  • correct a problem selecting from the scrollback buffer in UTF-8 mode by changing remaining getXtermCell() calls to XTERM_CELL() as in the non-UTF-8 cases (report by Markus Kuhn, patch by Robert Brady).

Patch #145 - 2000/9/11 - XFree86 4.0.1c

  • changes for UTF-8 configuration (Robert Brady):
    • doublewide characters don't lose their accents when the cursor moves onto or from them (a visual bug)
    • fix logic in addXtermCombining, which mean that if the low byte of a cell's first combining char was 0, a following combining char would go into combining slot 1, not 2.
    • modify logic for cut-buffers so UTF-8 data is first converted to Latin1.
    • collapse surrogates, 0xfffe, 0xffff to UCS_REPL.
    • modify to allow xterm to to show combining characters attached to doublewidth characters.
    • correct bug in linewrap with -u8 option (reported by Andreas Koenig <andreas.koenig@anima.de>).
  • several changes to PTY logic (based on request by Tim Ryan <timryan@nortelnetworks.com>).
    • modify treatment of -S option to to make it work with Unix98 PTY's.
    • restore sense of IsPts flag in get_pty(), which was lost in Unix98 changes.
    • use new functions my_pty_id() and my_pty_name() to simplify/fix strings used for utmp, wtmp identifiers.
    • simplify get_pty() function, making it have a single return point so its inputs/outputs can be identified.
  • update config.guess and config.sub and scripts to my 20000819 patch, adding cases for OS/2 EMX.
  • add special case for os390 compiler options to configure script (patch by Paul Gilmartin)
  • fix some unused-variable compiler warnings (reported by Zdenek Sekera).
  • split-out some string functions into xstrings.c, to use them more consistently among main.c, os2main.c and resize.c
  • align termcap/terminfo files, adding entries to make them match. The termcap entries are necessarily less complete than the terminfo, to fit within 1023 character per entry.
  • add terminfo entry for xterm-sco (SCO function keys).
  • modify same_font_name() to properly handle wildcard introduced in bold_font_name(), making comparison for different fonts succeed when only the normal font is specified. This is needed to decide if 1-pixel offset should be used. (reported in a newsgroup by Bart Oldeman <enbeo@enbeo.resnet.bris.ac.uk>)
  • correct preprocessor line for OPT_WIDE_CHARS in drawXtermText() from patch #141 which resulted in overstriking for bold fonts not working.
  • correct Imakefile from 4.0.1c resync so UTF-8 modules are in UTF8SRC, UTF8OBJ lists, allowing build without UTF-8 support.

Patch #144 - 2000/8/23 - XFree86 4.0.1b

  • remove a spurious assignment in ScreenWrite() from Robert Brady's patch which set a null at the "end" of the buffer to be written. That made the autowrap feature write a blank in the first column for the non-UTF-8 configuration, rather than the actual character (reported by Alan Citterman <alan@mticket.com>).

Patch #143 - 2000/8/19 - XFree86 4.0.1b

  • add a check to ensure that -class command-line option is not confused with -c (reported by Paul Townsend <aab@aab.cc.purdue.edu>).

Patch #142 - 2000/8/18 - XFree86 4.0.1b

  • correction to precompose scripts, so 0061 + 0300 will now be really be displayed as 00C0 (patch by Robert Brady <robert@susu.org.uk>).
  • correct macro ClassSelects() in button.c, used to hide ifdef's for OPT_WIDE_CHARS in patch #141 (reported by Andreas Paul <paula@informatik.tu-muenchen.de>).
  • change wcwidth.h to include stddef.h rather than wchar.h, which is not present on OpenBSD and FreeBSD (reported by Christian Weisgerber and Bram Moolenaar).
  • newer config.sub and config.guess, from lynx 2.8.4dev.7

Patch #141 - 2000/8/14 - XFree86 4.0.1b

  • changes for doublewidth and combining characters, from http://www.ecs.soton.ac.uk/~rwb197/xterm/ (integrated patch by Robert Brady). In this context, doublewidth refers to 16-bit character sets which may have glyphs occupying two cells.
  • add command-line option -class, which allows one to override xterm's resource class. Also add resource file UXTerm.ad, which simplifies using xterm for both 8-bit character sets and UTF-8.
  • fixes/improvements to OPT_TCAP_QUERY logic (patches by Bram Moolenaar, Stephen P Wall).

Patch #140 - 2000/7/23 - XFree86 4.0.1

  • modify Makefile.in to circumvent GNU make's built-in suffix rule for ".sh" which confuses install.sh with the "make install" target (report/patch by Paul Gilmartin).
  • implement an experimental control sequence which an application may use to query the terminal to determine what sequence of characters it would send for a given function key. This is ifdef'd with OPT_TCAP_QUERY (request by Bram Moolenaar).
  • add /usr/local to search path in CF_X_ATHENA configure macro to build with Xaw3d on OpenBSD (patch by Christian Weisgerber).
  • add missing #undef HAVE_TERMIO_C_ISPEED to xtermcfg.hin, omitted in patch #133 fix for IRIX 6.5 baudrate (report by Alain Filbois <Alain.Filbois@loria.fr>).
  • correct a few errors in xterm.man: font in filename example for Tektronix emulation, and description of -nul/+nul command-line options (report by Eric Fischer <enf@pobox.com>).
  • update config.guess and config.sub, from tin and lynx.

Patch #139 - 2000/6/17 - XFree86 4.0d

  • back out change to -name command-line option, restoring its original behavior (as noted by David Madore, the correct interpretation of this option is the application instance rather than the application class).

Patch #138 - 2000/6/15 - XFree86 4.0c

  • workaround for fixed fonts which are generated from Unicode fonts: they omit glyphs for some xterm's less-used line-drawing characters, which caused xterm to set a flag telling it to use only its internal line-drawing characters. Do not set the flag (it can be set from the popup menu), and xterm will generate only the line-drawing glyphs which actually are missing.
    Otherwise, when used for large fonts, xterm may generate a 2-pixel wide line, which can leave dots on the screen.
  • restore first line of 256colres.pl, omitted in 4.0c diffs.

Patch #137 - 2000/6/10 - XFree86 4.0b

  • make command-line -name option work as documented. Apparently this was lost in X11R5 when coding to use XtAppInitialize.
  • limit numeric parameters of control sequences to 65535 to simplify checks for numeric overflow.
  • change index into UDK list to unsigned to guard against numeric overflow making the index negative (Taneli Huuskonen <huuskone@cc.helsinki.fi>).
  • change sun function-keys resource name to sunFunctionKeys to work around redefinition of the token sun by xrdb on Solaris. Similarly, renamed resource sun keyboard to sunKeyboard (Stephen P Wall).
  • change similar resource names for HP and SCO to avoid potential conflict with xrdb symbols on other systems, as well as for consistency.
  • reorganized the install targets in the autoconf'd Makefile, adding install-app, install-bin, install-dirs and install-man. The app-defaults class can be overridden by setting the make variable 'CLASS', simplifying customization of xterm as a Unicode terminal, e.g., CLASS=UXTerm.
  • add limit checks to ClearInLine(), ScrnInsertChar(), ScrnDeleteChar() to correct potential out-of-bounds indexing (prompted by Debian bug report #64713, which reported a problem with ICH escape sequences).
  • updates to config.sub and config.guess Kevin Buettner <kev@primenet.com> for elf64_ia64 Bernd Kuemmerlen <bkuemmer@mevis.de> and MacOS X.
  • for os390, add check for errno set to ENODEV on failure to open /dev/tty when there is no controlling terminal (patch by Paul Gilmartin).
  • fixes for building on Digital Unix 4.0 and AIX 4.2 (patch from H Merijn Brand <h.m.brand@hccnet.nl>).
  • modify DECRQSS reply for DECSCL to additionally report if the terminal is set for 8-bit controls.

Patch #136 - 2000/6/3 - XFree86 4.0b

  • add a resource (limitResize) limiting resizing via the CSI 4 t and CSI 8 t sequences.
  • ignore out-of-bounds resize requests, i.e., where sign-extension or truncation of the parameters would occur.

Patch #135 - 2000/5/29 - XFree86 4.0b

  • remove code introduced in #134 which made some backgrounds bold.
  • minor correction to format of updated $TERMCAP when adding kb capability for ptyInitialErase logic.
  • improved test for SVR4 definition.

Patch #134 - 2000/5/28 - XFree86 4.0b

  • update URL's and mailing addresses, moved to http://dickey.his.com and dickey@herndon4.his.com
  • correct missing quotes in CF_TTY_GROUP configure script macro in case the script is run in batch mode.
  • modify ownership-check of log file to ignore the group ownership. Otherwise xterm cannot create logfiles in directories with set-gid permissions.
  • simplify the logic that reads termcap data.
  • add fallback definition for B9600 in case line speed definition for 38400 is missing (report by Jack J Woehr <jwoehr@ibm.net>, for OpenBSD 2.6).
  • fix: Set highlightColor, and select a region containing the text cursor. If the window loses focus, the cursor becomes hollow, with the region inside the cursor being background/foreground, unlike the rest of the selection, which is foreground/highlight (patch by Ross Paterson <ross@soi.city.ac.uk>).
  • add configure script tests to define SVR4, SYSV and USE_POSIX_WAIT, which enables xterm to compile on Solaris 7 and SCO Openserver without imake, though there are still a few features for the latter which require sco to be predefined.
  • patches from Stephen P Wall:
    • add support for two Sun-specific function keys. These keys are labeled F11 and F12 on Sun Type 5 keyboards, but return SunXK_F36 and SunXK_F37. Support will only be compiled in if the header file <X11/Sunkeysym.h> exists and contains the appropriate symbol definitions. The keycodes for the DEC keycodes were arbitrary unused codes, but the ones for the Sun keycodes are what cmdtool and shelltool actually send.
    • add colorRV and colorRVMode resources to allow specifying a color to use for reverse video, similar to the existing UL, BD, and BL modes.
    • add alwaysUseMods resource, to override check if alt or meta modifiers are used in translations resource. Revamped the code to calculate the modifier value, and included Meta if alwaysUseMods is TRUE, using values 9-16.
  • fixes for os390 (Paul Gilmartin):
    • regularize the definition of CONTROL() and remove an acknowledged "trial and error" table.
    • translate "^?" into A2E(0177) which is the EBCDIC "DEL" rather than plain 0177 which is the EBCDIC quotation mark.
    • modify xtermMissingChar() so that EBCDIC codes 128-159 are not rendered as blanks by X server running on Solaris, which sees those as control characters.
    • make debugging traces (configure --enable-trace) work properly with EBCDIC.

Patch #133 - 2000/5/2 - XFree86 4.0a

  • add substitutions in autoconf'd Makefile for CPPFLAGS, LDFLAGS and AWK (reported by Neil Bird).
  • correct uninitialized childstat variable from patch #131 in creat_as() function, which caused logging to not work on Solaris, whose waitpid() function does not initialize its parameter. Add check for EINTR on return from waitpid() as well (reported by Neil Bird <neil.bird@rdel.co.uk>).
  • remove a redundant check for working setuid() function introduced in patch #132. Greg Smith reports that this does not work as intended on os390.
  • change line speed from 9600bd to 38400bd, to accommodate people who mistakenly use $TERM set to vt100, to reduce the effect of padding associated with this terminal type.
  • add configure script check for IRIX 6.5's redefinition of baud rates associated with struct termio, to correct a situation where the baud rate was initialized to zero (reported by Andrew Isaacson <adi@lcse.umn.edu>).
  • remove unused configure script check for VDISABLE.

Patch #132 - 2000/4/11 - XFree86 4.0a

  • undo an incorrect change from patch #113 caused the right scrollbar to be positioned incorrectly when re-enabling it (analysis by D Roland Walker).
  • add ctrlFKeys resource, replacing constant for adjusting control-F1 to control-F12 to VT220-style F10-F20. The resource changes the constant 12 to a default value of 10 (request by Jim Knoble <jmknoble@pobox.com>).
  • correct ifdef'ing for conflict between definitions in AIX's <sys/select.h> and <X11/Xpoll.h> (reported by Clint Olsen).
  • add checks for return-values of getutid(), initgroups() and setuid() in main.c, as well as modifying ifdef's for __osf__ to include tty-group and WTMP logic (adapted from patch by Paul Szabo <psz@maths.usyd.edu.au>)
  • modify resize.c to build and work on os390 (uses EBCDIC) (adapted from patch by Phil Sidler <Phil.Sidler@airborne.com>)
  • use Ires(), Bres() and Sres() macros to simplify resource list in charproc.c
  • resync with XFree86 4.0a:
    • correct a typo in os2main.c (Holger Veit, from 4.0a).

Patch #131 - 2000/3/3 - XFree86 3.9.18b

  • improve logfile security (integrated patch by Branden Robinson)
    • make the creat_as() function more strict by using O_EXCL rather than O_APPEND.
    • fixes to make DEBUG ifdef's compile/run, including making the debug logfile more unique by appending a timestamp to its name.
    • include <term.h> in resize.c, to fix a missing-prototype warning.
  • modified creat_as() a little more, retaining the ability to append to a logfile If the user specifies the name. Also, check if the opened file (which patch #130 ensures is owned by the effective user) is not writable by other users.
  • use creat_as() logic to make tek4014 screen-copy more secure (noted by Branden Robinson).
  • ifdef'd some of Branden's changes to build/work on older machines.
  • correct missing initialization of the .mode flag in ColorRes struct, from patch #129. This worked on Linux because malloc() zeroes memory on that platform (reported by Christian Weisgerber).
  • modify logic for deleteIsDEL resource so it has internally 3 states: unspecified, true and false. If unspecified, the keyboard type determines whether the Delete key transmits <ESC>[3~ or \177, and the popup menu entry reflects the internal state. Otherwise, the popup menu entry overrides the keyboard type (suggested by Dr Werner Fink, to make it simpler to set resources that imitate the legacy X11R6 xterm).

Patch #130 - 2000/3/1 - XFree86 3.9.18a

  • modify scroll-forw() and scroll-back() actions, adding a third parameter which will direct xterm to ignore the action when mouse reporting is enabled. This is needed for the wheel mouse to be used to report to the application rather than scroll the window.
  • add menu entry and action to allow disabling xterm's assumption that the current font contains line-drawing characters if the font cells 1-31 are nonempty. Some fonts may have other characters (reported by Bruno Betro <bruno@iami.mi.cnr.it>).
  • add a check in creat_as() to ensure that the user really owns the logfile that has been opened.
  • add logic to implement SCO function-keys. (This is really incomplete, since I intend to revisit this and make xterm able to emulate scoansi better than just the function-keys).
  • add configure script option --enable-sco-fkeys, minor related fixes (patch by Dr Werner Fink).
  • fix typos in ctlseqs.ms (reported by Bram Moolenaar)
  • fix typo in sinstall.sh default for $TST_PROG (reported by Paul Gilmartin <pg@sweng.stortek.com>)

Patch #129 - 2000/2/26 - XFree86 3.9.18a

  • improve initialization of ANSI colors by delaying allocation until each color is first used.
  • remove ifdef that prevented colorBD/colorUL/colorBL resources from working when 256-color configuration was built (reported by Todd Larason).
  • fix some minor inconsistencies in terminfo (Debian #58530).

Patch #128 - 2000/2/17 - XFree86 3.9.18

  • correct logic for oldXtermFKeys resource, fixes a core dump when attempting to set it from the command-line (reported by Dr Werner Fink).
  • correct ifdef for meta-sends-escap so configure --disable-num-lock builds.

Patch #127 - 2000/2/12 - XFree86 3.9.17e

  • add resource, popup menu entry and control sequence to allow changing the Delete key to send either DEL or the VT220-style Remove escape sequence.
  • remove logic for metaSendsEscape that would allow xterm to send <ESC>[3~ before a function key that would begin with <ESC>[3~ (request by Christian Weisgerber).
  • add missing action and documentation for meta-sends-escape.
  • correct a few typos in ctlseqs.ms (incorrect code for Cyan color)

Patch #126 - 2000/2/8 - XFree86 3.9.17c

  • ensure that xterm will automatically activate the UTF-8 mode whenever the name of the locale environment variable suggests that a UTF-8 locale is in use (patch by Markus Kuhn). This will help that by simply setting LC_CTYPE an entire system can be switched over to UTF-8, without users having to remember the UTF-8 command line options ("-u8", etc.) of the various applications. Command line options and X resource entries can still be used to override this default choice.
  • add old function-keys control sequences and popup menu entry, for compatibility with legacy X11R6 xterm.
  • revert translation of editing keypad "Delete" key to legacy \177.
  • simplify the color-resource data expressions with macro COLOR_RES, for later use in restructuring color initialization.
  • change encoding of wheel mouse (buttons 4 and 5) to avoid conflict with legacy mouse modifiers (suggested by Bram Moolenaar).

Patch #125 - 2000/1/31 - XFree86 3.9.17c

  • make this work on OpenVMS (integrated patch by David Mathog).
  • rename some functions, e.g., Index to xtermIndex so that ports such as VMS which link externals ignoring case will not have library conflicts (reported by David Mathog).
  • correct logic of do_reversevideo(), which did not update the corresponding popup menu check mark (reported by David Mathog, this was a detail overlooked in patch #94).
  • change TRACE macro so semicolon is not within definition, making indent and similar programs work better.
  • add depend rule to Makefile.in
  • modify logic of boldColors resource to suppress it if an extended color control has been used, e.g., for 88-color or 256-color mode (patch by Todd Larason).
  • revise logic that handles menus and input translation for keyboard type so only one can be selected at a time.
  • restore kdch1=\177 for the Sun function-key type, and make the the Delete key send DEL (\177) if the oldXtermFKeys resource is set.
  • rephrase logic and ifdef's for POSIX VDISABLE to avoid preprocessor expression that will not compile on NetBSD/x86 1.4.1 (reported by Takaaki Nomura <amadeus@yk.rim.or.jp>).

Patch #124 - 2000/1/27 - XFree86 3.9.17b

  • change coding of editing keypad's "Delete" key to <escape>[3~, in the default (Sun/PC) keyboard mode. This makes the terminfo kdch1 capability independent of the coding of the backarrow key, which sends either backspace (8) or DEL (127). The reason for doing this (compatibility with the screen program) outweighs the choice of DEL (127) which was used in X11R5/X11R6 xterms. The screen program translates whatever matches kdch1 into <escape>[3~, even if it happens to be the stty erase character.
  • add encoding for control/?, to work around xmodmap or key translations which may confuse backspace and delete. A control/? will send DEL (127), and a control/H will of course send backspace (8).
  • add encoding for kcbt to <escape>[Z (fixes Debian #54840).
  • minor correction to logic that encodes Sun and DEC function keys to avoid sending an escape sequence if the key symbol is not found in xterm's lookup table.
  • simplify ifdef's in main.c for POSIX VDISABLE so the "^-" pattern is more likely to be implemented when imake configures xterm (fixes Debian #55105).
  • change manpage to make it clearer what codes are sent by the backarrow key.

Patch #123 - 2000/1/22 - XFree86 3.9.17a

  • add a note reserving OSC 51 for use in Emacs shell (request by Rob Mayoff <mayoff@dqd.com>).
  • correct a missing backslash in xterm-vt220 termcap.
  • cleanup remaining quoted includes, preferring bracketed form.
  • minor configure-script macro updates from tin and vile.
  • add configure-script option for using utempter library, adapted from Redhat 6.1 patch for XFree86 3.3.5
  • resync with XFree86 3.9.17a:
    • correction to QNX support (Frank Guangxin Liu)
    • some cosmetic changes that did not correct any reported problems.

Patch #122 - 1999/12/28 - XFree86 3.9.16f

  • move the suggested wheel-mouse button translations into charproc.c to simplify customization. Correct some minor logic errors in the support for buttons 4 and 5, used for wheel mice (reported by Bram Moolenaar).
  • implement metaSendsEscape resource, with corresponding control sequence and menu entry. Like eightBitInput, this causes xterm to send ESC prefixing the given key, but applies to all keys and is independent of the 8-bit/7-bit terminal setting. (requests by Alexander V Lukyanov and Marc Feeley).
  • correct potential indexing with negative subscript in udk_lookup(), (reported by Ian Collier <Ian.Collier@comlab.ox.ac.uk>).
  • modify configure script that sets TERMINFO_DIR to use ${prefix} rather than /usr if the --prefix option was specified (request by Zdenek Sekera <zs@sgi.com>).
  • modify checks for repeat-character control sequence to test the character class against xterm's state table, rather than the isprint() macro (patch by Alexander V Lukyanov).
  • change several functions to macros to improve speed
  • two corrections to simulation of bold font via overstriking:
    • use clipping to avoid leaving trash at end of the text, and
    • add brackets so wide-character logic does not fall-through into the overstriking logic (reported by Marc Feeley <feeley@IRO.UMontreal.CA>)
  • add several entries to termcap file to make it have the same set of aliases as the terminfo file.
  • scale the color values used for xterm-256color terminfo entry to 0..1000, as expected by ncurses.
  • change xterm-r6 terminfo definitions for F1-F4 to match program.
  • Add QNX/Neutrino support (Frank Guangxin Liu <frank@ctcqnx4.ctc.cummins.com>)

Patch #121 - 1999/11/14 - XFree86 3.9.16c

  • change label on "Sun/PC Keyboard" popup menu entry to "VT220 Keyboard", since the checked state corresponds to VT220 rather than Sun/PC.
  • add configure test CF_UTMP_UT_XSTATUS to handle the variants of utmp exit status (reports by Dave Ellement, Jeremie Petit, Tomas Vanhala).
  • amend treatment of ALT key (see patch #94) so that if ALT is used as a modifier in key translations, then no parameter will be sent in escape sequences for Sun/PC function keys (request by Dr Werner Fink).
  • modify default for OPT_I18N_SUPPORT to assume that XtSetLanguageProc() is available in X11R5.

    Caveat: XtSetLanguageProc() was added fairly late in the X11R5 patches, and some vendors shipped buggy versions of this function (request by Tomas Vanhala).

  • correct configure macro CF_SYSV_UTMP to test-link with functions consistent with the header, e.g., getutent() for utmp.h and getutxent() for utmpx.h (reported by Greg Smith).
  • modify terminfo entry for xterm-xfree86 to reflect modifiers for shift and control (from a patch by Alexander V Lukyanov).
  • modify terminfo entry for xterm-sun to match the function-key definitions in ncurses. The pageup/pagedown and related function keys correspond to the Sun keyboard, which does not necessarily correspond with X's notion of those keys.
  • modify treatment of XK_Delete keysym so it transmits parameterized VT220-style <ESC>[3~ if modifiers (shift, control alt) are given (request by Alexander V Lukyanov).
  • corrected misspelled resource name in command-line option for HP function keys.

Patch #120 - 1999/10/28 - XFree86 3.9.16c

  • refine the change to SGR_Background() in patch #119, by not flushing the pending scrolling operation if the background color is not actually changing. This combination occurs when using color-ls to display a long listing, since each line ends with an SGR0 which affects only the foreground color. The unnecessary flushing made it noticeably slower (reported by D Roland Walker <walker@pobox.com>).
  • remove obsolete documentation about modifiers which can be returned in mouse tracking mode, and modify logic to ignore modifiers other than the existing ones, e.g., NumLock (prompted by discussions with Christian Weisgerber and Brad Pepers <brad@linuxcanada.com>).
  • use free bit from obsolete shift-modifier coding of mouse tracking button events to encode buttons 4 and 5, e.g., for a wheel mouse (requests by Brad Pepers and Bram Moolenaar).
  • correct a place where the ptyInitialErase logic did not set the backarrowKey state, and modify it further to use tgetstr() rather than parse the termcap data returned from tgetent() so the ptyInitialErase logic will work when xterm is linked with a terminfo library (based on a patch by Dr Werner Fink <werner@suse.de>).
  • fix definition of HAVE_UTMP_UT_HOST for ISC configuration (patch by Michael Rohleder).
  • improve configure script's utmp tests (based on reports by Greg Smith for os390, and David Ellement for HPUX).
  • modify sinstall.sh to use uid=0 rather than 'root' to determine if the installer is privileged. This is needed on some systems since more than one account may be privileged (report by Greg Smith).
  • add an application resource, messages (and a corresponding -/+mesg option) which controls the initial permission on the terminal: if messages is set to true (the default), behavior is as without the patch; if it is set to false (as per -mesg), the terminal is opened in mode 0600, thus producing the effect of the mesg n command. This is useful for users who want to redirect all their messages to one particular xterm: it is more pleasant to do this with xterm resources than with explicit calls to the mesg program (patch, description by David Madore <david.madore@ens.fr>).

Patch #119 - 1999/10/16 - XFree86 3.9.16c

  • add responses (DA and DSR) for DEC locator mode
  • add coding for ANSI color to DA response
  • implement UTF-8 translation for Media Copy (print) operations.
  • implement vt320 control sequences for Print Composed Main Display and for Print All Pages. The latter directs xterm to print the current screen as well as the scrollback buffer.
  • correct error in _GNU_SOURCE configure test, which left it always defined.
  • add more information, i.e., with strerror for some system calls in the main program which may fail due to insufficient permissions (prompted by a problem report for -C by Jeremie Petit <Jeremie.Petit@digital.com>).
  • add workaround for conflict between <X11/Xpoll.h> and <sys/select.h> on AIX 4.3 (Richard Griswold <griswold@acm.org>).
  • add configure script test to resolve conflict between between <X11/Xpoll.h> and <sys/select.h>
  • modify translation of UTF-8 sequences to reject "overly long" variations (patch by Markus Kuhn).
  • remove utf8controls resource, since Markus' change removes the corresponding logic.
  • correct a case where colors were not rendered properly. This happened when an application inserted several lines, then changed colors. If this was done all in one write, then there would be no intervening refresh, and the new color was applied to the pending scrolling operation which was awaiting the next refresh (reported by Stephane Chazelas <Stephane_Chazelas@Raytheon.com>).

Patch #118 - 1999/10/5 - XFree86 3.9.16b

  • refine configure test for utmp versus utmpx, to build on HP-UX 10.x (reported by David Ellement).
  • move the configure check for const after the check for ANSI C compiler options, since those may be required to make it work properly on HP-UX.
  • add configure test for defining _GNU_SOURCE
  • correction to -hold option, ensure that if data is already in the output buffer that it will be displayed before closing the PTY.
  • move the configure checks for setuid install of xterm into a script to avoid installing it setuid'd to a non-root user (reported by Adam Sulmicki <adam@cfar.umd.edu>).
  • correct configure script's check for termcap.h to avoid using ncurses' version of it on systems that have a working tgetent() function. This is needed to make resize work properly.
  • fix some typography in ctlseqs.ms description of DEC locator events (reported by Stephen P Wall).

Patch #117 - 1999/9/29 - XFree86 3.9.16b

  • change order of tests in configure script for utmp and utmpx to test utmpx first, to compile on Solaris (reported by Leena Heino <liinu@uta.fi> and Patrik Hagglund <patha@ida.liu.se>).
  • add a configure test for utmp.ut_xtime, needed for SCO Openserver, and for lastlog, needed for Redhat 6.0, to refine the utmp/utmpx auto-configure.
  • remove a spurious comma in an #undef (reported by David Green <greendjf@cvhp152.marconicomms.com> and David Ellement <ellement@sdd.hp.com> both on HP-UX, whose compiler does care about syntax).
  • change ifdef's using __CYGWIN32__ to __CYGWIN__ (reported by Suhaib M. Siddiqi <Ssiddiqi@InspirePharm.Com>, who is told that the next Cygnus release will drop that symbol in their next release).
  • minor cleanup of ifdef's for makeColorPair (patch by Stephen P Wall).
  • work around problem observed in XFree86 3.3.5 (patch by Alexander V Lukyanov, Redhat #5419). From the problem report:

    xterm consumes cpu when selecting text with mouse (holding down left mouse button) and when a program working under the xterm outputs something to stdout.

    Easy way to reproduce:
    while :; do echo aaa; sleep 1; done
    (while this runs, select text and hold down left mouse button) watch cpu load.
    release left mouse button - spinning stops.

Patch #116 - 1999/9/25 - XFree86 3.9.16a

  • modify warning if change-ownership of PTY fails; some configurations may not happen to have old-style pty's (reported by Bob Maynard).
  • improve check in configure script for group ownership of installed xterm; some platforms use the -g option of ls to toggle group off rather than on (reported by Greg Smith).
  • minor improvement to toolbar geometry, to make it not resizable. This still is not satisfactory (but is usable) since the toolbar overlaps the xterm widget if the window is resized to make it smaller. It appears that some work is needed for the xterm widget's geometry management to make it function properly.
  • implement configure script tests for utmp, tty group.
  • implement -hold option, allowing users to retain the window after a shell has exited (this is recently an FAQ, but prompted by a comment by Joachim Plaettner-Hochwarth <plaettner@aem.umn.edu> in comp.unix.programmer, that the IRIX winterm provides this option).
  • add support for DEC Locator control sequences for xterm (integrated patch by Stephen P Wall):
                    DECEFR, "Enable Filter Rectangle"
                    DECELR, "Enable Locator Reports"
                    DECSLE, "Select Locator Events"
                    DECRQLP, "Request Locator Position"
    

    This allows the xterm mouse to be used with applications that use the DEC Locator sequences, such as VAX Tpu, or SMG$ based applications.

  • improve print action (patch by Matthias Baake). From his notes,
    • Bug 1
      Underlined text is preceded by ESC [0;2m . This should be ESC [0;4m , ESC [2m doesn't seem to have any effect. (print.c/send_SGR)
    • Bug 2
      The check for the last non-empty column (while (last > 0) ... in print.c/printLine) omits the rightmost column of the screen, the loop must start with last = screen->max_col+1 instead of last = screen->max_col.
    • Bug 3
      Any attributes of the first character (and of all immediately following characters with the same attributes) are ignored. The variable attr (print.c/printLine) should be initialized with 0, not with *a & SGR_MASK.

Patch #115 - 1999/9/18 - XFree86 3.9.16a

  • integrated changes by Stephen P Wall to implement an 88-color model for systems where 256-colors cannot be allocated.
  • when 256-color configuration is compiled, colored bold and underlining is not available; ifdef'd to avoid possible odd effects in this case (reported by Stephen P Wall).
  • add resource cacheDoublesize, to limit the caching of font information for double-sized characters. This addresses a problem reported by Aryeh Koenigsberg for X terminals with limited font memory.
  • modify treatment of line-drawing characters in UTF-8 mode so that the Unicode values are used rather than the C0 codes for storing the translated characters (request by Markus Kuhn).

Patch #114 - 1999/9/15 - XFree86 3.9.16

  • add configure script checks for Athena headers and libraries under /usr/contrib to work on HPUX (reported by several people: David Nixon <djn@csc.liv.ac.uk> Aryeh Koenigsberg <aryeh.koenigsberg@telrad.co.il> Johannes Mähner <johanm@camline.com> Andrew Gaylard <andrew.gaylard@bsw.co.za>).
  • add check to configure script if xterm is installed setgid rather than setuid, since wtmp and utmp may be installed with group-writable permissions other than root (based on Debian bug report #7112 by Bo Branten <bosse@ing.umu.se>).
  • rewrote logic that removes data from termcap entry, e.g., for titeInhibit, to make it less likely to remove the wrong data.
  • correct logic which checks for missing characters used for line drawing. The 0 character was tested unnecessarily, leading to some inefficiency when rendering.
  • change termcap capability which is used as input or output of ptyInitialErase logic from kD to kb. Christian Weisgerber <naddy@mips.rhein-neckar.de> pointed out in effect that kD (in terminfo kdch1) should correspond to the control sequence for dch1, which deletes from the current position toward the right.
  • check for failure to change ownership of the PTY device and warn when xterm is running setuid'd to root. This was reported to happen on the FreeBSD/NetBSD/OpenBSD systems as a result of the chflags() call.
  • add xterm-noapp terminfo entry to illustate a nominally bash-compatible terminal description.

Patch #113 - 1999/8/15 - XFree86 3.9.15b

Several fixes. The main one is a first draft of pulldown menus. It's not complete (I have some minor/annoying geometry problems to correct), but is usable. Once it's complete I plan to add a menu to support additional selections that won't fit on the current popup menus. Also, this fits into my longterm plan to allow configuring with Motif libraries.

  • correct error in input conversion for NRC mode (reported by Stefan Traby <stefan@sime.com>).
  • fix initialization of num_lock data in Misc struct (since those fields of the reference widget aren't initialized), and add logic to deal with XVision whose NumLock key does not transmit but does alter keypad state.
  • correct a missing return-value in get_pty(), for SCO
  • add E2A fix for backspace (patch by Greg Smith), i.e.,
    #define VAL_INITIAL_ERASE A2E(127)
  • correct foreground color within cursor outline when the window is unfocused (reported by Stephane Chazelas).
  • corrected position of scrollbar set in ResizeScrollBar(), which left it positioned incorrectly if the right scrollbar were enabled from the popup menu but was not initially enabled.

    I have noticed some additional problems with right-scrollbar on X11R5 which I will correct later.

  • integrate changes by Jean-Claude Michot for QNX from XFree86 3.3.4c
  • add resources menuBar/MenuBar, menuHeight/MenuHeight for later use in toolbar geometry.
  • add configure option --enable-toolbar
  • add missing definition to make ziconbeep logic not compile-in when configure script disables it.
  • add configure-check for input-method support in X libraries

Patch #112 - 1999/7/17 - XFree86 3.9Pw

  • add null-pointer check to FlushLog(), fixes a core dump when both -l and -lf options are used when xterm is configured with wide-character support.
  • remove "ISO" case for SD, which was due to a typographical error in ECMA-48 (reported by Paul Williams <paul@celigne.co.uk> for vttest).
  • add "FILES" section to manpage.
  • generate header file to initialize default resources for colors 16-255.
  • fixes for os390 (Greg Smith):
    • add README.os390
    • use the pty_search() function to find an available pty/tty pair.
    • move E2A() call out of getXtermCell() to SaveText() function so it will be available in all configurations.
  • patches by Todd Larason:
    • enable SGR 48 5 in ISO color mode, not just 256 color mode
    • change configure's --disable-256-color option to --enable-256-color, to match its effect
    • fix OSC 4 xx ? (report ansi color) to report a string which can actually be used to set the color back
    • fix OSC 4 xx yy (change ansi color) to not allow setting colors > 15 in 16 color mode
    • simplify the COLOR_ settings a bit in ptyx.h, along with setting NUM_ANSI_COLORS needed for #1 and #4 above
    • correct string-terminator code passed for reference to OSC responses; when in 7-bit mode, only the final byte of ST was seen.
    • Allow multiple color #;name pairs in OSC 4, and document changes to match.

Patch #111 - 1999/7/10 - XFree86 3.9Pw

  • add control sequences for specifying the RGB value of the ANSI colors, and for configuring with 256 colors (patch by Todd Larason <jtl@molehill.org>). I made the default configuration to 16-colors, because xterm uses the default color map (which has only 256 colors).
  • correct an error in DCS $ q m reporting for colors 8-15 (Todd Larason).
  • add test/demo script for double size characters. Used this to test/correct display of double size characters that should wrap, underlined double size characters.
  • increased cache size for double size fonts to 8, to allow for both normal and bold fonts (discussion with Aryeh Koenigsberg <aryeh.koenigsberg@telrad.co.il>).
  • add fixes for port to OS390 aka MVS (integrated patch from Greg Smith <rys@epaibm.rtpnc.epa.gov>). OS390 uses EBCDIC rather than ASCII.
  • correct an off-by-one in binary search limits in keysym2ucs.c (Markus Kuhn).
  • implement logging for UTF-8 mode. The output is written in UTF-8 form.

Patch #110 - 1999/6/29 - XFree86 3.9Pu

  • If colorMode is enabled by default, compile-in default resources to match the colors listed in XTerm-col.ad (this should fix a longstanding FAQ).
  • added new OSC 3 ; PROPNAME=VALUE ST escape sequence to set an arbitrary X property on the top level xterm X11 window. Omit "=VALUE" to delete the X property (patch by Greg Badros <gjb@cs.washington.edu>).
  • change internal flag used for utf8controls resource so we allow 31-bit range of characters (suggested by Thomas Wolff).
  • add check for 16-bit characters in OSC strings, change them to '?' (reported by Thomas Wolff).
  • modify logic of same_font_name() to avoid trying to interpret both parameters as wildcard patterns. That does not (cannot) work, and in some instances the font server will return unresolved wildcards for the normal or bold fontnames, making them match inadvertently, triggering the fallback overstrike logic (reported by Tim Adye).

Patch #109 - 1999/6/23 - XFree86 3.9Pt

  • correct range-check from patch #108, which resulted in not being able to select from the scrollback buffer (reported by Tim Adye <T.J.Adye@rl.ac.uk>)
  • correct "no available ptys" problem with Cygwin B20.1 (patch by Tim Adye).
  • modified install-ti rule in Makefile.in to allow override of the terminfo directory when doing a "make install", i.e., by assigning to TERMINFO_DIR (request by Zdenek Sekera <zs@sgi.com>).
  • added install-full rule to Makefile.in
  • resync mkdirs.sh and install.sh scripts against current autoconf
  • implement $(DESTDIR) in Makefile.in, making it simple to install xterm and associated files into a directory just for packaging a binary release (suggested by CaT <cat@zip.com.au>).
  • change IChar type to unsigned, rather than unsigned short, making room for a flag to keep with 16-bit characters to prevent them from being interpreted as C0 or C1 controls (reported by Thomas Wolff).
  • correct a typo from patch #107, incorrect array name, in the filterUTF8 function (patch by Bruno Haible <haible@ilog.fr>)
  • add utf8controls resource to specify whether xterm should interpret 16-bit characters unpacked from UTF-8 form as control characters if they happen to fall into that range. This behavior is left unspecified by the Unicode standard (request by Thomas Wolff).
  • modify handling of OSC to recover if application sends 16-bit characters with codes above 255. We cannot display them as is, but translate out-of-range characters to a '?' (reported by Thomas Wolff).

Patch #108 - 1999/6/19 - XFree86 3.9Ps

  • add a range-check to LastTextCol(), to guard against indexing before the beginning of the scrollback buffer. This appears to happen with certain fonts under X11R5 (reported by Stephane Chazelas <Stephane_Chazelas@Raytheon.com>).
  • implement resource boldMode, to allow disabling the simulation of bold fonts when the bold and normal fonts are not different (requested by Will Day <willday@rom.oit.gatech.edu>).
  • change the atom "UTF-8" to "UTF8_STRING", and fixes a few bugs in the UTF-8 selection (patch by Juliusz Chroboczek).
  • correct logic of binary-search in keysym2ucs.c (patch by Markus Kuhn).
  • add special interpretation of keysym codes above 0x1000000 as the corresponding UCS value plus 0x1000000 (patch by Markus Kuhn).

Patch #107 - 1999/6/12 - XFree86 3.9Pq

  • Two changes from Stephen P Wall. From his description:

    The first change is simple - I added ESC[3J to erase the stored lines above the screen. That's what the changes to util.c and ctlseqs.ms are.

    The second change is to get the blinking cursor working. I took out the cursorBlinkTime resource, and put in cursorBlink (Boolean), cursorOnTime (time cursor is on in msecs) and cursorOffTime, and added a cursorblink item to the vtMenu to enable/disable it.

  • improve selection (integrated patch by Juliusz Chroboczek). From his description:

    With this patch, selection conversion works properly:

            ISO 8859-1 xterm -> ISO 8859-1 xterm (transferred as STRING);
            ISO 8859-1 xterm -> UTF-8 xterm (transferred as STRING);
            UTF-8 xterm -> ISO 8859-1 xterm (transferred as STRING);
            UTF-8 xterm -> UTF-8 xterm (transferred as UTF-8).
    

    It will not work properly if one xterm is in, say, ISO 8859-2. Actually, for this case xterm breaks the ICCCM routinely (sending ISO 8859-2 data as STRING), so I wouldn't worry too much about it. I have not changed the behaviour in eight-bit mode in any way.

Patch #106 - 1999/6/9 - XFree86 3.9Pq

  • remove duplicate fix for OpenBSD in resize.c
  • correct logic in ScreenWrite, which did not reset the high bytes of 16-bit characters when overwriting them with a 8-bit character string (reported by Thomas Wolff).
  • provide limited support for input of UTF-8 16-bit data by a lookup table (integrated patch by Markus Kuhn).
  • correct check in non_blank_line to ensure we're in wide-character mode before looking at the high bytes, for InsertChar.

Patch #105 - 1999/6/5 - XFree86 3.9Pp

  • implement new resource trimSelection, which allows xterm to trim trailing blanks from selected lines. This does not affect the highlighting. (reported by several people using mutt, including Hans Morten Kind <edphk@uib.no>, Jeremy <jeremy@exit109.com> and (Michael Fuller <msf@mds.rmit.edu.au>).
  • include term.h in resize for OpenBSD (patch by Matthieu Herrb).
  • correct logic for UTF-8 in functions that hide and show the cursor; it was displaying a space whenever the low byte of the character at the cursor position was zero (reported by Thomas Wolff <Thomas.Wolff@icn.siemens.de>).

Patch #104 - 1999/5/30 - XFree86 3.9Pn

This is a resync patch against XFree86 3.9Pn, reflecting changes which were submitted by Branden Robinson, who worked with Wichert Akkerman <wichert@cs.leidenuniv.nl> to set up ifdef's to handle GNU libc 2.1, and use getpt() which lets xterm avoid having to know the actual PTY name.

I have also added a few fixes for signed/unsigned mismatches, and corrected a problem in the configure script (the UTF-8 code was always configured since the Imakefile defines this).

Patch #103 - 1999/5/14 - XFree86 3.9Pm

  • correct selection logic: I omitted an offset that accounts for the distance into the scrollback buffer when rewriting this for patch #101. Also fixed a similar problem for selecting double size characters from the scrollback buffer (first was reported by D Roland Walker <walker@pobox.com>).
  • improved support for Unix98 PTY's, using patch in Debian bug report #35650, by J.H.M. Dassen <jdassen@wi.leidenuniv.nl>. From the patch description:
    • No longer links xterm against libutil on a glibc2.1 system. libutil is a compatibility library and should only be used when necessary. Rather than having get_pty() use openpty() from this compatibility library, use the real UNIX98 pty support in get_pty() (open()ing the master pty, through getpt() if available (glibc extension)). Use openpty() only under glibc2.0.
    • GNU libc2 is not Linux-specific; already it runs on the Hurd. It provides the UNIX98 pty functions (plus the getpt() extension), regardless of the underlying OS. Changed two constructs to look for GNU libc2 only, not GNU libc2 on Linux.
  • improve font configuration, by checking if the user's resource settings for normal and bold fonts give the same font sizes (fixes problem reported by Peter Waltenberg <peterw@dascom.com>).

Patch #102 - 1999/5/12 - XFree86 3.9Pm

  • revert change to openpty call in patch #101; this causes xterm to fail on DEC-Alpha OSF/1 4.0B (reported by H Merijn Brand).
  • modify print.c to move include of stdio.h after the autoconf'd xtermcfg.h since HP's ANSI C compiler otherwise sees inconsistent prototype for getopt, probably due to problem with const (reported by H Merijn Brand).

Patch #101 - 1999/5/10 - XFree86 3.9Pm

  • moved includes and definitions for 'select' from data.h to xterm.h to fix problem introduced by prototype for getPtyData, part of UTF-8 changes (reported by Jens Schleusener <Jens.Schleusener@dlr.de>)
  • added "Meta <Btn2Down>:clear-saved-lines()" default translation (patch by H Merijn Brand)
  • fixes to configure script and ifdef's in main.c to build on a HP9000/D390 (hppa-2.0w) running HP-UX 11.00 (64 bit) with egcs 1.1.2 and HP's ANSI C compiler (patch by H Merijn Brand <PROCURA_BV@CompuServe.com>)
  • add more parentheses in ifdef's (patch by Bob Maynard).
  • eliminate conflicting definitions for USE_TERMINFO in resize.c (reported by Jeremy Buhler).
  • change openpty call to pass NULL rather than ttydev parameter, since that was used only to estimate the length of the corresponding data, and may not really be long enough (reported by Andreas Jaeger)
  • update description in xterm manpage for character class table, which said it handles only 7-bit codes.
  • correct a typo in ScrnDeleteChar() which made it not clear the high byte of wide-character data.
  • add logic to convert selection to UTF-8 form when appropriate. This makes select/paste "work", but further work is needed to make UTF-8 recognized as a locale in Xlib.
  • correct right-limit check when selecting double-width characters.
  • change default answerback response to an empty string.

Patch #100 - 1999/5/3 - XFree86 3.9Pl

  • Correct a typo in the default resource value for backarrowKeyIsErase: it was always true (reported by Bram Moolenaar).
  • improve configure script's test if the installed xterm is setuid, in case that is a symbolic link.
  • correct "install-ti" rule in Makefile.in, by not setting a blank $TERMINFO value. That is interpreted as "." by ncurses' tic.

Patch #99 - 1999/5/2 - XFree86 3.9Pk

  • correct logic that computes num_ptrs count of the number of indices into the screen buffer. This is the maximum of the colors and character-set indices; was incorrect in patch #97.
  • correct argument type for sigsetjmp, incidental change in patch #96's Unix88 PTY patch (reported by Bram Moolenaar).
  • correct description of secondary DA in ctlseqs.ms (reported by Bram Moolenaar).
  • decouple the backarrowKey and ptyInitialErase resources by adding a new resource backarrowKeyIsErase, to accommodate people using applications which have hardcoded tests for characters 8 and 127 rather than relying on the stty settings.
  • modify the UTF-8 decoder so that all possible illegal UTF-8 sequences are properly represented by U+FFFD. This should be very helpful for developers of code that output UTF-8 strings for debugging. See the file utf-8-test.txt in http://www.cl.cam.ac.uk/~mgk25/download/ucs-fonts.tar.gz for a demonstration text that contains numerous illegal UTF-8 values. (patch by Markus Kuhn).
  • correct a place in ScrnRefresh where I was filling the high byte of a wide character with a space rather than a null (reported by Markus Kuhn).

Patch #98 - 1999/4/26 - XFree86 3.9Pk

  • correct data manipulation in unparseputc(), broken for little-endian machines by patch #97's UTF-8 changes. This meant that keyboard input on SunOS did not work, though Linux i386 was fine.
  • modify initialization for backarrowKey and logic for initial-erase to prevent the initial-erase from overriding an explicitly set backarrowKey resource (reported by Vikas Agnihotri).
  • add a missing null-pointer check in ScrnRefresh, for the wide-characters configuration.

Patch #97 - 1999/4/25 - XFree86 3.9Pk

  • add configure script test for -lutil, needed for openpty call when configuring xterm for Glibc-2.1 and Unix98 PTY's (first reported by Martin Lorentz" <m.lorentz@w12.link-goe.de>).
  • completely parenthesize ifdef expressions for Glibc (suggested by Bob Maynard).
  • add initial-erase options (-ie, +ie) to help message (reported by Vikas Agnihotri).
  • remove duplicate definition of USE_USG_PTYS (reported by Jeremy Buhler).
  • change termcap kD and terminfo kdch1 to a DEL (\177). I overlooked this when separating the styles of keyboard with the sunKeyboard resources in patch #94, so that it normally matches the value of the stty erase character:
    • Reported by Jae Gangemi <jgangemi@ccf.rutgers.edu>, this caused emacs to not process the DEL properly, combining it with succeeding characters.
    • This does not appear to be related to a problem which I have found with screen, which translates the stty erase into the termcap kD or terminfo kdch1 value (depending on how it is linked) if the $TERMCAP variable is set when screen is invoked.
  • add command-line options for enabling UTF-8 mode: -u8 and +u8. The more obvious -utf8 and +utf8 would conflict with xterm's -ut and +ut (utmp) options. The UTF-8 changes were requested by Markus Kuhn <Markus.Kuhn@cl.cam.ac.uk>. This patch does not complete UTF-8 implementation, but makes it usable, i.e., display and refresh work, and I am able to display the test cases which Markus provides. More work is needed to complete this feature:
    • the control sequences for switching in/out of UTF-8 mode are partly implemented (don't use them). Similarly, the switching between vt100 and tek4014 emulations when UTF-8 mode is enabled will not work properly.

      You must use the -u8 command line option to use this feature, as well as compile with the OPT_WIDE_CHARS definition.

    • cut/paste only copies 8-bit characters.
    • logging is disabled in the wide-character configuration
    • printing only writes 8-bit characters.
    • input only does 8-bit characters. This is the area that I know least about.

Patch #96 - 1999/4/19 - XFree86 3.9Pj

  • modify Makefile.in to work with configure script's --srcdir option. (patch by Jeremy Buhler <jbuhler@cs.washington.edu>)
  • add checks for 'echo -n' equivalent for 8colors.sh and 16colors.sh scripts (reported by Vikas Agnihotri).
  • improve logic that looks for bold fonts to allow for wildcards in the specification for normal fonts, and to ensure that if a bold font is specified as normal, that xterm will simulate a bold version of that using a one-pixel offset overstrike (reported by Henrik Harmsen <harmsen@erv.ericsson.se>).
  • correct horizontal spacing of double width line-drawing characters that xterm simulates.
  • improve support for Unix98 PTY's, using patch in Debian bug report #35650, by Topi Miettinen <Topi.Miettinen@medialab.sonera.fi>. Andreas Jaeger says this also corrects a permissions problem reported by cat@zip.net.au
  • modify initial-erase logic to ensure that ttyModes resource overrides it.

Patch #95 - 1999/4/5 - XFree86 3.9Ph

  • modify primary DA response to allow a '1' parameter.
  • add printer and national replacement character sets to VT220 primary DA response.
  • document primary and secondary DA responses in ctlseqs.ms
  • use the patch number (e.g., 95) in the secondary DA response, providing user applications a means of determining the version of xterm for feature comparison (request by Bram Moolenaar).
  • make xterm respond to secondary DA when the decTerminalID is set for VT100.
  • limit user-defined keys (DECUDK) to VT220-style keyboard when sunKeyBoard resource is true.
  • modify ifdef's for Linux-2.2.x with Glibc-2.1 to work with Glibc-2.1 and no Unix98 PTY support (patch from Andreas Jaeger <aj@arthur.rhein-neckar.de>)
  • add optional feature (resource and command-line options) to make xterm use the PTY's sense of erase character on startup, rather than requiring it to be \177, or set the PTY's erase character to match xterm's configuration. Note that while $TERMCAP is modified to reflect the actual configuration, the terminfo kdch1 string is not (request by Dirk H Hohndel <hohndel@suse.de>)
  • improve scripts in vttests to work with newer shells that do not use 'echo -n'.
  • add fonts.sh example script
  • correct inequality in handling of "#1" font specification.
  • correct call to XGetWMNormalHints() used for computing maximum screen size; the size hints may not have been set.
  • begin implementation of support for wide-characters (configure option --enable-wide-chars defines OPT_WIDE_CHARS, invoke xterm with -wc option to activate this feature). This patch optionally widens internal data structures, invokes the 16-bit text output rather than the 8-bit version and adds some tables.

Patch #94 - 1999/3/27 - XFree86 3.9Pf

  • further fixes for terminfo: ka1, ka3, etc., differ between the default xterm-xfree86 and xterm-vt220 entries.
  • change default (with sunKeyboard resource false) behavior of the editing keypad "Delete" to send a 127, like xterm-r6. The VT220-style <ESC>[3~ is sent when sunKeyboard is true (reported by Tomas Vanhala).
  • add parameters to function keys to indicate if shift, control or alt are set. The codes are based on a description of a DEC VT510 with a PC keyboard, from Jeffrey Altman <jaltman@watsun.cc.columbia.edu>.
  • add control sequence 1035, set-num-lock action and num-lock menu entry to control the use of the NumLock and Alt keys for the Sun/PC and VT220 keyboard extensions.
  • implement DECSET/DECRST numeric keypad (DECNKM) mode.
  • modify terminfo and termcap to use recommended "X Window" or "X11" names rather than "X Windows" (reported by Tomas Vanhala).
  • suppress translation of shifted keypad "+" when sunKeyboard is true.
  • workaround unexpected behavior (perhaps bug) in XmbLookupString, which returns trash in the string buffer for numlock and control-key combined with keypad-keys.
  • modify ScrollBarReverseVideo() to keep scrollbar border visible when reverse video is toggled.
  • correct missing case for parameter 17 (set highlight color) in dynamic colors control sequences.
  • extend dynamic colors control sequences to allow users to determine the colors and font which are currently active.
  • minor tweak to OSC responses, to use BEL if the application used that to end the request, rather than ST. This works better with shell scripts, which may not handle an <ESC>backslash very well.
  • separate menu settings for reverse video from that done under program control.
  • corrected ifdef's for menus, which did not allow tek4014 to be suppressed properly (reported by Clint Olsen).
  • changes for Linux-2.2.x with GLibc-2.1 and /dev/ptmx support (integrated patch from Pavel Roskin):
    • main.c and resize.c were using different rules to determine whether ATT should be defined (actually USE_USG_PTYS is more apt).
    • copy definitions from main.c to resize.c to prevent sys/stream.h and sys/ptem.h from inclusion when SYSV is not defined
    • define CNUL if not already defined like other variables.
    • /dev/tty does exist in Linux, but it doesn't mean, it should be used. Therefore EACCES is now an acceptable result.
    • ifdef'd several calls such as ioctl (ptyfd, I_PUSH, "ptem") to build on Linux (I_PUSH is not defined when sys/stropts.h is not included).
  • initialize second "ltc" variable in main.c (reported by David Dawes).
  • provide definition for USE_USG_PTYS in screen.c
  • add resource-files to install rule in standalone Makefile.in
  • add sample scripts to illustrate titlebar controls, resizing and colors.

Patch #93 - 1999/3/14 - XFree86 3.9Pd

Here are several fixes and minor enhancements. The chief ones are the fixes for NumLock mode and reverse video, since we had become used to working around the problems.

  • remove kfnd/kll/kslt strings from terminfo, because curses applications do not necessarily return khome/kend pairs (reported by Vikas Agnihotri).
  • implement NumLock resource which overrides the keyboard tables for the special case of keypad keys. This is a problem introduced in xterm by X11R6 changes, i.e., an ambiguity which in effect discarded vt100 keypad support.
  • modify Sun/PC keyboard mode to extend this (emulation of DEC vt100 keypad) to the remainder of the numeric keypad. Now, the default operating mode of xterm uses the keyboard tables as-is (except if the NumLock mode overrides), but provides good vt100 keypad compatibility if the Sun/PC keyboard menu item is checked.
  • separate command-line settings for reverse video from that done under program control. This is a problem which was introduced by X11R6. Though correct, most users are confused by allowing the reset command to undo the effect of the command-line -rv option.
  • add description of function keys, keypad and cursor keys to ctlseqs.ms
  • add terminfo entries for xterm-vt52, xterm-sun and xterm-hp
  • correct typo (missing case value) for DECSET 35, enable/disable shifted keypad action and a few compiler warnings (reported by Zdenek Sekera <zs@sgi.com>).
  • correct reporting of color values 8-15 in DECRQSS (reported by Vikas Agnihotri).
  • modify parsing of ttyModes resource to recognize "^-" as "undef" (requested by Tomas Vanhala).
  • integrate/extend changes to add iconify/maximize actions (from Edward S. Arthur <eda@ultranet.com>).
  • add control sequences for maximizing/restoring window, and for reporting maximum screen size.
  • add 'interpret' action, to support local function-key interpretation. Used properly, this makes most of the specialized actions of xterm redundant.
  • add control sequence private modes 1051, 1052 and 1052, for setting the Sun and HP function key modes, and for setting the Sun/PC keyboard mode.
  • add configure option --disable-maximize
  • add configure option --disable-num-lcok
  • extend descriptions of configure script options in INSTALL.

Patch #92 - 1999/2/5 - XFree86 3.9Nz

  • increase buffer size for tgetent (i.e., termcap) to 1500. This fixes a problem where screen is built using ncurses or GNU termcap and xterm is built using the standard termcap interface. The former does not limit the termcap size, while the latter is assumed to be no longer than 1023 characters. The screen program's termcap entry is about 1200 characters long.
  • change update_menu_item() to a function, to simplify debugging. This also reduces the executable by 4Kb.
  • add control sequences for DECSET 30, 1010, 1011 like rxvt (enable or disable some features that were only settable via resources or command line arguments).
  • add control sequence for DECSET 35, which enables/disables the shifted keypad functions.
  • add support for switching font sizes, by stepping through the font menu using shifted keypad plus and minus.
  • correct missing initialization of tekInhibit and tekSmall resources.
  • correct ifdef's in charproc.c for XtNgeometry and XtCGeometry (reported by Bram Moolenaar).

Patch #91 - 1999/1/21 - XFree86 3.9Nw

  • Implement logic to translate input characters which are mapped when in vt220 National Replacement Character mode (requested by Tomas Vanhala).
  • Resync configure scripts with my patches to autoconf 2.13
  • Change order of -lXmu and -lXext to accommodate cygwin32 (reported by Vikas Agnihotri).
  • Add "-ti" option to set terminal emulation level from command line rather than via resource.
  • Simplify some of the preprocessor logic using #elif.

Patch #90 - 1998/12/13 - XFree86 3.9Nq

This implements several small fixes and enhancements. The chief one implements fallback support for line drawing characters with fonts that do not include those characters. But I implemented that last.

  • If any of the glyphs in positions 0-31 (used by xterm to implement the VT100 alternate character set) are zero-sized (i.e., missing), xterm will reserve a normal space for the glyph when drawing. I implemented a simple stroke-drawing function to draw the line-drawing characters and a couple of the other (simpler) characters such as diamond. (This was suggested by Vikas Agnihotri).
  • Modify the computation of doublesize characters to work around font servers which shift the scaled characters up/down or do not give the correct width.
  • Add popup menu item and corresponding resource settings to disable the font-scaling logic for doublesize characters to work around (older) font servers which simply do not draw the fonts scaled to the size that they said they would. I see this problem on a SunOS system running X11R5; the X11R6 servers seem well behaved.
  • Implement new escape sequence, private mode 1049, which combines the switch to/from alternate screen mode with screen clearing and cursor save/restore. Unlike the existing escape sequence, this clears the alternate screen when switching to it rather than when switching to the normal screen, thus retaining the alternate screen contents for select/paste operations.

    When I implemented the popup menu entry to toggle between the normal and alternate screens, I considered only pasting from the normal screen to the alternate; this improvement allows either direction.

  • Changed the termcap and terminfo for xterm-xfree86 and xterm-8bit to use the new 1049 private mode.
  • Modify the logic which switches between normal and alternate screens so that the save/restore cursor operations apply only to the current screen. That means that applications which use the terminfo smcur/rmcur or termcap ti/te capabilities will restore the cursor to the original position on the normal screen rather than to the most recent place where a save-cursor operation was performed.

    I note that a real VT100 terminal would not behave in this way, but it is a moot point since the VT100 does not implement alternate screen, and therefore the save/restore cursor sequence would not be used in this context. I reviewed the logic which switches between normal and alternate screens based on some recent newsgroup postings as well as a proposed patch in the Debian group which attempts to do this (the patch has a bug, however, so I did not use it).

  • Add popup menu entry for toggling the titeInhibit resource.
  • Add new resource answerbackString, which overrides the default "xterm" returned by xterm when responding to an ENQ (control/E) character (request by Rajesh Vaidheeswarran <rv@fore.com>).
  • Add new resource keyboardDialect for setting the NRC display character set (request by Tomas Vanhala, who notes that I should add logic to translate the keyboard as well).
  • Add new command-line option and corresponding resources for making xterm generate escape sequences compatible with HP terminals. Like the existing Sun escape sequences, this is available as a popup menu item. It is enabled by the configure script with the option --enable-hp-fkeys (requested by Toni Mueller <sales@oeko.net>).
  • Add configure script option --disable-boxchars to disable the fallback support for line drawing characters.
  • Fix ifdef's for configure script --disable-ansi-color, and reviewed all configure options to ensure that all can be enabled/disabled appropriately.
  • Update config.guess and config.sub, from Lynx.

Patch #89 - 1998/11/20 - XFree86 3.9Nm

This patch completes the implementation of double-sized character support for the VT100 emulation, and fixes a few minor bugs:

  • corrected the cursor position in HideCursor, which did not multiply the column by two when in doublesize mode. This bug, which did not appear in normal use, dates back to my original changes to partly implement double-sized characters. I noticed it when cat'ing a typescript from vttest's double-sized character test.
  • ensure that the current line is repainted when switching between single and double width characters.
  • reduce the number of bits used for double-sized character coding from 3 to 2, to make more room for soft-font codes.
  • copy newer ifdef's from the XFree86 3.3.3 release's main.c, which address details of glibc and powerpc.
  • moved definition of DECL_ERRNO in xterm.h to match XFree86 3.3.3
  • modify resize to remove the ifdef on SVr4 that suppressed printing the script for $LINES and $COLUMNS. Solaris' resize utility does this; suppressing the behavior is unnecessary.

I tested the double-sized characters using vttest and the xfsft patch. These fonts worked reasonably well:

        -bitstream-courier-medium-r-normal--0-0-0-0-m-0-iso8859-1
        9x15

The iso8859 font does not include box characters, of course, but looks good.

Patch #88 - 1998/10/31 - XFree86 3.9Nk and 3.3.2h

This refines my #85 patch by checking for a case where the font server returns a bold font that does not quite correspond to the normal font. When I asked for a bold version of the 6x12 font, the font server returned a near equivalent where the ascent and descent values did not match, causing xterm to leave lines across the display. This patch makes xterm reject that type of mismatch, falling back to the old font behavior.

Patch #87 - 1998/10/21 - XFree86 3.9Nj and 3.3.2f

This corrects a problem reported by Stefan Dalibor. My table entries for the printerExtent and printerFormFeed resources used the wrong types for sizeof, causing the printer to not work properly on some platforms because the printAttributes resource was overwritten (e.g., Digital Unix with DEC Alpha).

I reviewed all of the resource table entries and fixed a potential problem with resizeGravity, which was typed as int rather than XtGravity.

Patch #86 - 1998/10/14 - XFree86 3.9Nj and 3.3.2e

A small fix: when switching to/from the continuous mouse reporting mode, the event mask was incorrect if xterm was built under X11R5 because the original data was saved under an ifdef for active-icon.

Patch #85 - 1998/10/12 - XFree86 3.9Nj and 3.3.2e

Some cleanup (I noticed the pixel droppings a few months ago after getting a new 17" monitor):

  • split-out the functions that load/reload fonts for xterm as new file fontutils.c to extend them to support automatic loading of bold font corresponding to the normal font. Adapted logic from EMU 1.3 for this purpose. This fixes most occurrences of pixel droppings from bold characters.
  • modified by renaming variables and adding casts to permit compile with g++.
  • modify headers so they can all be compiled without order dependencies, and use bracketed rather than quoting includes to allow compile from separate directory.
  • renamed xtermm terminfo entry to xterm-mono, to avoid conflict with Solaris entry now in ncurses.

Patch #84 - 1998/10/9 - XFree86 3.9Ni and 3.3.2e

Several small fixes and enhancements, including a patch from Bjorn Helgaas:

  • correct initialization of TERMCAP environment variable, which was frequently set to garbage on non-Linux systems because "termcap" and "newtc" contained random data from the stack.
  • remove the LINEWRAPPED attribute from lines as they are cleared. Previously, the attribute was set but never cleared.
  • make word and line selections work even when lines are wrapped by xterm. Previously, selections were limited to one screen line.

as well as

  • modify logic for line-wrapping to reset the associated flag if the application deletes a character. This fixes a problem reported by Bjorn Helgaas where word/line selection would still wrap even after deleting characters from the first line.
  • add kll/kH capabilities to xterm-xfree86 entries in termcap and terminfo (request by Michael Schroeder).
  • shorten descriptions in termcap to make resolved entries all shorter than 1023 character limit.
  • use DECSTR control sequence to shorten initialization and reset strings in xterm-xfree86 termcap and terminfo.
  • use rmul/smul and rmir/smir in xterm-r5 terminfo to match termcap.
  • correct typos in initialization and reset strings in xterm-r5 termcap and terminfo.
  • disable special translations of key symbols (the backarrow key, the editing keypad and the keypad "+") when a modifier other than shift, control or numlock is used. This makes xterm handle the meta key as expected by people using emacs (reported by Pete Harlan <harlan@pointofchoice.com> in linux.debian.user newsgroup).

Resync #83 - 1998/10/7 - XFree86 3.3.2e

Merge changes through patch #83 with the 3.3.2e version.

This follows a change from XFree86 CVS which adds checks for non-null return from malloc (patch by Matthieu Herrb).

Patch #83 - 1998/8/25 - XFree86 3.9Nb

Several small fixes and enhancements:

  • add configure test to infer if xterm should be installed setuid based on previously installed xterm (reported by Stephen Marley and Stefan Dalibor).
  • implement quasi-continuous mouse reporting (integrated patch by Jason Bacon).
  • correct control sequences transmitted by function keys F1 to F4 when sunFunctionKeys resource is true (it was still using the VT100 control sequences).
  • modify handling of backarrow key so that the control modifier toggles the backspace/delete interpretation set by the backarrowKey resource.
  • limit the row and column values used to report mouse position.

From resync with XFree86 3.9Nb:

  • add support for the VSTATUS control character (patch by Robert Earl <rearl@teleport.com>).

Patch #82 - 1998/7/15 - XFree86 3.9Aj

Bug fix for patch #81:

  • remove an #undef for NBBY, which caused compile problem on FreeBSD (reported by David Dawes).

Patch #81 - 1998/7/14 - XFree86 3.9Aj

More bug fixes:

  • fix conflicting ifdef's for TIOCSLTC when building with Linux on AXP aka DEC Alpha (reported by Robin Cutshaw).
  • correction to patch #79, move assignment for *utptr->ut_user = 0; back into non-SVR4 ifdef in main.c, since this clobbers username on Solaris 2.5.1 (analysis by Will Day <willday@rom.oit.gatech.edu>).
  • corrected khome/kend in xterm-8bit terminfo description.
  • improve cursor color by making it always the reverse of fg/bg unless the cursorColor resource is set, i.e., to something other than the default foreground (reported by Vikas Agnihotri and Bram Moolenaar).
  • minor fixes for compiler warnings, including a syntax error in the AMOEBA ifdef's.

From resync with XFree86 3.9Aj:

  • correction to patch #73, supply missing #else for fallback definitions of size_t, time_t (Robin Cutshaw <robin@intercore.com>).

Patch #80 - 1998/6/29 - XFree86 3.9Ai

This fixes a couple of items leftover or introduced by patch 79:

  • take out the logic that suppresses editing-keypad in vt100 mode (those keys are too valuable to give up for a fine point of emulation).
  • corrected a couple of places in terminfo where I missed using the vt220-style editing-keypad codes for Find/Select (mapped to Home/End).
  • checked termcap file against terminfo, fix several places where it was inconsistent.

Patch #79 - 1998/6/28 - XFree86 3.9Ai

This patch fixes several small bugs:

  • use X_EXTRA_LIBS in standalone Makefile.in (patch by Tomas Vanhala).
  • add new resource 'oldXtermFKeys' which provides backward compatibility for F1-F4 control sequences with TOG's xterm.
  • determine the server's default foreground/background Pixel values, needed if the -flipPixels X server option is used (reported by David Dawes).
  • correct logic for F1-F4 function keys so that they generate VT100 compatible escape sequences in VT220 mode, since that is what the numeric keypad is supposed to do (reported by Ron Johnson, Jr. <ronjohn@communique.net>).
  • modify logic for editing keypad to work more like VT220: don't pass those codes in VT100-mode unless oldXtermFKeys mode is set.
  • correct an interaction with the editing-keypad logic that prevented backarrow key from sending a 127 for the delete key (the 'remove' escape sequence was being sent instead).
  • use return-value from getuid() rather than the parameter, to work on systems which do not update the latter (patch by Kevin Buhr <buhr@mozart.stat.wisc.edu>)
  • correct scrollbar border color when toggling to/from secure keyboard mode (patch by Jeff Uphoff <juphoff@tarsier.cv.nrao.edu>)
  • modifications to terminfo file:
    • rename description to xterm-xfree86, adding an entry 'xterm' which is derived from xterm-xfree86 to simplify customization.
    • change string for kdch1 from \177 to \E[3~, to address complaints from Debian developers. (This applies to the key labeled "Delete", and does not affect the backarrow key).
    • add user-strings u6, u7, u8, u9 to entries to make them work with Daniel Weaver's "tack" program.
    • modify xterm-24, xterm-bold, xterm-boldso entries to disentangle them from explicit dependency upon xterm-xfree86.
    • add generic 'xterm-color' entry.
    • minor corrections to xterm-xfree86, xterm-8bit, xterm-r5 and xterm-r6 entries.

Patch #78 - 1998/6/3 - XFree86 3.9Ah and 3.3.2

Again, most of the bulk of this patch is for ANSI conversion. I used the IRIX compiler's -wlint option to find the remaining functions that use K&R syntax (since gcc does not do this properly). Also, I changed the logic in the print code slightly to close unwanted files before opening a pipe to the printer. This may help in some configurations where the line printer hangs until xterm closes the pipe.

Patch #77 - 1998/5/26 - XFree86 3.9Ah and 3.3.2

Most of the bulk of this patch is to convert the extended C (K&R functions with prototypes) to ANSI. I verified that on Linux by comparing object files, to ensure that I did not, for example, interchange parameters in the function declarations.

The rest of the patch fixes several minor bugs, and adds a few features:

  • back-out my use of ncurses "captoinfo -f" option (if/then/else/endif) formatting, since ncurses did not correctly filter embedded newlines in terminfo capability strings until _after_ ncurses 4.1, thus corrupting setf/setb/sgr strings (reported by Darren Hiebert and others).
  • document SGR 8, 28 (invisible/visible), add corresponding capabilities to terminfo description.

    I would also add the 'prot protected capability, but the control sequences for that would not be recognized or properly ignored by the older xterm programs.

  • modify ChangeGroup to not suppress a null-resource, but treat it as an empty string (recommended by Stefan Dalibor).
  • add printerAutoClose resource to control whether printer is closed when going offline. More than one person reports problems (on Solaris 2.6 and Digital Unix 4.0) getting the printer to proceed unless xterm exits; I think that it is a problem flushing the pipe. Closing it ought to flush it.
  • adapt TOG fix-3 to in HandleKeymapChange and VTInitI18N (but adapt XtStackAlloc/XtStackFree for clarity, as well as fixing memory leak).
  • change calls on FillCurBackground to ClearCurBackground, in effect using XClearArea rather than XFillRectangle when clearing as a side-effect of scrolling and insertion (patch by Alexander V Lukyanov)
  • correct some places where insert/delete did not _move_ the color attributes, using memmove (patch by Alexander V Lukyanov <lav@long.yar.ru>)
  • add ifdef's for __CYGWIN32__, for port to cygnus version B19.1 (patch by Andrew Sumner <andrew_sumner@hotmail.com>).
  • remove #define for hpux that turned on USE_SYSV_ENVVARS, since this causes some applications (such as 'less') to get incorrect $LINES and $COLUMNS values (reported by Clint Olsen).
  • modify behavior for HP-UX, to set the "reserved" process group controls to _POSIX_VDISABLE so the TIOCSLTC ioctl does not produce an error (patch by Ben Yoshino <ben@wiliki.eng.hawaii.edu>).
  • correct length of underlining, reducing it by one pixel to avoid leaving a dot when the application does not clear the whole screen I noticed this only recently myself (and other people as well); it depends on the font chosen. A 6x10 font shows it, but the other fonts from XTerm.ad do not. I also see a similar problem with the emulation of bold fonts. (patch by Sergei Laskavy <Laskavy@cs.msu.su>).
  • add include for Xos.h to xterm.h, to ensure proper definitions (reported by Holger Veit).
  • update config.guess to recognize Unixware 2.1 and 7 (patch by Mike Hopkirk <hops@sco.com>).

Patch #76 - 1998/5/8 - XFree86 3.9Ah and 3.3.2

A fix for the print-window function, and some minor cleanup:

  • modify logic that closes pipe in the print-window function to not use pclose, which does not work on all systems, since I did not open the pipe with popen (reported by Stefan Dalibor).
  • correct name of $(EXTRA_LOAD_FLAGS) imake variable (reported by Stefan Dalibor).
  • guard logic in ChangeGroup() function against null pointer (reported by Stefan Dalibor).
  • ensure that menu entry for toggling sunKeyboard resource is initialized (reported by Branden Robinson <branden@purdue.edu>).
  • gcc unused-variable warnings (reported by Bernd Ernesti <bernd@arresum.inka.de>)
  • rename global variable 'buffer' to 'VTbuffer'

Patch #75 - 1998/5/7 - XFree86 3.9Ah and 3.3.2

This incorporates fixes from several people, as well as some improvements that I made based on feedback from users:

  • add option to standalone configure script, "--with-own-terminfo-dir", which causes xterm to pass a predefined value of $TERMINFO to the application. Also use this value in install rule "make install-ti", for the standalone configure script. (patch & feedback from Tor Lillqvist <tml@hemuli.tte.vtt.fi>)
  • change ifdef's for "hpux" to "__hpux" (patch by Tor Lillqvist). The imake configuration uses the former, but the latter is predefined by HP's compilers.
  • define USE_SYSV_ENVVARS for HP-UX, curses does not use $TERMCAP (patch by Tor Lillqvist).
  • on HP-UX, use the /dev/ptym/clone device to allocate PTY's. Works both on HP-UX 9 and 10. (patch by Tor Lillqvist).
  • modify configure script to obtain the $(EXTRA_LOADFLAGS) value from imake, needed for compiling under DEC OSF/1 (reported by Stefan Dalibor)
  • modify print-window action so that the printer is closed after printing a window, unless the printer was already opened (i.e., by an application running in the window). This makes the printing complete without having to exit xterm, since not all systems treat fflush through a pipe very well (reported by Stefan Dalibor)
  • modify printing code so that the ^M's are not printed if the printAttribute resource is set to zero (request by Stefan Dalibor).
  • correct typo in xterm.man, for the default value of printAttribute (reported by Stefan Dalibor).
  • correct printing code so that the alternate character set is printed, like other attributes, with escape sequences.
  • correct termcap description, removing spurious 'm' character from the 'op' capability (reported by Greg Woods <woods@weird.com>).
  • correct trace code so that the initial timestamp is set.
  • correct/modify utmp data for the Linux glibc 2 configuration, so that the ut_line member is set before using it to update wtmp (patch by Bill Nottingham <wen1@cec.wustl.edu>).

Patch #74 - 1998/4/27 - XFree86 3.9Ag and 3.3.2

This corrects a couple of recent bugs and adds a new resource:

  • modify definition of TRACE_CHILD so that it does not conflict with ifdef's for USE_USG_PTYS in main.c (reported by Vikas Agnihotri <VikasA@att.com> and Stefan Dalibor).
  • correct ownership of file (actually pipe) written by the print controls. When undoing the setuid changes in patch #69, I overlooked this. Now xterm forks a process which resets setuid and routes the printer data as the real user.
  • add a new resource, "printAttributes", which controls whether color attributes (or any attributes) are sent to the printer.

Patch #73 - 1998/4/25 - XFree86 3.9Ag and 3.3.2

This patch does the following:

  • implements a print-window facility for xterm. Though useful in itself, I added it as part of some debugging which I am doing. (Occasionally during an exposure event xterm fails to restore the proper colors for highlighted text, and printing the screen will show the internal states nicely).

    The print facility now also displays the color information. (I will probably make this a resource).

  • modified the xterm-16color terminfo description to use the setaf and setab strings, which is a little more efficient (requested by Stephen Marley).
  • reduced some clutter of the ifdef/includes (e.g., stdlib.h, unistd.h, errno) making the configure script test for these.

    I removed the symbols Size_t and Time_t, since they no longer serve a useful purpose.

  • added some debugging traces to show the initial screen size, and the success/failure of the ioctl calls pass handle window resizing events to the application (for Clint Olsen).

    I also modified the trace code to produce two files since some of the information is produced by the child process. So now they are Trace-parent.out and Trace-child.out

  • updated configure test for ANSI compiler options to handle a special case for HP-UX 10.x (reported by Clint Olsen).

Patch #72 - 1998/4/17 - XFree86 3.9Ag and 3.3.2

This is a patch from Chris Siebenmann <cks@hawkwind.utcs.toronto.edu>, which I have cleaned up a little, and integrated into the configure script.

From his description:

This set of patches is the latest incarnation of patches originally written by Ian! D Allen, then of the University of Waterloo and now of who knows where; I have been carrying them forward from xterm to xterm ever since about X11R4. What they do is add an option so that when an iconified xterm receives output it prepends '*** ' to its icon title and (optionally) beeps the bell; deiconifying the xterm removes the '*** '. Over the years I've found this to be incredibly convenient for monitoring all sorts of low-activity things.

Patch #71 - 1998/4/12 - XFree86 3.9Ag and 3.3.2

This patch is a slightly modified version of one by Richard Braakman, which prevents buffer overflow in the input-method and preedit-type parsing in xterm. I changed a couple of details to make the code more maintainable, and looked for similar things - copying into a fixed-size buffer (found none, though I did spot an unused variable).

Patch #70 - 1998/3/29 - XFree86 3.9Af and 3.3.2

This patch corrects some minor bugs in xterm, and fills in some more details in the VT220 emulation:

  • modify Imakefile to use SpecialCObjectRule for menu and data modules, making xterm build properly if logging is enabled (patch by Scott Sewall <scott@iprg.nokia.com>).
  • restore "ich" capability to terminfo entries, since Michael Schroeder points out that "ich1" is the one which is the problem in Solaris vi.
  • correct color of cursor, which would disappear on inverse-video since the initialization did not compare the cursor color against both foreground and background (reported by Olivier Calle).
  • correct abbreviation-test for -version and -help options, making command-line option -vb work (reported by Stefan Dalibor).
  • correct a dependency between ifdef's for OPT_I18N_SUPPORT and OPT_INPUT_METHOD (reported by Stefan Dalibor).
  • split-out character-set translations as new module charsets.c, to implement VT220 national replacement character sets (a mode where some of the characters are displayed as specific European glyphs). This relies on xterm using an ISO 8859-1 font (approach suggested by Kenneth R. Robinette <zkrr01@mailbox.neosoft.com>).
  • correct a missing increment, which made SS2 and SS3 controls repeat the shifted character.
  • add xterm-nrc to terminfo to illustrate the VT220 national replacement character sets.
  • reformat terminfo using new ncurses tic option "-f", which makes if/then/else/endif expressions easier to read.

Patch #69 - 1998/3/16 - XFree86 3.9Ad and 3.3.2

This corrects the problem in xterm with utmp, reported by Olivier Calle <olivier@tc.fluke.com> as well as some other people after the XFree86 3.3.2 release.

The error was introduced by my patch #53 in XFree86 3.9r (October 1997).

The correction removes the reset of setuid/setgid before the main event loop, and solves the problem which I had worked around in a different manner: for some reason, the particular waitpid() call in creat_as() hangs, does not return when the child process exits. I changed the ifdef's to force the Linux configuration to use wait() instead. This call appears to work properly on other platforms such as SunOS and Solaris.

I also added tests in the standalone configure script to check for the existence of waitpid().

Patch #68 - 1998/3/4 - XFree86 3.9Ad and 3.3.1z

This corrects another problem with the logic for highlightColor resource. As reported by David Dawes:

I've just noticed a problem with with the "inverse" control sequence (ESC[7m) with the 3.3.2 xterm. What it does is sets the background black, and the text the usual foreground colour rather than simply swapping the foreground/background.

This appears to be because when I added logic to check that the highlightColor was distinct from foreground and background colors, I did not add a further check to see that it was not black (I would make an explicit check for the resource not being set, but see nothing definite in the headers that would let me reference an explicitly-undefined Pixel value, though there are some implications in xpm.h). But this should work.

Patch #67 - 1998/2/23 - XFree86 3.9Ad and 3.3.1e

This patch does the following:

  • improve test for highlightColor so that xterm does not attempt to use that unless it is different from the foreground and background colors (reported by Stefan Dalibor <Stefan.Dalibor@informatik.uni-erlangen.de>.

    I could not reproduce this until I noticed that the -rev option exposed it nicely.

  • remove ich and ich1 from xterm and xterm-8bit terminfo descriptions. SVr4 terminfo documents that you must not combine these with smir/rmir, but ncurses allows it, opening a hole. Solaris 2.6 vi does not work properly if it is using a terminfo description when these are combined, since it was written to accommodate old terminals that required it (reported by Stephen Marley).
  • restore 1-pixel overlap of scrollbar border with left edge of window (reported by Jim Burmeister <jimb@metrolink.com>).
  • add a configure option, --enable-logfile-exec, which allows the user to specify a pipe for logfile. This defines ALLOWLOGFILEEXEC.
  • makes the ALLOWLOGFILEEXEC code compile & run, if configured.
  • minor documentation nits.

Patch #66 - 1998/2/16 - XFree86 3.9Ad and 3.3.1d

This fixes the problem reported with failure to build the resize program (BSDI, OSF/1) due to not having <termcap.h>, by changing the ifdef to one that would be set only if the file exists (not currently specified, except by the standalone configure script). We do not really need to include <termcap.h> to build, but only for a clean compile, since it may declare the tgetent() prototype. I also updated the man-page for resize, since I had recently noticed that it can be used to resize xterm using the "Sun" control sequences option.

Patch #65 - 1998/2/14 - XFree86 3.9Ad and 3.3.1c

This is a small patch to xterm's 8-bit terminal description. I noticed while testing ncurses that I had specified the wrong (VT100-style) codes for the F1-F4. Xterm only uses VT220-style function keys in 8-bit mode.

Patch #64 - 1998/2/8 - XFree86 3.9Ad

This fixes the following problems with xterm:

  • save/restore the ANSI foreground and background colors with the other visible attributes in the save-cursor and restore-cursor operations. This works around a problem with vim, which apparently assumed that switching between the normal and alternate screens resets the colors (reported by Jim Battle <jb@chromatic.com>).

    It would be nice to implement save/restore cursor as a stack (and solve this type of problem completely), but that would lead to incompatibility with applications which assume they are running with a VT100 or VT220.

  • corrects behavior of a restore-cursor operation which does not follow a save-cursor (it is supposed to set the character sets to a known initial state).
  • extends the sunKeyboard resource (and menu toggle) to modify the home, end and delete keys on a Sun or PC editing keypad, making them generate codes compatible with DEC VT220's Find, Select and Remove keys.
  • corrects a length in checking command-line options, which caused the "-help" message to not work when X was not running.
  • add some detail to the man-page (requested by Jason Bacon <acadix@execpc.com>)
  • modify the standalone configure script to ignore the broken nsl and socket libraries on IRIX 6.2 (the ones on 5.2 also are broken, so this change just widens the check for the system version number).

Patch #63 - 1998/2/5 - XFree86 3.9Ad

This is another patch from Bjorn Helgaas <helgaas@rsn.hp.com>, which I've reviewed (and learned some). Following are his notes:

I poked around some more and finally got xterm-62 to build and run cleanly on HP-UX 10.20. Here are the patches. They look sort of ugly, so here's a little explanation:

  • aclocal.m4: Removed side effects from the AC_CACHE_VAL commands in CF_FUNC_TGETENT. Previously, LIBS was set inside AC_CACHE_VAL, which worked fine the first time configure was run, but failed if there were cached values.
  • aclocal.m4: Added temporary setting of LIBS before AC_TRY_LINK in CF_FUNC_TGETENT. Previously, the last value set by the AC_TRY_RUN loop was used, so only -lcurses was checked.
  • configure.in: Added temporary setting of CPPFLAGS before AC_CHECK_HEADERS for X11 files. Previously <X11/DECkeysym.h> and <X11/Xpoll.h> were found only if they were in the compiler's default include directories, even if `--x-includes=DIR' had been used or AC_PATH_XTRA had found them elsewhere.

The problem on HP-UX was that we were linking with -lcurses rather than -ltermcap due to the second bullet above, and apparently something in HP-UX curses is broken. This seems very strange, because the only thing used is tgetent, which should affect any tty/pty configuration, but I lost interest in tracking down the exact problem.

Patch #62 - 1998/1/23 - XFree86 3.9Ac

This is a patch mostly by Bjorn Helgaas <helgaas@dhc.net> (I added the os2main.c change, and a little of the documentation). From Bjorn's description:

  • If you use the "-hc <color>" option or set the "highlightColor" resource, text is highlighted by changing only the background color, rather than using reverse video. I find this easier to read, especially when selecting multi-colored text, and it is similar to the way Netscape shows selections.
  • Most of the code changes are under "#if OPT_HIGHLIGHT_COLOR". The principal exception is in screen.c, where I added a couple calls to resetXtermGC(). This seems like it could be a bug even without the color highlighting changes (though I don't pretend to understand all the logic).

Patch #61 - 1998/1/17 - XFree86 3.9Ac

This patch modifies the reset behavior of xterm slightly:

  • change the terminfo entry so that rs1 (one of the strings used by the 'reset' program) does a hard reset rather than switching character sets. This is more in accord with other terminal descriptions.
  • modifies the treatment of hard reset by the xterm program to reset the saved lines.
  • corrects hard reset by also resetting user-defined keys, i.e., DECUDK.

Patch #60 - 1998/1/10 - XFree86 3.9Ab

This fixes some minor bugs and adds new functionality:

  • add support for blinking text.
    • This does not actually cause the text to flash, but text with the blink attribute can be displayed in color, using new resources colorBL and colorBLMode.
    • If colors are not used, the blinking text will be displayed as before (just like bold). The main purpose of this is to make applications work properly when they assume the emulator supports blinking text.
    • I did this by moving the per-cell LINEWRAPPED flag to a per-line flag, to make room for the new BLINK flag. There were no per-line flags, so this changes a lot of logic.
  • corrected missing save-cursor logic in the handling of SGR 1048 (the new control sequence I added in patch #54, 1997/10/17). Reported by Darren Hiebert.
  • flush the output of the transparent printing after each line Reported by Tomas Vanhala <vanhala@ling.helsinki.fi>.
  • correct the modes that are affected by save/restore cursor by adding WRAPAROUND and PROTECTED.
  • corrected placement of one of the XSync calls that I added in patch #51, 1997/9/15, which had the side-effect of writing on the window border when the xterm was resizing from 132 to 80 columns.
  • work around an incompatibility of the XKB definition used in xterm versus that symbol from IRIX 6.2's imake definitions (by adjusting the standalone configure script).

Patch #59 - 1998/1/5 - XFree86 3.9Ab

My last patch has an off-by-one error in the comparison for argc. Douglas Kosovic <douglask@dstc.edu.au> showed me where (he got a core dump). Also, I think this explains Clint Olsen's problem, but the symptoms were more subtle (EINVAL for a system call if the -display option is omitted).

Patch #58 - 1998/1/3 - XFree86 3.9Ab

This patch does the following:

  • implement logic to permit xterm to work with proportional fonts.
    • Thomas Wolff <Thomas.Wolff@sietec.de> requested this (but it isn't exactly what he's asking for - that's a more involved task).
    • I chose to do this by rendering the characters on a fixed pitch, because it would not be useful for existing applications to display varying numbers of characters on each line.
    • Except that this forces the display to be wider, it works reasonably well. A couple of special cases (reverse + colorBD, for example) do not display with proper colors, since the inter-character gaps are painted with the background.
  • added a version number to the program (several people have requested this).
  • make the -version and -help options interpreted before the program attempts to open the display.
  • minor reorganization of the man-page (ordered the options, resources and translations alphabetically - and eliminated some duplication).
  • corrected a misspelled filename in Makefile.in, and added a lint rule.
  • updated the configure script to correct behavior when it cannot find imake, as well as to fix the IRIX+gcc build (conflict with /usr/include).
  • regenerated the configure script with a newer patch to autoconf that fixes a problem with environment space vs the configure --help message.

Patch #57 - 1997/12/26 - XFree86 3.9Aa

This patch is mostly concerned with the standalone configure script; a few minor corrections are added:

  • add configure option --disable-tek4014, to allow xterm to be built without the tek4014 emulation.
  • add configure option --with-terminal-type, to allow xterm to be compiled with default $TERM value other than "xterm" (e.g., "xterm-16color") -- requested by Stephen Marley <stephen@memex.com>.
  • fix a typo in the configure --help message -- reported by Darren Hiebert <darren@hmi.com>.
  • review diffs between main.c and os2main.c, to make them more alike. (applies some minor bug-fixes to OS/2's version).
  • add missing quotes in memmove/bcopy configure test

Patch #56 - 1997/11/28 - XFree86 3.9x

This patch is based on analysis by Arfst Ludwig <arfst@luxor.IN-Berlin.DE>, who reported:

Setting the following resources xterm (all current versions) receives a segmentation fault on <Btn2Up> after scrolling:

          *XTerm*VT100*translations:    #override \
              ~Shift~Ctrl<Btn2Up>: insert-selection(PRIMARY, CUT_BUFFER0)\n\
              Shift~Ctrl<Btn2Up>:  insert-selection(CLIPBOARD, CUT_BUFFER1)\n\
              ~Shift<BtnUp>:       select-end(PRIMARY, CUT_BUFFER0)\n\
              Shift<BtnUp>:        select-end(CLIPBOARD, CUT_BUFFER1)

(The above resources intention is to be able to paste the latest selection even if the xterm was cleared.)

And here is how it works (and a fix!): The widget given to the action handler as first argument is not guaranteed to be a XtermWidget (it can be the ScrollbarWidget). Instead of accessing the widget's member directly XtDisplay gives the required pointer in a safe way.

I noticed that this was not the only instance (by reading the code, and testing with his example), and extended the solution to check the widget-class to ensure that it is indeed xterm's widget class before attempting to use it in the context of translations.

Patch #55 - 1997/11/25 - XFree86 3.9x

This fixes the segmentation violation noted by Rogier Wolff about a month ago. He'd set xterm to 400 (rows) by 150 columns, which broke because there were limited buffers (200 rows) used for juggling data when adding or deleting lines and for switching between alternate and normal screens. I replaced this by an allocated buffer.

The bug is simple to test if you set titeInhibit false.

Patch #54 - 1997/10/17 - XFree86 3.9s

This patch does the following:

  • correct a minor placement problem with the right scrollbar.
  • implement a new set of control sequences for switching between the normal and alternate VT100 screens. These work around the older sequences limitation that required modification of the runtime $TERMCAP to cooperate with the titeInhibit resource (that can't work with terminfo). I do this by moving all of the functionality of the rmcur terminfo capability into the control sequences.
  • implement the alternate-screen menu entry

Patch #53 - 1997/10/12 - XFree86 3.9r

This patch adds a fix and implements a new feature (as well as some minor typos):

  • JCHANDRA@Inf.COM (JCHANDRA) noted that there was still a problem with the wait call with the logging option. It hung when the logfile was opened as a command-line option. I fixed this by moving the StartLogging() call down past the place where I'd reset the setuid mode. So the logfile is opened as the real user, without having to fork.
  • improve Rohleder's changes by renaming the command-line options and reducing the number of ifdef's.
  • implement right-scrollbars for xterm (patch by Michael Rohleder <michael.rohleder@stadt-frankfurt.de>).

Patch #52 - 1997/9/29 - XFree86 3.9q

This patch addresses bugs and requests reported by

  • Bob Maynard <rmaynard@montana.com>,
  • Clint Olsen <olsenc@ichips.intel.com>,
  • JCHANDRA@Inf.COM (JCHANDRA),
  • Michael Schroeder <Michael.Schroeder@informatik.uni-erlangen.de>,
  • Pablo Ariel Kohan <pablo@memco.co.il>

Some of the changes are interrelated (it was an unusually busy week).

  • change the default resource value for colorMode to true, matching the Xterm.ad file.
  • correct behavior of 'ech' control, making the default and 0 parameters erase one character rather than to the end of line (reported by Michael Schroeder).
  • add resource boldColors, command-line options +pc and -pc and configure-script option to specify behavior of xterm's mapping bold colors 0 through 7 to colors 8 through 15. (request by Pablo Ariel Kohan).
  • add resource colorAttrMode to specify whether colorULMode and colorBDMode can override the ANSI colors (report by Clint Olsen).
  • correct a conflict between colorULMode/colorBDMode versus ANSI colors, where exposure events would occasionally pick up the former (e.g., colorBD) rather than ANSI colors. Testing the colorAttrMode made this apparent, though it has been in the code since 3.2A (patch #35 in Jan 1997).
  • correct two problems with the optional logging support. On Linux at least, the waitpid call in creat_as hangs when the logging is toggled from the popup menu. Also, the mktemp template has the wrong number of X's (since X11R5!). Fixed the waitpid problem by exploiting the fact that the setuid behavior is reset before the popup menus are available. (reported by Jayachandran C.).
  • add configure script options for building with the Xaw3d and neXtaw libraries.
  • correct CF_IMAKE_CFLAGS standalone configure script macro, so that it will pick up $(ALLDEFINES) rather than $(STD_DEFINES). This is needed to make scrollbars work on Linux, since that uses narrow prototypes. (reported by Bob Maynard).
  • various minor updates to configure-script macros.

Patch #51 - 1997/9/15 - XFree86 3.9p

Most of this patch is related to the standalone configure script, though there are fixes/enhancements as well:

  • add a new resource sunKeyboard, with associated command-line option and menu-toggle that allows using a normal Sun or PC keyboard to generated the complete DEC-style function keys and keypad.
  • correct a reversed foreground/background test in the control sequence that replies with the current SGR settings.
  • correct, by invoking XSync, a display problem that caused the program to not properly update newly exposed areas when a font change or 80/132 resize request was not completely accepted.
  • restructured autoconf macros (I made a library of all of the macros across the complicated configure scripts I'm working on).
  • use the autoconf config.guess and config.sub scripts to better identify the host-os.
  • improve the configure script that uses 'imake' as a fallback for definitions.
  • correct several instances of unsigned/signed mixed expressions.

I've tested the configure script on Linux, SunOS 4.1.3, Solaris 2.5.1, IRIX 5.2 and 6.2, AIX 3.2.5 and CLIX 3.1 (all but the last run properly as well).

Patch #50 - 1997/8/22 - XFree86 3.9m

This is a collection of small fixes, and a couple of minor enhancements:

  • plug a security hole in the implementation of Media Copy (print) by invoking setuid just before the main loop.
  • add an ifdef'd include for <sys/termio.h> for HP-UX, which allows the program to process SIGWINCH events (this is a bug in X11R6.3)
  • add state-table entries for VT52 emulation to enter/exit keypad application mode.
  • disable the popup-menu entry for 8-bit controls when the terminal-id is less than 200 (e.g., VT52 or VT100).
  • ensure that the popup-menu entry for 8-bit controls is updated when the application enables/disables this mode, including the response to a full-reset.
  • implement VT300 DECBKM feature: set interpretation of the backarrow key to either backspace or delete. The initial setting is via resource; it can also be modified in the main popup menu.
  • implement VTxxx KAM (ISO AM), which allows a keyboard to be locked (i.e., the terminal discards input).
  • implement VTxxx SRM, which is used to control local echoing of input on the terminal.
  • add terminfo and termcap entries for xterm-8bit, a variation of the xterm description that uses 8-bit control characters.
  • add fallback definitions for Imakefile to allow it to work on some X11R5 systems that have no SpecialCObjectRule or ProgramTargetName macros.
  • add .c.o and .c.i rules to standalone Makefile.in
  • correct order of -lXmu and -lXext in standalone configure script.
  • add configure script options to allow selective disabling of active-icon, input-method and i18n code (mainly for users with X11R5 or an incomplete X11R6 configuration).
  • change menu-indices from #define's to enum values, thereby making it work better with the ifdef's for logging and active-icon (the X11R6.3 active-icon code is incorrectly ifdef'd; this corrects an error introduced by incorporating that code).
  • correct minor compile errors in the configuration where active-icon is not used.
  • add configure option to suppress echoing of long compiler commands
  • correct spelling of decTerminalID in configure script help message
  • use gcc __attribute__((unused)) to quiet warnings about unused parameters when compiling with -W (to make it simpler to find the real problems).

Patch #49 - 1997/8/10 - XFree86 3.9k

This patch implements the VT100/VT220 Media Copy (i.e., print-screen) control sequences.

Patch #48 - 1997/7/26 - XFree86 3.9j

This patch does the following (all but the first affect only the standalone configure script):

  • minor correction to positioning of underlines for small (e.g., 5x8) font size.

    The existing behavior allowed underlines to be drawn outside the character-cell, so they weren't cleared properly under some circumstances.

  • adds more special-case tokens to the standalone configure script's imake-option filter (e.g., "&&", since a "make -n main.o" on my IRIX system uses that shell construct).
  • adds a '--enable-logging' option for the standalone configure script.
  • adds check and ifdef's for the standalone configure script to allow for building on platforms with X11R6, which lacks Xpoll.h (introduced in X11R6.1).

Patch #47 - 1997/7/13 - XFree86 3.9i

This patch does the following

  • corrects an indexing error in the doublesize character logic (button.c) that caused core dump (this was reported by J. Wunsch).
  • corrects the logic of ShowCursor when it is painting in a doublesize cell (charproc.c).
  • corrects, according to vttest, the behavior when switching to doublesize characters and back again (doublechr.c).
  • adds cbt (back_tab) to the terminfo description (this was something that I'd overlooked as applicable to curses optimization last summer).
  • corrects, for the standalone xmc test, the logic for disabling xmc.

Patch #46 - 1997/7/4 - XFree86 3.9h

This is a patch to provide test-support for some work I'm doing on ncurses. It does not modify the normal configuration of xterm; the code is compiled if the standalone configure option "--enable-xmc-glitch" is specified.

Patch #45 - 1997/7/2 - XFree86 3.9h

This fixes the problem reported with xterm's cursor color versus the background (the second chunk in this patch) and also removes some duplicate initialization of the cursor GC's. If the cursor color at startup is the same as the background, then xterm will use the reverse GC, ignoring the setting of the colorMode resource.

Patch #44 - 1997/6/22 - XFree86 3.9g

This implements the first part of the VT100 doublesize characters for xterm, as well as fixing a handful of bugs:

  • the doublesize character support uses the normal font (using scaled fonts will be another patch) with blanks to simulate doublesize characters. This patch does most of the global changes that'll be required. I've hidden most of the details in macros and ifdef's so it's easy to configure out (part of the patch is a configure option for that purpose).
  • corrected limits in DeleteChar() function -- it's always ignored the size of the left border and scrollbar. I noticed this when working on the doublesize characters since the glitch was doubled in size (i.e., it wrapped some garbage around the right margin).
  • corrected 'memmove()' logic, for standalone builds (it referenced a malloc wrapper from my development library).
  • add a check for HideCursor() to prevent repeated screen updates (which can cause a spurious cursor glitch to appear, e.g., during scrolling). I noticed this with the 3.2A version (but only a few weeks ago, when I started working on this patch).

Patch #43 - 1997/6/10 - XFree86 3.9d

Here's a fix for two problems:

  • modify handling of tgetent results in xterm and resize programs to make them tolerant of missing termcap file, or unknown terminal name. In this scheme, an explicit "-tn" option will succeed, overriding the fallback list.
  • a nit in the configure script (log extra information to help diagnose which case of the test-compile of tgetent was used).

Patch #42 - 1997/6/8 - XFree86 3.2Xl

Bram Moolenaar reported that the cursor color changed unexpectedly while scrolling. The cause was that it used the same GC's as the logic that draws the ANSI colors. The bug only appears if the cursorColor resource isn't set, and has been present since the initial implementation early last year. (The same bug also appears in rxvt ;-). Here's a fix.

Patch #41 - 1997/5/28 - XFree86 3.2Xl

Some nits found by Darren Hiebert (missing part of install-rule, incorrect assignment for --enable-color-mode option).

Patch #40 - 1997/5/26 - XFree86 3.2Xl

Patch for the configure script's logic for obtaining imake predefined symbols.

Patch #39 - 1997/5/24 - XFree86 3.2Xl

This patch does the following:

  • integrate the 16-color change for 'xterm'
  • minor fixes/clarification of tgetent in terminfo vs termcap to 'resize'

(both changes also modify the configure script)

Patch #38 - 1997/5/22 - XFree86 3.2Xh

This implements a simple configuration script with autoconf (to which I'll add more options later). It does the following:

  • configures xterm to build with X11R5 (at least on SunOS 4.1, Solaris 2.4, possibly IRIX - sorry network was down today, but I did test an earlier version yesterday).
  • enables/disables the configuration ifdef's for ANSI color and VT52 emulation.

It does not make tests for the things that imake does (that's another project), instead it uses a hybrid of the autoconf tests for libraries and adds imake's compiler options (which are necessary in some cases to get main.c to compile).

Patch #37 - 1997/5/7 - XFree86 3.9a

This corrects a minor, but annoying error in the vt220 emulation: the DECUDK is only supposed to be interpreted for _shifted_ function keys.

Patch #36 - 1997/1/16 - XFree86 3.2r

This corrects something that I overlooked in patch #27 (21-aug-1996), which is that when trimming the region to be repainted for the highlightSelection resource of xterm, I still have to paint the background past the highlighted region. This only happens when I first do a selection in a window that's partly off-screen, then move the window on-screen.

Patch #35 - 1997/1/7 - XFree86 3.2o

This patch does the following:

  • combines the coding for foreground and background colors into a single byte, reducing the memory required to store saved-lines in color. (I'll take back that byte in a following patch to use to ensure the character-set, so there's no long-term decrease in memory use).
  • modifies the PF1-PF4 coding in termcap/terminfo. Because xterm is still by default emulating vt100, the function key codes are vt100-compatible (I overlooked this in patch #31). I also reformatted the whole terminfo file into a single-column, for consistency.
  • adds an interim xterm-vt220 description to accommodate the old and new styles of function-keys (though probably it'd be better to drop the old-style altogether).

Patch #34 - 1997/1/5 - XFree86 3.2o

This patch does the following:

  • implement DECSTR (soft terminal reset). The biggest diff is due to adding another state table (note that there's only one useful state here, but it's only 256 bytes rather than 1k as it would have been before I reduced the size of state entries).
  • some minor tidying up (e.g., signed/unsigned use bitcpy, MODE_DECCKM, resetColor, resetCharsets). More is done in patch #35.

I got the description of DECSTR from a vt420 user's manual. I'll do some testing with vttest to ensure that there's nothing else to do than what was documented.

Patch #33 - 1996/11/24 - XFree86 3.2

This adds to the reset-fix by Matthieu Herrb <Mathieu.Herrb@mipnet.fr> a small change to make xterm able to output 8-bit characters in VT100 mode. Applications that run on real VT100's don't do that anyway, and this feature should be removed sometime after finishing off the VT220 emulation (VT220's can do 8-bit characters). That would be a good time to change the default terminal-id to 220.

Patch #32 - 1996/11/21 - XFree86 3.2

This implements the REP (repeat) control for xterm. That isn't part of the DEC VTxxx series, but is defined in ISO 6429. (Note that the base xterm terminal description is not changed -- I added a variant, "xterm-rep").

Patch #31 - 1996/11/16 - XFree86 3.2

This implements vt52 emulation in xterm (ifdef'd so it can be removed). I've been using it for testing for the past month or so.

Patch #30 - 1996/11/16 - XFree86 3.2

From bug-report by <auroux@clipper.ens.fr> (Denis Auroux), missing reset to ground state. I checked through the rest of that table and found another, in the unimplemented MC (screen print).

Patch #29 - 1996/9/15 - XFree86 3.1.2Gb

This patch does the following:

  • corrects the restoration of color for bold/underline color mode
  • adds a resource 'decTerminalID' to control the reporting level of xterm (e.g., VT100, VT220).
  • uses the new resource to implement/correct the DA1, DA2 and DECRPTUI reports.
  • change valid-response code in DECRQSS from 0 to 1 (the manual says 0, but the VT420 terminal I've been testing on says 1).

All of these changes are based on vttest 2.6

(Most of the volume in the patch is to add 2 more state tables for parsing the 2nd/3rd device-attribute controls).

Patch #28 - 1996/8/31 - XFree86 3.1.2F

This patch corrects the following reported by Roland Rosenfeld <roland@spinnaker.rhein.de>:

  • handle SGR 22, 24 and 25 in combination with colorUL and colorBD resources. Also noted & fixed reset of colored underline/bold with SGR 0.
  • a typo in the termcap (missing '['), from 3.1.2Dj (my error)

Roland also complained that he couldn't use box characters with

        -adobe-courier-bold-r-normal--12-120-75-75-m-70-iso8859-1

but that's a known xterm limitation (the box characters must be part of the font, in the first 32 locations).

Patch #27 - 1996/8/21 - XFree86 3.1.2Ek

This patch fixes one of my long-term gripes: xterm's selection doesn't clearly show what's being selected (as per David's request, it's controlled by a resource, which defaults to the older behavior).

Patch #26 - 1996/8/20 - XFree86 3.1.2Ei

Here's a patch to fix a problem with xterm's cut/paste and another to modify the appearance of the highlighting while selecting. (The changes are independent, so you can see if the change to screen.c is desirable).

Patch #25 - 1996/8/18 - XFree86 3.1.2Ei

Here's a correction for two minor bugs that I picked up in testing, plus some lint (from Solaris 2.5) where NULL was used incorrectly:

  • make the second alternate font the same as the first (that's what vt420 and dtterm do)
  • corrected DECSCL report when DECSCL hasn't been set (i.e., don't return a '60').

Patch #24 - 1996/8/11 - XFree86 3.1.2Ee

This patch does several things. In effect, xterm can (I think) do a reasonably good job of emulating vt220 and vt320 terminals (as well as it was doing vt100, at any rate ;-).

It does NOT do:

  • soft fonts
  • rigel or sixel graphics

Anyway, I:

  • added ECH, CPL, CNL, SU, SD, CBT, CHT controls
  • added popup-menu for switching between DEC and Sun function keys. (corrected alignment err wrt logging entry at that point).
  • make xterm recognize both 8-bit and 7-bit controls (including popup menu for switching modes).
  • add user-definable function keys (aka DECUDK)
  • support concealed text
  • support protected text (both ISO compatible and DEC compatible - that's not the same thing, btw), with SPA, EPA, DECSCA, DECSED, DECSEL controls.
  • implement DECSCL.

I'll be continuing to test this patch for a while, but don't expect to add any new functionality (it passes all of the current tests I've built in vttest, but I need to make more tests)..

Patch #23 - 1996/7/31 - XFree86 3.1.2Ec

This removes the blinking cursor I added last week (for performance reasons). Time-permitting, I'll revisit this after 3.2 is released (there will be more work after XFree86 3.2, I assume).

Patch #22 - 1996/7/26 - XFree86 3.1.2Ec

I looked more closely at my "double-negative" and realized that I had been confused by the default color scheme (black on white) in combination with reverse video. However, I did see that the original_fg and original_bg data weren't really used - so I removed that logic.

Also:

  • during initialization, check if ANSI colors are set with non fg/bg values, disable color mode if not. This makes xterm tolerant of applications that allocate the whole color map.
  • implemented blinking cursor (default is off)

Patch #21 - 1996/7/24 - XFree86 3.1.2Ec

This patch does the following:

  • fixes some minor typography in the control-sequences documentation (it didn't occur to me til I'd sent the last patch that I could use ghostview for previewing the troff output ;-)
  • adjusts the shell's background color in ReverseVideo so that flicker in resizing is reduced
  • adds an ifdef OPT_ISO_COLORS to allow configuring xterm without the ISO color support (saves a lot of memory)
  • used that ifdef to isolate/modify logic so that if the user doesn't have the colorMode enabled, then ISO color support is disabled (saving memory).

    (If anyone needs numbers, I had savedLines set to 2000, and found a reduction from ~700k to ~400k of allocated memory, according to Purify).

Patch #20 - 1996/7/24 - XFree86 3.1.2Ec

This documents the changes in control sequences for window operations that I added in my previous patch. I'm testing another patch that allows the user to use less memory if colors aren't needed.

Patch #19 - 1996/7/21 - XFree86 3.1.2Ec

This patch does the following:

  • fixes the core dump that I reported on IRIX 5.2 (in main.c)

    (it's worth noting that this bug exists in X11R6.1, so I'd like to assume that someone's already submitted a fix to X Consortium...)

  • change the interpretation of zero rows or columns in a resize-window request to use the root window's size (looking more carefully at dtterm, that seems to be what it does).
  • change some memmove calls to memcpy for slightly better performance. also, a couple of memset calls to bzero, since Quantify says bzero runs 20% faster, I assume because there's one less argument.
  • interpret character sets 1 and 2 (so that vttest gives a reasonable result) Both rxvt and dtterm do something equivalent.
  • fix a minor memory leak in the logic that retrieves the window or icon names (Purify found this for me while I ran vttest).

Patch #18 - 1996/7/18 - XFree86 3.1.2Ec

This implements the following:

  • escape sequences that act like the CDE dtterm's window operations (though I have implemented the default width and height -- I've seen a rather buggy dtterm running that seems to treat width=0 or height=0 literally -- maybe that's a feature, not a bug?)
  • minor tweak to the screen-repainting when resizing (I still cannot entirely get rid of flicker).
  • still more fixes to terminfo & termcap (I corrected my error for the hpa code and added some other stuff by comparing to ncurses' description and rxvt's).
  • a tweak to the changes by Michael Rohleder for the color translation
  • re-order attribute codes to allow later implementation of protected fields (dtterm supposedly does this; it's probably more useful than blinking or invisible text -- that uses up all of the available bits without changing the attribute scheme radically).

Patch #17 - 1996/7/2 - XFree86 3.1.2Eb

This patch implements for xterm several minor features from ISO 6429 which are useful for terminfo applications. The HPA and VPA control sequences allow cursor movement along a row or column, cutting down a little on the characters transmitted. The other codes allow resetting specific graphic rendition attributes without modifying the other attributes. (now if someone just had time to implement blinking cursors...)

Patch #16 - 1996/6/25 - XFree86 3.1.2Ea

Adam Tla/lka <atlka@pg.gda.pl> told me a couple of weeks ago that I'd missed some of the background coloring in xterm. I investigated, and found that while I'd picked up on the clear-to-bottom and clear-to-end-of-line operations, I'd overlooked the insert/delete lines. Just so I wouldn't overlook any more of these, I updated a copy of vttest to test ISO colors and bce (background color erase). This patch introduces a new function, ClearCurBackground, whose calls replace the direct XClearArea calls that I'd overlooked. (There's also a few compiler warnings fixed, etc ;-)

Patch #15 - 1996/5/29 - XFree86 3.1.2E

This fixes the problem reported by David Dawes, by making the 50msec select timeout for the Xaw3d arrow scrollbar a resource. (I made it a boolean for a variety of reasons -- to make it a number, you'd need an additional resource, to avoid breaking the logic).

Patch #14 - 1996/5/12 - XFree86 3.1.2Dj

This patch brings the termcap and terminfo descriptions for xterm up to date. I made the following changes:

  • reformatted the terminfo description in a single-column (this is ok for terminfo, and will simplify future patches -- can't do that for termcap, since it would impact buffer requirements on some systems).
  • omitted obsolete features in termcap to save a little space (bs, pt)
  • added color capabilities to termcap (ut, Co, NC, op, AB, AF)
  • corrected some capabilities (vi, ve)
  • added 'st' (set tab)
  • reduced function keys in termcap for 'xterm' to 12 because color capabilities makes that description larger than 1023 characters.
  • created new termcap name 'xtermm' (monochrome) to match the terminfo list, and make that description have 20 function keys.
  • added corresponding color capabilities to terminfo (bce, colors, pairs, op, ncv, setab, setaf)
  • corrected corresponding capabilities in terminfo (civis, cnorm, rmcup, smcup)
  • added capabilities (el1, hts)
  • in both, corrected home/end keys to match the code correction made by Thomas Mueller in 3.1.2Bk

    => (I'm still considering modifying the code & description to match the rxvt program).

Patch #13 - 1996/4/23 - XFree86 3.1.2Df

This corrects my earlier changes for colors - the inner border of the xterm was getting painted with the wrong color, since I'd moved the call to set the background into the logic that tracks SGR information.

Patch #12 - 1996/3/16 - XFree86 3.1.2Dc

This corrects a memory leak in xterm that happens whenever one switches fonts.

Patch #11 - 1996/3/5 - XFree86 3.1.2Db

This patch corrects the behavior of the ANSI colors in xterm when reverse video is used, as well as some other lesser sins:

  • button.c
    • (compiler warnings: shadowing of 'time', redundant cast)
  • charproc.c
    • renamed screen.colors[] array to screen.Acolors[] to more easily distinguish the non-ANSI colors from the ANSI colors.
    • moved logic of SGR_Save() into VTInitialize, getting rid of local private variables original_fg and original_bg.
    • moved some logic into getXtermForeground and getXtermBackground from SGR_Foreground, SGR_Background, etc.
    • corrected misleading 'row' to 'col' in case for CUF, CUB sequences.
  • ctlseqs.ms
  • xterm.man
    • (correct a misconception which I'd added that the color0 through color6 resource values apply to non-ANSI colors)
  • ptyx.h
    • added original_fg, original_bg to TScreen structure.
  • scrollbar.c
    • (compiler warnings: redundant cast)
  • util.c
    • new functions getXtermForeground and getXtermBackground replace the macros GET_FG and GET_BG, with the added functionality of checking for the reverse-video status of xterm.
    • in ReverseVideo, swap the SGR foreground and background colors also.

Patch #10 - 1996/2/14 - XFree86 3.1.2Cd

I observed an occasional glitch in the xterm's color behavior; a clear to end of line would get a color that had been used in a program that supposedly reset colors. I traced this down to the way xterm was modifying colors of GC's on the fly; it didn't restore the original color of the GC, even though it would later be used in functions (such as ClearRight) that assumed (my error) that the GC would have the current foreground or background color.

I fixed this by resetting the GC's colors with a new function 'resetXtermGC()', and direct calls on SGR_Foreground/SGR_Background, as appropriate and using a new function 'updatedXtermGC()' to encapsulate the logic that modifies the GC's color. (I also removed some commented-out code that was trying to do this -- the problem was a little more obscure).

Patch #9 - 1996/2/10 - XFree86 3.1.2Cb

This patch fixes the remaining problems that I had making xterm run with x11r5, as well as a couple of other bugs. It follows my patch from yesterday, that added ifdef's for some of the input-method resources.

  • corrected ifdef's that suppress the input-method code (doesn't exist in my x11r5, and xterm works adequately without it).
  • corrected fallback definition for 'Select()' macro (oops: I'd copied the wrong text...)
  • moved the declarations for the fd_set variables to data.[ch]
  • corrected an ifdef in resize.c (sunos 4.x doesn't have termcap.h)
  • corrected (in main.c) some unused/orphaned variables.

Patch #8 - 1996/2/9 - XFree86 3.1.2Cb

This is mostly a documentation patch for xterm. It describes the color control sequences in more detail, and documents some other features of xterm that aren't described elsewhere.

I've also added a couple of ifdef's to fix (part of) the problem that I'm working on (making the program work properly on x11r5, where I'm doing memory testing -- I have a "good" version from mid-January, but my resync version doesn't work properly on x11r5). I'm not done with that yet.

Patch #7 - 1996/1/28 - XFree86 3.1.2n

I did a (clean) build of 3.1.2n on Linux 1.2.13 (ELF). I've got an S3 card.

This fixes the following in the 3.1.2n xterm:

  • initialize cur_foreground, cur_background in charproc.c (Purify told me they weren't initialized).
  • add interpretation of codes 39, 49, to reset background and foreground to default value (I'm told that ISO 6429 does this; but I don't have a written reference -- yet -- can anyone help here?). Anyway, rxvt does it, and it'll solve my remaining color management problems.
  • shadowing of 'time' in menu.c
  • 'Cardinal' vs 'int' in scrollbar.c
  • several changes to permit compile with X11R5 (the system that I've got Purify on won't be upgraded to X11R6 for a long time).

I built this version (with a minor nit that I'll patch soon) on SunOS 4.1.3 so that I can test it some more with Purify.

btw: the changes made in Xpoll.h won't work on some older systems, because fd_set isn't a defined type (I've got one machine at least that this applies to).

Patch #6 - 1996/1/8

This patch does all of the SGR foreground/background fixes (i.e., clearing the screen after an SGR color is set causes that color to be used in the foreground and/or background). If the FG_COLOR and/or BG_COLOR flags aren't set, then the xterm foreground and background default to the window's values. This usage is consistent with various types of hardware (especially the IBM PC), and is also used in rxvt.

  • charproc.c:
    • add/use new macros GET_FG, GET_BG - n/c.
    • add/use new functions SGR_Foreground() and SGR_Background() to set corresponding colors in GC's, and to retain sense of "original" colors.

      => This makes redundant some of the corresponding logic in HideCursor to set the foreground and background, but I left it in since it may be fixing an unrelated requirement.

    • set GC's in LoadNewFont() according to whether the SGR fg/bg colors are active.

      => This fixes some glitches in the accompanying resize, that leaves parts of the window in the original background color.

  • screen.c:
    • modified ClearBufRows() to use the SGR fg/bg colors if they're set.
    • added function ScrnClearLines(), used this to replace portions of ScrnInsertLine() and ScrnDeleteLine(). The new function uses the SGR fg/bg colors if they're set.

      => Otherwise, selection after an index or reverse index will paint the wrong colors.

    • modified ScrnDeleteChar() and ScrnInsertChar() to use SGR fg/bg colors.
  • util.c:
    • modified ClearRight() so that if either of the SGR fg/bg colors is set, we don't bzero the attributes and color arrays, but instead fill them with the appropriate codes.
    • modified ClearLeft to use SGR fg/bg colors.

Patch #5 - 1996/1/7

This patch modifies the object code, by replacing indexing expressions with temporary variables with the full indexing expression. At first glance, this seems inefficient (it did to me ;-), until remembering comments made in the compilers newsgroups that trying to "help" the compiler doesn't really work that well. A good optimizing compiler can do a better job than the programmer can. (There's a moral in the use of 'register' variables also, but I won't fix those...).

Anyway, the revised code generates a smaller object...

  • charproc.c:
    • recode index expressions in ShowCursor() and HideCursor() using SCRN_BUF_xxxxS macros - changes object.
    • replace constant '4' by MAX_PTRS - n/c.
  • ptyx.h:
    • defined the SCRN_BUF_xxxxS macros in terms of BUF_xxxxS macros, to pick up references to ScrnBuf data directly, and added MAX_PTRS symbol to pick up those '4' constants strewn about the code - n/c.
  • screen.c:
    • recode index expressions in ScreenWrite() using SCRN_BUF_xxxxS macros - changes object.
    • replace constant '4' by MAX_PTRS - n/c.
    • use macros BUF_CHARS, BUF_ATTRS - n/c.
    • cast calloc to 'Char *' to fix compiler warning on IRIX - n/c
  • scrollbar.c:
    • replace constant '4' by MAX_PTRS - n/c.
    • cast calloc to 'Char *' to fix compiler warning on IRIX - n/c

Patch #4 - 1996/1/7

When setting up for this phase, I saw that you'd corrected the bug that I found in ClearLeft. I decided to make this series of patches anyway, since readability never hurt (and there's the potential for finding another bug while reviewing this set).

  • button.c:
    • use SCRN_BUF_xxxxS macros - n/c
  • charproc.c:
    • use SCRN_BUF_xxxxS macros - n/c
  • ptyx.h:
    • added four macros: SCRN_BUF_CHARS, SCRN_BUF_ATTRS, SCRN_BUF_FORES, SCRN_BUF_BACKS to represent the four arrays that are derived from screen->buf.
  • screen.c:
    • use SCRN_BUF_xxxxS macros - n/c
  • util.c:
    • use SCRN_BUF_xxxxS macros - n/c

Patch #3 - 1996/1/7

This is my third (and final cleanup) patch for xterm. It gets rid of the unused stuff, and converts several functions to static (thereby reducing their scope).

At this point, the only compile warnings I've got (on Linux) are those about the select arguments (int vs fd_set type), and a missing declaration for waitpid. Those both are hard to get right without autoconfigure.

The next patches will address the functional changes...

  • Tekproc.c:
    • changed several functions to 'static' that aren't used outside this module -- changes object
  • charproc.c:
    • changed several functions to 'static' that aren't used outside this module -- changes object
    • deleted unused function unparsefputs -- changes object.
  • main.c:
    • changed several functions to 'static' that aren't used outside this module -- changes object
    • ifdef'd out unused function 'consolepr()' -- changes object
    • removed unused variable 'dummy_tio' -- changes object
    • moved variable 'discipline' to quiet unused-warning -- changes object
  • main.h:
    • deleted unused definition of DEFBORDERWIDTH - n/c
  • misc.c:
    • changed several functions to 'static' that aren't used outside this module -- changes object
    • provide dummy return statements for xerror and xioerror to quiet compiler warnings -- changes object
  • ptyx.h:
    • change sbuf_address and abuf_address to 'Char *' - n/c
  • resize.c:
    • changed several functions to 'static' that aren't used outside this module -- changes object
  • screen.c:
    • remove unnecessary 'Char **' casts - n/c
  • util.c:
    • changed several functions to 'static' that aren't used outside this module -- changes object

Patch #2 - 1996/1/7

This is my second patch to xterm. It corrects most of the gcc warnings (except for some that are due to X header files ;-). I compared objects to keep track of the changes that don't affect the object code (n/c) versus those that do.

At this point, I'm compiling (fairly) clean with gcc options

        -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wnested-externs

(I also compiled with -Wshadow, but while that found some things that I wanted to find, there's far too many warnings from the X headers to be usable in this context).

The changes:

  • Tekproc.c:
    • parenthesized expression to avoid gcc warning -- n/c.
    • corrected nested-extern declaration for Bool waiting_for_initial_map; ourTopLevelShellArgs, and number_ourTopLevelShellArgs - n/c
  • charproc.c:
    • corrected potentially-unintialized variables 'scstype', 'xim', and 'input_style' -- changes object.
    • adjusted logic of VTparse so that gcc won't warn about setjmp clobbering parsestate -- changes object.
    • corrected initialization of 'scstype', which could have been clobbered by setjmp/longjmp - changes object.
    • corrected nested-extern declaration of 'term', 'ProgramName' - n/c
  • cursor.c:
    • corrected nested-extern declaration of 'term' -- n/c
    • renamed 'term' parameters to avoid gcc -Wshadow warning - n/c
  • input.c:
    • change interface of StringInput to assume size_t (i.e., unsigned) nbytes -- changes object.
    • change interface of funcvalue, and sunfuncvalue to use 'KeySym' type instead of 'int' - changes object.
  • main.c:
    • moved definitions of SIGNAL_T, SIGNAL_RETURN to proto.h - n/c
    • corrected missing params of 'do_hangup()' -- changes object (note: the missing params were not used).
    • corrected missing param of 'Error()' -- changes object
    • corrected nested-extern 'environ' - n/c
    • adjusted assignments to 'tty_got_hung' and 'no_dev_tty' so that gcc can see they won't be clobbered by the longjmp - changes object.
    • use Size_t type - n/c.
  • menu.c:
    • removed redundant prototype for 'do_hangup()' -- n/c.
    • renamed 'time' parameters to avoid gcc -Wshadow warning - n/c
  • menu.h:
    • renamed 'time' parameters to avoid gcc -Wshadow warning - n/c
  • misc.c:
    • corrected definition of 'HandleFocusChange()' -- changes object
    • cast parameters in call to 'TekExpose()' -- n/c
    • corrected nested-extern declarations of 'term', 'toplevel', ProgramName, and 'environ' -- n/c.
    • use Size_t type - n/c.
  • proto.h:
    • moved definition of SIGNAL_T (and SIGNAL_RETURN) here from main.c, resize.c to allow use of this symbol in prototypes (mostly in xterm.h).
    • added definition 'Size_t' to use as corrected type for strncpy, malloc sizes - n/c.
  • resize.c:
    • moved SIGNAL_T definition to proto.h -- n/c.
    • use Size_t type - n/c.
  • screen.c:
    • use Size_t type - n/c.
  • tabs.c:
    • corrected nested-extern declaration of 'term' -- n/c
  • util.c:
    • corrected/supplied parameters to 'TekExpose()' -- changes object (note: 'TekExpose()' doesn't use its parameters).
    • corrected nested-extern declaration of 'waiting_for_initial_map' -- n/c.
    • renamed 'term' parameters to avoid gcc -Wshadow warning - n/c
  • xterm.h:
    • prototype 'do_hangup()', 'HandleFocusChange()', 'TekExpose()', 'Error()', 'Exit()' - forces changes in various places.
    • adjusted prototypes that pass 'Boolean' arguments to use 'int' (this is the "correct" ANSI approach to extended compiles; it's worth mentioning that gcc doesn't meet the ANSI spec here). I used gcc -Wconversion to find these, but there's a lot of unrelated warnings that are due to setting NARROWPROTO in the config - n/c.
    • renamed 'term' parameters to avoid gcc -Wshadow warning - n/c

Patch #1 - 1996/1/6

This is my first cleanup patch for xterm. It addresses all of the gcc warnings for -Wall, -Wmissing-prototypes and -Wstrict-prototypes that I can change without modifying the object code. (I'm compiling this with gcc 2.7.0 for an aout target, which makes it simple to compare objects. When I do ELF-only, I've got a tool that compares that sort of thing as well).

Briefly, this patch adds (and uses) two header files in the xterm directory:

        proto.h
        xterm.h

I expect this to be the biggest patch by far. However (barring a misplaced prototype), it shouldn't break anything, since the intent of the patch is to provide missing declarations.

xterm-330/xutf8.c0000644000175100001440000001715113113503474012467 0ustar tomusers/* $XTermId: xutf8.c,v 1.16 2017/05/31 09:05:00 tom Exp $ */ /* * Copyright 2002-2016,2017 by Thomas E. Dickey * Copyright (c) 2001 by Juliusz Chroboczek * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include #include #include #include #include #include #ifndef X_HAVE_UTF8_STRING #undef XA_UTF8_STRING #define KEYSYM2UCS_INCLUDED #include "keysym2ucs.c" Atom _xa_utf8_string(Display *dpy) { static AtomPtr p = NULL; if (p == NULL) p = XmuMakeAtom("UTF8_STRING"); return XmuInternAtom(dpy, p); } #define XA_UTF8_STRING(dpy) _xa_utf8_string(dpy) static int utf8countBytes(int c) { if (c < 0) return 0; if (c <= 0x7F) { return 1; } else if (c <= 0x7FF) { return 2; } else if (c <= 0xFFFF) { return 3; } else return 4; } static void utf8insert(char *dest, int c, size_t *len_return) { if (c < 0) return; if (c <= 0x7F) { dest[0] = (char) c; *len_return = 1; } else if (c <= 0x7FF) { dest[0] = (char) (0xC0 | ((c >> 6) & 0x1F)); dest[1] = (char) (0x80 | (c & 0x3F)); *len_return = 2; } else if (c <= 0xFFFF) { dest[0] = (char) (0xE0 | ((c >> 12) & 0x0F)); dest[1] = (char) (0x80 | ((c >> 6) & 0x3F)); dest[2] = (char) (0x80 | (c & 0x3F)); *len_return = 3; } else { dest[0] = (char) (0xF0 | ((c >> 18) & 0x07)); dest[1] = (char) (0x80 | ((c >> 12) & 0x3f)); dest[2] = (char) (0x80 | ((c >> 6) & 0x3f)); dest[3] = (char) (0x80 | (c & 0x3f)); *len_return = 4; } } static size_t l1countUtf8Bytes(char *s, size_t len) { size_t l = 0; while (len != 0) { if ((*s & 0x80) == 0) l++; else l += 2; s++; len--; } return l; } static void l1utf8copy(char *d, char *s, size_t len) { size_t l; while (len != 0) { utf8insert(d, (*s) & 0xFF, &l); d += (int) l; s++; len--; } } static void utf8l1strcpy(char *d, char *s) { #define SKIP do { s++; } while(((*s & 0x80) != 0) && (*s & 0xC0) != 0xC0) while (*s) { if ((*s & 0x80) == 0) *d++ = *s++; else if ((*s & 0x7C) == 0x40) { if ((s[1] & 0x80) == 0) { s++; /* incorrect UTF-8 */ continue; } else if ((*s & 0x7C) == 0x40) { *d++ = (char) (((*s & 0x03) << 6) | (s[1] & 0x3F)); s += 2; } else { *d++ = '?'; SKIP; } } else { *d++ = '?'; SKIP; } } *d = 0; #undef SKIP } /* Keep this in sync with utf8l1strcpy! */ static int utf8l1strlen(char *s) { #define SKIP do { s++; } while(((*s & 0x80) != 0) && (*s & 0xC0) != 0xC0) int len = 0; while (*s) { if ((*s & 0x80) == 0) { s++; len++; } else if ((*s & 0x7C) == 0x40) { if ((s[1] & 0x80) == 0) { s++; continue; } else if ((*s & 0x7C) == 0x40) { len++; s += 2; } else { len++; SKIP; } } else { len++; SKIP; } } #undef SKIP return len; } int Xutf8TextPropertyToTextList(Display *dpy, const XTextProperty * tp, char ***list_return, int *count_return) { int utf8; char **list; int nelements; char *cp; char *start; size_t i; int j; size_t datalen = tp->nitems; size_t len; if (tp->format != 8) return XConverterNotFound; if (tp->encoding == XA_STRING) utf8 = 0; else if (tp->encoding == XA_UTF8_STRING(dpy)) utf8 = 1; else return XConverterNotFound; if (datalen == 0) { *list_return = NULL; *count_return = 0; return 0; } nelements = 1; for (cp = (char *) tp->value, i = datalen; i != 0; cp++, i--) { if (*cp == '\0') nelements++; } list = TypeMallocN(char *, (unsigned) nelements); if (!list) return XNoMemory; if (utf8) len = datalen; else len = l1countUtf8Bytes((char *) tp->value, datalen); start = TextAlloc(len); if (!start) { free(list); return XNoMemory; } if (utf8) memcpy(start, (char *) tp->value, datalen); else l1utf8copy(start, (char *) tp->value, datalen); start[len] = '\0'; for (cp = start, i = len + 1, j = 0; i != 0; cp++, i--) { if (*cp == '\0') { list[j] = start; start = (cp + 1); j++; } } list[j] = NULL; *list_return = list; *count_return = nelements; return 0; } int Xutf8TextListToTextProperty(Display *dpy, char **list, int count, XICCEncodingStyle style, XTextProperty * text_prop) { XTextProperty proto; unsigned int nbytes; int i; if (style != XStringStyle && style != XCompoundTextStyle && style != XStdICCTextStyle && style != XUTF8StringStyle) return XConverterNotFound; if (style == XUTF8StringStyle) { for (i = 0, nbytes = 0; i < count; i++) { nbytes += (unsigned) ((list[i] ? strlen(list[i]) : 0) + 1); } } else { for (i = 0, nbytes = 0; i < count; i++) { nbytes += (unsigned) ((list[i] ? utf8l1strlen(list[i]) : 0) + 1); } } if (style == XCompoundTextStyle) proto.encoding = XA_COMPOUND_TEXT(dpy); else if (style == XUTF8StringStyle) proto.encoding = XA_UTF8_STRING(dpy); else proto.encoding = XA_STRING; proto.format = 8; if (nbytes) proto.nitems = nbytes - 1; else proto.nitems = 0; proto.value = NULL; if (nbytes > 0) { char *buf = TypeMallocN(char, nbytes); if (!buf) return XNoMemory; proto.value = (unsigned char *) buf; for (i = 0; i < count; i++) { char *arg = list[i]; if (arg) { if (style == XUTF8StringStyle) { strcpy(buf, arg); } else { utf8l1strcpy(buf, arg); } buf += (strlen(buf) + 1); } else { *buf++ = '\0'; } } } else { proto.value = CastMalloc(unsigned char); /* easier for client */ if (!proto.value) return XNoMemory; proto.value[0] = '\0'; } *text_prop = proto; return 0; } int Xutf8LookupString(XIC ic GCC_UNUSED, XKeyEvent *ev, char *buffer, int nbytes, KeySym * keysym_return, Status * status_return) { int rc; KeySym keysym; int codepoint; size_t len; rc = XLookupString(ev, buffer, nbytes, &keysym, NULL); if (rc > 0) { codepoint = buffer[0] & 0xFF; } else { codepoint = keysym2ucs(keysym); } if (codepoint < 0) { if (keysym == None) { *status_return = XLookupNone; } else { *status_return = XLookupKeySym; *keysym_return = keysym; } return 0; } if (nbytes < utf8countBytes(codepoint)) { *status_return = XBufferOverflow; return utf8countBytes(codepoint); } utf8insert(buffer, codepoint, &len); if (keysym != None) { *keysym_return = keysym; *status_return = XLookupBoth; } else { *status_return = XLookupChars; } return (int) len; } #else /* X_HAVE_UTF8_STRING */ /* Silence the compiler */ void xutf8_dummy(void) { return; } #endif xterm-330/NEWS0000644000175100001440000000410613122341131011726 0ustar tomusersThe NEWS file was generated from xterm.log.html, which serves as the changelog for xterm. -------------------------------------------------------------------------------- Patch #330 - 2017/06/20 * updates for ReGIS (Ross Combs): + remove redundant text command error check which broke T(B) and T(E). + retain the loading alphabet number across multiple “L†commands. + add S(T) delay handler. + fix some color handling error messages. + add stubbed-out macrograph handling. + use fragment_remaining() and fragment_consumed() instead of manually checking position / length in various places. + rename some local variables in string / extent / option parsing + wrap some long lines. + move macrograph command handling out of the top-level. * add a summary of the italic fonts loaded to -report-fonts option. * modify the font-lookup for italics to allow for “-i-†if no match is found with slant “-o-†(prompted by patch by Ben Wong). * change default values for mkSamplePass and mkSampleSize to reflect generally-improved locale support in various operating systems (FreeBSD #219800). * modify wcwidth.c to return -1 for non-Unicode values, and adjust a couple of blocks to better match assumptions about ambiguous-width characters in other implementations. Also modify wcwidth.c to support configurable soft-hyphen, so there is no drawback to using this version rather than a system wcwidth. * amend change made in patch #328 for cursor-visibility to handle case where an application is updating the reverse-video state (FreeBSD #219800). * update tables of combining and ambiguous-width characters in wcwidth.c based on Unicode 10.0.0. * build-fix for --enable-sixel-graphics without --enable-regis-graphics (reports by Sven Joachim, FreeBSD #219945). xterm-330/cursor.c0000644000175100001440000002716413103217663012734 0ustar tomusers/* $XTermId: cursor.c,v 1.71 2017/05/06 00:58:27 tom Exp $ */ /* * Copyright 2002-2016,2017 by Thomas E. Dickey * * All Rights Reserved * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * Except as contained in this notice, the name(s) of the above copyright * holders shall not be used in advertising or otherwise to promote the * sale, use or other dealings in this Software without prior written * authorization. * * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ /* cursor.c */ #include #include #include #include /* * Moves the cursor to the specified position, checking for bounds. * (this includes scrolling regions) * The origin is considered to be 0, 0 for this procedure. */ void CursorSet(TScreen *screen, int row, int col, unsigned flags) { int use_row = row; int use_col = col; int max_col = screen->max_col; int max_row = screen->max_row; if (flags & ORIGIN) { use_col += screen->lft_marg; max_col = screen->rgt_marg; } use_col = (use_col < 0 ? 0 : use_col); set_cur_col(screen, (use_col <= max_col ? use_col : max_col)); if (flags & ORIGIN) { use_row += screen->top_marg; max_row = screen->bot_marg; } use_row = (use_row < 0 ? 0 : use_row); set_cur_row(screen, (use_row <= max_row ? use_row : max_row)); ResetWrap(screen); TRACE(("CursorSet(%d,%d) margins V[%d..%d] H[%d..%d] -> %d,%d %s\n", row, col, screen->top_marg, screen->bot_marg, screen->lft_marg, screen->rgt_marg, screen->cur_row, screen->cur_col, ((flags & ORIGIN) ? "origin" : "normal"))); } /* * moves the cursor left n, no wrap around */ void CursorBack(XtermWidget xw, int n) { #define WRAP_MASK (REVERSEWRAP | WRAPAROUND) TScreen *screen = TScreenOf(xw); int rev; int left = ScrnLeftMargin(xw); int before = screen->cur_col; if ((rev = ((xw->flags & WRAP_MASK) == WRAP_MASK)) != 0 && screen->do_wrap) { n--; } /* if the cursor is already before the left-margin, we have to let it go */ if (before < left) left = 0; if ((screen->cur_col -= n) < left) { if (rev) { int in_row = ScrnRightMargin(xw) - left + 1; int offset = (in_row * screen->cur_row) + screen->cur_col - left; if (offset < 0) { int length = in_row * MaxRows(screen); offset += ((-offset) / length + 1) * length; } set_cur_row(screen, (offset / in_row)); set_cur_col(screen, (offset % in_row) + left); do_xevents(); } else { set_cur_col(screen, left); } } ResetWrap(screen); } /* * moves the cursor forward n, no wraparound */ void CursorForward(XtermWidget xw, int n) { TScreen *screen = TScreenOf(xw); #if OPT_DEC_CHRSET LineData *ld = getLineData(screen, screen->cur_row); #endif int next = screen->cur_col + n; int max; if (IsLeftRightMode(xw)) { max = screen->rgt_marg; if (screen->cur_col > max) max = screen->max_col; } else { max = LineMaxCol(screen, ld); } if (next > max) next = max; set_cur_col(screen, next); ResetWrap(screen); } /* * moves the cursor down n, no scrolling. * Won't pass bottom margin or bottom of screen. */ void CursorDown(TScreen *screen, int n) { int max; int next = screen->cur_row + n; max = (screen->cur_row > screen->bot_marg ? screen->max_row : screen->bot_marg); if (next > max) next = max; if (next > screen->max_row) next = screen->max_row; set_cur_row(screen, next); ResetWrap(screen); } /* * moves the cursor up n, no linestarving. * Won't pass top margin or top of screen. */ void CursorUp(TScreen *screen, int n) { int min; int next = screen->cur_row - n; min = ((screen->cur_row < screen->top_marg) ? 0 : screen->top_marg); if (next < min) next = min; if (next < 0) next = 0; set_cur_row(screen, next); ResetWrap(screen); } /* * Moves cursor down amount lines, scrolls if necessary. * Won't leave scrolling region. No carriage return. */ void xtermIndex(XtermWidget xw, int amount) { TScreen *screen = TScreenOf(xw); /* * indexing when below scrolling region is cursor down. * if cursor high enough, no scrolling necessary. */ if (screen->cur_row > screen->bot_marg || screen->cur_row + amount <= screen->bot_marg || (IsLeftRightMode(xw) && !ScrnIsColInMargins(screen, screen->cur_col))) { CursorDown(screen, amount); } else { int j; CursorDown(screen, j = screen->bot_marg - screen->cur_row); xtermScroll(xw, amount - j); } } /* * Moves cursor up amount lines, reverse scrolls if necessary. * Won't leave scrolling region. No carriage return. */ void RevIndex(XtermWidget xw, int amount) { TScreen *screen = TScreenOf(xw); /* * reverse indexing when above scrolling region is cursor up. * if cursor low enough, no reverse indexing needed */ if (screen->cur_row < screen->top_marg || screen->cur_row - amount >= screen->top_marg || (IsLeftRightMode(xw) && !ScrnIsColInMargins(screen, screen->cur_col))) { CursorUp(screen, amount); } else { RevScroll(xw, amount - (screen->cur_row - screen->top_marg)); CursorUp(screen, screen->cur_row - screen->top_marg); } } /* * Moves Cursor To First Column In Line * (Note: xterm doesn't implement SLH, SLL which would affect use of this) */ void CarriageReturn(XtermWidget xw) { TScreen *screen = TScreenOf(xw); int left = ScrnLeftMargin(xw); int col; if (xw->flags & ORIGIN) { col = left; } else if (screen->cur_col >= left) { col = left; } else { /* * If origin-mode is not active, it is possible to use cursor * addressing outside the margins. In that case we will go to the * first column rather than following the margin. */ col = 0; } set_cur_col(screen, col); ResetWrap(screen); do_xevents(); } /* * When resizing the window, if we're showing the alternate screen, we still * have to adjust the saved cursor from the normal screen to account for * shifting of the saved-line region in/out of the viewable window. */ void AdjustSavedCursor(XtermWidget xw, int adjust) { TScreen *screen = TScreenOf(xw); if (screen->whichBuf) { SavedCursor *sc = &screen->sc[0]; if (adjust > 0) { TRACE(("AdjustSavedCursor %d -> %d\n", sc->row, sc->row - adjust)); sc->row += adjust; } } } /* * Save Cursor and Attributes */ void CursorSave(XtermWidget xw) { TScreen *screen = TScreenOf(xw); SavedCursor *sc = &screen->sc[screen->whichBuf]; sc->saved = True; sc->row = screen->cur_row; sc->col = screen->cur_col; sc->flags = xw->flags; sc->curgl = screen->curgl; sc->curgr = screen->curgr; sc->wrap_flag = screen->do_wrap; #if OPT_ISO_COLORS sc->cur_foreground = xw->cur_foreground; sc->cur_background = xw->cur_background; sc->sgr_foreground = xw->sgr_foreground; #endif memmove(sc->gsets, screen->gsets, sizeof(screen->gsets)); } /* * We save/restore all visible attributes, plus wrapping, origin mode, and the * selective erase attribute. */ #define DECSC_FLAGS (ATTRIBUTES|ORIGIN|PROTECTED) /* * Restore Cursor and Attributes */ void CursorRestore(XtermWidget xw) { TScreen *screen = TScreenOf(xw); SavedCursor *sc = &screen->sc[screen->whichBuf]; /* Restore the character sets, unless we never did a save-cursor op. * In that case, we'll reset the character sets. */ if (sc->saved) { memmove(screen->gsets, sc->gsets, sizeof(screen->gsets)); screen->curgl = sc->curgl; screen->curgr = sc->curgr; } else { resetCharsets(screen); } UIntClr(xw->flags, DECSC_FLAGS); UIntSet(xw->flags, sc->flags & DECSC_FLAGS); CursorSet(screen, ((xw->flags & ORIGIN) ? sc->row - screen->top_marg : sc->row), sc->col, xw->flags); screen->do_wrap = sc->wrap_flag; /* after CursorSet/ResetWrap */ #if OPT_ISO_COLORS xw->sgr_foreground = sc->sgr_foreground; SGR_Foreground(xw, (xw->flags & FG_COLOR) ? sc->cur_foreground : -1); SGR_Background(xw, (xw->flags & BG_COLOR) ? sc->cur_background : -1); #endif } /* * Move the cursor to the first column of the n-th next line. */ void CursorNextLine(XtermWidget xw, int count) { TScreen *screen = TScreenOf(xw); CursorDown(screen, count < 1 ? 1 : count); CarriageReturn(xw); do_xevents(); } /* * Move the cursor to the first column of the n-th previous line. */ void CursorPrevLine(XtermWidget xw, int count) { TScreen *screen = TScreenOf(xw); CursorUp(screen, count < 1 ? 1 : count); CarriageReturn(xw); do_xevents(); } /* * Return col/row values which can be passed to CursorSet() preserving the * current col/row, e.g., accounting for DECOM. */ int CursorCol(XtermWidget xw) { TScreen *screen = TScreenOf(xw); int result = screen->cur_col; if (xw->flags & ORIGIN) { result -= ScrnLeftMargin(xw); if (result < 0) result = 0; } return result; } int CursorRow(XtermWidget xw) { TScreen *screen = TScreenOf(xw); int result = screen->cur_row; if (xw->flags & ORIGIN) { result -= screen->top_marg; if (result < 0) result = 0; } return result; } #if OPT_TRACE int set_cur_row(TScreen *screen, int value) { TRACE(("set_cur_row %d vs %d\n", value, screen ? screen->max_row : -1)); assert(screen != 0); assert(value >= 0); assert(value <= screen->max_row); screen->cur_row = value; return value; } int set_cur_col(TScreen *screen, int value) { TRACE(("set_cur_col %d vs %d\n", value, screen ? screen->max_col : -1)); assert(screen != 0); assert(value >= 0); assert(value <= screen->max_col); screen->cur_col = value; return value; } #endif /* OPT_TRACE */ xterm-330/terminfo0000644000175100001440000012764713103722651013026 0ustar tomusers# $XTermId: terminfo,v 1.165 2017/05/07 22:54:33 tom Exp $ # # Updates/notes/new entries (e.g., xterm-8bit, xterm-16color, xterm-256color) # - Thomas E. Dickey # #------------------------------------------------------------------------------ # Copyright 1996-2016,2017 by Thomas E. Dickey # # All Rights Reserved # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name(s) of the above copyright # holders shall not be used in advertising or otherwise to promote the # sale, use or other dealings in this Software without prior written # authorization. #------------------------------------------------------------------------------ # # Special Capabilities: # -------------------- # ich has a corresponding capability that inserts a single blank. We could # have used ich1=\E[@, which works with ncurses, but that is not standard # behavior. If it is set, then SVr4 vi (e.g., Solaris 2.6) emits both # smir/rmir and ich1. # meml locks memory above the cursor; memu unlocks (ala HP terminals). This # is not recognized by some older (e.g., SVr3) tic programs, but none # do more than warn about it. Ignore the warning. # smcup clears memory before switching to the alternate screen. The older # (deprecated) \E[?47h did not do this, requiring applications to # embed a \E[2J in the rmcup string. However, that behavior cannot # be disabled via titeInhibit, making that resource not function as # intended on systems with terminfo. # rs2/is2 are shorter with XFree86 xterm because it supports DECSTR. We # use the shorter sequence for compatibility with the termcap, which # is trimmed to keep it shorter than 1023 characters. It (escape \E[!p) # replaces these in the conventional vt100 reset-string: # \E7 - save cursor (fixes origin-mode side-effect) # \E[r - reset scrolling margins # \E[m - reset SGR (including color) # \E[?7h - reset wraparound mode (DECAWM) # \E[?1l - reset application cursor keys (DECCKM) # \E[?6l - reset origin mode (DECOM) # \E8 - restore cursor # DECSTR is recognized by XFree86 xterm even in vt52 mode. # # Editing Keypad: # -------------- # XFree86 xterm emulates vt220 if the decTerminalID resource is set to 200 or # higher. Otherwise it emulates a vt100 or vt52 depending on the value of the # resource. When emulating a vt220, we support the editing keypad. Sun and PC # keyboards have an editing keypad which is similar to the vt220: # # VT220 editing keypad # ---------------------------- # Find Insert Remove # Select Prev Next # ---------------------------- # # Sun/PC editing keypad # ---------------------------- # Insert Home PageUp # Delete End PageDn # ---------------------------- # # If the sunKeyboard resource is true, we map it this way (adjusting the values # of Home, End and Delete): # VT220 Sun/PC # ---------------------------- # Find Home # Select End # Insert Insert # Remove Delete # Prev PageUp # Next PageDn # ---------------------------- # # Note that all of the keys on the editing keypad transmit escape sequences. A # vt220 does this only when in vt220 mode; when emulating a vt100 the editing # keypad is inactive. # # Alternative keycodes: # -------------------- # Several of the function keys have alternative names, depending on the type of # host which your xterm is connected to. DEC (i.e., the VMS system) uses F15 # as the HELP key, F16 as the DO key. Unix applications generally do not do # this. Curses applications in particular, assign a unique keycode to each # capability string. These terminal descriptions do not have conflicting # definitions, to ensure that Unix curses applications use a consistent set of # keycodes. To get a VMS-bias, make these substitutions: # 1. change khome to kfnd # 2. change kend to kslt # The original xterm-r6 entry does in fact have a VMS bias. # # Some legacy applications using the termcap emulation may expect kll where # we have specified kend. # # Function keys with modifiers (Sun/PC): # ------------------------------------- # Shift-Fx - kf{12+x} # Control-Fx - kf{24+x} # Shift-Control-Fx - kf{36+x} # # The terminfo defines some special keys which are documented as "shifted", # e.g., kDC is shifted-delete-character. # # Note however, that even though the terminfo says a key might be sent, there # may be conflicts which prevent this. For example, it is common to use # shifted pageup and pagedown for window manager functions. The default # translation for xterm since X11R4 has overridden shifted Insert, Select, # PageUp and PageDown, which correspond to terminfo kIC, kEND, kPRV and kNXT # respectively. # xterm-new|modern xterm terminal emulator, npc, indn=\E[%p1%dS, kb2=\EOE, kcbt=\E[Z, kent=\EOM, rin=\E[%p1%dT, use=ecma+strikeout, use=xterm+pcfkeys, use=xterm+tmux, use=xterm-basic, # # Encode modifiers using parameters (see "Xterm Control Sequences" ctlseqs.ms). # Note that this is unrelated to PCTERM. # # Some names are extensions allowed by ncurses, e.g., # kDN, kDN5, kDN6, kLFT5, kLFT6, kRIT5, kRIT6, kUP, kUP5, kUP6 # # The uppercase names are made up, since there are no standards that apply. # If they were limited to two characters, they could in principle be translated # to termcap. However, termcap sizes are limited to 1023 bytes, so there is # little point in ensuring that extended key names can be translated to # termcap. A terminfo file can be up to 4096 bytes; using all extended keys # that xterm can generate would in fact exceed that limit. # # The numbers correspond to the modifier parameters documented in Xterm # Control Sequences: # # 2 Shift # 3 Alt # 4 Shift + Alt # 5 Control # 6 Shift + Control # 7 Alt + Control # 8 Shift + Alt + Control # # X/Open Curses defines some shift combinations, which are also used here # where applicable. Since it does define some shift combinations, no number # (2) is used for suffixing the made-up names. Some combinations are not # useful, e.g., they may reboot your computer, or they may require too many # fingers. I stopped at modifier 7, just to keep things simple -TD # # XTerm resources: # --------------- # The xterm+pcfn, xterm+pcf0, xterm+pcf1, xterm+pcf2 and xterm+pcf3 fragments # correspond to default resource settings for xterm on a 104-key PC keyboard # with 12 function-keys: # # *sunKeyboard:false # *oldXtermFKeys:false # *modifyCursorKeys:2 # *modifyFunctionKeys:2 # *ctrlFKeys:10 # # The key numbers are computed based on the modifiers: # # kf1-kf12 are F1-F12 # kf13-kf24 are shift F1-F12 # kf25-kf36 are control F1-F12 # kf37-kf48 are control+shift F1-F12 # kf49-kf60 are alt F1-F12 # kf61-kf63 are shift-alt F1-F3 # # Note that ncurses would allow definition of kf64 and beyond, if there were # an application that required it. # xterm+pcfkeys|fragment for PC-style keys, use=xterm+app, use=xterm+pcf2, use=xterm+pce2, use=xterm+pcc2, # This chunk is based on suggestions by Ailin Nemui and Nicholas Marriott, who # asked for some of xterm's advanced features to be added to its terminfo # entry. It defines extended capabilities not found in standard terminfo or # termcap. These are useful in tmux, for instance, hence the name. # # One caveat in adding extended capabilities in ncurses is that if the names # are longer than two characters, then they will not be visible through the # termcap interface. # # Ms modifies the selection/clipboard. Its parameters are # p1 = the storage unit (clipboard, selection or cut buffer) # p2 = the base64-encoded clipboard content. # # Ss is used to set the cursor style as described by the DECSCUSR # function to a block or underline. # Se resets the cursor style to the terminal power-on default. # # Cs and Ce set and reset the cursor colour. xterm+tmux|advanced xterm features used in tmux, Cr=\E]112\007, Cs=\E]12;%p1%s\007, Ms=\E]52;%p1%s;%p2%s \007, Se=\E[2\sq, Ss=\E[%p1%d\sq, # # The ctrlFKeys resource is only relevant to the xterm+pcfn and xterm+pcfN # entries, since the modifyFunctionKeys resource overrides ctrlFKeys when it is # positive. A different choice of ctrlFKeys would give a different set of # function-key strings. xterm+pcfn|fragment with modifyFunctionKeys:-1 and ctrlFKeys:10, kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf2=\EOQ, kf20=\E[34~, kf21=\E[42~, kf22=\E[43~, kf23=\E[44~, kf24=\E[45~, kf25=\E[46~, kf26=\E[47~, kf27=\E[48~, kf28=\E[49~, kf29=\E[50~, kf3=\EOR, kf30=\E[51~, kf31=\E[52~, kf32=\E[53~, kf33=\E[54~, kf34=\E[55~, kf35=\E[56~, kf36=\E[57~, kf37=\E[58~, kf38=\E[59~, kf39=\E[60~, kf4=\EOS, kf40=\E[61~, kf41=\E[62~, kf42=\E[63~, kf43=\E[64~, kf44=\E[65~, kf45=\E[66~, kf46=\E[67~, kf47=\E[68~, kf48=\E[69~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, # Changing ctrlFKeys to 12 would let us number the keys using just shift- and # control- modifiers: # kf1-kf12 are F1-F12 # kf13-kf24 are shift F1-F12 # kf25-kf36 are control F1-F12 # kf37-kf48 are control+shift F1-F12 xterm+pcfN|fragment with modifyFunctionKeys:-1 and ctrlFKeys:12, kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf2=\EOQ, kf20=\E[34~, kf21=\E[42~, kf22=\E[43~, kf23=\E[44~, kf24=\E[45~, kf25=\E[46~, kf26=\E[47~, kf27=\E[48~, kf28=\E[49~, kf29=\E[50~, kf3=\EOR, kf30=\E[51~, kf31=\E[52~, kf32=\E[53~, kf33=\E[54~, kf34=\E[55~, kf35=\E[56~, kf36=\E[57~, kf37=\E[58~, kf38=\E[59~, kf39=\E[60~, kf4=\EOS, kf40=\E[61~, kf41=\E[62~, kf42=\E[63~, kf43=\E[64~, kf44=\E[65~, kf45=\E[66~, kf46=\E[67~, kf47=\E[68~, kf48=\E[69~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, xterm+pcf0|fragment with modifyFunctionKeys:0, kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\EO2P, kf14=\EO2Q, kf15=\EO2R, kf16=\EO2S, kf17=\E[15;2~, kf18=\E[17;2~, kf19=\E[18;2~, kf2=\EOQ, kf20=\E[19;2~, kf21=\E[20;2~, kf22=\E[21;2~, kf23=\E[23;2~, kf24=\E[24;2~, kf25=\EO5P, kf26=\EO5Q, kf27=\EO5R, kf28=\EO5S, kf29=\E[15;5~, kf3=\EOR, kf30=\E[17;5~, kf31=\E[18;5~, kf32=\E[19;5~, kf33=\E[20;5~, kf34=\E[21;5~, kf35=\E[23;5~, kf36=\E[24;5~, kf37=\EO6P, kf38=\EO6Q, kf39=\EO6R, kf4=\EOS, kf40=\EO6S, kf41=\E[15;6~, kf42=\E[17;6~, kf43=\E[18;6~, kf44=\E[19;6~, kf45=\E[20;6~, kf46=\E[21;6~, kf47=\E[23;6~, kf48=\E[24;6~, kf49=\EO3P, kf5=\E[15~, kf50=\EO3Q, kf51=\EO3R, kf52=\EO3S, kf53=\E[15;3~, kf54=\E[17;3~, kf55=\E[18;3~, kf56=\E[19;3~, kf57=\E[20;3~, kf58=\E[21;3~, kf59=\E[23;3~, kf6=\E[17~, kf60=\E[24;3~, kf61=\EO4P, kf62=\EO4Q, kf63=\EO4R, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, # This is almost the same as xterm+pcf2 because the unmodified keys all happen # to have a pattern that forces the modifier to the same position. xterm+pcf1|fragment with modifyFunctionKeys:1, kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[2P, kf14=\E[2Q, kf15=\E[2R, kf16=\E[2S, kf17=\E[15;2~, kf18=\E[17;2~, kf19=\E[18;2~, kf2=\EOQ, kf20=\E[19;2~, kf21=\E[20;2~, kf22=\E[21;2~, kf23=\E[23;2~, kf24=\E[24;2~, kf25=\E[5P, kf26=\E[5Q, kf27=\E[5R, kf28=\E[5S, kf29=\E[15;5~, kf3=\EOR, kf30=\E[17;5~, kf31=\E[18;5~, kf32=\E[19;5~, kf33=\E[20;5~, kf34=\E[21;5~, kf35=\E[23;5~, kf36=\E[24;5~, kf37=\E[6P, kf38=\E[6Q, kf39=\E[6R, kf4=\EOS, kf40=\E[6S, kf41=\E[15;6~, kf42=\E[17;6~, kf43=\E[18;6~, kf44=\E[19;6~, kf45=\E[20;6~, kf46=\E[21;6~, kf47=\E[23;6~, kf48=\E[24;6~, kf49=\E[3P, kf5=\E[15~, kf50=\E[3Q, kf51=\E[3R, kf52=\E[3S, kf53=\E[15;3~, kf54=\E[17;3~, kf55=\E[18;3~, kf56=\E[19;3~, kf57=\E[20;3~, kf58=\E[21;3~, kf59=\E[23;3~, kf6=\E[17~, kf60=\E[24;3~, kf61=\E[4P, kf62=\E[4Q, kf63=\E[4R, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, xterm+pcf2|fragment with modifyFunctionKeys:2, kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[1;2P, kf14=\E[1;2Q, kf15=\E[1;2R, kf16=\E[1;2S, kf17=\E[15;2~, kf18=\E[17;2~, kf19=\E[18;2~, kf2=\EOQ, kf20=\E[19;2~, kf21=\E[20;2~, kf22=\E[21;2~, kf23=\E[23;2~, kf24=\E[24;2~, kf25=\E[1;5P, kf26=\E[1;5Q, kf27=\E[1;5R, kf28=\E[1;5S, kf29=\E[15;5~, kf3=\EOR, kf30=\E[17;5~, kf31=\E[18;5~, kf32=\E[19;5~, kf33=\E[20;5~, kf34=\E[21;5~, kf35=\E[23;5~, kf36=\E[24;5~, kf37=\E[1;6P, kf38=\E[1;6Q, kf39=\E[1;6R, kf4=\EOS, kf40=\E[1;6S, kf41=\E[15;6~, kf42=\E[17;6~, kf43=\E[18;6~, kf44=\E[19;6~, kf45=\E[20;6~, kf46=\E[21;6~, kf47=\E[23;6~, kf48=\E[24;6~, kf49=\E[1;3P, kf5=\E[15~, kf50=\E[1;3Q, kf51=\E[1;3R, kf52=\E[1;3S, kf53=\E[15;3~, kf54=\E[17;3~, kf55=\E[18;3~, kf56=\E[19;3~, kf57=\E[20;3~, kf58=\E[21;3~, kf59=\E[23;3~, kf6=\E[17~, kf60=\E[24;3~, kf61=\E[1;4P, kf62=\E[1;4Q, kf63=\E[1;4R, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, xterm+pcf3|fragment with modifyFunctionKeys:3, kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[>1;2P, kf14=\E[>1;2Q, kf15=\E[>1;2R, kf16=\E[>1;2S, kf17=\E[>15;2~, kf18=\E[>17;2~, kf19=\E[>18;2~, kf2=\EOQ, kf20=\E[>19;2~, kf21=\E[>20;2~, kf22=\E[>21;2~, kf23=\E[>23;2~, kf24=\E[>24;2~, kf25=\E[>1;5P, kf26=\E[>1;5Q, kf27=\E[>1;5R, kf28=\E[>1;5S, kf29=\E[>15;5~, kf3=\EOR, kf30=\E[>17;5~, kf31=\E[>18;5~, kf32=\E[>19;5~, kf33=\E[>20;5~, kf34=\E[>21;5~, kf35=\E[>23;5~, kf36=\E[>24;5~, kf37=\E[>1;6P, kf38=\E[>1;6Q, kf39=\E[>1;6R, kf4=\EOS, kf40=\E[>1;6S, kf41=\E[>15;6~, kf42=\E[>17;6~, kf43=\E[>18;6~, kf44=\E[>19;6~, kf45=\E[>20;6~, kf46=\E[>21;6~, kf47=\E[>23;6~, kf48=\E[>24;6~, kf49=\E[>1;3P, kf5=\E[15~, kf50=\E[>1;3Q, kf51=\E[>1;3R, kf52=\E[>1;3S, kf53=\E[>15;3~, kf54=\E[>17;3~, kf55=\E[>18;3~, kf56=\E[>19;3~, kf57=\E[>20;3~, kf58=\E[>21;3~, kf59=\E[>23;3~, kf6=\E[17~, kf60=\E[>24;3~, kf61=\E[>1;4P, kf62=\E[>1;4Q, kf63=\E[>1;4R, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, # # The "PC-style" modifier scheme was introduced in xterm patch #94 (1999/3/27) # and revised in patch #167 (2002/8/24). # # The original assignments from patch #94 for cursor-keys had some technical # issues: # # A parameter for a function-key to represent a modifier is just more # bits. But for a cursor-key it may change the behavior of the # application. For instance, emacs decodes the first parameter of a # cursor-key as a repeat count. # # A parameterized string should (really) not begin with SS3 (\EO). # Rather, CSI (\E[) should be used. # # For these reasons, the original assignments were deprecated. For # compatibility reasons, they are still available as a setting of xterm's # modifyCursorKeys resource. These fragments list the modified cursor-keys # that might apply to xterm+pcfkeys with different values of that resource. xterm+pcc3|fragment with modifyCursorKeys:3, kLFT=\E[>1;2D, kRIT=\E[>1;2C, kind=\E[>1;2B, kri=\E[>1;2A, kDN=\E[>1;2B, kDN3=\E[>1;3B, kDN4=\E[>1;4B, kDN5=\E[>1;5B, kDN6=\E[>1;6B, kDN7=\E[>1;7B, kLFT3=\E[>1;3D, kLFT4=\E[>1;4D, kLFT5=\E[>1;5D, kLFT6=\E[>1;6D, kLFT7=\E[>1;7D, kRIT3=\E[>1;3C, kRIT4=\E[>1;4C, kRIT5=\E[>1;5C, kRIT6=\E[>1;6C, kRIT7=\E[>1;7C, kUP=\E[>1;2A, kUP3=\E[>1;3A, kUP4=\E[>1;4A, kUP5=\E[>1;5A, kUP6=\E[>1;6A, kUP7=\E[>1;7A, xterm+pcc2|fragment with modifyCursorKeys:2, kLFT=\E[1;2D, kRIT=\E[1;2C, kind=\E[1;2B, kri=\E[1;2A, kDN=\E[1;2B, kDN3=\E[1;3B, kDN4=\E[1;4B, kDN5=\E[1;5B, kDN6=\E[1;6B, kDN7=\E[1;7B, kLFT3=\E[1;3D, kLFT4=\E[1;4D, kLFT5=\E[1;5D, kLFT6=\E[1;6D, kLFT7=\E[1;7D, kRIT3=\E[1;3C, kRIT4=\E[1;4C, kRIT5=\E[1;5C, kRIT6=\E[1;6C, kRIT7=\E[1;7C, kUP=\E[1;2A, kUP3=\E[1;3A, kUP4=\E[1;4A, kUP5=\E[1;5A, kUP6=\E[1;6A, kUP7=\E[1;7A, xterm+pcc1|fragment with modifyCursorKeys:1, kLFT=\E[2D, kRIT=\E[2C, kind=\E[2B, kri=\E[2A, kDN=\E[2B, kDN3=\E[3B, kDN4=\E[4B, kDN5=\E[5B, kDN6=\E[6B, kDN7=\E[7B, kLFT3=\E[3D, kLFT4=\E[4D, kLFT5=\E[5D, kLFT6=\E[6D, kLFT7=\E[7D, kRIT3=\E[3C, kRIT4=\E[4C, kRIT5=\E[5C, kRIT6=\E[6C, kRIT7=\E[7C, kUP=\E[2A, kUP3=\E[3A, kUP4=\E[4A, kUP5=\E[5A, kUP6=\E[6A, kUP7=\E[7A, xterm+pcc0|fragment with modifyCursorKeys:0, kLFT=\EO2D, kRIT=\EO2C, kind=\EO2B, kri=\EO2A, kDN=\EO2B, kDN3=\EO3B, kDN4=\EO4B, kDN5=\EO5B, kDN6=\EO6B, kDN7=\EO7B, kLFT3=\EO3D, kLFT4=\EO4D, kLFT5=\EO5D, kLFT6=\EO6D, kLFT7=\EO7D, kRIT3=\EO3C, kRIT4=\EO4C, kRIT5=\EO5C, kRIT6=\EO6C, kRIT7=\EO7C, kUP=\EO2A, kUP3=\EO3A, kUP4=\EO4A, kUP5=\EO5A, kUP6=\EO6A, kUP7=\EO7A, # The home/end keys on the editing keypad are also treated as cursor keys. xterm+pce3|fragment with modifyCursorKeys:3, kDC=\E[>3;2~, kEND=\E[>1;2F, kHOM=\E[>1;2H, kIC=\E[>2;2~, kNXT=\E[>6;2~, kPRV=\E[>5;2~, kDC3=\E[>3;3~, kDC4=\E[>3;4~, kDC5=\E[>3;5~, kDC6=\E[>3;6~, kDC7=\E[>3;7~, kEND3=\E[>1;3F, kEND4=\E[>1;4F, kEND5=\E[>1;5F, kEND6=\E[>1;6F, kEND7=\E[>1;7F, kHOM3=\E[>1;3H, kHOM4=\E[>1;4H, kHOM5=\E[>1;5H, kHOM6=\E[>1;6H, kHOM7=\E[>1;7H, kIC3=\E[>2;3~, kIC4=\E[>2;4~, kIC5=\E[>2;5~, kIC6=\E[>2;6~, kIC7=\E[>2;7~, kNXT3=\E[>6;3~, kNXT4=\E[>6;4~, kNXT5=\E[>6;5~, kNXT6=\E[>6;6~, kNXT7=\E[>6;7~, kPRV3=\E[>5;3~, kPRV4=\E[>5;4~, kPRV5=\E[>5;5~, kPRV6=\E[>5;6~, kPRV7=\E[>5;7~, use=xterm+pce0, xterm+pce2|fragment with modifyCursorKeys:2, kDC=\E[3;2~, kEND=\E[1;2F, kHOM=\E[1;2H, kIC=\E[2;2~, kNXT=\E[6;2~, kPRV=\E[5;2~, kDC3=\E[3;3~, kDC4=\E[3;4~, kDC5=\E[3;5~, kDC6=\E[3;6~, kDC7=\E[3;7~, kEND3=\E[1;3F, kEND4=\E[1;4F, kEND5=\E[1;5F, kEND6=\E[1;6F, kEND7=\E[1;7F, kHOM3=\E[1;3H, kHOM4=\E[1;4H, kHOM5=\E[1;5H, kHOM6=\E[1;6H, kHOM7=\E[1;7H, kIC3=\E[2;3~, kIC4=\E[2;4~, kIC5=\E[2;5~, kIC6=\E[2;6~, kIC7=\E[2;7~, kNXT3=\E[6;3~, kNXT4=\E[6;4~, kNXT5=\E[6;5~, kNXT6=\E[6;6~, kNXT7=\E[6;7~, kPRV3=\E[5;3~, kPRV4=\E[5;4~, kPRV5=\E[5;5~, kPRV6=\E[5;6~, kPRV7=\E[5;7~, use=xterm+pce0, xterm+pce1|fragment with modifyCursorKeys:1, kDC=\E[3;2~, kEND=\E[2F, kHOM=\E[2H, kIC=\E[2;2~, kNXT=\E[6;2~, kPRV=\E[5;2~, kDC3=\E[3;3~, kDC4=\E[3;4~, kDC5=\E[3;5~, kDC6=\E[3;6~, kDC7=\E[3;7~, kEND3=\E[3F, kEND4=\E[4F, kEND5=\E[5F, kEND6=\E[6F, kEND7=\E[7F, kHOM3=\E[3H, kHOM4=\E[4H, kHOM5=\E[5H, kHOM6=\E[6H, kHOM7=\E[7H, kIC3=\E[2;3~, kIC4=\E[2;4~, kIC5=\E[2;5~, kIC6=\E[2;6~, kIC7=\E[2;7~, kNXT3=\E[6;3~, kNXT4=\E[6;4~, kNXT5=\E[6;5~, kNXT6=\E[6;6~, kNXT7=\E[6;7~, kPRV3=\E[5;3~, kPRV4=\E[5;4~, kPRV5=\E[5;5~, kPRV6=\E[5;6~, kPRV7=\E[5;7~, use=xterm+pce0, xterm+pce0|fragment with modifyCursorKeys:0, kDC=\E[3;2~, kEND=\EO2F, kHOM=\EO2H, kIC=\E[2;2~, kNXT=\E[6;2~, kPRV=\E[5;2~, kDC3=\E[3;3~, kDC4=\E[3;4~, kDC5=\E[3;5~, kDC6=\E[3;6~, kDC7=\E[3;7~, kEND3=\EO3F, kEND4=\EO4F, kEND5=\EO5F, kEND6=\EO6F, kEND7=\EO7F, kHOM3=\EO3H, kHOM4=\EO4H, kHOM5=\EO5H, kHOM6=\EO6H, kHOM7=\EO7H, kIC3=\E[2;3~, kIC4=\E[2;4~, kIC5=\E[2;5~, kIC6=\E[2;6~, kIC7=\E[2;7~, kNXT3=\E[6;3~, kNXT4=\E[6;4~, kNXT5=\E[6;5~, kNXT6=\E[6;6~, kNXT7=\E[6;7~, kPRV3=\E[5;3~, kPRV4=\E[5;4~, kPRV5=\E[5;5~, kPRV6=\E[5;6~, kPRV7=\E[5;7~, use=xterm+edit, ecma+strikeout|ECMA-48 strikeout/crossed-out, rmxx=\E[29m, smxx=\E[9m, # # This chunk is used for building the VT220/Sun/PC keyboard variants. xterm-basic|modern xterm terminal emulator - common, OTbs, am, bce, km, mc5i, mir, msgr, xenl, AX, XT, colors#8, cols#80, it#8, lines#24, pairs#64, acsc=``aaffggiijjkkllmmnnooppqqr rssttuuvvwwxxyyzz{{||}}~~, bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l, clear=\E[H\E[2J, cnorm=\E[?12l\E[?25h, cr=\r, csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, cvvis=\E[?12;25h, dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m, dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K, flash=\E[?5h$<100/>\E[?5l, home=\E[H, hpa=\E[%i%p1%dG, ht=^I, hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=\n, invis=\E[8m, is2=\E[!p\E[?3;4l\E[4l\E>, kmous=\E[M, mc0=\E[i, mc4=\E[4i, mc5=\E[5i, meml=\El, memu=\Em, op=\E[39;49m, rc=\E8, rev=\E[7m, ri=\EM, ritm=\E[23m, rmacs=\E(B, rmam=\E[?7l, rmcup=\E[?1049l, rmir=\E[4l, rmkx=\E[?1l\E>, rmm=\E[?1034l, rmso=\E[27m, rmul=\E[24m, rs1=\Ec, rs2=\E[!p\E[?3;4l\E[4l\E>, sc=\E7, setab=\E[4%p1%dm, setaf=\E[3%p1%dm, setb=\E[4 %? %p1%{1}%= %t4 %e %p1%{3}%= %t6 %e %p1%{4}%= %t1 %e %p1%{6}%= %t3 %e %p1%d %; m, setf=\E[3 %? %p1%{1}%= %t4 %e %p1%{3}%= %t6 %e %p1%{4}%= %t1 %e %p1%{6}%= %t3 %e %p1%d %; m, sgr= %? %p9 %t\E(0 %e \E(B %; \E[0 %? %p6 %t;1 %; %? %p5 %t;2 %; %? %p2 %t;4 %; %? %p1%p3%| %t;7 %; %? %p4 %t;5 %; %? %p7 %t;8 %; m, sgr0=\E(B\E[m, sitm=\E[3m, smacs=\E(0, smam=\E[?7h, smcup=\E[?1049h, smir=\E[4h, smkx=\E[?1h\E=, smm=\E[?1034h, smso=\E[7m, smul=\E[4m, tbc=\E[3g, u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?%[;0123456789]c, u9=\E[c, vpa=\E[%i%p1%dd, E3=\E[3J, use=xterm+kbs, # # The xterm-new description has all of the features, but is not completely # compatible with vt220. If you are using a Sun or PC keyboard, set the # sunKeyboard resource to true: # + maps the editing keypad # + interprets control-function-key as a second array of keys, so a # 12-fkey keyboard can support vt220's 20-fkeys. # + maps numeric keypad "+" to ",". # + uses DEC-style control sequences for the application keypad. # # Some packagers modify xterm's resource definitions to provide extra function # keys by using the shift-modifier in the translations resource. However, that # interferes with the DECUDK functionality. # xterm-vt220|xterm emulating vt220, ka1=\EOw, ka3=\EOy, kb2=\EOu, kc1=\EOq, kc3=\EOs, kcbt=\E[Z, kend=\E[4~, kent=\EOM, kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf2=\EOQ, kf20=\E[34~, kf3=\EOR, kf4=\EOS, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khome=\E[1~, kich1=\E[2~, knp=\E[6~, kpp=\E[5~, ka2=\EOx, kb1=\EOt, kb3=\EOv, kc2=\EOr, use=xterm+app, use=xterm+edit, use=xterm-basic, # xterm-vt52|xterm emulating dec vt52, cols#80, it#8, lines#24, acsc=``aaffggjjkkllmmnnooppqqrrs sttuuvvwwxxyyzz{{||}}~~, bel=^G, clear=\EH\EJ, cr=\r, cub1=\ED, cud1=\EB, cuf1=\EC, cup=\EY%p1%'\s'%+%c%p2%'\s'%+%c, cuu1=\EA, ed=\EJ, el=\EK, home=\EH, ht=^I, ind=\n, kcub1=\ED, kcud1=\EB, kcuf1=\EC, kcuu1=\EA, nel=\r\n, ri=\EI, rmacs=\EG, smacs=\EF, use=xterm+kbs, # # Sun does not number the function keys this way in their sparse termcap; their # terminal descriptions ignore the keypads. kb(7M) states that there are codes # reserved for 64 function keys, 16 each in left, right, top and bottom. Each # keyboard type has a different number of function keys in different # arrangements. Using xkeycaps for reference: # # Type 3: left 10, top 9, right 15 # ------ # kf1-kf9 are XK_F1-XK_F9 # There is no kf10 on this keyboard type. # kf11-kf20 are keysyms XK_L1 through XK_L10. # kf31-kf45 are keysyms XK_R1 through XK_R15. # # However, X's keysymdef.h is hard-coded to make # XK_L1==XK_F11 and # XK_R1==XK_F21, # by someone who was unfamiliar with terminal types other than Sun's. So # xterm uses the internal X keysymbols, but the terminfo entry uses the Sun # numbering scheme. # # Type 4: left 11, top 12, right 15 # ------ # The left-keypad contains an unnumbered Help-key. # The right-keypad also contains NumLock, Ins, Del, Enter, + and - keys which # do not appear to be part of the R-sequence. # # Type 5: left 9, top 12, right (more than one keypad) # ------ # These keyboards do not use the same naming convention, look like a hybrid of # the type 4 and IBM keyboards. # # XTerm resources: # --------------- # Set the modifyFunctionKeys resource to negative (-1) to make it simple to # enter the higher function-key values using shift- and control-modifiers. # xterm-sun|xterm with sun function keys, kb2=\E[218z, kcpy=\E[197z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kdch1=\E[3z, kend=\E[220z, kent=\EOM, kf1=\E[224z, kf10=\E[233z, kf11=\E[192z, kf12=\E[193z, kf13=\E[194z, kf14=\E[195z, kf15=\E[196z, kf17=\E[198z, kf18=\E[199z, kf19=\E[200z, kf2=\E[225z, kf20=\E[201z, kf3=\E[226z, kf31=\E[208z, kf32=\E[209z, kf33=\E[210z, kf34=\E[211z, kf35=\E[212z, kf36=\E[213z, kf38=\E[215z, kf4=\E[227z, kf40=\E[217z, kf42=\E[219z, kf44=\E[221z, kf45=\E[222z, kf46=\E[234z, kf47=\E[235z, kf5=\E[228z, kf6=\E[229z, kf7=\E[230z, kf8=\E[231z, kf9=\E[232z, kfnd=\E[200z, khlp=\E[196z, khome=\E[214z, kich1=\E[2z, knp=\E[222z, kpp=\E[216z, kund=\E[195z, use=xterm-basic, # xterm-hp|xterm with hpterm function keys, kclr=\EJ, kcub1=\ED, kcud1=\EB, kcuf1=\EC, kcuu1=\EA, kdch1=\EP, kend=\EF, kf1=\Ep, kf2=\Eq, kf3=\Er, kf4=\Es, kf5=\Et, kf6=\Eu, kf7=\Ev, kf8=\Ew, khome=\Eh, kich1=\EQ, knp=\ES, kpp=\ET, use=xterm-basic, # # scoterm implements 48 function-keys using shift- and control-modifiers to # multiple 12 function-keys. X has a hard-coded limit of 35 function-keys, # but xterm can represent larger values. # # XTerm resources: # --------------- # Set the modifyFunctionKeys resource to negative (-1) to make it simple to # enter the higher function-key values using shift- and control-modifiers. # # Also, set ctrlFKeys resource to 12 (the default is 10) to make xterm see 48 # function-keys on a keyboard with 12 function-keys and 4 control/shift # modifier combinations. # xterm-sco|xterm with SCO function keys, kbeg=\E[E, kdch1=^?, kf1=\E[M, kf10=\E[V, kf11=\E[W, kf12=\E[X, kf13=\E[Y, kf14=\E[Z, kf15=\E[a, kf16=\E[b, kf17=\E[c, kf18=\E[d, kf19=\E[e, kf2=\E[N, kf20=\E[f, kf21=\E[g, kf22=\E[h, kf23=\E[i, kf24=\E[j, kf25=\E[k, kf26=\E[l, kf27=\E[m, kf28=\E[n, kf29=\E[o, kf3=\E[O, kf30=\E[p, kf31=\E[q, kf32=\E[r, kf33=\E[s, kf34=\E[t, kf35=\E[u, kf36=\E[v, kf37=\E[w, kf38=\E[x, kf39=\E[y, kf4=\E[P, kf40=\E[z, kf41=\E[@, kf42=\E[[, kf43=\E[\\, kf44=\E[], kf45=\E[\^, kf46=\E[_, kf47=\E[`, kf48=\E[{, kf5=\E[Q, kf6=\E[R, kf7=\E[S, kf8=\E[T, kf9=\E[U, kich1=\E[L, kmous=\E[>M, knp=\E[G, kpp=\E[I, use=xterm+noapp, use=xterm-basic, # # Other variants (these are all very old entries, from X11R5): xterm-24|xterms|vs100|xterm terminal emulator (X Window System), lines#24, use=xterm-old, xterm-65|xterm with tall window 65x80 (X Window System), lines#65, use=xterm-old, xterm-bold|xterm with bold instead of underline (X Window System), sgr= %? %p9 %t\016 %e \017 %; B\E[0 %? %p6 %t;1 %; %? %p2 %t;1 %; %? %p1%p3%| %t;7 %; m, smso=\E[7m, smul=\E[1m, use=xterm-old, xterm-boldso|xterm with bold for standout (X Window System), rmso=\E[m, smso=\E[1m, use=xterm-old, xterm-mono|monochrome xterm, bce@, colors@, ncv@, pairs@, op@, setab@, setaf@, setb@, setf@, sgr@, use=xterm-old, # # VTxxx terminals are usually set up so that full-screen applications will use # the cursor application mode strings. This is good for full-screen # applications, including legacy applications which may have hard-coded # behavior, but bad for interactive shells (e.g., tcsh, bash) which use arrow # keys to scroll through a history of command strings. # # To see the difference between normal/application modes, consider this example: # + In normal (non-application) mode, the terminal transmits a down-arrow # as \E[C, which happens to echo as a down-arrow. # + In application mode the terminal transmits \EOC, which echoes as C. # That is because the \EO is the SS3 control, which says to use the # character from the G3 character set for the next cell. # # One example of hard-coded behavior would be for applications written to work # with VT52 and VT100 terminals. If the application's parser ignores 'O' and # '?' characters after the escape, then the cursor and keypad strings for the # two terminals are the same. (Indeed, one of the first curses applications # which I used did something like this to cover "ANSI" terminals -TD). # # To make this work (leaving the cursor keys in normal mode), we have to adjust # the terminal initialization sequences: # # smkx/rmkx set/reset the cursor and keypad application modes. We retain # the latter (otherwise many applications fail). # # smcup/rmcup set/restore cursor-addressing mode for full-screen # applications. For xterm, this normally means the alternate # screen, which is not compatible with interactive shells. Some # programs are "smart" and disable these. # xterm-noapp|xterm with cursor keys in normal mode, rmcup@, rmkx=\E>, smcup@, smkx=\E=, use=xterm+noapp, use=xterm, xterm+noapp|fragment with cursor keys in normal mode, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, use=xterm+noapp+pc, xterm+app|fragment with cursor keys in application mode, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, use=xterm+app+pc, xterm+noapp+pc|fragment for noapp pc-style home/end, kend=\E[F, khome=\E[H, xterm+app+pc|fragment for app pc-style home/end, kend=\EOF, khome=\EOH, xterm+edit|fragment for 6-key editing-keypad, kdch1=\E[3~, kich1=\E[2~, knp=\E[6~, kpp=\E[5~, use=xterm+pc+edit, xterm+decedit|fragment for vt220 6-key editing-keypad, kdch1=\E[3~, kich1=\E[2~, knp=\E[6~, kpp=\E[5~, use=xterm+vt+edit, xterm+pc+edit|fragment for pc-style editing keypad, kend=\E[4~, khome=\E[1~, xterm+vt+edit|fragment for vt220-style editing keypad, kfnd=\E[1~, kslt=\E[4~, # # This should work for the commonly used "color xterm" variations (XFree86 # xterm, color_xterm, nxterm, rxvt). Note that it does not set 'bce', so for # XFree86 and and rxvt, some applications that use colors will be less # efficient, and in a few special cases (with "smart" optimization) the wrong # color will be painted in spots. xterm-color|generic "ANSI" color xterm (X Window System), colors#8, ncv@, pairs#64, op=\E[m, setab=\E[4%p1%dm, setaf=\E[3%p1%dm, use=xterm-r6, # # vi may work better with this entry, because vi # doesn't use insert mode much xterm-ic|xterm-vi|xterm with insert character instead of insert mode, mir@, ich=\E[%p1%d@, ich1=\E[@, rmir@, smir@, use=xterm, # # This is used only for testing (it's not relevant to DEC VTxxx terminals, but # to ncurses). xterm-xmc|xterm with magic-cookie glitch, xmc#1, use=xterm-new, # # This one also is primarily for testing ncurses; while the ISO 6429 defines # the REP control, none of the DEC VTxxx terminals (VT52 through VT420) support # it. xterm-rep|xterm with repeat-character control, rep=%p1%c\E[%p2%{1}%-%db, use=xterm-new, # # This is mainly for testing xterm; the real VT220 will not let you switch # character sets without first altering the keyboard language in the setup # screen. Some emulators allow this anyway. (Note that these strings are # normally used only for printers). The parameter to csnm and scs is the same # in both cases: the keyboard language parameter returned by CSI ? 2 6 n. xterm-nrc|xterm with VT220 national replacement character sets, csnm= %? %p1%{1}%= %tNorth\sAmerican %e %p1%{2}%= %tBritish %e %p1%{3}%= %tFlemish %e %p1%{4}%= %tFrench\sCanadian %e %p1%{5}%= %tDanish %e %p1%{6}%= %tFinnish %e %p1%{7}%= %tGerman %e %p1%{8}%= %tDutch %e %p1%{9}%= %tItalian %e %p1%{10}%= %tSwiss\s(French) %e %p1%{11}%= %tSwiss\s(German) %e %p1%{12}%= %tSwedish %e %p1%{13}%= %tNorwegian %e %p1%{14}%= %tFrench/Belgian %e %p1%{15}%= %tSpanish %;, scs= %? %p1%{1}%= %t\E(B %e %p1%{2}%= %t\E(A %e %p1%{3}%= %t\E(R %e %p1%{4}%= %t\E(9 %e %p1%{5}%= %t\E(E %e %p1%{6}%= %t\E(5 %e %p1%{7}%= %t\E(K %e %p1%{8}%= %t\E(4 %e %p1%{9}%= %t\E(Y %e %p1%{10}%= %t\E(= %e %p1%{11}%= %t\E(= %e %p1%{12}%= %t\E(7 %e %p1%{13}%= %t\E(E %e %p1%{14}%= %t\E(R %e %p1%{15}%= %t\E(Z %;, use=xterm-new, # # Foreground 0-15 maps (with toggles) into 30-37 & 90-97 # Background 0-15 maps (with toggles) into 40-47 & 100-107 # # Originally I suppressed setaf/setab, since ANSI specifies only 8 colors, but # Stephen Marley persuaded me to allow the "ANSI" color controls to extend to # 16 colors. (Note that ncurses 4.2 uses setf/setb from this description; # however 5.0 selects either according to their availability). - T.Dickey # # SVr4 curses does not use more than 8 colors anyway, so using 16 colors is # either for terminfo-level applications or via ncurses. xterm-16color|xterm with 16 colors, colors#16, pairs#0x100, setab=\E[ %? %p1%{8}%< %t%p1%{40}%+ %e %p1%{92}%+ %; %dm, setaf=\E[ %? %p1%{8}%< %t%p1%{30}%+ %e %p1%{82}%+ %; %dm, setb= %p1%{8}%/%{6}%*%{4}%+\E[%d%p1%{8}%m%Pa %?%ga%{1}%= %t4 %e%ga%{3}%= %t6 %e%ga%{4}%= %t1 %e%ga%{6}%= %t3 %e%ga%d %; m, setf= %p1%{8}%/%{6}%*%{3}%+\E[%d%p1%{8}%m%Pa %?%ga%{1}%= %t4 %e%ga%{3}%= %t6 %e%ga%{4}%= %t1 %e%ga%{6}%= %t3 %e%ga%d %; m, use=xterm+256color, use=xterm-new, # # This uses RGB values 0..1000 # # 256 colors should give 65536 pairs, but terminfo stores numbers in a signed # short. Most people will not notice problems with only 32767 pairs. xterm+256color|xterm 256-color feature, ccc, colors#0x100, pairs#0x7fff, initc=\E]4; %p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\, oc=\E]104\007, rs1=\Ec\E]104\007, setab=\E[ %? %p1%{8}%< %t4%p1%d %e %p1%{16}%< %t10%p1%{8}%-%d %e48;5; %p1%d %; m, setaf=\E[ %? %p1%{8}%< %t3%p1%d %e %p1%{16}%< %t9%p1%{8}%-%d %e38;5; %p1%d %; m, setb@, setf@, xterm-256color|xterm with 256 colors, use=xterm+256color, use=xterm-new, xterm-88color|xterm with 88 colors, colors#88, pairs#7744, use=xterm-256color, # # This is an 8-bit version of xterm, which emulates DEC vt220 with ANSI color. # To use it, your decTerminalID resource must be set to 200 or above, and the # sunKeyboard resource set to true. # # HTS \E H \210 # RI \E M \215 # SS3 \E O \217 # CSI \E [ \233 # xterm-8bit|xterm terminal emulator with 8-bit controls (X Window System), OTbs, am, bce, km, mc5i, mir, msgr, npc, xenl, AX, colors#8, cols#80, it#8, lines#24, pairs#64, acsc=``aaffggiijjkkllmmnnooppqqr rssttuuvvwwxxyyzz{{||}}~~, bel=^G, blink=\2335m, bold=\2331m, cbt=\233Z, civis=\233?25l, clear=\233H\2332J, cnorm=\233?25l\233?25h, cr=\r, csr=\233%i%p1%d;%p2%dr, cub=\233%p1%dD, cub1=^H, cud=\233%p1%dB, cud1=\n, cuf=\233%p1%dC, cuf1=\233C, cup=\233%i%p1%d;%p2%dH, cuu=\233%p1%dA, cuu1=\233A, cvvis=\233?12;25h, dch=\233%p1%dP, dch1=\233P, dl=\233%p1%dM, dl1=\233M, ech=\233%p1%dX, ed=\233J, el=\233K, el1=\2331K, flash=\233?5h$<100/>\233?5l, home=\233H, hpa=\233%i%p1%dG, ht=^I, hts=\210, ich=\233%p1%d@, il=\233%p1%dL, il1=\233L, ind=\n, invis=\2338m, is2=\E[62"p\E\sG\233m\233?7h\E> \E7\233?1;3;4;6l\2334l\233r \E8, ka1=\217w, ka3=\217u, kb2=\217y, kbeg=\217E, kc1=\217q, kc3=\217s, kcbt=\233Z, kcub1=\217D, kcud1=\217B, kcuf1=\217C, kcuu1=\217A, kdch1=\2333~, kend=\2334~, kent=\217M, kf1=\23311~, kf10=\23321~, kf11=\23323~, kf12=\23324~, kf13=\23325~, kf14=\23326~, kf15=\23328~, kf16=\23329~, kf17=\23331~, kf18=\23332~, kf19=\23333~, kf2=\23312~, kf20=\23334~, kf3=\23313~, kf4=\23314~, kf5=\23315~, kf6=\23317~, kf7=\23318~, kf8=\23319~, kf9=\23320~, khome=\2331~, kich1=\2332~, kmous=\233M, knp=\2336~, kpp=\2335~, mc0=\233i, mc4=\2334i, mc5=\2335i, meml=\El, memu=\Em, op=\23339;49m, rc=\E8, rev=\2337m, ri=\215, rmacs=\E(B, rmam=\233?7l, rmcup=\233?1049l, rmir=\2334l, rmkx=\233?1l\E>, rmso=\23327m, rmul=\23324m, rs1=\Ec, rs2=\E[62"p\E\sG\233m\233?7h\E> \E7\233?1;3;4;6l\2334l\233r \E8, sc=\E7, setab=\2334%p1%dm, setaf=\2333%p1%dm, setb=\2334 %? %p1%{1}%= %t4 %e %p1%{3}%= %t6 %e %p1%{4}%= %t1 %e %p1%{6}%= %t3 %e %p1%d %; m, setf=\2333 %? %p1%{1}%= %t4 %e %p1%{3}%= %t6 %e %p1%{4}%= %t1 %e %p1%{6}%= %t3 %e %p1%d %; m, sgr=\2330 %? %p6 %t;1 %; %? %p2 %t;4 %; %? %p1%p3%| %t;7 %; %? %p4 %t;5 %; %? %p7 %t;8 %; m %? %p9 %t\E(0 %e \E(B %;, sgr0=\2330m\E(B, smacs=\E(0, smam=\233?7h, smcup=\233?1049h, smir=\2334h, smkx=\233?1h\E=, smso=\2337m, smul=\2334m, tbc=\2333g, u6=\233[%i%d;%dR, u7=\E[6n, u8=\233[?%[;0123456789]c, u9=\E[c, vpa=\233%i%p1%dd, use=xterm+kbs, # xterm-xf86-v44|xterm terminal emulator (XFree86 4.4 Window System), OTbs, am, bce, km, mc5i, mir, msgr, npc, xenl, AX, XT, colors#8, cols#80, it#8, lines#24, pairs#64, acsc=``aaffggiijjkkllmmnnooppqqr rssttuuvvwwxxyyzz{{||}}~~, bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l, clear=\E[H\E[2J, cnorm=\E[?12l\E[?25h, cr=\r, csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, cvvis=\E[?12;25h, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K, enacs=\E(B\E)0, flash=\E[?5h$<100/>\E[?5l, home=\E[H, hpa=\E[%i%p1%dG, ht=^I, hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=\n, indn=\E[%p1%dS, invis=\E[8m, is2=\E[!p\E[?3;4l\E[4l\E>, kDC=\E[3;2~, kEND=\E[1;2F, kHOM=\E[1;2H, kIC=\E[2;2~, kLFT=\E[1;2D, kNXT=\E[6;2~, kPRV=\E[5;2~, kRIT=\E[1;2C, kb2=\EOE, kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kdch1=\E[3~, kend=\EOF, kent=\EOM, kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\EO2P, kf14=\EO2Q, kf15=\EO2R, kf16=\EO2S, kf17=\E[15;2~, kf18=\E[17;2~, kf19=\E[18;2~, kf2=\EOQ, kf20=\E[19;2~, kf21=\E[20;2~, kf22=\E[21;2~, kf23=\E[23;2~, kf24=\E[24;2~, kf25=\EO5P, kf26=\EO5Q, kf27=\EO5R, kf28=\EO5S, kf29=\E[15;5~, kf3=\EOR, kf30=\E[17;5~, kf31=\E[18;5~, kf32=\E[19;5~, kf33=\E[20;5~, kf34=\E[21;5~, kf35=\E[23;5~, kf36=\E[24;5~, kf37=\EO6P, kf38=\EO6Q, kf39=\EO6R, kf4=\EOS, kf40=\EO6S, kf41=\E[15;6~, kf42=\E[17;6~, kf43=\E[18;6~, kf44=\E[19;6~, kf45=\E[20;6~, kf46=\E[21;6~, kf47=\E[23;6~, kf48=\E[24;6~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khome=\EOH, kich1=\E[2~, kmous=\E[M, knp=\E[6~, kpp=\E[5~, mc0=\E[i, mc4=\E[4i, mc5=\E[5i, meml=\El, memu=\Em, op=\E[39;49m, rc=\E8, rev=\E[7m, ri=\EM, rin=\E[%p1%dT, rmacs=^O, rmam=\E[?7l, rmcup=\E[?1049l, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[27m, rmul=\E[24m, rs1=\Ec, rs2=\E[!p\E[?3;4l\E[4l\E>, sc=\E7, setab=\E[4%p1%dm, setaf=\E[3%p1%dm, setb=\E[4 %? %p1%{1}%= %t4 %e %p1%{3}%= %t6 %e %p1%{4}%= %t1 %e %p1%{6}%= %t3 %e %p1%d %; m, setf=\E[3 %? %p1%{1}%= %t4 %e %p1%{3}%= %t6 %e %p1%{4}%= %t1 %e %p1%{6}%= %t3 %e %p1%d %; m, sgr=\E[0 %? %p6 %t;1 %; %? %p2 %t;4 %; %? %p1%p3%| %t;7 %; %? %p4 %t;5 %; %? %p7 %t;8 %; m %? %p9 %t\016 %e \017 %;, sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smcup=\E[?1049h, smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g, u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?1;2c, u9=\E[c, vpa=\E[%i%p1%dd, ka2=\EOx, kb1=\EOt, kb3=\EOv, kc2=\EOr, use=xterm+kbs, xterm-xfree86|xterm terminal emulator (XFree86 4.4 Window System), use=xterm-xf86-v44, # # Compatible with the R6 xterm, with the following changes: # + added acsc (perhaps some versions of tic assume the standard vt100 # alternate character set) # + added u6, u7, u8, u9 strings for Daniel Weaver's tack program. # + added kmous string for ncurses. # + added khome/kend strings (which conflict with kfnd/kslt, see note). xterm-r6|xterm X11R6 version, OTbs, am, km, mir, msgr, xenl, cols#80, it#8, lines#24, acsc=``aaffggiijjkkllmmnnooppqqr rssttuuvvwwxxyyzz{{||}}~~, bel=^G, bold=\E[1m, clear=\E[H\E[2J, cr=\r, csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, enacs=\E)0, home=\E[H, ht=^I, hts=\EH, il=\E[%p1%dL, il1=\E[L, ind=\n, is2=\E[m\E[?7h\E[4l\E>\E7\E[r\E[ ?1;3;4;6l\E8, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kdch1=\E[3~, kf1=\E[11~, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf2=\E[12~, kf20=\E[34~, kf3=\E[13~, kf4=\E[14~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, kmous=\E[M, meml=\El, memu=\Em, rc=\E8, rev=\E[7m, ri=\EM, rmacs=^O, rmcup=\E[2J\E[?47l\E8, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[m, rmul=\E[m, rs2=\E[m\E[?7h\E[4l\E>\E7\E[r\E[ ?1;3;4;6l\E8, sc=\E7, sgr0=\E[m, smacs=^N, smcup=\E7\E[?47h, smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g, u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?1;2c, u9=\E[c, use=xterm+kbs, use=xterm+decedit, xterm-old|antique xterm version, use=xterm-r6, # # Compatible with the R5 xterm, with the following changes: # + changed 'blink=@', to 'blink@' (the former meant that "@" would start # a blink, the latter that it is not supported). # + changed kf1 through kf4 to correspond with actual usage. Though X # supports keypad symbols for PF1 to PF4, and xterm interprets these # correctly, the F1 to F4 codes are commonly (but incorrectly) used. # + moved reset string from rs1 to rs2, to correlate better with termcap. # + make khome consistent with other entries. # + use rmul/smul, rmir/smir from termcap, but not rmcup/smcup because # not everyone wants the alternate screen. # + added u6, u7, u8, u9 strings for Daniel Weaver's tack program. # + added kmous string for ncurses. xterm-r5|xterm R5 version, OTbs, am, km, msgr, xenl, cols#80, it#8, lines#24, bel=^G, bold=\E[1m, clear=\E[H\E[2J, cr=\r, csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL, il1=\E[L, ind=\n, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kdch1=\E[3~, kdl1=\E[31~, kel=\E[8~, kend=\E[4~, kf0=\EOq, kf1=\E[11~, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf2=\E[12~, kf3=\E[13~, kf4=\E[14~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khome=\E[1~, kich1=\E[2~, kil1=\E[30~, kmous=\E[M, knp=\E[6~, kpp=\E[5~, rc=\E8, rev=\E[7m, ri=\EM, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[m, rmul=\E[m, rs2=\E>\E[?1;3;4;5;6l\E[4l\E[?7h \E[m\E[r\E[2J\E[H, sc=\E7, sgr=\E[ %? %p1 %t;7 %; %? %p2 %t;4 %; %? %p3 %t;7 %; %? %p4 %t;5 %; %? %p6 %t;1 %; m, sgr0=\E[m, smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g, u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?1;2c, u9=\E[c, use=xterm+kbs, # # # Customization begins here. # # This is the only entry which you should have to customize, since "xterm" # is widely used for a variety of incompatible terminal emulations including # color_xterm and rxvt. xterm|X11 terminal emulator, use=xterm-new, # use=xterm-r6, # This fragment is for people who cannot agree on what the backspace key # should send. xterm+kbs|fragment for backspace key, kbs=^H, # kbs=^?, xterm-330/charclass.h0000644000175100001440000000104113113033326013342 0ustar tomusers/* $XTermId: charclass.h,v 1.7 2017/05/29 14:57:26 tom Exp $ */ /* $XFree86: xc/programs/xterm/charclass.h,v 1.3 2006/02/13 01:14:58 dickey Exp $ */ #ifndef CHARCLASS_H #define CHARCLASS_H extern void init_classtab(void); /* intialise the table. needs calling before either of the others. */ extern int SetCharacterClassRange(int low, int high, int value); extern int CharacterClass(int c); #if OPT_REPORT_CCLASS extern void report_wide_char_class(void); #endif #ifdef NO_LEAKS extern void noleaks_CharacterClass(void); #endif #endif xterm-330/html.c0000644000175100001440000002211513113234017012343 0ustar tomusers/* $XTermId: html.c,v 1.6 2017/05/30 09:14:55 tom Exp $ */ /* * Copyright 2015 Jens Schweikhardt * * All Rights Reserved * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * Except as contained in this notice, the name(s) of the above copyright * holders shall not be used in advertising or otherwise to promote the sale, * use or other dealings in this Software without prior written * authorization. */ #include #include #define NO_COLOR ((unsigned)-1) #define RGBPCT(c) c.red / 655.35, c.green / 655.35, c.blue / 655.35 #define DUMP_PREFIX "xterm" #define DUMP_SUFFIX ".xhtml" #define DEFAULTNAME DUMP_PREFIX DUMP_SUFFIX #ifdef VMS #define VMS_HTML_FILE "sys$scratch:" DEFAULTNAME #endif static void dumpHtmlHeader(XtermWidget xw, FILE *fp); static void dumpHtmlScreen(XtermWidget xw, FILE *fp); static void dumpHtmlLine(XtermWidget xw, int row, FILE *fp); static void dumpHtmlFooter(XtermWidget, FILE *fp); static void writeStyle(XtermWidget, FILE *fp); char *PixelToCSSColor(XtermWidget xw, Pixel p); void xtermDumpHtml(XtermWidget xw) { FILE *fp; TRACE(("xtermDumpHtml...\n")); #ifdef VMS fp = fopen(VMS_HTML_FILE, "wb"); #elif defined(HAVE_STRFTIME) { char fname[sizeof(DEFAULTNAME) + LEN_TIMESTAMP]; time_t now; struct tm *ltm; now = time((time_t *) 0); ltm = localtime(&now); if (strftime(fname, sizeof fname, DUMP_PREFIX FMT_TIMESTAMP DUMP_SUFFIX, ltm) > 0) { fp = fopen(fname, "wb"); } else { fp = fopen(DEFAULTNAME, "wb"); } } #else fp = fopen(DEFAULTNAME, "wb"); #endif if (fp != 0) { dumpHtmlHeader(xw, fp); dumpHtmlScreen(xw, fp); dumpHtmlFooter(xw, fp); fclose(fp); } TRACE(("...xtermDumpHtml done\n")); } static void dumpHtmlHeader(XtermWidget xw, FILE *fp) { fputs("\n", fp); fputs("]>\n", fp); fputs("\n", fp); fputs(" \n", fp); fprintf(fp, " \n", xtermVersion()); fputs(" \n", fp); fputs(" \n", fp); fputs(" Xterm\n", fp); writeStyle(xw, fp); fputs(" \n", fp); fputs(" \n", fp); fputs("
\n", fp); fputs("
", fp);
}

static void
writeStyle(XtermWidget xw, FILE *fp)
{
    TScreen *s = TScreenOf(xw);

    fputs("  \n", fp);
}

static void
dumpHtmlScreen(XtermWidget xw, FILE *fp)
{
    TScreen *s = TScreenOf(xw);
    int row;

    for (row = s->top_marg; row <= s->bot_marg; ++row) {
	dumpHtmlLine(xw, row, fp);
    }
}

/*
 * Note: initial and final space around values of class and style
 *       attribute are deliberate. They make it easier for XPath
 *       to test whether a particular name is among the attributes.
 *       It allows expressions such as
 *           [contains(@class, ' ul ')]
 *       instead of the unwieldy
 *           [contains(concat(' ', @class, ' '), ' ul ')]
 *       The ev and od (for even and odd rows) values
 *       avoid empty values when going back to old fg/bg.
 */
static void
dumpHtmlLine(XtermWidget xw, int row, FILE *fp)
{
    TScreen *s = TScreenOf(xw);
    char attrs[2][sizeof
		  ""];
    int attr_index = 0;
    char *attr = &attrs[attr_index][0];
    int inx = ROW2INX(s, row);
    LineData *ld = getLineData(s, inx);
    int col;

    if (ld == 0)
	return;

    for (col = 0; col < MaxCols(s); col++) {
	XColor fgcolor, bgcolor;
	IChar chr = ld->charData[col];
	int slen = 0;

	fgcolor.pixel = xw->old_foreground;
	bgcolor.pixel = xw->old_background;
#if OPT_ISO_COLORS
	if (ld->attribs[col] & FG_COLOR) {
	    unsigned fg = extract_fg(xw, ld->color[col], ld->attribs[col]);
	    fgcolor.pixel = s->Acolors[fg].value;
	}
	if (ld->attribs[col] & BG_COLOR) {
	    unsigned bg = extract_bg(xw, ld->color[col], ld->attribs[col]);
	    bgcolor.pixel = s->Acolors[bg].value;
	}
#endif

	XQueryColor(xw->screen.display, xw->core.colormap, &fgcolor);
	XQueryColor(xw->screen.display, xw->core.colormap, &bgcolor);
	if (ld->attribs[col] & BLINK) {
	    /* White on red. */
	    fgcolor.red = fgcolor.green = fgcolor.blue = 65535u;
	    bgcolor.red = 65535u;
	    bgcolor.green = bgcolor.blue = 0u;
	}
#if OPT_WIDE_ATTRS
	if (ld->attribs[col] & ATR_FAINT) {
	    fgcolor.red = (unsigned short) ((2 * fgcolor.red) / 3);
	    fgcolor.green = (unsigned short) ((2 * fgcolor.green) / 3);
	    fgcolor.blue = (unsigned short) ((2 * fgcolor.blue) / 3);
	}
#endif
	if (ld->attribs[col] & INVERSE) {
	    XColor tmp = fgcolor;
	    fgcolor = bgcolor;
	    bgcolor = tmp;
	}

	slen = sprintf(attr + slen, "", RGBPCT(bgcolor));
	if (col == 0) {
	    fputs(attr, fp);
	    attr = &attrs[attr_index ^= 1][0];
	} else {
	    if (strcmp(&attrs[0][0], &attrs[1][0])) {
		fputs("", fp);
		fputs(attr, fp);
		attr = &attrs[attr_index ^= 1][0];
	    }
	}

#if OPT_WIDE_CHARS
	if (chr > 127) {
	    /* Ignore hidden characters. */
	    if (chr != HIDDEN_CHAR) {
		Char temp[10];
		*convertToUTF8(temp, chr) = 0;
		fputs((char *) temp, fp);
	    }
	} else
#endif
	    switch (chr) {
	    case 0:
		/* This sometimes happens when resizing... ignore. */
		break;
	    case '&':
		fputs("&", fp);
		break;
	    case '<':
		fputs("<", fp);
		break;
	    case '>':
		fputs(">", fp);
		break;
	    case ' ':
		fputs("&s;", fp);
		break;
	    default:
		fputc((int) chr, fp);
	    }
    }
    fprintf(fp, "\n");
}

static void
dumpHtmlFooter(XtermWidget xw GCC_UNUSED, FILE *fp)
{
    fputs("
\n", fp); fputs("
\n", fp); fputs(" \n", fp); fputs("\n", fp); } char * PixelToCSSColor(XtermWidget xw, Pixel p) { static char rgb[sizeof "rgb(100.00%, 100.00%, 100.00%)"]; XColor c; c.pixel = p; XQueryColor(xw->screen.display, xw->core.colormap, &c); sprintf(rgb, "rgb(%.2f%%, %.2f%%, %.2f%%)", RGBPCT(c)); return rgb; } /* vim: set ts=8 sw=4 et: */ xterm-330/uxterm0000755000175100001440000000713210735744140012521 0ustar tomusers#!/bin/sh # $XTermId: uxterm,v 1.26 2007/12/30 16:33:36 tom Exp $ # ----------------------------------------------------------------------------- # this file is part of xterm # # Copyright 2001-2006,2007 by Thomas E. Dickey # # All Rights Reserved # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name(s) of the above copyright # holders shall not be used in advertising or otherwise to promote the # sale, use or other dealings in this Software without prior written # authorization. # ----------------------------------------------------------------------------- # # wrapper script to setup xterm with UTF-8 locale whoami=uxterm : ${XTERM_PROGRAM=xterm} # Check if there is a workable locale program. If there is not, we will read # something via the standard error. Ignore whatever is written to the # standard output. locale=`sh -c "LC_ALL=C LC_CTYPE=C LANG=C locale >/dev/null" 2>&1` found=no # Check for -version and -help options, to provide a simple return without # requiring the program to create a window: if test $# = 1 then case $1 in -v|-ver*|-h|-he*) $XTERM_PROGRAM "$@" exit $? ;; esac fi # Check environment variables that xterm does, in the same order: for name in LC_ALL LC_CTYPE LANG do eval 'value=$'$name if test -n "$value" ; then case $value in *.utf8|*.UTF8|*.utf-8|*.UTF-8) found=yes ;; *.utf8@*|*.UTF8@*|*.utf-8@*|*.UTF-8@*) found=yes ;; C|POSIX) # Yes, I know this is not the same - but why are you # here then? value=en_US ;; esac break fi done # If we didn't find one that used UTF-8, modify the safest one. Not everyone # has a UTF-8 locale installed (and there appears to be no trivial/portable way # to determine whether it is, from a shell script). We could check if the # user's shell does not reset unknown locale specifiers, but not all shells do. if test $found != yes ; then if test -n "$value" ; then value=`echo ${value} |sed -e 's/[.@].*//'`.UTF-8 else name="LC_CTYPE" value="en_US.UTF-8" fi eval save=\$${name} eval ${name}=${value} eval export ${name} if test -z "$locale" ; then # The 'locale' program tries to do a sanity check. check=`sh -c "locale >/dev/null" 2>&1` if test -n "$check" ; then eval ${name}=${save} eval export ${name} echo "$whoami tried to use locale $value by setting \$$name" >&2 xmessage -file - < #if OPT_GRAPHICS #define CHANNEL_MAX 100 typedef struct { short r, g, b; } ColorRegister; typedef unsigned short RegisterNum; #define MAX_COLOR_REGISTERS 1024U #define COLOR_HOLE ((RegisterNum)MAX_COLOR_REGISTERS) #define MAX_GRAPHICS 16U typedef struct { RegisterNum *pixels; ColorRegister *private_color_registers; ColorRegister *color_registers; char color_registers_used[MAX_COLOR_REGISTERS]; XtermWidget xw; int max_width; /* largest image which can be stored */ int max_height; /* largest image which can be stored */ unsigned valid_registers; /* for wrap-around behavior */ int actual_width; /* size of image before scaling */ int actual_height; /* size of image before scaling */ int private_colors; /* if not using the shared color registers */ int charrow; /* upper left starting point in characters */ int charcol; /* upper left starting point in characters */ int pixw; /* width of graphic pixels in screen pixels */ int pixh; /* height of graphic pixels in screen pixels */ int bufferid; /* which screen buffer the graphic is associated with */ unsigned type; /* type of graphic 0==sixel, 1...NUM_REGIS_PAGES==ReGIS page */ unsigned id; /* sequential id used for preserving layering */ int valid; /* if the graphic has been initialized */ int dirty; /* if the graphic needs to be redrawn */ int hidden; /* if the graphic should not be displayed */ } Graphic; extern Graphic *get_new_graphic(XtermWidget /* xw */, int /* charrow */, int /* charcol */, unsigned /* type */); extern Graphic *get_new_or_matching_graphic(XtermWidget /* xw */, int /* charrow */, int /* charcol */, int /* actual_width */, int /* actual_height */, unsigned /* type */); extern RegisterNum read_pixel(Graphic */* graphic */, int /* x */, int /* y */); extern void draw_solid_pixel(Graphic */* graphic */, int /* x */, int /* y */, unsigned /* color */); extern void draw_solid_rectangle(Graphic */* graphic */, int /* x1 */, int /* y1 */, int /* x2 */, int /* y2 */, unsigned /* color */); extern void draw_solid_line(Graphic */* graphic */, int /* x1 */, int /* y1 */, int /* x2 */, int /* y2 */, unsigned /* color */); extern void copy_overlapping_area(Graphic */* graphic */, int /* src_x */, int /* src_y */, int /* dst_x */, int /* dst_y */, unsigned /* w */, unsigned /* h */, unsigned /* default_color */); extern void hls2rgb(int /* h */, int /* l */, int /* s */, short */* r */, short */* g */, short */* b */); extern void dump_graphic(Graphic const */* graphic */); extern unsigned get_color_register_count(TScreen const */* screen */); extern void update_color_register(Graphic */* graphic */, unsigned /* color */, int /* r */, int /* g */, int /* b */); extern RegisterNum find_color_register(ColorRegister const */* color_registers */, int /* r */, int /* g */, int /* b */); extern void chararea_clear_displayed_graphics(TScreen const */* screen */, int /* leftcol */, int /* toprow */, int /* ncols */, int /* nrows */); extern void pixelarea_clear_displayed_graphics(TScreen const */* screen */, int /* winx */, int /* winy */, int /* w */, int /* h */); extern void refresh_displayed_graphics(XtermWidget /* xw */, int /* leftcol */, int /* toprow */, int /* ncols */, int /* nrows */); extern void refresh_modified_displayed_graphics(XtermWidget /* xw */); extern void reset_displayed_graphics(TScreen const */* screen */); extern void scroll_displayed_graphics(XtermWidget /* xw */, int /* rows */); #ifdef NO_LEAKS extern void noleaks_graphics(void); #endif #else #define get_new_graphic(xw, charrow, charcol, type) /* nothing */ #define get_new_or_matching_graphic(xw, charrow, charcol, actual_width, actual_height, type) /* nothing */ #define read_pixel(graphic, x, y) /* nothing */ #define draw_solid_pixel(graphic, x, y, color) /* nothing */ #define draw_solid_rectangle(graphic, x1, y1, x2, y2, color) /* nothing */ #define draw_solid_line(graphic, x1, y1, x2, y2, color) /* nothing */ #define copy_overlapping_area(graphic, src_x, src_y, dst_x, dst_y, w, h, default_color) /* nothing */ #define hls2rgb(h, l, s, r, g, b) /* nothing */ #define dump_graphic(graphic) /* nothing */ #define get_color_register_count(screen) /* nothing */ #define update_color_register(graphic, color, r, g, b) /* nothing */ #define find_color_register(color_registers, r, g, b) /* nothing */ #define chararea_clear_displayed_graphics(screen, leftcol, toprow, ncols, nrows) /* nothing */ #define pixelarea_clear_displayed_graphics(screen, winx, winy, w, h) /* nothing */ #define refresh_displayed_graphics(xw, leftcol, toprow, ncols, nrows) /* nothing */ #define refresh_modified_displayed_graphics(xw) /* nothing */ #define reset_displayed_graphics(screen) /* nothing */ #define scroll_displayed_graphics(xw, rows) /* nothing */ #endif /* *INDENT-ON* */ #endif /* included_graphics_h */ xterm-330/256colres.h0000644000175100001440000003702310633366147013152 0ustar tomusers/* * This header file was generated by ./256colres.pl */ /* $XTermId: 256colres.h,v 1.11 2007/06/12 00:44:23 tom Exp $ */ #ifndef included_256colres_h #define included_256colres_h COLOR_RES("16", screen.Acolors[16], DFT_COLOR("rgb:00/00/00")), COLOR_RES("17", screen.Acolors[17], DFT_COLOR("rgb:00/00/5f")), COLOR_RES("18", screen.Acolors[18], DFT_COLOR("rgb:00/00/87")), COLOR_RES("19", screen.Acolors[19], DFT_COLOR("rgb:00/00/af")), COLOR_RES("20", screen.Acolors[20], DFT_COLOR("rgb:00/00/d7")), COLOR_RES("21", screen.Acolors[21], DFT_COLOR("rgb:00/00/ff")), COLOR_RES("22", screen.Acolors[22], DFT_COLOR("rgb:00/5f/00")), COLOR_RES("23", screen.Acolors[23], DFT_COLOR("rgb:00/5f/5f")), COLOR_RES("24", screen.Acolors[24], DFT_COLOR("rgb:00/5f/87")), COLOR_RES("25", screen.Acolors[25], DFT_COLOR("rgb:00/5f/af")), COLOR_RES("26", screen.Acolors[26], DFT_COLOR("rgb:00/5f/d7")), COLOR_RES("27", screen.Acolors[27], DFT_COLOR("rgb:00/5f/ff")), COLOR_RES("28", screen.Acolors[28], DFT_COLOR("rgb:00/87/00")), COLOR_RES("29", screen.Acolors[29], DFT_COLOR("rgb:00/87/5f")), COLOR_RES("30", screen.Acolors[30], DFT_COLOR("rgb:00/87/87")), COLOR_RES("31", screen.Acolors[31], DFT_COLOR("rgb:00/87/af")), COLOR_RES("32", screen.Acolors[32], DFT_COLOR("rgb:00/87/d7")), COLOR_RES("33", screen.Acolors[33], DFT_COLOR("rgb:00/87/ff")), COLOR_RES("34", screen.Acolors[34], DFT_COLOR("rgb:00/af/00")), COLOR_RES("35", screen.Acolors[35], DFT_COLOR("rgb:00/af/5f")), COLOR_RES("36", screen.Acolors[36], DFT_COLOR("rgb:00/af/87")), COLOR_RES("37", screen.Acolors[37], DFT_COLOR("rgb:00/af/af")), COLOR_RES("38", screen.Acolors[38], DFT_COLOR("rgb:00/af/d7")), COLOR_RES("39", screen.Acolors[39], DFT_COLOR("rgb:00/af/ff")), COLOR_RES("40", screen.Acolors[40], DFT_COLOR("rgb:00/d7/00")), COLOR_RES("41", screen.Acolors[41], DFT_COLOR("rgb:00/d7/5f")), COLOR_RES("42", screen.Acolors[42], DFT_COLOR("rgb:00/d7/87")), COLOR_RES("43", screen.Acolors[43], DFT_COLOR("rgb:00/d7/af")), COLOR_RES("44", screen.Acolors[44], DFT_COLOR("rgb:00/d7/d7")), COLOR_RES("45", screen.Acolors[45], DFT_COLOR("rgb:00/d7/ff")), COLOR_RES("46", screen.Acolors[46], DFT_COLOR("rgb:00/ff/00")), COLOR_RES("47", screen.Acolors[47], DFT_COLOR("rgb:00/ff/5f")), COLOR_RES("48", screen.Acolors[48], DFT_COLOR("rgb:00/ff/87")), COLOR_RES("49", screen.Acolors[49], DFT_COLOR("rgb:00/ff/af")), COLOR_RES("50", screen.Acolors[50], DFT_COLOR("rgb:00/ff/d7")), COLOR_RES("51", screen.Acolors[51], DFT_COLOR("rgb:00/ff/ff")), COLOR_RES("52", screen.Acolors[52], DFT_COLOR("rgb:5f/00/00")), COLOR_RES("53", screen.Acolors[53], DFT_COLOR("rgb:5f/00/5f")), COLOR_RES("54", screen.Acolors[54], DFT_COLOR("rgb:5f/00/87")), COLOR_RES("55", screen.Acolors[55], DFT_COLOR("rgb:5f/00/af")), COLOR_RES("56", screen.Acolors[56], DFT_COLOR("rgb:5f/00/d7")), COLOR_RES("57", screen.Acolors[57], DFT_COLOR("rgb:5f/00/ff")), COLOR_RES("58", screen.Acolors[58], DFT_COLOR("rgb:5f/5f/00")), COLOR_RES("59", screen.Acolors[59], DFT_COLOR("rgb:5f/5f/5f")), COLOR_RES("60", screen.Acolors[60], DFT_COLOR("rgb:5f/5f/87")), COLOR_RES("61", screen.Acolors[61], DFT_COLOR("rgb:5f/5f/af")), COLOR_RES("62", screen.Acolors[62], DFT_COLOR("rgb:5f/5f/d7")), COLOR_RES("63", screen.Acolors[63], DFT_COLOR("rgb:5f/5f/ff")), COLOR_RES("64", screen.Acolors[64], DFT_COLOR("rgb:5f/87/00")), COLOR_RES("65", screen.Acolors[65], DFT_COLOR("rgb:5f/87/5f")), COLOR_RES("66", screen.Acolors[66], DFT_COLOR("rgb:5f/87/87")), COLOR_RES("67", screen.Acolors[67], DFT_COLOR("rgb:5f/87/af")), COLOR_RES("68", screen.Acolors[68], DFT_COLOR("rgb:5f/87/d7")), COLOR_RES("69", screen.Acolors[69], DFT_COLOR("rgb:5f/87/ff")), COLOR_RES("70", screen.Acolors[70], DFT_COLOR("rgb:5f/af/00")), COLOR_RES("71", screen.Acolors[71], DFT_COLOR("rgb:5f/af/5f")), COLOR_RES("72", screen.Acolors[72], DFT_COLOR("rgb:5f/af/87")), COLOR_RES("73", screen.Acolors[73], DFT_COLOR("rgb:5f/af/af")), COLOR_RES("74", screen.Acolors[74], DFT_COLOR("rgb:5f/af/d7")), COLOR_RES("75", screen.Acolors[75], DFT_COLOR("rgb:5f/af/ff")), COLOR_RES("76", screen.Acolors[76], DFT_COLOR("rgb:5f/d7/00")), COLOR_RES("77", screen.Acolors[77], DFT_COLOR("rgb:5f/d7/5f")), COLOR_RES("78", screen.Acolors[78], DFT_COLOR("rgb:5f/d7/87")), COLOR_RES("79", screen.Acolors[79], DFT_COLOR("rgb:5f/d7/af")), COLOR_RES("80", screen.Acolors[80], DFT_COLOR("rgb:5f/d7/d7")), COLOR_RES("81", screen.Acolors[81], DFT_COLOR("rgb:5f/d7/ff")), COLOR_RES("82", screen.Acolors[82], DFT_COLOR("rgb:5f/ff/00")), COLOR_RES("83", screen.Acolors[83], DFT_COLOR("rgb:5f/ff/5f")), COLOR_RES("84", screen.Acolors[84], DFT_COLOR("rgb:5f/ff/87")), COLOR_RES("85", screen.Acolors[85], DFT_COLOR("rgb:5f/ff/af")), COLOR_RES("86", screen.Acolors[86], DFT_COLOR("rgb:5f/ff/d7")), COLOR_RES("87", screen.Acolors[87], DFT_COLOR("rgb:5f/ff/ff")), COLOR_RES("88", screen.Acolors[88], DFT_COLOR("rgb:87/00/00")), COLOR_RES("89", screen.Acolors[89], DFT_COLOR("rgb:87/00/5f")), COLOR_RES("90", screen.Acolors[90], DFT_COLOR("rgb:87/00/87")), COLOR_RES("91", screen.Acolors[91], DFT_COLOR("rgb:87/00/af")), COLOR_RES("92", screen.Acolors[92], DFT_COLOR("rgb:87/00/d7")), COLOR_RES("93", screen.Acolors[93], DFT_COLOR("rgb:87/00/ff")), COLOR_RES("94", screen.Acolors[94], DFT_COLOR("rgb:87/5f/00")), COLOR_RES("95", screen.Acolors[95], DFT_COLOR("rgb:87/5f/5f")), COLOR_RES("96", screen.Acolors[96], DFT_COLOR("rgb:87/5f/87")), COLOR_RES("97", screen.Acolors[97], DFT_COLOR("rgb:87/5f/af")), COLOR_RES("98", screen.Acolors[98], DFT_COLOR("rgb:87/5f/d7")), COLOR_RES("99", screen.Acolors[99], DFT_COLOR("rgb:87/5f/ff")), COLOR_RES("100", screen.Acolors[100], DFT_COLOR("rgb:87/87/00")), COLOR_RES("101", screen.Acolors[101], DFT_COLOR("rgb:87/87/5f")), COLOR_RES("102", screen.Acolors[102], DFT_COLOR("rgb:87/87/87")), COLOR_RES("103", screen.Acolors[103], DFT_COLOR("rgb:87/87/af")), COLOR_RES("104", screen.Acolors[104], DFT_COLOR("rgb:87/87/d7")), COLOR_RES("105", screen.Acolors[105], DFT_COLOR("rgb:87/87/ff")), COLOR_RES("106", screen.Acolors[106], DFT_COLOR("rgb:87/af/00")), COLOR_RES("107", screen.Acolors[107], DFT_COLOR("rgb:87/af/5f")), COLOR_RES("108", screen.Acolors[108], DFT_COLOR("rgb:87/af/87")), COLOR_RES("109", screen.Acolors[109], DFT_COLOR("rgb:87/af/af")), COLOR_RES("110", screen.Acolors[110], DFT_COLOR("rgb:87/af/d7")), COLOR_RES("111", screen.Acolors[111], DFT_COLOR("rgb:87/af/ff")), COLOR_RES("112", screen.Acolors[112], DFT_COLOR("rgb:87/d7/00")), COLOR_RES("113", screen.Acolors[113], DFT_COLOR("rgb:87/d7/5f")), COLOR_RES("114", screen.Acolors[114], DFT_COLOR("rgb:87/d7/87")), COLOR_RES("115", screen.Acolors[115], DFT_COLOR("rgb:87/d7/af")), COLOR_RES("116", screen.Acolors[116], DFT_COLOR("rgb:87/d7/d7")), COLOR_RES("117", screen.Acolors[117], DFT_COLOR("rgb:87/d7/ff")), COLOR_RES("118", screen.Acolors[118], DFT_COLOR("rgb:87/ff/00")), COLOR_RES("119", screen.Acolors[119], DFT_COLOR("rgb:87/ff/5f")), COLOR_RES("120", screen.Acolors[120], DFT_COLOR("rgb:87/ff/87")), COLOR_RES("121", screen.Acolors[121], DFT_COLOR("rgb:87/ff/af")), COLOR_RES("122", screen.Acolors[122], DFT_COLOR("rgb:87/ff/d7")), COLOR_RES("123", screen.Acolors[123], DFT_COLOR("rgb:87/ff/ff")), COLOR_RES("124", screen.Acolors[124], DFT_COLOR("rgb:af/00/00")), COLOR_RES("125", screen.Acolors[125], DFT_COLOR("rgb:af/00/5f")), COLOR_RES("126", screen.Acolors[126], DFT_COLOR("rgb:af/00/87")), COLOR_RES("127", screen.Acolors[127], DFT_COLOR("rgb:af/00/af")), COLOR_RES("128", screen.Acolors[128], DFT_COLOR("rgb:af/00/d7")), COLOR_RES("129", screen.Acolors[129], DFT_COLOR("rgb:af/00/ff")), COLOR_RES("130", screen.Acolors[130], DFT_COLOR("rgb:af/5f/00")), COLOR_RES("131", screen.Acolors[131], DFT_COLOR("rgb:af/5f/5f")), COLOR_RES("132", screen.Acolors[132], DFT_COLOR("rgb:af/5f/87")), COLOR_RES("133", screen.Acolors[133], DFT_COLOR("rgb:af/5f/af")), COLOR_RES("134", screen.Acolors[134], DFT_COLOR("rgb:af/5f/d7")), COLOR_RES("135", screen.Acolors[135], DFT_COLOR("rgb:af/5f/ff")), COLOR_RES("136", screen.Acolors[136], DFT_COLOR("rgb:af/87/00")), COLOR_RES("137", screen.Acolors[137], DFT_COLOR("rgb:af/87/5f")), COLOR_RES("138", screen.Acolors[138], DFT_COLOR("rgb:af/87/87")), COLOR_RES("139", screen.Acolors[139], DFT_COLOR("rgb:af/87/af")), COLOR_RES("140", screen.Acolors[140], DFT_COLOR("rgb:af/87/d7")), COLOR_RES("141", screen.Acolors[141], DFT_COLOR("rgb:af/87/ff")), COLOR_RES("142", screen.Acolors[142], DFT_COLOR("rgb:af/af/00")), COLOR_RES("143", screen.Acolors[143], DFT_COLOR("rgb:af/af/5f")), COLOR_RES("144", screen.Acolors[144], DFT_COLOR("rgb:af/af/87")), COLOR_RES("145", screen.Acolors[145], DFT_COLOR("rgb:af/af/af")), COLOR_RES("146", screen.Acolors[146], DFT_COLOR("rgb:af/af/d7")), COLOR_RES("147", screen.Acolors[147], DFT_COLOR("rgb:af/af/ff")), COLOR_RES("148", screen.Acolors[148], DFT_COLOR("rgb:af/d7/00")), COLOR_RES("149", screen.Acolors[149], DFT_COLOR("rgb:af/d7/5f")), COLOR_RES("150", screen.Acolors[150], DFT_COLOR("rgb:af/d7/87")), COLOR_RES("151", screen.Acolors[151], DFT_COLOR("rgb:af/d7/af")), COLOR_RES("152", screen.Acolors[152], DFT_COLOR("rgb:af/d7/d7")), COLOR_RES("153", screen.Acolors[153], DFT_COLOR("rgb:af/d7/ff")), COLOR_RES("154", screen.Acolors[154], DFT_COLOR("rgb:af/ff/00")), COLOR_RES("155", screen.Acolors[155], DFT_COLOR("rgb:af/ff/5f")), COLOR_RES("156", screen.Acolors[156], DFT_COLOR("rgb:af/ff/87")), COLOR_RES("157", screen.Acolors[157], DFT_COLOR("rgb:af/ff/af")), COLOR_RES("158", screen.Acolors[158], DFT_COLOR("rgb:af/ff/d7")), COLOR_RES("159", screen.Acolors[159], DFT_COLOR("rgb:af/ff/ff")), COLOR_RES("160", screen.Acolors[160], DFT_COLOR("rgb:d7/00/00")), COLOR_RES("161", screen.Acolors[161], DFT_COLOR("rgb:d7/00/5f")), COLOR_RES("162", screen.Acolors[162], DFT_COLOR("rgb:d7/00/87")), COLOR_RES("163", screen.Acolors[163], DFT_COLOR("rgb:d7/00/af")), COLOR_RES("164", screen.Acolors[164], DFT_COLOR("rgb:d7/00/d7")), COLOR_RES("165", screen.Acolors[165], DFT_COLOR("rgb:d7/00/ff")), COLOR_RES("166", screen.Acolors[166], DFT_COLOR("rgb:d7/5f/00")), COLOR_RES("167", screen.Acolors[167], DFT_COLOR("rgb:d7/5f/5f")), COLOR_RES("168", screen.Acolors[168], DFT_COLOR("rgb:d7/5f/87")), COLOR_RES("169", screen.Acolors[169], DFT_COLOR("rgb:d7/5f/af")), COLOR_RES("170", screen.Acolors[170], DFT_COLOR("rgb:d7/5f/d7")), COLOR_RES("171", screen.Acolors[171], DFT_COLOR("rgb:d7/5f/ff")), COLOR_RES("172", screen.Acolors[172], DFT_COLOR("rgb:d7/87/00")), COLOR_RES("173", screen.Acolors[173], DFT_COLOR("rgb:d7/87/5f")), COLOR_RES("174", screen.Acolors[174], DFT_COLOR("rgb:d7/87/87")), COLOR_RES("175", screen.Acolors[175], DFT_COLOR("rgb:d7/87/af")), COLOR_RES("176", screen.Acolors[176], DFT_COLOR("rgb:d7/87/d7")), COLOR_RES("177", screen.Acolors[177], DFT_COLOR("rgb:d7/87/ff")), COLOR_RES("178", screen.Acolors[178], DFT_COLOR("rgb:d7/af/00")), COLOR_RES("179", screen.Acolors[179], DFT_COLOR("rgb:d7/af/5f")), COLOR_RES("180", screen.Acolors[180], DFT_COLOR("rgb:d7/af/87")), COLOR_RES("181", screen.Acolors[181], DFT_COLOR("rgb:d7/af/af")), COLOR_RES("182", screen.Acolors[182], DFT_COLOR("rgb:d7/af/d7")), COLOR_RES("183", screen.Acolors[183], DFT_COLOR("rgb:d7/af/ff")), COLOR_RES("184", screen.Acolors[184], DFT_COLOR("rgb:d7/d7/00")), COLOR_RES("185", screen.Acolors[185], DFT_COLOR("rgb:d7/d7/5f")), COLOR_RES("186", screen.Acolors[186], DFT_COLOR("rgb:d7/d7/87")), COLOR_RES("187", screen.Acolors[187], DFT_COLOR("rgb:d7/d7/af")), COLOR_RES("188", screen.Acolors[188], DFT_COLOR("rgb:d7/d7/d7")), COLOR_RES("189", screen.Acolors[189], DFT_COLOR("rgb:d7/d7/ff")), COLOR_RES("190", screen.Acolors[190], DFT_COLOR("rgb:d7/ff/00")), COLOR_RES("191", screen.Acolors[191], DFT_COLOR("rgb:d7/ff/5f")), COLOR_RES("192", screen.Acolors[192], DFT_COLOR("rgb:d7/ff/87")), COLOR_RES("193", screen.Acolors[193], DFT_COLOR("rgb:d7/ff/af")), COLOR_RES("194", screen.Acolors[194], DFT_COLOR("rgb:d7/ff/d7")), COLOR_RES("195", screen.Acolors[195], DFT_COLOR("rgb:d7/ff/ff")), COLOR_RES("196", screen.Acolors[196], DFT_COLOR("rgb:ff/00/00")), COLOR_RES("197", screen.Acolors[197], DFT_COLOR("rgb:ff/00/5f")), COLOR_RES("198", screen.Acolors[198], DFT_COLOR("rgb:ff/00/87")), COLOR_RES("199", screen.Acolors[199], DFT_COLOR("rgb:ff/00/af")), COLOR_RES("200", screen.Acolors[200], DFT_COLOR("rgb:ff/00/d7")), COLOR_RES("201", screen.Acolors[201], DFT_COLOR("rgb:ff/00/ff")), COLOR_RES("202", screen.Acolors[202], DFT_COLOR("rgb:ff/5f/00")), COLOR_RES("203", screen.Acolors[203], DFT_COLOR("rgb:ff/5f/5f")), COLOR_RES("204", screen.Acolors[204], DFT_COLOR("rgb:ff/5f/87")), COLOR_RES("205", screen.Acolors[205], DFT_COLOR("rgb:ff/5f/af")), COLOR_RES("206", screen.Acolors[206], DFT_COLOR("rgb:ff/5f/d7")), COLOR_RES("207", screen.Acolors[207], DFT_COLOR("rgb:ff/5f/ff")), COLOR_RES("208", screen.Acolors[208], DFT_COLOR("rgb:ff/87/00")), COLOR_RES("209", screen.Acolors[209], DFT_COLOR("rgb:ff/87/5f")), COLOR_RES("210", screen.Acolors[210], DFT_COLOR("rgb:ff/87/87")), COLOR_RES("211", screen.Acolors[211], DFT_COLOR("rgb:ff/87/af")), COLOR_RES("212", screen.Acolors[212], DFT_COLOR("rgb:ff/87/d7")), COLOR_RES("213", screen.Acolors[213], DFT_COLOR("rgb:ff/87/ff")), COLOR_RES("214", screen.Acolors[214], DFT_COLOR("rgb:ff/af/00")), COLOR_RES("215", screen.Acolors[215], DFT_COLOR("rgb:ff/af/5f")), COLOR_RES("216", screen.Acolors[216], DFT_COLOR("rgb:ff/af/87")), COLOR_RES("217", screen.Acolors[217], DFT_COLOR("rgb:ff/af/af")), COLOR_RES("218", screen.Acolors[218], DFT_COLOR("rgb:ff/af/d7")), COLOR_RES("219", screen.Acolors[219], DFT_COLOR("rgb:ff/af/ff")), COLOR_RES("220", screen.Acolors[220], DFT_COLOR("rgb:ff/d7/00")), COLOR_RES("221", screen.Acolors[221], DFT_COLOR("rgb:ff/d7/5f")), COLOR_RES("222", screen.Acolors[222], DFT_COLOR("rgb:ff/d7/87")), COLOR_RES("223", screen.Acolors[223], DFT_COLOR("rgb:ff/d7/af")), COLOR_RES("224", screen.Acolors[224], DFT_COLOR("rgb:ff/d7/d7")), COLOR_RES("225", screen.Acolors[225], DFT_COLOR("rgb:ff/d7/ff")), COLOR_RES("226", screen.Acolors[226], DFT_COLOR("rgb:ff/ff/00")), COLOR_RES("227", screen.Acolors[227], DFT_COLOR("rgb:ff/ff/5f")), COLOR_RES("228", screen.Acolors[228], DFT_COLOR("rgb:ff/ff/87")), COLOR_RES("229", screen.Acolors[229], DFT_COLOR("rgb:ff/ff/af")), COLOR_RES("230", screen.Acolors[230], DFT_COLOR("rgb:ff/ff/d7")), COLOR_RES("231", screen.Acolors[231], DFT_COLOR("rgb:ff/ff/ff")), COLOR_RES("232", screen.Acolors[232], DFT_COLOR("rgb:08/08/08")), COLOR_RES("233", screen.Acolors[233], DFT_COLOR("rgb:12/12/12")), COLOR_RES("234", screen.Acolors[234], DFT_COLOR("rgb:1c/1c/1c")), COLOR_RES("235", screen.Acolors[235], DFT_COLOR("rgb:26/26/26")), COLOR_RES("236", screen.Acolors[236], DFT_COLOR("rgb:30/30/30")), COLOR_RES("237", screen.Acolors[237], DFT_COLOR("rgb:3a/3a/3a")), COLOR_RES("238", screen.Acolors[238], DFT_COLOR("rgb:44/44/44")), COLOR_RES("239", screen.Acolors[239], DFT_COLOR("rgb:4e/4e/4e")), COLOR_RES("240", screen.Acolors[240], DFT_COLOR("rgb:58/58/58")), COLOR_RES("241", screen.Acolors[241], DFT_COLOR("rgb:62/62/62")), COLOR_RES("242", screen.Acolors[242], DFT_COLOR("rgb:6c/6c/6c")), COLOR_RES("243", screen.Acolors[243], DFT_COLOR("rgb:76/76/76")), COLOR_RES("244", screen.Acolors[244], DFT_COLOR("rgb:80/80/80")), COLOR_RES("245", screen.Acolors[245], DFT_COLOR("rgb:8a/8a/8a")), COLOR_RES("246", screen.Acolors[246], DFT_COLOR("rgb:94/94/94")), COLOR_RES("247", screen.Acolors[247], DFT_COLOR("rgb:9e/9e/9e")), COLOR_RES("248", screen.Acolors[248], DFT_COLOR("rgb:a8/a8/a8")), COLOR_RES("249", screen.Acolors[249], DFT_COLOR("rgb:b2/b2/b2")), COLOR_RES("250", screen.Acolors[250], DFT_COLOR("rgb:bc/bc/bc")), COLOR_RES("251", screen.Acolors[251], DFT_COLOR("rgb:c6/c6/c6")), COLOR_RES("252", screen.Acolors[252], DFT_COLOR("rgb:d0/d0/d0")), COLOR_RES("253", screen.Acolors[253], DFT_COLOR("rgb:da/da/da")), COLOR_RES("254", screen.Acolors[254], DFT_COLOR("rgb:e4/e4/e4")), COLOR_RES("255", screen.Acolors[255], DFT_COLOR("rgb:ee/ee/ee")), #endif /* included_256colres_h */ xterm-330/menu.c0000644000175100001440000026065613032563073012370 0ustar tomusers/* $XTermId: menu.c,v 1.344 2017/01/02 23:46:03 tom Exp $ */ /* * Copyright 1999-2016,2017 by Thomas E. Dickey * * All Rights Reserved * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * Except as contained in this notice, the name(s) of the above copyright * holders shall not be used in advertising or otherwise to promote the * sale, use or other dealings in this Software without prior written * authorization. * * * Copyright 1989 The Open Group * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation. * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * Except as contained in this notice, the name of The Open Group shall not be * used in advertising or otherwise to promote the sale, use or other dealings * in this Software without prior written authorization from The Open Group. */ #include #include #include #include #include #include #include #define app_con Xaw_app_con /* quiet a warning from SimpleMenu.h */ #if defined(HAVE_LIB_XAW) #include #include #include #include #if OPT_TOOLBAR #include #include #endif #elif defined(HAVE_LIB_XAW3D) #include #include #include #include #if OPT_TOOLBAR #include #include #endif #elif defined(HAVE_LIB_XAW3DXFT) #include #include #include #include #if OPT_TOOLBAR #include #include #endif #elif defined(HAVE_LIB_NEXTAW) #include #include #include #include #if OPT_TOOLBAR #include #include #endif #elif defined(HAVE_LIB_XAWPLUS) #include #include #include #include #if OPT_TOOLBAR #include #include #endif #endif #undef app_con #include #include #if OPT_TRACE #define UpdateCheckbox(func, mn, mi, val) UpdateMenuItem(func, mn, mi, val) #else #define UpdateCheckbox(func, mn, mi, val) UpdateMenuItem(mn, mi, val) #endif #define ToggleFlag(flag) flag = (Boolean) !flag /* *INDENT-OFF* */ static void do_8bit_control PROTO_XT_CALLBACK_ARGS; static void do_allow132 PROTO_XT_CALLBACK_ARGS; static void do_allowBoldFonts PROTO_XT_CALLBACK_ARGS; static void do_allowsends PROTO_XT_CALLBACK_ARGS; static void do_altscreen PROTO_XT_CALLBACK_ARGS; static void do_appcursor PROTO_XT_CALLBACK_ARGS; static void do_appkeypad PROTO_XT_CALLBACK_ARGS; static void do_autolinefeed PROTO_XT_CALLBACK_ARGS; static void do_autowrap PROTO_XT_CALLBACK_ARGS; static void do_backarrow PROTO_XT_CALLBACK_ARGS; static void do_bellIsUrgent PROTO_XT_CALLBACK_ARGS; static void do_clearsavedlines PROTO_XT_CALLBACK_ARGS; static void do_continue PROTO_XT_CALLBACK_ARGS; static void do_delete_del PROTO_XT_CALLBACK_ARGS; #if OPT_SCREEN_DUMPS static void do_dump_html PROTO_XT_CALLBACK_ARGS; static void do_dump_svg PROTO_XT_CALLBACK_ARGS; #endif static void do_hardreset PROTO_XT_CALLBACK_ARGS; static void do_interrupt PROTO_XT_CALLBACK_ARGS; static void do_jumpscroll PROTO_XT_CALLBACK_ARGS; static void do_keepClipboard PROTO_XT_CALLBACK_ARGS; static void do_keepSelection PROTO_XT_CALLBACK_ARGS; static void do_kill PROTO_XT_CALLBACK_ARGS; static void do_old_fkeys PROTO_XT_CALLBACK_ARGS; static void do_poponbell PROTO_XT_CALLBACK_ARGS; static void do_print PROTO_XT_CALLBACK_ARGS; static void do_print_redir PROTO_XT_CALLBACK_ARGS; static void do_quit PROTO_XT_CALLBACK_ARGS; static void do_redraw PROTO_XT_CALLBACK_ARGS; static void do_reversevideo PROTO_XT_CALLBACK_ARGS; static void do_reversewrap PROTO_XT_CALLBACK_ARGS; static void do_scrollbar PROTO_XT_CALLBACK_ARGS; static void do_scrollkey PROTO_XT_CALLBACK_ARGS; static void do_scrollttyoutput PROTO_XT_CALLBACK_ARGS; static void do_securekbd PROTO_XT_CALLBACK_ARGS; static void do_selectClipboard PROTO_XT_CALLBACK_ARGS; static void do_softreset PROTO_XT_CALLBACK_ARGS; static void do_suspend PROTO_XT_CALLBACK_ARGS; static void do_terminate PROTO_XT_CALLBACK_ARGS; static void do_titeInhibit PROTO_XT_CALLBACK_ARGS; static void do_visualbell PROTO_XT_CALLBACK_ARGS; static void do_vtfont PROTO_XT_CALLBACK_ARGS; #ifdef ALLOWLOGGING static void do_logging PROTO_XT_CALLBACK_ARGS; #endif #ifndef NO_ACTIVE_ICON static void do_activeicon PROTO_XT_CALLBACK_ARGS; #endif /* NO_ACTIVE_ICON */ #if OPT_ALLOW_XXX_OPS static void enable_allow_xxx_ops (Bool); static void do_allowColorOps PROTO_XT_CALLBACK_ARGS; static void do_allowFontOps PROTO_XT_CALLBACK_ARGS; static void do_allowMouseOps PROTO_XT_CALLBACK_ARGS; static void do_allowTcapOps PROTO_XT_CALLBACK_ARGS; static void do_allowTitleOps PROTO_XT_CALLBACK_ARGS; static void do_allowWindowOps PROTO_XT_CALLBACK_ARGS; #endif #if OPT_BLINK_CURS static void do_cursorblink PROTO_XT_CALLBACK_ARGS; #endif #if OPT_BOX_CHARS static void do_font_boxchars PROTO_XT_CALLBACK_ARGS; static void do_font_packed PROTO_XT_CALLBACK_ARGS; #endif #if OPT_DEC_CHRSET static void do_font_doublesize PROTO_XT_CALLBACK_ARGS; #endif #if OPT_DEC_SOFTFONT static void do_font_loadable PROTO_XT_CALLBACK_ARGS; #endif #if OPT_HP_FUNC_KEYS static void do_hp_fkeys PROTO_XT_CALLBACK_ARGS; #endif #if OPT_MAXIMIZE static void do_fullscreen PROTO_XT_CALLBACK_ARGS; #endif #if OPT_NUM_LOCK static void do_alt_esc PROTO_XT_CALLBACK_ARGS; static void do_num_lock PROTO_XT_CALLBACK_ARGS; static void do_meta_esc PROTO_XT_CALLBACK_ARGS; #endif #if OPT_PRINT_ON_EXIT static void do_write_now PROTO_XT_CALLBACK_ARGS; static void do_write_error PROTO_XT_CALLBACK_ARGS; #endif #if OPT_RENDERFONT static void do_font_renderfont PROTO_XT_CALLBACK_ARGS; #endif #if OPT_SCO_FUNC_KEYS static void do_sco_fkeys PROTO_XT_CALLBACK_ARGS; #endif #if OPT_SIXEL_GRAPHICS static void do_sixelscrolling PROTO_XT_CALLBACK_ARGS; #endif #if OPT_GRAPHICS static void do_privatecolorregisters PROTO_XT_CALLBACK_ARGS; #endif #if OPT_SUN_FUNC_KEYS static void do_sun_fkeys PROTO_XT_CALLBACK_ARGS; #endif #if OPT_SUNPC_KBD static void do_sun_kbd PROTO_XT_CALLBACK_ARGS; #endif #if OPT_TCAP_FKEYS static void do_tcap_fkeys PROTO_XT_CALLBACK_ARGS; #endif #if OPT_TEK4014 static void do_tekcopy PROTO_XT_CALLBACK_ARGS; static void do_tekhide PROTO_XT_CALLBACK_ARGS; static void do_tekmode PROTO_XT_CALLBACK_ARGS; static void do_tekonoff PROTO_XT_CALLBACK_ARGS; static void do_tekpage PROTO_XT_CALLBACK_ARGS; static void do_tekreset PROTO_XT_CALLBACK_ARGS; static void do_tekshow PROTO_XT_CALLBACK_ARGS; static void do_tektext2 PROTO_XT_CALLBACK_ARGS; static void do_tektext3 PROTO_XT_CALLBACK_ARGS; static void do_tektextlarge PROTO_XT_CALLBACK_ARGS; static void do_tektextsmall PROTO_XT_CALLBACK_ARGS; static void do_vthide PROTO_XT_CALLBACK_ARGS; static void do_vtmode PROTO_XT_CALLBACK_ARGS; static void do_vtonoff PROTO_XT_CALLBACK_ARGS; static void do_vtshow PROTO_XT_CALLBACK_ARGS; static void handle_tekshow (Widget gw, Bool allowswitch); static void handle_vtshow (Widget gw, Bool allowswitch); #endif #if OPT_TOOLBAR static void do_toolbar PROTO_XT_CALLBACK_ARGS; #endif #if OPT_WIDE_CHARS static void do_font_utf8_mode PROTO_XT_CALLBACK_ARGS; static void do_font_utf8_fonts PROTO_XT_CALLBACK_ARGS; static void do_font_utf8_title PROTO_XT_CALLBACK_ARGS; #endif /* * The order of entries MUST match the values given in menu.h */ MenuEntry mainMenuEntries[] = { #if OPT_TOOLBAR { "toolbar", do_toolbar, NULL }, #endif #if OPT_MAXIMIZE { "fullscreen", do_fullscreen, NULL }, #endif { "securekbd", do_securekbd, NULL }, { "allowsends", do_allowsends, NULL }, { "redraw", do_redraw, NULL }, { "line1", NULL, NULL }, #ifdef ALLOWLOGGING { "logging", do_logging, NULL }, #endif #ifdef OPT_PRINT_ON_EXIT { "print-immediate", do_write_now, NULL }, { "print-on-error", do_write_error, NULL }, #endif { "print", do_print, NULL }, { "print-redir", do_print_redir, NULL }, #if OPT_SCREEN_DUMPS { "dump-html", do_dump_html, NULL }, { "dump-svg", do_dump_svg, NULL }, #endif { "line2", NULL, NULL }, { "8-bit control", do_8bit_control,NULL }, { "backarrow key", do_backarrow, NULL }, #if OPT_NUM_LOCK { "num-lock", do_num_lock, NULL }, { "alt-esc", do_alt_esc, NULL }, { "meta-esc", do_meta_esc, NULL }, #endif { "delete-is-del", do_delete_del, NULL }, { "oldFunctionKeys",do_old_fkeys, NULL }, #if OPT_TCAP_FKEYS { "tcapFunctionKeys",do_tcap_fkeys, NULL }, #endif #if OPT_HP_FUNC_KEYS { "hpFunctionKeys", do_hp_fkeys, NULL }, #endif #if OPT_SCO_FUNC_KEYS { "scoFunctionKeys",do_sco_fkeys, NULL }, #endif #if OPT_SUN_FUNC_KEYS { "sunFunctionKeys",do_sun_fkeys, NULL }, #endif #if OPT_SUNPC_KBD { "sunKeyboard", do_sun_kbd, NULL }, #endif { "line3", NULL, NULL }, { "suspend", do_suspend, NULL }, { "continue", do_continue, NULL }, { "interrupt", do_interrupt, NULL }, { "hangup", do_hangup, NULL }, { "terminate", do_terminate, NULL }, { "kill", do_kill, NULL }, { "line4", NULL, NULL }, { "quit", do_quit, NULL }}; MenuEntry vtMenuEntries[] = { { "scrollbar", do_scrollbar, NULL }, { "jumpscroll", do_jumpscroll, NULL }, { "reversevideo", do_reversevideo, NULL }, { "autowrap", do_autowrap, NULL }, { "reversewrap", do_reversewrap, NULL }, { "autolinefeed", do_autolinefeed, NULL }, { "appcursor", do_appcursor, NULL }, { "appkeypad", do_appkeypad, NULL }, { "scrollkey", do_scrollkey, NULL }, { "scrollttyoutput",do_scrollttyoutput, NULL }, { "allow132", do_allow132, NULL }, { "keepSelection", do_keepSelection, NULL }, { "selectToClipboard",do_selectClipboard, NULL }, { "visualbell", do_visualbell, NULL }, { "bellIsUrgent", do_bellIsUrgent, NULL }, { "poponbell", do_poponbell, NULL }, #if OPT_BLINK_CURS { "cursorblink", do_cursorblink, NULL }, #endif { "titeInhibit", do_titeInhibit, NULL }, #ifndef NO_ACTIVE_ICON { "activeicon", do_activeicon, NULL }, #endif /* NO_ACTIVE_ICON */ { "line1", NULL, NULL }, { "softreset", do_softreset, NULL }, { "hardreset", do_hardreset, NULL }, { "clearsavedlines",do_clearsavedlines, NULL }, { "line2", NULL, NULL }, #if OPT_TEK4014 { "tekshow", do_tekshow, NULL }, { "tekmode", do_tekmode, NULL }, { "vthide", do_vthide, NULL }, #endif { "altscreen", do_altscreen, NULL }, #if OPT_SIXEL_GRAPHICS { "sixelScrolling", do_sixelscrolling, NULL }, #endif #if OPT_GRAPHICS { "privateColorRegisters", do_privatecolorregisters, NULL }, #endif }; MenuEntry fontMenuEntries[] = { { "fontdefault", do_vtfont, NULL }, { "font1", do_vtfont, NULL }, { "font2", do_vtfont, NULL }, { "font3", do_vtfont, NULL }, { "font4", do_vtfont, NULL }, { "font5", do_vtfont, NULL }, { "font6", do_vtfont, NULL }, /* this is after the last builtin font; the other entries are special */ { "fontescape", do_vtfont, NULL }, { "fontsel", do_vtfont, NULL }, /* down to here should match NMENUFONTS in ptyx.h */ #if OPT_DEC_CHRSET || OPT_BOX_CHARS || OPT_DEC_SOFTFONT { "line1", NULL, NULL }, { "allow-bold-fonts", do_allowBoldFonts, NULL }, #if OPT_BOX_CHARS { "font-linedrawing",do_font_boxchars,NULL }, { "font-packed", do_font_packed,NULL }, #endif #if OPT_DEC_CHRSET { "font-doublesize",do_font_doublesize,NULL }, #endif #if OPT_DEC_SOFTFONT { "font-loadable", do_font_loadable,NULL }, #endif #endif /* toggles for DEC font extensions */ #if OPT_RENDERFONT || OPT_WIDE_CHARS { "line2", NULL, NULL }, #if OPT_RENDERFONT { "render-font", do_font_renderfont,NULL }, #endif #if OPT_WIDE_CHARS { "utf8-mode", do_font_utf8_mode,NULL }, { "utf8-fonts", do_font_utf8_fonts,NULL }, { "utf8-title", do_font_utf8_title,NULL }, #endif #endif /* toggles for other font extensions */ #if OPT_ALLOW_XXX_OPS { "line3", NULL, NULL }, { "allow-color-ops",do_allowColorOps,NULL }, { "allow-font-ops", do_allowFontOps,NULL }, { "allow-mouse-ops",do_allowMouseOps,NULL }, { "allow-tcap-ops", do_allowTcapOps,NULL }, { "allow-title-ops",do_allowTitleOps,NULL }, { "allow-window-ops",do_allowWindowOps,NULL }, #endif }; #if OPT_TEK4014 MenuEntry tekMenuEntries[] = { { "tektextlarge", do_tektextlarge, NULL }, { "tektext2", do_tektext2, NULL }, { "tektext3", do_tektext3, NULL }, { "tektextsmall", do_tektextsmall, NULL }, { "line1", NULL, NULL }, { "tekpage", do_tekpage, NULL }, { "tekreset", do_tekreset, NULL }, { "tekcopy", do_tekcopy, NULL }, { "line2", NULL, NULL }, { "vtshow", do_vtshow, NULL }, { "vtmode", do_vtmode, NULL }, { "tekhide", do_tekhide, NULL }}; #endif typedef struct { char *internal_name; MenuEntry *entry_list; Cardinal entry_len; } MenuHeader; /* This table is ordered to correspond with MenuIndex */ static const MenuHeader menu_names[] = { { "mainMenu", mainMenuEntries, XtNumber(mainMenuEntries) }, { "vtMenu", vtMenuEntries, XtNumber(vtMenuEntries) }, { "fontMenu", fontMenuEntries, XtNumber(fontMenuEntries) }, #if OPT_TEK4014 { "tekMenu", tekMenuEntries, XtNumber(tekMenuEntries) }, #endif { 0, 0, 0 }, }; /* *INDENT-ON* */ /* * FIXME: These are global data rather than in the xterm widget because they * are initialized before the widget is created. */ typedef struct { Widget b; /* the toolbar's buttons */ Widget w; /* the popup shell activated by the button */ Cardinal entries; } MenuList; static MenuList vt_shell[NUM_POPUP_MENUS]; #if OPT_TEK4014 && OPT_TOOLBAR static MenuList tek_shell[NUM_POPUP_MENUS]; #endif static String setMenuLocale(Bool before, String substitute) { String result = setlocale(LC_CTYPE, 0); if (before) { result = x_strdup(result); } (void) setlocale(LC_CTYPE, substitute); TRACE(("setMenuLocale %s:%s\n", (before ? "before" : "after"), NonNull(result))); if (!before) { free((void *) substitute); } return result; } /* * Returns a pointer to the MenuList entry that matches the popup menu. */ static MenuList * select_menu(Widget w GCC_UNUSED, MenuIndex num) { #if OPT_TEK4014 && OPT_TOOLBAR while (w != 0) { if (w == tekshellwidget) { return &tek_shell[num]; } w = XtParent(w); } #endif return &vt_shell[num]; } /* * Returns a pointer to the given popup menu shell */ static Widget obtain_menu(Widget w, MenuIndex num) { return select_menu(w, num)->w; } /* * Returns the number of entries in the given popup menu shell */ static Cardinal sizeof_menu(Widget w, MenuIndex num) { return select_menu(w, num)->entries; } /* * Return an array of flags telling if a given menu item is never going to * be used, so we can reduce the size of menus. */ static Boolean * unusedEntries(XtermWidget xw, MenuIndex num) { static Boolean result[XtNumber(mainMenuEntries) + XtNumber(vtMenuEntries) + XtNumber(fontMenuEntries) #if OPT_TEK4014 + XtNumber(tekMenuEntries) #endif ]; TScreen *screen = TScreenOf(xw); memset(result, 0, sizeof(result)); switch (num) { case mainMenu: #if OPT_MAXIMIZE if (resource.fullscreen > 1) { result[mainMenu_fullscreen] = True; } #endif #if OPT_NUM_LOCK if (!screen->alt_is_not_meta) { result[mainMenu_alt_esc] = True; } #endif if (!xtermHasPrinter(xw)) { result[mainMenu_print] = True; result[mainMenu_print_redir] = True; } if (screen->terminal_id < 200) { result[mainMenu_8bit_ctrl] = True; } #if !defined(SIGTSTP) result[mainMenu_suspend] = True; #endif #if !defined(SIGCONT) result[mainMenu_continue] = True; #endif #ifdef ALLOWLOGGING if (screen->inhibit & I_LOG) { result[mainMenu_logging] = True; } #endif if (screen->inhibit & I_SIGNAL) { int n; for (n = (int) mainMenu_suspend; n <= (int) mainMenu_quit; ++n) { result[n] = True; } } break; case vtMenu: #ifndef NO_ACTIVE_ICON if (!getIconicFont(screen)->fs || !screen->iconVwin.window) { result[vtMenu_activeicon] = True; } #endif /* NO_ACTIVE_ICON */ #if OPT_TEK4014 if (screen->inhibit & I_TEK) { int n; for (n = (int) vtMenu_tekshow; n <= (int) vtMenu_vthide; ++n) { result[n] = True; } } #endif break; case fontMenu: break; #if OPT_TEK4014 case tekMenu: break; #endif case noMenu: break; } return result; } /* * create_menu - create a popup shell and stuff the menu into it. */ static Widget create_menu(Widget w, XtermWidget xw, MenuIndex num) { static XtCallbackRec cb[2] = { {NULL, NULL}, {NULL, NULL}}; static Arg arg = {XtNcallback, (XtArgVal) cb}; TScreen *screen = TScreenOf(xw); const MenuHeader *data = &menu_names[num]; MenuList *list = select_menu(w, num); struct _MenuEntry *entries = data->entry_list; Cardinal nentries = data->entry_len; #if !OPT_TOOLBAR String saveLocale; #endif if (screen->menu_item_bitmap == None) { /* * we really want to do these dynamically */ #define check_width 9 #define check_height 8 static unsigned char check_bits[] = { 0x00, 0x01, 0x80, 0x01, 0xc0, 0x00, 0x60, 0x00, 0x31, 0x00, 0x1b, 0x00, 0x0e, 0x00, 0x04, 0x00 }; screen->menu_item_bitmap = XCreateBitmapFromData(XtDisplay(xw), RootWindowOfScreen(XtScreen(xw)), (char *) check_bits, check_width, check_height); } #if !OPT_TOOLBAR saveLocale = setMenuLocale(True, resource.menuLocale); list->w = XtCreatePopupShell(data->internal_name, simpleMenuWidgetClass, toplevel, NULL, 0); #endif if (list->w != 0) { Boolean *unused = unusedEntries(xw, num); Cardinal n; list->entries = 0; for (n = 0; n < nentries; ++n) { if (!unused[n]) { cb[0].callback = (XtCallbackProc) entries[n].function; cb[0].closure = (XtPointer) entries[n].name; entries[n].widget = XtCreateManagedWidget(entries[n].name, (entries[n].function ? smeBSBObjectClass : smeLineObjectClass), list->w, &arg, (Cardinal) 1); list->entries++; } } } #if !OPT_TOOLBAR (void) setMenuLocale(False, saveLocale); #endif /* do not realize at this point */ return list->w; } static MenuIndex indexOfMenu(String menuName) { MenuIndex me; switch (*menuName) { case 'm': me = mainMenu; break; case 'v': me = vtMenu; break; case 'f': me = fontMenu; break; #if OPT_TEK4014 case 't': me = tekMenu; break; #endif default: me = noMenu; } return (me); } /* ARGSUSED */ static Bool domenu(Widget w, XEvent *event GCC_UNUSED, String *params, /* mainMenu, vtMenu, or tekMenu */ Cardinal *param_count) /* 0 or 1 */ { XtermWidget xw = term; TScreen *screen = TScreenOf(xw); MenuIndex me; Bool created = False; Widget mw; if (*param_count != 1) { Bell(xw, XkbBI_MinorError, 0); return False; } if ((me = indexOfMenu(params[0])) == noMenu) { Bell(xw, XkbBI_MinorError, 0); return False; } if ((mw = obtain_menu(w, me)) == 0 || sizeof_menu(w, me) == 0) { mw = create_menu(w, xw, me); created = (mw != 0); } if (mw == 0) return False; TRACE(("domenu(%s) %s\n", params[0], created ? "create" : "update")); switch (me) { case mainMenu: if (created) { update_toolbar(); update_fullscreen(); update_securekbd(); update_allowsends(); update_logging(); update_print_redir(); update_8bit_control(); update_decbkm(); update_num_lock(); update_alt_esc(); update_meta_esc(); update_delete_del(); update_keyboard_type(); #ifdef OPT_PRINT_ON_EXIT screen->write_error = !IsEmpty(resource.printFileOnXError); SetItemSensitivity(mainMenuEntries[mainMenu_write_now].widget, False); SetItemSensitivity(mainMenuEntries[mainMenu_write_error].widget, screen->write_error); #endif } break; case vtMenu: if (created) { update_scrollbar(); update_jumpscroll(); update_reversevideo(); update_autowrap(); update_reversewrap(); update_autolinefeed(); update_appcursor(); update_appkeypad(); update_scrollkey(); update_scrollttyoutput(); update_allow132(); update_cursesemul(); update_keepSelection(); update_selectToClipboard(); update_visualbell(); update_poponbell(); update_bellIsUrgent(); update_cursorblink(); update_altscreen(); update_decsdm(); /* Sixel Display Mode */ update_titeInhibit(); #ifndef NO_ACTIVE_ICON update_activeicon(); #endif /* NO_ACTIVE_ICON */ update_privatecolorregisters(); } break; case fontMenu: if (created) { int n; set_menu_font(True); for (n = fontMenu_font1; n <= fontMenu_font6; ++n) { if (IsEmpty(screen->menu_font_names[n][fNorm])) SetItemSensitivity(fontMenuEntries[n].widget, False); } update_font_escape(); update_menu_allowBoldFonts(); #if OPT_BOX_CHARS update_font_boxchars(); SetItemSensitivity( fontMenuEntries[fontMenu_font_boxchars].widget, True); update_font_packed(); SetItemSensitivity( fontMenuEntries[fontMenu_font_packedfont].widget, True); #endif #if OPT_DEC_SOFTFONT /* FIXME: not implemented */ update_font_loadable(); SetItemSensitivity( fontMenuEntries[fontMenu_font_loadable].widget, False); #endif #if OPT_DEC_CHRSET update_font_doublesize(); if (TScreenOf(xw)->cache_doublesize == 0) SetItemSensitivity( fontMenuEntries[fontMenu_font_doublesize].widget, False); #endif #if OPT_RENDERFONT update_font_renderfont(); #endif #if OPT_WIDE_CHARS update_font_utf8_mode(); update_font_utf8_fonts(); update_font_utf8_title(); #endif #if OPT_ALLOW_XXX_OPS update_menu_allowColorOps(); update_menu_allowFontOps(); update_menu_allowMouseOps(); update_menu_allowTcapOps(); update_menu_allowTitleOps(); update_menu_allowWindowOps(); enable_allow_xxx_ops(!(screen->allowSendEvents)); #endif } #if OPT_TOOLBAR /* menus for toolbar are initialized once only */ SetItemSensitivity(fontMenuEntries[fontMenu_fontsel].widget, True); #else FindFontSelection(xw, NULL, True); SetItemSensitivity(fontMenuEntries[fontMenu_fontsel].widget, (screen->SelectFontName() ? True : False)); #endif break; #if OPT_TEK4014 case tekMenu: if (created && tekWidget) { set_tekfont_menu_item(TekScreenOf(tekWidget)->cur.fontsize, True); update_vtshow(); } break; #endif case noMenu: default: break; } return True; } /* * public interfaces */ void HandleCreateMenu(Widget w, XEvent *event, String *params, /* mainMenu, vtMenu, or tekMenu */ Cardinal *param_count) /* 0 or 1 */ { TRACE(("HandleCreateMenu\n")); (void) domenu(w, event, params, param_count); } void HandlePopupMenu(Widget w, XEvent *event, String *params, /* mainMenu, vtMenu, or tekMenu */ Cardinal *param_count) /* 0 or 1 */ { TRACE(("HandlePopupMenu\n")); if (domenu(w, event, params, param_count)) { XtermWidget xw = term; TScreen *screen = TScreenOf(xw); #if OPT_TOOLBAR w = select_menu(w, mainMenu)->w; #endif /* * The action procedure in SimpleMenu.c, PositionMenu does not expect a * key translation event when we are popping up a menu. In particular, * if the pointer is outside the menu, then the action procedure will * fail in its attempt to determine the location of the pointer within * the menu. Anticipate that by warping the pointer into the menu when * a key event is detected. */ switch (event->type) { case KeyPress: case KeyRelease: XWarpPointer(screen->display, None, XtWindow(w), 0, 0, 0, 0, 0, 0); break; default: XtCallActionProc(w, "XawPositionSimpleMenu", event, params, 1); break; } XtCallActionProc(w, "MenuPopup", event, params, 1); } } /* * private interfaces - keep out! */ /* ARGSUSED */ static void handle_send_signal(Widget gw GCC_UNUSED, int sig) { #ifndef VMS TScreen *screen = TScreenOf(term); if (hold_screen > 1) hold_screen = 0; if (screen->pid > 1) kill_process_group(screen->pid, sig); #endif } static void UpdateMenuItem( #if OPT_TRACE const char *func, #endif MenuEntry * menu, int which, Bool val) { static Arg menuArgs = {XtNleftBitmap, (XtArgVal) 0}; Widget mi = menu[which].widget; if (mi) { menuArgs.value = (XtArgVal) ((val) ? TScreenOf(term)->menu_item_bitmap : None); XtSetValues(mi, &menuArgs, (Cardinal) 1); } TRACE(("%s(%d): %s\n", func, which, MtoS(val))); } void SetItemSensitivity(Widget mi, Bool val) { static Arg menuArgs = {XtNsensitive, (XtArgVal) 0}; if (mi) { menuArgs.value = (XtArgVal) (val); XtSetValues(mi, &menuArgs, (Cardinal) 1); } } /* * action routines */ static void do_securekbd(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { XtermWidget xw = term; TScreen *screen = TScreenOf(xw); Time now = CurrentTime; /* XXX - wrong */ if (screen->grabbedKbd) { XUngrabKeyboard(screen->display, now); ReverseVideo(xw); screen->grabbedKbd = False; } else { if (XGrabKeyboard(screen->display, XtWindow(CURRENT_EMU()), True, GrabModeAsync, GrabModeAsync, now) != GrabSuccess) { Bell(xw, XkbBI_MinorError, 100); } else { ReverseVideo(xw); screen->grabbedKbd = True; } } update_securekbd(); } /* ARGSUSED */ void HandleSecure(Widget w GCC_UNUSED, XEvent *event GCC_UNUSED, /* unused */ String *params GCC_UNUSED, /* [0] = volume */ Cardinal *param_count GCC_UNUSED) /* 0 or 1 */ { do_securekbd(vt_shell[mainMenu].w, (XtPointer) 0, (XtPointer) 0); } static void do_allowsends(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { TScreen *screen = TScreenOf(term); ToggleFlag(screen->allowSendEvents); update_allowsends(); #if OPT_ALLOW_XXX_OPS enable_allow_xxx_ops(!(screen->allowSendEvents)); #endif } static void do_visualbell(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { TScreen *screen = TScreenOf(term); ToggleFlag(screen->visualbell); update_visualbell(); } static void do_bellIsUrgent(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { TScreen *screen = TScreenOf(term); ToggleFlag(screen->bellIsUrgent); update_bellIsUrgent(); } static void do_poponbell(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { TScreen *screen = TScreenOf(term); ToggleFlag(screen->poponbell); update_poponbell(); } #ifdef ALLOWLOGGING static void do_logging(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { XtermWidget xw = term; TScreen *screen = TScreenOf(xw); if (screen->logging) { CloseLog(xw); } else { StartLog(xw); } /* update_logging done by CloseLog and StartLog */ } #endif #ifdef OPT_PRINT_ON_EXIT static void do_write_now(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { XtermWidget xw = term; xtermPrintImmediately(xw, (IsEmpty(resource.printFileNow) ? (String) "XTerm" : resource.printFileNow), resource.printOptsNow, resource.printModeNow); } static void do_write_error(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { XtermWidget xw = term; if (IsEmpty(resource.printFileOnXError)) { resource.printFileOnXError = "XTermError"; } TScreenOf(xw)->write_error = (Boolean) (!TScreenOf(xw)->write_error); update_write_error(); } #endif static void do_print(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { xtermPrintScreen(term, True, getPrinterFlags(term, NULL, 0)); } static void do_print_redir(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { setPrinterControlMode(term, (PrinterOf(TScreenOf(term)).printer_controlmode ? 0 : 2)); } #if OPT_SCREEN_DUMPS static void do_dump_html(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { xtermDumpHtml(term); } static void do_dump_svg(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { xtermDumpSvg(term); } #endif static void do_redraw(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { Redraw(); } void show_8bit_control(Bool value) { if (TScreenOf(term)->control_eight_bits != value) { TScreenOf(term)->control_eight_bits = (Boolean) value; update_8bit_control(); } } static void do_8bit_control(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { show_8bit_control(!TScreenOf(term)->control_eight_bits); } static void do_backarrow(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { term->keyboard.flags ^= MODE_DECBKM; update_decbkm(); } #if OPT_NUM_LOCK static void do_num_lock(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { ToggleFlag(term->misc.real_NumLock); update_num_lock(); } static void do_alt_esc(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { ToggleFlag(TScreenOf(term)->alt_sends_esc); update_alt_esc(); } static void do_meta_esc(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { ToggleFlag(TScreenOf(term)->meta_sends_esc); update_meta_esc(); } #endif static void do_delete_del(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { if (xtermDeleteIsDEL(term)) TScreenOf(term)->delete_is_del = False; else TScreenOf(term)->delete_is_del = True; update_delete_del(); } static void do_old_fkeys(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { toggle_keyboard_type(term, keyboardIsLegacy); } #if OPT_HP_FUNC_KEYS static void do_hp_fkeys(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { toggle_keyboard_type(term, keyboardIsHP); } #endif #if OPT_SCO_FUNC_KEYS static void do_sco_fkeys(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { toggle_keyboard_type(term, keyboardIsSCO); } #endif #if OPT_SUN_FUNC_KEYS static void do_sun_fkeys(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { toggle_keyboard_type(term, keyboardIsSun); } #endif #if OPT_SUNPC_KBD /* * This really means "Sun/PC keyboard emulating VT220". */ static void do_sun_kbd(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { toggle_keyboard_type(term, keyboardIsVT220); } #endif #if OPT_TCAP_FKEYS static void do_tcap_fkeys(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { toggle_keyboard_type(term, keyboardIsTermcap); } #endif /* * The following cases use the pid instead of the process group so that we * don't get hosed by programs that change their process group */ /* ARGSUSED */ static void do_suspend(Widget gw, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { #if defined(SIGTSTP) handle_send_signal(gw, SIGTSTP); #endif } /* ARGSUSED */ static void do_continue(Widget gw, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { #if defined(SIGCONT) handle_send_signal(gw, SIGCONT); #endif } /* ARGSUSED */ static void do_interrupt(Widget gw, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { handle_send_signal(gw, SIGINT); } /* ARGSUSED */ void do_hangup(Widget gw, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { handle_send_signal(gw, SIGHUP); } /* ARGSUSED */ static void do_terminate(Widget gw, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { handle_send_signal(gw, SIGTERM); } /* ARGSUSED */ static void do_kill(Widget gw, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { handle_send_signal(gw, SIGKILL); } static void do_quit(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { Cleanup(SIGHUP); } /* * vt menu callbacks */ static void do_scrollbar(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { ToggleScrollBar(term); } static void do_jumpscroll(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { TScreen *screen = TScreenOf(term); term->flags ^= SMOOTHSCROLL; if (term->flags & SMOOTHSCROLL) { screen->jumpscroll = False; if (screen->scroll_amt) FlushScroll(term); } else { screen->jumpscroll = True; } update_jumpscroll(); } static void do_reversevideo(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { ReverseVideo(term); } static void do_autowrap(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { term->flags ^= WRAPAROUND; update_autowrap(); } static void do_reversewrap(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { term->flags ^= REVERSEWRAP; update_reversewrap(); } static void do_autolinefeed(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { term->flags ^= LINEFEED; update_autolinefeed(); } static void do_appcursor(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { term->keyboard.flags ^= MODE_DECCKM; update_appcursor(); } static void do_appkeypad(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { term->keyboard.flags ^= MODE_DECKPAM; update_appkeypad(); } static void do_scrollkey(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { TScreen *screen = TScreenOf(term); ToggleFlag(screen->scrollkey); update_scrollkey(); } static void do_scrollttyoutput(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { TScreen *screen = TScreenOf(term); ToggleFlag(screen->scrollttyoutput); update_scrollttyoutput(); } static void do_keepClipboard(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { TScreen *screen = TScreenOf(term); ToggleFlag(screen->keepClipboard); update_keepClipboard(); } static void do_keepSelection(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { TScreen *screen = TScreenOf(term); ToggleFlag(screen->keepSelection); update_keepSelection(); } static void do_selectClipboard(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { TScreen *screen = TScreenOf(term); ToggleFlag(screen->selectToClipboard); update_selectToClipboard(); } static void do_allow132(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { TScreen *screen = TScreenOf(term); ToggleFlag(screen->c132); update_allow132(); } static void do_cursesemul(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { TScreen *screen = TScreenOf(term); ToggleFlag(screen->curses); update_cursesemul(); } static void do_marginbell(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { TScreen *screen = TScreenOf(term); if ((ToggleFlag(screen->marginbell)) == 0) screen->bellArmed = -1; update_marginbell(); } #if OPT_TEK4014 static void handle_tekshow(Widget gw GCC_UNUSED, Bool allowswitch) { XtermWidget xw = term; TScreen *screen = TScreenOf(xw); TRACE(("Show tek-window\n")); if (!TEK4014_SHOWN(xw)) { /* not showing, turn on */ set_tek_visibility(True); } else if (screen->Vshow || allowswitch) { /* is showing, turn off */ set_tek_visibility(False); end_tek_mode(); /* WARNING: this does a longjmp */ } else Bell(xw, XkbBI_MinorError, 0); } /* ARGSUSED */ static void do_tekshow(Widget gw, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { handle_tekshow(gw, True); } /* ARGSUSED */ static void do_tekonoff(Widget gw, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { handle_tekshow(gw, False); } #endif /* OPT_TEK4014 */ #if OPT_BLINK_CURS /* ARGSUSED */ static void do_cursorblink(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { TScreen *screen = TScreenOf(term); ToggleCursorBlink(screen); } #endif /* ARGSUSED */ static void do_altscreen(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { ToggleAlternate(term); } /* ARGSUSED */ static void do_titeInhibit(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { ToggleFlag(term->misc.titeInhibit); update_titeInhibit(); } #ifndef NO_ACTIVE_ICON /* ARGSUSED */ static void do_activeicon(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { TScreen *screen = TScreenOf(term); if (screen->iconVwin.window) { Widget shell = XtParent(term); ToggleFlag(term->work.active_icon); XtVaSetValues(shell, XtNiconWindow, term->work.active_icon ? screen->iconVwin.window : None, (XtPointer) 0); update_activeicon(); } } #endif /* NO_ACTIVE_ICON */ static void do_softreset(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { VTReset(term, False, False); } static void do_hardreset(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { VTReset(term, True, False); } static void do_clearsavedlines(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { VTReset(term, True, True); } #if OPT_TEK4014 static void do_tekmode(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { switch_modes(TEK4014_ACTIVE(term)); /* switch to tek mode */ } /* ARGSUSED */ static void do_vthide(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { hide_vt_window(); } #endif /* OPT_TEK4014 */ /* * vtfont menu */ static void do_vtfont(Widget gw GCC_UNUSED, XtPointer closure, XtPointer data GCC_UNUSED) { XtermWidget xw = term; char *entryname = (char *) closure; int i; TRACE(("do_vtfont(%s)\n", entryname)); for (i = 0; i < NMENUFONTS; i++) { if (strcmp(entryname, fontMenuEntries[i].name) == 0) { SetVTFont(xw, i, True, NULL); return; } } Bell(xw, XkbBI_MinorError, 0); } #if OPT_DEC_CHRSET static void do_font_doublesize(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { XtermWidget xw = term; if (TScreenOf(xw)->cache_doublesize != 0) ToggleFlag(TScreenOf(xw)->font_doublesize); update_font_doublesize(); Redraw(); } #endif #if OPT_BOX_CHARS static void do_font_boxchars(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { ToggleFlag(TScreenOf(term)->force_box_chars); update_font_boxchars(); Redraw(); } static void do_font_packed(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { ToggleFlag(TScreenOf(term)->force_packed); update_font_packed(); SetVTFont(term, TScreenOf(term)->menu_font_number, True, NULL); } #endif #if OPT_DEC_SOFTFONT static void do_font_loadable(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { ToggleFlag(term->misc.font_loadable); update_font_loadable(); } #endif #if OPT_RENDERFONT static void do_font_renderfont(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { XtermWidget xw = (XtermWidget) term; TScreen *screen = TScreenOf(xw); int fontnum = screen->menu_font_number; String name = TScreenOf(xw)->MenuFontName(fontnum); DefaultRenderFont(xw); ToggleFlag(xw->work.render_font); update_font_renderfont(); xtermLoadFont(xw, xtermFontName(name), True, fontnum); ScrnRefresh(term, 0, 0, MaxRows(screen), MaxCols(screen), True); } #endif #if OPT_WIDE_CHARS static void setup_wide_fonts(XtermWidget xw) { TScreen *screen = TScreenOf(xw); if (screen->wide_chars) { if (xtermLoadWideFonts(xw, True)) { SetVTFont(xw, screen->menu_font_number, True, NULL); } } else { ChangeToWide(xw); } } static void setup_narrow_fonts(XtermWidget xw) { TScreen *screen = TScreenOf(xw); if (xtermLoadDefaultFonts(xw)) { SetVTFont(xw, screen->menu_font_number, True, NULL); } } static void do_font_utf8_mode(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { XtermWidget xw = term; TScreen *screen = TScreenOf(xw); /* * If xterm was started with -wc option, it might not have the wide fonts. * If xterm was not started with -wc, it might not have wide cells. */ if (!screen->utf8_mode) { setup_wide_fonts(xw); } switchPtyData(screen, !screen->utf8_mode); /* * We don't repaint the screen when switching UTF-8 on/off. When switching * on - the Latin-1 codes should paint as-is. When switching off, that's * hard to do properly. */ } static void do_font_utf8_fonts(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { XtermWidget xw = term; TScreen *screen = TScreenOf(xw); ToggleFlag(screen->utf8_fonts); update_font_utf8_fonts(); if (screen->utf8_fonts) { setup_wide_fonts(xw); } else { setup_narrow_fonts(xw); } } static void do_font_utf8_title(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { TScreen *screen = TScreenOf(term); ToggleFlag(screen->utf8_title); update_font_utf8_title(); } #endif /* * tek menu */ #if OPT_TEK4014 static void do_tektextlarge(Widget gw, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { TekSetFontSize(getTekWidget(gw), True, tekMenu_tektextlarge); } static void do_tektext2(Widget gw, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { TekSetFontSize(getTekWidget(gw), True, tekMenu_tektext2); } static void do_tektext3(Widget gw, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { TekSetFontSize(getTekWidget(gw), True, tekMenu_tektext3); } static void do_tektextsmall(Widget gw, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { TekSetFontSize(getTekWidget(gw), True, tekMenu_tektextsmall); } static void do_tekpage(Widget gw, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { TekSimulatePageButton(getTekWidget(gw), False); } static void do_tekreset(Widget gw, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { TekSimulatePageButton(getTekWidget(gw), True); } static void do_tekcopy(Widget gw, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { TekCopy(getTekWidget(gw)); } static void handle_vtshow(Widget gw GCC_UNUSED, Bool allowswitch) { XtermWidget xw = term; TScreen *screen = TScreenOf(xw); TRACE(("Show vt-window\n")); if (!screen->Vshow) { /* not showing, turn on */ set_vt_visibility(True); } else if (TEK4014_SHOWN(xw) || allowswitch) { /* is showing, turn off */ set_vt_visibility(False); if (!TEK4014_ACTIVE(xw) && tekRefreshList) TekRefresh(tekWidget); end_vt_mode(); /* WARNING: this does a longjmp... */ } else Bell(xw, XkbBI_MinorError, 0); } static void do_vtshow(Widget gw, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { handle_vtshow(gw, True); } static void do_vtonoff(Widget gw, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { handle_vtshow(gw, False); } static void do_vtmode(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { switch_modes(TEK4014_ACTIVE(term)); /* switch to vt, or from */ } /* ARGSUSED */ static void do_tekhide(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { hide_tek_window(); } #endif /* OPT_TEK4014 */ /* * public handler routines */ int decodeToggle(XtermWidget xw, String *params, Cardinal nparams) { int dir = toggleErr; switch (nparams) { case 0: dir = toggleAll; break; case 1: if (XmuCompareISOLatin1(params[0], "on") == 0) dir = toggleOn; else if (XmuCompareISOLatin1(params[0], "off") == 0) dir = toggleOff; else if (XmuCompareISOLatin1(params[0], "toggle") == 0) dir = toggleAll; break; } if (dir == toggleErr) { Bell(xw, XkbBI_MinorError, 0); } return dir; } static void handle_toggle(void (*proc) PROTO_XT_CALLBACK_ARGS, int var, String *params, Cardinal nparams, Widget w, XtPointer closure, XtPointer data) { XtermWidget xw = term; switch (decodeToggle(xw, params, nparams)) { case toggleAll: (*proc) (w, closure, data); break; case toggleOff: if (var) (*proc) (w, closure, data); else Bell(xw, XkbBI_MinorError, 0); break; case toggleOn: if (!var) (*proc) (w, closure, data); else Bell(xw, XkbBI_MinorError, 0); break; } return; } #define handle_vt_toggle(proc, var, params, nparams, w) \ handle_toggle(proc, (int) (var), params, nparams, w, (XtPointer)0, (XtPointer)0) #define HANDLE_VT_TOGGLE(name) \ handle_vt_toggle(do_##name, TScreenOf(term)->name, params, *param_count, w) #define handle_tek_toggle(proc, var, params, nparams, w) \ handle_toggle(proc, (int) (var), params, nparams, w, (XtPointer)0, (XtPointer)0) void HandleAllowSends(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { handle_vt_toggle(do_allowsends, TScreenOf(term)->allowSendEvents, params, *param_count, w); } void HandleSetVisualBell(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { HANDLE_VT_TOGGLE(visualbell); } void HandleSetPopOnBell(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { HANDLE_VT_TOGGLE(poponbell); } #ifdef ALLOWLOGGING void HandleLogging(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { HANDLE_VT_TOGGLE(logging); } #endif #if OPT_PRINT_ON_EXIT void HandleWriteNow(Widget w, XEvent *event GCC_UNUSED, String *params GCC_UNUSED, Cardinal *param_count GCC_UNUSED) { do_write_now(w, 0, 0); } void HandleWriteError(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { HANDLE_VT_TOGGLE(write_error); } #endif /* ARGSUSED */ void HandlePrintScreen(Widget w GCC_UNUSED, XEvent *event GCC_UNUSED, String *params GCC_UNUSED, Cardinal *param_count GCC_UNUSED) { xtermPrintScreen(term, True, getPrinterFlags(term, params, param_count)); } /* ARGSUSED */ void HandlePrintEverything(Widget w GCC_UNUSED, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { xtermPrintEverything(term, getPrinterFlags(term, params, param_count)); } /* ARGSUSED */ void HandlePrintControlMode(Widget w, XEvent *event GCC_UNUSED, String *params GCC_UNUSED, Cardinal *param_count GCC_UNUSED) { do_print_redir(w, (XtPointer) 0, (XtPointer) 0); } /* ARGSUSED */ void HandleRedraw(Widget w, XEvent *event GCC_UNUSED, String *params GCC_UNUSED, Cardinal *param_count GCC_UNUSED) { do_redraw(w, (XtPointer) 0, (XtPointer) 0); } /* ARGSUSED */ void HandleSendSignal(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { /* *INDENT-OFF* */ static const struct sigtab { const char *name; int sig; } signals[] = { #ifdef SIGTSTP { "suspend", SIGTSTP }, { "tstp", SIGTSTP }, #endif #ifdef SIGCONT { "cont", SIGCONT }, #endif { "int", SIGINT }, { "hup", SIGHUP }, { "quit", SIGQUIT }, { "alrm", SIGALRM }, { "alarm", SIGALRM }, { "term", SIGTERM }, { "kill", SIGKILL }, { NULL, 0 }, }; /* *INDENT-ON* */ if (*param_count == 1) { const struct sigtab *st; for (st = signals; st->name; st++) { if (XmuCompareISOLatin1(st->name, params[0]) == 0) { handle_send_signal(w, st->sig); return; } } /* one could allow numeric values, but that would be a security hole */ } Bell(term, XkbBI_MinorError, 0); } /* ARGSUSED */ void HandleQuit(Widget w, XEvent *event GCC_UNUSED, String *params GCC_UNUSED, Cardinal *param_count GCC_UNUSED) { do_quit(w, (XtPointer) 0, (XtPointer) 0); } void Handle8BitControl(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { handle_vt_toggle(do_8bit_control, TScreenOf(term)->control_eight_bits, params, *param_count, w); } void HandleBackarrow(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { handle_vt_toggle(do_backarrow, term->keyboard.flags & MODE_DECBKM, params, *param_count, w); } #if OPT_MAXIMIZE #if OPT_TEK4014 #define WhichEWMH (TEK4014_ACTIVE(xw) != 0) #else #define WhichEWMH 0 #endif static void do_fullscreen(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { XtermWidget xw = term; if (resource.fullscreen != esNever) FullScreen(xw, !xw->work.ewmh[WhichEWMH].mode); } /* ARGSUSED */ void HandleFullscreen(Widget w, XEvent *event GCC_UNUSED, String *params GCC_UNUSED, Cardinal *param_count GCC_UNUSED) { XtermWidget xw = term; if (resource.fullscreen != esNever) { handle_vt_toggle(do_fullscreen, xw->work.ewmh[WhichEWMH].mode, params, *param_count, w); } } void update_fullscreen(void) { XtermWidget xw = term; if (resource.fullscreen <= 1) { UpdateCheckbox("update_fullscreen", mainMenuEntries, mainMenu_fullscreen, xw->work.ewmh[WhichEWMH].mode); } else { SetItemSensitivity(mainMenuEntries[mainMenu_fullscreen].widget, False); } } #endif /* OPT_MAXIMIZE */ #if OPT_SIXEL_GRAPHICS static void do_sixelscrolling(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { term->keyboard.flags ^= MODE_DECSDM; update_decsdm(); } void update_decsdm(void) { UpdateCheckbox("update_decsdm", vtMenuEntries, vtMenu_sixelscrolling, (term->keyboard.flags & MODE_DECSDM) != 0); } void HandleSixelScrolling(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { handle_vt_toggle(do_sixelscrolling, term->keyboard.flags & MODE_DECSDM, params, *param_count, w); } #endif #if OPT_GRAPHICS static void do_privatecolorregisters(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { TScreen *screen = TScreenOf(term); ToggleFlag(screen->privatecolorregisters); update_privatecolorregisters(); } void update_privatecolorregisters(void) { UpdateCheckbox("update_privatecolorregisters", vtMenuEntries, vtMenu_privatecolorregisters, TScreenOf(term)->privatecolorregisters); } void HandleSetPrivateColorRegisters(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { HANDLE_VT_TOGGLE(privatecolorregisters); } #endif #if OPT_SUN_FUNC_KEYS void HandleSunFunctionKeys(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { handle_vt_toggle(do_sun_fkeys, term->keyboard.type == keyboardIsSun, params, *param_count, w); } #endif #if OPT_NUM_LOCK void HandleNumLock(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { handle_vt_toggle(do_num_lock, term->misc.real_NumLock, params, *param_count, w); } void HandleAltEsc(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { handle_vt_toggle(do_alt_esc, !TScreenOf(term)->alt_sends_esc, params, *param_count, w); } void HandleMetaEsc(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { handle_vt_toggle(do_meta_esc, TScreenOf(term)->meta_sends_esc, params, *param_count, w); } #endif void HandleDeleteIsDEL(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { handle_vt_toggle(do_delete_del, TScreenOf(term)->delete_is_del, params, *param_count, w); } void HandleOldFunctionKeys(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { handle_vt_toggle(do_old_fkeys, term->keyboard.type == keyboardIsLegacy, params, *param_count, w); } #if OPT_SUNPC_KBD void HandleSunKeyboard(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { handle_vt_toggle(do_sun_kbd, term->keyboard.type == keyboardIsVT220, params, *param_count, w); } #endif #if OPT_HP_FUNC_KEYS void HandleHpFunctionKeys(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { handle_vt_toggle(do_hp_fkeys, term->keyboard.type == keyboardIsHP, params, *param_count, w); } #endif #if OPT_SCO_FUNC_KEYS void HandleScoFunctionKeys(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { handle_vt_toggle(do_sco_fkeys, term->keyboard.type == keyboardIsSCO, params, *param_count, w); } #endif void HandleScrollbar(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { XtermWidget xw = term; if (IsIcon(TScreenOf(xw))) { Bell(xw, XkbBI_MinorError, 0); } else { handle_vt_toggle(do_scrollbar, TScreenOf(xw)->fullVwin.sb_info.width, params, *param_count, w); } } void HandleJumpscroll(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { HANDLE_VT_TOGGLE(jumpscroll); } void HandleKeepClipboard(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { HANDLE_VT_TOGGLE(keepClipboard); } void HandleKeepSelection(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { HANDLE_VT_TOGGLE(keepSelection); } void HandleSetSelect(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { handle_vt_toggle(do_selectClipboard, TScreenOf(term)->selectToClipboard, params, *param_count, w); } void HandleReverseVideo(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { handle_vt_toggle(do_reversevideo, (term->misc.re_verse0), params, *param_count, w); } void HandleAutoWrap(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { handle_vt_toggle(do_autowrap, (term->flags & WRAPAROUND), params, *param_count, w); } void HandleReverseWrap(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { handle_vt_toggle(do_reversewrap, (term->flags & REVERSEWRAP), params, *param_count, w); } void HandleAutoLineFeed(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { handle_vt_toggle(do_autolinefeed, (term->flags & LINEFEED), params, *param_count, w); } void HandleAppCursor(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { handle_vt_toggle(do_appcursor, (term->keyboard.flags & MODE_DECCKM), params, *param_count, w); } void HandleAppKeypad(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { handle_vt_toggle(do_appkeypad, (term->keyboard.flags & MODE_DECKPAM), params, *param_count, w); } void HandleScrollKey(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { HANDLE_VT_TOGGLE(scrollkey); } void HandleScrollTtyOutput(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { HANDLE_VT_TOGGLE(scrollttyoutput); } void HandleAllow132(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { handle_vt_toggle(do_allow132, TScreenOf(term)->c132, params, *param_count, w); } void HandleCursesEmul(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { handle_vt_toggle(do_cursesemul, TScreenOf(term)->curses, params, *param_count, w); } void HandleBellIsUrgent(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { HANDLE_VT_TOGGLE(bellIsUrgent); } void HandleMarginBell(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { HANDLE_VT_TOGGLE(marginbell); } #if OPT_BLINK_CURS void HandleCursorBlink(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { /* eventually want to see if sensitive or not */ handle_vt_toggle(do_cursorblink, TScreenOf(term)->cursor_blink, params, *param_count, w); } #endif void HandleAltScreen(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { /* eventually want to see if sensitive or not */ handle_vt_toggle(do_altscreen, TScreenOf(term)->whichBuf, params, *param_count, w); } void HandleTiteInhibit(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { /* eventually want to see if sensitive or not */ handle_vt_toggle(do_titeInhibit, !(term->misc.titeInhibit), params, *param_count, w); } /* ARGSUSED */ void HandleSoftReset(Widget w, XEvent *event GCC_UNUSED, String *params GCC_UNUSED, Cardinal *param_count GCC_UNUSED) { do_softreset(w, (XtPointer) 0, (XtPointer) 0); } /* ARGSUSED */ void HandleHardReset(Widget w, XEvent *event GCC_UNUSED, String *params GCC_UNUSED, Cardinal *param_count GCC_UNUSED) { do_hardreset(w, (XtPointer) 0, (XtPointer) 0); } /* ARGSUSED */ void HandleClearSavedLines(Widget w, XEvent *event GCC_UNUSED, String *params GCC_UNUSED, Cardinal *param_count GCC_UNUSED) { do_clearsavedlines(w, (XtPointer) 0, (XtPointer) 0); } void HandleAllowBoldFonts(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { HANDLE_VT_TOGGLE(allowBoldFonts); } #if OPT_LOAD_VTFONTS void update_font_escape(void) { TScreen *screen = TScreenOf(term); SetItemSensitivity(fontMenuEntries[fontMenu_fontescape].widget, ((screen->allowFontOps && screen->EscapeFontName()) ? True : False)); } #endif #if OPT_DEC_CHRSET void HandleFontDoublesize(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { HANDLE_VT_TOGGLE(font_doublesize); } #endif #if OPT_BOX_CHARS void HandleFontBoxChars(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { handle_vt_toggle(do_font_boxchars, TScreenOf(term)->force_box_chars, params, *param_count, w); } void HandleFontPacked(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { handle_vt_toggle(do_font_packed, TScreenOf(term)->force_packed, params, *param_count, w); } #endif #if OPT_DEC_SOFTFONT void HandleFontLoading(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { handle_vt_toggle(do_font_loadable, term->misc.font_loadable, params, *param_count, w); } #endif #if OPT_RENDERFONT static void update_fontmenu(XtermWidget xw) { TScreen *screen = TScreenOf(xw); int n; for (n = 0; n <= fontMenu_lastBuiltin; ++n) { Boolean active = (Boolean) (xw->work.render_font || (screen->menu_font_sizes[n] >= 0)); SetItemSensitivity(fontMenuEntries[n].widget, active); } } void HandleRenderFont(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { XtermWidget xw = (XtermWidget) term; DefaultRenderFont(xw); handle_vt_toggle(do_font_renderfont, xw->work.render_font, params, *param_count, w); update_fontmenu(xw); } #endif #if OPT_WIDE_CHARS void HandleUTF8Mode(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { handle_vt_toggle(do_font_utf8_mode, TScreenOf(term)->utf8_mode, params, *param_count, w); } void HandleUTF8Fonts(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { handle_vt_toggle(do_font_utf8_fonts, TScreenOf(term)->utf8_fonts, params, *param_count, w); } void HandleUTF8Title(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { handle_vt_toggle(do_font_utf8_title, TScreenOf(term)->utf8_title, params, *param_count, w); } #endif #if OPT_SCREEN_DUMPS void HandleDumpHtml(Widget w GCC_UNUSED, XEvent *event GCC_UNUSED, String *params GCC_UNUSED, Cardinal *param_count GCC_UNUSED) { xtermDumpHtml(term); } void HandleDumpSvg(Widget w GCC_UNUSED, XEvent *event GCC_UNUSED, String *params GCC_UNUSED, Cardinal *param_count GCC_UNUSED) { xtermDumpSvg(term); } #endif #if OPT_TEK4014 void HandleSetTerminalType(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { XtermWidget xw = term; if (*param_count == 1) { switch (params[0][0]) { case 'v': case 'V': if (TEK4014_ACTIVE(xw)) do_vtmode(w, (XtPointer) 0, (XtPointer) 0); break; case 't': case 'T': if (!TEK4014_ACTIVE(xw)) do_tekmode(w, (XtPointer) 0, (XtPointer) 0); break; default: Bell(xw, XkbBI_MinorError, 0); } } else { Bell(xw, XkbBI_MinorError, 0); } } void HandleVisibility(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { XtermWidget xw = term; if (*param_count == 2) { switch (params[0][0]) { case 'v': case 'V': handle_tek_toggle(do_vtonoff, (int) TScreenOf(xw)->Vshow, params + 1, (*param_count) - 1, w); break; case 't': case 'T': handle_tek_toggle(do_tekonoff, (int) TEK4014_SHOWN(xw), params + 1, (*param_count) - 1, w); break; default: Bell(xw, XkbBI_MinorError, 0); } } else { Bell(xw, XkbBI_MinorError, 0); } } /* ARGSUSED */ void HandleSetTekText(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { XtermWidget xw = term; void (*proc) PROTO_XT_CALLBACK_ARGS = 0; switch (*param_count) { case 0: proc = do_tektextlarge; break; case 1: switch (TekGetFontSize(params[0])) { case TEK_FONT_LARGE: proc = do_tektextlarge; break; case TEK_FONT_2: proc = do_tektext2; break; case TEK_FONT_3: proc = do_tektext3; break; case TEK_FONT_SMALL: proc = do_tektextsmall; break; } break; } if (proc) (*proc) (w, (XtPointer) 0, (XtPointer) 0); else Bell(xw, XkbBI_MinorError, 0); } /* ARGSUSED */ void HandleTekPage(Widget w, XEvent *event GCC_UNUSED, String *params GCC_UNUSED, Cardinal *param_count GCC_UNUSED) { do_tekpage(w, (XtPointer) 0, (XtPointer) 0); } /* ARGSUSED */ void HandleTekReset(Widget w, XEvent *event GCC_UNUSED, String *params GCC_UNUSED, Cardinal *param_count GCC_UNUSED) { do_tekreset(w, (XtPointer) 0, (XtPointer) 0); } /* ARGSUSED */ void HandleTekCopy(Widget w, XEvent *event GCC_UNUSED, String *params GCC_UNUSED, Cardinal *param_count GCC_UNUSED) { do_tekcopy(w, (XtPointer) 0, (XtPointer) 0); } #endif /* OPT_TEK4014 */ #if OPT_TOOLBAR /* * The normal style of xterm popup menu delays initialization until the menu is * first requested. When using a toolbar, we can use the same initialization, * though on the first popup there will be a little geometry layout jitter, * since the menu is already managed when this callback is invoked. */ static void InitPopup(Widget gw, XtPointer closure, XtPointer data GCC_UNUSED) { String params[2]; Cardinal count = 1; params[0] = (char *) closure; params[1] = 0; TRACE(("InitPopup(%s)\n", params[0])); domenu(gw, (XEvent *) 0, params, &count); XtRemoveCallback(gw, XtNpopupCallback, InitPopup, closure); } static Dimension SetupShell(Widget *menus, MenuList * shell, int n, int m) { char temp[80]; char *external_name = 0; Dimension button_height; Dimension button_border; String saveLocale = setMenuLocale(True, resource.menuLocale); shell[n].w = XtVaCreatePopupShell(menu_names[n].internal_name, simpleMenuWidgetClass, *menus, XtNgeometry, NULL, (XtPointer) 0); XtAddCallback(shell[n].w, XtNpopupCallback, InitPopup, menu_names[n].internal_name); XtVaGetValues(shell[n].w, XtNlabel, &external_name, (XtPointer) 0); TRACE(("...SetupShell(%s) -> %s -> %#lx\n", menu_names[n].internal_name, external_name, (long) shell[n].w)); sprintf(temp, "%sButton", menu_names[n].internal_name); shell[n].b = XtVaCreateManagedWidget(temp, menuButtonWidgetClass, *menus, XtNfromHoriz, ((m >= 0) ? shell[m].b : 0), XtNmenuName, menu_names[n].internal_name, XtNlabel, external_name, (XtPointer) 0); XtVaGetValues(shell[n].b, XtNheight, &button_height, XtNborderWidth, &button_border, (XtPointer) 0); (void) setMenuLocale(False, saveLocale); return (Dimension) (button_height + (button_border * 2)); } #endif /* OPT_TOOLBAR */ void SetupMenus(Widget shell, Widget *forms, Widget *menus, Dimension *menu_high) { #if OPT_TOOLBAR Dimension button_height = 0; Dimension toolbar_hSpace; Arg args[10]; #endif TRACE(("SetupMenus(%s)\n", shell == toplevel ? "vt100" : "tek4014")); *menu_high = 0; if (shell == toplevel) { XawSimpleMenuAddGlobalActions(app_con); XtRegisterGrabAction(HandlePopupMenu, True, (unsigned) (ButtonPressMask | ButtonReleaseMask), GrabModeAsync, GrabModeAsync); } #if OPT_TOOLBAR *forms = XtVaCreateManagedWidget("form", formWidgetClass, shell, (XtPointer) 0); xtermAddInput(*forms); /* * Set a nominal value for the preferred pane size, which lets the * buttons determine the actual height of the menu bar. We don't show * the grip, because it's too easy to make the toolbar look bad that * way. */ XtSetArg(args[0], XtNorientation, XtorientHorizontal); XtSetArg(args[1], XtNtop, XawChainTop); XtSetArg(args[2], XtNbottom, XawChainTop); XtSetArg(args[3], XtNleft, XawChainLeft); XtSetArg(args[4], XtNright, XawChainLeft); if (resource.toolBar) { *menus = XtCreateManagedWidget("menubar", boxWidgetClass, *forms, args, 5); } else { *menus = XtCreateWidget("menubar", boxWidgetClass, *forms, args, 5); } /* * The toolbar widget's height is not necessarily known yet. If the * toolbar is not created as a managed widget, we can still make a good * guess about its height by collecting the widget's other resource values. */ XtVaGetValues(*menus, XtNhSpace, &toolbar_hSpace, (XtPointer) 0); if (shell == toplevel) { /* vt100 */ int j; for (j = mainMenu; j <= fontMenu; j++) { button_height = SetupShell(menus, vt_shell, j, j - 1); } } #if OPT_TEK4014 else { /* tek4014 */ (void) SetupShell(menus, tek_shell, mainMenu, -1); button_height = SetupShell(menus, tek_shell, tekMenu, mainMenu); } #endif /* * Tell the main program how high the toolbar is, to help with the initial * layout. */ *menu_high = (Dimension) (button_height + 2 * (toolbar_hSpace)); TRACE(("...menuHeight:%d = (%d + 2 * %d)\n", *menu_high, button_height, toolbar_hSpace)); #else /* !OPT_TOOLBAR */ *forms = shell; *menus = shell; #endif TRACE(("...shell=%#lx\n", (long) shell)); TRACE(("...forms=%#lx\n", (long) *forms)); TRACE(("...menus=%#lx\n", (long) *menus)); } void repairSizeHints(void) { XtermWidget xw = term; TScreen *screen = TScreenOf(xw); if (XtIsRealized((Widget) xw)) { getXtermSizeHints(xw); xtermSizeHints(xw, ScrollbarWidth(screen)); XSetWMNormalHints(screen->display, VShellWindow(xw), &xw->hints); } } #if OPT_TOOLBAR #define INIT_POPUP(s, n) InitPopup(s[n].w, menu_names[n].internal_name, 0) static Bool InitWidgetMenu(Widget shell) { Bool result = False; TRACE(("InitWidgetMenu(%p)\n", (void *) shell)); if (term != 0) { if (shell == toplevel) { /* vt100 */ if (!term->init_menu) { INIT_POPUP(vt_shell, mainMenu); INIT_POPUP(vt_shell, vtMenu); INIT_POPUP(vt_shell, fontMenu); term->init_menu = True; TRACE(("...InitWidgetMenu(vt)\n")); } result = term->init_menu; } #if OPT_TEK4014 else if (tekWidget) { /* tek4014 */ if (!tekWidget->init_menu) { INIT_POPUP(tek_shell, mainMenu); INIT_POPUP(tek_shell, tekMenu); tekWidget->init_menu = True; TRACE(("...InitWidgetMenu(tek)\n")); } result = tekWidget->init_menu; } #endif } TRACE(("...InitWidgetMenu ->%d\n", result)); return result; } static TbInfo * toolbar_info(Widget w) { TRACE(("...getting toolbar_info\n")); #if OPT_TEK4014 if (w != (Widget) term) return &(tekWidget->tek.tb_info); #else (void) w; #endif return &(WhichVWin(TScreenOf(term))->tb_info); } static void hide_toolbar(Widget w) { if (w != 0) { TbInfo *info = toolbar_info(w); TRACE(("hiding toolbar\n")); XtVaSetValues(w, XtNfromVert, (Widget) 0, (XtPointer) 0); if (info->menu_bar != 0) { repairSizeHints(); XtUnmanageChild(info->menu_bar); if (XtIsRealized(info->menu_bar)) { XtUnmapWidget(info->menu_bar); } } TRACE(("...hiding toolbar (done)\n")); } } static void show_toolbar(Widget w) { if (w != 0) { TbInfo *info = toolbar_info(w); TRACE(("showing toolbar\n")); if (info->menu_bar != 0) { XtVaSetValues(w, XtNfromVert, info->menu_bar, (XtPointer) 0); if (XtIsRealized(info->menu_bar)) repairSizeHints(); XtManageChild(info->menu_bar); if (XtIsRealized(info->menu_bar)) { XtMapWidget(info->menu_bar); } } /* * This is needed to make the terminal widget move down below the * toolbar. */ XawFormDoLayout(XtParent(w), True); TRACE(("...showing toolbar (done)\n")); } } /* * Make the toolbar visible or invisible in the current window(s). */ void ShowToolbar(Bool enable) { XtermWidget xw = term; TRACE(("ShowToolbar(%d)\n", enable)); if (IsIcon(TScreenOf(xw))) { Bell(xw, XkbBI_MinorError, 0); } else { if (enable) { if (InitWidgetMenu(toplevel)) show_toolbar((Widget) xw); #if OPT_TEK4014 if (InitWidgetMenu(tekshellwidget)) show_toolbar((Widget) tekWidget); #endif } else { hide_toolbar((Widget) xw); #if OPT_TEK4014 hide_toolbar((Widget) tekWidget); #endif } resource.toolBar = (Boolean) enable; update_toolbar(); } } void HandleToolbar(Widget w, XEvent *event GCC_UNUSED, String *params GCC_UNUSED, Cardinal *param_count GCC_UNUSED) { XtermWidget xw = term; if (IsIcon(TScreenOf(xw))) { Bell(xw, XkbBI_MinorError, 0); } else { handle_vt_toggle(do_toolbar, resource.toolBar, params, *param_count, w); } } /* ARGSUSED */ static void do_toolbar(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { XtermWidget xw = term; /* * Toggle toolbars for both vt100 and tek windows, since they share the * menu which contains the checkbox indicating whether the toolbar is * active. */ if (IsIcon(TScreenOf(xw))) { Bell(xw, XkbBI_MinorError, 0); } else { ShowToolbar(ToggleFlag(resource.toolBar)); } } void update_toolbar(void) { UpdateCheckbox("update_toolbar", mainMenuEntries, mainMenu_toolbar, resource.toolBar); } #endif /* OPT_TOOLBAR */ void update_securekbd(void) { UpdateCheckbox("update_securekbd", mainMenuEntries, mainMenu_securekbd, TScreenOf(term)->grabbedKbd); } void update_allowsends(void) { UpdateCheckbox("update_allowsends", mainMenuEntries, mainMenu_allowsends, TScreenOf(term)->allowSendEvents); } #ifdef ALLOWLOGGING void update_logging(void) { UpdateCheckbox("update_logging", mainMenuEntries, mainMenu_logging, TScreenOf(term)->logging); } #endif #if OPT_PRINT_ON_EXIT void update_write_error(void) { UpdateCheckbox("update_write_error", mainMenuEntries, mainMenu_write_error, TScreenOf(term)->write_error); } #endif void update_print_redir(void) { UpdateCheckbox("update_print_redir", mainMenuEntries, mainMenu_print_redir, PrinterOf(TScreenOf(term)).printer_controlmode); } void update_8bit_control(void) { UpdateCheckbox("update_8bit_control", mainMenuEntries, mainMenu_8bit_ctrl, TScreenOf(term)->control_eight_bits); } void update_decbkm(void) { UpdateCheckbox("update_decbkm", mainMenuEntries, mainMenu_backarrow, (term->keyboard.flags & MODE_DECBKM) != 0); } #if OPT_NUM_LOCK void update_num_lock(void) { UpdateCheckbox("update_num_lock", mainMenuEntries, mainMenu_num_lock, term->misc.real_NumLock); } void update_alt_esc(void) { UpdateCheckbox("update_alt_esc", mainMenuEntries, mainMenu_alt_esc, TScreenOf(term)->alt_sends_esc); } void update_meta_esc(void) { UpdateCheckbox("update_meta_esc", mainMenuEntries, mainMenu_meta_esc, TScreenOf(term)->meta_sends_esc); } #endif #if OPT_SUN_FUNC_KEYS void update_sun_fkeys(void) { UpdateCheckbox("update_sun_fkeys", mainMenuEntries, mainMenu_sun_fkeys, term->keyboard.type == keyboardIsSun); } #endif #if OPT_TCAP_FKEYS void update_tcap_fkeys(void) { UpdateCheckbox("update_tcap_fkeys", mainMenuEntries, mainMenu_tcap_fkeys, term->keyboard.type == keyboardIsTermcap); } #endif void update_old_fkeys(void) { UpdateCheckbox("update_old_fkeys", mainMenuEntries, mainMenu_old_fkeys, term->keyboard.type == keyboardIsLegacy); } void update_delete_del(void) { UpdateCheckbox("update_delete_del", mainMenuEntries, mainMenu_delete_del, xtermDeleteIsDEL(term)); } #if OPT_SUNPC_KBD void update_sun_kbd(void) { UpdateCheckbox("update_sun_kbd", mainMenuEntries, mainMenu_sun_kbd, term->keyboard.type == keyboardIsVT220); } #endif #if OPT_HP_FUNC_KEYS void update_hp_fkeys(void) { UpdateCheckbox("update_hp_fkeys", mainMenuEntries, mainMenu_hp_fkeys, term->keyboard.type == keyboardIsHP); } #endif #if OPT_SCO_FUNC_KEYS void update_sco_fkeys(void) { UpdateCheckbox("update_sco_fkeys", mainMenuEntries, mainMenu_sco_fkeys, term->keyboard.type == keyboardIsSCO); } #endif void update_scrollbar(void) { UpdateCheckbox("update_scrollbar", vtMenuEntries, vtMenu_scrollbar, ScrollbarWidth(TScreenOf(term))); } void update_jumpscroll(void) { UpdateCheckbox("update_jumpscroll", vtMenuEntries, vtMenu_jumpscroll, TScreenOf(term)->jumpscroll); } void update_reversevideo(void) { UpdateCheckbox("update_reversevideo", vtMenuEntries, vtMenu_reversevideo, (term->misc.re_verse)); } void update_autowrap(void) { UpdateCheckbox("update_autowrap", vtMenuEntries, vtMenu_autowrap, (term->flags & WRAPAROUND) != 0); } void update_reversewrap(void) { UpdateCheckbox("update_reversewrap", vtMenuEntries, vtMenu_reversewrap, (term->flags & REVERSEWRAP) != 0); } void update_autolinefeed(void) { UpdateCheckbox("update_autolinefeed", vtMenuEntries, vtMenu_autolinefeed, (term->flags & LINEFEED) != 0); } void update_appcursor(void) { UpdateCheckbox("update_appcursor", vtMenuEntries, vtMenu_appcursor, (term->keyboard.flags & MODE_DECCKM) != 0); } void update_appkeypad(void) { UpdateCheckbox("update_appkeypad", vtMenuEntries, vtMenu_appkeypad, (term->keyboard.flags & MODE_DECKPAM) != 0); } void update_scrollkey(void) { UpdateCheckbox("update_scrollkey", vtMenuEntries, vtMenu_scrollkey, TScreenOf(term)->scrollkey); } void update_scrollttyoutput(void) { UpdateCheckbox("update_scrollttyoutput", vtMenuEntries, vtMenu_scrollttyoutput, TScreenOf(term)->scrollttyoutput); } void update_keepSelection(void) { UpdateCheckbox("update_keepSelection", vtMenuEntries, vtMenu_keepSelection, TScreenOf(term)->keepSelection); } void update_selectToClipboard(void) { UpdateCheckbox("update_selectToClipboard", vtMenuEntries, vtMenu_selectToClipboard, TScreenOf(term)->selectToClipboard); } void update_allow132(void) { UpdateCheckbox("update_allow132", vtMenuEntries, vtMenu_allow132, TScreenOf(term)->c132); } void update_cursesemul(void) { #if 0 /* 2006-2-12: no longer menu entry */ UpdateMenuItem("update_cursesemul", vtMenuEntries, vtMenu_cursesemul, TScreenOf(term)->curses); #endif } void update_visualbell(void) { UpdateCheckbox("update_visualbell", vtMenuEntries, vtMenu_visualbell, TScreenOf(term)->visualbell); } void update_bellIsUrgent(void) { UpdateCheckbox("update_bellIsUrgent", vtMenuEntries, vtMenu_bellIsUrgent, TScreenOf(term)->bellIsUrgent); } void update_poponbell(void) { UpdateCheckbox("update_poponbell", vtMenuEntries, vtMenu_poponbell, TScreenOf(term)->poponbell); } #ifndef update_marginbell /* 2007-3-7: no longer menu entry */ void update_marginbell(void) { UpdateCheckbox("update_marginbell", vtMenuEntries, vtMenu_marginbell, TScreenOf(term)->marginbell); } #endif #if OPT_BLINK_CURS void update_cursorblink(void) { UpdateCheckbox("update_cursorblink", vtMenuEntries, vtMenu_cursorblink, TScreenOf(term)->cursor_blink); } #endif void update_altscreen(void) { UpdateCheckbox("update_altscreen", vtMenuEntries, vtMenu_altscreen, TScreenOf(term)->whichBuf); } void update_titeInhibit(void) { UpdateCheckbox("update_titeInhibit", vtMenuEntries, vtMenu_titeInhibit, !(term->misc.titeInhibit)); } #ifndef NO_ACTIVE_ICON void update_activeicon(void) { UpdateCheckbox("update_activeicon", vtMenuEntries, vtMenu_activeicon, term->work.active_icon); } #endif /* NO_ACTIVE_ICON */ static void do_allowBoldFonts(Widget w, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { XtermWidget xw = getXtermWidget(w); if (xw != 0) { ToggleFlag(TScreenOf(xw)->allowBoldFonts); update_menu_allowBoldFonts(); Redraw(); } } #if OPT_DEC_CHRSET void update_font_doublesize(void) { UpdateCheckbox("update_font_doublesize", fontMenuEntries, fontMenu_font_doublesize, TScreenOf(term)->font_doublesize); } #endif #if OPT_BOX_CHARS void update_font_boxchars(void) { UpdateCheckbox("update_font_boxchars", fontMenuEntries, fontMenu_font_boxchars, TScreenOf(term)->force_box_chars); } void update_font_packed(void) { UpdateCheckbox("update_font_packed", fontMenuEntries, fontMenu_font_packedfont, TScreenOf(term)->force_packed); } #endif #if OPT_DEC_SOFTFONT void update_font_loadable(void) { UpdateCheckbox("update_font_loadable", fontMenuEntries, fontMenu_font_loadable, term->misc.font_loadable); } #endif #if OPT_RENDERFONT void update_font_renderfont(void) { UpdateCheckbox("update_font_renderfont", fontMenuEntries, fontMenu_render_font, (term->work.render_font == True)); SetItemSensitivity(fontMenuEntries[fontMenu_render_font].widget, !IsEmpty(CurrentXftFont(term))); update_fontmenu(term); } #endif #if OPT_WIDE_CHARS void update_font_utf8_mode(void) { Bool active = (TScreenOf(term)->utf8_mode != uAlways); Bool enable = (TScreenOf(term)->utf8_mode != uFalse); TRACE(("update_font_utf8_mode active %d, enable %d\n", active, enable)); SetItemSensitivity(fontMenuEntries[fontMenu_utf8_mode].widget, active); UpdateCheckbox("update_font_utf8_mode", fontMenuEntries, fontMenu_utf8_mode, enable); } void update_font_utf8_fonts(void) { Bool active = (TScreenOf(term)->utf8_fonts != uAlways); Bool enable = (TScreenOf(term)->utf8_fonts != uFalse); TRACE(("update_font_utf8_fonts active %d, enable %d\n", active, enable)); SetItemSensitivity(fontMenuEntries[fontMenu_utf8_fonts].widget, active); UpdateCheckbox("update_font_utf8_fonts", fontMenuEntries, fontMenu_utf8_fonts, enable); } void update_font_utf8_title(void) { Bool active = (TScreenOf(term)->utf8_mode != uFalse); Bool enable = (TScreenOf(term)->utf8_title); TRACE(("update_font_utf8_title active %d, enable %d\n", active, enable)); SetItemSensitivity(fontMenuEntries[fontMenu_utf8_title].widget, active); UpdateCheckbox("update_font_utf8_title", fontMenuEntries, fontMenu_utf8_title, enable); } #endif #if OPT_DEC_CHRSET || OPT_BOX_CHARS || OPT_DEC_SOFTFONT void update_menu_allowBoldFonts(void) { UpdateCheckbox("update_menu_allowBoldFonts", fontMenuEntries, fontMenu_allowBoldFonts, TScreenOf(term)->allowBoldFonts); } #endif #if OPT_ALLOW_XXX_OPS static void enable_allow_xxx_ops(Bool enable) { SetItemSensitivity(fontMenuEntries[fontMenu_allowFontOps].widget, enable); SetItemSensitivity(fontMenuEntries[fontMenu_allowMouseOps].widget, enable); SetItemSensitivity(fontMenuEntries[fontMenu_allowTcapOps].widget, enable); SetItemSensitivity(fontMenuEntries[fontMenu_allowTitleOps].widget, enable); SetItemSensitivity(fontMenuEntries[fontMenu_allowWindowOps].widget, enable); } static void do_allowColorOps(Widget w, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { XtermWidget xw = getXtermWidget(w); if (xw != 0) { ToggleFlag(TScreenOf(xw)->allowColorOps); update_menu_allowColorOps(); } } static void do_allowFontOps(Widget w, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { XtermWidget xw = getXtermWidget(w); if (xw != 0) { ToggleFlag(TScreenOf(xw)->allowFontOps); update_menu_allowFontOps(); } } static void do_allowMouseOps(Widget w, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { XtermWidget xw = getXtermWidget(w); if (xw != 0) { ToggleFlag(TScreenOf(xw)->allowMouseOps); update_menu_allowMouseOps(); } } static void do_allowTcapOps(Widget w, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { XtermWidget xw = getXtermWidget(w); if (xw != 0) { ToggleFlag(TScreenOf(xw)->allowTcapOps); update_menu_allowTcapOps(); } } static void do_allowTitleOps(Widget w, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { XtermWidget xw = getXtermWidget(w); if (xw != 0) { ToggleFlag(TScreenOf(xw)->allowTitleOps); update_menu_allowTitleOps(); } } static void do_allowWindowOps(Widget w, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { XtermWidget xw = getXtermWidget(w); if (xw != 0) { ToggleFlag(TScreenOf(xw)->allowWindowOps); update_menu_allowWindowOps(); } } void HandleAllowColorOps(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { HANDLE_VT_TOGGLE(allowColorOps); } void HandleAllowFontOps(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { HANDLE_VT_TOGGLE(allowFontOps); } void HandleAllowMouseOps(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { HANDLE_VT_TOGGLE(allowMouseOps); } void HandleAllowTcapOps(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { HANDLE_VT_TOGGLE(allowTcapOps); } void HandleAllowTitleOps(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { HANDLE_VT_TOGGLE(allowTitleOps); } void HandleAllowWindowOps(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { HANDLE_VT_TOGGLE(allowWindowOps); } void update_menu_allowColorOps(void) { UpdateCheckbox("update_menu_allowColorOps", fontMenuEntries, fontMenu_allowColorOps, TScreenOf(term)->allowColorOps); } void update_menu_allowFontOps(void) { UpdateCheckbox("update_menu_allowFontOps", fontMenuEntries, fontMenu_allowFontOps, TScreenOf(term)->allowFontOps); } void update_menu_allowMouseOps(void) { UpdateCheckbox("update_menu_allowMouseOps", fontMenuEntries, fontMenu_allowMouseOps, TScreenOf(term)->allowMouseOps); } void update_menu_allowTcapOps(void) { UpdateCheckbox("update_menu_allowTcapOps", fontMenuEntries, fontMenu_allowTcapOps, TScreenOf(term)->allowTcapOps); } void update_menu_allowTitleOps(void) { UpdateCheckbox("update_menu_allowTitleOps", fontMenuEntries, fontMenu_allowTitleOps, TScreenOf(term)->allowTitleOps); } void update_menu_allowWindowOps(void) { UpdateCheckbox("update_menu_allowWindowOps", fontMenuEntries, fontMenu_allowWindowOps, TScreenOf(term)->allowWindowOps); } #endif #if OPT_TEK4014 void update_tekshow(void) { if (!(TScreenOf(term)->inhibit & I_TEK)) { UpdateCheckbox("update_tekshow", vtMenuEntries, vtMenu_tekshow, TEK4014_SHOWN(term)); } } void update_vttekmode(void) { XtermWidget xw = term; if (!(TScreenOf(xw)->inhibit & I_TEK)) { UpdateCheckbox("update_vtmode", vtMenuEntries, vtMenu_tekmode, TEK4014_ACTIVE(xw)); UpdateCheckbox("update_tekmode", tekMenuEntries, tekMenu_vtmode, !TEK4014_ACTIVE(xw)); update_fullscreen(); } } void update_vtshow(void) { if (!(TScreenOf(term)->inhibit & I_TEK)) { UpdateCheckbox("update_vtshow", tekMenuEntries, tekMenu_vtshow, TScreenOf(term)->Vshow); } } void set_vthide_sensitivity(void) { if (!(TScreenOf(term)->inhibit & I_TEK)) { SetItemSensitivity( vtMenuEntries[vtMenu_vthide].widget, TEK4014_SHOWN(term)); } } void set_tekhide_sensitivity(void) { if (!(TScreenOf(term)->inhibit & I_TEK)) { SetItemSensitivity( tekMenuEntries[tekMenu_tekhide].widget, TScreenOf(term)->Vshow); } } void set_tekfont_menu_item(int n, int val) { if (!(TScreenOf(term)->inhibit & I_TEK)) { UpdateCheckbox("set_tekfont_menu_item", tekMenuEntries, FS2MI(n), (val)); } } #endif /* OPT_TEK4014 */ void set_menu_font(int val) { UpdateCheckbox("set_menu_font", fontMenuEntries, TScreenOf(term)->menu_font_number, (val)); } xterm-330/vms.c0000644000175100001440000004315411454542517012227 0ustar tomusers/* $XTermId: vms.c,v 1.13 2010/10/11 08:05:35 tom Exp $ */ /* vms.c * * This module contains the VMS version of the routine SPAWN (from the module * MAIN.C) and the routines that do IO to the pseudo terminal. * * Modification History: * Stephan Jansen 1-Mar-1990 Original version * Hal R. Brand 5-Sep-1990 Added code to propagate DECW$DISPLAY * Aaron Leonard 11-Sep-1990 Fix string descriptor lengths * Stephan Jansen 2-Dec-1991 Modify to use new Pseudo terminal drivers * (patterned after photo.c by Forrest A. Kenney) * Patrick Mahan 7-Jan-1991 Removed reference to from VMS.C * Forced device type to be VT102 since that is * what we are emulating. */ #include #include #include #include #include "xterm.h" #include "data.h" #include "vms.h" #define PTD$C_SEND_XON 0 /* Pseudo Terminal Driver event */ #define PTD$C_SEND_BELL 1 #define PTD$C_SEND_XOFF 2 #define PTD$C_STOP_OUTPUT 3 #define PTD$C_RESUME_OUTPUT 4 #define PTD$C_CHAR_CHANGED 5 #define PTD$C_ABORT_OUTPUT 6 #define PTD$C_START_READ 7 #define PTD$C_MIDDLE_READ 8 #define PTD$C_END_READ 9 #define PTD$C_ENABLE_READ 10 #define PTD$C_DISABLE_READ 11 #define PTD$C_MAX_EVENTS 12 #define BUFFERS 6 #define PAGE 512 typedef struct tt_buffer { unsigned int flink; unsigned int blink; short int status; short int length; char data[VMS_TERM_BUFFER_SIZE]; } TT_BUF_STRUCT; TT_BUF_STRUCT *tt_w_buff; struct q_head _align(QUADWORD) buffer_queue = (0,0); struct q_head _align(QUADWORD) read_queue = (0,0); static char tt_name[64]; static $DESCRIPTOR (tt_name_desc, &tt_name); static char ws_name[64]; static $DESCRIPTOR (ws_name_desc, &ws_name); static struct tt_char { char class; char type; short int page_width; char characteristics[3]; char length; int extended; } tt_mode, tt_chars, orig_tt_chars; struct mem_region { TT_BUF_STRUCT *start; TT_BUF_STRUCT *end; } ret_addr; int read_stopped = False; int write_stopped = False; int tt_width; int tt_length; int tt_changed; int tt_pasting=False; /* drm */ int tt_new_output=False; /* Cleared by flushlog(), set whenever something new goes to the screen through tt_write */ int trnlnm(char *in,int id,char *out); void spawn (void); static void tt_echo_ast(TT_BUF_STRUCT *buff_addr); static void tt_read_ast(TT_BUF_STRUCT *buff_addr); /* static void tt_start_read(void); */ void tt_start_read(void); int tt_read(char *buffer); static void send_xon(void); static void send_xoff(void); static void send_bell(void); static void char_change(void); static void freeBuff (TT_BUF_STRUCT *buff_addr); TT_BUF_STRUCT *getBuff(void); static void CloseDown(int exit_status); static void mbx_read_ast(void); static void mbx_read(void); #define DESCRIPTOR(name,string) struct dsc$descriptor_s name = \ { strlen(string), DSC$K_DTYPE_T, DSC$K_CLASS_S, string } int trnlnm(char *in, int id, char *out) { int status, num, len, attr = LNM$M_CASE_BLIND, foo = id; short outlen; struct itemlist { short buffer_length; short item_code; char *buffer_addr; int *return_length; } itmlst[] = { 4 , LNM$_INDEX , &foo, 0, 255, LNM$_STRING , out , &outlen, 4 , LNM$_MAX_INDEX, &num, &len, 0 , 0 }; DESCRIPTOR(lognam,in); DESCRIPTOR(tabnam,"LNM$DCL_LOGICAL"); status = sys$trnlnm(&attr,&tabnam,&lognam,0,itmlst); if(status != SS$_NORMAL) return(-1); /* error status */ out[outlen] = 0; /* terminate the output string */ return(++num); /* return number of translations */ } static int pty; static int Xsocket; void spawn (void) { int status; static $DESCRIPTOR (dtime, "0 00:00:00.01"); static int delta[2]; register TScreen *screen = TScreenOf(term); static struct IOSB iosb; static unsigned int flags; static unsigned int uic; static char imagename[64]; static int privs; static $DESCRIPTOR(device, "FTA0:"); static int type; static int class; static int devdepend; static int mem_size; int i; /* if pid and mbx_chan are nonzero then close them in CloseDown() */ pid = 0; mbx_chan = 0; status = SYS$EXPREG (BUFFERS, &ret_addr, 0, 0); if(!(status & SS$_NORMAL)) lib$signal(status); tt_w_buff = (char *)ret_addr.end - PAGE + 1; /* use one buffer for writing, the reset go in the free buffer queue */ for(i=0; i < BUFFERS-1; i++) { freeBuff((char *)ret_addr.start +i*PAGE); } /* avoid double MapWindow requests, for wm's that care... */ XtSetMappedWhenManaged( screen->TekEmu ? XtParent(tekWidget) : XtParent(term), False ); /* Realize the Tek or VT widget, depending on which mode we're in. If VT mode, this calls VTRealize (the widget's Realize proc) */ XtRealizeWidget (screen->TekEmu ? XtParent(tekWidget) : XtParent(term)); /* get the default device characteristics of the pseudo terminal */ itemlist[0].buflen = 4; itemlist[0].code = DVI$_DEVTYPE; itemlist[0].buffer = &type; itemlist[0].return_addr = &tt_name_desc.dsc$w_length; itemlist[1].buflen = 4; itemlist[1].code = DVI$_DEVCLASS; itemlist[1].buffer = &class; itemlist[1].return_addr = &tt_name_desc.dsc$w_length; itemlist[2].buflen = 4; itemlist[2].code = DVI$_DEVDEPEND; itemlist[2].buffer = &devdepend; itemlist[2].return_addr = &tt_name_desc.dsc$w_length; itemlist[3].buflen = 4; itemlist[3].code = DVI$_DEVDEPEND2; itemlist[3].buffer = &tt_chars.extended; itemlist[3].return_addr = &tt_name_desc.dsc$w_length; itemlist[4].buflen = 0; itemlist[4].code = 0; status = sys$getdviw(0,0,&device,&itemlist,&iosb,0,0,0); if(!(status & SS$_NORMAL)) lib$signal(status); if(!(iosb.status & SS$_NORMAL)) lib$signal(iosb.status); tt_chars.type = DT$_VT102; /* XTerm supports VT102 mode */ tt_chars.class = class; tt_chars.page_width = screen->max_col+1; tt_chars.length = screen->max_row+1; /* copy the default char's along with the created window size */ bcopy(&devdepend, &tt_chars.characteristics, 3); tt_chars.extended |= TT2$M_ANSICRT | TT2$M_AVO | TT2$M_DECCRT; /* create the pseudo terminal with the proper char's */ status = ptd$create(&tt_chan,0,&tt_chars,12,0,0,0,&ret_addr); if(!(status & SS$_NORMAL)) lib$signal(status); /* get the device name of the Pseudo Terminal */ itemlist[0].buflen = 64; itemlist[0].code = DVI$_DEVNAM; itemlist[0].buffer = &tt_name; itemlist[0].return_addr = &tt_name_desc.dsc$w_length; /* terminate the list */ itemlist[1].buflen = 0; itemlist[1].code = 0; status = sys$getdviw(0,tt_chan,0,&itemlist,&iosb,0,0,0); if(!(status & SS$_NORMAL)) CloseDown(status); if(!(iosb.status & SS$_NORMAL)) CloseDown(iosb.status); /* * set up AST's for XON, XOFF, BELL and characteristics change. */ status = ptd$set_event_notification(tt_chan,&send_xon,0,0,PTD$C_SEND_XON); if(!(status & SS$_NORMAL)) CloseDown(status); status = ptd$set_event_notification(tt_chan,&send_xoff,0,0,PTD$C_SEND_XOFF); if(!(status & SS$_NORMAL)) CloseDown(status); status = ptd$set_event_notification(tt_chan,&send_bell,0,0,PTD$C_SEND_BELL); if(!(status & SS$_NORMAL)) CloseDown(status); status = ptd$set_event_notification(tt_chan,&char_change,0,0,PTD$C_CHAR_CHANGED); if(!(status & SS$_NORMAL)) CloseDown(status); /* create a mailbox for the detached process to detect hangup */ status = sys$crembx(0,&mbx_chan,ACC$K_TERMLEN,0,255,0,0); if(!(status & SS$_NORMAL)) CloseDown(status); /* * get the device unit number for created process completion * status to be sent to. */ itemlist[0].buflen = 4; itemlist[0].code = DVI$_UNIT; itemlist[0].buffer = &mbxunit; itemlist[0].return_addr = 0; /* terminate the list */ itemlist[1].buflen = 0; itemlist[1].code = 0; status = sys$getdviw(0,mbx_chan,0,&itemlist,&iosb,0,0,0); if(!(status & SS$_NORMAL)) CloseDown(status); if(!(iosb.status & SS$_NORMAL)) CloseDown(iosb.status); tt_start_read(); /* * find the current process's UIC so that it can be used in the * call to sys$creprc */ itemlist[0].buflen = 4; itemlist[0].code = JPI$_UIC; itemlist[0].buffer = &uic; itemlist[0].return_addr = 0; /* terminate the list */ itemlist[1].buflen = 0; itemlist[1].code = 0; status = sys$getjpiw(0,0,0,&itemlist,0,0,0); if(!(status & SS$_NORMAL)) CloseDown(status); /* Complete a descriptor for the WS (DECW$DISPLAY) device */ trnlnm("DECW$DISPLAY",0,ws_name); ws_name_desc.dsc$w_length = strlen(ws_name); /* create the process */ /* Set sys$error to be the WS (DECW$DISPLAY) device. LOGINOUT */ /* has special code for DECWINDOWS that will: */ /* 1) do a DEFINE/JOB DECW$DISPLAY 'f$trnlnm(sys$error)' */ /* 2) then redefine SYS$ERROR to match SYS$OUTPUT! */ /* This will propogate DECW$DISPLAY to the XTERM process!!! */ /* Thanks go to Joel M Snyder who posted this info to INFO-VAX */ flags = PRC$M_INTER | PRC$M_NOPASSWORD | PRC$M_DETACH; status = sys$creprc(&pid,&image,&tt_name_desc,&tt_name_desc, &ws_name_desc,0,0,0,4,uic,mbxunit,flags); if(!(status & SS$_NORMAL)) CloseDown(status); /* hang a read on the mailbox waiting for completion */ mbx_read(); /* set time value and schedule a periodic wakeup (every 1/100 of a second) * this is used to prevent the controlling process from using up all the * CPU. The controlling process will hibernate at strategic points in * the program when it is just waiting for input. */ status = sys$bintim(&dtime,&delta); if (!(status & SS$_NORMAL)) CloseDown(status); status = sys$schdwk(0,0,&delta,&delta); if (!(status & SS$_NORMAL)) CloseDown(status); /* * This is rather funky, but it saves me from having to totally * rewrite some parts of the code (namely in_put in module CHARPROC.C) */ pty = 1; screen->respond = pty; pty_mask = 1 << pty; Select_mask = pty_mask; X_mask = 1 << Xsocket; } /* * This routine handles completion of write with echo. It takes the * echo buffer and puts it on the read queue. It will then be processed * by the routine tt_read. If the echo buffer is empty, it is put back * on the free buffer queue. */ static void tt_echo_ast(TT_BUF_STRUCT *buff_addr) { int status; if (buff_addr->length != 0) { status = LIB$INSQTI(buff_addr, &read_queue); if((status != SS$_NORMAL) && (status != LIB$_ONEENTQUE)) { CloseDown(status); } } else { freeBuff(buff_addr); } } /* * This routine writes to the pseudo terminal. If there is a free * buffer then write with an echo buffer completing asyncronously, else * write syncronously using the buffer reserved for writing. All errors * are fatal, except DATAOVERUN and DATALOST,these errors can be ignored. CAREFUL! Whatever calls this must NOT pass more than VMS_TERM_BUFFER_SIZE bytes at a time. This definition has been moved to VMS.H */ int tt_write(const char *tt_write_buf, int size) { int status; TT_BUF_STRUCT *echoBuff; /* if writing stopped, return 0 until Xon */ if(write_stopped) return (0); memmove(&tt_w_buff->data,tt_write_buf,size); echoBuff = getBuff(); if (echoBuff != LIB$_QUEWASEMP) { status = PTD$WRITE (tt_chan, &tt_echo_ast, echoBuff, &tt_w_buff->status, size, &echoBuff->status, VMS_TERM_BUFFER_SIZE); } else { status = PTD$WRITE (tt_chan, 0, 0, &tt_w_buff->status, size, 0, 0); } if (status & SS$_NORMAL) { if ((tt_w_buff->status != SS$_NORMAL) && (tt_w_buff->status != SS$_DATAOVERUN) && (tt_w_buff->status != SS$_DATALOST)) { CloseDown(tt_w_buff->status); } } else { CloseDown(status); } return(size); } /* * This routine is called when a read to the pseudo terminal completes. * Put the newly read buffer onto the read queue. It will be processed * and freed in the routine tt_read. */ static void tt_read_ast(TT_BUF_STRUCT *buff_addr) { int status; if (buff_addr->status & SS$_NORMAL) { status = LIB$INSQTI(buff_addr, &read_queue); if ((status != SS$_NORMAL) && (status != LIB$_ONEENTQUE)) { CloseDown(status); } } else CloseDown(buff_addr->status); tt_start_read(); sys$wake(0,0); return; } /* * If there is a free buffer on the buffer queue then Start a read from * the pseudo terminal, otherwise set a flag, the reading will be restarted * in the routine freeBuff when a buffer is freed. */ void tt_start_read(void) { int status; static int size; TT_BUF_STRUCT *buff_addr; buff_addr = getBuff(); if (buff_addr != LIB$_QUEWASEMP) { if(!tt_pasting){ status = PTD$READ (0, tt_chan, &tt_read_ast, buff_addr, &buff_addr->status, VMS_TERM_BUFFER_SIZE); if ((status & SS$_NORMAL) != SS$_NORMAL) { CloseDown(status); } } } else { read_stopped = True; } return; } /* * Get data from the pseudo terminal. Return the data from the first item * on the read queue, and put that buffer back onto the free buffer queue. * Return the length or zero if the read queue is empty. * */ int tt_read(char *buffer) { TT_BUF_STRUCT *read_buff; int status; int len; status = LIB$REMQHI(&read_queue, &read_buff); if(status == LIB$_QUEWASEMP){ return(0); } else if (status & SS$_NORMAL) { len = read_buff->length; memmove(buffer,&read_buff->data,len); freeBuff(read_buff); tt_new_output=True; /* DRM something will be written */ } else CloseDown(status); return(len); } /* * if xon then it is safe to start writing again. */ static void send_xon(void) { write_stopped = False; } /* * If Xoff then stop writing to the pseudo terminal until you get Xon. */ static void send_xoff(void) { write_stopped = True; } /* * Beep the terminal to let the user know data will be lost because * of too much data. */ static void send_bell(void) { Bell(term); } /* * if the pseudo terminal's characteristics change, check to see if the * page size changed. If it did, resize the widget, otherwise, ignore * it! This routine just gets the new term dimensions and sets a flag * to indicate the term chars have changed. The widget gets resized in * the routine in_put in the module CHARPROC.C. You cant resize the * widget in this routine because this is an AST and X is not reenterent. */ static void char_change(void) { int status; /* * Dont do anything if in Tek mode */ if(!(TScreenOf(term)->TekEmu)) { status = sys$qiow(0,tt_chan,IO$_SENSEMODE,0,0,0,&tt_mode,8,0,0,0,0); if(!(status & SS$_NORMAL)) CloseDown(status); if((TScreenOf(term)->max_row != tt_mode.length) || (TScreenOf(term)->max_col != tt_mode.page_width)) { tt_length = tt_mode.length; tt_width = tt_mode.page_width; tt_changed = True; } } } /* * Put a free buffer back onto the buffer queue. If reading was * stopped for lack of free buffers, start reading again. */ static void freeBuff (TT_BUF_STRUCT *buff_addr) { int ast_stat; int status; ast_stat = SYS$SETAST(0); if (!read_stopped) { LIB$INSQHI(buff_addr, &buffer_queue); } else { status = PTD$READ (0, tt_chan, &tt_read_ast, buff_addr, &buff_addr->status, VMS_TERM_BUFFER_SIZE); if (status & SS$_NORMAL) { read_stopped = False; } else { CloseDown(status); } } if (ast_stat == SS$_WASSET) ast_stat = SYS$SETAST(1); } /* * return a free buffer from the buffer queue. */ TT_BUF_STRUCT *getBuff(void) { int status; TT_BUF_STRUCT *buff_addr; status = LIB$REMQHI(&buffer_queue, &buff_addr); if (status & SS$_NORMAL) { return(buff_addr); } else { return(status); } } /* * Close down and exit. Kill the detached process (if it still * exists), deassign mailbox channell (if assigned), cancel any * waiting IO to the pseudo terminal and delete it, exit with any * status information. */ static void CloseDown(int exit_status) { int status; /* if process has not terminated, do so now! */ if(pid != 0) { status = sys$forcex(&pid,0,0); if(!(status & SS$_NORMAL)) lib$signal(status); } /* if mbx_chan is assigned, deassign it */ if(mbx_chan != 0) { sys$dassgn(mbx_chan); } /* cancel pseudo terminal IO requests */ status = ptd$cancel(tt_chan); if(!(status & SS$_NORMAL)) lib$signal(status); /* delete pseudo terminal */ status = ptd$delete(tt_chan); if(!(status & SS$_NORMAL)) lib$signal(status); if(!(exit_status & SS$_NORMAL)) lib$signal(exit_status); exit(1); } /* * This routine gets called when the detached process terminates (for * whatever reason). The mailbox buffer has final exit status. Close * down and exit. */ static void mbx_read_ast(void) { int status; pid = 0; status = mbx_read_iosb.status; if (!(status & SS$_NORMAL)) CloseDown(status); status = (unsigned long int) mbx_buf.acc$l_finalsts; if (!(status & SS$_NORMAL)) CloseDown(status); CloseDown(1); } /* * This routine starts a read on the mailbox associated with the detached * process. The AST routine gets called when the detached process terminates. */ static void mbx_read(void) { int status; static int size; size = ACC$K_TERMLEN; status = sys$qio(0,mbx_chan, IO$_READVBLK, &mbx_read_iosb, &mbx_read_ast, 0, &mbx_buf, size,0,0,0,0); if (!(status & SS$_NORMAL)) CloseDown(status); return; } xterm-330/88colres.h0000644000175100001440000001132610633366145013071 0ustar tomusers/* * This header file was generated by ./88colres.pl */ /* $XTermId: 88colres.h,v 1.11 2007/06/12 00:44:21 tom Exp $ */ #ifndef included_88colres_h #define included_88colres_h COLOR_RES("16", screen.Acolors[16], DFT_COLOR("rgb:00/00/00")), COLOR_RES("17", screen.Acolors[17], DFT_COLOR("rgb:00/00/8b")), COLOR_RES("18", screen.Acolors[18], DFT_COLOR("rgb:00/00/cd")), COLOR_RES("19", screen.Acolors[19], DFT_COLOR("rgb:00/00/ff")), COLOR_RES("20", screen.Acolors[20], DFT_COLOR("rgb:00/8b/00")), COLOR_RES("21", screen.Acolors[21], DFT_COLOR("rgb:00/8b/8b")), COLOR_RES("22", screen.Acolors[22], DFT_COLOR("rgb:00/8b/cd")), COLOR_RES("23", screen.Acolors[23], DFT_COLOR("rgb:00/8b/ff")), COLOR_RES("24", screen.Acolors[24], DFT_COLOR("rgb:00/cd/00")), COLOR_RES("25", screen.Acolors[25], DFT_COLOR("rgb:00/cd/8b")), COLOR_RES("26", screen.Acolors[26], DFT_COLOR("rgb:00/cd/cd")), COLOR_RES("27", screen.Acolors[27], DFT_COLOR("rgb:00/cd/ff")), COLOR_RES("28", screen.Acolors[28], DFT_COLOR("rgb:00/ff/00")), COLOR_RES("29", screen.Acolors[29], DFT_COLOR("rgb:00/ff/8b")), COLOR_RES("30", screen.Acolors[30], DFT_COLOR("rgb:00/ff/cd")), COLOR_RES("31", screen.Acolors[31], DFT_COLOR("rgb:00/ff/ff")), COLOR_RES("32", screen.Acolors[32], DFT_COLOR("rgb:8b/00/00")), COLOR_RES("33", screen.Acolors[33], DFT_COLOR("rgb:8b/00/8b")), COLOR_RES("34", screen.Acolors[34], DFT_COLOR("rgb:8b/00/cd")), COLOR_RES("35", screen.Acolors[35], DFT_COLOR("rgb:8b/00/ff")), COLOR_RES("36", screen.Acolors[36], DFT_COLOR("rgb:8b/8b/00")), COLOR_RES("37", screen.Acolors[37], DFT_COLOR("rgb:8b/8b/8b")), COLOR_RES("38", screen.Acolors[38], DFT_COLOR("rgb:8b/8b/cd")), COLOR_RES("39", screen.Acolors[39], DFT_COLOR("rgb:8b/8b/ff")), COLOR_RES("40", screen.Acolors[40], DFT_COLOR("rgb:8b/cd/00")), COLOR_RES("41", screen.Acolors[41], DFT_COLOR("rgb:8b/cd/8b")), COLOR_RES("42", screen.Acolors[42], DFT_COLOR("rgb:8b/cd/cd")), COLOR_RES("43", screen.Acolors[43], DFT_COLOR("rgb:8b/cd/ff")), COLOR_RES("44", screen.Acolors[44], DFT_COLOR("rgb:8b/ff/00")), COLOR_RES("45", screen.Acolors[45], DFT_COLOR("rgb:8b/ff/8b")), COLOR_RES("46", screen.Acolors[46], DFT_COLOR("rgb:8b/ff/cd")), COLOR_RES("47", screen.Acolors[47], DFT_COLOR("rgb:8b/ff/ff")), COLOR_RES("48", screen.Acolors[48], DFT_COLOR("rgb:cd/00/00")), COLOR_RES("49", screen.Acolors[49], DFT_COLOR("rgb:cd/00/8b")), COLOR_RES("50", screen.Acolors[50], DFT_COLOR("rgb:cd/00/cd")), COLOR_RES("51", screen.Acolors[51], DFT_COLOR("rgb:cd/00/ff")), COLOR_RES("52", screen.Acolors[52], DFT_COLOR("rgb:cd/8b/00")), COLOR_RES("53", screen.Acolors[53], DFT_COLOR("rgb:cd/8b/8b")), COLOR_RES("54", screen.Acolors[54], DFT_COLOR("rgb:cd/8b/cd")), COLOR_RES("55", screen.Acolors[55], DFT_COLOR("rgb:cd/8b/ff")), COLOR_RES("56", screen.Acolors[56], DFT_COLOR("rgb:cd/cd/00")), COLOR_RES("57", screen.Acolors[57], DFT_COLOR("rgb:cd/cd/8b")), COLOR_RES("58", screen.Acolors[58], DFT_COLOR("rgb:cd/cd/cd")), COLOR_RES("59", screen.Acolors[59], DFT_COLOR("rgb:cd/cd/ff")), COLOR_RES("60", screen.Acolors[60], DFT_COLOR("rgb:cd/ff/00")), COLOR_RES("61", screen.Acolors[61], DFT_COLOR("rgb:cd/ff/8b")), COLOR_RES("62", screen.Acolors[62], DFT_COLOR("rgb:cd/ff/cd")), COLOR_RES("63", screen.Acolors[63], DFT_COLOR("rgb:cd/ff/ff")), COLOR_RES("64", screen.Acolors[64], DFT_COLOR("rgb:ff/00/00")), COLOR_RES("65", screen.Acolors[65], DFT_COLOR("rgb:ff/00/8b")), COLOR_RES("66", screen.Acolors[66], DFT_COLOR("rgb:ff/00/cd")), COLOR_RES("67", screen.Acolors[67], DFT_COLOR("rgb:ff/00/ff")), COLOR_RES("68", screen.Acolors[68], DFT_COLOR("rgb:ff/8b/00")), COLOR_RES("69", screen.Acolors[69], DFT_COLOR("rgb:ff/8b/8b")), COLOR_RES("70", screen.Acolors[70], DFT_COLOR("rgb:ff/8b/cd")), COLOR_RES("71", screen.Acolors[71], DFT_COLOR("rgb:ff/8b/ff")), COLOR_RES("72", screen.Acolors[72], DFT_COLOR("rgb:ff/cd/00")), COLOR_RES("73", screen.Acolors[73], DFT_COLOR("rgb:ff/cd/8b")), COLOR_RES("74", screen.Acolors[74], DFT_COLOR("rgb:ff/cd/cd")), COLOR_RES("75", screen.Acolors[75], DFT_COLOR("rgb:ff/cd/ff")), COLOR_RES("76", screen.Acolors[76], DFT_COLOR("rgb:ff/ff/00")), COLOR_RES("77", screen.Acolors[77], DFT_COLOR("rgb:ff/ff/8b")), COLOR_RES("78", screen.Acolors[78], DFT_COLOR("rgb:ff/ff/cd")), COLOR_RES("79", screen.Acolors[79], DFT_COLOR("rgb:ff/ff/ff")), COLOR_RES("80", screen.Acolors[80], DFT_COLOR("rgb:2e/2e/2e")), COLOR_RES("81", screen.Acolors[81], DFT_COLOR("rgb:5c/5c/5c")), COLOR_RES("82", screen.Acolors[82], DFT_COLOR("rgb:73/73/73")), COLOR_RES("83", screen.Acolors[83], DFT_COLOR("rgb:8b/8b/8b")), COLOR_RES("84", screen.Acolors[84], DFT_COLOR("rgb:a2/a2/a2")), COLOR_RES("85", screen.Acolors[85], DFT_COLOR("rgb:b9/b9/b9")), COLOR_RES("86", screen.Acolors[86], DFT_COLOR("rgb:d0/d0/d0")), COLOR_RES("87", screen.Acolors[87], DFT_COLOR("rgb:e7/e7/e7")), #endif /* included_88colres_h */ xterm-330/TekPrsTbl.c0000644000175100001440000014743610373756621013306 0ustar tomusers/* $XTermId: TekPrsTbl.c,v 1.8 2006/02/13 01:14:57 tom Exp $ */ /* * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ /* $XFree86: xc/programs/xterm/TekPrsTbl.c,v 3.5 2006/02/13 01:14:57 dickey Exp $ */ #include Const int Talptable[] = /* US (^_) normal alpha mode */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_BEL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_LF, CASE_UP, /* NP CR SO SI */ CASE_IGNORE, CASE_CR, CASE_IGNORE, CASE_IGNORE, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_ESC_STATE, /* FS GS RS US */ CASE_PT_STATE, CASE_PLT_STATE, CASE_IPL_STATE, CASE_ALP_STATE, /* SP ! " # */ CASE_SP, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* $ % & ' */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* ( ) * + */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* , - . / */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* 0 1 2 3 */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* 4 5 6 7 */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* 8 9 : ; */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* < = > ? */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* @ A B C */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* D E F G */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* H I J K */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* L M N O */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* P Q R S */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* T U V W */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* X Y Z [ */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* \ ] ^ _ */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* ` a b c */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* d e f g */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* h i j k */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* l m n o */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* p q r s */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* t u v w */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* x y z { */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* | } ~ DEL */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x99 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* currency yen brokenbar section */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* diaeresis copyright ordfeminine guillemotleft */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* notsign hyphen registered macron */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* degree plusminus twosuperior threesuperior */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* acute mu paragraph periodcentered */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* cedilla onesuperior masculine guillemotright */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* onequarter onehalf threequarters questiondown */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Agrave Aacute Acircumflex Atilde */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Adiaeresis Aring AE Ccedilla */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Eth Ntilde Ograve Oacute */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Udiaeresis Yacute Thorn ssharp */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* agrave aacute acircumflex atilde */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* adiaeresis aring ae ccedilla */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* egrave eacute ecircumflex ediaeresis */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* igrave iacute icircumflex idiaeresis */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* eth ntilde ograve oacute */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* ocircumflex otilde odiaeresis division */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* oslash ugrave uacute ucircumflex */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* udiaeresis yacute thorn ydiaeresis */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, }; Const int Tbestable[] = /* ESC while in bypass state */ { /* NUL SOH STX ETX */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_VT_MODE, /* EOT ENQ ACK BEL */ CASE_BYP_STATE, CASE_REPORT, CASE_BYP_STATE, CASE_BEL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_IGNORE, CASE_UP, /* NP CR SO SI */ CASE_PAGE, CASE_IGNORE, CASE_BYP_STATE, CASE_BYP_STATE, /* DLE DC1 DC2 DC3 */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* DC4 NAK SYN ETB */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_COPY, /* CAN EM SUB ESC */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_GIN, CASE_IGNORE, /* FS GS RS US */ CASE_SPT_STATE, CASE_PLT_STATE, CASE_IPL_STATE, CASE_ALP_STATE, /* SP ! " # */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* $ % & ' */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* ( ) * + */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* , - . / */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* 0 1 2 3 */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* 4 5 6 7 */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* 8 9 : ; */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* < = > ? */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* @ A B C */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* D E F G */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* H I J K */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* L M N O */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* P Q R S */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* T U V W */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* X Y Z [ */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* \ ] ^ _ */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* ` a b c */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* d e f g */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* h i j k */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* l m n o */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* p q r s */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* t u v w */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* x y z { */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* | } ~ DEL */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_IGNORE, CASE_BYP_STATE, /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x99 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* currency yen brokenbar section */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* notsign hyphen registered macron */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* degree plusminus twosuperior threesuperior */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* acute mu paragraph periodcentered */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* cedilla onesuperior masculine guillemotright */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* onequarter onehalf threequarters questiondown */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* Agrave Aacute Acircumflex Atilde */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* Eth Ntilde Ograve Oacute */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* agrave aacute acircumflex atilde */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* adiaeresis aring ae ccedilla */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* eth ntilde ograve oacute */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* ocircumflex otilde odiaeresis division */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* oslash ugrave uacute ucircumflex */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, CASE_BYP_STATE, }; Const int Tbyptable[] = /* ESC CAN (^X) bypass state */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_BEL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_LF, CASE_UP, /* NP CR SO SI */ CASE_IGNORE, CASE_CR, CASE_IGNORE, CASE_IGNORE, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_BES_STATE, /* FS GS RS US */ CASE_PT_STATE, CASE_PLT_STATE, CASE_IPL_STATE, CASE_ALP_STATE, /* SP ! " # */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* $ % & ' */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ( ) * + */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* , - . / */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0 1 2 3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 4 5 6 7 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 8 9 : ; */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* < = > ? */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* @ A B C */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* D E F G */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* H I J K */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* L M N O */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* P Q R S */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* T U V W */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* X Y Z [ */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* \ ] ^ _ */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ` a b c */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* d e f g */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* h i j k */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* l m n o */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* p q r s */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* t u v w */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* x y z { */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* | } ~ DEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x99 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* currency yen brokenbar section */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* notsign hyphen registered macron */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* acute mu paragraph periodcentered */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* cedilla onesuperior masculine guillemotright */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* onequarter onehalf threequarters questiondown */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Agrave Aacute Acircumflex Atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Adiaeresis Aring AE Ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Eth Ntilde Ograve Oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Udiaeresis Yacute Thorn ssharp */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* agrave aacute acircumflex atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* adiaeresis aring ae ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* egrave eacute ecircumflex ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* igrave iacute icircumflex idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* eth ntilde ograve oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ocircumflex otilde odiaeresis division */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* oslash ugrave uacute ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* udiaeresis yacute thorn ydiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, }; Const int Tesctable[] = /* ESC */ { /* NUL SOH STX ETX */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_VT_MODE, /* EOT ENQ ACK BEL */ CASE_CURSTATE, CASE_REPORT, CASE_CURSTATE, CASE_BEL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_IGNORE, CASE_UP, /* NP CR SO SI */ CASE_PAGE, CASE_IGNORE, CASE_APL, CASE_ASCII, /* DLE DC1 DC2 DC3 */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* DC4 NAK SYN ETB */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_COPY, /* CAN EM SUB ESC */ CASE_BYP_STATE, CASE_CURSTATE, CASE_GIN, CASE_IGNORE, /* FS GS RS US */ CASE_SPT_STATE, CASE_PLT_STATE, CASE_IPL_STATE, CASE_ALP_STATE, /* SP ! " # */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* $ % & ' */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* ( ) * + */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* , - . / */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* 0 1 2 3 */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* 4 5 6 7 */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* 8 9 : ; */ CASE_CHAR_SIZE, CASE_CHAR_SIZE, CASE_CHAR_SIZE, CASE_CHAR_SIZE, /* < = > ? */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* @ A B C */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* D E F G */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* H I J K */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* L M N O */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* P Q R S */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* T U V W */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* X Y Z [ */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* \ ] ^ _ */ CASE_CURSTATE, CASE_OSC, CASE_CURSTATE, CASE_CURSTATE, /* ` a b c */ CASE_BEAM_VEC, CASE_BEAM_VEC, CASE_BEAM_VEC, CASE_BEAM_VEC, /* d e f g */ CASE_BEAM_VEC, CASE_CURSTATE, CASE_CURSTATE, CASE_BEAM_VEC, /* h i j k */ CASE_BEAM_VEC, CASE_BEAM_VEC, CASE_BEAM_VEC, CASE_BEAM_VEC, /* l m n o */ CASE_BEAM_VEC, CASE_CURSTATE, CASE_CURSTATE, CASE_BEAM_VEC, /* p q r s */ CASE_BEAM_VEC, CASE_BEAM_VEC, CASE_BEAM_VEC, CASE_BEAM_VEC, /* t u v w */ CASE_BEAM_VEC, CASE_CURSTATE, CASE_CURSTATE, CASE_BEAM_VEC, /* x y z { */ CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, CASE_CURSTATE, /* | } ~ DEL */ CASE_CURSTATE, CASE_CURSTATE, CASE_IGNORE, CASE_CURSTATE, /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x99 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* currency yen brokenbar section */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* notsign hyphen registered macron */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* acute mu paragraph periodcentered */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* cedilla onesuperior masculine guillemotright */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* onequarter onehalf threequarters questiondown */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Agrave Aacute Acircumflex Atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Adiaeresis Aring AE Ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Eth Ntilde Ograve Oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Udiaeresis Yacute Thorn ssharp */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* agrave aacute acircumflex atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* adiaeresis aring ae ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* egrave eacute ecircumflex ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* igrave iacute icircumflex idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* eth ntilde ograve oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ocircumflex otilde odiaeresis division */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* oslash ugrave uacute ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* udiaeresis yacute thorn ydiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, }; Const int Tipltable[] = /* RS (^^) incremental plot */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_BEL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_LF, CASE_UP, /* NP CR SO SI */ CASE_IGNORE, CASE_CR, CASE_IGNORE, CASE_IGNORE, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_ESC_STATE, /* FS GS RS US */ CASE_PT_STATE, CASE_PLT_STATE, CASE_IPL_STATE, CASE_ALP_STATE, /* SP ! " # */ CASE_PENUP, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* $ % & ' */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ( ) * + */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* , - . / */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0 1 2 3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 4 5 6 7 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 8 9 : ; */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* < = > ? */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* @ A B C */ CASE_IGNORE, CASE_IPL_POINT, CASE_IPL_POINT, CASE_IGNORE, /* D E F G */ CASE_IPL_POINT, CASE_IPL_POINT, CASE_IPL_POINT, CASE_IGNORE, /* H I J K */ CASE_IPL_POINT, CASE_IPL_POINT, CASE_IPL_POINT, CASE_IGNORE, /* L M N O */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* P Q R S */ CASE_PENDOWN, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* T U V W */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* X Y Z [ */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* \ ] ^ _ */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ` a b c */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* d e f g */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* h i j k */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* l m n o */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* p q r s */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* t u v w */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* x y z { */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* | } ~ DEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x99 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* currency yen brokenbar section */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* notsign hyphen registered macron */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* acute mu paragraph periodcentered */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* cedilla onesuperior masculine guillemotright */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* onequarter onehalf threequarters questiondown */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Agrave Aacute Acircumflex Atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Adiaeresis Aring AE Ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Eth Ntilde Ograve Oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Udiaeresis Yacute Thorn ssharp */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* agrave aacute acircumflex atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* adiaeresis aring ae ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* egrave eacute ecircumflex ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* igrave iacute icircumflex idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* eth ntilde ograve oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ocircumflex otilde odiaeresis division */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* oslash ugrave uacute ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* udiaeresis yacute thorn ydiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, }; Const int Tplttable[] = /* GS (^]) graph (plot) mode */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_BEL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_LF, CASE_UP, /* NP CR SO SI */ CASE_IGNORE, CASE_CR, CASE_IGNORE, CASE_IGNORE, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_ESC_STATE, /* FS GS RS US */ CASE_PT_STATE, CASE_PLT_STATE, CASE_IPL_STATE, CASE_ALP_STATE, /* SP ! " # */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* $ % & ' */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* ( ) * + */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* , - . / */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* 0 1 2 3 */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* 4 5 6 7 */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* 8 9 : ; */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* < = > ? */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* @ A B C */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* D E F G */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* H I J K */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* L M N O */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* P Q R S */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* T U V W */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* X Y Z [ */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* \ ] ^ _ */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* ` a b c */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* d e f g */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* h i j k */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* l m n o */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* p q r s */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* t u v w */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* x y z { */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* | } ~ DEL */ CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, CASE_PLT_VEC, /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x99 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* currency yen brokenbar section */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* notsign hyphen registered macron */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* acute mu paragraph periodcentered */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* cedilla onesuperior masculine guillemotright */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* onequarter onehalf threequarters questiondown */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Agrave Aacute Acircumflex Atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Adiaeresis Aring AE Ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Eth Ntilde Ograve Oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Udiaeresis Yacute Thorn ssharp */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* agrave aacute acircumflex atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* adiaeresis aring ae ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* egrave eacute ecircumflex ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* igrave iacute icircumflex idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* eth ntilde ograve oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ocircumflex otilde odiaeresis division */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* oslash ugrave uacute ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* udiaeresis yacute thorn ydiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, }; Const int Tpttable[] = /* FS (^\) point plot mode */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_BEL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_LF, CASE_UP, /* NP CR SO SI */ CASE_IGNORE, CASE_CR, CASE_IGNORE, CASE_IGNORE, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_ESC_STATE, /* FS GS RS US */ CASE_PT_STATE, CASE_PLT_STATE, CASE_IPL_STATE, CASE_ALP_STATE, /* SP ! " # */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* $ % & ' */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* ( ) * + */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* , - . / */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* 0 1 2 3 */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* 4 5 6 7 */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* 8 9 : ; */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* < = > ? */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* @ A B C */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* D E F G */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* H I J K */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* L M N O */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* P Q R S */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* T U V W */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* X Y Z [ */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* \ ] ^ _ */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* ` a b c */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* d e f g */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* h i j k */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* l m n o */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* p q r s */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* t u v w */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* x y z { */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* | } ~ DEL */ CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, CASE_PT_POINT, /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x99 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* currency yen brokenbar section */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* notsign hyphen registered macron */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* acute mu paragraph periodcentered */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* cedilla onesuperior masculine guillemotright */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* onequarter onehalf threequarters questiondown */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Agrave Aacute Acircumflex Atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Adiaeresis Aring AE Ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Eth Ntilde Ograve Oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Udiaeresis Yacute Thorn ssharp */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* agrave aacute acircumflex atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* adiaeresis aring ae ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* egrave eacute ecircumflex ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* igrave iacute icircumflex idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* eth ntilde ograve oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ocircumflex otilde odiaeresis division */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* oslash ugrave uacute ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* udiaeresis yacute thorn ydiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, }; Const int Tspttable[] = /* ESC FS (^\) special point plot */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_BEL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_LF, CASE_UP, /* NP CR SO SI */ CASE_IGNORE, CASE_CR, CASE_IGNORE, CASE_IGNORE, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_ESC_STATE, /* FS GS RS US */ CASE_PT_STATE, CASE_PLT_STATE, CASE_IPL_STATE, CASE_ALP_STATE, /* SP ! " # */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* $ % & ' */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* ( ) * + */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* , - . / */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* 0 1 2 3 */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* 4 5 6 7 */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* 8 9 : ; */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* < = > ? */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* @ A B C */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* D E F G */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* H I J K */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* L M N O */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* P Q R S */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* T U V W */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* X Y Z [ */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* \ ] ^ _ */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* ` a b c */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* d e f g */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* h i j k */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* l m n o */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* p q r s */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* t u v w */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* x y z { */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* | } ~ DEL */ CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, CASE_SPT_POINT, /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x99 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* currency yen brokenbar section */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* notsign hyphen registered macron */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* acute mu paragraph periodcentered */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* cedilla onesuperior masculine guillemotright */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* onequarter onehalf threequarters questiondown */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Agrave Aacute Acircumflex Atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Adiaeresis Aring AE Ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Eth Ntilde Ograve Oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Udiaeresis Yacute Thorn ssharp */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* agrave aacute acircumflex atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* adiaeresis aring ae ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* egrave eacute ecircumflex ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* igrave iacute icircumflex idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* eth ntilde ograve oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ocircumflex otilde odiaeresis division */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* oslash ugrave uacute ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* udiaeresis yacute thorn ydiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, }; xterm-330/xterm.appdata.xml0000644000175100001440000000312312772015025014531 0ustar tomusers xterm.desktop CC-BY-3.0 X11 XTerm Terminal emulator for the X Window System

XTerm is the standard terminal emulator for the X Window System. It provides DEC VT102/VT220 and selected features from higher-level terminals such as VT320/VT420/VT520 (VTxxx). It also provides Tektronix 4014 emulation for programs that cannot use the window system directly.

You would use xterm to get a shell prompt, to run command-line programs.

http://invisible-island.net/xterm/images/merged-xterm-menus.png xterm with its popup menus superimposed shell prompt command commandline cmd terminal http://invisible-island.net/xterm/ dickey@invisible-island.net Thomas E. Dickey mailto:dickey@invisible-island.net http://invisible-island.net/xterm/xterm.faq.html
xterm-330/termcap0000644000175100001440000002420012740242400012606 0ustar tomusers# $XTermId: termcap,v 1.83 2016/07/09 18:40:00 tom Exp $ # # These are termcap entries that correspond to xterm's terminfo file. # The file is formatted using ncurses' "tic -CNx", but is not mechanically # derived from the terminfo. # #------------------------------------------------------------------------------ # Copyright 1996-2012,2016 by Thomas E. Dickey # # All Rights Reserved # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name(s) of the above copyright # holders shall not be used in advertising or otherwise to promote the # sale, use or other dealings in this Software without prior written # authorization. #------------------------------------------------------------------------------ # # Note: # termcap format is limited to 1023 characters. This set of descriptions # is a subset of the terminfo, since not all features can be fit into # that limit. The 'xterm' description supports color. The monochrome # 'xterm-mono' drops color in favor of additional function keys. If you # need both, use terminfo. # # The 1023-character limit applies to each entry after resolving the # "tc=" strings. Some implementations may discount all or part of the # formatting characters in the entry (i.e., the backslash newline tab # colon). GNU termcap does not have this limit. # # I checked the limits using ncurses "captoinfo -CrTUvx", which prints # the resolved length of each entry in a comment at the end - T.Dickey # xf|xterm-new|modern xterm:\ :XT:*6=\EOF:@7=\EOF:F1=\E[23~:F2=\E[24~:K2=\EOE:Km=\E[M:\ :k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:k5=\E[15~:k6=\E[17~:\ :k7=\E[18~:k8=\E[19~:k9=\E[20~:k;=\E[21~:kB=\E[Z:kH=\EOF:\ :kI=\E[2~:kN=\E[6~:kP=\E[5~:kd=\EOB:kh=\EOH:kl=\EOD:\ :kr=\EOC:ku=\EOA:tc=xterm-basic: # # This chunk is used for building the VT220/Sun/PC keyboard variants. xb|xterm-basic|modern xterm common:\ :am:bs:km:mi:ms:ut:xn:AX:\ :Co#8:co#80:kn#12:li#24:pa#64:\ :AB=\E[4%dm:AF=\E[3%dm:AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:\ :DO=\E[%dB:LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:ae=\E(B:al=\E[L:\ :as=\E(0:bl=^G:cd=\E[J:ce=\E[K:cl=\E[H\E[2J:\ :cm=\E[%i%d;%dH:cs=\E[%i%d;%dr:ct=\E[3g:dc=\E[P:dl=\E[M:\ :ei=\E[4l:ho=\E[H:im=\E[4h:is=\E[!p\E[?3;4l\E[4l\E>\E]104^G:\ :kD=\E[3~:ke=\E[?1l\E>:ks=\E[?1h\E=:le=^H:md=\E[1m:\ :me=\E[m:ml=\El:mr=\E[7m:mu=\Em:nd=\E[C:op=\E[39;49m:\ :rc=\E8:rs=\E[!p\E[?3;4l\E[4l\E>\E]104^G:sc=\E7:se=\E[27m:sf=^J:\ :so=\E[7m:sr=\EM:st=\EH:te=\E[?1049l:ti=\E[?1049h:\ :ue=\E[24m:up=\E[A:us=\E[4m:ve=\E[?12l\E[?25h:vi=\E[?25l:\ :vs=\E[?12;25h:tc=xterm+kbs: # The xterm-new description has all of the features, but is not completely # compatible with vt220. If you are using a Sun or PC keyboard, set the # sunKeyboard resource to true: # + maps the editing keypad # + interprets control-function-key as a second array of keys, so a # 12-fkey keyboard can support vt220's 20-fkeys. # + maps numeric keypad "+" to ",". # + uses DEC-style control sequences for the application keypad. # vt|xterm-vt220|xterm emulating vt220:\ :XT:*6=\E[4~:@7=\E[4~:K2=\EOu:Km=\E[M:kB=\E[Z:kH=\E[4~:\ :kh=\E[1~:tc=xterm-basic: v1|xterm-24|xterms|vs100|24x80 xterm:\ :li#24:tc=xterm-old: v2|xterm-65|65x80 xterm:\ :li#65:tc=xterm-old: vb|xterm-bold|xterm with bold for underline:\ :so=\E[7m:us=\E[1m:tc=xterm-old: vB|xterm-boldso|xterm with bold for standout:\ :se=\E[m:so=\E[1m:tc=xterm-old: vm|xterm-mono|monochrome xterm:\ :ut@:\ :Co@:NC@:kn#20:pa@:\ :AB@:AF@:Sb@:Sf@:op@:st@:tc=xterm-old: # # Alternate terminal description that "works" for interactive shells such as # tcsh and bash. xn|xterm-noapp|xterm with cursor keys in normal mode:\ :kd=\E[B:ke=\E>:kl=\E[D:kr=\E[C:ks=\E=:ku=\E[A:te@:ti@:\ :tc=xterm: # # This should work for the commonly used "color xterm" variations (XFree86 # xterm, color_xterm, nxterm, rxvt). Note that it does not set 'bce', so for # XFree86 and rxvt, some applications that use colors will be less efficient, # and in a few special cases (with "smart" optimization) the wrong color will # be painted in spots. vc|xterm-color|generic "ANSI" color xterm:\ :Co#8:NC@:pa#64:\ :AB=\E[4%dm:AF=\E[3%dm:ac=:op=\E[m:tc=xterm-r6: # # These aliases are for compatibility with the terminfo; termcap cannot provide # the extra features such as color initialization, but termcap applications # still want the names. x1|xterm-16color|xterm alias:\ :tc=xterm-new: x2|xterm-88color|xterm alias:\ :Co#88:pa#7744:tc=xterm-256color: x3|xterm-256color|xterm alias:\ :Co#256:pa#32767:\ :AB=\E[48;5;%dm:AF=\E[38;5;%dm:tc=xterm-new: xi|xterm-nrc|xterm alias:\ :tc=xterm: xr|xterm-rep|xterm alias:\ :tc=xterm: xx|xterm-xmc|xterm alias:\ :sg#1:tc=xterm: # # An 8-bit description is doable with termcap, but there are probably no # termcap (or BSD curses) applications that are able to use it. x8|xterm-8bit|xterm terminal emulator 8-bit controls (X Window System):\ :am:km:mi:ms:xn:XT:\ :co#80:it#8:li#24:\ :AL=\233%dL:DC=\233%dP:DL=\233%dM:DO=\233%dB:IC=\233%d@:\ :K2=\217y:Km=\233M:LE=\233%dD:RI=\233%dC:UP=\233%dA:\ :ae=\E(B:al=\233L:as=\E(0:bl=^G:bt=\233Z:cd=\233J:ce=\233K:\ :cl=\233H\2332J:cm=\233%i%d;%dH:cr=^M:cs=\233%i%d;%dr:\ :ct=\2333g:dc=\233P:dl=\233M:do=^J:ei=\2334l:ho=\233H:\ :im=\2334h:\ :is=\E[62"p\E G\233m\233?7h\E>\E7\233?1;3;4;6l\2334l\233r\E8:\ :k1=\23311~:k2=\23312~:k3=\23313~:k4=\23314~:k5=\23315~:\ :k6=\23317~:k7=\23318~:k8=\23319~:k9=\23320~:kD=\2333~:\ :kI=\2332~:kN=\2336~:kP=\2335~:kd=\217B:ke=\233?1l\E>:\ :kh=\2331~:kl=\217D:kr=\217C:ks=\233?1h\E=:ku=\217A:le=^H:\ :mb=\2335m:md=\2331m:me=\233m:mr=\2337m:nd=\233C:rc=\E8:\ :sc=\E7:se=\23327m:sf=^J:so=\2337m:sr=\215:st=\210:ta=^I:\ :te=\233?1049l:ti=\233?1049h:ue=\23324m:up=\233A:\ :us=\2334m:vb=\233?5h\233?5l:ve=\233?25l\233?25h:\ :vi=\233?25l:vs=\233?12;25h:tc=xterm+kbs: # hp|xterm-hp|xterm with hpterm function keys:\ :@7=\EF:k1=\Ep:k2=\Eq:k3=\Er:k4=\Es:k5=\Et:k6=\Eu:k7=\Ev:\ :k8=\Ew:kC=\EJ:kD=\EP:kI=\EQ:kN=\ES:kP=\ET:kd=\EB:kh=\Eh:\ :kl=\ED:kr=\EC:ku=\EA:tc=xterm-basic: # xS|xterm-sco|xterm with SCO function keys:\ :@7=\E[F:F1=\E[W:F2=\E[X:F3=\E[Y:F5=\E[a:F6=\E[b:F7=\E[c:\ :F8=\E[d:F9=\E[e:FA=\E[f:FB=\E[g:FC=\E[h:FD=\E[i:FE=\E[j:\ :FF=\E[k:ac=:k1=\E[M:k2=\E[N:k3=\E[O:k4=\E[P:k5=\E[Q:\ :k6=\E[R:k7=\E[S:k8=\E[T:k9=\E[U:k;=\E[V:kD=\177:kI=\E[L:\ :kN=\E[G:kP=\E[I:kd=\E[B:kh=\E[H:kl=\E[D:kr=\E[C:ku=\E[A:\ :tc=xterm-basic: # v5|xterm-vt52|xterm emulating vt52:\ :bs:\ :co#80:it#8:li#24:\ :ae=\EG:as=\EF:bl=^G:cd=\EJ:ce=\EK:cl=\EH\EJ:cm=\EY%+ %+ :\ :cr=^M:do=\EB:ho=\EH:kd=\EB:kl=\ED:kr=\EC:ku=\EA:le=\ED:\ :nd=\EC:nw=^M^J:sf=^J:sr=\EI:ta=^I:up=\EA:tc=xterm+kbs: # xs|xterm-sun|xterm with Sun functionkeys:\ :%1=\E[196z:&8=\E[195z:@0=\E[200z:@5=\E[197z:@7=\E[220z:\ :F1=\E[192z:F2=\E[193z:K2=\E[218z:Km=\E[M:k1=\E[224z:\ :k2=\E[225z:k3=\E[226z:k4=\E[227z:k5=\E[228z:k6=\E[229z:\ :k7=\E[230z:k8=\E[231z:k9=\E[232z:k;=\E[233z:kD=\E[3z:\ :kI=\E[2z:kN=\E[222z:kP=\E[216z:kh=\E[214z:\ :tc=xterm-basic: # # vi may work better with this entry, because vi doesn't use insert mode much. # |xterm-ic|xterm-vi|xterm with insert character instead of insert mode:\ vi|xterm-ic|xterm-vi|xterm with insert char:\ :mi@:\ :IC=\E[%d@:ei@:ic=\E[@:im@:tc=xterm: # # Compatible with the X11R6.3 xterm r6|xterm-r6|xterm-old|X11R6 xterm:\ :am:bs:km:mi:ms:pt:xn:\ :co#80:kn#20:li#24:\ :*6=\E[4~:@0=\E[1~:@7=\E[4~:AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:\ :DO=\E[%dB:F1=\E[23~:F2=\E[24~:F3=\E[25~:F4=\E[26~:\ :F5=\E[28~:F6=\E[29~:F7=\E[31~:F8=\E[32~:F9=\E[33~:\ :FA=\E[34~:LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:ae=^O:al=\E[L:\ :as=^N:bl=^G:cd=\E[J:ce=\E[K:cl=\E[H\E[2J:cm=\E[%i%d;%dH:\ :cs=\E[%i%d;%dr:ct=\E[3g:dc=\E[P:dl=\E[M:eA=\E)0:ei=\E[4l:\ :ho=\E[H:im=\E[4h:\ :is=\E[m\E[?7h\E[4l\E>\E7\E[r\E[?1;3;4;6l\E8:\ :k1=\E[11~:k2=\E[12~:k3=\E[13~:k4=\E[14~:k5=\E[15~:\ :k6=\E[17~:k7=\E[18~:k8=\E[19~:k9=\E[20~:k;=\E[21~:\ :kD=\E[3~:kI=\E[2~:kN=\E[6~:kP=\E[5~:kd=\EOB:ke=\E[?1l\E>:\ :kh=\E[1~:kl=\EOD:kr=\EOC:ks=\E[?1h\E=:ku=\EOA:md=\E[1m:\ :me=\E[m:ml=\El:mr=\E[7m:mu=\Em:nd=\E[C:rc=\E8:\ :rs=\E[m\E[?7h\E[4l\E>\E7\E[r\E[?1;3;4;6l\E8:sc=\E7:\ :se=\E[m:sf=^J:so=\E[7m:sr=\EM:te=\E[2J\E[?47l\E8:\ :ti=\E7\E[?47h:ue=\E[m:up=\E[A:us=\E[4m:tc=xterm+kbs: # # Compatible with the R5 xterm r5|xterm-r5|X11R5 xterm X11R5:\ :am:bs:km:mi:ms:pt:xn:\ :co#80:kn#4:li#24:\ :@7=\E[4~:AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:\ :IC=\E[%d@:UP=\E[%dA:al=\E[L:cd=\E[J:ce=\E[K:cl=\E[H\E[2J:\ :cm=\E[%i%d;%dH:cs=\E[%i%d;%dr:ct=\E[3g:dc=\E[P:dl=\E[M:\ :ei=\E[4l:ho=\E[H:im=\E[4h:\ :is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l:\ :k1=\E[11~:k2=\E[12~:k3=\E[13~:k4=\E[14~:kd=\EOB:\ :ke=\E[?1l\E>:kh=\E[1~:kl=\EOD:kr=\EOC:ks=\E[?1h\E=:\ :ku=\EOA:md=\E[1m:me=\E[m:mr=\E[7m:nd=\E[C:rc=\E8:\ :rs=\E>\E[?1;3;4;5;6l\E[4l\E[?7h\E[m\E[r\E[2J\E[H:\ :sc=\E7:se=\E[m:sf=^J:so=\E[7m:sr=\EM:te=\E[2J\E[?47l\E8:\ :ti=\E7\E[?47h:ue=\E[m:up=\E[A:us=\E[4m:tc=xterm+kbs: # # Customization begins here. x0|xterm-xfree86|xterm terminal emulator (XFree86):\ :tc=xterm-new: # # This is the only entry which you should have to customize, since "xterm" # is widely used for a variety of incompatible terminal emulations including # color_xterm and rxvt. v0|xterm|X11 terminal emulator:\ :tc=xterm-new: # :tc=xterm-r6: # This fragment is for people who cannot agree on what the backspace key # should send. xterm+kbs|fragment for backspace key:\ :kb=^H: xterm-330/graphics_regis.h0000644000175100001440000000352412722615047014413 0ustar tomusers/* $XTermId: graphics_regis.h,v 1.2 2016/05/29 16:34:47 tom Exp $ */ /* * Copyright 2014,2016 by Ross Combs * Copyright 2014,2016 by Thomas E. Dickey * * All Rights Reserved * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * Except as contained in this notice, the name(s) of the above copyright * holders shall not be used in advertising or otherwise to promote the * sale, use or other dealings in this Software without prior written * authorization. */ #ifndef included_graphics_regis_h #define included_graphics_regis_h /* *INDENT-OFF* */ #include #if OPT_REGIS_GRAPHICS extern void parse_regis(XtermWidget /* xw */, ANSI */* params */, char const */* string */); #else #define parse_regis(xw, params, string) /* nothing */ #endif /* *INDENT-ON* */ #endif /* included_graphics_regis_h */ xterm-330/df-install.in0000644000175100001440000000571012016544107013627 0ustar tomusers#!/bin/sh # $XTermId: df-install.in,v 1.14 2012/08/27 01:07:19 tom Exp $ # ----------------------------------------------------------------------------- # this file is part of xterm # # Copyright 2011,2012 by Thomas E. Dickey # # All Rights Reserved # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name(s) of the above copyright # holders shall not be used in advertising or otherwise to promote the # sale, use or other dealings in this Software without prior written # authorization. # ----------------------------------------------------------------------------- # # Install desktop-files, substituting the category to customize the file # to the current system's conventions. # # Parameters are passed to the desktop-file-install program. The last # parameter is the name of the ".desktop" file to install. OPTS= if test $# != 0 then APP_NAME=$1 shift 1 fi CDPATH=: export CDPATH while test $# != 0 do case .$1 in #(vi *.desktop) #(vi if test $# = 1 then OLD_FILE=$1 else OPTS="$OPTS $1" fi ;; *) OPTS="$OPTS $1" ;; esac shift 1 done MY_TEMP=tempdir$$ rm -rf $MY_TEMP if test -z "$OLD_FILE" then echo "? not found: $OLD_FILE" exit 1 elif ! mkdir $MY_TEMP then echo "? cannot mkdir: $MY_TEMP" exit 1 fi # The newer dfi whines about deprecation of encoding, but no release provides # --version or equivalent. really. if desktop-file-install --help-all >/dev/null 2>&1 then NO_ENCODING="#Encoding" else NO_ENCODING="Encoding" fi NEW_FILE=`basename $OLD_FILE` sed \ -e '/^Encoding=/s%Encoding%'$NO_ENCODING'%' \ -e '/^[^#]*Icon=/s%=.*%=xterm-color%' \ -e '/^[^#]*Category=/s%=.*%=@DESKTOP_CATEGORY@%' \ -e '/^[^#]*Categories=/s%=.*%=@DESKTOP_CATEGORY@%' \ -e '/^[^#]/s%xterm%'$APP_NAME'%g' \ -e '/^[^#]/s%XTerm%@APP_CLASS@%g' \ $OLD_FILE >$MY_TEMP/$NEW_FILE diff -u $OLD_FILE $MY_TEMP/$NEW_FILE cd $MY_TEMP desktop-file-install $OPTS $NEW_FILE cd .. rm -rf $MY_TEMP # vi:ts=4 sw=4 xterm-330/koi8rxterm0000755000175100001440000000725710735744102013317 0ustar tomusers#!/bin/sh # $XTermId: koi8rxterm,v 1.5 2007/12/30 16:33:06 tom Exp $ # ----------------------------------------------------------------------------- # this file is part of xterm # # Copyright 2007 by Thomas E. Dickey # # All Rights Reserved # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name(s) of the above copyright # holders shall not be used in advertising or otherwise to promote the # sale, use or other dealings in this Software without prior written # authorization. # ----------------------------------------------------------------------------- # This is a wrapper script to set up xterm with a KOI8-R locale; based on # uxterm by Branden Robinson. whoami=koi8rxterm : ${XTERM_PROGRAM=xterm} # Check if there is a workable locale program. If there is not, we will read # something via the standard error. Ignore whatever is written to the # standard output. locale=`sh -c "LC_ALL=C LC_CTYPE=C LANG=C locale >/dev/null" 2>&1` found=no # Check for -version and -help options, to provide a simple return without # requiring the program to create a window: if test $# = 1 then case $1 in -v|-ver*|-h|-he*) $XTERM_PROGRAM "$@" exit $? ;; esac fi # Check environment variables that xterm does, in the same order: for name in LC_ALL LC_CTYPE LANG do eval 'value=$'$name if test -n "$value" ; then case $value in *.koi8r|*.KOI8R|*.koi8-r|*.KOI8-R) found=yes ;; *.koi8r@*|*.KOI8R@*|*.koi8-r@*|*.KOI8-R*) found=yes ;; *) # The user may not have configured his or her # locale; try to muddle through anyway. value=ru_RU.KOI8-R ;; esac break fi done # If we didn't find one that uses KOI8-R, modify the safest one. Not everyone # has a KOI8-R locale installed (and there appears to be no trivial/portable # way to determine whether it is, from a shell script). We could check if the # user's shell does not reset unknown locale specifiers, but not all shells do. if test $found != yes ; then if test -n "$value" ; then value=`echo ${value} |sed -e 's/[.@].*//'`.KOI8-R else name="LC_CTYPE" value="ru_RU.KOI8-R" fi eval save=\$${name} eval ${name}=${value} eval export ${name} if test -z "$locale" ; then # The 'locale' program tries to do a sanity check. check=`sh -c "locale >/dev/null" 2>&1` if test -n "$check" ; then eval ${name}=${save} eval export ${name} echo "$whoami tried to use locale $value by setting \$$name" >&2 xmessage -file - < #include #ifndef HAVE_TIGETSTR #undef USE_TERMINFO #endif #ifndef USE_TERMINFO #define USE_TERMINFO 0 #endif #if !USE_TERMINFO #undef HAVE_TIGETSTR #ifndef USE_TERMCAP #define USE_TERMCAP 1 #endif #endif #undef ERR /* workaround for glibc 2.1.3 */ #ifdef HAVE_NCURSES_CURSES_H #include #else #include #endif #ifndef NCURSES_VERSION #ifdef HAVE_TERMCAP_H #include #endif #endif #ifdef HAVE_NCURSES_TERM_H #include #elif defined(HAVE_TERM_H) #include /* tgetent() */ #endif /* * Get rid of conflicting symbols from term.h */ #undef bell /***====================================================================***/ #ifdef __cplusplus extern "C" { #endif #define MOD_NONE 1 #define MOD_SHIFT 1 #define MOD_ALT 2 #define MOD_CTRL 4 #define MOD_META 8 #define MODIFIER_NAME(parm, name) \ (((parm > MOD_NONE) && ((parm - MOD_NONE) & name)) ? " "#name : "") /* xtermcap.c */ extern Bool get_termcap(XtermWidget /* xw */, char * /* name */); extern void set_termcap(XtermWidget /* xw */, const char * /* name */); extern void free_termcap(XtermWidget /* xw */); extern char *get_tcap_buffer(XtermWidget /* xw */); extern char *get_tcap_erase(XtermWidget /* xw */); #if OPT_TCAP_FKEYS extern int xtermcapString(XtermWidget /* xw */, int /* keycode */, unsigned /* mask */); #endif #if OPT_TCAP_QUERY extern int xtermcapKeycode(XtermWidget /* xw */, const char ** /* params */, unsigned * /* state */, Bool * /* fkey */); #endif #ifdef __cplusplus } #endif /* *INDENT-ON* */ #endif /* included_xtermcap_h */ xterm-330/scrollbar.c0000644000175100001440000006302412720360640013373 0ustar tomusers/* $XTermId: scrollbar.c,v 1.200 2016/05/22 16:43:12 tom Exp $ */ /* * Copyright 2000-2014,2016 by Thomas E. Dickey * * All Rights Reserved * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * Except as contained in this notice, the name(s) of the above copyright * holders shall not be used in advertising or otherwise to promote the * sale, use or other dealings in this Software without prior written * authorization. * * * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ #include #include #if defined(HAVE_LIB_XAW) #include #elif defined(HAVE_LIB_XAW3D) #include #elif defined(HAVE_LIB_XAW3DXFT) #include #elif defined(HAVE_LIB_NEXTAW) #include #elif defined(HAVE_LIB_XAWPLUS) #include #endif #if defined(HAVE_XKBQUERYEXTENSION) #include #include #endif #include #include #include #include /* * The scrollbar's border overlaps the border of the vt100 window. If there * is no border for the vt100, there can be no border for the scrollbar. */ #define SCROLLBAR_BORDER(xw) (TScreenOf(xw)->scrollBarBorder) #if OPT_TOOLBAR #define ScrollBarBorder(xw) (BorderWidth(xw) ? SCROLLBAR_BORDER(xw) : 0) #else #define ScrollBarBorder(xw) SCROLLBAR_BORDER(xw) #endif /* Event handlers */ static void ScrollTextTo PROTO_XT_CALLBACK_ARGS; static void ScrollTextUpDownBy PROTO_XT_CALLBACK_ARGS; /* Resize the text window for a terminal screen, modifying the * appropriate WM_SIZE_HINTS and taking advantage of bit gravity. */ void DoResizeScreen(XtermWidget xw) { TScreen *screen = TScreenOf(xw); int border = 2 * screen->border; int min_wide = border + screen->fullVwin.sb_info.width; int min_high = border; XtGeometryResult geomreqresult; Dimension reqWidth, reqHeight, repWidth, repHeight; #ifndef NO_ACTIVE_ICON VTwin *saveWin = WhichVWin(screen); /* all units here want to be in the normal font units */ WhichVWin(screen) = &screen->fullVwin; #endif /* NO_ACTIVE_ICON */ /* * I'm going to try to explain, as I understand it, why we * have to do XGetWMNormalHints and XSetWMNormalHints here, * although I can't guarantee that I've got it right. * * In a correctly written toolkit program, the Shell widget * parses the user supplied geometry argument. However, * because of the way xterm does things, the VT100 widget does * the parsing of the geometry option, not the Shell widget. * The result of this is that the Shell widget doesn't set the * correct window manager hints, and doesn't know that the * user has specified a geometry. * * The XtVaSetValues call below tells the Shell widget to * change its hints. However, since it's confused about the * hints to begin with, it doesn't get them all right when it * does the SetValues -- it undoes some of what the VT100 * widget did when it originally set the hints. * * To fix this, we do the following: * * 1. Get the sizehints directly from the window, going around * the (confused) shell widget. * 2. Call XtVaSetValues to let the shell widget know which * hints have changed. Note that this may not even be * necessary, since we're going to right ahead after that * and set the hints ourselves, but it's good to put it * here anyway, so that when we finally do fix the code so * that the Shell does the right thing with hints, we * already have the XtVaSetValues in place. * 3. We set the sizehints directly, this fixing up whatever * damage was done by the Shell widget during the * XtVaSetValues. * * Gross, huh? * * The correct fix is to redo VTRealize, VTInitialize and * VTSetValues so that font processing happens early enough to * give back responsibility for the size hints to the Shell. * * Someday, we hope to have time to do this. Someday, we hope * to have time to completely rewrite xterm. */ TRACE(("DoResizeScreen\n")); #if 1 /* ndef nothack */ /* * NOTE: the hints and the XtVaSetValues() must match. */ TRACE(("%s@%d -- ", __FILE__, __LINE__)); TRACE_WM_HINTS(xw); getXtermSizeHints(xw); xtermSizeHints(xw, ScrollbarWidth(screen)); /* These are obsolete, but old clients may use them */ xw->hints.width = MaxCols(screen) * FontWidth(screen) + xw->hints.min_width; xw->hints.height = MaxRows(screen) * FontHeight(screen) + xw->hints.min_height; #if OPT_MAXIMIZE /* assure single-increment resize for fullscreen */ if (xw->work.ewmh[0].mode) { xw->hints.width_inc = 1; xw->hints.height_inc = 1; } #endif /* OPT_MAXIMIZE */ #endif XSetWMNormalHints(screen->display, VShellWindow(xw), &xw->hints); reqWidth = (Dimension) (MaxCols(screen) * FontWidth(screen) + min_wide); reqHeight = (Dimension) (MaxRows(screen) * FontHeight(screen) + min_high); #if OPT_MAXIMIZE /* compensate for fullscreen mode */ if (xw->work.ewmh[0].mode) { Screen *xscreen = DefaultScreenOfDisplay(xw->screen.display); reqWidth = (Dimension) WidthOfScreen(xscreen); reqHeight = (Dimension) HeightOfScreen(xscreen); ScreenResize(xw, reqWidth, reqHeight, &xw->flags); } #endif /* OPT_MAXIMIZE */ TRACE(("...requesting screensize chars %dx%d, pixels %dx%d\n", MaxRows(screen), MaxCols(screen), reqHeight, reqWidth)); geomreqresult = REQ_RESIZE((Widget) xw, reqWidth, reqHeight, &repWidth, &repHeight); if (geomreqresult == XtGeometryAlmost) { TRACE(("...almost, retry screensize %dx%d\n", repHeight, repWidth)); geomreqresult = REQ_RESIZE((Widget) xw, repWidth, repHeight, NULL, NULL); } if (geomreqresult != XtGeometryYes) { /* The resize wasn't successful, so we might need to adjust our idea of how large the screen is. */ TRACE(("...still no (%d) - resize the core-class\n", geomreqresult)); xw->core.widget_class->core_class.resize((Widget) xw); } #if 1 /* ndef nothack */ /* * XtMakeResizeRequest() has the undesirable side-effect of clearing * the window manager's hints, even on a failed request. This would * presumably be fixed if the shell did its own work. */ if (xw->hints.flags && repHeight && repWidth) { xw->hints.height = repHeight; xw->hints.width = repWidth; TRACE_HINTS(&xw->hints); XSetWMNormalHints(screen->display, VShellWindow(xw), &xw->hints); } #endif XSync(screen->display, False); /* synchronize */ if (xtermAppPending()) xevents(); #ifndef NO_ACTIVE_ICON WhichVWin(screen) = saveWin; #endif /* NO_ACTIVE_ICON */ } static Widget CreateScrollBar(XtermWidget xw, int x, int y, int height) { Widget result; Arg args[6]; XtSetArg(args[0], XtNx, x); XtSetArg(args[1], XtNy, y); XtSetArg(args[2], XtNheight, height); XtSetArg(args[3], XtNreverseVideo, xw->misc.re_verse); XtSetArg(args[4], XtNorientation, XtorientVertical); XtSetArg(args[5], XtNborderWidth, ScrollBarBorder(xw)); result = XtCreateWidget("scrollbar", scrollbarWidgetClass, (Widget) xw, args, XtNumber(args)); XtAddCallback(result, XtNscrollProc, ScrollTextUpDownBy, 0); XtAddCallback(result, XtNjumpProc, ScrollTextTo, 0); return (result); } void ScrollBarReverseVideo(Widget scrollWidget) { XtermWidget xw = getXtermWidget(scrollWidget); if (xw != 0) { SbInfo *sb = &(TScreenOf(xw)->fullVwin.sb_info); Arg args[4]; Cardinal nargs = XtNumber(args); /* * Remember the scrollbar's original colors. */ if (sb->rv_cached == False) { XtSetArg(args[0], XtNbackground, &(sb->bg)); XtSetArg(args[1], XtNforeground, &(sb->fg)); XtSetArg(args[2], XtNborderColor, &(sb->bdr)); XtSetArg(args[3], XtNborderPixmap, &(sb->bdpix)); XtGetValues(scrollWidget, args, nargs); sb->rv_cached = True; sb->rv_active = 0; } sb->rv_active = !(sb->rv_active); if (sb->rv_active) { XtSetArg(args[0], XtNbackground, sb->fg); XtSetArg(args[1], XtNforeground, sb->bg); } else { XtSetArg(args[0], XtNbackground, sb->bg); XtSetArg(args[1], XtNforeground, sb->fg); } nargs = 2; /* don't set border_pixmap */ if (sb->bdpix == XtUnspecifiedPixmap) { /* if not pixmap then pixel */ if (sb->rv_active) { /* keep border visible */ XtSetArg(args[2], XtNborderColor, args[1].value); } else { XtSetArg(args[2], XtNborderColor, sb->bdr); } nargs = 3; } XtSetValues(scrollWidget, args, nargs); } } void ScrollBarDrawThumb(Widget scrollWidget) { XtermWidget xw = getXtermWidget(scrollWidget); if (xw != 0) { TScreen *screen = TScreenOf(xw); int thumbTop, thumbHeight, totalHeight; thumbTop = ROW2INX(screen, screen->savedlines); thumbHeight = MaxRows(screen); totalHeight = thumbHeight + screen->savedlines; XawScrollbarSetThumb(scrollWidget, ((float) thumbTop) / (float) totalHeight, ((float) thumbHeight) / (float) totalHeight); } } void ResizeScrollBar(XtermWidget xw) { TScreen *screen = TScreenOf(xw); if (screen->scrollWidget != 0) { int height = screen->fullVwin.height + screen->border * 2; int width = screen->scrollWidget->core.width; int ypos = -ScrollBarBorder(xw); #ifdef SCROLLBAR_RIGHT int xpos = ((xw->misc.useRight) ? (screen->fullVwin.fullwidth - screen->scrollWidget->core.width - BorderWidth(screen->scrollWidget)) : -ScrollBarBorder(xw)); #else int xpos = -ScrollBarBorder(xw); #endif TRACE(("ResizeScrollBar at %d,%d %dx%d\n", ypos, xpos, height, width)); XtConfigureWidget( screen->scrollWidget, (Position) xpos, (Position) ypos, (Dimension) width, (Dimension) height, BorderWidth(screen->scrollWidget)); ScrollBarDrawThumb(screen->scrollWidget); } } void WindowScroll(XtermWidget xw, int top, Bool always GCC_UNUSED) { TScreen *screen = TScreenOf(xw); #if OPT_SCROLL_LOCK if (screen->allowScrollLock && (screen->scroll_lock && !always)) { if (screen->scroll_dirty) { screen->scroll_dirty = False; ScrnRefresh(xw, 0, 0, MaxRows(screen), MaxCols(screen), False); } } else #endif { int i; if (top < -screen->savedlines) { top = -screen->savedlines; } else if (top > 0) { top = 0; } if ((i = screen->topline - top) != 0) { int lines; int scrolltop, scrollheight, refreshtop; if (screen->cursor_state) HideCursor(); lines = i > 0 ? i : -i; if (lines > MaxRows(screen)) lines = MaxRows(screen); scrollheight = screen->max_row - lines + 1; if (i > 0) refreshtop = scrolltop = 0; else { scrolltop = lines; refreshtop = scrollheight; } scrolling_copy_area(xw, scrolltop, scrollheight, -i); screen->topline = top; ScrollSelection(screen, i, True); #if OPT_DOUBLE_BUFFER XFillRectangle(screen->display, VDrawable(screen), ReverseGC(xw, screen), OriginX(screen), OriginY(screen) + refreshtop * FontHeight(screen), (unsigned) Width(screen), (unsigned) (lines * FontHeight(screen))); #else XClearArea(screen->display, VWindow(screen), OriginX(screen), OriginY(screen) + refreshtop * FontHeight(screen), (unsigned) Width(screen), (unsigned) (lines * FontHeight(screen)), False); #endif ScrnRefresh(xw, refreshtop, 0, lines, MaxCols(screen), False); #if OPT_BLINK_CURS || OPT_BLINK_TEXT RestartBlinking(screen); #endif } } ScrollBarDrawThumb(screen->scrollWidget); } #ifdef SCROLLBAR_RIGHT /* * Adjust the scrollbar position if we're asked to turn on scrollbars for the * first time (or after resizing) after the xterm is already running. That * makes the window grow after we've initially configured the scrollbar's * position. (There must be a better way). */ void updateRightScrollbar(XtermWidget xw) { TScreen *screen = TScreenOf(xw); if (xw->misc.useRight && screen->fullVwin.fullwidth < xw->core.width) XtVaSetValues(screen->scrollWidget, XtNx, screen->fullVwin.fullwidth - BorderWidth(screen->scrollWidget), (XtPointer) 0); } #endif void ScrollBarOn(XtermWidget xw, Bool init) { TScreen *screen = TScreenOf(xw); if (screen->fullVwin.sb_info.width || IsIcon(screen)) return; TRACE(("ScrollBarOn(init %s)\n", BtoS(init))); if (init) { /* then create it only */ if (screen->scrollWidget == 0) { /* make it a dummy size and resize later */ screen->scrollWidget = CreateScrollBar(xw, -ScrollBarBorder(xw), -ScrollBarBorder(xw), 5); if (screen->scrollWidget == NULL) { Bell(xw, XkbBI_MinorError, 0); } } } else if (!screen->scrollWidget || !XtIsRealized((Widget) xw)) { Bell(xw, XkbBI_MinorError, 0); Bell(xw, XkbBI_MinorError, 0); } else { ResizeScrollBar(xw); xtermAddInput(screen->scrollWidget); XtRealizeWidget(screen->scrollWidget); TRACE_TRANS("scrollbar", screen->scrollWidget); screen->fullVwin.sb_info.rv_cached = False; screen->fullVwin.sb_info.width = (screen->scrollWidget->core.width + BorderWidth(screen->scrollWidget)); TRACE(("setting scrollbar width %d = %d + %d\n", screen->fullVwin.sb_info.width, screen->scrollWidget->core.width, BorderWidth(screen->scrollWidget))); ScrollBarDrawThumb(screen->scrollWidget); DoResizeScreen(xw); #ifdef SCROLLBAR_RIGHT updateRightScrollbar(xw); #endif XtMapWidget(screen->scrollWidget); update_scrollbar(); if (screen->visbuf) { xtermClear(xw); Redraw(); } } } void ScrollBarOff(XtermWidget xw) { TScreen *screen = TScreenOf(xw); if (!screen->fullVwin.sb_info.width || IsIcon(screen)) return; TRACE(("ScrollBarOff\n")); if (XtIsRealized((Widget) xw)) { XtUnmapWidget(screen->scrollWidget); screen->fullVwin.sb_info.width = 0; DoResizeScreen(xw); update_scrollbar(); if (screen->visbuf) { xtermClear(xw); Redraw(); } } else { Bell(xw, XkbBI_MinorError, 0); } } /* * Toggle the visibility of the scrollbars. */ void ToggleScrollBar(XtermWidget xw) { TScreen *screen = TScreenOf(xw); if (IsIcon(screen)) { Bell(xw, XkbBI_MinorError, 0); } else { TRACE(("ToggleScrollBar{{\n")); if (screen->fullVwin.sb_info.width) { ScrollBarOff(xw); } else { ScrollBarOn(xw, False); } update_scrollbar(); TRACE(("...ToggleScrollBar}}\n")); } } /*ARGSUSED*/ static void ScrollTextTo( Widget scrollbarWidget, XtPointer client_data GCC_UNUSED, XtPointer call_data) { XtermWidget xw = getXtermWidget(scrollbarWidget); if (xw != 0) { float *topPercent = (float *) call_data; TScreen *screen = TScreenOf(xw); int thumbTop; /* relative to first saved line */ int newTopLine; /* * screen->savedlines : Number of offscreen text lines, * MaxRows(screen) : Number of onscreen text lines, */ thumbTop = (int) (*topPercent * (float) (screen->savedlines + MaxRows(screen))); newTopLine = thumbTop - screen->savedlines; WindowScroll(xw, newTopLine, True); } } /*ARGSUSED*/ static void ScrollTextUpDownBy( Widget scrollbarWidget, XtPointer client_data GCC_UNUSED, XtPointer call_data) { XtermWidget xw = getXtermWidget(scrollbarWidget); if (xw != 0) { long pixels = (long) call_data; TScreen *screen = TScreenOf(xw); int rowOnScreen, newTopLine; rowOnScreen = (int) (pixels / FontHeight(screen)); if (rowOnScreen == 0) { if (pixels < 0) rowOnScreen = -1; else if (pixels > 0) rowOnScreen = 1; } newTopLine = ROW2INX(screen, rowOnScreen); WindowScroll(xw, newTopLine, True); } } /* * assume that b is alphabetic and allow plural */ static int CompareWidths(const char *a, const char *b, int *modifier) { int result; char ca, cb; *modifier = 0; if (!a || !b) return 0; for (;;) { ca = x_toupper(*a); cb = x_toupper(*b); if (ca != cb || ca == '\0') break; /* if not eq else both nul */ a++, b++; } if (cb != '\0') return 0; if (ca == 'S') ca = *++a; switch (ca) { case '+': case '-': *modifier = (ca == '-' ? -1 : 1) * atoi(a + 1); result = 1; break; case '\0': result = 1; break; default: result = 0; break; } return result; } static long params_to_pixels(TScreen *screen, String *params, Cardinal n) { int mult = 1; const char *s; int modifier; switch (n > 2 ? 2 : n) { case 2: s = params[1]; if (CompareWidths(s, "PAGE", &modifier)) { mult = (MaxRows(screen) + modifier) * FontHeight(screen); } else if (CompareWidths(s, "HALFPAGE", &modifier)) { mult = ((MaxRows(screen) + modifier) * FontHeight(screen)) / 2; } else if (CompareWidths(s, "PIXEL", &modifier)) { mult = 1; } else { /* else assume that it is Line */ mult = FontHeight(screen); } mult *= atoi(params[0]); TRACE(("params_to_pixels(%s,%s) = %d\n", params[0], params[1], mult)); break; case 1: mult = atoi(params[0]) * FontHeight(screen); /* lines */ TRACE(("params_to_pixels(%s) = %d\n", params[0], mult)); break; default: mult = screen->scrolllines * FontHeight(screen); TRACE(("params_to_pixels() = %d\n", mult)); break; } return mult; } static long AmountToScroll(Widget w, String *params, Cardinal nparams) { long result = 0; XtermWidget xw; if ((xw = getXtermWidget(w)) != 0) { TScreen *screen = TScreenOf(xw); if (nparams <= 2 || screen->send_mouse_pos == MOUSE_OFF) { result = params_to_pixels(screen, params, nparams); } } return result; } static void AlternateScroll(Widget w, long amount) { XtermWidget xw; TScreen *screen; if ((xw = getXtermWidget(w)) != 0 && (screen = TScreenOf(xw)) != 0 && screen->alternateScroll && screen->whichBuf) { ANSI reply; amount /= FontHeight(screen); memset(&reply, 0, sizeof(reply)); reply.a_type = ((xw->keyboard.flags & MODE_DECCKM) ? ANSI_SS3 : ANSI_CSI); if (amount > 0) { reply.a_final = 'B'; } else { amount = -amount; reply.a_final = 'A'; } while (amount-- > 0) { unparseseq(xw, &reply); } } else { ScrollTextUpDownBy(w, (XtPointer) 0, (XtPointer) amount); } } /*ARGSUSED*/ void HandleScrollForward( Widget xw, XEvent *event GCC_UNUSED, String *params, Cardinal *nparams) { long amount; if ((amount = AmountToScroll(xw, params, *nparams)) != 0) { AlternateScroll(xw, amount); } } /*ARGSUSED*/ void HandleScrollBack( Widget xw, XEvent *event GCC_UNUSED, String *params, Cardinal *nparams) { long amount; if ((amount = -AmountToScroll(xw, params, *nparams)) != 0) { AlternateScroll(xw, amount); } } #if OPT_SCROLL_LOCK #define SCROLL_LOCK_LED 3 #ifdef HAVE_XKBQUERYEXTENSION /* * Check for Xkb on client and server. */ static int have_xkb(Display *dpy) { static int initialized = -1; if (initialized < 0) { int xkbmajor = XkbMajorVersion; int xkbminor = XkbMinorVersion; int xkbopcode, xkbevent, xkberror; initialized = 0; if (XkbLibraryVersion(&xkbmajor, &xkbminor) && XkbQueryExtension(dpy, &xkbopcode, &xkbevent, &xkberror, &xkbmajor, &xkbminor)) { TRACE(("we have Xkb\n")); initialized = 1; #if OPT_TRACE { XkbDescPtr xkb; unsigned int mask; xkb = XkbGetKeyboard(dpy, XkbAllComponentsMask, XkbUseCoreKbd); if (xkb != NULL) { int n; TRACE(("XkbGetKeyboard ok\n")); for (n = 0; n < XkbNumVirtualMods; ++n) { if (xkb->names->vmods[n] != 0) { char *modStr = XGetAtomName(xkb->dpy, xkb->names->vmods[n]); if (modStr != 0) { XkbVirtualModsToReal(xkb, (unsigned) (1 << n), &mask); TRACE((" name[%d] %s (%#x)\n", n, modStr, mask)); } } } XkbFreeKeyboard(xkb, 0, True); } } #endif } } return initialized; } static Boolean getXkbLED(Display *dpy, const char *name, Boolean *result) { Atom my_atom; Boolean success = False; Bool state; if (have_xkb(dpy)) { my_atom = XInternAtom(dpy, name, False); if ((my_atom != None) && XkbGetNamedIndicator(dpy, my_atom, NULL, &state, NULL, NULL)) { *result = (Boolean) state; success = True; } } return success; } /* * Use Xkb if we have it (still unreliable, but slightly better than hardcoded). */ static Boolean showXkbLED(Display *dpy, const char *name, Bool enable) { Atom my_atom; Boolean result = False; if (have_xkb(dpy)) { my_atom = XInternAtom(dpy, name, False); if ((my_atom != None) && XkbGetNamedIndicator(dpy, my_atom, NULL, NULL, NULL, NULL) && XkbSetNamedIndicator(dpy, my_atom, True, enable, False, NULL)) { result = True; } } return result; } #endif /* * xlsatoms agrees with this list. However Num/Caps lock are generally * unusable due to special treatment in X. They are used here for * completeness. */ static const char *led_table[] = { "Num Lock", "Caps Lock", "Scroll Lock" }; static Boolean xtermGetLED(TScreen *screen, Cardinal led_number) { Display *dpy = screen->display; Boolean result = False; #ifdef HAVE_XKBQUERYEXTENSION if (!getXkbLED(dpy, led_table[led_number - 1], &result)) #endif { XKeyboardState state; unsigned long my_bit = (unsigned long) (1 << (led_number - 1)); XGetKeyboardControl(dpy, &state); result = (Boolean) ((state.led_mask & my_bit) != 0); } TRACE(("xtermGetLED %d:%s\n", led_number, BtoS(result))); return result; } /* * Display the given LED, preferably independent of keyboard state. */ void xtermShowLED(TScreen *screen, Cardinal led_number, Bool enable) { TRACE(("xtermShowLED %d:%s\n", led_number, BtoS(enable))); if ((led_number >= 1) && (led_number <= XtNumber(led_table))) { Display *dpy = screen->display; #ifdef HAVE_XKBQUERYEXTENSION if (!showXkbLED(dpy, led_table[led_number - 1], enable)) #endif { XKeyboardState state; XKeyboardControl values; unsigned long use_mask; unsigned long my_bit = (unsigned long) (1 << (led_number - 1)); XGetKeyboardControl(dpy, &state); use_mask = state.led_mask; if (enable) { use_mask |= my_bit; } else { use_mask &= ~my_bit; } if (state.led_mask != use_mask) { values.led = (int) led_number; values.led_mode = enable; XChangeKeyboardControl(dpy, KBLed | KBLedMode, &values); } } } } void xtermClearLEDs(TScreen *screen) { Display *dpy = screen->display; XKeyboardControl values; TRACE(("xtermClearLEDs\n")); #ifdef HAVE_XKBQUERYEXTENSION ShowScrollLock(screen, False); #endif memset(&values, 0, sizeof(values)); XChangeKeyboardControl(dpy, KBLedMode, &values); } void ShowScrollLock(TScreen *screen, Bool enable) { xtermShowLED(screen, SCROLL_LOCK_LED, enable); } void GetScrollLock(TScreen *screen) { if (screen->allowScrollLock) screen->scroll_lock = xtermGetLED(screen, SCROLL_LOCK_LED); } void SetScrollLock(TScreen *screen, Bool enable) { if (screen->allowScrollLock) { if (screen->scroll_lock != enable) { TRACE(("SetScrollLock %s\n", BtoS(enable))); screen->scroll_lock = (Boolean) enable; ShowScrollLock(screen, enable); } } } /* ARGSUSED */ void HandleScrollLock(Widget w, XEvent *event GCC_UNUSED, String *params, Cardinal *param_count) { XtermWidget xw; if ((xw = getXtermWidget(w)) != 0) { TScreen *screen = TScreenOf(xw); if (screen->allowScrollLock) { switch (decodeToggle(xw, params, *param_count)) { case toggleOff: SetScrollLock(screen, False); break; case toggleOn: SetScrollLock(screen, True); break; case toggleAll: SetScrollLock(screen, !screen->scroll_lock); break; } } } } #endif xterm-330/link_axp.com0000644000175100001440000000546007050367166013563 0ustar tomusers$! $XFree86: xc/programs/xterm/link_axp.com,v 1.1 2000/02/08 17:19:35 dawes Exp $ $ SAVE_VERIFY='F$VERIFY(0) $ if p1 .Eqs. "CLEAN" then goto clean $ if p1 .Eqs. "CLOBBER" then goto clobber $ if p1 .Eqs. "INSTALL" then goto install $! $! Compile the X11R4 Xterm application $! $ Set Symbol/Scope=NoGlobal $! $! Define logicals pointing to the needed directories $! $ x11lib_device = f$parse("[.lib]",,,"DEVICE") $ x11lib_directory = f$parse("[.lib]",,,"DIRECTORY") $ define/nolog x11lib 'x11lib_device''x11lib_directory' $! $ x11inc_device = f$parse("[]",,,"DEVICE") $ x11inc_directory = f$parse("[]",,,"DIRECTORY") $ define/nolog x11inc 'x11inc_device''x11inc_directory' $! $ xmu_device = f$parse("[.lib.xmu]",,,"DEVICE") $ xmu_directory = f$parse("[.lib.xmu]",,,"DIRECTORY") $ define/nolog x11xmu 'xmu_device''xmu_directory' $! $ xbm_device = f$parse("[.lib.x11]",,,"DEVICE") $ xbm_directory = f$parse("[.lib.x11]",,,"DIRECTORY") $ define/nolog x11xbm 'xbm_device''xbm_directory' $! $ xaw_device = f$parse("[.lib.xaw]",,,"DEVICE") $ xaw_directory = f$parse("[.lib.xaw]",,,"DIRECTORY") $ define/nolog x11xaw 'xaw_device''xaw_directory' $! $ x11vms_device = f$parse("[.lib.misc]",,,"DEVICE") $ x11vms_directory = f$parse("[.lib.misc]",,,"DIRECTORY") $ define/nolog x11vms 'x11vms_device''x11vms_directory' $! $! Get the compiler options via the logical name COPTS $! $ cc_options = f$trnlnm("COPTS") $! $! Get the linker options via the logical name LOPTS $! $ link_options = f$trnlnm("LOPTS") $! $ write sys$output "Building XTERM Image" $ CALL MAKE XTERM.EXE "LINK ''link_options' /EXE=XTERM.EXE_AXP/CROSS/FULL/MAP=XTERM.MAP XTERM_AXP/OPT" *.OBJ $! $ deassign x11lib $ deassign x11vms $ deassign x11xmu $ deassign x11xbm $ deassign x11xaw $! $ exit $! $ Clobber: ! Delete executables, Purge directory and clean up object files and listings $ Delete/noconfirm/log *.exe;* $! $ Clean: ! Purge directory, clean up object files and listings $ Purge $ Delete/noconfirm/log *.lis;* $ Delete/noconfirm/log *.obj;* $! $ exit $! $ Install: $ Copy/log *.exe x11bin: $ exit $! $MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES $ V = 'F$Verify(0) $! P1 = What we are trying to make $! P2 = Command to make it $! P3 - P8 What it depends on $ $ If F$Search(P1) .Eqs. "" Then Goto Makeit $ Time = F$CvTime(F$File(P1,"RDT")) $arg=3 $Loop: $ Argument = P'arg $ If Argument .Eqs. "" Then Goto Exit $ El=0 $Loop2: $ File = F$Element(El," ",Argument) $ If File .Eqs. " " Then Goto Endl $ AFile = "" $Loop3: $ OFile = AFile $ AFile = F$Search(File) $ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl $ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit $ Goto Loop3 $NextEL: $ El = El + 1 $ Goto Loop2 $EndL: $ arg=arg+1 $ If arg .Le. 8 Then Goto Loop $ Goto Exit $ $Makeit: $ Set Verify $ 'P2 $ VV='F$Verify(0) $Exit: $ If V Then Set Verify $ENDSUBROUTINE xterm-330/KOI8RXTerm.ad0000644000175100001440000000454011343605075013370 0ustar tomusers! $XTermId: KOI8RXTerm.ad,v 1.4 2010/03/04 01:17:49 tom Exp $ ! ----------------------------------------------------------------------------- ! this file is part of xterm ! ! Copyright 2007,2010 by Thomas E. Dickey ! ! All Rights Reserved ! ! Permission is hereby granted, free of charge, to any person obtaining a ! copy of this software and associated documentation files (the ! "Software"), to deal in the Software without restriction, including ! without limitation the rights to use, copy, modify, merge, publish, ! distribute, sublicense, and/or sell copies of the Software, and to ! permit persons to whom the Software is furnished to do so, subject to ! the following conditions: ! ! The above copyright notice and this permission notice shall be included ! in all copies or substantial portions of the Software. ! ! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ! OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ! MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. ! IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY ! CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, ! TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ! SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ! ! Except as contained in this notice, the name(s) of the above copyright ! holders shall not be used in advertising or otherwise to promote the ! sale, use or other dealings in this Software without prior written ! authorization. ! ----------------------------------------------------------------------------- ! This is based on the UXTerm app-defaults file. ! ----------------------------------------------------------------------------- ! Use ! xterm -class KOI8RXTerm ! to set resources for KOI8-R mode with corresponding fonts. #include "XTerm" *fontMenu.Label: KOI8-R Fonts *VT100*allowC1Printable: true ! Use Cyrillic instead of Latin fonts. *VT100.font: -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-koi8-r *VT100.font2: -misc-fixed-medium-r-normal--8-80-75-75-c-50-koi8-r *VT100.font3: -misc-fixed-medium-r-normal--14-130-75-75-c-70-koi8-r *VT100.font4: -misc-fixed-medium-r-normal--13-120-75-75-c-80-koi8-r *VT100.font5: -misc-fixed-medium-r-normal--18-120-100-100-c-90-koi8-r *VT100.font6: -misc-fixed-medium-r-normal--20-200-75-75-c-100-koi8-r xterm-330/88colres.pl0000755000175100001440000000610110632366343013252 0ustar tomusers#!/usr/bin/perl # $XTermId: 88colres.pl,v 1.17 2007/06/08 23:57:23 tom Exp $ # ----------------------------------------------------------------------------- # this file is part of xterm # # Copyright 1999-2005,2007 by Thomas E. Dickey # Copyright 1999-2000 by Steve Wall # # All Rights Reserved # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name(s) of the above copyright # holders shall not be used in advertising or otherwise to promote the # sale, use or other dealings in this Software without prior written # authorization. # ----------------------------------------------------------------------------- # Made from 256colres.pl # Construct a header file defining default resources for the # 88-color model of xterm. # use the resources for colors 0-15 - usually more-or-less a # reproduction of the standard ANSI colors, but possibly more # pleasing shades use strict; our ( $line1, $line2, $line3 ); our ( $red, $green, $blue, $gray ); our ( $level, $code, @steps ); print < 0 ) { $level += 23.18181818; } $code = 80 + $gray; printf($line1, $code); printf($line2, $code); printf($line3, int($level), int($level), int($level)); } print < at the end of each line. 27-JAN-2000. Discovered a bug when doing an X11 paste into an EDT session, had to add a tt_start_read() in button.c after the paste to reenable the read AST. Rearranged code in VMS.C to make the compiler happy and eliminate warnings. David Mathog mathog@seqaxp.bio.caltech.edu Manager, sequence analysis facility, biology division, Caltech $XFree86: xc/programs/xterm/AAA_README_VMS.txt,v 1.2 2000/06/13 02:28:37 dawes Exp $ xterm-330/run-tic.sh0000755000175100001440000000407410635251573013173 0ustar tomusers#!/bin/sh # $XTermId: run-tic.sh,v 1.4 2007/06/17 15:30:03 tom Exp $ # ----------------------------------------------------------------------------- # this file is part of xterm # # Copyright 2006,2007 by Thomas E. Dickey # # All Rights Reserved # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name(s) of the above copyright # holders shall not be used in advertising or otherwise to promote the # sale, use or other dealings in this Software without prior written # authorization. # ----------------------------------------------------------------------------- # # Run tic, either using ncurses' extension feature or filtering out harmless # messages for the extensions which are otherwise ignored by other versions of # tic. TMP=run-tic$$.log VER=`tic -V 2>/dev/null` OPT= case .$VER in .ncurses*) OPT="-x" ;; esac echo "** tic $OPT" "$@" tic $OPT "$@" 2>$TMP RET=$? fgrep -v 'Unknown Capability' $TMP | \ fgrep -v 'Capability is not recognized:' | \ fgrep -v 'tic: Warning near line ' >&2 rm -f $TMP exit $RET xterm-330/VTPrsTbl.c0000644000175100001440000055140412470246467013110 0ustar tomusers/* $XTermId: VTPrsTbl.c,v 1.81 2015/02/16 01:51:51 tom Exp $ */ /* * Copyright 1999-2014,2015 by Thomas E. Dickey * * All Rights Reserved * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * Except as contained in this notice, the name(s) of the above copyright * holders shall not be used in advertising or otherwise to promote the * sale, use or other dealings in this Software without prior written * authorization. * * * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ #include /* *INDENT-OFF* */ #if !OPT_BLINK_CURS #undef CASE_CSI_SPACE_STATE #define CASE_CSI_SPACE_STATE CASE_CSI_IGNORE #endif #if !OPT_DEC_LOCATOR #undef CASE_DECEFR #define CASE_DECEFR CASE_CSI_IGNORE #undef CASE_DECELR #define CASE_DECELR CASE_CSI_IGNORE #undef CASE_DECSLE #define CASE_DECSLE CASE_CSI_IGNORE #undef CASE_DECRQLP #define CASE_DECRQLP CASE_CSI_IGNORE #endif #if !OPT_WIDE_CHARS #undef CASE_ESC_PERCENT #define CASE_ESC_PERCENT CASE_ESC_IGNORE #endif #if !OPT_MOD_FKEYS #undef CASE_SET_MOD_FKEYS #define CASE_SET_MOD_FKEYS CASE_GROUND_STATE #undef CASE_SET_MOD_FKEYS0 #define CASE_SET_MOD_FKEYS0 CASE_GROUND_STATE #endif /* * Stupid Apollo C preprocessor can't handle long lines. So... To keep * it happy, we put each onto a separate line.... Sigh... */ Const PARSE_T ansi_table[] = { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_ENQ, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* FF CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_GROUND_STATE, CASE_IGNORE, CASE_GROUND_STATE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* $ % & ' */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* ( ) * + */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* , - . / */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* 0 1 2 3 */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* 4 5 6 7 */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* 8 9 : ; */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* < = > ? */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* @ A B C */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* D E F G */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* H I J K */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* L M N O */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* P Q R S */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* T U V W */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* X Y Z [ */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* \ ] ^ _ */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* ` a b c */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* d e f g */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* h i j k */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* l m n o */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* p q r s */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* t u v w */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* x y z { */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* | } ~ DEL */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x84 0x85 0x86 0x87 */ CASE_IND, CASE_NEL, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x88 0x89 0x8a 0x8b */ CASE_HTS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_GROUND_STATE, CASE_RI, CASE_SS2, CASE_SS3, /* 0x90 0x91 0x92 0x93 */ CASE_DCS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x94 0x95 0x96 0x97 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_SPA, CASE_EPA, /* 0x98 0x99 0x9a 0x9b */ CASE_SOS, CASE_GROUND_STATE, CASE_DECID, CASE_CSI_STATE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_ST, CASE_OSC, CASE_PM, CASE_APC, /* nobreakspace exclamdown cent sterling */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* currency yen brokenbar section */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* diaeresis copyright ordfeminine guillemotleft */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* notsign hyphen registered macron */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* degree plusminus twosuperior threesuperior */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* acute mu paragraph periodcentered */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* cedilla onesuperior masculine guillemotright */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* onequarter onehalf threequarters questiondown */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Agrave Aacute Acircumflex Atilde */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Adiaeresis Aring AE Ccedilla */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Eth Ntilde Ograve Oacute */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* Udiaeresis Yacute Thorn ssharp */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* agrave aacute acircumflex atilde */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* adiaeresis aring ae ccedilla */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* egrave eacute ecircumflex ediaeresis */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* igrave iacute icircumflex idiaeresis */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* eth ntilde ograve oacute */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* ocircumflex otilde odiaeresis division */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* oslash ugrave uacute ucircumflex */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* udiaeresis yacute thorn ydiaeresis */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, }; Const PARSE_T csi_table[] = /* CSI */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_ENQ, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* FF CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_GROUND_STATE, CASE_IGNORE, CASE_GROUND_STATE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_CSI_SPACE_STATE, CASE_CSI_EX_STATE, CASE_CSI_QUOTE_STATE, CASE_CSI_IGNORE, /* $ % & ' */ CASE_CSI_DOLLAR_STATE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_TICK_STATE, /* ( ) * + */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* , - . / */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* 0 1 2 3 */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, /* 4 5 6 7 */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, /* 8 9 : ; */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_COLON, CASE_ESC_SEMI, /* < = > ? */ CASE_CSI_IGNORE, CASE_DEC3_STATE, CASE_DEC2_STATE, CASE_DEC_STATE, /* @ A B C */ CASE_ICH, CASE_CUU, CASE_CUD, CASE_CUF, /* D E F G */ CASE_CUB, CASE_CNL, CASE_CPL, CASE_HPA, /* H I J K */ CASE_CUP, CASE_CHT, CASE_ED, CASE_EL, /* L M N O */ CASE_IL, CASE_DL, CASE_GROUND_STATE, CASE_GROUND_STATE, /* P Q R S */ CASE_DCH, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_SU, /* T U V W */ CASE_TRACK_MOUSE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_ECH, CASE_GROUND_STATE, CASE_CBT, CASE_GROUND_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ` a b c */ CASE_HPA, CASE_HPR, CASE_REP, CASE_DA1, /* d e f g */ CASE_VPA, CASE_VPR, CASE_CUP, CASE_TBC, /* h i j k */ CASE_SET, CASE_MC, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_RST, CASE_SGR, CASE_CPR, CASE_GROUND_STATE, /* p q r s */ CASE_GROUND_STATE, CASE_DECLL, CASE_DECSTBM, CASE_ANSI_SC, /* t u v w */ CASE_XTERM_WINOPS, CASE_ANSI_RC, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_DECREQTPARM, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x84 0x85 0x86 0x87 */ CASE_IND, CASE_NEL, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x88 0x89 0x8a 0x8b */ CASE_HTS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_GROUND_STATE, CASE_RI, CASE_SS2, CASE_SS3, /* 0x90 0x91 0x92 0x93 */ CASE_DCS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x94 0x95 0x96 0x97 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_SPA, CASE_EPA, /* 0x98 0x99 0x9a 0x9b */ CASE_SOS, CASE_GROUND_STATE, CASE_DECID, CASE_CSI_STATE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_ST, CASE_OSC, CASE_PM, CASE_APC, /* nobreakspace exclamdown cent sterling */ CASE_CSI_SPACE_STATE, CASE_CSI_EX_STATE, CASE_CSI_QUOTE_STATE, CASE_CSI_IGNORE, /* currency yen brokenbar section */ CASE_CSI_DOLLAR_STATE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_TICK_STATE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* notsign hyphen registered macron */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, /* acute mu paragraph periodcentered */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, /* cedilla onesuperior masculine guillemotright */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_COLON, CASE_ESC_SEMI, /* onequarter onehalf threequarters questiondown */ CASE_CSI_IGNORE, CASE_DEC3_STATE, CASE_DEC2_STATE, CASE_DEC_STATE, /* Agrave Aacute Acircumflex Atilde */ CASE_ICH, CASE_CUU, CASE_CUD, CASE_CUF, /* Adiaeresis Aring AE Ccedilla */ CASE_CUB, CASE_CNL, CASE_CPL, CASE_HPA, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_CUP, CASE_CHT, CASE_ED, CASE_EL, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_IL, CASE_DL, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_DCH, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_SU, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_TRACK_MOUSE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_ECH, CASE_GROUND_STATE, CASE_CBT, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_HPA, CASE_HPR, CASE_REP, CASE_DA1, /* adiaeresis aring ae ccedilla */ CASE_VPA, CASE_VPR, CASE_CUP, CASE_TBC, /* egrave eacute ecircumflex ediaeresis */ CASE_SET, CASE_MC, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_RST, CASE_SGR, CASE_CPR, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_GROUND_STATE, CASE_DECLL, CASE_DECSTBM, CASE_ANSI_SC, /* ocircumflex otilde odiaeresis division */ CASE_XTERM_WINOPS, CASE_ANSI_RC, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_DECREQTPARM, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, }; Const PARSE_T csi2_table[] = /* CSI */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_ENQ, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* FF CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_GROUND_STATE, CASE_IGNORE, CASE_GROUND_STATE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_CSI_SPACE_STATE, CASE_CSI_EX_STATE, CASE_CSI_QUOTE_STATE, CASE_CSI_IGNORE, /* $ % & ' */ CASE_CSI_DOLLAR_STATE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_TICK_STATE, /* ( ) * + */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_STAR_STATE, CASE_CSI_IGNORE, /* , - . / */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* 0 1 2 3 */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, /* 4 5 6 7 */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, /* 8 9 : ; */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_COLON, CASE_ESC_SEMI, /* < = > ? */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* @ A B C */ CASE_ICH, CASE_CUU, CASE_CUD, CASE_CUF, /* D E F G */ CASE_CUB, CASE_CNL, CASE_CPL, CASE_HPA, /* H I J K */ CASE_CUP, CASE_CHT, CASE_ED, CASE_EL, /* L M N O */ CASE_IL, CASE_DL, CASE_GROUND_STATE, CASE_GROUND_STATE, /* P Q R S */ CASE_DCH, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_SU, /* T U V W */ CASE_TRACK_MOUSE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_ECH, CASE_GROUND_STATE, CASE_CBT, CASE_GROUND_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ` a b c */ CASE_HPA, CASE_HPR, CASE_REP, CASE_DA1, /* d e f g */ CASE_VPA, CASE_VPR, CASE_CUP, CASE_TBC, /* h i j k */ CASE_SET, CASE_MC, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_RST, CASE_SGR, CASE_CPR, CASE_GROUND_STATE, /* p q r s */ CASE_GROUND_STATE, CASE_DECLL, CASE_DECSTBM, CASE_ANSI_SC, /* t u v w */ CASE_XTERM_WINOPS, CASE_ANSI_RC, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_DECREQTPARM, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x84 0x85 0x86 0x87 */ CASE_IND, CASE_NEL, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x88 0x89 0x8a 0x8b */ CASE_HTS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_GROUND_STATE, CASE_RI, CASE_SS2, CASE_SS3, /* 0x90 0x91 0x92 0x93 */ CASE_DCS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x94 0x95 0x96 0x97 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_SPA, CASE_EPA, /* 0x98 0x99 0x9a 0x9b */ CASE_SOS, CASE_GROUND_STATE, CASE_DECID, CASE_CSI_STATE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_ST, CASE_OSC, CASE_PM, CASE_APC, /* nobreakspace exclamdown cent sterling */ CASE_CSI_SPACE_STATE, CASE_CSI_EX_STATE, CASE_CSI_QUOTE_STATE, CASE_CSI_IGNORE, /* currency yen brokenbar section */ CASE_CSI_DOLLAR_STATE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_TICK_STATE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_STAR_STATE, CASE_CSI_IGNORE, /* notsign hyphen registered macron */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, /* acute mu paragraph periodcentered */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, /* cedilla onesuperior masculine guillemotright */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_COLON, CASE_ESC_SEMI, /* onequarter onehalf threequarters questiondown */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* Agrave Aacute Acircumflex Atilde */ CASE_ICH, CASE_CUU, CASE_CUD, CASE_CUF, /* Adiaeresis Aring AE Ccedilla */ CASE_CUB, CASE_CNL, CASE_CPL, CASE_HPA, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_CUP, CASE_CHT, CASE_ED, CASE_EL, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_IL, CASE_DL, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_DCH, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_SU, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_TRACK_MOUSE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_ECH, CASE_GROUND_STATE, CASE_CBT, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_HPA, CASE_HPR, CASE_REP, CASE_DA1, /* adiaeresis aring ae ccedilla */ CASE_VPA, CASE_VPR, CASE_CUP, CASE_TBC, /* egrave eacute ecircumflex ediaeresis */ CASE_SET, CASE_MC, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_RST, CASE_SGR, CASE_CPR, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_GROUND_STATE, CASE_DECLL, CASE_DECSTBM, CASE_ANSI_SC, /* ocircumflex otilde odiaeresis division */ CASE_XTERM_WINOPS, CASE_ANSI_RC, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_DECREQTPARM, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, }; Const PARSE_T csi_ex_table[] = /* CSI ! */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_ENQ, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* FF CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_GROUND_STATE, CASE_IGNORE, CASE_GROUND_STATE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* $ % & ' */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* ( ) * + */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* , - . / */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* 0 1 2 3 */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* 4 5 6 7 */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* 8 9 : ; */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* < = > ? */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* @ A B C */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* D E F G */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* H I J K */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* L M N O */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* P Q R S */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* T U V W */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ` a b c */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* h i j k */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* p q r s */ CASE_DECSTR, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* t u v w */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x84 0x85 0x86 0x87 */ CASE_IND, CASE_NEL, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x88 0x89 0x8a 0x8b */ CASE_HTS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_GROUND_STATE, CASE_RI, CASE_SS2, CASE_SS3, /* 0x90 0x91 0x92 0x93 */ CASE_DCS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x94 0x95 0x96 0x97 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_SPA, CASE_EPA, /* 0x98 0x99 0x9a 0x9b */ CASE_SOS, CASE_GROUND_STATE, CASE_DECID, CASE_CSI_STATE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_ST, CASE_OSC, CASE_PM, CASE_APC, /* nobreakspace exclamdown cent sterling */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* currency yen brokenbar section */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* notsign hyphen registered macron */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* acute mu paragraph periodcentered */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* cedilla onesuperior masculine guillemotright */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* onequarter onehalf threequarters questiondown */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* Agrave Aacute Acircumflex Atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_DECSTR, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ocircumflex otilde odiaeresis division */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, }; Const PARSE_T csi_quo_table[] = /* CSI ... " */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_ENQ, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* FF CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_GROUND_STATE, CASE_IGNORE, CASE_GROUND_STATE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* $ % & ' */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* ( ) * + */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* , - . / */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* 0 1 2 3 */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* 4 5 6 7 */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* 8 9 : ; */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* < = > ? */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* @ A B C */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* D E F G */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* H I J K */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* L M N O */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* P Q R S */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* T U V W */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ` a b c */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* h i j k */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* p q r s */ CASE_DECSCL, CASE_DECSCA, CASE_GROUND_STATE, CASE_GROUND_STATE, /* t u v w */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x84 0x85 0x86 0x87 */ CASE_IND, CASE_NEL, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x88 0x89 0x8a 0x8b */ CASE_HTS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_GROUND_STATE, CASE_RI, CASE_SS2, CASE_SS3, /* 0x90 0x91 0x92 0x93 */ CASE_DCS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x94 0x95 0x96 0x97 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_SPA, CASE_EPA, /* 0x98 0x99 0x9a 0x9b */ CASE_SOS, CASE_GROUND_STATE, CASE_DECID, CASE_CSI_STATE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_ST, CASE_OSC, CASE_PM, CASE_APC, /* nobreakspace exclamdown cent sterling */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* currency yen brokenbar section */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* notsign hyphen registered macron */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* acute mu paragraph periodcentered */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* cedilla onesuperior masculine guillemotright */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* onequarter onehalf threequarters questiondown */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* Agrave Aacute Acircumflex Atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_DECSCL, CASE_DECSCA, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ocircumflex otilde odiaeresis division */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, }; #if OPT_BLINK_CURS Const PARSE_T csi_sp_table[] = /* CSI ... SP */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_ENQ, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* FF CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_GROUND_STATE, CASE_IGNORE, CASE_GROUND_STATE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* $ % & ' */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* ( ) * + */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* , - . / */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* 0 1 2 3 */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* 4 5 6 7 */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* 8 9 : ; */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* < = > ? */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* @ A B C */ CASE_SL, CASE_SR, CASE_GROUND_STATE, CASE_GROUND_STATE, /* D E F G */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* H I J K */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* L M N O */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* P Q R S */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* T U V W */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ` a b c */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* h i j k */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* p q r s */ CASE_GROUND_STATE, CASE_DECSCUSR, CASE_GROUND_STATE, CASE_GROUND_STATE, /* t u v w */ CASE_DECSWBV, CASE_DECSMBV, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x84 0x85 0x86 0x87 */ CASE_IND, CASE_NEL, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x88 0x89 0x8a 0x8b */ CASE_HTS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_GROUND_STATE, CASE_RI, CASE_SS2, CASE_SS3, /* 0x90 0x91 0x92 0x93 */ CASE_DCS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x94 0x95 0x96 0x97 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_SPA, CASE_EPA, /* 0x98 0x99 0x9a 0x9b */ CASE_SOS, CASE_GROUND_STATE, CASE_DECID, CASE_CSI_STATE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_ST, CASE_OSC, CASE_PM, CASE_APC, /* nobreakspace exclamdown cent sterling */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* currency yen brokenbar section */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* notsign hyphen registered macron */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* acute mu paragraph periodcentered */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* cedilla onesuperior masculine guillemotright */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* onequarter onehalf threequarters questiondown */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* Agrave Aacute Acircumflex Atilde */ CASE_SL, CASE_SR, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_GROUND_STATE, CASE_DECSCUSR, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ocircumflex otilde odiaeresis division */ CASE_DECSWBV, CASE_DECSMBV, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, }; #endif Const PARSE_T csi_tick_table[] = /* CSI ... ' */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_ENQ, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* FF CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_GROUND_STATE, CASE_IGNORE, CASE_GROUND_STATE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* $ % & ' */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* ( ) * + */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* , - . / */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* 0 1 2 3 */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* 4 5 6 7 */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* 8 9 : ; */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* < = > ? */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* @ A B C */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* D E F G */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* H I J K */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* L M N O */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* P Q R S */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* T U V W */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ` a b c */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* h i j k */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* p q r s */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* t u v w */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_DECEFR, /* x y z { */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_DECELR, CASE_DECSLE, /* | } ~ DEL */ CASE_DECRQLP, CASE_DECIC, CASE_DECDC, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x84 0x85 0x86 0x87 */ CASE_IND, CASE_NEL, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x88 0x89 0x8a 0x8b */ CASE_HTS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_GROUND_STATE, CASE_RI, CASE_SS2, CASE_SS3, /* 0x90 0x91 0x92 0x93 */ CASE_DCS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x94 0x95 0x96 0x97 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_SPA, CASE_EPA, /* 0x98 0x99 0x9a 0x9b */ CASE_SOS, CASE_GROUND_STATE, CASE_DECID, CASE_CSI_STATE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_ST, CASE_OSC, CASE_PM, CASE_APC, /* nobreakspace exclamdown cent sterling */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* currency yen brokenbar section */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* notsign hyphen registered macron */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* acute mu paragraph periodcentered */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* cedilla onesuperior masculine guillemotright */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* onequarter onehalf threequarters questiondown */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* Agrave Aacute Acircumflex Atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ocircumflex otilde odiaeresis division */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_DECEFR, /* oslash ugrave uacute ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_DECELR, CASE_DECSLE, /* udiaeresis yacute thorn ydiaeresis */ CASE_DECRQLP, CASE_DECIC, CASE_DECDC, CASE_IGNORE, }; #if OPT_DEC_RECTOPS Const PARSE_T csi_dollar_table[] = /* CSI ... $ */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_ENQ, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* FF CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_GROUND_STATE, CASE_IGNORE, CASE_GROUND_STATE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* $ % & ' */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* ( ) * + */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* , - . / */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* 0 1 2 3 */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* 4 5 6 7 */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* 8 9 : ; */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* < = > ? */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* @ A B C */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* D E F G */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* H I J K */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* L M N O */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* P Q R S */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* T U V W */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ` a b c */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* h i j k */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* p q r s */ CASE_RQM, CASE_GROUND_STATE, CASE_DECCARA, CASE_GROUND_STATE, /* t u v w */ CASE_DECRARA, CASE_GROUND_STATE, CASE_DECCRA, CASE_GROUND_STATE, /* x y z { */ CASE_DECFRA, CASE_GROUND_STATE, CASE_DECERA, CASE_DECSERA, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x84 0x85 0x86 0x87 */ CASE_IND, CASE_NEL, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x88 0x89 0x8a 0x8b */ CASE_HTS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_GROUND_STATE, CASE_RI, CASE_SS2, CASE_SS3, /* 0x90 0x91 0x92 0x93 */ CASE_DCS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x94 0x95 0x96 0x97 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_SPA, CASE_EPA, /* 0x98 0x99 0x9a 0x9b */ CASE_SOS, CASE_GROUND_STATE, CASE_DECID, CASE_CSI_STATE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_ST, CASE_OSC, CASE_PM, CASE_APC, /* nobreakspace exclamdown cent sterling */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* currency yen brokenbar section */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* notsign hyphen registered macron */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* acute mu paragraph periodcentered */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* cedilla onesuperior masculine guillemotright */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* onequarter onehalf threequarters questiondown */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* Agrave Aacute Acircumflex Atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_RQM, CASE_GROUND_STATE, CASE_DECCARA, CASE_GROUND_STATE, /* ocircumflex otilde odiaeresis division */ CASE_DECRARA, CASE_GROUND_STATE, CASE_DECCRA, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_DECFRA, CASE_GROUND_STATE, CASE_DECERA, CASE_DECSERA, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, }; Const PARSE_T csi_star_table[] = /* CSI ... * */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_ENQ, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* FF CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_GROUND_STATE, CASE_IGNORE, CASE_GROUND_STATE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* $ % & ' */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* ( ) * + */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* , - . / */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* 0 1 2 3 */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* 4 5 6 7 */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* 8 9 : ; */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* < = > ? */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* @ A B C */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* D E F G */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* H I J K */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* L M N O */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* P Q R S */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* T U V W */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ` a b c */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* h i j k */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* p q r s */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* t u v w */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_DECSACE, CASE_DECRQCRA, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x84 0x85 0x86 0x87 */ CASE_IND, CASE_NEL, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x88 0x89 0x8a 0x8b */ CASE_HTS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_GROUND_STATE, CASE_RI, CASE_SS2, CASE_SS3, /* 0x90 0x91 0x92 0x93 */ CASE_DCS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x94 0x95 0x96 0x97 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_SPA, CASE_EPA, /* 0x98 0x99 0x9a 0x9b */ CASE_SOS, CASE_GROUND_STATE, CASE_DECID, CASE_CSI_STATE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_ST, CASE_OSC, CASE_PM, CASE_APC, /* nobreakspace exclamdown cent sterling */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* currency yen brokenbar section */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* notsign hyphen registered macron */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* acute mu paragraph periodcentered */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* cedilla onesuperior masculine guillemotright */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* onequarter onehalf threequarters questiondown */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* Agrave Aacute Acircumflex Atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ocircumflex otilde odiaeresis division */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_DECSACE, CASE_DECRQCRA, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, }; #endif /* OPT_DEC_RECTOPS */ Const PARSE_T dec_table[] = /* CSI ? */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_ENQ, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* FF CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_GROUND_STATE, CASE_IGNORE, CASE_GROUND_STATE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* $ % & ' */ CASE_CSI_DEC_DOLLAR_STATE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* ( ) * + */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* , - . / */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* 0 1 2 3 */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, /* 4 5 6 7 */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, /* 8 9 : ; */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_COLON, CASE_ESC_SEMI, /* < = > ? */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* @ A B C */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* D E F G */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* H I J K */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_DECSED, CASE_DECSEL, /* L M N O */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* P Q R S */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GRAPHICS_ATTRIBUTES, /* T U V W */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ` a b c */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* h i j k */ CASE_DECSET, CASE_DEC_MC, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_DECRST, CASE_GROUND_STATE, CASE_DSR, CASE_GROUND_STATE, /* p q r s */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_XTERM_RESTORE, CASE_XTERM_SAVE, /* t u v w */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x84 0x85 0x86 0x87 */ CASE_IND, CASE_NEL, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x88 0x89 0x8a 0x8b */ CASE_HTS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_GROUND_STATE, CASE_RI, CASE_SS2, CASE_SS3, /* 0x90 0x91 0x92 0x93 */ CASE_DCS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x94 0x95 0x96 0x97 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_SPA, CASE_EPA, /* 0x98 0x99 0x9a 0x9b */ CASE_SOS, CASE_GROUND_STATE, CASE_DECID, CASE_CSI_STATE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_ST, CASE_OSC, CASE_PM, CASE_APC, /* nobreakspace exclamdown cent sterling */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* currency yen brokenbar section */ CASE_CSI_DEC_DOLLAR_STATE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* notsign hyphen registered macron */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, /* acute mu paragraph periodcentered */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, /* cedilla onesuperior masculine guillemotright */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_COLON, CASE_ESC_SEMI, /* onequarter onehalf threequarters questiondown */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* Agrave Aacute Acircumflex Atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_DECSED, CASE_DECSEL, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GRAPHICS_ATTRIBUTES, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_DECSET, CASE_DEC_MC, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_DECRST, CASE_GROUND_STATE, CASE_DSR, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_XTERM_RESTORE, CASE_XTERM_SAVE, /* ocircumflex otilde odiaeresis division */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, }; #if OPT_DEC_RECTOPS Const PARSE_T csi_dec_dollar_table[] = /* CSI ?... $ */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_ENQ, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* FF CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_GROUND_STATE, CASE_IGNORE, CASE_GROUND_STATE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* $ % & ' */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* ( ) * + */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* , - . / */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* 0 1 2 3 */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* 4 5 6 7 */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* 8 9 : ; */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* < = > ? */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* @ A B C */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* D E F G */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* H I J K */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* L M N O */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* P Q R S */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* T U V W */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ` a b c */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* h i j k */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* p q r s */ CASE_DECRQM, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* t u v w */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x84 0x85 0x86 0x87 */ CASE_IND, CASE_NEL, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x88 0x89 0x8a 0x8b */ CASE_HTS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_GROUND_STATE, CASE_RI, CASE_SS2, CASE_SS3, /* 0x90 0x91 0x92 0x93 */ CASE_DCS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x94 0x95 0x96 0x97 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_SPA, CASE_EPA, /* 0x98 0x99 0x9a 0x9b */ CASE_SOS, CASE_GROUND_STATE, CASE_DECID, CASE_CSI_STATE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_ST, CASE_OSC, CASE_PM, CASE_APC, /* nobreakspace exclamdown cent sterling */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* currency yen brokenbar section */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* notsign hyphen registered macron */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* acute mu paragraph periodcentered */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* cedilla onesuperior masculine guillemotright */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* onequarter onehalf threequarters questiondown */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* Agrave Aacute Acircumflex Atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_DECRQM, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ocircumflex otilde odiaeresis division */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, }; #endif /* OPT_DEC_RECTOPS */ Const PARSE_T dec2_table[] = /* CSI > */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_ENQ, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* FF CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_GROUND_STATE, CASE_IGNORE, CASE_GROUND_STATE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* $ % & ' */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* ( ) * + */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* , - . / */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* 0 1 2 3 */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, /* 4 5 6 7 */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, /* 8 9 : ; */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_COLON, CASE_ESC_SEMI, /* < = > ? */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* @ A B C */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* D E F G */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* H I J K */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* L M N O */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* P Q R S */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* T U V W */ CASE_RM_TITLE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ` a b c */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_DA2, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* h i j k */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_GROUND_STATE, CASE_SET_MOD_FKEYS, CASE_SET_MOD_FKEYS0, CASE_GROUND_STATE, /* p q r s */ CASE_HIDE_POINTER, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* t u v w */ CASE_SM_TITLE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x84 0x85 0x86 0x87 */ CASE_IND, CASE_NEL, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x88 0x89 0x8a 0x8b */ CASE_HTS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_GROUND_STATE, CASE_RI, CASE_SS2, CASE_SS3, /* 0x90 0x91 0x92 0x93 */ CASE_DCS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x94 0x95 0x96 0x97 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_SPA, CASE_EPA, /* 0x98 0x99 0x9a 0x9b */ CASE_SOS, CASE_GROUND_STATE, CASE_DECID, CASE_CSI_STATE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_ST, CASE_OSC, CASE_PM, CASE_APC, /* nobreakspace exclamdown cent sterling */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* currency yen brokenbar section */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* notsign hyphen registered macron */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, /* acute mu paragraph periodcentered */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, /* cedilla onesuperior masculine guillemotright */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_COLON, CASE_ESC_SEMI, /* onequarter onehalf threequarters questiondown */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* Agrave Aacute Acircumflex Atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_RM_TITLE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_DA2, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_GROUND_STATE, CASE_SET_MOD_FKEYS, CASE_SET_MOD_FKEYS0, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_HIDE_POINTER, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ocircumflex otilde odiaeresis division */ CASE_SM_TITLE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, }; Const PARSE_T dec3_table[] = /* CSI = */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_ENQ, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* FF CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_GROUND_STATE, CASE_IGNORE, CASE_GROUND_STATE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* $ % & ' */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* ( ) * + */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* , - . / */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* 0 1 2 3 */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, /* 4 5 6 7 */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, /* 8 9 : ; */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_COLON, CASE_ESC_SEMI, /* < = > ? */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* @ A B C */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* D E F G */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* H I J K */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* L M N O */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* P Q R S */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* T U V W */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ` a b c */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_DECRPTUI, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* h i j k */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* p q r s */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* t u v w */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x84 0x85 0x86 0x87 */ CASE_IND, CASE_NEL, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x88 0x89 0x8a 0x8b */ CASE_HTS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_GROUND_STATE, CASE_RI, CASE_SS2, CASE_SS3, /* 0x90 0x91 0x92 0x93 */ CASE_DCS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x94 0x95 0x96 0x97 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_SPA, CASE_EPA, /* 0x98 0x99 0x9a 0x9b */ CASE_SOS, CASE_GROUND_STATE, CASE_DECID, CASE_CSI_STATE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_ST, CASE_OSC, CASE_PM, CASE_APC, /* nobreakspace exclamdown cent sterling */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* currency yen brokenbar section */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* notsign hyphen registered macron */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, /* acute mu paragraph periodcentered */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_DIGIT, /* cedilla onesuperior masculine guillemotright */ CASE_ESC_DIGIT, CASE_ESC_DIGIT, CASE_ESC_COLON, CASE_ESC_SEMI, /* onequarter onehalf threequarters questiondown */ CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, CASE_CSI_IGNORE, /* Agrave Aacute Acircumflex Atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_DECRPTUI, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ocircumflex otilde odiaeresis division */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, }; Const PARSE_T cigtable[] = /* CASE_CSI_IGNORE */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_ENQ, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* FF CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_GROUND_STATE, CASE_IGNORE, CASE_GROUND_STATE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* $ % & ' */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ( ) * + */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* , - . / */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0 1 2 3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 4 5 6 7 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 8 9 : ; */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* < = > ? */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* @ A B C */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* D E F G */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* H I J K */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* L M N O */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* P Q R S */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* T U V W */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ` a b c */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* h i j k */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* p q r s */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* t u v w */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x84 0x85 0x86 0x87 */ CASE_IND, CASE_NEL, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x88 0x89 0x8a 0x8b */ CASE_HTS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_GROUND_STATE, CASE_RI, CASE_SS2, CASE_SS3, /* 0x90 0x91 0x92 0x93 */ CASE_DCS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x94 0x95 0x96 0x97 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_SPA, CASE_EPA, /* 0x98 0x99 0x9a 0x9b */ CASE_SOS, CASE_GROUND_STATE, CASE_DECID, CASE_CSI_STATE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_ST, CASE_OSC, CASE_PM, CASE_APC, /* nobreakspace exclamdown cent sterling */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* currency yen brokenbar section */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* notsign hyphen registered macron */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* acute mu paragraph periodcentered */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* cedilla onesuperior masculine guillemotright */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* onequarter onehalf threequarters questiondown */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Agrave Aacute Acircumflex Atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ocircumflex otilde odiaeresis division */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, }; Const PARSE_T eigtable[] = /* CASE_ESC_IGNORE */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_ENQ, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* FF CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_GROUND_STATE, CASE_IGNORE, CASE_GROUND_STATE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* $ % & ' */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ( ) * + */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* , - . / */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0 1 2 3 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 4 5 6 7 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 8 9 : ; */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* < = > ? */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* @ A B C */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* D E F G */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* H I J K */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* L M N O */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* P Q R S */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* T U V W */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ` a b c */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* h i j k */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* p q r s */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* t u v w */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x84 0x85 0x86 0x87 */ CASE_IND, CASE_NEL, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x88 0x89 0x8a 0x8b */ CASE_HTS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_GROUND_STATE, CASE_RI, CASE_SS2, CASE_SS3, /* 0x90 0x91 0x92 0x93 */ CASE_DCS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x94 0x95 0x96 0x97 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_SPA, CASE_EPA, /* 0x98 0x99 0x9a 0x9b */ CASE_SOS, CASE_GROUND_STATE, CASE_DECID, CASE_CSI_STATE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_ST, CASE_OSC, CASE_PM, CASE_APC, /* nobreakspace exclamdown cent sterling */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* currency yen brokenbar section */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* notsign hyphen registered macron */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* acute mu paragraph periodcentered */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* cedilla onesuperior masculine guillemotright */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* onequarter onehalf threequarters questiondown */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Agrave Aacute Acircumflex Atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ocircumflex otilde odiaeresis division */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, }; Const PARSE_T esc_table[] = /* ESC */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_ENQ, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* FF CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_GROUND_STATE, CASE_IGNORE, CASE_GROUND_STATE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_ESC_SP_STATE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_SCR_STATE, /* $ % & ' */ CASE_ESC_IGNORE, CASE_ESC_PERCENT, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* ( ) * + */ CASE_SCS0_STATE, CASE_SCS1_STATE, CASE_SCS2_STATE, CASE_SCS3_STATE, /* , - . / */ CASE_ESC_IGNORE, CASE_SCS1A_STATE, CASE_SCS2A_STATE, CASE_SCS3A_STATE, /* 0 1 2 3 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 4 5 6 7 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_DECBI, CASE_DECSC, /* 8 9 : ; */ CASE_DECRC, CASE_DECFI, CASE_GROUND_STATE, CASE_GROUND_STATE, /* < = > ? */ CASE_GROUND_STATE, CASE_DECKPAM, CASE_DECKPNM, CASE_GROUND_STATE, /* @ A B C */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* D E F G */ CASE_IND, CASE_NEL, CASE_HP_BUGGY_LL, CASE_GROUND_STATE, /* H I J K */ CASE_HTS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* L M N O */ CASE_GROUND_STATE, CASE_RI, CASE_SS2, CASE_SS3, /* P Q R S */ CASE_DCS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* T U V W */ CASE_XTERM_TITLE, CASE_GROUND_STATE, CASE_SPA, CASE_EPA, /* X Y Z [ */ CASE_SOS, CASE_GROUND_STATE, CASE_DECID, CASE_CSI_STATE, /* \ ] ^ _ */ CASE_ST, CASE_OSC, CASE_PM, CASE_APC, /* ` a b c */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_RIS, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* h i j k */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_HP_MEM_LOCK, CASE_HP_MEM_UNLOCK, CASE_LS2, CASE_LS3, /* p q r s */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* t u v w */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_LS3R, CASE_LS2R, CASE_LS1R, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x84 0x85 0x86 0x87 */ CASE_IND, CASE_NEL, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x88 0x89 0x8a 0x8b */ CASE_HTS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_GROUND_STATE, CASE_RI, CASE_SS2, CASE_SS3, /* 0x90 0x91 0x92 0x93 */ CASE_DCS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x94 0x95 0x96 0x97 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_SPA, CASE_EPA, /* 0x98 0x99 0x9a 0x9b */ CASE_SOS, CASE_GROUND_STATE, CASE_DECID, CASE_CSI_STATE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_ST, CASE_OSC, CASE_PM, CASE_APC, /* nobreakspace exclamdown cent sterling */ CASE_ESC_SP_STATE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_SCR_STATE, /* currency yen brokenbar section */ CASE_ESC_IGNORE, CASE_ESC_PERCENT, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_SCS0_STATE, CASE_SCS1_STATE, CASE_SCS2_STATE, CASE_SCS3_STATE, /* notsign hyphen registered macron */ CASE_ESC_IGNORE, CASE_SCS1A_STATE, CASE_SCS2A_STATE, CASE_SCS3A_STATE, /* degree plusminus twosuperior threesuperior */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* acute mu paragraph periodcentered */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_DECBI, CASE_DECSC, /* cedilla onesuperior masculine guillemotright */ CASE_DECRC, CASE_DECFI, CASE_GROUND_STATE, CASE_GROUND_STATE, /* onequarter onehalf threequarters questiondown */ CASE_GROUND_STATE, CASE_DECKPAM, CASE_DECKPNM, CASE_GROUND_STATE, /* Agrave Aacute Acircumflex Atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_IND, CASE_NEL, CASE_HP_BUGGY_LL, CASE_GROUND_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_HTS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_GROUND_STATE, CASE_RI, CASE_SS2, CASE_SS3, /* Eth Ntilde Ograve Oacute */ CASE_DCS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_XTERM_TITLE, CASE_GROUND_STATE, CASE_SPA, CASE_EPA, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_SOS, CASE_GROUND_STATE, CASE_DECID, CASE_CSI_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_ST, CASE_OSC, CASE_PM, CASE_APC, /* agrave aacute acircumflex atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_RIS, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_HP_MEM_LOCK, CASE_HP_MEM_UNLOCK, CASE_LS2, CASE_LS3, /* eth ntilde ograve oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ocircumflex otilde odiaeresis division */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_LS3R, CASE_LS2R, CASE_LS1R, CASE_IGNORE, }; Const PARSE_T esc_sp_table[] = /* ESC SP */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_ENQ, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* FF CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_GROUND_STATE, CASE_IGNORE, CASE_GROUND_STATE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* $ % & ' */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* ( ) * + */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* , - . / */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* 0 1 2 3 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 4 5 6 7 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 8 9 : ; */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* < = > ? */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* @ A B C */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* D E F G */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_S7C1T, CASE_S8C1T, /* H I J K */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* L M N O */ CASE_ANSI_LEVEL_1, CASE_ANSI_LEVEL_2, CASE_ANSI_LEVEL_3, CASE_GROUND_STATE, /* P Q R S */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* T U V W */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ` a b c */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* h i j k */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* p q r s */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* t u v w */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x84 0x85 0x86 0x87 */ CASE_IND, CASE_NEL, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x88 0x89 0x8a 0x8b */ CASE_HTS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_GROUND_STATE, CASE_RI, CASE_SS2, CASE_SS3, /* 0x90 0x91 0x92 0x93 */ CASE_DCS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x94 0x95 0x96 0x97 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_SPA, CASE_EPA, /* 0x98 0x99 0x9a 0x9b */ CASE_SOS, CASE_GROUND_STATE, CASE_DECID, CASE_CSI_STATE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_ST, CASE_OSC, CASE_PM, CASE_APC, /* nobreakspace exclamdown cent sterling */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* currency yen brokenbar section */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* notsign hyphen registered macron */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* acute mu paragraph periodcentered */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* cedilla onesuperior masculine guillemotright */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* onequarter onehalf threequarters questiondown */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Agrave Aacute Acircumflex Atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_S7C1T, CASE_S8C1T, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_ANSI_LEVEL_1, CASE_ANSI_LEVEL_2, CASE_ANSI_LEVEL_3, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ocircumflex otilde odiaeresis division */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, }; Const PARSE_T scrtable[] = /* ESC # */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_ENQ, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* FF CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_GROUND_STATE, CASE_IGNORE, CASE_GROUND_STATE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* $ % & ' */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* ( ) * + */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* , - . / */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* 0 1 2 3 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_DECDHL, /* 4 5 6 7 */ CASE_DECDHL, CASE_DECSWL, CASE_DECDWL, CASE_GROUND_STATE, /* 8 9 : ; */ CASE_DECALN, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* < = > ? */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* @ A B C */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* D E F G */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* H I J K */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* L M N O */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* P Q R S */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* T U V W */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ` a b c */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* h i j k */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* p q r s */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* t u v w */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x84 0x85 0x86 0x87 */ CASE_IND, CASE_NEL, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x88 0x89 0x8a 0x8b */ CASE_HTS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_GROUND_STATE, CASE_RI, CASE_SS2, CASE_SS3, /* 0x90 0x91 0x92 0x93 */ CASE_DCS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x94 0x95 0x96 0x97 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_SPA, CASE_EPA, /* 0x98 0x99 0x9a 0x9b */ CASE_SOS, CASE_GROUND_STATE, CASE_DECID, CASE_CSI_STATE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_ST, CASE_OSC, CASE_PM, CASE_APC, /* nobreakspace exclamdown cent sterling */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* currency yen brokenbar section */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* notsign hyphen registered macron */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_DECDHL, /* acute mu paragraph periodcentered */ CASE_DECDHL, CASE_DECSWL, CASE_DECDWL, CASE_GROUND_STATE, /* cedilla onesuperior masculine guillemotright */ CASE_DECALN, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* onequarter onehalf threequarters questiondown */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Agrave Aacute Acircumflex Atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ocircumflex otilde odiaeresis division */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, }; Const PARSE_T scstable[] = /* ESC ( etc. */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_ENQ, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* FF CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_GROUND_STATE, CASE_IGNORE, CASE_GROUND_STATE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* $ % & ' */ CASE_ESC_IGNORE, CASE_SCS_PERCENT, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* ( ) * + */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* , - . / */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* 0 1 2 3 */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GROUND_STATE, /* 4 5 6 7 */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GSETS, /* 8 9 : ; */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* < = > ? */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GROUND_STATE, /* @ A B C */ CASE_GROUND_STATE, CASE_GSETS, CASE_GSETS, CASE_GSETS, /* D E F G */ CASE_GROUND_STATE, CASE_GSETS, CASE_GROUND_STATE, CASE_GROUND_STATE, /* H I J K */ CASE_GSETS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GSETS, /* L M N O */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* P Q R S */ CASE_GROUND_STATE, CASE_GSETS, CASE_GSETS, CASE_GROUND_STATE, /* T U V W */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_GROUND_STATE, CASE_GSETS, CASE_GSETS, CASE_GROUND_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ` a b c */ CASE_GSETS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* h i j k */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* p q r s */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* t u v w */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x84 0x85 0x86 0x87 */ CASE_IND, CASE_NEL, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x88 0x89 0x8a 0x8b */ CASE_HTS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_GROUND_STATE, CASE_RI, CASE_SS2, CASE_SS3, /* 0x90 0x91 0x92 0x93 */ CASE_DCS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x94 0x95 0x96 0x97 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_SPA, CASE_EPA, /* 0x98 0x99 0x9a 0x9b */ CASE_SOS, CASE_GROUND_STATE, CASE_DECID, CASE_CSI_STATE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_ST, CASE_OSC, CASE_PM, CASE_APC, /* nobreakspace exclamdown cent sterling */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* currency yen brokenbar section */ CASE_ESC_IGNORE, CASE_SCS_PERCENT, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* notsign hyphen registered macron */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GROUND_STATE, /* acute mu paragraph periodcentered */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GSETS, /* cedilla onesuperior masculine guillemotright */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* onequarter onehalf threequarters questiondown */ CASE_GSETS, CASE_GSETS, CASE_GSETS, CASE_GROUND_STATE, /* Agrave Aacute Acircumflex Atilde */ CASE_GROUND_STATE, CASE_GSETS, CASE_GSETS, CASE_GSETS, /* Adiaeresis Aring AE Ccedilla */ CASE_GROUND_STATE, CASE_GSETS, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_GSETS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GSETS, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_GROUND_STATE, CASE_GSETS, CASE_GSETS, CASE_GROUND_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_GROUND_STATE, CASE_GSETS, CASE_GSETS, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_GSETS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ocircumflex otilde odiaeresis division */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, }; Const PARSE_T scs96table[] = /* ESC - etc. */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_ENQ, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* FF CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_GROUND_STATE, CASE_IGNORE, CASE_GROUND_STATE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* $ % & ' */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* ( ) * + */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* , - . / */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* 0 1 2 3 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 4 5 6 7 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 8 9 : ; */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* < = > ? */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* @ A B C */ CASE_GROUND_STATE, CASE_GSETS, CASE_GROUND_STATE, CASE_GROUND_STATE, /* D E F G */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* H I J K */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* L M N O */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* P Q R S */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* T U V W */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ` a b c */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* h i j k */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* p q r s */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* t u v w */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x84 0x85 0x86 0x87 */ CASE_IND, CASE_NEL, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x88 0x89 0x8a 0x8b */ CASE_HTS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_GROUND_STATE, CASE_RI, CASE_SS2, CASE_SS3, /* 0x90 0x91 0x92 0x93 */ CASE_DCS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x94 0x95 0x96 0x97 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_SPA, CASE_EPA, /* 0x98 0x99 0x9a 0x9b */ CASE_SOS, CASE_GROUND_STATE, CASE_DECID, CASE_CSI_STATE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_ST, CASE_OSC, CASE_PM, CASE_APC, /* nobreakspace exclamdown cent sterling */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* currency yen brokenbar section */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* notsign hyphen registered macron */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* acute mu paragraph periodcentered */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* cedilla onesuperior masculine guillemotright */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* onequarter onehalf threequarters questiondown */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Agrave Aacute Acircumflex Atilde */ CASE_GROUND_STATE, CASE_GSETS, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ocircumflex otilde odiaeresis division */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, }; /* * This table is treated specially. The CASE_IGNORE entries correspond to the * characters that can be accumulated for the string function (e.g., OSC). */ Const PARSE_T sos_table[] = /* OSC, DCS, etc. */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* FF CR SO SI */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_GROUND_STATE, CASE_IGNORE, CASE_GROUND_STATE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* $ % & ' */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ( ) * + */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* , - . / */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0 1 2 3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 4 5 6 7 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 8 9 : ; */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* < = > ? */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* @ A B C */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* D E F G */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* H I J K */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* L M N O */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* P Q R S */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* T U V W */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* X Y Z [ */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* \ ] ^ _ */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ` a b c */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* d e f g */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* h i j k */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* l m n o */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* p q r s */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* t u v w */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* x y z { */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* | } ~ DEL */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x84 0x85 0x86 0x87 */ CASE_IND, CASE_NEL, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x88 0x89 0x8a 0x8b */ CASE_HTS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_GROUND_STATE, CASE_RI, CASE_SS2, CASE_SS3, /* 0x90 0x91 0x92 0x93 */ CASE_DCS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x94 0x95 0x96 0x97 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_SPA, CASE_EPA, /* 0x98 0x99 0x9a 0x9b */ CASE_SOS, CASE_GROUND_STATE, CASE_DECID, CASE_CSI_STATE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_ST, CASE_OSC, CASE_PM, CASE_APC, /* nobreakspace exclamdown cent sterling */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* currency yen brokenbar section */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* notsign hyphen registered macron */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* acute mu paragraph periodcentered */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* cedilla onesuperior masculine guillemotright */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* onequarter onehalf threequarters questiondown */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Agrave Aacute Acircumflex Atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Adiaeresis Aring AE Ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Eth Ntilde Ograve Oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Udiaeresis Yacute Thorn ssharp */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* agrave aacute acircumflex atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* adiaeresis aring ae ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* egrave eacute ecircumflex ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* igrave iacute icircumflex idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* eth ntilde ograve oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ocircumflex otilde odiaeresis division */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* oslash ugrave uacute ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* udiaeresis yacute thorn ydiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, }; #if OPT_WIDE_CHARS Const PARSE_T esc_pct_table[] = /* ESC % */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_ENQ, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* FF CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_GROUND_STATE, CASE_IGNORE, CASE_GROUND_STATE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* $ % & ' */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* ( ) * + */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* , - . / */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* 0 1 2 3 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 4 5 6 7 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 8 9 : ; */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* < = > ? */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* @ A B C */ CASE_UTF8, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* D E F G */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_UTF8, /* H I J K */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* L M N O */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* P Q R S */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* T U V W */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ` a b c */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* h i j k */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* p q r s */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* t u v w */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x84 0x85 0x86 0x87 */ CASE_IND, CASE_NEL, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x88 0x89 0x8a 0x8b */ CASE_HTS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_GROUND_STATE, CASE_RI, CASE_SS2, CASE_SS3, /* 0x90 0x91 0x92 0x93 */ CASE_DCS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x94 0x95 0x96 0x97 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_SPA, CASE_EPA, /* 0x98 0x99 0x9a 0x9b */ CASE_SOS, CASE_GROUND_STATE, CASE_DECID, CASE_CSI_STATE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_ST, CASE_OSC, CASE_PM, CASE_APC, /* nobreakspace exclamdown cent sterling */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* currency yen brokenbar section */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* notsign hyphen registered macron */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* acute mu paragraph periodcentered */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* cedilla onesuperior masculine guillemotright */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* onequarter onehalf threequarters questiondown */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Agrave Aacute Acircumflex Atilde */ CASE_UTF8, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_UTF8, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ocircumflex otilde odiaeresis division */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, }; Const PARSE_T scs_pct_table[] = /* SCS % */ { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_ENQ, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* FF CR SO SI */ CASE_VMOT, CASE_CR, CASE_SO, CASE_SI, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_GROUND_STATE, CASE_IGNORE, CASE_GROUND_STATE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* $ % & ' */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* ( ) * + */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* , - . / */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* 0 1 2 3 */ CASE_GSETS_PERCENT, CASE_GROUND_STATE, CASE_GSETS_PERCENT, CASE_GSETS_PERCENT, /* 4 5 6 7 */ CASE_GROUND_STATE, CASE_GSETS_PERCENT, CASE_GSETS_PERCENT, CASE_GROUND_STATE, /* 8 9 : ; */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* < = > ? */ CASE_GROUND_STATE, CASE_GSETS_PERCENT, CASE_GROUND_STATE, CASE_GROUND_STATE, /* @ A B C */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* D E F G */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* H I J K */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* L M N O */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* P Q R S */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* T U V W */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ` a b c */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* h i j k */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* p q r s */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* t u v w */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x84 0x85 0x86 0x87 */ CASE_IND, CASE_NEL, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x88 0x89 0x8a 0x8b */ CASE_HTS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_GROUND_STATE, CASE_RI, CASE_SS2, CASE_SS3, /* 0x90 0x91 0x92 0x93 */ CASE_DCS, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 0x94 0x95 0x96 0x97 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_SPA, CASE_EPA, /* 0x98 0x99 0x9a 0x9b */ CASE_SOS, CASE_GROUND_STATE, CASE_DECID, CASE_CSI_STATE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_ST, CASE_OSC, CASE_PM, CASE_APC, /* nobreakspace exclamdown cent sterling */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* currency yen brokenbar section */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* notsign hyphen registered macron */ CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, CASE_ESC_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_GSETS_PERCENT, CASE_GROUND_STATE, CASE_GSETS_PERCENT, CASE_GSETS_PERCENT, /* acute mu paragraph periodcentered */ CASE_GROUND_STATE, CASE_GSETS_PERCENT, CASE_GSETS_PERCENT, CASE_GROUND_STATE, /* cedilla onesuperior masculine guillemotright */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* onequarter onehalf threequarters questiondown */ CASE_GROUND_STATE, CASE_GSETS_PERCENT, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Agrave Aacute Acircumflex Atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Adiaeresis Aring AE Ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Eth Ntilde Ograve Oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* Udiaeresis Yacute Thorn ssharp */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* agrave aacute acircumflex atilde */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* adiaeresis aring ae ccedilla */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* egrave eacute ecircumflex ediaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* igrave iacute icircumflex idiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* eth ntilde ograve oacute */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ocircumflex otilde odiaeresis division */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* oslash ugrave uacute ucircumflex */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* udiaeresis yacute thorn ydiaeresis */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, }; #endif /* OPT_WIDE_CHARS */ #if OPT_VT52_MODE Const PARSE_T vt52_table[] = { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_ENQ, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* FF CR SO SI */ CASE_VMOT, CASE_CR, CASE_IGNORE, CASE_IGNORE, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_GROUND_STATE, CASE_IGNORE, CASE_GROUND_STATE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* $ % & ' */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* ( ) * + */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* , - . / */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* 0 1 2 3 */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* 4 5 6 7 */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* 8 9 : ; */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* < = > ? */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* @ A B C */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* D E F G */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* H I J K */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* L M N O */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* P Q R S */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* T U V W */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* X Y Z [ */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* \ ] ^ _ */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* ` a b c */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* d e f g */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* h i j k */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* l m n o */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* p q r s */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* t u v w */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* x y z { */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_PRINT, /* | } ~ DEL */ CASE_PRINT, CASE_PRINT, CASE_PRINT, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x98 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* currency yen brokenbar section */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* notsign hyphen registered macron */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* acute mu paragraph periodcentered */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* cedilla onesuperior masculine guillemotright */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* onequarter onehalf threequarters questiondown */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Agrave Aacute Acircumflex Atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Adiaeresis Aring AE Ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Eth Ntilde Ograve Oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Udiaeresis Yacute Thorn ssharp */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* agrave aacute acircumflex atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* adiaeresis aring ae ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* egrave eacute ecircumflex ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* igrave iacute icircumflex idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* eth ntilde ograve oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ocircumflex otilde odiaeresis division */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* oslash ugrave uacute ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* udiaeresis yacute thorn ydiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, }; Const PARSE_T vt52_esc_table[] = { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_ENQ, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* FF CR SO SI */ CASE_VMOT, CASE_CR, CASE_IGNORE, CASE_IGNORE, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_GROUND_STATE, CASE_IGNORE, CASE_GROUND_STATE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_VT52_IGNORE, CASE_VT52_IGNORE, CASE_VT52_IGNORE, CASE_VT52_IGNORE, /* $ % & ' */ CASE_VT52_IGNORE, CASE_VT52_IGNORE, CASE_VT52_IGNORE, CASE_VT52_IGNORE, /* ( ) * + */ CASE_VT52_IGNORE, CASE_VT52_IGNORE, CASE_VT52_IGNORE, CASE_VT52_IGNORE, /* , - . / */ CASE_VT52_IGNORE, CASE_VT52_IGNORE, CASE_VT52_IGNORE, CASE_VT52_IGNORE, /* 0 1 2 3 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 4 5 6 7 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 8 9 : ; */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* < = > ? */ CASE_VT52_FINISH, CASE_DECKPAM, CASE_DECKPNM, CASE_GROUND_STATE, /* @ A B C */ CASE_GROUND_STATE, CASE_CUU, CASE_CUD, CASE_CUF, /* D E F G */ CASE_CUB, CASE_GROUND_STATE, CASE_SO, CASE_SI, /* H I J K */ CASE_CUP, CASE_RI, CASE_ED, CASE_EL, /* L M N O */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* P Q R S */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* T U V W */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_GROUND_STATE, CASE_VT52_CUP, CASE_DECID, CASE_GROUND_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ` a b c */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* h i j k */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* p q r s */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* t u v w */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x98 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* currency yen brokenbar section */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* notsign hyphen registered macron */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* acute mu paragraph periodcentered */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* cedilla onesuperior masculine guillemotright */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* onequarter onehalf threequarters questiondown */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Agrave Aacute Acircumflex Atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Adiaeresis Aring AE Ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Eth Ntilde Ograve Oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Udiaeresis Yacute Thorn ssharp */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* agrave aacute acircumflex atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* adiaeresis aring ae ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* egrave eacute ecircumflex ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* igrave iacute icircumflex idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* eth ntilde ograve oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ocircumflex otilde odiaeresis division */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* oslash ugrave uacute ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* udiaeresis yacute thorn ydiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, }; Const PARSE_T vt52_ignore_table[] = { /* NUL SOH STX ETX */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* EOT ENQ ACK BEL */ CASE_IGNORE, CASE_ENQ, CASE_IGNORE, CASE_BELL, /* BS HT NL VT */ CASE_BS, CASE_TAB, CASE_VMOT, CASE_VMOT, /* FF CR SO SI */ CASE_VMOT, CASE_CR, CASE_IGNORE, CASE_IGNORE, /* DLE DC1 DC2 DC3 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* DC4 NAK SYN ETB */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* CAN EM SUB ESC */ CASE_GROUND_STATE, CASE_IGNORE, CASE_GROUND_STATE, CASE_ESC, /* FS GS RS US */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* SP ! " # */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* $ % & ' */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ( ) * + */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* , - . / */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0 1 2 3 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 4 5 6 7 */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* 8 9 : ; */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* < = > ? */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* @ A B C */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* D E F G */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* H I J K */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* L M N O */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* P Q R S */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* T U V W */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* X Y Z [ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* \ ] ^ _ */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* ` a b c */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* d e f g */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* h i j k */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* l m n o */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* p q r s */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* t u v w */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* x y z { */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, /* | } ~ DEL */ CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_GROUND_STATE, CASE_IGNORE, /* 0x80 0x81 0x82 0x83 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x84 0x85 0x86 0x87 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x88 0x89 0x8a 0x8b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x8c 0x8d 0x8e 0x8f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x90 0x91 0x92 0x93 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x94 0x95 0x96 0x97 */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x98 0x99 0x9a 0x9b */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* 0x9c 0x9d 0x9e 0x9f */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* nobreakspace exclamdown cent sterling */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* currency yen brokenbar section */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* diaeresis copyright ordfeminine guillemotleft */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* notsign hyphen registered macron */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* degree plusminus twosuperior threesuperior */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* acute mu paragraph periodcentered */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* cedilla onesuperior masculine guillemotright */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* onequarter onehalf threequarters questiondown */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Agrave Aacute Acircumflex Atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Adiaeresis Aring AE Ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Egrave Eacute Ecircumflex Ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Igrave Iacute Icircumflex Idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Eth Ntilde Ograve Oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ocircumflex Otilde Odiaeresis multiply */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Ooblique Ugrave Uacute Ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* Udiaeresis Yacute Thorn ssharp */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* agrave aacute acircumflex atilde */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* adiaeresis aring ae ccedilla */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* egrave eacute ecircumflex ediaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* igrave iacute icircumflex idiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* eth ntilde ograve oacute */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* ocircumflex otilde odiaeresis division */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* oslash ugrave uacute ucircumflex */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, /* udiaeresis yacute thorn ydiaeresis */ CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, CASE_IGNORE, }; #endif /* OPT_VT52_MODE */ /* *INDENT-ON* */ xterm-330/graphics_regis.c0000644000175100001440000065172313122344247014414 0ustar tomusers/* $XTermId: graphics_regis.c,v 1.96 2017/06/21 01:15:19 tom Exp $ */ /* * Copyright 2014-2016,2017 by Ross Combs * * All Rights Reserved * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * Except as contained in this notice, the name(s) of the above copyright * holders shall not be used in advertising or otherwise to promote the * sale, use or other dealings in this Software without prior written * authorization. */ #include #include #include #include #include #if OPT_DOUBLE_BUFFER #include #endif #include #include #include #include #include #include /* get rid of shadowing warnings (we will not draw Bessel functions) */ #define y1 my_y1 #define y0 my_y0 #define IS_HEX_DIGIT(CH) ( \ (CH) == '0' || \ (CH) == '1' || \ (CH) == '2' || \ (CH) == '3' || \ (CH) == '4' || \ (CH) == '5' || \ (CH) == '6' || \ (CH) == '7' || \ (CH) == '8' || \ (CH) == '9' || \ (CH) == 'a' || \ (CH) == 'b' || \ (CH) == 'c' || \ (CH) == 'd' || \ (CH) == 'e' || \ (CH) == 'f' || \ (CH) == 'A' || \ (CH) == 'B' || \ (CH) == 'C' || \ (CH) == 'D' || \ (CH) == 'E' || \ (CH) == 'F' ) #define SCALE_FIXED_POINT 16U #undef DEBUG_PARSING #undef DEBUG_ALPHABET_LOOKUP #undef DEBUG_ALPHABETS #undef DEBUG_BEZIER #undef DEBUG_SPLINE_SEGMENTS #undef DEBUG_SPLINE_POINTS #undef DEBUG_SPLINE_WITH_ROTATION #undef DEBUG_SPLINE_WITH_OVERDRAW #undef DEBUG_ARC_POINTS #undef DEBUG_ARC_CENTER #undef DEBUG_ARC_START #undef DEBUG_ARC_END #undef DEBUG_SPECIFIC_CHAR_METRICS #define IS_DEBUG_CHAR(CH) ((CH) == 'W') /* glyphs to dump to terminal */ #undef DEBUG_COMPUTED_FONT_METRICS #undef DEBUG_FONT_NAME #undef DEBUG_FONT_SIZE_SEARCH #undef DEBUG_XFT_GLYPH #undef DEBUG_USER_GLYPH #undef DEBUG_LOAD /* controls for extensions over VT3x0 limitations */ #define ENABLE_RGB_COLORSPECS #undef ENABLE_FREE_ROTATION #undef ENABLE_DISTORTIONLESS_ROTATION #define ENABLE_UPLOAD_ALPHABET_FROM_FONT #define ENABLE_UPLOAD_ALPHABET_ZERO #define ENABLE_USER_FONT_SIZE #define ENABLE_VARIABLE_ITALICS #define MIN_ITERATIONS_BEFORE_REFRESH 10U #define MIN_MS_BEFORE_REFRESH 33 /* *INDENT-OFF* */ typedef struct RegisPoint { int x, y; } RegisPoint; typedef struct RegisWriteControls { unsigned pv_multiplier; unsigned pattern; unsigned pattern_multiplier; unsigned invert_pattern; unsigned plane_mask; unsigned write_style; RegisterNum foreground; unsigned shading_enabled; char shading_character; int shading_reference; unsigned shading_reference_dim; unsigned line_width; } RegisWriteControls; typedef struct RegisTextControls { unsigned alphabet_num; unsigned character_set_l; /* default: "(B" (ASCII) */ unsigned character_set_r; /* default: "-@" (Latin-1) */ unsigned character_display_w; unsigned character_display_h; unsigned character_unit_cell_w; unsigned character_unit_cell_h; int character_inc_x; int character_inc_y; int string_rotation; int character_rotation; int slant; /* for italic/oblique */ } RegisTextControls; #define FixedCopy(dst, src, len) strncpy(dst, src, len - 1)[len - 1] = '\0' #define CopyFontname(dst, src) FixedCopy(dst, src, REGIS_FONTNAME_LEN) #define MAX_REGIS_PAGES 8U #define MAX_REGIS_ALPHABETS 8U #define REGIS_ALPHABET_NAME_LEN 11U #define REGIS_FONTNAME_LEN 256U /* enough for a 16x24 font (about 100KB) */ #define MAX_REGIS_ALPHABET_BYTES (256U * 16U * 24U) #define MAX_GLYPH_PIXELS 8192U #define MAX_GLYPHS 256U #define INVALID_ALPHABET_NUM ~0U typedef struct RegisAlphabet { unsigned alphabet_num; unsigned pixw, pixh; char name[REGIS_ALPHABET_NAME_LEN]; char fontname[REGIS_FONTNAME_LEN]; int use_font; int loaded[MAX_GLYPHS]; unsigned char *bytes; } RegisAlphabet; typedef struct RegisDataFragment { char const *start; unsigned pos; unsigned len; } RegisDataFragment; /* *INDENT-ON* */ #define POSITION_STACK_SIZE 16U #define DUMMY_STACK_X -32768 #define DUMMY_STACK_Y -32768 #define CURVE_POSITION_ARC_EDGE 0U #define CURVE_POSITION_ARC_CENTER 1U #define CURVE_POSITION_OPEN_CURVE 2U #define CURVE_POSITION_CLOSED_CURVE 3U #define MAX_INPUT_CURVE_POINTS 16U #define MAX_CURVE_POINTS (MAX_INPUT_CURVE_POINTS + 4U) #define MAX_FILL_POINTS 2048U typedef struct RegisParseState { RegisDataFragment input; char *temp; unsigned templen; char command; char option; /* position stack */ int stack_x[POSITION_STACK_SIZE]; int stack_y[POSITION_STACK_SIZE]; unsigned stack_next; /* next empty position */ /* curve options */ int curve_mode; int arclen; int x_points[MAX_CURVE_POINTS]; int y_points[MAX_CURVE_POINTS]; unsigned num_points; /* load options */ char load_name[REGIS_ALPHABET_NAME_LEN]; unsigned load_alphabet; unsigned load_w, load_h; unsigned load_index; unsigned load_glyph; unsigned load_row; /* text options */ unsigned text_tilt_state; } RegisParseState; #define TEXT_TILT_STATE_READY 0U #define TEXT_TILT_STATE_GOT_D 1U #define TEXT_TILT_STATE_GOT_DS 2U #define TEXT_TILT_STATE_GOT_DSD 3U typedef struct RegisGraphicsContext { XtermWidget current_widget; Graphic *destination_graphic; Graphic *display_graphic; int terminal_id; int x_off, y_off; int x_div, y_div; int width, height; unsigned all_planes; RegisterNum background; char const *builtin_font; RegisAlphabet alphabets[MAX_REGIS_ALPHABETS]; RegisWriteControls persistent_write_controls; RegisWriteControls temporary_write_controls; RegisTextControls persistent_text_controls; RegisTextControls temporary_text_controls; RegisTextControls *current_text_controls; int multi_input_mode; int graphics_output_cursor_x; int graphics_output_cursor_y; unsigned pattern_count; unsigned pattern_bit; int fill_mode; RegisPoint fill_points[MAX_FILL_POINTS]; unsigned fill_point_count; unsigned destination_page; unsigned display_page; int force_refresh; } RegisGraphicsContext; static RegisGraphicsContext persistent_context; static RegisParseState persistent_state; #define MAX_PATTERN_BITS 8U #define WRITE_STYLE_OVERLAY 1U #define WRITE_STYLE_REPLACE 2U #define WRITE_STYLE_COMPLEMENT 3U #define WRITE_STYLE_ERASE 4U #define WRITE_SHADING_REF_Y 0U #define WRITE_SHADING_REF_X 1U #define WRITE_SHADING_REF_NONE 2U /* keypress event example: http://iraf.net/forum/viewtopic.php?showtopic=61692 */ #define MIN2(X, Y) ( (X) < (Y) ? (X) : (Y) ) #define MIN3(X, Y, Z) ( MIN2(MIN2((X), (Y)), MIN2((Y), (Z))) ) #define MAX2(X, Y) ( (X) > (Y) ? (X) : (Y) ) #define MAX3(X, Y, Z) ( MAX2(MAX2((X), (Y)), MAX2((Y), (Z))) ) #define ROT_LEFT_N(V, N) ( (((V) << ((N) & 3U )) & 255U) | \ ((V) >> (8U - ((N) & 3U))) ) #define ROT_LEFT(V) ( (((V) << 1U) & 255U) | ((V) >> 7U) ) /* convert user coordinates to absolute pixel coordinates */ #define SCALE_XCOORD(C, X, S) ( ( (X) * ((C)->width - 1) ) / ( (C)->x_div * (S) ) ) #define SCALE_YCOORD(C, Y, S) ( ( (Y) * ((C)->height - 1) ) / ( (C)->y_div * (S) ) ) #define TRANSLATE_XCOORD(C, X, S) SCALE_XCOORD((C), (X) - (C)->x_off * (S), (S) ) #define TRANSLATE_YCOORD(C, Y, S) SCALE_YCOORD((C), (Y) - (C)->y_off * (S), (S) ) #if 0 /* convert absolute pixel coordinate to user coordinates */ #define SCALE_XPIX(C, X, S) ( ( (X) * ((C)->x_div * (S) ) ) / ((C)->width - 1) ) #define SCALE_YPIX(C, Y, S) ( ( (Y) * ((C)->y_div * (S) ) ) / ((C)->height - 1) ) #define TRANSLATE_XPIX(C, X, S) ( SCALE_XPIX((C), (X), (S) ) + (C)->x_off * (S) ) #define TRANSLATE_YPIX(C, Y, S) ( SCALE_YPIX((C), (Y), (S) ) + (C)->y_off * (S) ) #endif #define READ_PIXEL(C, X, Y) read_pixel((C)->destination_graphic, (X), (Y)) #define DRAW_PIXEL(C, X, Y, COL) draw_solid_pixel((C)->destination_graphic, (X), (Y), (COL)) #define DRAW_ALL(C, COL) \ draw_solid_rectangle((C)->destination_graphic, 0, 0, (C)->width, (C)->height, (COL)) static unsigned get_shade_character_pixel(unsigned char const *pixels, unsigned w, unsigned h, unsigned smaxf, unsigned scale, int slant_dx, int px, int py); static void get_bitmap_of_character(RegisGraphicsContext const *context, int ch, unsigned maxw, unsigned maxh, unsigned char *pixels, unsigned *w, unsigned *h, unsigned max_pixels); static void init_regis_load_state(RegisParseState *state) { state->load_index = MAX_REGIS_ALPHABETS; state->load_w = 8U; state->load_h = 10U; state->load_alphabet = 1U; /* FIXME: is this the correct default */ state->load_name[0] = '\0'; state->load_glyph = (unsigned) (unsigned char) '\0'; state->load_row = 0U; } static void init_regis_parse_state(RegisParseState *state) { state->command = '_'; state->option = '_'; state->stack_next = 0U; state->load_index = MAX_REGIS_ALPHABETS; init_regis_load_state(state); } static int ifloor(double d) { double dl = floor(d); return (int) dl; } static int isqrt(double d) { double dl = sqrt(d); return (int) dl; } static void draw_regis_pixel(RegisGraphicsContext *context, int x, int y, unsigned value) { unsigned color = 0; switch (context->temporary_write_controls.write_style) { case WRITE_STYLE_OVERLAY: /* * Update pixels with foreground when pattern is 1, * don't change when pattern is 0. */ if (!value) { return; } if (context->temporary_write_controls.invert_pattern) { color = context->background; } else { color = context->temporary_write_controls.foreground; } break; case WRITE_STYLE_REPLACE: /* * Update pixels with foreground when pattern is 1, * set to background when pattern is 0. */ { unsigned fg, bg; if (context->temporary_write_controls.invert_pattern) { fg = context->background; bg = context->temporary_write_controls.foreground; } else { fg = context->temporary_write_controls.foreground; bg = context->background; } color = value ? fg : bg; } break; case WRITE_STYLE_COMPLEMENT: /* * Update pixels with background when pattern is 1, * don't change when pattern is 0. */ if (!value) { return; } color = READ_PIXEL(context, x, y); if (color == COLOR_HOLE) color = context->background; color = color ^ context->all_planes; break; case WRITE_STYLE_ERASE: /* Update pixels to foreground. */ if (context->temporary_write_controls.invert_pattern) { color = context->temporary_write_controls.foreground; } else { color = context->background; } break; } if (context->temporary_write_controls.plane_mask != context->all_planes) { unsigned old_color = READ_PIXEL(context, x, y); if (old_color == COLOR_HOLE) old_color = context->background; color = (color & context->temporary_write_controls.plane_mask) | (old_color & ~context->temporary_write_controls.plane_mask); } DRAW_PIXEL(context, x, y, color); } static void shade_pattern_to_pixel(RegisGraphicsContext *context, unsigned dim, int ref, int x, int y) { unsigned value; if (dim == WRITE_SHADING_REF_X) { int delta = x > ref ? 1 : -1; int curr_x; context->pattern_bit = 1U << (((unsigned) y) & 7U); for (curr_x = ref; curr_x != x + delta; curr_x += delta) { value = context->temporary_write_controls.pattern & context->pattern_bit; draw_regis_pixel(context, curr_x, y, value); } } else if (dim == WRITE_SHADING_REF_Y) { int delta = y > ref ? 1 : -1; int curr_y; for (curr_y = ref; curr_y != y + delta; curr_y += delta) { context->pattern_bit = 1U << (((unsigned) curr_y) & 7U); value = context->temporary_write_controls.pattern & context->pattern_bit; draw_regis_pixel(context, x, curr_y, value); } } else { TRACE(("ERROR: shading requested, but there is no reference axis\n")); } } static void shade_char_to_pixel(RegisGraphicsContext *context, unsigned char const *pixels, unsigned w, unsigned h, unsigned dim, int ref, int x, int y) { unsigned xmaxf = context->current_text_controls->character_unit_cell_w; unsigned ymaxf = context->current_text_controls->character_unit_cell_h; unsigned smaxf; unsigned s; unsigned scale; unsigned value; if (xmaxf > ymaxf) { smaxf = ymaxf; s = h; } else { smaxf = xmaxf; s = w; } scale = (s << SCALE_FIXED_POINT) / smaxf; if (dim == WRITE_SHADING_REF_X) { int delta = x > ref ? 1 : -1; int curr_x; for (curr_x = ref; curr_x != x + delta; curr_x += delta) { value = get_shade_character_pixel(pixels, w, h, smaxf, scale, 0, curr_x, y); draw_regis_pixel(context, curr_x, y, value); } } else if (dim == WRITE_SHADING_REF_Y) { int delta = y > ref ? 1 : -1; int curr_y; for (curr_y = ref; curr_y != y + delta; curr_y += delta) { value = get_shade_character_pixel(pixels, w, h, smaxf, scale, 0, x, curr_y); draw_regis_pixel(context, x, curr_y, value); } } else { TRACE(("ERROR: shading requested, but there is no reference axis\n")); } } static void draw_patterned_pixel(RegisGraphicsContext *context, int x, int y) { if (context->pattern_count >= context->temporary_write_controls.pattern_multiplier) { context->pattern_count = 0U; context->pattern_bit = ROT_LEFT(context->pattern_bit); } context->pattern_count++; draw_regis_pixel(context, x, y, context->temporary_write_controls.pattern & context->pattern_bit); } static void shade_to_pixel(RegisGraphicsContext *context, unsigned dim, int ref, int x, int y) { if (context->temporary_write_controls.shading_character != '\0') { unsigned xmaxf = context->current_text_controls->character_unit_cell_w; unsigned ymaxf = context->current_text_controls->character_unit_cell_h; char ch = context->temporary_write_controls.shading_character; unsigned char pixels[MAX_GLYPH_PIXELS]; unsigned w, h; get_bitmap_of_character(context, ch, xmaxf, ymaxf, pixels, &w, &h, MAX_GLYPH_PIXELS); if (w > 0 && h > 0) { shade_char_to_pixel(context, pixels, w, h, dim, ref, x, y); } } else { shade_pattern_to_pixel(context, dim, ref, x, y); } } static void draw_or_save_patterned_pixel(RegisGraphicsContext *context, int x, int y) { if (context->fill_mode == 1) { if (context->fill_point_count >= MAX_FILL_POINTS) { TRACE(("point %d,%d can not be added to filled polygon\n", x, y)); return; } if (context->fill_point_count > 0U && context->fill_points[context->fill_point_count - 1U].x == x && context->fill_points[context->fill_point_count - 1U].y == y) { return; } context->fill_points[context->fill_point_count].x = x; context->fill_points[context->fill_point_count].y = y; context->fill_point_count++; return; } if (context->temporary_write_controls.shading_enabled) { unsigned dim = context->temporary_write_controls.shading_reference_dim; int ref = context->temporary_write_controls.shading_reference; shade_to_pixel(context, dim, ref, x, y); return; } draw_patterned_pixel(context, x, y); } static int sort_points(void const *l, void const *r) { RegisPoint const *const lp = l; RegisPoint const *const rp = r; if (lp->y < rp->y) return -1; if (lp->y > rp->y) return +1; if (lp->x < rp->x) return -1; if (lp->x > rp->x) return +1; return 0; } static void draw_filled_polygon(RegisGraphicsContext *context) { unsigned p; int old_x, old_y; int inside; unsigned char pixels[MAX_GLYPH_PIXELS]; unsigned w = 1, h = 1; if (context->temporary_write_controls.shading_character != '\0') { char ch = context->temporary_write_controls.shading_character; unsigned xmaxf = context->current_text_controls->character_unit_cell_w; unsigned ymaxf = context->current_text_controls->character_unit_cell_h; get_bitmap_of_character(context, ch, xmaxf, ymaxf, pixels, &w, &h, MAX_GLYPH_PIXELS); if (w < 1U || h < 1U) { return; } } qsort(context->fill_points, context->fill_point_count, sizeof(context->fill_points[0]), sort_points); old_x = DUMMY_STACK_X; old_y = DUMMY_STACK_Y; inside = 0; for (p = 0U; p < context->fill_point_count; p++) { int new_x = context->fill_points[p].x; int new_y = context->fill_points[p].y; #if 0 printf("got %d,%d (%d,%d) inside=%d\n", new_x, new_y, old_x, old_y, inside); #endif /* * FIXME: This is using pixels to represent lines which loses * information about exact slope and how many lines are present which * causes misbehavior with some inputs (especially complex polygons). * It also takes more room than remembering vertices, but I'd rather * not have to implement line segments for arcs. Maybe store a count * at each vertex instead (doesn't fix the slope problem). */ /* * FIXME: Change this to only draw inside of polygons, and round * points in a uniform direction to avoid overlapping drawing. As an * option we could continue to support drawing the outline. */ if (new_y != old_y) { if (inside) { /* * Just draw the vertical line when there is not a matching * edge on the right side. */ if (context->temporary_write_controls.shading_character != '\0') { shade_char_to_pixel(context, pixels, w, h, WRITE_SHADING_REF_X, old_x, old_x, old_y); } else { shade_pattern_to_pixel(context, WRITE_SHADING_REF_X, old_x, old_x, old_y); } } inside = 1; } else { if (inside) { if (context->temporary_write_controls.shading_character != '\0') { shade_char_to_pixel(context, pixels, w, h, WRITE_SHADING_REF_X, old_x, new_x, new_y); } else { shade_pattern_to_pixel(context, WRITE_SHADING_REF_X, old_x, new_x, new_y); } } if (new_x > old_x + 1) { inside = !inside; } } old_x = new_x; old_y = new_y; } context->destination_graphic->dirty = 1; } static void draw_patterned_line(RegisGraphicsContext *context, int x1, int y1, int x2, int y2) { int x, y; int dx, dy; int dir, diff; dx = abs(x1 - x2); dy = abs(y1 - y2); if (dx > dy) { if (x1 > x2) { int tmp; EXCHANGE(x1, x2, tmp); EXCHANGE(y1, y2, tmp); } if (y1 < y2) dir = 1; else if (y1 > y2) dir = -1; else dir = 0; diff = 0; y = y1; for (x = x1; x <= x2; x++) { if (diff >= dx) { diff -= dx; y += dir; } diff += dy; draw_or_save_patterned_pixel(context, x, y); } } else { if (y1 > y2) { int tmp; EXCHANGE(y1, y2, tmp); EXCHANGE(x1, x2, tmp); } if (x1 < x2) dir = 1; else if (x1 > x2) dir = -1; else dir = 0; diff = 0; x = x1; for (y = y1; y <= y2; y++) { if (diff >= dy) { diff -= dy; x += dir; } diff += dx; draw_or_save_patterned_pixel(context, x, y); } } context->destination_graphic->dirty = 1; } typedef struct { int dxx; int dxy; int dyx; int dyy; } quadmap_coords; static void draw_patterned_arc(RegisGraphicsContext *context, int cx, int cy, int ex, int ey, int a_start, int a_length, int *ex_final, int *ey_final) { const double third = hypot((double) (cx - ex), (double) (cy - ey)); const int radius = (int) third; const int ra = radius; const int rb = radius; const quadmap_coords neg_quadmap[4] = { {-1, 0, 0, +1}, {0, -1, -1, 0}, {+1, 0, 0, -1}, {0, +1, +1, 0}, }; const quadmap_coords pos_quadmap[4] = { {-1, 0, 0, -1}, {0, -1, +1, 0}, {+1, 0, 0, +1}, {0, +1, -1, 0}, }; const quadmap_coords *quadmap; int total_points; int half_degree; int points_start, points_stop; int points; unsigned iterations; long rx, ry; long dx, dy; int x, y; long e2; long error; TRACE(("orig a_length=%d a_start=%d\n", a_length, a_start)); if (a_length == 0) return; if (a_length > 0) { quadmap = pos_quadmap; } else { quadmap = neg_quadmap; if (a_start != 0) a_start = 3600 - a_start; a_length = abs(a_length); } TRACE(("positive a_length=%d a_start=%d\n", a_length, a_start)); rx = -ra; ry = 0; e2 = rb; dx = (2 * rx + 1) * e2 * e2; dy = rx * rx; error = dx + dy; total_points = 0; do { total_points += 4; e2 = 2 * error; if (e2 >= dx) { rx++; dx += 2 * rb * rb; error += dx; } if (e2 <= dy) { ry++; dy += 2 * ra * ra; error += dy; } } while (rx <= 0); /* FIXME: This is apparently not accurate enough because some arcs start or * end a few pixels off. Maybe compare line slopes in the loop below * instead? */ half_degree = total_points * 5; points_start = (total_points * a_start - half_degree) / 3600; points_stop = (total_points * a_start + total_points * a_length + half_degree) / 3600; TRACE(("drawing arc with %d points clockwise from %g degrees for %g degrees (from point %d to %d out of %d)\n", total_points, a_start / 10.0, a_length / 10.0, points_start, points_stop, total_points)); /* FIXME: The four pixels at the cardinal directions are double-drawn. */ points = 0; for (iterations = 0U; iterations < 8U; iterations++) { int q2 = iterations & 0x3; rx = -ra; ry = 0; e2 = rb; dx = (2 * rx + 1) * e2 * e2; dy = rx * rx; error = dx + dy; do { #ifdef DEBUG_ARC_POINTS double rad = atan2( (double) (quadmap[q2].dyx * rx + quadmap[q2].dyy * ry), (double) (quadmap[q2].dxx * rx + quadmap[q2].dxy * ry)); double deg = (360.0 * rad / (2.0 * M_PI)); if (deg < 0.0) deg += 360.0; #endif if (points >= points_start && points <= points_stop) { x = (int) (cx + quadmap[q2].dxx * rx + quadmap[q2].dxy * ry); y = (int) (cy + quadmap[q2].dyx * rx + quadmap[q2].dyy * ry); #ifdef DEBUG_ARC_POINTS TRACE(("drawing point %u at %d,%d (%.5g deg)\n", points, x, y, deg)); #endif draw_or_save_patterned_pixel(context, x, y); if (ex_final) *ex_final = x; if (ey_final) *ey_final = y; } else { #ifdef DEBUG_ARC_POINTS x = (int) (cx + quadmap[q2].dxx * rx + quadmap[q2].dxy * ry); y = (int) (cy + quadmap[q2].dyx * rx + quadmap[q2].dyy * ry); TRACE(("skipping point %u at %d,%d which is outside of range (%.5g deg)\n", points, x, y, deg)); #endif } points++; e2 = 2 * error; if (e2 >= dx) { rx++; dx += 2 * rb * rb; error += dx; } if (e2 <= dy) { ry++; dy += 2 * ra * ra; error += dy; } } while (rx <= 0); } context->destination_graphic->dirty = 1; } /* * The plot* functions are based on optimized rasterization primitves written by Zingl Alois. * See http://members.chello.at/easyfilter/bresenham.html */ /* * FIXME: * This is a terrible temporary hack. The plot functions below can be adapted * to work like the other rasterization functions but there's no point in doing * that until we know we don't have to write something completely different. */ static RegisGraphicsContext *global_context; static void setPixel(int x, int y) { draw_or_save_patterned_pixel(global_context, x, y); } static void plotLine(int x0, int y0, int x1, int y1) { int dx = abs(x1 - x0), sx = x0 < x1 ? 1 : -1; int dy = -abs(y1 - y0), sy = y0 < y1 ? 1 : -1; int err = dx + dy; /* error value e_xy */ for (;;) { /* loop */ int e2; setPixel(x0, y0); e2 = 2 * err; if (e2 >= dy) { /* e_xy+e_x > 0 */ if (x0 == x1) break; err += dy; x0 += sx; } if (e2 <= dx) { /* e_xy+e_y < 0 */ if (y0 == y1) break; err += dx; y0 += sy; } } } static void plotQuadBezierSeg(int x0, int y0, int x1, int y1, int x2, int y2) { /* plot a limited quadratic Bezier segment */ int sx = x2 - x1; int sy = y2 - y1; long xx = (x0 - x1); /* relative values for checks */ long yy = (y0 - y1); double cur = (double) (xx * sy - yy * sx); /* curvature */ assert(xx * sx <= 0 && yy * sy <= 0); /* sign of gradient must not change */ if (sx * (long) sx + sy * (long) sy > xx * xx + yy * yy) { /* begin with longer part */ x2 = x0; x0 = sx + x1; y2 = y0; y0 = sy + y1; cur = -cur; /* swap P0 P2 */ } if (cur != 0) { /* no straight line */ long xy; double dx, dy, err; xx += sx; xx *= sx = x0 < x2 ? 1 : -1; /* x step direction */ yy += sy; yy *= sy = y0 < y2 ? 1 : -1; /* y step direction */ xy = 2 * xx * yy; xx *= xx; yy *= yy; /* differences 2nd degree */ if (cur * sx * sy < 0) { /* negated curvature? */ xx = -xx; yy = -yy; xy = -xy; cur = -cur; } /* differences 1st degree */ dx = ((4.0 * sy * cur * (x1 - x0)) + (double) xx) - (double) xy; dy = ((4.0 * sx * cur * (y0 - y1)) + (double) yy) - (double) xy; xx += xx; yy += yy; err = dx + dy + (double) xy; /* error 1st step */ do { setPixel(x0, y0); /* plot curve */ if (x0 == x2 && y0 == y2) return; /* last pixel -> curve finished */ y1 = (2 * err) < dx; /* save value for test of y step */ if ((2 * err) > dy) { x0 += sx; dx -= (double) xy; dy += (double) yy; err += dy; } /* x step */ if (y1) { y0 += sy; dy -= (double) xy; dx += (double) xx; err += dx; } /* y step */ } while (dy < 0 && dx > 0); /* gradient negates -> algorithm fails */ } plotLine(x0, y0, x2, y2); /* plot remaining part to end */ } #if 0 static void plotQuadBezier(int x0, int y0, int x1, int y1, int x2, int y2) { /* plot any quadratic Bezier curve */ int x = x0 - x1; int y = y0 - y1; double t = x0 - 2 * x1 + x2; double r; if ((long) x * (x2 - x1) > 0) { /* horizontal cut at P4? */ if ((long) y * (y2 - y1) > 0) /* vertical cut at P6 too? */ if (fabs((y0 - 2 * y1 + y2) / t * x) > abs(y)) { /* which first? */ x0 = x2; x2 = x + x1; y0 = y2; y2 = y + y1; /* swap points */ } /* now horizontal cut at P4 comes first */ t = (x0 - x1) / t; r = (1 - t) * ((1 - t) * y0 + 2.0 * t * y1) + t * t * y2; /* By(t=P4) */ t = (x0 * x2 - x1 * x1) * t / (x0 - x1); /* gradient dP4/dx=0 */ x = ifloor(t + 0.5); y = ifloor(r + 0.5); r = (y1 - y0) * (t - x0) / (x1 - x0) + y0; /* intersect P3 | P0 P1 */ plotQuadBezierSeg(x0, y0, x, ifloor(r + 0.5), x, y); r = (y1 - y2) * (t - x2) / (x1 - x2) + y2; /* intersect P4 | P1 P2 */ x0 = x1 = x; y0 = y; y1 = ifloor(r + 0.5); /* P0 = P4, P1 = P8 */ } if ((long) (y0 - y1) * (y2 - y1) > 0) { /* vertical cut at P6? */ t = y0 - 2 * y1 + y2; t = (y0 - y1) / t; r = (1 - t) * ((1 - t) * x0 + 2.0 * t * x1) + t * t * x2; /* Bx(t=P6) */ t = (y0 * y2 - y1 * y1) * t / (y0 - y1); /* gradient dP6/dy=0 */ x = ifloor(r + 0.5); y = ifloor(t + 0.5); r = (x1 - x0) * (t - y0) / (y1 - y0) + x0; /* intersect P6 | P0 P1 */ plotQuadBezierSeg(x0, y0, ifloor(r + 0.5), y, x, y); r = (x1 - x2) * (t - y2) / (y1 - y2) + x2; /* intersect P7 | P1 P2 */ x0 = x; x1 = ifloor(r + 0.5); y0 = y1 = y; /* P0 = P6, P1 = P7 */ } plotQuadBezierSeg(x0, y0, x1, y1, x2, y2); /* remaining part */ } #endif static void plotCubicBezierSeg(int x0, int y0, double x1, double y1, double x2, double y2, int x3, int y3) { /* plot limited cubic Bezier segment */ int f, fx, fy, tt; int leg = 1; int sx = x0 < x3 ? 1 : -1; int sy = y0 < y3 ? 1 : -1; /* step direction */ double xc = -fabs(x0 + x1 - x2 - x3); double xa = xc - 4 * sx * (x1 - x2); double xb = sx * (x0 - x1 - x2 + x3); double yc = -fabs(y0 + y1 - y2 - y3); double ya = yc - 4 * sy * (y1 - y2); double yb = sy * (y0 - y1 - y2 + y3); double ab, ac, bc, cb, xx, xy, yy, dx, dy, ex, *pxy; double EP = 0.01; /* check for curve restrains */ /* slope P0-P1 == P2-P3 and (P0-P3 == P1-P2 or no slope change) */ assert((x1 - x0) * (x2 - x3) < EP && ((x3 - x0) * (x1 - x2) < EP || xb * xb < xa * xc + EP)); assert((y1 - y0) * (y2 - y3) < EP && ((y3 - y0) * (y1 - y2) < EP || yb * yb < ya * yc + EP)); if (xa == 0 && ya == 0) { /* quadratic Bezier */ sx = ifloor((3 * x1 - x0 + 1) / 2); sy = ifloor((3 * y1 - y0 + 1) / 2); /* new midpoint */ plotQuadBezierSeg(x0, y0, sx, sy, x3, y3); return; } x1 = (x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0) + 1; /* line lengths */ x2 = (x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3) + 1; do { /* loop over both ends */ ab = xa * yb - xb * ya; ac = xa * yc - xc * ya; bc = xb * yc - xc * yb; ex = ab * (ab + ac - 3 * bc) + ac * ac; /* P0 part of self-intersection loop? */ f = ((ex > 0.0) ? 1 : isqrt(1 + 1024 / x1)); /* calculate resolution */ ab *= f; ac *= f; bc *= f; ex *= f * f; /* increase resolution */ xy = 9 * (ab + ac + bc) / 8; cb = 8 * (xa - ya); /* init differences of 1st degree */ dx = 27 * (8 * ab * (yb * yb - ya * yc) + ex * (ya + 2 * yb + yc)) / 64 - ya * ya * (xy - ya); dy = 27 * (8 * ab * (xb * xb - xa * xc) - ex * (xa + 2 * xb + xc)) / 64 - xa * xa * (xy + xa); /* init differences of 2nd degree */ xx = 3 * (3 * ab * (3 * yb * yb - ya * ya - 2 * ya * yc) - ya * (3 * ac * (ya + yb) + ya * cb)) / 4; yy = 3 * (3 * ab * (3 * xb * xb - xa * xa - 2 * xa * xc) - xa * (3 * ac * (xa + xb) + xa * cb)) / 4; xy = xa * ya * (6 * ab + 6 * ac - 3 * bc + cb); ac = ya * ya; cb = xa * xa; xy = 3 * (xy + 9 * f * (cb * yb * yc - xb * xc * ac) - 18 * xb * yb * ab) / 8; if (ex < 0) { /* negate values if inside self-intersection loop */ dx = -dx; dy = -dy; xx = -xx; yy = -yy; xy = -xy; ac = -ac; cb = -cb; } /* init differences of 3rd degree */ ab = 6 * ya * ac; ac = -6 * xa * ac; bc = 6 * ya * cb; cb = -6 * xa * cb; dx += xy; ex = dx + dy; dy += xy; /* error of 1st step */ for (pxy = &xy, fx = fy = f; x0 != x3 && y0 != y3;) { setPixel(x0, y0); /* plot curve */ do { /* move sub-steps of one pixel */ if (dx > *pxy || dy < *pxy) goto exit; /* confusing values */ y1 = 2 * ex - dy; /* save value for test of y step */ if (2 * ex >= dx) { /* x sub-step */ fx--; ex += dx += xx; dy += xy += ac; yy += bc; xx += ab; } if (y1 <= 0) { /* y sub-step */ fy--; ex += dy += yy; dx += xy += bc; xx += ac; yy += cb; } } while (fx > 0 && fy > 0); /* pixel complete? */ if (2 * fx <= f) { x0 += sx; fx += f; } /* x step */ if (2 * fy <= f) { y0 += sy; fy += f; } /* y step */ if (pxy == &xy && dx < 0 && dy > 0) pxy = &EP; /* pixel ahead valid */ } exit: EXCHANGE(x0, x3, tt); sx = -sx; xb = -xb; /* swap legs */ EXCHANGE(y0, y3, tt); sy = -sy; yb = -yb; x1 = x2; } while (leg--); /* try other end */ plotLine(x0, y0, x3, y3); /* remaining part in case of cusp or crunode */ } static void plotCubicBezier(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) { /* plot any cubic Bezier curve */ int n = 0, i = 0; long xc = x0 + x1 - x2 - x3; long xa = xc - 4 * (x1 - x2); long xb = x0 - x1 - x2 + x3; long xd = xb + 4 * (x1 + x2); long yc = y0 + y1 - y2 - y3; long ya = yc - 4 * (y1 - y2); long yb = y0 - y1 - y2 + y3; long yd = yb + 4 * (y1 + y2); double fx0 = x0; double fy0 = y0; double t1 = (double) (xb * xb - xa * xc), t2, t[5]; #ifdef DEBUG_BEZIER printf("plotCubicBezier(%d,%d, %d,%d, %d,%d, %d,%d\n", x0, y0, x1, y1, x2, y2, x3, y3); #endif /* sub-divide curve at gradient sign changes */ if (xa == 0) { /* horizontal */ if (labs(xc) < 2 * labs(xb)) t[n++] = (double) xc / (2.0 * (double) xb); /* one change */ } else if (t1 > 0.0) { /* two changes */ t2 = sqrt(t1); t1 = ((double) xb - t2) / (double) xa; if (fabs(t1) < 1.0) t[n++] = t1; t1 = ((double) xb + t2) / (double) xa; if (fabs(t1) < 1.0) t[n++] = t1; } t1 = (double) (yb * yb - ya * yc); if (ya == 0) { /* vertical */ if (labs(yc) < 2 * labs(yb)) t[n++] = (double) yc / (2.0 * (double) yb); /* one change */ } else if (t1 > 0.0) { /* two changes */ t2 = sqrt(t1); t1 = ((double) yb - t2) / (double) ya; if (fabs(t1) < 1.0) t[n++] = t1; t1 = ((double) yb + t2) / (double) ya; if (fabs(t1) < 1.0) t[n++] = t1; } for (i = 1; i < n; i++) /* bubble sort of 4 points */ if ((t1 = t[i - 1]) > t[i]) { t[i - 1] = t[i]; t[i] = t1; i = 0; } t1 = -1.0; t[n] = 1.0; /* begin / end point */ for (i = 0; i <= n; i++) { /* plot each segment separately */ double fx1, fx2, fx3; double fy1, fy2, fy3; t2 = t[i]; /* sub-divide at t[i-1], t[i] */ fx1 = (t1 * (t1 * (double) xb - (double) (2 * xc)) - t2 * (t1 * (t1 * (double) xa - (double) (2 * xb)) + (double) xc) + (double) xd) / 8 - fx0; fy1 = (t1 * (t1 * (double) yb - (double) (2 * yc)) - t2 * (t1 * (t1 * (double) ya - (double) (2 * yb)) + (double) yc) + (double) yd) / 8 - fy0; fx2 = (t2 * (t2 * (double) xb - (double) (2 * xc)) - t1 * (t2 * (t2 * (double) xa - (double) (2 * xb)) + (double) xc) + (double) xd) / 8 - fx0; fy2 = (t2 * (t2 * (double) yb - (double) (2 * yc)) - t1 * (t2 * (t2 * (double) ya - (double) (2 * yb)) + (double) yc) + (double) yd) / 8 - fy0; fx0 -= fx3 = (t2 * (t2 * ((double) (3 * xb) - t2 * (double) xa) - (double) (3 * xc)) + (double) xd) / 8; fy0 -= fy3 = (t2 * (t2 * ((double) (3 * yb) - t2 * (double) ya) - (double) (3 * yc)) + (double) yd) / 8; x3 = ifloor(fx3 + 0.5); y3 = ifloor(fy3 + 0.5); /* scale bounds to int */ if (fx0 != 0.0) { fx1 *= fx0 = (x0 - x3) / fx0; fx2 *= fx0; } if (fy0 != 0.0) { fy1 *= fy0 = (y0 - y3) / fy0; fy2 *= fy0; } if (x0 != x3 || y0 != y3) /* segment t1 - t2 */ plotCubicBezierSeg(x0, y0, x0 + fx1, y0 + fy1, x0 + fx2, y0 + fy2, x3, y3); x0 = x3; y0 = y3; fx0 = fx3; fy0 = fy3; t1 = t2; } } #if 0 static void plotQuadSpline(int n, int x[], int y[], int skip_segments) { /* plot quadratic spline, destroys input arrays x,y */ #define M_MAX 12 double mi = 1, m[M_MAX]; /* diagonal constants of matrix */ int i, x0, y0, x1, y1, x2, y2; #ifdef DEBUG_SPLINE_SEGMENTS int color = 0; #endif assert(n > 1); /* need at least 3 points P[0]..P[n] */ #ifdef DEBUG_SPLINE_POINTS { int save_pattern; i = 0; global_context->temporary_write_controls.foreground = 11; save_pattern = global_context->temporary_write_controls.pattern; global_context->temporary_write_controls.pattern = 0xff; draw_patterned_arc(global_context, x[i], y[i], x[i] + 2, y[i], 0, 3600, NULL, NULL); i++; global_context->temporary_write_controls.foreground = 15; for (; i < n; i++) { draw_patterned_arc(global_context, x[i], y[i], x[i] + 2, y[i], 0, 3600, NULL, NULL); } global_context->temporary_write_controls.foreground = 10; draw_patterned_arc(global_context, x[i], y[n], x[i] + 2, y[i], 0, 3600, NULL, NULL); global_context->temporary_write_controls.pattern = save_pattern; } #endif x2 = x[n]; y2 = y[n]; x[1] = x0 = 8 * x[1] - 2 * x[0]; /* first row of matrix */ y[1] = y0 = 8 * y[1] - 2 * y[0]; for (i = 2; i < n; i++) { /* forward sweep */ if (i - 2 < M_MAX) m[i - 2] = mi = 1.0 / (6.0 - mi); x[i] = x0 = ifloor(8 * x[i] - x0 * mi + 0.5); /* store yi */ y[i] = y0 = ifloor(8 * y[i] - y0 * mi + 0.5); } x1 = ifloor((x0 - 2 * x2) / (5.0 - mi) + 0.5); /* correction last row */ y1 = ifloor((y0 - 2 * y2) / (5.0 - mi) + 0.5); for (i = n - 2; i > 0; i--) { /* back substitution */ if (i <= M_MAX) mi = m[i - 1]; x0 = ifloor((x[i] - x1) * mi + 0.5); /* next corner */ y0 = ifloor((y[i] - y1) * mi + 0.5); #ifdef DEBUG_SPLINE_SEGMENTS color++; global_context->temporary_write_controls.foreground = color; #endif if ((n - 2) - i < skip_segments) plotQuadBezier((x0 + x1) / 2, (y0 + y1) / 2, x1, y1, x2, y2); x2 = (x0 + x1) / 2; x1 = x0; y2 = (y0 + y1) / 2; y1 = y0; } #ifdef DEBUG_SPLINE_SEGMENTS color++; global_context->temporary_write_controls.foreground = color; #endif if (skip_segments > 0) plotQuadBezier(x[0], y[0], x1, y1, x2, y2); } #endif static void plotCubicSpline(int n, int x[], int y[], int skip_first_last) { #define M_MAX 12 double mi = 0.25, m[M_MAX]; /* diagonal constants of matrix */ int x3, y3, x4, y4; int i, x0, y0, x1, y1, x2, y2; #ifdef DEBUG_SPLINE_SEGMENTS RegisterNum color = 0; #endif assert(n > 2); /* need at least 4 points P[0]..P[n] */ #ifdef DEBUG_SPLINE_POINTS { unsigned save_pattern; i = 0; global_context->temporary_write_controls.foreground = 11; save_pattern = global_context->temporary_write_controls.pattern; global_context->temporary_write_controls.pattern = 0xff; draw_patterned_arc(global_context, x[i], y[i], x[i] + 2, y[i], 0, 3600, NULL, NULL); i++; global_context->temporary_write_controls.foreground = 15; for (; i < n; i++) { draw_patterned_arc(global_context, x[i], y[i], x[i] + 2, y[i], 0, 3600, NULL, NULL); } global_context->temporary_write_controls.foreground = 10; draw_patterned_arc(global_context, x[i], y[i], x[i] + 2, y[i], 0, 3600, NULL, NULL); global_context->temporary_write_controls.pattern = save_pattern; } #endif x3 = x[n - 1]; y3 = y[n - 1]; x4 = x[n]; y4 = y[n]; x[1] = x0 = 12 * x[1] - 3 * x[0]; /* first row of matrix */ y[1] = y0 = 12 * y[1] - 3 * y[0]; for (i = 2; i < n; i++) { /* forward sweep */ if (i - 2 < M_MAX) m[i - 2] = mi = 0.25 / (2.0 - mi); x[i] = x0 = ifloor(12 * x[i] - 2 * x0 * mi + 0.5); y[i] = y0 = ifloor(12 * y[i] - 2 * y0 * mi + 0.5); } x2 = ifloor((x0 - 3 * x4) / (7 - 4 * mi) + 0.5); /* correct last row */ /* printf("y0=%d, y4=%d mi=%g\n", y0, y4, mi); */ y2 = ifloor((y0 - 3 * y4) / (7 - 4 * mi) + 0.5); /* printf("y2=%d, y3=%d, y4=%d\n", y2, y3, y4); */ #ifdef DEBUG_SPLINE_SEGMENTS color++; global_context->temporary_write_controls.foreground = color; #endif if (!skip_first_last) plotCubicBezier(x3, y3, (x2 + x4) / 2, (y2 + y4) / 2, x4, y4, x4, y4); if (n - 3 < M_MAX) mi = m[n - 3]; x1 = ifloor((x[n - 2] - 2 * x2) * mi + 0.5); y1 = ifloor((y[n - 2] - 2 * y2) * mi + 0.5); for (i = n - 3; i > 0; i--) { /* back substitution */ if (i <= M_MAX) mi = m[i - 1]; x0 = ifloor((x[i] - 2 * x1) * mi + 0.5); y0 = ifloor((y[i] - 2 * y1) * mi + 0.5); x4 = ifloor((x0 + 4 * x1 + x2 + 3) / 6.0); /* reconstruct P[i] */ y4 = ifloor((y0 + 4 * y1 + y2 + 3) / 6.0); #ifdef DEBUG_SPLINE_SEGMENTS color++; global_context->temporary_write_controls.foreground = color; #endif #define CB_PARM(num) ifloor((num) / 3.0 + 0.5) plotCubicBezier(x4, y4, CB_PARM(2 * x1 + x2), CB_PARM(2 * y1 + y2), CB_PARM(x1 + 2 * x2), CB_PARM(y1 + 2 * y2), x3, y3); x3 = x4; y3 = y4; x2 = x1; y2 = y1; x1 = x0; y1 = y0; } x0 = x[0]; x4 = ifloor((3 * x0 + 7 * x1 + 2 * x2 + 6) / 12.0); /* reconstruct P[1] */ y0 = y[0]; y4 = ifloor((3 * y0 + 7 * y1 + 2 * y2 + 6) / 12.0); #ifdef DEBUG_SPLINE_SEGMENTS global_context->temporary_write_controls.foreground = 4; #endif plotCubicBezier(x4, y4, CB_PARM(2 * x1 + x2), CB_PARM(2 * y1 + y2), CB_PARM(x1 + 2 * x2), CB_PARM(y1 + 2 * y2), x3, y3); #ifdef DEBUG_SPLINE_SEGMENTS color++; global_context->temporary_write_controls.foreground = color; #endif if (!skip_first_last) plotCubicBezier(x0, y0, x0, y0, (x0 + x1) / 2, (y0 + y1) / 2, x4, y4); } static unsigned find_free_alphabet_index(RegisGraphicsContext *context, unsigned alphabet, unsigned pixw, unsigned pixh) { unsigned ii, jj; /* try an exact match */ for (ii = 0U; ii < MAX_REGIS_ALPHABETS; ii++) { if (context->alphabets[ii].alphabet_num == alphabet && context->alphabets[ii].pixw == pixw && context->alphabets[ii].pixh == pixh) { return ii; } } /* otherwise use any empty slot */ for (ii = 0U; ii < MAX_REGIS_ALPHABETS; ii++) { if (context->alphabets[ii].alphabet_num == INVALID_ALPHABET_NUM) { context->alphabets[ii].alphabet_num = alphabet; context->alphabets[ii].pixw = pixw; context->alphabets[ii].pixh = pixh; return ii; } } /* otherwise recycle a slot with a different font size */ for (ii = 0U; ii < MAX_REGIS_ALPHABETS; ii++) { if (context->alphabets[ii].alphabet_num == alphabet) { context->alphabets[ii].pixw = pixw; context->alphabets[ii].pixh = pixh; context->alphabets[ii].name[0] = '\0'; context->alphabets[ii].fontname[0] = '\0'; context->alphabets[ii].use_font = 0; if (context->alphabets[ii].bytes != NULL) { free(context->alphabets[ii].bytes); context->alphabets[ii].bytes = NULL; } for (jj = 0U; jj < MAX_GLYPHS; jj++) { context->alphabets[ii].loaded[jj] = 0; } return ii; } } /* finally just recycle this arbitrary slot */ context->alphabets[0U].alphabet_num = alphabet; context->alphabets[0U].pixw = pixw; context->alphabets[0U].pixh = pixh; context->alphabets[0U].name[0] = '\0'; context->alphabets[0U].fontname[0] = '\0'; context->alphabets[0U].use_font = 0; if (context->alphabets[0U].bytes != NULL) { free(context->alphabets[0U].bytes); context->alphabets[0U].bytes = NULL; } for (jj = 0U; jj < MAX_GLYPHS; jj++) { context->alphabets[0U].loaded[jj] = 0; } return 0U; } #ifdef DEBUG_SPECIFIC_CHAR_METRICS static void dump_bitmap_pixels(unsigned char const *pixels, unsigned w, unsigned h) { unsigned yy, xx; for (yy = 0U; yy < h; yy++) { printf(" "); for (xx = 0U; xx < w; xx++) { if (pixels[yy * w + xx]) { printf("#"); } else { printf("_"); } } printf("\n"); } } #endif #if OPT_RENDERFONT && defined(HAVE_TYPE_FCCHAR32) static int copy_bitmap_from_xft_font(Display *display, XftFont *font, FcChar32 ch, unsigned char *pixels, unsigned w, unsigned h, unsigned xmin, unsigned ymin) { /* * FIXME: cache: * - the bitmap for the last M characters and target dimensions * - resuse the pixmap object where possible */ XftColor bg, fg; Pixmap bitmap; XftDraw *draw; XImage *image; unsigned bmw, bmh; unsigned xx, yy; bg.pixel = 0UL; bg.color.red = 0; bg.color.green = 0; bg.color.blue = 0; bg.color.alpha = 0x0; fg.pixel = 1UL; fg.color.red = 0xffff; fg.color.green = 0xffff; fg.color.blue = 0xffff; fg.color.alpha = 0xffff; bmw = w + xmin; bmh = h; bitmap = XCreatePixmap(display, DefaultRootWindow(display), bmw, bmh, 1); if (bitmap == None) { TRACE(("Unable to create Pixmap\n")); return 0; } draw = XftDrawCreateBitmap(display, bitmap); if (!draw) { TRACE(("Unable to create XftDraw\n")); XFreePixmap(display, bitmap); return 0; } XftDrawRect(draw, &bg, 0, 0, bmw, bmh); XftDrawString32(draw, &fg, font, 0, font->ascent - (int) ymin, &ch, 1); image = XGetImage(display, bitmap, (int) xmin, 0, w, h, 1, XYPixmap); if (!image) { TRACE(("Unable to create XImage\n")); XftDrawDestroy(draw); XFreePixmap(display, bitmap); return 0; } for (yy = 0U; yy < h; yy++) { for (xx = 0U; xx < w; xx++) { pixels[yy * w + xx] = (unsigned char) XGetPixel(image, (int) xx, (int) yy); } } XDestroyImage(image); XftDrawDestroy(draw); XFreePixmap(display, bitmap); return 1; } static void get_xft_glyph_dimensions(Display *display, XftFont *font, unsigned *w, unsigned *h, unsigned *xmin, unsigned *ymin) { unsigned workw, workh; FcChar32 ch; unsigned char *pixels; unsigned yy, xx; unsigned char_count, pixel_count; unsigned real_minx, real_maxx, real_miny, real_maxy; unsigned char_minx, char_maxx, char_miny, char_maxy; /* * For each ASCII or ISO-8859-1 printable code, find out what its * dimensions are. * * We actually render the glyphs and determine the extents ourselves * because the font library can lie by several pixels, and since we are * doing manual character placement in fixed areas the glyph boundary needs * to be accurate. * * Ignore control characters and spaces - their extent information is * misleading. */ /* Our "work area" is just a buffer which should be big enough to hold the * largest glyph even if its size is under-reported by a couple of pixels * in each dimension. */ workw = (unsigned) font->max_advance_width + 2U; if (font->ascent + font->descent > font->height) { workh = (unsigned) (font->ascent + font->descent) + 2U; } else { workh = (unsigned) font->height + 2U; } if (!(pixels = malloc(workw * workh))) { *w = 0U; *h = 0U; return; } /* FIXME: ch is in UCS32 -- try to support non-ASCII characters */ char_count = 0U; real_minx = workw - 1U; real_maxx = 0U; real_miny = workh - 1U; real_maxy = 0U; for (ch = 33; ch < 256; ++ch) { if (ch >= 127 && ch <= 160) continue; if (!FcCharSetHasChar(font->charset, ch)) continue; copy_bitmap_from_xft_font(display, font, ch, pixels, workw, workh, 0U, 0U); pixel_count = 0U; char_minx = workh - 1U; char_maxx = 0U; char_miny = workh - 1U; char_maxy = 0U; for (yy = 0U; yy < workh; yy++) { for (xx = 0U; xx < workw; xx++) { if (pixels[yy * workw + xx]) { if (xx < char_minx) char_minx = xx; if (xx > char_maxx) char_maxx = xx; if (yy < char_miny) char_miny = yy; if (yy > char_maxy) char_maxy = yy; pixel_count++; } } } if (pixel_count < 1U) continue; #ifdef DEBUG_SPECIFIC_CHAR_METRICS if (IS_DEBUG_CHAR(ch)) { printf("char: '%c' (%d)\n", (char) ch, ch); printf(" minx: %u\n", char_minx); printf(" maxx: %u\n", char_maxx); printf(" miny: %u\n", char_miny); printf(" maxy: %u\n", char_maxy); dump_bitmap_pixels(pixels, workw, workh); printf("\n"); } #endif if (char_minx < real_minx) real_minx = char_minx; if (char_maxx > real_maxx) real_maxx = char_maxx; if (char_miny < real_miny) real_miny = char_miny; if (char_maxy > real_maxy) real_maxy = char_maxy; char_count++; } free(pixels); if (char_count < 1U) { *w = 0U; *h = 0U; return; } *w = (unsigned) (1 + real_maxx - real_minx); *h = (unsigned) (1 + real_maxy - real_miny); *xmin = real_minx; *ymin = real_miny; #ifdef DEBUG_COMPUTED_FONT_METRICS printf("reported metrics:\n"); printf(" %ux%u ascent=%u descent=%u\n", font->max_advance_width, font->height, font->ascent, font->descent); printf("computed metrics:\n"); printf(" real_minx=%u real_maxx=%u real_miny=%u real_maxy=%u\n", real_minx, real_maxx, real_miny, real_maxy); printf(" final: %ux%u xmin=%u ymin=%u\n", *w, *h, *xmin, *ymin); #endif } #define FONT_SIZE_CACHE_SIZE 32U /* Find the font pixel size which returns the font which is closest to the given * maxw and maxh without overstepping either dimension. */ static XftFont * find_best_xft_font_size(Display *display, Screen *screen, char const *fontname, unsigned maxw, unsigned maxh, unsigned max_pixels, unsigned *w, unsigned *h, unsigned *xmin, unsigned *ymin) { XftFont *font; unsigned targeth; unsigned ii, cacheindex; static struct { char fontname[REGIS_FONTNAME_LEN]; unsigned maxw, maxh, max_pixels; unsigned targeth; unsigned w, h; unsigned xmin; unsigned ymin; } cache[FONT_SIZE_CACHE_SIZE]; assert(display); assert(screen); assert(fontname); assert(w); assert(h); assert(xmin); assert(ymin); cacheindex = FONT_SIZE_CACHE_SIZE; for (ii = 0U; ii < FONT_SIZE_CACHE_SIZE; ii++) { if (cache[ii].maxw == maxw && cache[ii].maxh == maxh && cache[ii].max_pixels == max_pixels && strcmp(cache[ii].fontname, fontname) == 0) { cacheindex = ii; break; } } if (cacheindex < FONT_SIZE_CACHE_SIZE) { targeth = cache[cacheindex].targeth; } else { targeth = maxh * 10U + 5U; } for (;;) { if (targeth <= 5U) { TRACE(("Giving up finding suitable Xft font size for %ux%u.\n", maxw, maxh)); return NULL; } /* * Xft does a bad job at: * - two-color low-resolution anti-aliased fonts * - non-anti-aliased fonts at low resolution unless a font size is * given (pixel size does not help, and the value of the font size * doesn't appear to matter). * * In those two cases it literally drops pixels, sometimes whole * columns, making the glyphs unreadable and ugly even when readable. */ /* * FIXME: * Also, we need to scale the width and height separately. The * CHAR_WIDTH and CHAR_HEIGHT attributes would seem to be ideal, but * don't appear to have any effect if set. Instead we will manually * scale the bitmap later, which may be very ugly because we won't try * to identify different parts of glyphs or preserve density. */ { XftPattern *pat; XftPattern *match; XftResult status; font = NULL; if ((pat = XftNameParse(fontname))) { XftPatternBuild(pat, /* arbitrary value */ XFT_SIZE, XftTypeDouble, 12.0, XFT_PIXEL_SIZE, XftTypeDouble, (double) targeth / 10.0, #if 0 XFT_CHAR_WIDTH, XftTypeInteger, (int) maxw, XFT_CHAR_HEIGHT, XftTypeInteger, (int) (targeth / 10U), #endif XFT_SPACING, XftTypeInteger, XFT_MONO, XFT_SLANT, XftTypeInteger, 0, XFT_ANTIALIAS, XftTypeBool, False, NULL); if ((match = XftFontMatch(display, XScreenNumberOfScreen(screen), pat, &status))) { font = XftFontOpenPattern(display, match); } } } if (!font) { TRACE(("Unable to open a monospaced Xft font.\n")); return NULL; } #ifdef DEBUG_FONT_SIZE_SEARCH { char buffer[1024]; if (XftNameUnparse(font->pattern, buffer, (int) sizeof(buffer))) { printf("Testing font named \"%s\"\n", buffer); } else { printf("Testing unknown font\n"); } } #endif if (cacheindex < FONT_SIZE_CACHE_SIZE && targeth == cache[cacheindex].targeth) { *w = cache[cacheindex].w; *h = cache[cacheindex].h; *xmin = cache[cacheindex].xmin; *ymin = cache[cacheindex].ymin; } else { get_xft_glyph_dimensions(display, font, w, h, xmin, ymin); } #ifdef DEBUG_FONT_SIZE_SEARCH printf("checking max=%ux%u targeth=%u.%u\n", maxw, maxh, targeth / 10U, targeth % 10U); #endif if (*h > maxh) { XftFontClose(display, font); #ifdef DEBUG_FONT_SIZE_SEARCH printf("got %ux%u glyph; too tall; reducing target size\n", *w, *h); #endif if (*h > 2U * maxh) { targeth /= (*h / maxh); } else if (targeth > 10U && *h > maxh + 1U) { targeth -= 10U; } else { targeth--; } continue; } if (*w > maxw) { XftFontClose(display, font); #ifdef DEBUG_FONT_SIZE_SEARCH printf("got %ux%u glyph; too wide; reducing target size\n", *w, *h); #endif if (*w > 2U * maxw) { targeth /= (*w / maxw); } else if (targeth > 10U && *w > maxw + 1U) { targeth -= 10U; } else { targeth--; } continue; } if (*w * *h > max_pixels) { XftFontClose(display, font); #ifdef DEBUG_FONT_SIZE_SEARCH printf("got %ux%u glyph; too many pixels; reducing target size\n", *w, *h); #endif if (*w * *h > 2U * max_pixels) { unsigned min = *w < *h ? *w : *h; unsigned divisor = (*w * *h) / (max_pixels * min); if (divisor > 1U) { targeth /= divisor; } else if (targeth > 10U) { targeth -= 10U; } else { targeth--; } } else { targeth--; } continue; } #ifdef DEBUG_FONT_NAME { char buffer[1024]; if (XftNameUnparse(font->pattern, buffer, (int) sizeof(buffer))) { printf("Final font for \"%s\" max %dx%d is \"%s\"\n", fontname, maxw, maxh, buffer); } else { printf("Final font for \"%s\" max %dx%d is unknown\n", fontname, maxw, maxh); } } #endif if (cacheindex == FONT_SIZE_CACHE_SIZE) { for (ii = 0U; ii < FONT_SIZE_CACHE_SIZE; ii++) { if (cache[ii].maxw == 0U || cache[ii].maxh == 0U || cache[ii].max_pixels == 0U) { CopyFontname(cache[ii].fontname, fontname); cache[ii].maxw = maxw; cache[ii].maxh = maxh; cache[ii].max_pixels = max_pixels; cache[ii].targeth = targeth; cache[ii].w = *w; cache[ii].h = *h; cache[ii].xmin = *xmin; cache[ii].ymin = *ymin; break; } } if (ii == FONT_SIZE_CACHE_SIZE) { ii = targeth % FONT_SIZE_CACHE_SIZE; CopyFontname(cache[ii].fontname, fontname); cache[ii].maxw = maxw; cache[ii].maxh = maxh; cache[ii].max_pixels = max_pixels; cache[ii].targeth = targeth; cache[ii].w = *w; cache[ii].h = *h; cache[ii].xmin = *xmin; cache[ii].ymin = *ymin; } } return font; } } #endif static int get_xft_bitmap_of_character(RegisGraphicsContext const *context, char const *fontname, int ch, unsigned maxw, unsigned maxh, unsigned char *pixels, unsigned max_pixels, unsigned *w, unsigned *h) { /* * See Xft / RENDERFONT stuff in fontutils.c and used in utils.c * Add a separate configuration for ReGIS. */ /* * FIXME: cache: * - resuse the font where possible */ #ifdef XRENDERFONT Display *display = XtDisplay(context->destination_graphic->xw); Screen *screen = XtScreen(context->destination_graphic->xw); XftFont *font; unsigned xmin = 0U, ymin = 0U; if (!(font = find_best_xft_font_size(display, screen, fontname, maxw, maxh, max_pixels, w, h, &xmin, &ymin))) { TRACE(("Unable to find suitable Xft font\n")); return 0; } if (!copy_bitmap_from_xft_font(display, font, CharOf(ch), pixels, *w, *h, xmin, ymin)) { TRACE(("Unable to create bitmap for '%c'\n", ch)); XftFontClose(display, font); return 0; } XftFontClose(display, font); return 1; #else (void) context; (void) context; (void) ch; (void) maxw; (void) maxh; (void) pixels; (void) max_pixels; (void) w; (void) h; return 0; #endif } static unsigned find_best_alphabet_index(RegisGraphicsContext const *context, unsigned minw, unsigned minh, unsigned maxw, unsigned maxh, unsigned max_pixels) { unsigned ii; unsigned bestmatch; unsigned bestw, besth; assert(context); assert(maxw); assert(maxh); bestmatch = MAX_REGIS_ALPHABETS; bestw = 0U; besth = 0U; for (ii = 0U; ii < MAX_REGIS_ALPHABETS; ii++) { if (context->alphabets[ii].alphabet_num == context->current_text_controls->alphabet_num && context->alphabets[ii].pixw >= minw && context->alphabets[ii].pixh >= minh && context->alphabets[ii].pixw <= maxw && context->alphabets[ii].pixh <= maxh && context->alphabets[ii].pixw > bestw && context->alphabets[ii].pixh > besth && context->alphabets[ii].pixw * context->alphabets[ii].pixh <= max_pixels) { bestmatch = ii; bestw = context->alphabets[ii].pixw; besth = context->alphabets[ii].pixh; } } #ifdef DEBUG_ALPHABET_LOOKUP if (bestmatch < MAX_REGIS_ALPHABETS) { TRACE(("found alphabet %u at index %u size %ux%u font=%s\n", context->current_text_controls->alphabet_num, bestmatch, bestw, besth, context->alphabets[bestmatch].use_font ? context->alphabets[bestmatch].fontname : "(none)")); } #endif return bestmatch; } #define GLYPH_WIDTH_BYTES(PIXW) ( ((PIXW) + 7U) >> 3U ) static int get_user_bitmap_of_character(RegisGraphicsContext const *context, int ch, unsigned alphabet_index, unsigned char *pixels) { const unsigned char *glyph; unsigned w, h; unsigned xx, yy; unsigned byte, bit; assert(context); assert(pixels); if (!context->alphabets[alphabet_index].loaded[(unsigned char) ch]) { TRACE(("in alphabet %u with alphabet index %u user glyph for '%c' not loaded\n", context->current_text_controls->alphabet_num, alphabet_index, ch)); return 0; } assert(context->alphabets[alphabet_index].bytes); w = context->alphabets[alphabet_index].pixw; h = context->alphabets[alphabet_index].pixh; glyph = &context->alphabets[alphabet_index] .bytes[(unsigned char) ch * GLYPH_WIDTH_BYTES(w) * h]; for (yy = 0U; yy < h; yy++) { for (xx = 0U; xx < w; xx++) { byte = yy * GLYPH_WIDTH_BYTES(w) + (xx >> 3U); bit = xx & 7U; pixels[yy * w + xx] = ((unsigned) glyph[byte] >> (7U - bit)) & 1U; } } return 1; } /* * alphabets * 0 built-in * 1-N custom (max is 3 on VT3X0 -- up to MAX_REGIS_ALPHABETS with xterm) * * built-in 7-bit charsets * (B ASCII * (0 DEC special graphics * (> DEC technical * (A NCR British * (4 NCR Dutch * (5 NCR Finnish * (R NCR French * (9 NCR French Canadian * (K NCR German * (Y NCR Italian * (' NCR Norwegian/Danish * (!6 NCR Portuguese * (Z NCR Spanish * (7 NCR Swedish * (- NCR Swiss * * -@ ??? * * built-in 8-bit charsets * )%5 DEC supplemental graphics * -A ISO Latin-1 supplemental * )< user-preferred supplemental (94 chars) * * defaults * terminal char cell size charsets angle * VT3x0 S1 0:ASCII(94) 0 (positive) * */ static void get_bitmap_of_character(RegisGraphicsContext const *context, int ch, unsigned maxw, unsigned maxh, unsigned char *pixels, unsigned *w, unsigned *h, unsigned max_pixels) { unsigned bestmatch; char const *fontname = NULL; assert(context); assert(w); assert(h); if (context->current_text_controls->alphabet_num == 0) fontname = context->builtin_font; *w = 0U; *h = 0U; bestmatch = find_best_alphabet_index(context, 1U, 1U, maxw, maxh, max_pixels); if (bestmatch < MAX_REGIS_ALPHABETS) { RegisAlphabet const *alpha = &context->alphabets[bestmatch]; if (!alpha->use_font && get_user_bitmap_of_character(context, ch, bestmatch, pixels)) { #ifdef DEBUG_USER_GLYPH TRACE(("found user glyph for alphabet number %d (index %u)\n\n", context->current_text_controls->alphabet_num, bestmatch)); #endif *w = alpha->pixw; *h = alpha->pixh; return; } if (alpha->use_font) fontname = alpha->fontname; } if (fontname) { if (get_xft_bitmap_of_character(context, fontname, ch, maxw, maxh, pixels, max_pixels, w, h)) { if (*w > maxw) { TRACE(("BUG: Xft glyph is too wide: %ux%u but max is %ux%u\n", *w, *h, maxw, maxh)); } else if (*h > maxh) { TRACE(("BUG: Xft glyph is too tall: %ux%u but max is %ux%u\n", *w, *h, maxw, maxh)); } else if (*w * *h > max_pixels) { TRACE(("BUG: Xft glyph has too many pixels: %u but max is %u\n", *w * *h, max_pixels)); } else { TRACE(("got glyph from \"%s\" for alphabet number %d\n", fontname, context->current_text_controls->alphabet_num)); #ifdef DEBUG_SPECIFIC_CHAR_METRICS if (IS_DEBUG_CHAR(ch)) { printf("got %ux%u Xft bitmap for '%c' target size %ux%u:\n", *w, *h, ch, maxw, maxh); dump_bitmap_pixels(pixels, *w, *h); printf("\n"); } #endif return; } } } TRACE(("unable to load any bitmap for character '%c' in alphabet number %u at %ux%u\n", ch, context->current_text_controls->alphabet_num, maxw, maxh)); /* * The VT3x0 series (and probably earlier ReGIS implementations) use a solid * block glyph for unknown glyphs. */ { unsigned xx, yy; *w = MIN2(8U, maxh); *h = MIN2(10U, maxw); for (yy = 0U; yy < *h; yy++) for (xx = 0U; xx < *w; xx++) pixels[yy * *w + xx] = '\1'; } } #define ROT_SHEAR_SCALE 8192 #define SIGNED_UNSIGNED_MOD(VAL, BASE) ( (((VAL) % (int) (BASE)) + (int) (BASE)) % (int) (BASE) ) static unsigned get_shade_character_pixel(unsigned char const *pixels, unsigned w, unsigned h, unsigned smaxf, unsigned scale, int slant_dx, int px, int py) { unsigned wx, wy; unsigned fx, fy; wx = (unsigned) SIGNED_UNSIGNED_MOD(px - (slant_dx * SIGNED_UNSIGNED_MOD(py, smaxf)) / ROT_SHEAR_SCALE, smaxf); wy = (unsigned) SIGNED_UNSIGNED_MOD(py, smaxf); fx = (wx * scale) >> SCALE_FIXED_POINT; fy = (wy * scale) >> SCALE_FIXED_POINT; if (fx < w && fy < h) { return (unsigned) pixels[fy * w + fx]; } return 0U; } static void draw_character(RegisGraphicsContext *context, int ch, int slant_dx, int rot_shear_x, int rot_shear_y, int x_sign_x, int x_sign_y, int y_sign_x, int y_sign_y) { const unsigned xmaxd = context->current_text_controls->character_display_w; const unsigned ymaxd = context->current_text_controls->character_display_h; const unsigned xmaxf = context->current_text_controls->character_unit_cell_w; const unsigned ymaxf = context->current_text_controls->character_unit_cell_h; unsigned w, h; unsigned xscale, yscale; unsigned fx, fy; unsigned px, py; int sx; int rx, ry; int ox, oy; unsigned pad_left, pad_right; unsigned pad_top, pad_bottom; unsigned char pixels[MAX_GLYPH_PIXELS]; unsigned value; get_bitmap_of_character(context, ch, xmaxf, ymaxf, pixels, &w, &h, MAX_GLYPH_PIXELS); if (w < 1 || h < 1) { return; } if (xmaxd > xmaxf) { pad_left = (xmaxd - xmaxf) / 2U; pad_right = (xmaxd - xmaxf) - pad_left; } else { pad_left = 0U; pad_right = 0U; } if (ymaxd > ymaxf) { pad_top = (ymaxd - ymaxf) / 2U; pad_bottom = (ymaxd - ymaxf) - pad_top; } else { pad_top = 0U; pad_bottom = 0U; } xscale = (w << SCALE_FIXED_POINT) / xmaxf; yscale = (h << SCALE_FIXED_POINT) / ymaxf; for (py = 0U; py < ymaxd; py++) { for (px = 0U; px < xmaxd; px++) { if (py < pad_top || px < pad_left || py >= ymaxd - pad_bottom || px >= xmaxd - pad_right) { value = 0U; } else { fx = ((px - pad_left) * xscale) >> SCALE_FIXED_POINT; fy = ((py - pad_top) * yscale) >> SCALE_FIXED_POINT; if (fx < w && fy < h) { value = (unsigned) pixels[fy * w + fx]; } else { value = 0U; } } sx = (int) px + (slant_dx * (int) py) / ROT_SHEAR_SCALE; rx = x_sign_x * sx + x_sign_y * (int) py; ry = y_sign_x * sx + y_sign_y * (int) py; ox = rx + (rot_shear_x * ry) / ROT_SHEAR_SCALE; oy = ry + (rot_shear_y * ox) / ROT_SHEAR_SCALE; ox += (rot_shear_x * oy) / ROT_SHEAR_SCALE; draw_regis_pixel(context, (int) context->graphics_output_cursor_x + ox, (int) context->graphics_output_cursor_y + oy, value); } } } static void move_text(RegisGraphicsContext *context, int dx, int dy) { double total_rotation; int str_invert; int str_shear_x, str_shear_y; int ox, oy; total_rotation = 2.0 * M_PI * context->current_text_controls->string_rotation / 360.0; while (total_rotation > 1.5 * M_PI) { total_rotation -= 2.0 * M_PI; } if (total_rotation > 0.5 * M_PI) { total_rotation -= M_PI; str_invert = -1; } else { str_invert = 1; } str_shear_x = (int) (ROT_SHEAR_SCALE * -tan(0.5 * -total_rotation)); str_shear_y = (int) (ROT_SHEAR_SCALE * sin(-total_rotation)); total_rotation = 2.0 * M_PI * context->current_text_controls->character_rotation / 360.0; while (total_rotation > 1.5 * M_PI) { total_rotation -= 2.0 * M_PI; } TRACE(("str_shear: %.5f, %.5f (sign=%d)\n", str_shear_x / (double) ROT_SHEAR_SCALE, str_shear_y / (double) ROT_SHEAR_SCALE, str_invert)); ox = str_invert * dx + (str_shear_x * dy) / ROT_SHEAR_SCALE; oy = str_invert * dy + (str_shear_y * ox) / ROT_SHEAR_SCALE; ox += (str_shear_x * oy) / ROT_SHEAR_SCALE; TRACE(("after pv output updating position %+d,%+d\n", ox, oy)); context->graphics_output_cursor_x += ox; context->graphics_output_cursor_y += oy; return; } #define UPSCALE_TEXT_DIMENSION(D) do { \ *(D) = (unsigned)((double)(*(D)) * M_SQRT2); \ } while (0) static void draw_text(RegisGraphicsContext *context, char const *str) { #ifndef ENABLE_DISTORTIONLESS_ROTATION RegisTextControls *old_text_controls = NULL; RegisTextControls scratch_text_controls; #endif double total_rotation; size_t ii; int str_invert; int str_shear_x, str_shear_y; int slant_dx; int chr_x_sign_x, chr_x_sign_y; int chr_y_sign_x, chr_y_sign_y; int chr_shear_x, chr_shear_y; int begin_x, begin_y; int rx, ry; int ox, oy; #ifdef DEBUG_ALPHABETS { unsigned n; for (n = 0U; n < MAX_REGIS_ALPHABETS; n++) { printf("alphabet index %u\n", n); if (context->alphabets[n].alphabet_num != INVALID_ALPHABET_NUM) { printf(" alphabet_num=%u\n", context->alphabets[n].alphabet_num); printf(" pixw=%d\n", context->alphabets[n].pixw); printf(" pixh=%d\n", context->alphabets[n].pixh); printf(" name=\"%s\"\n", context->alphabets[n].name); printf(" use_font=%d\n", context->alphabets[n].use_font); printf(" fontname=\"%s\"\n", context->alphabets[n].fontname); printf(" bytes=%p\n", context->alphabets[n].bytes); } } } #endif if (context->current_text_controls->slant <= -75 || context->current_text_controls->slant >= +75) { TRACE(("ERROR: unsupported character slant angle %d\n", context->current_text_controls->slant)); return; } /* FIXME: grab when first entering command */ begin_x = context->graphics_output_cursor_x; begin_y = context->graphics_output_cursor_y; #ifndef ENABLE_DISTORTIONLESS_ROTATION if (context->current_text_controls->character_rotation != 0 && context->current_text_controls->character_rotation != 90 && context->current_text_controls->character_rotation != 180 && context->current_text_controls->character_rotation != 270) { old_text_controls = context->current_text_controls; scratch_text_controls = *context->current_text_controls; UPSCALE_TEXT_DIMENSION(&scratch_text_controls.character_display_w); UPSCALE_TEXT_DIMENSION(&scratch_text_controls.character_display_h); /* FIXME: Not sure if this is really scaled. The increment seems to * _not_ be scaled. */ UPSCALE_TEXT_DIMENSION(&scratch_text_controls.character_unit_cell_w); UPSCALE_TEXT_DIMENSION(&scratch_text_controls.character_unit_cell_h); context->current_text_controls = &scratch_text_controls; TRACE(("scaled up text to %dx%d\n", scratch_text_controls.character_display_w, scratch_text_controls.character_display_h)); } #endif total_rotation = 2.0 * M_PI * context->current_text_controls->string_rotation / 360.0; while (total_rotation > 1.5 * M_PI) { total_rotation -= 2.0 * M_PI; } if (total_rotation > 0.5 * M_PI) { total_rotation -= M_PI; str_invert = -1; } else { str_invert = 1; } str_shear_x = (int) (ROT_SHEAR_SCALE * -tan(0.5 * -total_rotation)); str_shear_y = (int) (ROT_SHEAR_SCALE * sin(-total_rotation)); total_rotation = 2.0 * M_PI * context->current_text_controls->character_rotation / 360.0; while (total_rotation > 1.5 * M_PI) { total_rotation -= 2.0 * M_PI; } if (total_rotation > 0.5 * M_PI) { total_rotation -= M_PI; chr_x_sign_x = -1; chr_x_sign_y = 0; chr_y_sign_x = 0; chr_y_sign_y = -1; } else { chr_x_sign_x = 1; chr_x_sign_y = 0; chr_y_sign_x = 0; chr_y_sign_y = 1; } chr_shear_x = (int) (ROT_SHEAR_SCALE * -tan(0.5 * -total_rotation)); chr_shear_y = (int) (ROT_SHEAR_SCALE * sin(-total_rotation)); { const int slant = context->current_text_controls->slant; TRACE(("float version: %.5f\n", tan(2.0 * M_PI * abs(slant) / 360.0))); /* The slant is negative for forward-leaning characters. */ if (slant > 0) { slant_dx = (int) +(tan(2.0 * M_PI * abs(slant) / 360.0) * ROT_SHEAR_SCALE); } else if (slant < 0) { slant_dx = (int) -(tan(2.0 * M_PI * abs(slant) / 360.0) * ROT_SHEAR_SCALE); } else { slant_dx = 0; } TRACE(("string rotation: %d\n", context->current_text_controls->string_rotation)); TRACE(("character rotation: %d\n", context->current_text_controls->character_rotation)); TRACE(("character slant: %d (%.5f pixels per line)\n", slant, slant_dx / (double) ROT_SHEAR_SCALE)); } TRACE(("str_shear: %.5f, %.5f (sign=%d)\n", str_shear_x / (double) ROT_SHEAR_SCALE, str_shear_y / (double) ROT_SHEAR_SCALE, str_invert)); TRACE(("chr_shear: %.5f, %.5f (xsign=%d,%d, ysign=%d,%d)\n", chr_shear_x / (double) ROT_SHEAR_SCALE, chr_shear_y / (double) ROT_SHEAR_SCALE, chr_x_sign_x, chr_x_sign_y, chr_y_sign_x, chr_y_sign_y)); TRACE(("character_inc: %d,%d\n", context->current_text_controls->character_inc_x, context->current_text_controls->character_inc_y)); rx = 0; ry = 0; for (ii = 0U; ii < strlen(str); ii++) { switch (str[ii]) { case '\r': rx = 0; break; case '\n': ry += (int) context->current_text_controls->character_display_h; break; case '\b': rx -= context->current_text_controls->character_inc_x; ry -= context->current_text_controls->character_inc_y; break; case '\t': rx += context->current_text_controls->character_inc_x; ry += context->current_text_controls->character_inc_y; break; default: ox = str_invert * rx + (str_shear_x * ry) / ROT_SHEAR_SCALE; oy = str_invert * ry + (str_shear_y * ox) / ROT_SHEAR_SCALE; ox += (str_shear_x * oy) / ROT_SHEAR_SCALE; TRACE(("during text output updating position to %d,%d + %+d,%+d for '%c'\n", begin_x, begin_y, ox, oy, str[ii])); context->graphics_output_cursor_x = begin_x + ox; context->graphics_output_cursor_y = begin_y + oy; draw_character(context, str[ii], slant_dx, chr_shear_x, chr_shear_y, chr_x_sign_x, chr_x_sign_y, chr_y_sign_x, chr_y_sign_y); rx += context->current_text_controls->character_inc_x; ry += context->current_text_controls->character_inc_y; } } ox = str_invert * rx + (str_shear_x * ry) / ROT_SHEAR_SCALE; oy = str_invert * ry + (str_shear_y * ox) / ROT_SHEAR_SCALE; ox += (str_shear_x * oy) / ROT_SHEAR_SCALE; TRACE(("after text output updating position to %d,%d + %+d,%+d\n", begin_x, begin_y, ox, oy)); context->graphics_output_cursor_x = begin_x + ox; context->graphics_output_cursor_y = begin_y + oy; #ifndef ENABLE_DISTORTIONLESS_ROTATION if (context->current_text_controls->character_rotation != 0 && context->current_text_controls->character_rotation != 90 && context->current_text_controls->character_rotation != 180 && context->current_text_controls->character_rotation != 270) { context->current_text_controls = old_text_controls; } #endif context->destination_graphic->dirty = 1; return; } /* * standard character cell sizes * number disp cell unit cell offset * S0 [ 9, 10] [ 8, disp_h] [disp_w, 0] * S1 [ 9, 20] [ 8, disp_h] [disp_w, 0] * S2 [ 18, 30] [ 16, disp_h] [disp_w, 0] * S3 [ 27, 45] [ 24, disp_h] [disp_w, 0] * S4 [ 36, 60] [ 32, disp_h] [disp_w, 0] * S5 [ 45, 75] [ 40, disp_h] [disp_w, 0] * S6 [ 54, 90] [ 48, disp_h] [disp_w, 0] * S7 [ 63,105] [ 56, disp_h] [disp_w, 0] * S8 [ 72,120] [ 64, disp_h] [disp_w, 0] * S9 [ 81,135] [ 72, disp_h] [disp_w, 0] * S10 [ 90,150] [ 80, disp_h] [disp_w, 0] * S11 [ 99,165] [ 88, disp_h] [disp_w, 0] * S12 [108,180] [ 96, disp_h] [disp_w, 0] * S13 [117,195] [104, disp_h] [disp_w, 0] * S14 [126,210] [112, disp_h] [disp_w, 0] * S15 [135,225] [120, disp_h] [disp_w, 0] * S16 [144,240] [128, disp_h] [disp_w, 0] */ static int get_standard_character_size(int standard, unsigned *disp_w, unsigned *disp_h, unsigned *unit_w, unsigned *unit_h, int *off_x, int *off_y) { switch (standard) { case 0: *disp_w = 9U; *disp_h = 10U; *unit_w = 8U; break; case 1: *disp_w = 9U; *disp_h = 20U; *unit_w = 8U; break; case 2: *disp_w = 18U; *disp_h = 30U; *unit_w = 16U; break; case 3: *disp_w = 27U; *disp_h = 45U; *unit_w = 24U; break; case 4: *disp_w = 36U; *disp_h = 60U; *unit_w = 32U; break; case 5: *disp_w = 45U; *disp_h = 75U; *unit_w = 40U; break; case 6: *disp_w = 54U; *disp_h = 90U; *unit_w = 48U; break; case 7: *disp_w = 63U; *disp_h = 105U; *unit_w = 56U; break; case 8: *disp_w = 72U; *disp_h = 120U; *unit_w = 64U; break; case 9: *disp_w = 81U; *disp_h = 135U; *unit_w = 72U; break; case 10: *disp_w = 90U; *disp_h = 150U; *unit_w = 80U; break; case 11: *disp_w = 99U; *disp_h = 165U; *unit_w = 88U; break; case 12: *disp_w = 108U; *disp_h = 180U; *unit_w = 96U; break; case 13: *disp_w = 117U; *disp_h = 195U; *unit_w = 104U; break; case 14: *disp_w = 126U; *disp_h = 210U; *unit_w = 112U; break; case 15: *disp_w = 135U; *disp_h = 225U; *unit_w = 120U; break; case 16: *disp_w = 144U; *disp_h = 240U; *unit_w = 128U; break; default: return 1; } *unit_h = *disp_h; *off_x = (int) *disp_w; *off_y = 0; return 0; } static void init_fragment(RegisDataFragment *fragment, char const *str) { assert(fragment); assert(str); fragment->start = str; fragment->len = (unsigned) strlen(str); fragment->pos = 0U; } static void copy_fragment(RegisDataFragment *dst, RegisDataFragment const *src) { assert(dst); assert(src); dst->start = src->start; dst->len = src->len; dst->pos = src->pos; } static char peek_fragment(RegisDataFragment const *fragment) { assert(fragment); if (fragment->pos < fragment->len) { return fragment->start[fragment->pos]; } return '\0'; } static char pop_fragment(RegisDataFragment *fragment) { assert(fragment); if (fragment->pos < fragment->len) { return fragment->start[fragment->pos++]; } return '\0'; } static char get_fragment(RegisDataFragment const *fragment, unsigned pos) { assert(fragment); if (fragment->pos + pos < fragment->len) { return fragment->start[fragment->pos + pos]; } return '\0'; } #define fragment_length(f) (f)->len static unsigned fragment_remaining(RegisDataFragment const *fragment) { assert(fragment); if (fragment->pos > fragment->len) return 0U; return fragment->len - fragment->pos; } static int fragment_consumed(RegisDataFragment const *fragment) { assert(fragment); return fragment->pos >= fragment->len; } static void fragment_to_string(RegisDataFragment const *fragment, char *out, unsigned outlen) { unsigned remaininglen; unsigned endpos; assert(fragment); assert(out); if (!outlen) return; remaininglen = fragment->len - fragment->pos; if (remaininglen < outlen - 1U) { endpos = remaininglen; } else { endpos = outlen - 1U; } strncpy(out, &fragment->start[fragment->pos], endpos); out[endpos] = '\0'; } #define MAX_FRAG 1024 static char const * fragment_to_tempstr(RegisDataFragment const *fragment) { static char tempstr[MAX_FRAG]; assert(fragment); fragment_to_string(fragment, tempstr, MAX_FRAG); return tempstr; } static int skip_regis_whitespace(RegisDataFragment *input) { int skipped = 0; assert(input); while (!fragment_consumed(input)) { char ch = peek_fragment(input); if (ch != ',' && !IsSpace(ch)) { break; } if (ch == '\n') { TRACE(("end of input line\n\n")); } skipped = 1; pop_fragment(input); } if (skipped) return 1; return 0; } static int extract_regis_extent(RegisDataFragment *input, RegisDataFragment *output) { char ch; assert(input); assert(output); output->start = &input->start[input->pos]; output->len = 0U; output->pos = 0U; if (input->pos >= input->len) return 0; ch = input->start[input->pos]; if (ch != '[') return 0; input->pos++; output->start++; /* FIXME: truncate to 16 bit signed integers */ for (; input->pos < input->len; input->pos++, output->len++) { ch = input->start[input->pos]; if (ch == ';') { TRACE(("DATA_ERROR: end of input before closing bracket\n")); break; } if (ch == ']') break; } if (ch == ']') input->pos++; return 1; } static int extract_regis_num(RegisDataFragment *input, RegisDataFragment *output) { char ch = 0; int has_digits = 0; assert(input); assert(output); output->start = &input->start[input->pos]; output->len = 0U; output->pos = 0U; if (input->start[input->pos] == '-' || input->start[input->pos] == '+') { input->pos++; output->len++; } for (; input->pos < input->len; input->pos++, output->len++) { ch = input->start[input->pos]; if (ch != '0' && ch != '1' && ch != '2' && ch != '3' && ch != '4' && ch != '5' && ch != '6' && ch != '7' && ch != '8' && ch != '9') { break; } has_digits = 1; } /* FIXME: what degenerate forms should be accepted ("E10" "1E" "1e" "1." "1ee10")? */ /* FIXME: the terminal is said to support "floating point values", truncating to int... what do these look like? */ if (has_digits && ch == 'E') { input->pos++; output->len++; for (; input->pos < input->len; input->pos++, output->len++) { ch = input->start[input->pos]; if (ch != '0' && ch != '1' && ch != '2' && ch != '3' && ch != '4' && ch != '5' && ch != '6' && ch != '7' && ch != '8' && ch != '9') { break; } } } return has_digits; } static int extract_regis_pixelvector(RegisDataFragment *input, RegisDataFragment *output) { char ch; int has_digits; assert(input); assert(output); output->start = &input->start[input->pos]; output->len = 0U; output->pos = 0U; if (input->pos < input->len) { ch = input->start[input->pos]; if (ch == '+' || ch == '-') { input->pos++; output->len++; } } has_digits = 0; for (; input->pos < input->len; input->pos++, output->len++) { ch = input->start[input->pos]; if (ch != '0' && ch != '1' && ch != '2' && ch != '3' && ch != '4' && ch != '5' && ch != '6' && ch != '7') { break; } has_digits = 1; } return has_digits; } static int extract_regis_command(RegisDataFragment *input, char *command) { char ch; assert(input); assert(command); if (input->pos >= input->len) return 0; ch = input->start[input->pos]; if (ch == '\0' || ch == ';') { return 0; } if (!islower(CharOf(ch)) && !isupper(CharOf(ch)) && ch != '@') { return 0; } *command = ch; input->pos++; return 1; } static int extract_regis_string(RegisDataFragment *input, char *out, unsigned maxlen) { char open_quote_ch; char ch; unsigned outlen; assert(input); assert(out); assert(maxlen > 0U); if (input->pos >= input->len) return 0; ch = peek_fragment(input); if (ch != '\'' && ch != '"') return 0; open_quote_ch = ch; outlen = 0U; pop_fragment(input); ch = '\0'; while (!fragment_consumed(input)) { char prev_ch = ch; ch = peek_fragment(input); /* ';' (resync) and '@' (macrograph) are not recognized in strings */ if (prev_ch == open_quote_ch) { if (ch == open_quote_ch) { if (outlen < maxlen) { out[outlen] = ch; } outlen++; pop_fragment(input); ch = '\0'; continue; } if (outlen < maxlen) out[outlen] = '\0'; else out[maxlen] = '\0'; return 1; } if (ch == '\0') break; if (ch != open_quote_ch) { if (outlen < maxlen) out[outlen] = ch; outlen++; } pop_fragment(input); } if (ch == open_quote_ch) { pop_fragment(input); if (outlen < maxlen) out[outlen] = '\0'; else out[maxlen] = '\0'; return 1; } /* FIXME: handle multiple strings concatenated with commas */ TRACE(("DATA_ERROR: end of input before closing quote\n")); return 0; } static int extract_regis_parenthesized_data(RegisDataFragment *input, RegisDataFragment *output) { char ch; char open_quote_ch; int nesting; assert(input); assert(output); output->start = &input->start[input->pos]; output->len = 0U; output->pos = 0U; if (input->pos >= input->len) return 0; ch = input->start[input->pos]; if (ch != '(') return 0; input->pos++; output->start++; nesting = 1; open_quote_ch = '\0'; ch = '\0'; for (; input->pos < input->len; input->pos++, output->len++) { char prev_ch = ch; ch = input->start[input->pos]; if (ch == '\'' || ch == '"') { if (open_quote_ch == '\0') { open_quote_ch = ch; } else { if (ch == prev_ch && prev_ch == open_quote_ch) { ch = '\0'; } else if (ch == open_quote_ch) { open_quote_ch = '\0'; } } continue; } if (open_quote_ch != '\0') continue; if (ch == ';') { TRACE(("leaving parenthesized data nested %d levels deep due to command termination character\n", nesting)); break; } if (ch == '(') nesting++; if (ch == ')') { nesting--; if (nesting == 0) { input->pos++; return 1; } } } TRACE(("DATA_ERROR: end of input before closing paren (%d levels deep)\n", nesting)); return 0; } static int extract_regis_option(RegisDataFragment *input, char *option, RegisDataFragment *output) { char ch; int paren_level, bracket_level; char open_quote_ch; assert(input); assert(option); assert(output); /* LETTER suboptions* value? */ /* * FIXME: what are the rules for using separate parens vs. sharing between * options? */ output->start = &input->start[input->pos]; output->len = 0U; output->pos = 0U; if (input->pos >= input->len) { return 0; } ch = input->start[input->pos]; /* FIXME: are options always letters or are some special characters ok? */ if (ch == ';' || ch == ',' || ch == '(' || ch == ')' || ch == '[' || ch == ']' || ch == '"' || ch == '\'' || isdigit(CharOf(ch))) { return 0; } *option = ch; input->pos++; output->start++; paren_level = 0; bracket_level = 0; open_quote_ch = '\0'; for (; input->pos < input->len; input->pos++, output->len++) { ch = input->start[input->pos]; TRACE(("looking at char '%c' in option '%c'\n", ch, *option)); /* FIXME: any special rules for commas? */ /* FIXME: handle escaped quotes */ if (ch == '\'' || ch == '"') { if (open_quote_ch == ch) { open_quote_ch = '\0'; } else { open_quote_ch = ch; } continue; } if (open_quote_ch != '\0') continue; if (ch == '(') { paren_level++; } if (ch == ')') { paren_level--; if (paren_level < 0) { TRACE(("DATA_ERROR: found ReGIS option has value with too many close parens \"%c\"\n", *option)); return 0; } } if (ch == '[') { bracket_level++; } if (ch == ']') { bracket_level--; if (bracket_level < 0) { TRACE(("DATA_ERROR: found ReGIS option has value with too many close brackets \"%c\"\n", *option)); return 0; } } if (paren_level == 0 && bracket_level == 0) { /* * Top-level commas indicate the end of this option and the start of * another. */ if (ch == ',') break; /* * Top-level command/option/suboption names also indicate the end of * this option. "E" is valid as the exponent indicator in a numeric * parameter. */ if (ch != 'E' && ch != 'e' && ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z'))) break; } if (ch == ';') break; } if (paren_level != 0) { TRACE(("DATA_ERROR: mismatched parens in argument to ReGIS option \"%c\"\n", *option)); return 0; } if (bracket_level != 0) { TRACE(("DATA_ERROR: mismatched brackets in argument to ReGIS option \"%c\"\n", *option)); return 0; } TRACE(("found ReGIS option and value \"%c\" \"%s\"\n", *option, fragment_to_tempstr(output))); return 1; } static int regis_num_to_int(RegisDataFragment const *input, int *out) { char ch; assert(input); assert(out); /* FIXME: handle exponential notation and rounding */ /* FIXME: check for junk after the number */ ch = peek_fragment(input); if (ch != '0' && ch != '1' && ch != '2' && ch != '3' && ch != '4' && ch != '5' && ch != '6' && ch != '7' && ch != '8' && ch != '9' && ch != '+' && ch != '-') { return 0; } TRACE(("converting \"%s\" to an int\n", fragment_to_tempstr(input))); *out = atoi(fragment_to_tempstr(input)); return 1; } static int load_regis_colorspec(RegisGraphicsContext const *context, RegisDataFragment const *input, short *r_out, short *g_out, short *b_out) { RegisDataFragment colorspec; short r = -1, g = -1, b = -1; short l = -1; int simple; assert(context); assert(input); assert(r_out); assert(g_out); assert(b_out); copy_fragment(&colorspec, input); TRACE(("colorspec option: \"%s\"\n", fragment_to_tempstr(&colorspec))); skip_regis_whitespace(&colorspec); simple = 0; if (fragment_remaining(&colorspec) == 1U) { simple = 1; } else if (fragment_remaining(&colorspec) > 1U) { char after = get_fragment(&colorspec, 1U); if (IsSpace(after)) simple = 1; } if (simple) { char ch = pop_fragment(&colorspec); TRACE(("got ReGIS RGB colorspec pattern '%c' with arguments: \"%s\"\n", ch, fragment_to_tempstr(&colorspec))); switch (ch) { case 'D': case 'd': r = 0; g = 0; b = 0; l = 0; break; case 'R': case 'r': r = 100; g = 0; b = 0; l = 46; break; case 'G': case 'g': r = 0; g = 100; b = 0; l = 50; break; case 'B': case 'b': r = 0; g = 0; b = 100; l = 50; break; case 'C': case 'c': r = 0; g = 100; b = 100; l = 50; break; case 'Y': case 'y': r = 100; g = 100; b = 0; l = 50; break; case 'M': case 'm': r = 100; g = 0; b = 100; l = 50; break; case 'W': case 'w': r = 100; g = 100; b = 100; l = 100; break; default: TRACE(("DATA_ERROR: unknown RGB color name: \"%c\"\n", ch)); return 0; } } else { RegisDataFragment num; int max, val; char comp; short h = -1; short s = -1; while (!fragment_consumed(&colorspec)) { if (skip_regis_whitespace(&colorspec)) continue; comp = pop_fragment(&colorspec); switch (comp) { case ',': /* not sure if this is valid, but it is easy to handle */ continue; case 'H': case 'h': max = 360; comp = 'H'; break; case 'L': case 'l': max = 100; comp = 'L'; break; case 'S': case 's': max = 100; comp = 'S'; break; #ifdef ENABLE_RGB_COLORSPECS case 'R': /* RLogin extension */ case 'r': max = 100; comp = 'R'; break; case 'G': /* RLogin extension */ case 'g': max = 100; comp = 'G'; break; case 'B': /* RLogin extension */ case 'b': max = 100; comp = 'B'; break; #endif default: TRACE(("DATA_ERROR: unrecognized component in colorspec: '%c'\n", comp)); return 0; } skip_regis_whitespace(&colorspec); if (!extract_regis_num(&colorspec, &num)) { TRACE(("DATA_ERROR: expected int after '%c' component in colorspec: \"%s\"\n", comp, fragment_to_tempstr(&colorspec))); return 0; } if (!regis_num_to_int(&num, &val)) { TRACE(("DATA_ERROR: component value %s is not a number\n", fragment_to_tempstr(&num))); return 0; } /* FIXME: error, truncate, wrap, ...? */ if (val < 0 || val > max) { TRACE(("DATA_ERROR: component value %d out of range\n", val)); return 0; } switch (comp) { case 'H': h = (short) val; break; case 'L': l = (short) val; break; case 'S': s = (short) val; break; case 'R': r = (short) val; break; case 'G': g = (short) val; break; case 'B': b = (short) val; break; } } if (h >= 0 && l >= 0 && s >= 0 && r < 0 && g < 0 && b < 0) { TRACE(("found HLS colorspec to be converted: %hd,%hd,%hd\n", h, l, s)); hls2rgb(h, l, s, &r, &g, &b); TRACE(("converted to RGB: %hd,%hd,%hd\n", r, g, b)); } else if (h < 0 && l < 0 && s < 0 && r >= 0 && g >= 0 && b >= 0) { TRACE(("found RGB colorspec: %hd,%hd,%hd\n", r, g, b)); l = (short) ((MIN3(r, g, b) + MAX3(r, g, b)) / 2); TRACE(("calculated L: %d\n", l)); } else if (h < 0 && l >= 0 && s < 0 && r < 0 && g < 0 && b < 0) { TRACE(("found L colorspec to be converted: %hd,%hd,%hd\n", h, l, s)); hls2rgb(0, l, 0, &r, &g, &b); TRACE(("converted to RGB: %hd,%hd,%hd\n", r, g, b)); } else { TRACE(("DATA_ERROR: unrecognized colorspec format\n")); return 0; } } /* * The VT240 and VT330 models convert to the closest grayscale value. */ if (context->terminal_id == 240 || context->terminal_id == 330) { hls2rgb(0, l, 0, &r, &g, &b); TRACE(("converted to grayscale: %hd,%hd,%hd\n", r, g, b)); } *r_out = r; *g_out = g; *b_out = b; skip_regis_whitespace(&colorspec); if (!fragment_consumed(&colorspec)) { char skip; skip = pop_fragment(&colorspec); (void) skip; /* variable needed only if tracing */ TRACE(("DATA_ERROR: ignoring unexpected character in ReGIS colorspec \"%c\"\n", skip)); } return 1; } static int load_regis_regnum_or_colorspec(RegisGraphicsContext const *context, RegisDataFragment const *input, RegisterNum *out) { int val; RegisDataFragment colorspec; RegisDataFragment num; RegisDataFragment coloroption; copy_fragment(&colorspec, input); TRACE(("looking at colorspec pattern: \"%s\"\n", fragment_to_tempstr(&colorspec))); skip_regis_whitespace(&colorspec); if (extract_regis_num(&colorspec, &num)) { if (!regis_num_to_int(&num, &val)) { TRACE(("DATA_ERROR: colorspec value %s is not a valid register\n", fragment_to_tempstr(&num))); return 0; } if (val < 0) { /* FIXME: error, truncate, wrap, ...? */ TRACE(("DATA_ERROR: ignoring negative colorspec value: %d\n", val)); return 0; } if (val >= (int) context->destination_graphic->valid_registers) { /* FIXME: error, truncate, wrap, ...? */ TRACE(("DATA_ERROR: colorspec value %d is too big; wrapping\n", val)); val %= (int) context->destination_graphic->valid_registers; } TRACE(("colorspec contains index for register %u\n", val)); *out = (RegisterNum) val; skip_regis_whitespace(&colorspec); if (!fragment_consumed(&colorspec)) { char skip; skip = pop_fragment(&colorspec); (void) skip; /* variable needed only if tracing */ TRACE(("DATA_ERROR: unexpected character after register \"%c\"\n", skip)); return 0; } return 1; } if (extract_regis_parenthesized_data(&colorspec, &coloroption)) { short r, g, b; if (!load_regis_colorspec(context, &coloroption, &r, &g, &b)) { TRACE(("unable to parse colorspec\n")); return 0; } *out = find_color_register(context->destination_graphic->color_registers, r, g, b); TRACE(("colorspec maps to closest register %u\n", *out)); return 1; } TRACE(("expected register number or colorspec, but found: \"%s\"\n", fragment_to_tempstr(&colorspec))); return 0; } static int to_scaled_int(char const *num, int scale, int *value) { unsigned long whole, frac; char *end; /* FIXME: handle whitespace? how about trailing junk? */ whole = strtoul(num, &end, 10); if (end[0] == '.') { char temp[5] = "0000"; if (end[1] != '\0') { temp[0] = end[1]; if (end[2] != '\0') { temp[1] = end[2]; if (end[3] != '\0') { temp[2] = end[3]; if (end[4] != '\0') { temp[3] = end[4]; } } } } frac = strtoul(temp, NULL, 10); } else if (end[0] == '\0' || end[0] == ',' || IsSpace(end[0])) { frac = 0; } else { TRACE(("unexpected character %c in number %s\n", end[0], num)); return 0; } *value = (int) (whole * (unsigned) scale + (frac * (unsigned) scale) / 10000); return 1; } static int load_regis_raw_extent(char const *extent, int *relx, int *rely, int *xloc, int *yloc, int scale) { int xsign, ysign; char const *xpart; char const *ypart; xpart = extent; if ((ypart = strchr(extent, ','))) { ypart++; } else { ypart = ""; } while (IsSpace(xpart[0])) xpart++; while (IsSpace(ypart[0])) ypart++; if (xpart[0] == '-') { xsign = -1; xpart++; } else if (xpart[0] == '+') { xsign = +1; xpart++; } else { xsign = 0; } if (ypart[0] == '-') { ysign = -1; ypart++; } else if (ypart[0] == '+') { ysign = +1; ypart++; } else { ysign = 0; } if (xpart[0] == '\0' || xpart[0] == ',') { *relx = 1; *xloc = 0; } else if (xsign == 0) { int val; if (!to_scaled_int(xpart, scale, &val)) return 0; *relx = 0; *xloc = val; } else { int val; if (!to_scaled_int(xpart, scale, &val)) return 0; *relx = 1; *xloc = xsign * val; } if (ypart[0] == '\0') { *rely = 1; *yloc = 0; } else if (ysign == 0) { int val; if (!to_scaled_int(ypart, scale, &val)) return 0; *rely = 0; *yloc = val; } else { int val; if (!to_scaled_int(ypart, scale, &val)) return 0; *rely = 1; *yloc = ysign * val; } return 1; } static int load_regis_mult_extent(char const *extent, int *w, int *h) { int relx, rely; int px, py; if (!load_regis_raw_extent(extent, &relx, &rely, &px, &py, 1)) { TRACE(("invalid coordinates in extent %s\n", extent)); return 0; } if (relx | rely) { TRACE(("invalid relative value in multiplier extent %s\n", extent)); return 0; } *w = px; *h = py; return 1; } static int load_regis_pixel_extent(char const *extent, int origx, int origy, int *xloc, int *yloc) { int relx, rely; int px, py; if (!load_regis_raw_extent(extent, &relx, &rely, &px, &py, 1)) { TRACE(("invalid coordinates in extent %s\n", extent)); return 0; } *xloc = px; *yloc = py; if (relx) *xloc += origx; if (rely) *yloc += origy; return 1; } #define COORD_SCALE 1000 static int load_regis_coord_extent(RegisGraphicsContext const *context, char const *extent, int origx, int origy, int *xloc, int *yloc) { int relx, rely; int ux, uy; if (!load_regis_raw_extent(extent, &relx, &rely, &ux, &uy, COORD_SCALE)) { TRACE(("invalid coordinates in extent %s\n", extent)); return 0; } if (relx) { const int px = SCALE_XCOORD(context, ux, COORD_SCALE); TRACE(("converted relative user X coord %.03f to relative pixel X coord %d (width=%d xoff=%d xdiv=%d)\n", ux / (double) COORD_SCALE, px, context->width, context->x_off, context->x_div)); *xloc = origx + px; } else { const int px = TRANSLATE_XCOORD(context, ux, COORD_SCALE); TRACE(("converted absolute user X coord %.03f to absolute pixel X coord %d\n", ux / (double) COORD_SCALE, px)); *xloc = px; } if (rely) { const int py = SCALE_YCOORD(context, uy, COORD_SCALE); TRACE(("converted relative user Y coord %.03f to relative pixel Y coord %d (height=%d yoff=%d ydiv=%d)\n", uy / (double) COORD_SCALE, py, context->height, context->y_off, context->y_div)); *yloc = origy + py; } else { const int py = TRANSLATE_YCOORD(context, uy, COORD_SCALE); TRACE(("converted absolute user Y coord %.03f to absolute pixel Y coord %d\n", uy / (double) COORD_SCALE, py)); *yloc = py; } return 1; } static int load_regis_raw_pixelvector_digit(char const *pixelvector, unsigned *offset, int *dx, int *dy, int mul) { switch (pixelvector[*offset]) { case '0': *dx += mul; break; case '1': *dx += mul; *dy -= mul; break; case '2': *dy -= mul; break; case '3': *dx -= mul; *dy -= mul; break; case '4': *dx -= mul; break; case '5': *dx -= mul; *dy += mul; break; case '6': *dy += mul; break; case '7': *dx += mul; *dy += mul; break; default: return 0; } (*offset)++; return 1; } static int load_regis_pixel_pixelvector(char const *pixelvector, int mul, int origx, int origy, int *xloc, int *yloc) { int found = 0; int px = 0, py = 0; unsigned offset = 0U; while (load_regis_raw_pixelvector_digit(pixelvector, &offset, &px, &py, mul)) found = 1; if (pixelvector[offset] != '\0') { TRACE(("DATA_ERROR: ignoring unknown pixel vector digits: \"%s\"\n", &pixelvector[offset])); } *xloc = origx + px; *yloc = origy + py; return found; } static int load_regis_coord_pixelvector(RegisGraphicsContext const *context, char const *pixelvector, int origx, int origy, int *xloc, int *yloc) { const int mul = (int) (context->temporary_write_controls.pv_multiplier * COORD_SCALE); int found = 0; int ux = 0, uy = 0; unsigned offset = 0U; while (load_regis_raw_pixelvector_digit(pixelvector, &offset, &ux, &uy, mul)) found = 1; if (pixelvector[offset] != '\0') { TRACE(("DATA_ERROR: ignoring unknown pixel vector digits: \"%s\"\n", &pixelvector[offset])); } { const int px = SCALE_XCOORD(context, ux, COORD_SCALE); const int py = SCALE_YCOORD(context, uy, COORD_SCALE); TRACE(("converted relative X coord %.03f to relative pixel X coord %d (width=%d xoff=%d xdiv=%d)\n", ux / (double) COORD_SCALE, px, context->width, context->x_off, context->x_div)); *xloc = origx + px; TRACE(("converted relative Y coord %.03f to relative pixel Y coord %d (height=%d yoff=%d ydiv=%d)\n", uy / (double) COORD_SCALE, py, context->height, context->y_off, context->y_div)); *yloc = origy + py; } return found; } static int load_regis_coord_pixelvector_step(RegisGraphicsContext const *context, char const *pixelvector, unsigned *offset, int origx, int origy, int *xloc, int *yloc) { const int mul = (int) (context->temporary_write_controls.pv_multiplier * COORD_SCALE); int found = 0; int ux = 0, uy = 0; if (load_regis_raw_pixelvector_digit(pixelvector, offset, &ux, &uy, mul)) found = 1; if (!found && pixelvector[*offset] != '\0') { TRACE(("DATA_ERROR: ignoring unknown pixel vector digits: \"%s\"\n", &pixelvector[*offset])); } { const int px = SCALE_XCOORD(context, ux, COORD_SCALE); const int py = SCALE_YCOORD(context, uy, COORD_SCALE); TRACE(("converted relative X coord %.03f to relative pixel X coord %d (width=%d xoff=%d xdiv=%d)\n", ux / (double) COORD_SCALE, px, context->width, context->x_off, context->x_div)); *xloc = origx + px; TRACE(("converted relative Y coord %.03f to relative pixel Y coord %d (height=%d yoff=%d ydiv=%d)\n", uy / (double) COORD_SCALE, py, context->height, context->y_off, context->y_div)); *yloc = origy + py; } return found; } static int load_regis_write_control(RegisParseState *state, RegisGraphicsContext const *context, int cur_x, int cur_y, int option, RegisDataFragment *arg, RegisWriteControls *out) { TRACE(("checking write control option \"%c\" with arg \"%s\"\n", option, fragment_to_tempstr(arg))); switch (option) { case 'A': case 'a': TRACE(("write control alternate display method \"%s\"\n", fragment_to_tempstr(arg))); { int val; if (!regis_num_to_int(arg, &val) || val < 0 || val >= 1) { TRACE(("DATA_ERROR: interpreting out of range value as 0 FIXME\n")); break; } if (val == 1) { TRACE(("ERROR: blink display method not supported FIXME\n")); } } break; case 'C': case 'c': TRACE(("write control compliment writing mode \"%s\"\n", fragment_to_tempstr(arg))); out->write_style = WRITE_STYLE_COMPLEMENT; break; case 'E': case 'e': TRACE(("write control erase writing mode \"%s\"\n", fragment_to_tempstr(arg))); out->write_style = WRITE_STYLE_ERASE; break; case 'F': case 'f': TRACE(("write control plane write mask \"%s\"\n", fragment_to_tempstr(arg))); { int val; if (!regis_num_to_int(arg, &val) || val < 0 || val >= (int) context->destination_graphic->valid_registers) { TRACE(("DATA_ERROR: interpreting out of range value as 0 FIXME\n")); out->plane_mask = 0U; } else { out->plane_mask = (unsigned) val; } } break; case 'I': case 'i': TRACE(("write control foreground color \"%s\"\n", fragment_to_tempstr(arg))); if (!load_regis_regnum_or_colorspec(context, arg, &out->foreground)) { TRACE(("DATA_ERROR: write control foreground color specifier not recognized: \"%s\"\n", fragment_to_tempstr(arg))); return 0; } break; case 'L': case 'l': TRACE(("write control line width \"%s\" (FIXME: currently ignored)\n", fragment_to_tempstr(arg))); { int val; if (!regis_num_to_int(arg, &val) || val < 0 || val >= (int) 9) { TRACE(("interpreting out of range value as 1 FIXME\n")); out->line_width = 1U; } else { out->line_width = (unsigned) val; } } break; case 'M': case 'm': TRACE(("write control found pixel multiplication factor \"%s\"\n", fragment_to_tempstr(arg))); { int val; if (!regis_num_to_int(arg, &val) || val <= 0) { TRACE(("interpreting out of range value %d as 1 FIXME\n", val)); out->pv_multiplier = 1U; } else { out->pv_multiplier = (unsigned) val; } } break; case 'N': case 'n': TRACE(("write control negative pattern control \"%s\"\n", fragment_to_tempstr(arg))); { int val; if (!regis_num_to_int(arg, &val)) { val = -1; } switch (val) { default: TRACE(("interpreting out of range value %d as 0 FIXME\n", val)); out->invert_pattern = 0U; break; case 0: out->invert_pattern = 0U; break; case 1: out->invert_pattern = 1U; break; } } break; case 'P': case 'p': TRACE(("write control found pattern control \"%s\"\n", fragment_to_tempstr(arg))); { RegisDataFragment suboptionset; RegisDataFragment suboptionarg; RegisDataFragment item; char suboption; while (!fragment_consumed(arg)) { if (skip_regis_whitespace(arg)) continue; TRACE(("looking for option in \"%s\"\n", fragment_to_tempstr(arg))); if (extract_regis_parenthesized_data(arg, &suboptionset)) { TRACE(("got write pattern suboptionset: \"%s\"\n", fragment_to_tempstr(&suboptionset))); while (!fragment_consumed(&suboptionset)) { skip_regis_whitespace(&suboptionset); if (extract_regis_option(&suboptionset, &suboption, &suboptionarg)) { skip_regis_whitespace(&suboptionarg); TRACE(("inspecting write pattern suboption \"%c\" with value \"%s\"\n", suboption, fragment_to_tempstr(&suboptionarg))); switch (suboption) { case 'M': case 'm': TRACE(("found pattern multiplier \"%s\"\n", fragment_to_tempstr(&suboptionarg))); { RegisDataFragment num; int val; if (extract_regis_num(&suboptionarg, &num)) { if (!regis_num_to_int(&num, &val) || val < 1) { TRACE(("interpreting out of range pattern multiplier \"%s\" as 2 FIXME\n", fragment_to_tempstr(&num))); out->pattern_multiplier = 2U; } else { out->pattern_multiplier = (unsigned) val; } skip_regis_whitespace(&suboptionarg); } if (!fragment_consumed(&suboptionarg)) { TRACE(("DATA_ERROR: unknown content after pattern multiplier \"%s\"\n", fragment_to_tempstr(&suboptionarg))); return 0; } } break; default: TRACE(("DATA_ERROR: unknown ReGIS write pattern suboption '%c' arg \"%s\"\n", suboption, fragment_to_tempstr(&suboptionarg))); return 0; } continue; } TRACE(("DATA_ERROR: skipping unknown token in pattern control suboptionset (expecting option): \"%s\"\n", fragment_to_tempstr(&suboptionset))); pop_fragment(&suboptionset); } continue; } TRACE(("looking for int in \"%s\"\n", fragment_to_tempstr(arg))); if (extract_regis_num(arg, &item)) { if (peek_fragment(&item) == '0' || peek_fragment(&item) == '1') { unsigned pattern = 0U; unsigned bitcount; TRACE(("converting pattern bits \"%s\"\n", fragment_to_tempstr(&item))); for (bitcount = 0;; bitcount++) { char ch = pop_fragment(&item); if (ch == '\0') break; switch (ch) { case '0': if (bitcount < MAX_PATTERN_BITS) { pattern <<= 1U; } break; case '1': if (bitcount < MAX_PATTERN_BITS) { pattern <<= 1U; pattern |= 1U; } break; default: TRACE(("DATA_ERROR: unknown ReGIS write pattern bit value \"%c\"\n", ch)); return 0; } } if (bitcount > 0U) { unsigned extrabits; for (extrabits = 0; bitcount + extrabits < MAX_PATTERN_BITS; extrabits++) { if (pattern & (1U << (bitcount - 1U))) { pattern <<= 1U; pattern |= 1U; } else { pattern <<= 1U; } } } out->pattern = pattern; } else { int val; TRACE(("converting pattern id \"%s\"\n", fragment_to_tempstr(&item))); if (!regis_num_to_int(&item, &val)) val = -1; switch (val) { /* FIXME: exponential allowed? */ case 0: out->pattern = 0x00; /* solid bg */ break; case 1: out->pattern = 0xff; /* solid fg */ break; case 2: out->pattern = 0xf0; /* dash */ break; case 3: out->pattern = 0xe4; /* dash dot */ break; case 4: out->pattern = 0xaa; /* dot */ break; case 5: out->pattern = 0xea; /* dash dot dot */ break; case 6: out->pattern = 0x88; /* sparse dot */ break; case 7: out->pattern = 0x84; /* asymmetric sparse dot */ break; case 8: out->pattern = 0xc8; /* sparse dash dot */ break; case 9: out->pattern = 0x86; /* sparse dot dash */ break; default: TRACE(("DATA_ERROR: unknown ReGIS standard write pattern \"%d\"\n", val)); return 0; } } TRACE(("final pattern is %02x\n", out->pattern)); continue; } skip_regis_whitespace(arg); TRACE(("DATA_ERROR: skipping unknown token in pattern suboption: \"%s\"\n", fragment_to_tempstr(arg))); pop_fragment(arg); } } break; case 'R': case 'r': TRACE(("write control switch to replacement writing mode \"%s\"\n", fragment_to_tempstr(arg))); out->write_style = WRITE_STYLE_REPLACE; break; case 'S': case 's': TRACE(("write control shading control \"%s\"\n", fragment_to_tempstr(arg))); { RegisDataFragment suboptionset; RegisDataFragment suboptionarg; RegisDataFragment item; char suboption; char shading_character = '\0'; unsigned reference_dim = WRITE_SHADING_REF_Y; /* FIXME: are relative offsets additive? */ int ref_x = cur_x, ref_y = cur_y; int shading_enabled = 0; while (!fragment_consumed(arg)) { if (skip_regis_whitespace(arg)) continue; if (extract_regis_string(arg, state->temp, state->templen)) { TRACE(("found fill char \"%s\"\n", state->temp)); /* FIXME: allow longer strings, ignore extra chars, or treat as error? */ if (strlen(state->temp) != 1) { TRACE(("DATA_ERROR: expected exactly one char in fill string FIXME\n")); return 0; } shading_character = state->temp[0]; shading_enabled = 1; TRACE(("shading character is: '%c' (%d)\n", shading_character, (int) shading_character)); continue; } if (extract_regis_parenthesized_data(arg, &suboptionset)) { skip_regis_whitespace(&suboptionset); TRACE(("got shading control suboptionset: \"%s\"\n", fragment_to_tempstr(&suboptionset))); while (!fragment_consumed(&suboptionset)) { if (skip_regis_whitespace(&suboptionset)) continue; if (extract_regis_option(&suboptionset, &suboption, &suboptionarg)) { TRACE(("inspecting write shading suboption \"%c\" with value \"%s\"\n", suboption, fragment_to_tempstr(&suboptionarg))); switch (suboption) { case 'X': case 'x': TRACE(("found horizontal shading suboption \"%s\"\n", fragment_to_tempstr(&suboptionarg))); if (!fragment_consumed(&suboptionarg)) { TRACE(("DATA_ERROR: unexpected value to horizontal shading suboption FIXME\n")); return 0; } reference_dim = WRITE_SHADING_REF_X; shading_enabled = 1; break; default: TRACE(("DATA_ERROR: unknown ReGIS write pattern suboption '%c' arg \"%s\"\n", suboption, fragment_to_tempstr(&suboptionarg))); return 0; } continue; } TRACE(("DATA_ERROR: skipping unknown token in shading control suboptionset (expecting option): \"%s\"\n", fragment_to_tempstr(&suboptionset))); pop_fragment(&suboptionset); } continue; } if (extract_regis_extent(arg, &item)) { TRACE(("found extent in shading option curr=%d,%d ref=%d,%d\n", cur_x, cur_y, ref_x, ref_y)); if (!load_regis_coord_extent(context, fragment_to_tempstr(&item), ref_x, ref_y, &ref_x, &ref_y)) { TRACE(("DATA_ERROR: unable to parse extent in write shading option '%c': \"%s\"\n", option, fragment_to_tempstr(&item))); return 0; } TRACE(("shading reference = %d,%d (%s)\n", ref_x, ref_y, ((reference_dim == WRITE_SHADING_REF_X) ? "X" : "Y"))); continue; } if (extract_regis_num(arg, &item)) { if (!regis_num_to_int(&item, &shading_enabled)) { TRACE(("DATA_ERROR: unable to parse int in write shading option '%c': \"%s\"\n", option, fragment_to_tempstr(&item))); return 0; } if (shading_enabled < 0 || shading_enabled > 1) { TRACE(("interpreting out of range value %d as 0 FIXME\n", shading_enabled)); shading_enabled = 0; } TRACE(("shading enabled = %d\n", shading_enabled)); continue; } if (skip_regis_whitespace(arg)) { continue; } TRACE(("DATA_ERROR: skipping unknown token in shade suboption: \"%s\"\n", fragment_to_tempstr(arg))); pop_fragment(arg); } if (shading_enabled) { out->shading_enabled = 1U; out->shading_reference_dim = reference_dim; out->shading_reference = ((reference_dim == WRITE_SHADING_REF_X) ? ref_x : ref_y); out->shading_character = shading_character; TRACE(("final shading state: enabled, dim=%d ref=%d, char=%c\n", out->shading_reference_dim, out->shading_reference, out->shading_character)); } else { /* FIXME: confirm there is no effect if shading isn't enabled * in the same command */ out->shading_enabled = 0U; TRACE(("final shading state: shading disabled\n")); } } break; case 'V': case 'v': TRACE(("write control switch to overlay writing mode \"%s\"\n", fragment_to_tempstr(arg))); out->write_style = WRITE_STYLE_OVERLAY; break; default: TRACE(("DATA_ERROR: ignoring unknown ReGIS write option \"%c\" arg \"%s\"\n", option, fragment_to_tempstr(arg))); return 0; } return 1; } static int load_regis_write_control_set(RegisParseState *state, RegisGraphicsContext const *context, int cur_x, int cur_y, RegisDataFragment *controls, RegisWriteControls *out) { RegisDataFragment optionset; RegisDataFragment arg; char option; while (!fragment_consumed(controls)) { if (skip_regis_whitespace(controls)) continue; if (extract_regis_parenthesized_data(controls, &optionset)) { TRACE(("got write control optionset: \"%s\"\n", fragment_to_tempstr(&optionset))); while (!fragment_consumed(&optionset)) { skip_regis_whitespace(&optionset); if (extract_regis_option(&optionset, &option, &arg)) { skip_regis_whitespace(&arg); TRACE(("got write control option and value: \"%c\" \"%s\"\n", option, fragment_to_tempstr(&arg))); if (!load_regis_write_control(state, context, cur_x, cur_y, option, &arg, out)) { return 0; } continue; } TRACE(("DATA_ERROR: skipping unknown token in write control optionset (expecting option): \"%s\"\n", fragment_to_tempstr(&optionset))); pop_fragment(&optionset); } continue; } TRACE(("DATA_ERROR: skipping unknown token in write controls (expecting optionset): \"%s\"\n", fragment_to_tempstr(controls))); pop_fragment(controls); } return 1; } static void init_regis_write_controls(int terminal_id, unsigned all_planes, RegisWriteControls *controls) { controls->pv_multiplier = 1U; controls->pattern = 0xff; /* solid */ controls->pattern_multiplier = 2U; controls->invert_pattern = 0U; controls->plane_mask = all_planes; controls->write_style = WRITE_STYLE_OVERLAY; switch (terminal_id) { case 125: /* FIXME: verify */ case 240: /* FIXME: verify */ case 241: /* FIXME: verify */ case 330: controls->foreground = 3U; break; case 340: default: controls->foreground = 7U; break; case 382: controls->foreground = 1U; /* FIXME: verify */ break; } controls->shading_enabled = 0U; controls->shading_character = '\0'; controls->shading_reference = 0; /* no meaning if shading is disabled */ controls->shading_reference_dim = WRITE_SHADING_REF_NONE; controls->line_width = 1U; /* FIXME: add the rest */ } static void map_regis_graphics_pages(XtermWidget xw, RegisGraphicsContext *context) { const int charrow = 0; const int charcol = 0; unsigned old_display_id = ~0U; if (context->destination_graphic) context->destination_graphic->hidden = 1; if (context->display_graphic) { context->display_graphic->hidden = 1; old_display_id = context->display_graphic->id; } context->destination_graphic = get_new_or_matching_graphic(xw, charrow, charcol, context->width, context->height, context->destination_page); if (context->destination_graphic) { context->destination_graphic->hidden = 1; context->destination_graphic->valid = 1; } context->display_graphic = get_new_or_matching_graphic(xw, charrow, charcol, context->width, context->height, context->display_page); if (context->display_graphic) { context->display_graphic->hidden = 0; if (old_display_id != context->display_graphic->id) { if (!context->display_graphic->valid) { draw_solid_rectangle(context->display_graphic, 0, 0, context->width, context->height, context->background); } context->display_graphic->dirty = 1; context->force_refresh = 1; /* FIXME: This isn't really enough. If there are holes in the new * graphic they should be cleared and set to the text from the same * page. But we don't have pages for text in xterm (the alt buffer * is similar though). */ } context->display_graphic->valid = 1; } TRACE(("using graphics destination=[%d -> %u] display=[%d -> %u]\n", context->destination_page, (context->destination_graphic ? context->destination_graphic->id : 0U), context->display_page, (context->display_graphic ? context->display_graphic->id : 0U))); } static void copy_regis_write_controls(RegisWriteControls const *src, RegisWriteControls *dst) { dst->pv_multiplier = src->pv_multiplier; dst->pattern = src->pattern; dst->pattern_multiplier = src->pattern_multiplier; dst->invert_pattern = src->invert_pattern; dst->foreground = src->foreground; dst->plane_mask = src->plane_mask; dst->write_style = src->write_style; dst->shading_enabled = src->shading_enabled; dst->shading_character = src->shading_character; dst->shading_reference = src->shading_reference; dst->shading_reference_dim = src->shading_reference_dim; dst->line_width = src->line_width; } static void init_regis_text_controls(RegisTextControls *controls) { controls->alphabet_num = 0U; /* built-in */ controls->character_set_l = 0U; /* ASCII */ controls->character_set_r = 0U; /* Latin-1 */ get_standard_character_size(1, &controls->character_display_w, &controls->character_display_h, &controls->character_unit_cell_w, &controls->character_unit_cell_h, &controls->character_inc_x, &controls->character_inc_y); controls->string_rotation = 0; controls->character_rotation = 0; controls->slant = 0; } static void copy_regis_text_controls(RegisTextControls const *src, RegisTextControls *dst) { dst->alphabet_num = src->alphabet_num; dst->character_set_l = src->character_set_l; dst->character_set_r = src->character_set_r; dst->character_display_w = src->character_display_w; dst->character_display_h = src->character_display_h; dst->character_unit_cell_w = src->character_unit_cell_w; dst->character_unit_cell_h = src->character_unit_cell_h; dst->character_inc_x = src->character_inc_x; dst->character_inc_y = src->character_inc_y; dst->string_rotation = src->string_rotation; dst->character_rotation = src->character_rotation; dst->slant = src->slant; } static void init_regis_alphabets(RegisGraphicsContext *context) { unsigned alphabet_index; for (alphabet_index = 0U; alphabet_index < MAX_REGIS_ALPHABETS; alphabet_index++) { context->alphabets[alphabet_index].alphabet_num = INVALID_ALPHABET_NUM; context->alphabets[alphabet_index].pixw = 0U; context->alphabets[alphabet_index].pixh = 0U; context->alphabets[alphabet_index].name[0] = '\0'; context->alphabets[alphabet_index].fontname[0] = '\0'; context->alphabets[alphabet_index].use_font = 0; context->alphabets[alphabet_index].bytes = NULL; } } static void init_regis_graphics_context(int terminal_id, int width, int height, unsigned max_colors, const char *builtin_font, RegisGraphicsContext *context) { context->destination_graphic = NULL; context->display_graphic = NULL; context->display_page = 0U; context->destination_page = 0U; context->terminal_id = terminal_id; /* reset addressing / clear user coordinates */ context->width = width; context->height = height; context->x_off = 0; context->y_off = 0; context->x_div = width - 1; context->y_div = height - 1; /* * Generate a mask covering all valid color register address bits * (but don't bother past 2**16). */ context->all_planes = max_colors; context->all_planes--; context->all_planes |= 1U; context->all_planes |= context->all_planes >> 1U; context->all_planes |= context->all_planes >> 2U; context->all_planes |= context->all_planes >> 4U; context->all_planes |= context->all_planes >> 8U; context->builtin_font = builtin_font; init_regis_write_controls(terminal_id, context->all_planes, &context->persistent_write_controls); copy_regis_write_controls(&context->persistent_write_controls, &context->temporary_write_controls); init_regis_text_controls(&context->persistent_text_controls); context->current_text_controls = &context->persistent_text_controls; init_regis_alphabets(context); context->multi_input_mode = 0; /* FIXME: coordinates */ /* FIXME: scrolling */ context->background = 0U; /* FIXME: input cursor location */ /* FIXME: input cursor style */ context->graphics_output_cursor_x = 0; context->graphics_output_cursor_y = 0; /* FIXME: output cursor style */ context->force_refresh = 0; } static int parse_regis_command(RegisParseState *state) { char ch; if (!extract_regis_command(&state->input, &ch)) return 0; switch (ch) { case 'C': case 'c': /* Curve * C * (A) # set the arc length in degrees (+ or nothing for * # counter-clockwise, - for clockwise, rounded to the * # closest integer degree) * (B) # begin closed curve sequence (must have at least two * # values; this option can not be nested) * (C) # position is the center, current location is the * # circumference (stays in effect until next command) * (E) # end curve sequence (drawing is performed here) * (S) # begin open curve sequence * (W) # temporary write options (see write command) * [] # center if (C), otherwise point on circumference * []... # if between (B) and (E) * ... # if between (B) and (E) */ TRACE(("found ReGIS command \"%c\" (curve)\n", ch)); state->command = 'c'; state->curve_mode = CURVE_POSITION_ARC_EDGE; state->arclen = 360; state->num_points = 0U; break; case 'F': case 'f': /* Fill * F * (V) # polygon (see vector command) * (C) # curve (see curve command) * (W) # temporary write options (see write command) */ TRACE(("found ReGIS command \"%c\" (filled polygon)\n", ch)); state->command = 'f'; break; case 'L': case 'l': /* Load * L * (A) # set alphabet number or name * (F)"fontname" # load from font (xterm extension) * (S)[w,h] # set glyph size (xterm extension) * "ascii"xx,xx,xx,xx,xx,xx,xx,xx # pixel values */ TRACE(("found ReGIS command \"%c\" (load charset)\n", ch)); state->command = 'l'; break; case 'P': case 'p': /* Position * P * (B) # begin bounded position stack (last point returns to first) * (E) # end position stack * (P) # select graphics page for the input and output cursors * (S) # begin unbounded position stack * (W) # temporary write options (see write command) * # move: 0 == right, 1 == upper right, ..., 7 == lower right * [] # move to position (X, Y, or both) * * Note the stack does not need to be ended before the next command * Note: maximum depth is 16 levels */ TRACE(("found ReGIS command \"%c\" (position)\n", ch)); state->command = 'p'; break; case 'R': case 'r': /* Report * R * (E) # parse error * (I) # set input mode (0 == one-shot, 1 == multiple) (always returns CR) * (L) # current alphabet number and name * (M() # macrograph contents * (M(=) # macrograph storage (free bytes of total bytes) * (P) # absolute output cursor position * (P(I)) # interactive locator mode (in one-shot or multiple mode) * (P(I[xmul,ymul])) # interactive locator mode with arrow key movement multiplers */ TRACE(("found ReGIS command \"%c\" (report status)\n", ch)); state->command = 'r'; break; case 'S': case 's': /* Screen * S * (A[][]) # adjust screen cordinates * (C # 0 (cursor output off), 1 (cursor output on) * (E) # erase to background color, resets shades, curves, and stacks * (F) # print the graphic and erase the screen (DECprint extension) * (H(P)[][) * (I) # set the background to a specific register * (I()) # set the background to the register closest to an "RGB" color * (I(RGB)) # set the background to the register closest to an RGB triplet (RLogin extension) * (I(HLS)) # set the background to the register closest to an HLS triplet * (I(L)) # set the background to the register closest to a grayscale value * (M()...) # codes are D (black), R (red), G (green), B (blue), C (cyan), Y (yellow), M (magenta), W (white) (sets color and grayscale registers) * (M(A)...) # codes are D (black), R (red), G (green), B (blue), C (cyan), Y (yellow), M (magenta), W (white) (sets color registers only) * (M(RGB)...) # 0..100, 0..100, 0..100 (sets color and grayscale registers) (RLogin extension) * (M(ARGB)...) # 0..100, 0..100, 0..100 (sets color registers only) (RLogin extension) * (M(HLS)...) # 0..360, 0..100, 0..100 (sets color and grayscale registers) * (M(AHLS)...) # 0..360, 0..100, 0..100 (sets color registers only) * (M(L)...) # level is 0 ... 100 (sets grayscale registers only) * (P) # 0 (default) or 1 * (S() # scale screen output by scale (default 1, VT125:max=2, VT3x0:unsupported) FIXME * (S(X) # scale screen output horizontally by scale (default 1, VT125:max=2, VT3x0:unsupported) FIXME * (S(Y) # scale screen output vertically by scale (default 1, VT125:max=2, VT3x0:unsupported) FIXME * (T(