diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2007-06-15 19:30:51 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2007-06-15 19:30:51 +0000 |
commit | f926630b59156fe2b8c19697a65ac67b09dd0ee7 (patch) | |
tree | a4fbcc7a17e8e403ed485bb5aba58cabc1fe8b25 /app | |
parent | d6c3cc17b5fdbf6ddcfb35e84b41e17225d0d9d7 (diff) |
import xterm 225
Diffstat (limited to 'app')
-rw-r--r-- | app/xterm/cachedGCs.c | 805 | ||||
-rw-r--r-- | app/xterm/config.guess | 16 | ||||
-rw-r--r-- | app/xterm/config.sub | 21 | ||||
-rw-r--r-- | app/xterm/precompose.c | 48 | ||||
-rw-r--r-- | app/xterm/run-tic.sh | 25 | ||||
-rw-r--r-- | app/xterm/unicode/make-precompose.sh | 18 | ||||
-rw-r--r-- | app/xterm/unicode/precompose.c.tail | 7 | ||||
-rw-r--r-- | app/xterm/vttests/dynamic2.sh | 85 | ||||
-rw-r--r-- | app/xterm/xtermcap.c | 338 | ||||
-rw-r--r-- | app/xterm/xtermcap.h | 86 |
10 files changed, 1418 insertions, 31 deletions
diff --git a/app/xterm/cachedGCs.c b/app/xterm/cachedGCs.c new file mode 100644 index 000000000..ca699fb83 --- /dev/null +++ b/app/xterm/cachedGCs.c @@ -0,0 +1,805 @@ +/* $XTermId: cachedGCs.c,v 1.35 2007/03/21 23:21:50 tom Exp $ */ + +/************************************************************ + +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. + +********************************************************/ + +#include <data.h> +#include <xstrings.h> + +#include <X11/Xmu/Drawing.h> + +#include <stdio.h> + +/* + * 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; + XFontStruct *font; + Pixel tile; + Pixel fg; + Pixel bg; +} CgsCacheData; + +#define DEPTH 8 +#define ITEM() (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 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 String +traceCgsEnum(CgsEnum value) +{ + String 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 String +traceVTwin(XtermWidget xw, VTwin * value) +{ + String result = "?"; + if (value == 0) + result = "null"; + else if (value == &(xw->screen.fullVwin)) + result = "fullVwin"; +#ifndef NO_ACTIVE_ICON + else if (value == &(xw->screen.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(XFontStruct * font) +{ + static char result[80]; + if (font != 0) { + sprintf(result, "%p(%dx%d %d %#lx)", + font, + font->max_bounds.width, + font->max_bounds.ascent + font->max_bounds.descent, + font->max_bounds.descent, + (unsigned long) (font->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 = &(xw->screen); + 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 */ + +/* + * FIXME: move the cache into XtermWidget + */ +static CgsCache * +myCache(XtermWidget xw GCC_UNUSED, VTwin * cgsWin GCC_UNUSED, CgsEnum cgsId) +{ + static CgsCache *main_cache; + CgsCache *my_cache; + CgsCache *result = 0; + + if (main_cache == 0) + main_cache = (CgsCache *) calloc(gcMAX, sizeof(CgsCache)); + my_cache = main_cache; + if ((int) cgsId >= 0 && cgsId < gcMAX) { +#ifndef NO_ACTIVE_ICON + static CgsCache icon_cache[gcMAX]; + if (cgsWin == &(xw->screen.iconVwin)) + my_cache = icon_cache; +#endif + result = my_cache + cgsId; + if (result->data == 0) { + result->data = result->list; + } + } + + return result; +} + +static Display * +myDisplay(XtermWidget xw) +{ + return xw->screen.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)->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), THIS(gc), ITEM())); + + THIS(used) = 0; + return THIS(gc); +} + +static GC +chgCache(XtermWidget xw, CgsEnum cgsId GCC_UNUSED, CgsCache * me) +{ + XGCValues xgcv; + XtGCMask mask = (GCForeground | GCBackground | GCFont); + + memset(&xgcv, 0, sizeof(xgcv)); + + TRACE2(("...Cgs old data fg=%s, bg=%s, font=%s cset %s\n", + tracePixel(xw, THIS(fg)), + tracePixel(xw, THIS(bg)), + traceFont(THIS(font)), + traceCSet(THIS(cset)))); + + THIS(font) = NEXT(font); + THIS(cset) = NEXT(cset); + THIS(fg) = NEXT(fg); + THIS(bg) = NEXT(bg); + + xgcv.font = THIS(font)->fid; + xgcv.foreground = THIS(fg); + xgcv.background = THIS(bg); + + XChangeGC(myDisplay(xw), THIS(gc), mask, &xgcv); + TRACE(("getCgsGC(%s) updated gc %p(%d)\n", + traceCgsEnum(cgsId), THIS(gc), ITEM())); + + THIS(used) = 0; + return THIS(gc); +} + +static Boolean +SameFont(XFontStruct * a, XFontStruct * b) +{ + return ((a != 0) && (b != 0) && (a == b) && !memcmp(a, b, sizeof(*a))); +} + +#define SameColor(a,b) ((a) == (b)) +#define SameCSet(a,b) ((a) == (b)) + +/* + * 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) { + if (!SameColor(NEXT(fg), fg)) { + 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) { + if (!SameColor(NEXT(bg), bg)) { + 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) { + if (!SameCSet(NEXT(cset), cset)) { + NEXT(cset) = cset; + me->mask |= GC_CSet; + } + } +} +#else +#define setCgsCSet(xw, cgsWin, dstCgsId, cset) /* nothing */ +#endif + +void +setCgsFont(XtermWidget xw, VTwin * cgsWin, CgsEnum cgsId, XFontStruct * font) +{ + CgsCache *me; + + if ((me = myCache(xw, cgsWin, cgsId)) != 0) { + if (font == 0) { + if (cgsId != gcNorm) + (void) getCgsGC(xw, cgsWin, gcNorm); +#ifndef NO_ACTIVE_ICON + if (cgsWin == &(xw->screen.iconVwin)) + font = xw->screen.fnt_icon; + else +#endif + font = xw->screen.fnts[fNorm]; + } + if (okFont(font) && !SameFont(NEXT(font), font)) { + TRACE2(("...updated next font for %s to %s\n", + traceCgsEnum(cgsId), traceFont(font))); + TRACE2(("...next font was %s\n", traceFont(NEXT(font)))); + NEXT(font) = font; + me->mask |= GCFont; + } else { + 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, XFontStruct * font) +{ + CgsCache *me; + int j, k; + + for_each_gc(j) { + if ((me = myCache(xw, cgsWin, (CgsEnum) j)) != 0) { + 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 &= ~(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; + int j, k; + unsigned used = 0; + + if ((me = myCache(xw, cgsWin, cgsId)) != 0) { + TRACE2(("getCgsGC(%s, %s)\n", + traceVTwin(xw, cgsWin), traceCgsEnum(cgsId))); + if (me->mask != 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) { + /* 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); + TRACE(("...getCgsGC least-used(%d) was %d\n", k, THIS(used))); + result = chgCache(xw, cgsId, me); + } + 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. + */ +XFontStruct * +getCgsFont(XtermWidget xw, VTwin * cgsWin, GC gc) +{ + int n; + XFontStruct *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))); + setCgsFont(xw, cgsWin, dstCgsId, THIS(font)); + setCgsCSet(xw, cgsWin, dstCgsId, THIS(cset)); + setCgsFore(xw, cgsWin, dstCgsId, THIS(fg)); + setCgsBack(xw, cgsWin, dstCgsId, THIS(bg)); + } + } +} + +/* + * Interchange colors in the cache, e.g., for reverse-video. + */ +void +redoCgs(XtermWidget xw, Pixel fg, Pixel bg, CgsEnum cgsId) +{ + int n; + VTwin *cgsWin = WhichVWin(&(xw->screen)); + CgsCache *me = myCache(xw, cgsWin, cgsId); + + if (me != 0) { + CgsCacheData *save_data = me->data; + + for (n = 0; n < DEPTH; ++n) { + if (LIST(n).gc != 0) { + 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); + } + } + 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 *dst; + CgsCache *src; + + if ((src = myCache(xw, cgsWin, srcCgsId)) != 0) { + if ((dst = myCache(xw, cgsWin, dstCgsId)) != 0) { + CgsCache tmp; + tmp = *dst; + *dst = *src; + *src = tmp; + } + } + } +} + +/* + * Free any GC associated with the given id. + */ +GC +freeCgs(XtermWidget xw, VTwin * cgsWin, CgsEnum cgsId) +{ + CgsCache *me; + int j; + + if ((me = myCache(xw, cgsWin, cgsId)) != 0) { + for (j = 0; j < DEPTH; ++j) { + if (LIST(j).gc != 0) { + TRACE(("freeCgs(%s, %s) gc %p(%d)\n", + traceVTwin(xw, cgsWin), + traceCgsEnum(cgsId), 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(xw->screen.display, LIST(j).gc); + memset(&LIST(j), 0, sizeof(LIST(j))); + } + LINK(0); + } + } + return 0; +} diff --git a/app/xterm/config.guess b/app/xterm/config.guess index 396482d6c..1a695461e 100644 --- a/app/xterm/config.guess +++ b/app/xterm/config.guess @@ -4,7 +4,7 @@ # 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, # Inc. -timestamp='2006-07-02' +timestamp='2006-12-22' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -161,6 +161,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; + sh5el) machine=sh5le-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched @@ -780,7 +781,7 @@ EOF i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; - i*:MINGW*:*) + *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:windows32*:*) @@ -793,7 +794,7 @@ EOF x86:Interix*:[3456]*) echo i586-pc-interix${UNAME_RELEASE} exit ;; - EM64T:Interix*:[3456]*) + EM64T:Interix*:[3456]* | authenticamd:Interix*:[3456]*) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) @@ -950,6 +951,9 @@ EOF x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit ;; + xtensa:Linux:*:*) + echo xtensa-unknown-linux-gnu + exit ;; i*86:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. cd to the root directory to prevent @@ -1208,6 +1212,12 @@ EOF SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; + SX-7:SUPER-UX:*:*) + echo sx7-nec-superux${UNAME_RELEASE} + exit ;; + SX-8:SUPER-UX:*:*) + echo sx8-nec-superux${UNAME_RELEASE} + exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; diff --git a/app/xterm/config.sub b/app/xterm/config.sub index 387c18d1a..4b8cc7b41 100644 --- a/app/xterm/config.sub +++ b/app/xterm/config.sub @@ -4,7 +4,7 @@ # 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, # Inc. -timestamp='2006-07-02' +timestamp='2006-12-08' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software @@ -245,7 +245,7 @@ case $basic_machine in | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ - | fr30 | frv \ + | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ @@ -276,6 +276,7 @@ case $basic_machine in | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ + | score \ | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ @@ -284,7 +285,7 @@ case $basic_machine in | tahoe | thumb | tic4x | tic80 | tron \ | v850 | v850e \ | we32k \ - | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \ + | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ | z8k) basic_machine=$basic_machine-unknown ;; @@ -323,7 +324,7 @@ case $basic_machine in | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ - | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ @@ -367,7 +368,7 @@ case $basic_machine in | tron-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ - | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ | xstormy16-* | xtensa-* \ | ymp-* \ | z8k-*) @@ -909,6 +910,10 @@ case $basic_machine in sb1el) basic_machine=mipsisa64sb1el-unknown ;; + sde) + basic_machine=mipsisa32-sde + os=-elf + ;; sei) basic_machine=mips-sei os=-seiux @@ -920,6 +925,9 @@ case $basic_machine in basic_machine=sh-hitachi os=-hms ;; + sh5el) + basic_machine=sh5le-unknown + ;; sh64) basic_machine=sh64-unknown ;; @@ -1366,6 +1374,9 @@ else # system, and we'll never get to this point. case $basic_machine in + score-*) + os=-elf + ;; spu-*) os=-elf ;; diff --git a/app/xterm/precompose.c b/app/xterm/precompose.c index afe4c3f3f..da0d346d2 100644 --- a/app/xterm/precompose.c +++ b/app/xterm/precompose.c @@ -4,8 +4,8 @@ * DO NOT EDIT BY HAND! This is generated by the script * unicode/make-precompose.sh */ -/* $XTermId: precompose.c,v 1.7 2004/12/01 01:27:47 tom Exp $ */ -/* $XFree86: xc/programs/xterm/precompose.c,v 1.3 2004/12/01 01:27:47 dickey Exp $ */ +/* $XTermId: precompose.c,v 1.8 2007/02/05 01:06:36 Thomas.Wolff Exp $ */ +/* $XFree86$ */ #include <precompose.h> @@ -754,19 +754,17 @@ static struct { { 0x0F76, 0x0FB2, 0x0F80}, { 0x0F78, 0x0FB3, 0x0F80}, { 0x1026, 0x1025, 0x102E}, -{ 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}, +{ 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}, @@ -1016,18 +1014,34 @@ static struct { { 0x30FE, 0x30FD, 0x3099}, { 0xFB2C, 0xFB49, 0x05C1}, { 0xFB2D, 0xFB49, 0x05C2}, +{ 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; int mid; - unsigned int sought = ((unsigned)base << 16) | (unsigned)comb, that; + unsigned long sought = ((unsigned) base << UNICODE_SHIFT) | (unsigned) comb; + unsigned long that; /* binary search */ while (max >= min) { mid = (min + max) / 2; - that = ((unsigned)precompositions[mid].base << 16) | ((unsigned)precompositions[mid].comb); + that = ((unsigned) precompositions[mid].base << UNICODE_SHIFT) | ((unsigned) precompositions[mid].comb); if (that < sought) { min = mid + 1; } else if (that > sought) { diff --git a/app/xterm/run-tic.sh b/app/xterm/run-tic.sh new file mode 100644 index 000000000..aeaa3ff9a --- /dev/null +++ b/app/xterm/run-tic.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# $XTermId: run-tic.sh,v 1.1 2006/08/10 21:42:07 tom Exp $ +# +# 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 >&2 +rm -f $TMP + +exit $RET diff --git a/app/xterm/unicode/make-precompose.sh b/app/xterm/unicode/make-precompose.sh index 747866c4d..7c513c41e 100644 --- a/app/xterm/unicode/make-precompose.sh +++ b/app/xterm/unicode/make-precompose.sh @@ -1,8 +1,18 @@ #!/bin/sh -# $XTermId: make-precompose.sh,v 1.5 2005/04/03 16:58:30 tom Exp $ +# $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' -cut UnicodeData.txt -d ";" -f 1,6 | \ - grep ";[0-9,A-F]" | grep " " | \ - sed -e "s/ /, 0x/;s/^/{ 0x/;s/;/, 0x/;s/$/},/" | (sort -k 3 || sort +2) + +# 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 diff --git a/app/xterm/unicode/precompose.c.tail b/app/xterm/unicode/precompose.c.tail index 0ceca9b6c..1f530f1bf 100644 --- a/app/xterm/unicode/precompose.c.tail +++ b/app/xterm/unicode/precompose.c.tail @@ -1,15 +1,18 @@ }; +#define UNICODE_SHIFT 21 + int do_precomposition(int base, int comb) { int min = 0; int max = sizeof(precompositions) / sizeof(precompositions[0]) - 1; int mid; - unsigned int sought = ((unsigned)base << 16) | (unsigned)comb, that; + unsigned long sought = ((unsigned) base << UNICODE_SHIFT) | (unsigned) comb; + unsigned long that; /* binary search */ while (max >= min) { mid = (min + max) / 2; - that = ((unsigned)precompositions[mid].base << 16) | ((unsigned)precompositions[mid].comb); + that = ((unsigned) precompositions[mid].base << UNICODE_SHIFT) | ((unsigned) precompositions[mid].comb); if (that < sought) { min = mid + 1; } else if (that > sought) { diff --git a/app/xterm/vttests/dynamic2.sh b/app/xterm/vttests/dynamic2.sh new file mode 100644 index 000000000..e099af0c8 --- /dev/null +++ b/app/xterm/vttests/dynamic2.sh @@ -0,0 +1,85 @@ +#!/bin/sh +# $XTermId: dynamic2.sh,v 1.1 2006/10/17 20:37:21 tom Exp $ +# +# -- Thomas Dickey (2006/10/17) +# Demonstrate the use of dynamic colors by setting each dynamic color +# successively to different values. + +ESC="" +CMD='echo' +OPT='-n' +SUF='' +TMP=/tmp/xterm$$ +eval '$CMD $OPT >$TMP || echo fail >$TMP' 2>/dev/null +( test ! -f $TMP || test -s $TMP ) && +for verb in printf print ; do + rm -f $TMP + eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null + if test -f $TMP ; then + if test ! -s $TMP ; then + CMD="$verb" + OPT= + SUF='\c' + break + fi + fi +done +rm -f $TMP + +LIST="00 30 80 d0 ff" +FULL="10 11 12 13 14 15 16 17 18" + +echo "reading current color settings" + +exec </dev/tty +old=`stty -g` +stty raw -echo min 0 time 5 + +original= +for N in $FULL +do + $CMD $OPT "${ESC}]$N;?${SUF}" > /dev/tty + read reply + eval original$N='${reply}${SUF}' + original=${original}${reply}${SUF} +done +stty $old + +if ( trap "echo exit" EXIT 2>/dev/null ) >/dev/null +then + trap '$CMD $OPT "$original" >/dev/tty; exit' EXIT HUP INT TRAP TERM +else + trap '$CMD $OPT "$original" >/dev/tty; exit' 0 1 2 5 15 +fi + +while true +do + for N in $FULL + do + case $N in + 10) echo "coloring text foreground";; + 11) echo "coloring text background";; + 12) echo "coloring text cursor";; + 13) echo "coloring mouse foreground";; + 14) echo "coloring mouse background";; + 15) echo "coloring tektronix foreground";; + 16) echo "coloring tektronix background";; + 17) echo "coloring highlight background";; + 18) echo "coloring tektronix cursor";; + esac + for R in $LIST + do + for G in $LIST + do + for B in $LIST + do + $CMD $OPT "${ESC}]$N;rgb:$R/$G/$B${SUF}" >/dev/tty + sleep 1 + done + done + done + eval 'restore=$'original$N + $CMD $OPT "$restore" >/dev/tty + sleep 1 + done +done diff --git a/app/xterm/xtermcap.c b/app/xterm/xtermcap.c new file mode 100644 index 000000000..b1730fedd --- /dev/null +++ b/app/xterm/xtermcap.c @@ -0,0 +1,338 @@ +/* $XTermId: xtermcap.c,v 1.5 2007/03/18 22:34:20 tom Exp $ */ + +/* + * 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. + */ + +#include <xtermcap.h> + +#include <X11/keysym.h> + +#ifdef VMS +#include <X11/keysymdef.h> +#endif + +#include <xstrings.h> + +#if OPT_TCAP_QUERY || OPT_TCAP_FKEYS + +typedef struct { + char *tc; + char *ti; + int code; + unsigned state; +} TCAPINFO; +/* *INDENT-OFF* */ +#define DATA(tc,ti,x,y) { tc, ti, x, y } +static TCAPINFO table[] = { + /* tcap terminfo code state */ + DATA( "%1", "khlp", XK_Help, 0 ), + DATA( "#1", "kHLP", XK_Help, ShiftMask ), + DATA( "@0", "kfnd", XK_Find, 0 ), + DATA( "*0", "kFND", XK_Find, ShiftMask ), + DATA( "*6", "kslt", XK_Select, 0 ), + DATA( "#6", "kSLT", XK_Select, ShiftMask ), + + DATA( "kh", "khome", XK_Home, 0 ), + DATA( "#2", "kHOM", XK_Home, ShiftMask ), + DATA( "@7", "kend", XK_End, 0 ), + DATA( "*7", "kEND", XK_End, ShiftMask ), + + 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, ShiftMask ), + DATA( "%i", "kRIT", XK_Right, ShiftMask ), + DATA( "%e", "kPRV", XK_Up, ShiftMask ), + DATA( "%c", "kNXT", XK_Down, ShiftMask ), + + 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 ), + +#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( "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 +}; +#undef DATA +/* *INDENT-ON* */ + +#if OPT_TCAP_QUERY +static int +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; +} + +static TCAPINFO * +lookupTcapByName(const char *name) +{ + TCAPINFO *result = 0; + Cardinal n; + + for (n = 0; n < XtNumber(table); n++) { + if (!strcmp(table[n].ti, name) || !strcmp(table[n].tc, name)) { + result = table + n; + break; + } + } + 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, char **params, unsigned *state, Bool * fkey) +{ + TCAPINFO *data; + unsigned len = 0; + int code = -1; +#define MAX_TNAME_LEN 6 + char name[MAX_TNAME_LEN + 1]; + char *p; + + TRACE(("xtermcapKeycode(%s)\n", *params)); + + /* Convert hex encoded name to ascii */ + for (p = *params; hex2int(p[0]) >= 0 && hex2int(p[1]) >= 0; p += 2) { + if (len >= MAX_TNAME_LEN) + break; + name[len++] = (hex2int(p[0]) << 4) + hex2int(p[1]); + } + name[len] = 0; + *params = p; + + *state = 0; + *fkey = False; + + if (*p == 0 || *p == ';') { + if ((data = lookupTcapByName(name)) != 0) { + code = data->code; + *state = data->state; + 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 + } + } + + TRACE(("... xtermcapKeycode(%s, %u, %d) -> %#06x\n", + name, *state, *fkey, code)); + return code; +} +#endif /* OPT_TCAP_QUERY */ + +#if OPT_TCAP_FKEYS +static TCAPINFO * +lookupTcapByCode(int code, unsigned mask) +{ + TCAPINFO *result = 0; + Cardinal n; + + for (n = 0; n < XtNumber(table); n++) { + if (table[n].code == code && + table[n].state == mask) { + TRACE(("lookupTcapByCode %d:%s\n", n, table[n].ti)); + result = table + n; + break; + } + } + return result; +} + +int +xtermcapString(XtermWidget xw, int keycode, unsigned mask) +{ + TCAPINFO *data; + + if ((data = lookupTcapByCode(keycode, mask)) != 0) { + TScreen *screen = TScreenOf(xw); + Cardinal which = data - table; + char *fkey; + + if (screen->tcap_fkeys == 0) { + Cardinal want = XtNumber(table); + Cardinal have; + char *area = screen->tcap_area; + + if ((screen->tcap_fkeys = TypeCallocN(char *, want)) == 0) + return 0; + for (have = 0; have < want; ++have) { + if ((fkey = tgetstr(table[have].tc, &area)) != 0) { + screen->tcap_fkeys[have] = x_strdup(fkey); + } + } + } + if ((fkey = screen->tcap_fkeys[which]) != 0) { + StringInput(xw, (Char *) fkey, strlen(fkey)); + return 1; + } + } + return 0; +} +#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(char *name, char *buffer) +{ + *buffer = 0; /* initialize, in case we're using terminfo's tgetent */ + + if (name != 0) { + if (tgetent(buffer, name) == 1) { + 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; +} diff --git a/app/xterm/xtermcap.h b/app/xterm/xtermcap.h new file mode 100644 index 000000000..fbd5bc06a --- /dev/null +++ b/app/xterm/xtermcap.h @@ -0,0 +1,86 @@ +/* $XTermId: xtermcap.h,v 1.3 2007/03/18 23:37:48 tom Exp $ */ + +/************************************************************ + +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. + +********************************************************/ + +/* + * Common/useful definitions for XTERM termcap interface. + */ +#ifndef included_xtermcap_h +#define included_xtermcap_h + +#include <xterm.h> + +#include <ptyx.h> + +#ifdef HAVE_TERMCAP_H +#include <termcap.h> +#if defined(NCURSES_VERSION) + /* The tgetent emulation function in SVr4-style curses implementations + * (e.g., ncurses) ignores the buffer, so TERMCAP can't be set from it. + * Instead, just use terminfo. + */ +#undef USE_TERMCAP +#include <curses.h> +#endif +#else +#undef ERR /* workaround for glibc 2.1.3 */ +#include <curses.h> +#ifdef HAVE_NCURSES_TERM_H +#include <ncurses/term.h> +#elif defined(HAVE_TERM_H) +#include <term.h> /* tgetent() */ +#endif /*CYGWIN */ +#endif /* HAVE_TERMCAP_H */ + +/***====================================================================***/ + +#ifdef __cplusplus +extern "C" { +#endif + +/* xtermcap.c */ +extern Bool get_termcap(char * /* name */, char * /* buffer */); + +#if OPT_TCAP_FKEYS +extern int xtermcapString(XtermWidget /* xw */, int /* keycode */, unsigned /* mask */); +#endif + +#if OPT_TCAP_QUERY +extern int xtermcapKeycode(XtermWidget /* xw */, char ** /* params */, unsigned * /* state */, Bool * /* fkey */); +#endif + +#ifdef __cplusplus + } +#endif + +#endif /* included_xtermcap_h */ |