diff options
-rw-r--r-- | app/xterm/MANIFEST | 2 | ||||
-rw-r--r-- | app/xterm/Tekproc.c | 59 | ||||
-rw-r--r-- | app/xterm/XTerm.ad | 25 | ||||
-rw-r--r-- | app/xterm/button.c | 240 | ||||
-rw-r--r-- | app/xterm/cachedGCs.c | 32 | ||||
-rw-r--r-- | app/xterm/charproc.c | 253 | ||||
-rw-r--r-- | app/xterm/charsets.c | 8 | ||||
-rw-r--r-- | app/xterm/data.h | 7 | ||||
-rw-r--r-- | app/xterm/doublechr.c | 223 | ||||
-rw-r--r-- | app/xterm/fontutils.c | 378 | ||||
-rw-r--r-- | app/xterm/fontutils.h | 36 | ||||
-rw-r--r-- | app/xterm/input.c | 32 | ||||
-rw-r--r-- | app/xterm/main.c | 18 | ||||
-rw-r--r-- | app/xterm/main.h | 6 | ||||
-rw-r--r-- | app/xterm/menu.c | 225 | ||||
-rw-r--r-- | app/xterm/menu.h | 46 | ||||
-rw-r--r-- | app/xterm/misc.c | 192 | ||||
-rw-r--r-- | app/xterm/os2main.c | 80 | ||||
-rw-r--r-- | app/xterm/ptydata.c | 22 | ||||
-rw-r--r-- | app/xterm/ptyx.h | 21 | ||||
-rw-r--r-- | app/xterm/screen.c | 175 | ||||
-rw-r--r-- | app/xterm/scrollbar.c | 105 | ||||
-rw-r--r-- | app/xterm/util.c | 249 | ||||
-rw-r--r-- | app/xterm/version.h | 4 | ||||
-rw-r--r-- | app/xterm/wcwidth.c | 94 | ||||
-rw-r--r-- | app/xterm/xterm.h | 30 | ||||
-rw-r--r-- | app/xterm/xterm.log.html | 91 | ||||
-rw-r--r-- | app/xterm/xterm.man | 161 | ||||
-rw-r--r-- | app/xterm/xtermcap.c | 6 |
29 files changed, 1862 insertions, 958 deletions
diff --git a/app/xterm/MANIFEST b/app/xterm/MANIFEST index 9c9105a06..3aa34dbcb 100644 --- a/app/xterm/MANIFEST +++ b/app/xterm/MANIFEST @@ -1,4 +1,4 @@ -MANIFEST for xterm-239, version xterm-239 +MANIFEST for xterm-242, version xterm-242 -------------------------------------------------------------------------------- MANIFEST this file 256colres.h resource-definitions for 256-color mode diff --git a/app/xterm/Tekproc.c b/app/xterm/Tekproc.c index bf38747b6..d982366ba 100644 --- a/app/xterm/Tekproc.c +++ b/app/xterm/Tekproc.c @@ -1,4 +1,4 @@ -/* $XTermId: Tekproc.c,v 1.160 2008/06/03 20:55:56 tom Exp $ */ +/* $XTermId: Tekproc.c,v 1.163 2009/02/13 20:01:21 tom Exp $ */ /* * Warning, there be crufty dragons here. @@ -7,7 +7,7 @@ /* -Copyright 2001-2007,2008 by Thomas E. Dickey +Copyright 2001-2008,2009 by Thomas E. Dickey All Rights Reserved @@ -146,7 +146,7 @@ in this Software without prior written authorization from The Open Group. #define TekMove(tw,x,y) tekscr->cur_X = x; tekscr->cur_Y = y #define input() Tinput(tw) -#define unput(c) *Tpushback++ = c +#define unput(c) *Tpushback++ = (Char) c /* *INDENT-OFF* */ static struct Tek_Char { int hsize; /* in Tek units */ @@ -708,7 +708,7 @@ Tekparse(TekWidget tw) case CASE_PRINT: TRACE(("case: printable character\n")); ch = c; - c = tekscr->cur.fontsize; + c = (IChar) tekscr->cur.fontsize; x = (int) (tekscr->cur_X * TekScale(tekscr)) + screen->border; y = (int) ((TEKHEIGHT + TEKTOPPAD - tekscr->cur_Y) * TekScale(tekscr)) @@ -757,10 +757,10 @@ Tekparse(TekWidget tw) IChar c2; unsigned len = 0; while ((c2 = input()) != ANSI_BEL) { - if (!isprint(c2 & 0x7f) + if (!isprint((int) (c2 & 0x7f)) || len + 2 >= (int) sizeof(buf2)) break; - buf2[len++] = c2; + buf2[len++] = (Char) c2; } buf2[len] = 0; if (!nested++) { @@ -790,13 +790,13 @@ Tinput(TekWidget tw) return (*--Tpushback); if (tekRefreshList) { if (rcnt-- > 0) - return (*rptr++); + return (IChar) (*rptr++); if ((tek = tekRefreshList->next) != 0) { tekRefreshList = tek; rptr = tek->data; rcnt = tek->count - 1; TekSetFontSize(tw, tek->fontsize); - return (*rptr++); + return (IChar) (*rptr++); } tekRefreshList = (TekLink *) 0; longjmp(Tekjump, 1); @@ -876,14 +876,14 @@ Tinput(TekWidget tw) Panic("Tinput: malloc error (%d)\n", errno); tek = tek->next; tek->next = (TekLink *) 0; - tek->fontsize = tekscr->cur.fontsize; + tek->fontsize = (unsigned short) tekscr->cur.fontsize; tek->count = 0; tek->ptr = tek->data; } tek->count++; (void) morePtyData(screen, VTbuffer); - return (*tek->ptr++ = nextPtyData(screen, VTbuffer)); + return (IChar) (*tek->ptr++ = (char) nextPtyData(screen, VTbuffer)); } static void @@ -999,7 +999,7 @@ TekPage(TekWidget tw) if (tekscr->TekGIN) TekGINoff(tw); tek = TekRecord = &Tek0; - tek->fontsize = tekscr->cur.fontsize; + tek->fontsize = (unsigned short) tekscr->cur.fontsize; tek->count = 0; tek->ptr = tek->data; tek = tek->next; @@ -1033,7 +1033,7 @@ getpoint(TekWidget tw) x = tekscr->cur.x; y = tekscr->cur.y; for (;;) { - if ((c = input()) < ' ') { /* control character */ + if ((c = (int) input()) < ' ') { /* control character */ unput(c); return (0); } @@ -1164,12 +1164,12 @@ AddToDraw(TekWidget tw, int x1, int y1, int x2, int y2) TekFlush(tw); } lp = line_pt++; - lp->x1 = x1 = (int) (x1 * TekScale(tekscr) + screen->border); - lp->y1 = y1 = (int) ((TEKHEIGHT + TEKTOPPAD - y1) * TekScale(tekscr) + - screen->border); - lp->x2 = x2 = (int) (x2 * TekScale(tekscr) + screen->border); - lp->y2 = y2 = (int) ((TEKHEIGHT + TEKTOPPAD - y2) * TekScale(tekscr) + - screen->border); + lp->x1 = (short) (x1 * TekScale(tekscr) + screen->border); + lp->y1 = (short) ((TEKHEIGHT + TEKTOPPAD - y1) * TekScale(tekscr) + + screen->border); + lp->x2 = (short) (x2 * TekScale(tekscr) + screen->border); + lp->y2 = (short) ((TEKHEIGHT + TEKTOPPAD - y2) * TekScale(tekscr) + + screen->border); nplot++; TRACE(("...AddToDraw %d points\n", nplot)); } @@ -1264,12 +1264,12 @@ TekEnq(TekWidget tw, int adj = (status != 0) ? 0 : 1; TRACE(("TekEnq\n")); - cplot[0] = status; + cplot[0] = (Char) status; /* Translate x and y to Tektronix code */ - cplot[1] = 040 | ((x >> SHIFTHI) & FIVEBITS); - cplot[2] = 040 | ((x >> SHIFTLO) & FIVEBITS); - cplot[3] = 040 | ((y >> SHIFTHI) & FIVEBITS); - cplot[4] = 040 | ((y >> SHIFTLO) & FIVEBITS); + 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'; @@ -1521,8 +1521,8 @@ TekRealize(Widget gw, ((*valuemaskp) | CWBackPixel | CWWinGravity), values); - TFullWidth(tekscr) = width; - TFullHeight(tekscr) = height; + TFullWidth(tekscr) = (Dimension) width; + TFullHeight(tekscr) = (Dimension) height; TWidth(tekscr) = width - border; THeight(tekscr) = height - border; TekScale(tekscr) = (double) TWidth(tekscr) / TEKWIDTH; @@ -1598,10 +1598,10 @@ TekRealize(Widget gw, args[0].value = (XtArgVal) & icon_name; args[1].value = (XtArgVal) & title; XtGetValues(SHELL_OF(tw), args, 2); - tek_icon_name = XtMalloc(strlen(icon_name) + 7); + tek_icon_name = XtMalloc((Cardinal) strlen(icon_name) + 7); strcpy(tek_icon_name, icon_name); strcat(tek_icon_name, "(Tek)"); - tek_title = XtMalloc(strlen(title) + 7); + tek_title = XtMalloc((Cardinal) strlen(title) + 7); strcpy(tek_title, title); strcat(tek_title, "(Tek)"); args[0].value = (XtArgVal) tek_icon_name; @@ -1613,7 +1613,7 @@ TekRealize(Widget gw, tek = TekRecord = &Tek0; tek->next = (TekLink *) 0; - tek->fontsize = tekscr->cur.fontsize; + tek->fontsize = (unsigned short) tekscr->cur.fontsize; tek->count = 0; tek->ptr = tek->data; Tpushback = Tpushb; @@ -1740,9 +1740,10 @@ TekReverseVideo(TekWidget tw) TScreen *screen = TScreenOf(term); TekScreen *tekscr = TekScreenOf(tw); int i; + Pixel tmp; XGCValues gcv; - EXCHANGE(T_COLOR(screen, TEK_FG), T_COLOR(screen, TEK_BG), i); + EXCHANGE(T_COLOR(screen, TEK_FG), T_COLOR(screen, TEK_BG), tmp); T_COLOR(screen, TEK_CURSOR) = T_COLOR(screen, TEK_FG); diff --git a/app/xterm/XTerm.ad b/app/xterm/XTerm.ad index 97ae45f14..8074053a3 100644 --- a/app/xterm/XTerm.ad +++ b/app/xterm/XTerm.ad @@ -1,4 +1,4 @@ -! $XTermId: XTerm.ad,v 1.85 2007/11/26 18:42:37 tom Exp $ +! $XTermId: XTerm.ad,v 1.88 2009/02/13 00:14:13 tom Exp $ *scrollBar: true *saveLines: 1024 @@ -93,6 +93,11 @@ *fontMenu*utf8-mode*Label: UTF-8 *fontMenu*utf8-title*Label: UTF-8 Titles +*fontMenu*allow-tcap-ops*Label: Allow Termcap Ops +*fontMenu*allow-font-ops*Label: Allow Font Ops +*fontMenu*allow-title-ops*Label: Allow Title Ops +*fontMenu*allow-window-ops*Label: Allow Window Ops + *VT100.utf8Fonts.font2: -misc-fixed-medium-r-normal--8-80-75-75-c-50-iso10646-1 *VT100.utf8Fonts.font: -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1 *VT100.utf8Fonts.font3: -misc-fixed-medium-r-normal--14-130-75-75-c-70-iso10646-1 @@ -189,6 +194,24 @@ ! Alternatively, !*on2Clicks: regex [[:alpha:]]+://([[:alnum:]!#+,./=?@_~-]|(%[[:xdigit:]][[:xdigit:]]))+ +! vt100's and similar terminals recognize escape sequences and control +! characters to which they reply to the host with other escape sequences, +! to provide information. The "resize" program uses this feature. +! +! In addition, xterm recognizes several escape sequences which can be used to +! set fonts, window properties, return settings via escape sequences. Some +! find these useful; others are concerned with the possibility of unexpected +! inputs. +! +! All of these features can be enabled or disabled via menus. +! +! Depending on your environment, you may wish to disable those by default by +! uncommenting one or more of the resource settings below: +!*allowFontOps: false +!*allowTcapOps: false +!*allowTitleOps: false +!*allowWindowOps: false + ! Uncomment this to have a login shell by default !*VT100*login_shell: true diff --git a/app/xterm/button.c b/app/xterm/button.c index d9e6dfc76..70e8ffc1a 100644 --- a/app/xterm/button.c +++ b/app/xterm/button.c @@ -1,4 +1,4 @@ -/* $XTermId: button.c,v 1.298 2009/01/09 01:29:52 tom Exp $ */ +/* $XTermId: button.c,v 1.306 2009/02/13 21:09:08 tom Exp $ */ /* * Copyright 1999-2008,2009 by Thomas E. Dickey @@ -156,7 +156,7 @@ static void do_select_end(XtermWidget xw, XEvent * event, String * params, Bool SendMousePosition(XtermWidget xw, XEvent * event) { - TScreen *screen = &(xw->screen); + TScreen *screen = TScreenOf(xw); /* If send_mouse_pos mode isn't on, we shouldn't be here */ if (screen->send_mouse_pos == MOUSE_OFF) @@ -249,7 +249,7 @@ static Bool SendLocatorPosition(XtermWidget xw, XEvent * event) { ANSI reply; - TScreen *screen = &(xw->screen); + TScreen *screen = TScreenOf(xw); int row, col; Bool oor; int button; @@ -337,7 +337,9 @@ SendLocatorPosition(XtermWidget xw, XEvent * event) /* update mask to "after" state */ state ^= 1 << button; /* swap Button1 & Button3 */ - state = (state & ~(4 | 1)) | ((state & 1) ? 4 : 0) | ((state & 4) ? 1 : 0); + 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; @@ -383,7 +385,7 @@ void GetLocatorPosition(XtermWidget xw) { ANSI reply; - TScreen *screen = &xw->screen; + TScreen *screen = TScreenOf(xw); Window root, child; int rx, ry, x, y; unsigned int mask; @@ -448,7 +450,7 @@ void InitLocatorFilter(XtermWidget xw) { ANSI reply; - TScreen *screen = &xw->screen; + TScreen *screen = TScreenOf(xw); Window root, child; int rx, ry, x, y; unsigned int mask; @@ -569,7 +571,7 @@ static void CheckLocatorPosition(XtermWidget xw, XEvent * event) { ANSI reply; - TScreen *screen = &(xw->screen); + TScreen *screen = TScreenOf(xw); int row, col; Bool oor; int state; @@ -807,9 +809,10 @@ DiredButton(Widget w, String * params GCC_UNUSED, /* selections */ Cardinal *num_params GCC_UNUSED) { - if (IsXtermWidget(w)) { - XtermWidget xw = (XtermWidget) w; - TScreen *screen = &(xw->screen); + XtermWidget xw; + + if ((xw = getXtermWidget(w)) != 0) { + TScreen *screen = TScreenOf(xw); Char Line[6]; unsigned line, col; @@ -837,9 +840,10 @@ ReadLineButton(Widget w, String * params GCC_UNUSED, /* selections */ Cardinal *num_params GCC_UNUSED) { - if (IsXtermWidget(w)) { - XtermWidget xw = (XtermWidget) w; - TScreen *screen = &(xw->screen); + XtermWidget xw; + + if ((xw = getXtermWidget(w)) != 0) { + TScreen *screen = TScreenOf(xw); Char Line[6]; int line, col, ldelta = 0; @@ -905,9 +909,10 @@ ViButton(Widget w, String * params GCC_UNUSED, /* selections */ Cardinal *num_params GCC_UNUSED) { - if (IsXtermWidget(w)) { - XtermWidget xw = (XtermWidget) w; - TScreen *screen = &(xw->screen); + XtermWidget xw; + + if ((xw = getXtermWidget(w)) != 0) { + TScreen *screen = TScreenOf(xw); int pty = screen->respond; Char Line[6]; int line; @@ -943,9 +948,10 @@ HandleSelectExtend(Widget w, String * params GCC_UNUSED, Cardinal *num_params GCC_UNUSED) { - if (IsXtermWidget(w)) { - XtermWidget xw = (XtermWidget) w; - TScreen *screen = &(xw->screen); + XtermWidget xw; + + if ((xw = getXtermWidget(w)) != 0) { + TScreen *screen = TScreenOf(xw); CELL cell; screen->selection_time = event->xmotion.time; @@ -976,9 +982,10 @@ HandleKeyboardSelectExtend(Widget w, String * params GCC_UNUSED, Cardinal *num_params GCC_UNUSED) { - if (IsXtermWidget(w)) { - XtermWidget xw = (XtermWidget) w; - TScreen *screen = &xw->screen; + XtermWidget xw; + + if ((xw = getXtermWidget(w)) != 0) { + TScreen *screen = TScreenOf(xw); ExtendExtend(xw, &screen->cursorp); } } @@ -993,7 +1000,7 @@ do_select_end(XtermWidget xw, #if OPT_READLINE int ldelta1, ldelta2; #endif - TScreen *screen = &xw->screen; + TScreen *screen = TScreenOf(xw); screen->selection_time = event->xbutton.time; switch (screen->eventMode) { @@ -1027,8 +1034,11 @@ HandleSelectEnd(Widget w, String * params, /* selections */ Cardinal *num_params) { - if (IsXtermWidget(w)) - do_select_end((XtermWidget) w, event, params, num_params, False); + XtermWidget xw; + + if ((xw = getXtermWidget(w)) != 0) { + do_select_end(xw, event, params, num_params, False); + } } void @@ -1037,8 +1047,11 @@ HandleKeyboardSelectEnd(Widget w, String * params, /* selections */ Cardinal *num_params) { - if (IsXtermWidget(w)) - do_select_end((XtermWidget) w, event, params, num_params, True); + XtermWidget xw; + + if ((xw = getXtermWidget(w)) != 0) { + do_select_end(xw, event, params, num_params, True); + } } struct _SelectionList { @@ -1066,14 +1079,13 @@ static Char * UTF8toLatin1(Char * s, unsigned len, unsigned long *result) { static Char *buffer; - static size_t used; + static Cardinal used; Char *q; - if (used == 0) { - buffer = (Char *) XtMalloc(1 + (used = len)); - } else if (len > used) { - buffer = (Char *) XtRealloc((char *) buffer, 1 + (used = len)); + if (len > used) { + used = 1 + (2 * len); + allocXtermChars(&buffer, used); } if (buffer != 0) { @@ -1096,7 +1108,7 @@ UTF8toLatin1(Char * s, unsigned len, unsigned long *result) if (eqv == value) eqv = '#'; *q++ = (Char) eqv; - if (iswide((wchar_t) value)) + if (isWide((wchar_t) value)) *q++ = ' '; } } @@ -1117,10 +1129,12 @@ _SelectionTargets(Widget w) TScreen *screen; int n; - if (!IsXtermWidget(w)) + XtermWidget xw; + + if ((xw = getXtermWidget(w)) == 0) return NULL; - screen = TScreenOf((XtermWidget) w); + screen = TScreenOf(xw); #if OPT_WIDE_CHARS if (screen->wide_chars) { @@ -1173,7 +1187,7 @@ _SelectionTargets(Widget w) static void UnmapSelections(XtermWidget xw) { - TScreen *screen = &(xw->screen); + TScreen *screen = TScreenOf(xw); Cardinal n; if (screen->mappedSelect) { @@ -1208,7 +1222,8 @@ MapSelections(XtermWidget xw, String * params, Cardinal num_params) } } if (map) { - const char *mapTo = (xw->screen.selectToClipboard + TScreen *screen = TScreenOf(xw); + const char *mapTo = (screen->selectToClipboard ? "CLIPBOARD" : "PRIMARY"); @@ -1225,7 +1240,7 @@ MapSelections(XtermWidget xw, String * params, Cardinal num_params) break; } } - xw->screen.mappedSelect = result; + screen->mappedSelect = result; } } } @@ -1276,10 +1291,12 @@ CutBuffer(unsigned code) static void FinishPaste64(XtermWidget xw) { - TRACE(("FinishPaste64(%d)\n", xw->screen.base64_paste)); - if (xw->screen.base64_paste) { - xw->screen.base64_paste = 0; - unparseputc1(xw, xw->screen.base64_final); + 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); } } @@ -1299,11 +1316,13 @@ xtermGetSelection(Widget w, int cutbuffer; Atom target; - if (!IsXtermWidget(w)) + XtermWidget xw; + + if ((xw = getXtermWidget(w)) == 0) return; TRACE(("xtermGetSelection\n")); - params = MapSelections((XtermWidget) w, params, num_params); + params = MapSelections(xw, params, num_params); XmuInternStrings(XtDisplay(w), params, (Cardinal) 1, &selection); cutbuffer = CutBuffer(selection); @@ -1330,7 +1349,7 @@ xtermGetSelection(Widget w, } #if OPT_PASTE64 else { - FinishPaste64((XtermWidget) w); + FinishPaste64(xw); } #endif return; @@ -1581,9 +1600,12 @@ SelectionReceived(Widget w, Char *line = (Char *) value; #endif - if (!IsXtermWidget(w)) + XtermWidget xw; + + if ((xw = getXtermWidget(w)) == 0) return; - screen = TScreenOf((XtermWidget) w); + + screen = TScreenOf(xw); dpy = XtDisplay(w); if (*type == 0 /*XT_CONVERT_FAIL */ @@ -1695,7 +1717,7 @@ SelectionReceived(Widget w, } #if OPT_PASTE64 if (screen->base64_paste) { - FinishPaste64((XtermWidget) w); + FinishPaste64(xw); } else #endif #if OPT_READLINE @@ -1720,7 +1742,7 @@ SelectionReceived(Widget w, XtFree((char *) client_data); #if OPT_PASTE64 } else { - FinishPaste64((XtermWidget) w); + FinishPaste64(xw); #endif } return; @@ -1732,13 +1754,13 @@ HandleInsertSelection(Widget w, String * params, /* selections in precedence order */ Cardinal *num_params) { - if (IsXtermWidget(w)) { - XtermWidget xw = (XtermWidget) w; + XtermWidget xw; + if ((xw = getXtermWidget(w)) != 0) { if (!SendMousePosition(xw, event)) { #if OPT_READLINE int ldelta; - TScreen *screen = &(xw->screen); + TScreen *screen = TScreenOf(xw); if ((event->type == ButtonPress || event->type == ButtonRelease) /* Disable on Shift-mouse, including the application-mouse modes */ && !(KeyModifiers & ShiftMask) @@ -1754,16 +1776,17 @@ HandleInsertSelection(Widget w, } static SelectUnit -EvalSelectUnit(TScreen * screen, +EvalSelectUnit(XtermWidget xw, Time buttonDownTime, SelectUnit defaultUnit, unsigned int button) { + TScreen *screen = TScreenOf(xw); SelectUnit result; int delta; if (button != screen->lastButton) { - delta = term->screen.multiClickTime + 1; + delta = xw->screen.multiClickTime + 1; } else if (screen->lastButtonUpTime == (Time) 0) { /* first time and once in a blue moon */ delta = screen->multiClickTime + 1; @@ -1791,11 +1814,11 @@ do_select_start(XtermWidget xw, XEvent * event, /* must be XButtonEvent* */ CELL * cell) { - TScreen *screen = &(xw->screen); + TScreen *screen = TScreenOf(xw); if (SendMousePosition(xw, event)) return; - screen->selectUnit = EvalSelectUnit(screen, + screen->selectUnit = EvalSelectUnit(xw, event->xbutton.time, Select_CHAR, event->xbutton.button); @@ -1815,9 +1838,10 @@ HandleSelectStart(Widget w, String * params GCC_UNUSED, Cardinal *num_params GCC_UNUSED) { - if (IsXtermWidget(w)) { - XtermWidget xw = (XtermWidget) w; - TScreen *screen = &(xw->screen); + XtermWidget xw; + + if ((xw = getXtermWidget(w)) != 0) { + TScreen *screen = TScreenOf(xw); CELL cell; screen->firstValidRow = 0; @@ -1839,9 +1863,10 @@ HandleKeyboardSelectStart(Widget w, String * params GCC_UNUSED, Cardinal *num_params GCC_UNUSED) { - if (IsXtermWidget(w)) { - XtermWidget xw = (XtermWidget) w; - TScreen *screen = &(xw->screen); + XtermWidget xw; + + if ((xw = getXtermWidget(w)) != 0) { + TScreen *screen = TScreenOf(xw); do_select_start(xw, event, &screen->cursorp); } } @@ -1849,10 +1874,10 @@ HandleKeyboardSelectStart(Widget w, static void TrackDown(XtermWidget xw, XButtonEvent * event) { - TScreen *screen = &(xw->screen); + TScreen *screen = TScreenOf(xw); CELL cell; - screen->selectUnit = EvalSelectUnit(screen, + screen->selectUnit = EvalSelectUnit(xw, event->time, Select_CHAR, event->button); @@ -1878,7 +1903,7 @@ TrackMouse(XtermWidget xw, int firstrow, int lastrow) { - TScreen *screen = &(xw->screen); + TScreen *screen = TScreenOf(xw); if (screen->waitingForTrackInfo) { /* if Timed, ignore */ screen->waitingForTrackInfo = False; @@ -1900,7 +1925,7 @@ TrackMouse(XtermWidget xw, static void StartSelect(XtermWidget xw, const CELL * cell) { - TScreen *screen = &(xw->screen); + TScreen *screen = TScreenOf(xw); TRACE(("StartSelect row=%d, col=%d\n", cell->row, cell->col)); if (screen->cursor_state) @@ -1931,7 +1956,7 @@ EndExtend(XtermWidget xw, { CELL cell; unsigned count; - TScreen *screen = &xw->screen; + TScreen *screen = TScreenOf(xw); Char line[9]; if (use_cursor_loc) { @@ -1981,8 +2006,10 @@ HandleSelectSet(Widget w, String * params, Cardinal *num_params) { - if (IsXtermWidget(w)) { - SelectSet((XtermWidget) w, event, params, *num_params); + XtermWidget xw; + + if ((xw = getXtermWidget(w)) != 0) { + SelectSet(xw, event, params, *num_params); } } @@ -1993,7 +2020,7 @@ SelectSet(XtermWidget xw, String * params, Cardinal num_params) { - TScreen *screen = &(xw->screen); + TScreen *screen = TScreenOf(xw); TRACE(("SelectSet\n")); /* Only do select stuff if non-null select */ @@ -2014,13 +2041,10 @@ do_start_extend(XtermWidget xw, Cardinal *num_params GCC_UNUSED, Bool use_cursor_loc) { - TScreen *screen = &(xw->screen); + TScreen *screen = TScreenOf(xw); int coord; CELL cell; - if (!IsXtermWidget(xw)) - return; - if (SendMousePosition(xw, event)) return; @@ -2031,7 +2055,7 @@ do_start_extend(XtermWidget xw, || event->xbutton.button != Button3 || !(SCREEN_FLAG(screen, dclick3_deletes))) #endif - screen->selectUnit = EvalSelectUnit(screen, + screen->selectUnit = EvalSelectUnit(xw, event->xbutton.time, screen->selectUnit, event->xbutton.button); @@ -2082,7 +2106,7 @@ do_start_extend(XtermWidget xw, static void ExtendExtend(XtermWidget xw, const CELL * cell) { - TScreen *screen = &(xw->screen); + TScreen *screen = TScreenOf(xw); int coord = Coordinate(screen, cell); TRACE(("ExtendExtend row=%d, col=%d\n", cell->row, cell->col)); @@ -2117,8 +2141,11 @@ HandleStartExtend(Widget w, String * params, /* unused */ Cardinal *num_params) /* unused */ { - if (IsXtermWidget(w)) - do_start_extend((XtermWidget) w, event, params, num_params, False); + XtermWidget xw; + + if ((xw = getXtermWidget(w)) != 0) { + do_start_extend(xw, event, params, num_params, False); + } } void @@ -2127,8 +2154,11 @@ HandleKeyboardStartExtend(Widget w, String * params, /* unused */ Cardinal *num_params) /* unused */ { - if (IsXtermWidget(w)) - do_start_extend((XtermWidget) w, event, params, num_params, True); + XtermWidget xw; + + if ((xw = getXtermWidget(w)) != 0) { + do_start_extend(xw, event, params, num_params, True); + } } void @@ -2218,7 +2248,7 @@ ResizeSelection(TScreen * screen GCC_UNUSED, int rows, int cols) Bool iswide(int i) { - return (i == HIDDEN_CHAR) || (my_wcwidth(i) == 2); + return (i == HIDDEN_CHAR) || ((i >= FIRST_WIDECHAR) && my_wcwidth(i) == 2); } #define isWideCell(row, col) iswide((int)XTERM_CELL(row, col)) @@ -2699,7 +2729,7 @@ ComputeSelect(XtermWidget xw, CELL * endc, Bool extend) { - TScreen *screen = &(xw->screen); + TScreen *screen = TScreenOf(xw); int length; int cclass; CELL first = *startc; @@ -2883,7 +2913,7 @@ TrackText(XtermWidget xw, const CELL * firstp, const CELL * lastp) { - TScreen *screen = &(xw->screen); + TScreen *screen = TScreenOf(xw); int from, to; CELL old_start, old_end; CELL first = *firstp; @@ -2931,7 +2961,7 @@ ReHiliteText(XtermWidget xw, CELL * firstp, CELL * lastp) { - TScreen *screen = &(xw->screen); + TScreen *screen = TScreenOf(xw); int i; CELL first = *firstp; CELL last = *lastp; @@ -2979,7 +3009,7 @@ SaltTextAway(XtermWidget xw, String * params, /* selections */ Cardinal num_params) { - TScreen *screen = &(xw->screen); + TScreen *screen = TScreenOf(xw); int i, j = 0; int eol; Char *line; @@ -3142,8 +3172,10 @@ AppendToSelectionBuffer(TScreen * screen, unsigned c) void CompleteSelection(XtermWidget xw, char **args, Cardinal len) { - xw->screen.base64_count = 0; - xw->screen.base64_accu = 0; + TScreen *screen = TScreenOf(xw); + + screen->base64_count = 0; + screen->base64_accu = 0; _OwnSelection(xw, args, len); } #endif /* OPT_PASTE64 */ @@ -3160,9 +3192,11 @@ _ConvertSelectionHelper(Widget w, XTextProperty *), XICCEncodingStyle conversion_style) { - if (IsXtermWidget(w)) { + XtermWidget xw; + + if ((xw = getXtermWidget(w)) != 0) { + TScreen *screen = TScreenOf(xw); Display *dpy = XtDisplay(w); - TScreen *screen = TScreenOf((XtermWidget) w); XTextProperty textprop; char *the_data = (char *) screen->selection_data; @@ -3215,10 +3249,12 @@ ConvertSelection(Widget w, TScreen *screen; Bool result = False; - if (!IsXtermWidget(w)) + XtermWidget xw; + + if ((xw = getXtermWidget(w)) == 0) return False; - screen = TScreenOf((XtermWidget) w); + screen = TScreenOf(xw); if (screen->selection_data == NULL) return False; /* can this happen? */ @@ -3368,10 +3404,12 @@ LoseSelection(Widget w, Atom * selection) Atom *atomP; Cardinal i; - if (!IsXtermWidget(w)) + XtermWidget xw; + + if ((xw = getXtermWidget(w)) == 0) return; - screen = TScreenOf((XtermWidget) w); + screen = TScreenOf(xw); for (i = 0, atomP = screen->selection_atoms; i < screen->selection_count; i++, atomP++) { if (*selection == *atomP) @@ -3395,7 +3433,7 @@ LoseSelection(Widget w, Atom * selection) } if (screen->selection_count == 0) - TrackText((XtermWidget) w, &zeroCELL, &zeroCELL); + TrackText(xw, &zeroCELL, &zeroCELL); } /* ARGSUSED */ @@ -3412,7 +3450,7 @@ _OwnSelection(XtermWidget xw, String * selections, Cardinal count) { - TScreen *screen = &(xw->screen); + TScreen *screen = TScreenOf(xw); Atom *atoms = screen->selection_atoms; Cardinal i; Bool have_selection = False; @@ -3437,7 +3475,7 @@ _OwnSelection(XtermWidget xw, (unsigned long) (4 * XMaxRequestSize(XtDisplay((Widget) xw)) - 32); if (screen->selection_length > limit) { fprintf(stderr, - "%s: selection too big (%ld bytes), not storing in CUT_BUFFER%d\n", + "%s: selection too big (%lu bytes), not storing in CUT_BUFFER%d\n", xterm_name, screen->selection_length, cutbuffer); } else { /* This used to just use the UTF-8 data, which was totally @@ -3480,7 +3518,7 @@ ResetSelectionState(TScreen * screen) void DisownSelection(XtermWidget xw) { - TScreen *screen = &(xw->screen); + TScreen *screen = TScreenOf(xw); Atom *atoms = screen->selection_atoms; Cardinal count = screen->selection_count; Cardinal i; @@ -3518,7 +3556,7 @@ DisownSelection(XtermWidget xw) void UnhiliteSelection(XtermWidget xw) { - TScreen *screen = &(xw->screen); + TScreen *screen = TScreenOf(xw); if (ScrnHaveSelection(screen)) { CELL first = screen->startH; @@ -3576,7 +3614,7 @@ SaveText(TScreen * screen, /* We want to strip out every occurrence of HIDDEN_CHAR AFTER a * wide character. */ - if (c == HIDDEN_CHAR && iswide((int) previous)) { + if (c == HIDDEN_CHAR && isWide((int) previous)) { previous = c; /* Combining characters attached to double-width characters are in memory attached to the HIDDEN_CHAR */ @@ -3665,7 +3703,7 @@ BtnCode(XButtonEvent * event, int button) static void EditorButton(XtermWidget xw, XButtonEvent * event) { - TScreen *screen = &(xw->screen); + TScreen *screen = TScreenOf(xw); int pty = screen->respond; Char line[6]; int row, col; @@ -3772,7 +3810,7 @@ EditorButton(XtermWidget xw, XButtonEvent * event) void SendFocusButton(XtermWidget xw, XFocusChangeEvent * event) { - TScreen *screen = &(xw->screen); + TScreen *screen = TScreenOf(xw); if (screen->send_focus_pos) { ANSI reply; diff --git a/app/xterm/cachedGCs.c b/app/xterm/cachedGCs.c index 70dac4a78..88819fc78 100644 --- a/app/xterm/cachedGCs.c +++ b/app/xterm/cachedGCs.c @@ -1,8 +1,8 @@ -/* $XTermId: cachedGCs.c,v 1.49 2008/12/30 17:33:30 tom Exp $ */ +/* $XTermId: cachedGCs.c,v 1.51 2009/02/13 00:37:46 tom Exp $ */ /************************************************************ -Copyright 2007,2008 by Thomas E. Dickey +Copyright 2007-2008,2009 by Thomas E. Dickey All Rights Reserved @@ -71,6 +71,8 @@ typedef struct { #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 { @@ -163,9 +165,9 @@ static String traceFont(XTermFonts * font) { static char result[80]; - XFontStruct *fs; - if (font != 0 && (fs = font->fs) != 0) { + if (HaveFont(font)) { + XFontStruct *fs = font->fs; sprintf(result, "%p(%dx%d %d %#lx)", fs, fs->max_bounds.width, @@ -394,12 +396,6 @@ newCache(XtermWidget xw, VTwin * cgsWin, CgsEnum cgsId, CgsCache * me) } static Boolean -HaveFont(XTermFonts * a) -{ - return (Boolean) (a != 0 && a->fs != 0); -} - -static Boolean SameFont(XTermFonts * a, XTermFonts * b) { return (Boolean) (HaveFont(a) @@ -412,7 +408,7 @@ SameFont(XTermFonts * a, XTermFonts * b) #define SameCSet(a,b) ((a) == (b)) static GC -chgCache(XtermWidget xw, CgsEnum cgsId GCC_UNUSED, CgsCache * me) +chgCache(XtermWidget xw, CgsEnum cgsId GCC_UNUSED, CgsCache * me, Bool both) { XGCValues xgcv; XtGCMask mask = (GCForeground | GCBackground | GCFont); @@ -436,8 +432,10 @@ chgCache(XtermWidget xw, CgsEnum cgsId GCC_UNUSED, CgsCache * me) TRACE2(("...chgCache new bg=%s\n", tracePixel(xw, NEXT(bg)))); #endif - THIS(font) = NEXT(font); - THIS(cset) = NEXT(cset); + if (both) { + THIS(font) = NEXT(font); + THIS(cset) = NEXT(cset); + } THIS(fg) = NEXT(fg); THIS(bg) = NEXT(bg); @@ -514,7 +512,7 @@ setCgsFont(XtermWidget xw, VTwin * cgsWin, CgsEnum cgsId, XTermFonts * font) #endif font = &(xw->screen.fnts[fNorm]); } - if (okFont(font->fs) && !SameFont(NEXT(font), font)) { + if (HaveFont(font) && okFont(font->fs) && !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)))); @@ -638,7 +636,7 @@ getCgsGC(XtermWidget xw, VTwin * cgsWin, CgsEnum cgsId) } LINK(k); TRACE(("...getCgsGC least-used(%d) was %d\n", k, THIS(used))); - result = chgCache(xw, cgsId, me); + result = chgCache(xw, cgsId, me, True); } me->next = *(me->data); } else { @@ -776,7 +774,7 @@ redoCgs(XtermWidget xw, Pixel fg, Pixel bg, CgsEnum cgsId) CgsCacheData *save_data = me->data; for (n = 0; n < DEPTH; ++n) { - if (LIST(n).gc != 0) { + if (LIST(n).gc != 0 && HaveFont(LIST(n).font)) { LINK(n); if (LIST(n).fg == fg @@ -791,7 +789,7 @@ redoCgs(XtermWidget xw, Pixel fg, Pixel bg, CgsEnum cgsId) continue; } - (void) chgCache(xw, cgsId, me); + (void) chgCache(xw, cgsId, me, False); } } me->data = save_data; diff --git a/app/xterm/charproc.c b/app/xterm/charproc.c index 556c4ba5d..12fa232c3 100644 --- a/app/xterm/charproc.c +++ b/app/xterm/charproc.c @@ -1,8 +1,8 @@ -/* $XTermId: charproc.c,v 1.865 2008/12/30 14:45:41 tom Exp $ */ +/* $XTermId: charproc.c,v 1.892 2009/02/13 21:15:35 tom Exp $ */ /* -Copyright 1999-2007,2008 by Thomas E. Dickey +Copyright 1999-2008,2009 by Thomas E. Dickey All Rights Reserved @@ -317,6 +317,12 @@ static XtActionsRec actionsList[] = { #ifdef ALLOWLOGGING { "set-logging", HandleLogging }, #endif +#if OPT_ALLOW_XXX_OPS + { "allow-font-ops", HandleAllowFontOps }, + { "allow-tcap-ops", HandleAllowTcapOps }, + { "allow-title-ops", HandleAllowTitleOps }, + { "allow-window-ops", HandleAllowWindowOps }, +#endif #if OPT_BLINK_CURS { "set-cursorblink", HandleCursorBlink }, #endif @@ -448,6 +454,7 @@ static XtResource resources[] = Bres(XtNvisualBell, XtCVisualBell, screen.visualbell, False), 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), @@ -782,7 +789,6 @@ WidgetClass xtermWidgetClass = (WidgetClass) & xtermClassRec; void xtermAddInput(Widget w) { -#if OPT_TOOLBAR /* *INDENT-OFF* */ XtActionsRec input_actions[] = { { "insert", HandleKeyPressed }, /* alias */ @@ -814,9 +820,10 @@ xtermAddInput(Widget w) }; /* *INDENT-ON* */ + TRACE_TRANS("BEFORE", w); XtAppAddActions(app_con, input_actions, XtNumber(input_actions)); -#endif XtAugmentTranslations(w, XtParseTranslationTable(defaultTranslations)); + TRACE_TRANS("AFTER:", w); #if OPT_EXTRA_PASTE if (term && term->keyboard.extra_translations) @@ -825,6 +832,42 @@ xtermAddInput(Widget w) } #if OPT_ISO_COLORS +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) { + col = (row == screen->cur_row) ? screen->cur_col : 0; + for (; isClear && (col <= screen->max_col); ++col) { + unsigned flags = SCRN_BUF_ATTRS(screen, row)[col]; + if (pass) { + flags &= ~FG_COLOR; + SCRN_BUF_ATTRS(screen, row)[col] = (Char) flags; + } else if ((flags & BG_COLOR)) { + isClear = False; + } else if ((flags & FG_COLOR)) { + unsigned ch = getXtermCell(screen, row, 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; +} + /* * The terminal's foreground and background colors are set via two mechanisms: * text (cur_foreground, cur_background values that are passed down to @@ -850,6 +893,19 @@ SGR_Foreground(XtermWidget xw, int color) setCgsFore(xw, WhichVWin(screen), gcBold, fg); setCgsBack(xw, WhichVWin(screen), gcBoldReverse, 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"); + } } void @@ -1224,6 +1280,7 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState *sp) do { #if OPT_WIDE_CHARS + int this_is_wide = 0; /* * Handle zero-width combining characters. Make it faster by noting @@ -1421,7 +1478,8 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState *sp) * If this character is a different width than the last one, put the * previous text into the buffer and draw it now. */ - if (iswide((int) c) != sp->last_was_wide) { + this_is_wide = isWide((int) c); + if (this_is_wide != sp->last_was_wide) { WriteNow(); } #endif @@ -1452,7 +1510,7 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState *sp) print_area[print_used++] = c; sp->lastchar = thischar = (int) c; #if OPT_WIDE_CHARS - sp->last_was_wide = iswide((int) c); + sp->last_was_wide = this_is_wide; #endif if (morePtyData(screen, VTbuffer)) { continue; @@ -2852,7 +2910,7 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState *sp) case CASE_XTERM_WINOPS: TRACE(("CASE_XTERM_WINOPS\n")); - if (screen->allowWindowOps) + if (AllowWindowOps(xw)) window_ops(xw); sp->parsestate = sp->groundtable; break; @@ -2964,7 +3022,7 @@ v_write(int f, Char * data, unsigned len) unsigned c = len; if (v_bufstr == NULL && len > 0) { - v_buffer = (Char *) XtMalloc(len); + v_buffer = (Char *) XtMalloc((Cardinal) len); v_bufstr = v_buffer; v_bufptr = v_buffer; v_bufend = v_buffer + len; @@ -3506,41 +3564,7 @@ dotext(XtermWidget xw, * buffers (perhaps this is simpler). */ if (chars_chomped != 0 && next_col <= screen->max_col) { - static unsigned limit; - static Char *hibyte, *lobyte; - Bool both = False; - unsigned j, k; - - if (chars_chomped >= limit) { - limit = (chars_chomped + 1) * 2; - lobyte = (Char *) XtRealloc((char *) lobyte, limit); - hibyte = (Char *) XtRealloc((char *) hibyte, limit); - } - for (j = offset, k = 0; j < offset + chars_chomped; j++) { - if (buf[j] == HIDDEN_CHAR) - continue; - lobyte[k] = LO_BYTE(buf[j]); - if (buf[j] > 255) { - hibyte[k] = HI_BYTE(buf[j]); - both = True; - } else { - hibyte[k] = 0; - } - ++k; - } - - WriteText(xw, PAIRED_CHARS(lobyte, - (both ? hibyte : 0)), - k); -#ifdef NO_LEAKS - if (limit != 0) { - limit = 0; - XtFree((char *) lobyte); - XtFree((char *) hibyte); - lobyte = 0; - hibyte = 0; - } -#endif + WriteText(xw, buf + offset, chars_chomped); } next_col += width_here; screen->do_wrap = need_wrap; @@ -3564,9 +3588,7 @@ dotext(XtermWidget xw, } next_col = screen->cur_col + this_col; - WriteText(xw, PAIRED_CHARS(buf + offset, - buf2 ? buf2 + offset : 0), - (unsigned) this_col); + WriteText(xw, buf + offset, (unsigned) this_col); /* * The call to WriteText updates screen->cur_col. @@ -3581,20 +3603,14 @@ dotext(XtermWidget xw, #if OPT_WIDE_CHARS unsigned -visual_width(PAIRED_CHARS(Char * str, Char * str2), Cardinal len) +visual_width(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 = *str; - if (str2) - ch |= *str2 << 8; - if (str) - str++; - if (str2) - str2++; - if (iswide(ch)) + int ch = (int) *str++; + if (isWide(ch)) my_len += 2; else my_len++; @@ -3636,7 +3652,7 @@ HandleStructNotify(Widget w GCC_UNUSED, return; } strcpy(buf, icon_name + 4); - ChangeIconName(buf); + ChangeIconName(xw, buf); free(buf); } } @@ -5607,7 +5623,14 @@ VTInitialize(Widget wrequest, for (i = fontMenu_font1; i <= fontMenu_lastBuiltin; i++) { init_Sres2(screen.MenuFontName, i); } - wnew->screen.MenuFontName(fontMenu_default) = wnew->misc.default_font.f_n; + init_Ires(misc.fontWarnings); +#define DefaultFontNames wnew->screen.menu_font_names[fontMenu_default] + DefaultFontNames[fNorm] = wnew->misc.default_font.f_n; + DefaultFontNames[fBold] = wnew->misc.default_font.f_b; +#if OPT_WIDE_CHARS + DefaultFontNames[fWide] = wnew->misc.default_font.f_w; + DefaultFontNames[fWBold] = wnew->misc.default_font.f_wb; +#endif wnew->screen.MenuFontName(fontMenu_fontescape) = NULL; wnew->screen.MenuFontName(fontMenu_fontsel) = NULL; @@ -6801,6 +6824,7 @@ ShowCursor(void) XtermWidget xw = term; TScreen *screen = &xw->screen; int x, y; + int base; Char clo; unsigned flags; unsigned fg_bg = 0; @@ -6822,7 +6846,6 @@ ShowCursor(void) #endif #if OPT_WIDE_CHARS Char chi = 0; - int base; int off; int my_col = 0; #endif @@ -6848,10 +6871,9 @@ ShowCursor(void) } #endif /* NO_ACTIVE_ICON */ -#if OPT_WIDE_CHARS base = -#endif clo = SCRN_BUF_CHARS(screen, screen->cursorp.row)[cursor_col]; + flags = SCRN_BUF_ATTRS(screen, screen->cursorp.row)[cursor_col]; if_OPT_WIDE_CHARS(screen, { chi = SCRN_BUF_WIDEC(screen, screen->cursorp.row)[cursor_col]; @@ -6865,31 +6887,31 @@ ShowCursor(void) } my_col = cursor_col; base = (chi << 8) | clo; - if (iswide(base)) + if (base == 0) + base = clo = ' '; + if (isWide(base)) my_col += 1; }); - flags = SCRN_BUF_ATTRS(screen, screen->cursorp.row)[cursor_col]; - - if (clo == 0 -#if OPT_WIDE_CHARS - && chi == 0 -#endif - ) { - clo = ' '; + if (base == 0) { + base = clo = ' '; } /* - * 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 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 ((flags & TERM_COLOR_FLAGS(xw)) == BG_COLOR -#if OPT_WIDE_CHARS - && chi == 0 -#endif - && clo == ' ') { - flags &= ~TERM_COLOR_FLAGS(xw); + 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); + } } #endif @@ -7007,9 +7029,9 @@ ShowCursor(void) && (screen->cursor_state != ON || screen->cursor_GC != set_at)) { screen->cursor_GC = set_at; - TRACE(("ShowCursor calling drawXtermText cur(%d,%d) %s\n", + TRACE(("ShowCursor calling drawXtermText cur(%d,%d) %s, set_at %d\n", screen->cur_row, screen->cur_col, - (filled ? "filled" : "outline"))); + (filled ? "filled" : "outline"), set_at)); currentGC = getCgsGC(xw, currentWin, currentCgs); drawXtermText(xw, flags & DRAWX_MASK, currentGC, @@ -7028,7 +7050,7 @@ ShowCursor(void) drawXtermText(xw, (flags & DRAWX_MASK) | NOBACKGROUND, currentGC, x, y, curXtermChrSet(xw, screen->cur_row), - PAIRED_CHARS(&clo, &chi), 1, iswide(base)); + PAIRED_CHARS(&clo, &chi), 1, isWide(base)); } }); #endif @@ -7059,14 +7081,14 @@ HideCursor(void) XtermWidget xw = term; TScreen *screen = &xw->screen; GC currentGC; - unsigned flags; - unsigned fg_bg = 0; int x, y; + int base; Char clo; + unsigned flags; + unsigned fg_bg = 0; Bool in_selection; #if OPT_WIDE_CHARS Char chi = 0; - int base; int off; int my_col = 0; #endif @@ -7086,15 +7108,13 @@ HideCursor(void) } #endif /* NO_ACTIVE_ICON */ -#if OPT_WIDE_CHARS base = -#endif clo = SCRN_BUF_CHARS(screen, screen->cursorp.row)[cursor_col]; flags = SCRN_BUF_ATTRS(screen, screen->cursorp.row)[cursor_col]; if_OPT_WIDE_CHARS(screen, { chi = SCRN_BUF_WIDEC(screen, screen->cursorp.row)[cursor_col]; - if (clo == HIDDEN_LO && chi == HIDDEN_HI) { + if (clo == HIDDEN_LO && chi == HIDDEN_HI && cursor_col > 0) { /* if cursor points to non-initial part of wide character, * back it up */ @@ -7104,10 +7124,38 @@ HideCursor(void) } my_col = cursor_col; base = (chi << 8) | clo; - if (iswide(base)) + if (base == 0) + base = clo = ' '; + if (isWide(base)) my_col += 1; }); + if (base == 0) { + base = clo = ' '; + } + + /* + * 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 + + /* + * Compare the current cell to the last set of colors used for the + * cursor and update the GC's if needed. + */ if_OPT_EXT_COLORS(screen, { fg_bg = PACK_FGBG(screen, screen->cursorp.row, cursor_col); }); @@ -7122,14 +7170,6 @@ HideCursor(void) currentGC = updatedXtermGC(xw, flags, fg_bg, in_selection); - if (clo == 0 -#if OPT_WIDE_CHARS - && chi == 0 -#endif - ) { - clo = ' '; - } - TRACE(("HideCursor calling drawXtermText cur(%d,%d)\n", screen->cursorp.row, screen->cursorp.col)); drawXtermText(xw, flags & DRAWX_MASK, currentGC, @@ -7148,7 +7188,7 @@ HideCursor(void) drawXtermText(xw, (flags & DRAWX_MASK) | NOBACKGROUND, currentGC, x, y, curXtermChrSet(xw, screen->cur_row), - PAIRED_CHARS(&clo, &chi), 1, iswide(base)); + PAIRED_CHARS(&clo, &chi), 1, isWide(base)); } }); #endif @@ -7603,9 +7643,12 @@ HandleIgnore(Widget w, String * params GCC_UNUSED, Cardinal *param_count GCC_UNUSED) { - if (IsXtermWidget(w)) { + XtermWidget xw; + + TRACE(("Handle ignore for %p\n", w)); + if ((xw = getXtermWidget(w)) != 0) { /* do nothing, but check for funny escape sequences */ - (void) SendMousePosition((XtermWidget) w, event); + (void) SendMousePosition(xw, event); } } @@ -7619,11 +7662,12 @@ DoSetSelectedFont(Widget w, unsigned long *length, int *format) { - if (!IsXtermWidget(w) || *type != XA_STRING || *format != 8) { + XtermWidget xw = getXtermWidget(w); + + if ((xw == 0) || *type != XA_STRING || *format != 8) { Bell(XkbBI_MinorError, 0); } else { Boolean failed = False; - XtermWidget xw = (XtermWidget) w; int oldFont = xw->screen.menu_font_number; char *save = xw->screen.MenuFontName(fontMenu_fontsel); char *val; @@ -7683,6 +7727,7 @@ DoSetSelectedFont(Widget w, void FindFontSelection(XtermWidget xw, const char *atom_name, Bool justprobe) { + TScreen *screen = &(xw->screen); static AtomPtr *atoms; unsigned int atomCount = 0; AtomPtr *pAtom; @@ -7690,8 +7735,8 @@ FindFontSelection(XtermWidget xw, const char *atom_name, Bool justprobe) Atom target; if (!atom_name) - atom_name = (xw->screen.mappedSelect - ? xw->screen.mappedSelect[0] + atom_name = (screen->mappedSelect + ? screen->mappedSelect[0] : "PRIMARY"); TRACE(("FindFontSelection(%s)\n", atom_name)); @@ -7707,8 +7752,10 @@ FindFontSelection(XtermWidget xw, const char *atom_name, Bool justprobe) target = XmuInternAtom(XtDisplay(xw), *pAtom); if (justprobe) { - xw->screen.MenuFontName(fontMenu_fontsel) = + screen->MenuFontName(fontMenu_fontsel) = XGetSelectionOwner(XtDisplay(xw), target) ? _Font_Selected_ : 0; + TRACE(("...selected fontname '%s'\n", + NonNull(screen->MenuFontName(fontMenu_fontsel)))); } else { XtGetSelectionValue((Widget) xw, target, XA_STRING, DoSetSelectedFont, NULL, diff --git a/app/xterm/charsets.c b/app/xterm/charsets.c index d3bd79f07..ff8cd8801 100644 --- a/app/xterm/charsets.c +++ b/app/xterm/charsets.c @@ -1,8 +1,8 @@ -/* $XTermId: charsets.c,v 1.40 2008/05/26 22:49:57 tom Exp $ */ +/* $XTermId: charsets.c,v 1.41 2009/01/25 23:39:12 tom Exp $ */ /************************************************************ -Copyright 1998-2007,2008 by Thomas E. Dickey +Copyright 1998-2008,2009 by Thomas E. Dickey All Rights Reserved @@ -308,7 +308,7 @@ xtermCharSetOut(XtermWidget xw, IChar * buf, IChar * ptr, int leftset) if (seven > 0x5f && seven <= 0x7e) { #if OPT_WIDE_CHARS if (screen->utf8_mode) - chr = dec2ucs((unsigned) (seven - 0x5f)); + chr = (int) dec2ucs((unsigned) (seven - 0x5f)); else #endif chr = seven - 0x5f; @@ -476,7 +476,7 @@ xtermCharSetOut(XtermWidget xw, IChar * buf, IChar * ptr, int leftset) */ if (chr == ANSI_DEL) chr = ' '; - *s = A2E(chr); + *s = (IChar) A2E(chr); } TRACE(("%d\t%s\n", count, diff --git a/app/xterm/data.h b/app/xterm/data.h index 2a87e90f9..53bdd4427 100644 --- a/app/xterm/data.h +++ b/app/xterm/data.h @@ -1,9 +1,9 @@ -/* $XTermId: data.h,v 1.105 2007/07/22 16:03:16 tom Exp $ */ +/* $XTermId: data.h,v 1.106 2009/01/24 16:24:06 tom Exp $ */ /* $XFree86: xc/programs/xterm/data.h,v 3.39 2006/02/13 01:14:58 dickey Exp $ */ /* - * Copyright 2002-2006,2007 by Thomas E. Dickey + * Copyright 2002-2007,2009 by Thomas E. Dickey * * All Rights Reserved * @@ -206,6 +206,9 @@ typedef struct XTERM_RESOURCE { #if OPT_TOOLBAR Boolean toolBar; #endif +#if OPT_MAXIMIZE + Boolean maximized; +#endif } XTERM_RESOURCE; extern XTERM_RESOURCE resource; diff --git a/app/xterm/doublechr.c b/app/xterm/doublechr.c index 0c8509e47..a59831ef0 100644 --- a/app/xterm/doublechr.c +++ b/app/xterm/doublechr.c @@ -1,12 +1,8 @@ -/* $XTermId: doublechr.c,v 1.48 2006/07/23 22:06:23 tom Exp $ */ - -/* - * $XFree86: xc/programs/xterm/doublechr.c,v 3.18 2006/02/13 01:14:58 dickey Exp $ - */ +/* $XTermId: doublechr.c,v 1.64 2009/02/12 01:23:54 tom Exp $ */ /************************************************************ -Copyright 1997-2005,2006 by Thomas E. Dickey +Copyright 1997-2008,2009 by Thomas E. Dickey All Rights Reserved @@ -42,6 +38,8 @@ authorization. #include <assert.h> +#define WhichCgsId(flag) (((flag) & BOLD) ? gcCBold : gcCNorm) + /* * The first column is all that matters for double-size characters (since the * controls apply to a whole line). However, it's easier to maintain the @@ -50,14 +48,15 @@ authorization. #define curChrSet SCRN_BUF_CSETS(screen, screen->cur_row)[0] #if OPT_DEC_CHRSET + static void -repaint_line(unsigned newChrSet) +repaint_line(XtermWidget xw, unsigned newChrSet) { - register TScreen *screen = &term->screen; + register TScreen *screen = &xw->screen; int curcol = screen->cur_col; int currow = screen->cur_row; - unsigned len = MaxCols(screen); - int width = len; + int width = MaxCols(screen); + unsigned len = (unsigned) width; unsigned oldChrSet = SCRN_BUF_CSETS(screen, currow)[0]; assert(width > 0); @@ -68,7 +67,9 @@ repaint_line(unsigned newChrSet) if (oldChrSet == newChrSet) return; - TRACE(("repaint_line(%2d,%2d) (%d)\n", currow, screen->cur_col, newChrSet)); + TRACE(("repaint_line(%2d,%2d) (%s -> %s)\n", currow, screen->cur_col, + visibleChrsetName(oldChrSet), + visibleChrsetName(newChrSet))); HideCursor(); /* If switching from single-width, keep the cursor in the visible part @@ -84,19 +85,17 @@ repaint_line(unsigned newChrSet) * ScrnRefresh won't paint blanks for us if we're switching between a * single-size and double-size font. So we paint our own. */ - if (CSET_DOUBLE(oldChrSet) != CSET_DOUBLE(newChrSet)) { - ClearCurBackground(term, - CursorY(screen, currow), - CurCursorX(screen, currow, 0), - (unsigned) FontHeight(screen), - len * CurFontWidth(screen, currow)); - } + ClearCurBackground(xw, + CursorY(screen, currow), + CurCursorX(screen, currow, 0), + (unsigned) FontHeight(screen), + len * (unsigned) CurFontWidth(screen, currow)); /* FIXME: do VT220 softchars allow double-sizes? */ memset(SCRN_BUF_CSETS(screen, currow), (Char) newChrSet, len); set_cur_col(screen, 0); - ScrnUpdate(term, currow, 0, 1, (int) len, True); + ScrnUpdate(xw, currow, 0, 1, (int) len, True); set_cur_col(screen, curcol); } #endif @@ -106,10 +105,10 @@ repaint_line(unsigned newChrSet) * we'll be using it for the top (true) or bottom (false) of the line. */ void -xterm_DECDHL(Bool top) +xterm_DECDHL(XtermWidget xw GCC_UNUSED, Bool top) { #if OPT_DEC_CHRSET - repaint_line((unsigned) (top ? CSET_DHL_TOP : CSET_DHL_BOT)); + repaint_line(xw, (unsigned) (top ? CSET_DHL_TOP : CSET_DHL_BOT)); #else (void) top; #endif @@ -119,10 +118,10 @@ xterm_DECDHL(Bool top) * Set the line to single-width characters (the normal state). */ void -xterm_DECSWL(void) +xterm_DECSWL(XtermWidget xw GCC_UNUSED) { #if OPT_DEC_CHRSET - repaint_line(CSET_SWL); + repaint_line(xw, CSET_SWL); #endif } @@ -130,38 +129,68 @@ xterm_DECSWL(void) * Set the line to double-width characters */ void -xterm_DECDWL(void) +xterm_DECDWL(XtermWidget xw GCC_UNUSED) { #if OPT_DEC_CHRSET - repaint_line(CSET_DWL); + repaint_line(xw, CSET_DWL); #endif } #if OPT_DEC_CHRSET static void -discard_font(TScreen * screen, XTermFonts * data) +discard_font(XtermWidget xw, int n) { + TScreen *screen = &xw->screen; + XTermFonts *data = &(screen->double_fonts[n]); + TRACE(("discard_font chrset=%d %s\n", data->chrset, (data->fn != 0) ? data->fn : "<no-name>")); data->chrset = 0; data->flags = 0; - if (data->gc != 0) { - XFreeGC(screen->display, data->gc); - data->gc = 0; - } if (data->fn != 0) { free(data->fn); data->fn = 0; } - data->fs = xtermCloseFont(screen, data->fs); + (void) xtermCloseFont(xw, data); + + screen->fonts_used -= 1; + while (n < screen->fonts_used) { + screen->double_fonts[n] = screen->double_fonts[n + 1]; + ++n; + } +} + +/* push back existing fonts and create a new entry */ +static XTermFonts * +pushback_font(XtermWidget xw, XTermFonts * source) +{ + TScreen *screen = &xw->screen; + XTermFonts *data = screen->double_fonts; + int n; + + if (screen->fonts_used >= screen->cache_doublesize) { + TRACE(("pushback_font: discard oldest\n")); + discard_font(xw, screen->fonts_used - 1); + } else { + screen->fonts_used += 1; + } + + for (n = screen->fonts_used; n > 0; n--) + data[n] = data[n - 1]; + data[0] = *source; + + TRACE(("pushback_font -> (NEW:%d)\n", screen->fonts_used)); + + return data; } int -xterm_Double_index(unsigned chrset, unsigned flags) +xterm_Double_index(XtermWidget xw, unsigned chrset, unsigned flags) { int n; - TScreen *screen = &term->screen; + int result = -1; + TScreen *screen = &xw->screen; XTermFonts *data = screen->double_fonts; flags &= BOLD; @@ -180,28 +209,12 @@ xterm_Double_index(unsigned chrset, unsigned flags) } data[n] = save; } - return n; + result = n; + break; } } - /* Not, found, push back existing fonts and create a new entry */ - if (screen->fonts_used >= screen->cache_doublesize) { - TRACE(("...xterm_Double_index: discard oldest\n")); - discard_font(screen, &(data[screen->fonts_used - 1])); - } else { - screen->fonts_used += 1; - } - for (n = screen->fonts_used; n > 0; n--) - data[n] = data[n - 1]; - - TRACE(("...xterm_Double_index -> (NEW:%d)\n", screen->fonts_used)); - - data[0].chrset = chrset; - data[0].flags = flags; - data[0].fn = 0; - data[0].fs = 0; - data[0].gc = 0; - return 0; + return result; } /* @@ -209,58 +222,82 @@ xterm_Double_index(unsigned chrset, unsigned flags) * NUM_CHRSET values. */ GC -xterm_DoubleGC(unsigned chrset, unsigned flags, GC old_gc) +xterm_DoubleGC(XtermWidget xw, + unsigned chrset, + unsigned flags, + GC old_gc, + int *inxp) { - XGCValues gcv; - register TScreen *screen = &term->screen; - unsigned long mask = (GCForeground | GCBackground | GCFont); + TScreen *screen = &(xw->screen); + VTwin *cgsWin = WhichVWin(screen); int n; char *name; - XTermFonts *data; + XTermFonts *data = 0; + GC result = 0; + + if ((name = xtermSpecialFont(screen, flags, chrset)) != 0) { + CgsEnum cgsId = WhichCgsId(flags); + Boolean found = False; + + if ((n = xterm_Double_index(xw, chrset, flags)) >= 0) { + data = &(screen->double_fonts[n]); + if (data->fn != 0) { + if (!strcmp(data->fn, name) + && data->fs != 0) { + found = True; + free(name); + } else { + discard_font(xw, n); + } + } + } - if ((name = xtermSpecialFont(screen, flags, chrset)) == 0) - return 0; + if (!found) { + XTermFonts temp; - n = xterm_Double_index(chrset, flags); - data = &(screen->double_fonts[n]); - if (data->fn != 0) { - if (!strcmp(data->fn, name)) { - if (data->fs != 0) { - XCopyGC(screen->display, old_gc, (unsigned long) (~GCFont), data->gc); - return data->gc; + TRACE(("xterm_DoubleGC %s %d: %s\n", + flags & BOLD ? "BOLD" : "NORM", n, name)); + + memset(&temp, 0, sizeof(temp)); + temp.fn = name; + temp.chrset = chrset; + temp.flags = (flags & BOLD); + + if (!xtermOpenFont(xw, name, &temp, fwAlways, False)) { + /* Retry with * in resolutions */ + char *nname = xtermSpecialFont(screen, flags | NORESOLUTION, chrset); + + if (nname != 0) { + found = (Boolean) xtermOpenFont(xw, nname, &temp, + fwAlways, False); + free(nname); + } + } else { + found = True; } - } - discard_font(screen, data); - data->chrset = chrset; - data->flags = flags & BOLD; - } - data->fn = name; + free(name); - TRACE(("xterm_DoubleGC %s %d: %s\n", flags & BOLD ? "BOLD" : "NORM", n, name)); + if (found) { + n = 0; + data = pushback_font(xw, &temp); + } - if ((data->fs = xtermOpenFont(screen, name)) == 0) { - /* Retry with * in resolutions */ - char *nname = xtermSpecialFont(screen, flags | NORESOLUTION, chrset); + TRACE(("-> %s\n", found ? "OK" : "FAIL")); + } - if (!nname) - return 0; - if ((data->fs = xtermOpenFont(screen, nname)) == 0) { - XtFree(nname); - return 0; + if (found) { + setCgsCSet(xw, cgsWin, cgsId, chrset); + setCgsFont(xw, cgsWin, cgsId, data); + setCgsFore(xw, cgsWin, cgsId, getCgsFore(xw, cgsWin, old_gc)); + setCgsBack(xw, cgsWin, cgsId, getCgsBack(xw, cgsWin, old_gc)); + result = getCgsGC(xw, cgsWin, cgsId); + *inxp = n; + } else if (flags & BOLD) { + flags &= ~BOLD; + result = xterm_DoubleGC(xw, chrset, flags, old_gc, inxp); } - XtFree(name); - data->fn = nname; } - TRACE(("-> OK\n")); - - gcv.graphics_exposures = TRUE; /* default */ - gcv.font = data->fs->fid; - gcv.foreground = T_COLOR(screen, TEXT_FG); - gcv.background = T_COLOR(screen, TEXT_BG); - - data->gc = XCreateGC(screen->display, VWindow(screen), mask, &gcv); - XCopyGC(screen->display, old_gc, (unsigned long) (~GCFont), data->gc); - return data->gc; + return result; } #endif diff --git a/app/xterm/fontutils.c b/app/xterm/fontutils.c index 4e401f15b..45133746f 100644 --- a/app/xterm/fontutils.c +++ b/app/xterm/fontutils.c @@ -1,8 +1,8 @@ -/* $XTermId: fontutils.c,v 1.278 2008/12/30 17:32:06 tom Exp $ */ +/* $XTermId: fontutils.c,v 1.300 2009/02/13 01:45:01 tom Exp $ */ /************************************************************ -Copyright 1998-2007,2008 by Thomas E. Dickey +Copyright 1998-2008,2009 by Thomas E. Dickey All Rights Reserved @@ -198,6 +198,21 @@ n_fields(char **source, int start, int stop) return str; } +static Boolean +check_fontname(const char *name) +{ + Boolean result = True; + + if (name == 0) { + TRACE(("fontname missing\n")); + result = False; + } else if (strlen(name) >= MAX_FONTNAME - 1) { + TRACE(("fontname too large: %s\n", name)); + 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. @@ -237,12 +252,9 @@ get_font_name_props(Display * dpy, XFontStruct * fs, char *result) last_name = name; if (result != 0) { - if (strlen(name) < MAX_FONTNAME - 1) { - strcpy(result, name); - } else { - TRACE(("fontname too large: %s\n", name)); + if (!check_fontname(name)) return 0; - } + strcpy(result, name); } /* @@ -492,26 +504,31 @@ xtermSpecialFont(TScreen * screen, unsigned atts, unsigned chrset) static Bool same_font_name(char *pattern, char *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; + 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 { - return False; + int p = x_toupper(*pattern++); + int m = x_toupper(*match++); + if (p != m) + 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 (*pattern == *match); /* both should be NUL */ + return result; } /* @@ -545,12 +562,13 @@ got_bold_font(Display * dpy, XFontStruct * fs, char *requested) static int same_font_size(XtermWidget xw, XFontStruct * nfs, XFontStruct * bfs) { + TScreen *screen = TScreenOf(xw); 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)); - return xw->screen.free_bold_box + return 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) @@ -681,26 +699,45 @@ cache_menu_font_name(TScreen * screen, int fontnum, int which, const char *name) * failure. */ Bool -xtermOpenFont(XtermWidget xw, char *name, XTermFonts * result) +xtermOpenFont(XtermWidget xw, + const char *name, + XTermFonts * result, + fontWarningTypes warn, + Bool force) { Bool code = False; TScreen *screen = TScreenOf(xw); - if (name != 0 - && (result->fs = XLoadQueryFont(screen->display, name)) != 0) { - code = True; - if (EmptyFont(result->fs)) { - result = xtermCloseFont(xw, result); - code = False; - } else { - result->fn = x_strdup(name); + if (name != 0) { + if ((result->fs = XLoadQueryFont(screen->display, name)) != 0) { + code = True; + if (EmptyFont(result->fs)) { + result = xtermCloseFont(xw, result); + code = False; + } else { + result->fn = x_strdup(name); + } + } else if (strcmp(name, DEFFONT)) { + if (warn <= xw->misc.fontWarnings +#if OPT_RENDERFONT + && !UsingRenderFont(xw) +#endif + ) { + TRACE(("OOPS: cannot load font %s\n", name)); + fprintf(stderr, "%s: cannot load font %s\n", ProgramName, name); + } else { + TRACE(("xtermOpenFont: cannot load font %s\n", name)); + } + if (force) { + code = xtermOpenFont(xw, DEFFONT, result, fwAlways, True); + } } } return code; } /* - * Close the font and Free the font info + * Close the font and free the font info. */ XTermFonts * xtermCloseFont(XtermWidget xw, XTermFonts * fnt) @@ -770,7 +807,7 @@ xtermLoadFont(XtermWidget xw, Bool doresize, int fontnum) { - TScreen *screen = &(xw->screen); + TScreen *screen = TScreenOf(xw); VTwin *win = WhichVWin(screen); VTFontNames myfonts; @@ -780,16 +817,39 @@ xtermLoadFont(XtermWidget xw, Pixel new_revers; char *tmpname = NULL; char normal[MAX_FONTNAME]; - Bool proportional = False; + Boolean proportional = False; + fontWarningTypes warn[fMAX]; + int j; memset(&myfonts, 0, sizeof(myfonts)); memset(fnts, 0, sizeof(fnts)); if (fonts != 0) myfonts = *fonts; - if (myfonts.f_n == 0) + if (!check_fontname(myfonts.f_n)) return 0; + /* + * Check the font names against the resource values, to see which were + * derived in a previous call. If so, we'll only warn about those if + * the warning level is set to "always". + */ + for (j = 0; j < fMAX; ++j) { + warn[j] = fwAlways; + } +#define CmpResource(field, index) \ + if (same_font_name(screen->menu_font_names[fontnum][index], myfonts.field)) \ + warn[index] = fwResource + + CmpResource(f_n, fNorm); + if (fontnum == fontMenu_default) { + CmpResource(f_b, fBold); +#if OPT_WIDE_CHARS + CmpResource(f_b, fWide); + CmpResource(f_b, fWBold); +#endif + } + if (fontnum == fontMenu_fontescape && myfonts.f_n != screen->MenuFontName(fontnum)) { if ((tmpname = x_strdup(myfonts.f_n)) == 0) @@ -799,24 +859,30 @@ xtermLoadFont(XtermWidget xw, TRACE(("Begin Cgs - xtermLoadFont(%s)\n", myfonts.f_n)); releaseWindowGCs(xw, win); - TRACE(("xtermLoadFont #%d normal %s\n", fontnum, NonNull(myfonts.f_n))); - TRACE(("xtermLoadFont #%d bold %s\n", fontnum, NonNull(myfonts.f_b))); +#define DbgResource(name, field, index) \ + TRACE(("xtermLoadFont #%d "name" %s%s\n", \ + fontnum, \ + (warn[index] == fwResource) ? "*" : " ", \ + NonNull(myfonts.field))); + DbgResource("normal", f_n, fNorm); + DbgResource("bold ", f_b, fBold); #if OPT_WIDE_CHARS - TRACE(("xtermLoadFont #%d wide %s\n", fontnum, NonNull(myfonts.f_w))); - TRACE(("xtermLoadFont #%d w/bold %s\n", fontnum, NonNull(myfonts.f_wb))); + DbgResource("wide ", f_w, fWide); + DbgResource("w/bold", f_wb, fWBold); #endif - if (!xtermOpenFont(xw, myfonts.f_n, &fnts[fNorm])) + if (!xtermOpenFont(xw, myfonts.f_n, &fnts[fNorm], warn[fNorm], True)) goto bad; strcpy(normal, myfonts.f_n); - if (myfonts.f_b == 0) { + if (!check_fontname(myfonts.f_b)) { + warn[fBold] = fwAlways; fp = get_font_name_props(screen->display, fnts[fNorm].fs, normal); if (fp != 0) { myfonts.f_b = bold_font_name(fp, fp->average_width); - if (!xtermOpenFont(xw, myfonts.f_b, &fnts[fBold])) { + if (!xtermOpenFont(xw, myfonts.f_b, &fnts[fBold], fwAlways, False)) { myfonts.f_b = bold_font_name(fp, -1); - (void) xtermOpenFont(xw, myfonts.f_b, &fnts[fBold]); + xtermOpenFont(xw, myfonts.f_b, &fnts[fBold], fwAlways, False); } TRACE(("...derived bold %s\n", NonNull(myfonts.f_b))); } @@ -832,8 +898,9 @@ xtermLoadFont(XtermWidget xw, fnts[fBold] = fnts[fNorm]; TRACE(("...did not get a matching bold font\n")); } - } else if (!xtermOpenFont(xw, myfonts.f_b, &fnts[fBold])) { + } else if (!xtermOpenFont(xw, myfonts.f_b, &fnts[fBold], warn[fBold], False)) { xtermCopyFontInfo(&fnts[fBold], &fnts[fNorm]); + warn[fBold] = fwAlways; TRACE(("...cannot load bold font %s\n", NonNull(myfonts.f_b))); } else { cache_menu_font_name(screen, fontnum, fBold, myfonts.f_b); @@ -848,35 +915,38 @@ xtermLoadFont(XtermWidget xw, Bool derived; char bold[MAX_FONTNAME]; - if (myfonts.f_w != 0) { + if (check_fontname(myfonts.f_w)) { cache_menu_font_name(screen, fontnum, fWide, myfonts.f_w); } else if (!is_double_width_font(fnts[fNorm].fs)) { fp = get_font_name_props(screen->display, fnts[fNorm].fs, normal); if (fp != 0) { myfonts.f_w = wide_font_name(fp); + warn[fWide] = fwAlways; TRACE(("...derived wide %s\n", NonNull(myfonts.f_w))); cache_menu_font_name(screen, fontnum, fWide, myfonts.f_w); } } - if (myfonts.f_w) { - (void) xtermOpenFont(xw, myfonts.f_w, &fnts[fWide]); + if (check_fontname(myfonts.f_w)) { + (void) xtermOpenFont(xw, myfonts.f_w, &fnts[fWide], warn[fWide], False); } else { xtermCopyFontInfo(&fnts[fWide], &fnts[fNorm]); + warn[fWide] = fwAlways; } derived = False; - if (myfonts.f_wb == 0) { + if (!check_fontname(myfonts.f_wb)) { fp = get_font_name_props(screen->display, fnts[fBold].fs, bold); if (fp != 0) { myfonts.f_wb = widebold_font_name(fp); + warn[fWBold] = fwAlways; derived = True; } } - if (myfonts.f_wb) { + if (check_fontname(myfonts.f_wb)) { - (void) xtermOpenFont(xw, myfonts.f_wb, &fnts[fWBold]); + xtermOpenFont(xw, myfonts.f_wb, &fnts[fWBold], warn[fWBold], False); if (derived && !compatibleWideCounts(fnts[fWide].fs, fnts[fWBold].fs)) { @@ -884,6 +954,7 @@ xtermLoadFont(XtermWidget xw, } if (fnts[fWBold].fs == 0) { myfonts.f_wb = myfonts.f_w; + warn[fWBold] = fwAlways; xtermCopyFontInfo(&fnts[fWBold], &fnts[fWide]); TRACE(("...cannot load wide-bold, use wide %s\n", NonNull(myfonts.f_w))); } else { @@ -894,9 +965,11 @@ xtermLoadFont(XtermWidget xw, } } else if (is_double_width_font(fnts[fBold].fs)) { xtermCopyFontInfo(&fnts[fWBold], &fnts[fBold]); + warn[fWBold] = fwAlways; TRACE(("...bold font is double-width, use it %s\n", NonNull(myfonts.f_b))); } else { xtermCopyFontInfo(&fnts[fWBold], &fnts[fWide]); + warn[fWBold] = fwAlways; TRACE(("...cannot load wide bold font, use wide %s\n", NonNull(myfonts.f_w))); } @@ -1133,7 +1206,7 @@ typedef struct { * correspond to the VT100 resources. */ static Bool -xtermLoadVTFonts(XtermWidget w, char *myName, char *myClass) +xtermLoadVTFonts(XtermWidget xw, char *myName, char *myClass) { static Bool initialized = False; static SubResourceRec original, referenceRec, subresourceRec; @@ -1159,26 +1232,27 @@ xtermLoadVTFonts(XtermWidget w, char *myName, char *myClass) }; Cardinal n, m; Bool status = True; + TScreen *screen = TScreenOf(xw); if (!initialized) { initialized = True; TRACE(("xtermLoadVTFonts saving original\n")); - original.default_font = w->misc.default_font; - COPY_MENU_FONTS(w->screen, original); + original.default_font = xw->misc.default_font; + COPY_MENU_FONTS(xw->screen, original); } if (myName == 0 || *myName == 0) { TRACE(("xtermLoadVTFonts restoring original\n")); - w->misc.default_font = original.default_font; - COPY_MENU_FONTS(original, w->screen); + xw->misc.default_font = original.default_font; + COPY_MENU_FONTS(original, xw->screen); for (n = 0; n < XtNumber(original.menu_font_names); ++n) - w->screen.MenuFontName(n) = original.MenuFontName(n); + screen->MenuFontName(n) = original.MenuFontName(n); } else { TRACE(("xtermLoadVTFonts(%s, %s)\n", myName, myClass)); memset(&subresourceRec, 0, sizeof(subresourceRec)); - XtGetSubresources((Widget) w, (XtPointer) &subresourceRec, + XtGetSubresources((Widget) xw, (XtPointer) &subresourceRec, myName, myClass, font_resources, (Cardinal) XtNumber(font_resources), @@ -1189,25 +1263,25 @@ xtermLoadVTFonts(XtermWidget w, char *myName, char *myClass) /* * If a particular resource value was not found, use the original. */ - MERGE_SUBFONT(w->misc, subresourceRec, default_font.f_n); - MERGE_SUBFONT(w->misc, subresourceRec, default_font.f_b); + MERGE_SUBFONT(xw->misc, subresourceRec, default_font.f_n); + MERGE_SUBFONT(xw->misc, subresourceRec, default_font.f_b); #if OPT_WIDE_CHARS - MERGE_SUBFONT(w->misc, subresourceRec, default_font.f_w); - MERGE_SUBFONT(w->misc, subresourceRec, default_font.f_wb); + MERGE_SUBFONT(xw->misc, subresourceRec, default_font.f_w); + MERGE_SUBFONT(xw->misc, subresourceRec, default_font.f_wb); #endif for (n = fontMenu_font1; n <= fontMenu_lastBuiltin; ++n) - MERGE_SUBFONT(w->screen, subresourceRec, MenuFontName(n)); + MERGE_SUBFONT(xw->screen, subresourceRec, MenuFontName(n)); /* * Finally, copy the subresource data to the widget. */ - w->misc.default_font = subresourceRec.default_font; - COPY_MENU_FONTS(subresourceRec, w->screen); - w->screen.MenuFontName(fontMenu_default) = w->misc.default_font.f_n; - w->screen.menu_font_names[0][fBold] = w->misc.default_font.f_b; + xw->misc.default_font = subresourceRec.default_font; + COPY_MENU_FONTS(subresourceRec, xw->screen); + screen->MenuFontName(fontMenu_default) = xw->misc.default_font.f_n; + screen->menu_font_names[0][fBold] = xw->misc.default_font.f_b; #if OPT_WIDE_CHARS - w->screen.menu_font_names[0][fWide] = w->misc.default_font.f_w; - w->screen.menu_font_names[0][fWBold] = w->misc.default_font.f_wb; + screen->menu_font_names[0][fWide] = xw->misc.default_font.f_w; + screen->menu_font_names[0][fWBold] = xw->misc.default_font.f_wb; #endif } else { TRACE(("...no resources found\n")); @@ -1246,7 +1320,7 @@ isWideFont(XFontStruct * fp, char *tag, Bool nullOk) Bool xtermLoadWideFonts(XtermWidget xw, Bool nullOk) { - TScreen *screen = &(xw->screen); + TScreen *screen = TScreenOf(xw); Bool result; if (EmptyFont(screen->fnts[fWide].fs)) { @@ -1273,10 +1347,10 @@ xtermLoadWideFonts(XtermWidget xw, Bool nullOk) * Restore the default fonts, i.e., if we had switched to wide-fonts. */ Bool -xtermLoadDefaultFonts(XtermWidget w) +xtermLoadDefaultFonts(XtermWidget xw) { Bool result; - result = xtermLoadVTFonts(w, NULL, NULL); + result = xtermLoadVTFonts(xw, NULL, NULL); TRACE(("xtermLoadDefaultFonts:%d\n", result)); return result; } @@ -1291,8 +1365,10 @@ HandleLoadVTFonts(Widget w, { static char empty[] = ""; /* appease strict compilers */ - if (IsXtermWidget(w)) { - XtermWidget xw = (XtermWidget) w; + XtermWidget xw; + + if ((xw = getXtermWidget(w)) != 0) { + TScreen *screen = TScreenOf(xw); char buf[80]; char *myName = (*param_count > 0) ? params[0] : empty; char *convert = (*param_count > 1) ? params[1] : myName; @@ -1310,11 +1386,11 @@ HandleLoadVTFonts(Widget w, * it is less surprising to do that (if the font-switching can be * undone) than to switch to "Default". */ - int font_number = xw->screen.menu_font_number; + int font_number = screen->menu_font_number; if (font_number > fontMenu_lastBuiltin) font_number = fontMenu_lastBuiltin; for (n = 0; n < NMENUFONTS; ++n) - xw->screen.menu_font_sizes[n] = 0; + screen->menu_font_sizes[n] = 0; SetVTFont(xw, font_number, True, ((font_number == fontMenu_default) ? &(xw->misc.default_font) @@ -1360,8 +1436,10 @@ xtermSetCursorBox(TScreen * screen) #if OPT_RENDERFONT static XftFont * -xtermOpenXft(Display * dpy, XftPattern * pat, const char *tag GCC_UNUSED) +xtermOpenXft(XtermWidget xw, const char *name, XftPattern * pat, const char *tag) { + TScreen *screen = TScreenOf(xw); + Display *dpy = screen->display; XftPattern *match; XftResult status; XftFont *result = 0; @@ -1375,9 +1453,19 @@ xtermOpenXft(Display * dpy, XftPattern * pat, const char *tag GCC_UNUSED) } 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)); + fprintf(stderr, "%s: cannot open %s font \"%s\"\n", + ProgramName, 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)); + fprintf(stderr, "%s: cannot match %s font \"%s\"\n", + ProgramName, tag, name); + } } } return result; @@ -1471,7 +1559,7 @@ xtermComputeFontInfo(XtermWidget xw, XFontStruct * font, int sbwidth) { - TScreen *screen = &(xw->screen); + TScreen *screen = TScreenOf(xw); int i, j, width, height; @@ -1484,7 +1572,6 @@ xtermComputeFontInfo(XtermWidget xw, * overrides it. */ if (xw->misc.render_font && !IsIconWin(screen, win)) { - Display *dpy = screen->display; int fontnum = screen->menu_font_number; XftFont *norm = screen->renderFontNorm[fontnum]; XftFont *bold = screen->renderFontBold[fontnum]; @@ -1555,7 +1642,7 @@ xtermComputeFontInfo(XtermWidget xw, break; } #endif - xw->misc.face_size[fontnum] = face_size; + xw->misc.face_size[fontnum] = (float) face_size; } /* @@ -1577,16 +1664,17 @@ xtermComputeFontInfo(XtermWidget xw, XFT_CHAR_WIDTH, XftTypeInteger, norm->max_advance_width if ((pat = XftNameParse(xw->misc.face_name)) != 0) { +#define OPEN_XFT(tag) xtermOpenXft(xw, xw->misc.face_name, pat, tag) XftPatternBuild(pat, NormXftPattern, (void *) 0); - norm = xtermOpenXft(dpy, pat, "normal"); + norm = OPEN_XFT("normal"); if (norm != 0) { XftPatternBuild(pat, BoldXftPattern(norm), (void *) 0); - bold = xtermOpenXft(dpy, pat, "bold"); + bold = OPEN_XFT("bold"); #if OPT_ISO_COLORS if (screen->italicULMode @@ -1595,9 +1683,10 @@ xtermComputeFontInfo(XtermWidget xw, NormXftPattern, ItalXftPattern(norm), (void *) 0); - ital = xtermOpenXft(dpy, pat, "italic"); + ital = OPEN_XFT("italic"); } #endif /* OPT_ISO_COLORS */ +#undef OPEN_XFT /* * FIXME: just assume that the corresponding font has no @@ -1637,18 +1726,19 @@ xtermComputeFontInfo(XtermWidget xw, XFT_SPACING, XftTypeInteger, XFT_MONO if ((pat = XftNameParse(face_name)) != 0) { +#define OPEN_XFT(tag) xtermOpenXft(xw, face_name, pat, tag) XftPatternBuild(pat, WideXftPattern, XFT_CHAR_WIDTH, XftTypeInteger, char_width, (void *) 0); - wnorm = xtermOpenXft(dpy, pat, "wide"); + wnorm = OPEN_XFT("wide"); if (wnorm != 0) { XftPatternBuild(pat, WideXftPattern, BoldXftPattern(wnorm), (void *) 0); - wbold = xtermOpenXft(dpy, pat, "wide-bold"); + wbold = OPEN_XFT("wide-bold"); #if OPT_ISO_COLORS if (screen->italicULMode @@ -1657,9 +1747,10 @@ xtermComputeFontInfo(XtermWidget xw, WideXftPattern, ItalXftPattern(wnorm), (void *) 0); - wital = xtermOpenXft(dpy, pat, "wide-italic"); + wital = OPEN_XFT("wide-italic"); } #endif +#undef OPEN_XFT } XftPatternDestroy(pat); } @@ -1700,8 +1791,8 @@ xtermComputeFontInfo(XtermWidget xw, j = 2 * screen->border; width = MaxCols(screen) * win->f_width + i; height = MaxRows(screen) * win->f_height + j; - win->fullwidth = width; - win->fullheight = height; + win->fullwidth = (Dimension) width; + win->fullheight = (Dimension) height; win->width = width - i; win->height = height - j; @@ -1720,8 +1811,8 @@ xtermComputeFontInfo(XtermWidget xw, void xtermSaveFontInfo(TScreen * screen, XFontStruct * font) { - screen->fnt_wide = (font->max_bounds.width); - screen->fnt_high = (font->ascent + font->descent); + 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)); } @@ -1731,7 +1822,7 @@ xtermSaveFontInfo(TScreen * screen, XFontStruct * font) void xtermUpdateFontInfo(XtermWidget xw, Bool doresize) { - TScreen *screen = &(xw->screen); + TScreen *screen = TScreenOf(xw); int scrollbar_width; VTwin *win = &(screen->fullVwin); @@ -1767,6 +1858,8 @@ xtermUpdateFontInfo(XtermWidget xw, Bool doresize) Bool xtermMissingChar(XtermWidget xw, unsigned ch, XFontStruct * font) { + TScreen *screen = TScreenOf(xw); + if (font != 0 && font->per_char != 0 && !font->all_chars_exist) { @@ -1797,7 +1890,7 @@ xtermMissingChar(XtermWidget xw, unsigned ch, XFontStruct * font) } } if (xtermIsDecGraphic(ch) - && xw->screen.force_box_chars) { + && screen->force_box_chars) { TRACE(("xtermMissingChar %#04x (forced off)\n", ch)); return True; } @@ -1820,8 +1913,8 @@ xtermMissingChar(XtermWidget xw, unsigned ch, XFontStruct * font) /* * ...since we'll scale the values anyway. */ -#define SCALE_X(n) n = (n * (font_width-1)) / (BOX_WIDE-1) -#define SCALE_Y(n) n = (n * (font_height-1)) / (BOX_HIGH-1) +#define SCALE_X(n) n = (n * (((int) font_width) - 1)) / (BOX_WIDE-1) +#define SCALE_Y(n) n = (n * (((int) font_height) - 1)) / (BOX_HIGH-1) #define SEG(x0,y0,x1,y1) x0,y0, x1,y1 @@ -1838,7 +1931,7 @@ xtermDrawBoxChar(XtermWidget xw, int y, int cells) { - TScreen *screen = &(xw->screen); + 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 */ @@ -2017,11 +2110,11 @@ xtermDrawBoxChar(XtermWidget xw, CgsEnum cgsId = (ch == 2) ? gcDots : gcLine; VTwin *cgsWin = WhichVWin(screen); const short *p; - unsigned font_width = ((flags & DOUBLEWFONT) ? 2 : 1) * screen->fnt_wide; - unsigned font_height = ((flags & DOUBLEHFONT) ? 2 : 1) * screen->fnt_high; + unsigned font_width = (unsigned) (((flags & DOUBLEWFONT) ? 2 : 1) * screen->fnt_wide); + unsigned font_height = (unsigned) (((flags & DOUBLEHFONT) ? 2 : 1) * screen->fnt_high); if (cells > 1) - font_width *= cells; + font_width *= (unsigned) cells; #if OPT_WIDE_CHARS /* @@ -2121,8 +2214,8 @@ xtermDrawBoxChar(XtermWidget xw, Convex, CoordModeOrigin); } else if (ch == 7) { /* degrees */ unsigned width = (BOX_WIDE / 3); - int x_coord = MID_WIDE - (width / 2); - int y_coord = MID_HIGH - width; + int x_coord = MID_WIDE - (int) (width / 2); + int y_coord = MID_HIGH - (int) width; SCALE_X(x_coord); SCALE_Y(y_coord); @@ -2135,8 +2228,8 @@ xtermDrawBoxChar(XtermWidget xw, 360 * 64); } else if (ch == 0x1f) { /* bullet */ unsigned width = 7 * BOX_WIDE / 10; - int x_coord = MID_WIDE - (width / 3); - int y_coord = MID_HIGH - (width / 3); + int x_coord = MID_WIDE - (int) (width / 3); + int y_coord = MID_HIGH - (int) (width / 3); SCALE_X(x_coord); SCALE_Y(y_coord); @@ -2149,7 +2242,7 @@ xtermDrawBoxChar(XtermWidget xw, 360 * 64); } else if (ch < (sizeof(lines) / sizeof(lines[0])) && (p = lines[ch]) != 0) { - unsigned coord[4]; + int coord[4]; int n = 0; while (*p >= 0) { coord[n++] = *p++; @@ -2186,7 +2279,8 @@ xtermXftMissing(XtermWidget xw, XftFont * font, unsigned wc) Bool result = False; if (font != 0) { - if (!XftGlyphExists(xw->screen.display, font, wc)) { + TScreen *screen = TScreenOf(xw); + if (!XftGlyphExists(screen->display, font, wc)) { #if OPT_WIDE_CHARS TRACE(("xtermXftMissing %d (dec=%#x, ucs=%#x)\n", wc, ucs2dec(wc), dec2ucs(wc))); @@ -2307,7 +2401,7 @@ lookupOneFontSize(XtermWidget xw, int fontnum) memset(&fnt, 0, sizeof(fnt)); screen->menu_font_sizes[fontnum] = -1; - if (xtermOpenFont(xw, screen->MenuFontName(fontnum), &fnt)) { + if (xtermOpenFont(xw, screen->MenuFontName(fontnum), &fnt, fwAlways, True)) { screen->menu_font_sizes[fontnum] = FontSize(fnt.fs); TRACE(("menu_font_sizes[%d] = %ld\n", fontnum, screen->menu_font_sizes[fontnum])); @@ -2345,6 +2439,56 @@ useFaceSizes(XtermWidget xw) break; } } + if (!result) { + Boolean broken_fonts = True; + TScreen *screen = TScreenOf(xw); + int first = screen->menu_font_sizes[0]; + + lookupFontSizes(xw); + for (n = 0; n < NMENUFONTS; n++) { + if (screen->menu_font_sizes[n] > 0 + && screen->menu_font_sizes[n] != first) { + broken_fonts = False; + break; + } + } + + /* + * Workaround for breakage in font-packages - check if all of the + * bitmap font sizes are the same, and if we're using TrueType + * fonts. + */ + if (broken_fonts) { + float lo_value = (float) 9.0e9; + float hi_value = (float) 0.0; + float value; + + TRACE(("bitmap fonts are broken - set faceSize resources\n")); + for (n = 0; n < NMENUFONTS; n++) { + value = xw->misc.face_size[n]; + if (value > 0.0) { + if (lo_value > value) + lo_value = value; + if (hi_value < value) + hi_value = value; + } + } + + if (hi_value <= 0.0) + sscanf(DEFFACESIZE, "%f", &value); + else + value = (float) ((hi_value + lo_value) / 2.0); + if (value <= 0) + value = (float) 14.0; + + for (n = 0; n < NMENUFONTS; n++) { + TRACE(("setting faceSize%d %.1f\n", n, value)); + xw->misc.face_size[n] = value; + value = (float) (value * 1.1); + } + result = True; + } + } } return result; } @@ -2430,11 +2574,12 @@ HandleLargerFont(Widget w GCC_UNUSED, String * params GCC_UNUSED, Cardinal *param_count GCC_UNUSED) { - if (IsXtermWidget(w)) { - XtermWidget xw = (XtermWidget) w; + XtermWidget xw; + TRACE(("Handle larger-vt-font for %p\n", w)); + if ((xw = getXtermWidget(w)) != 0) { if (xw->misc.shift_fonts) { - TScreen *screen = &xw->screen; + TScreen *screen = TScreenOf(xw); int m; m = lookupRelativeFontSize(xw, screen->menu_font_number, 1); @@ -2454,11 +2599,12 @@ HandleSmallerFont(Widget w GCC_UNUSED, String * params GCC_UNUSED, Cardinal *param_count GCC_UNUSED) { - if (IsXtermWidget(w)) { - XtermWidget xw = (XtermWidget) w; + XtermWidget xw; + TRACE(("Handle smaller-vt-font for %p\n", w)); + if ((xw = getXtermWidget(w)) != 0) { if (xw->misc.shift_fonts) { - TScreen *screen = &xw->screen; + TScreen *screen = TScreenOf(xw); int m; m = lookupRelativeFontSize(xw, screen->menu_font_number, -1); @@ -2523,7 +2669,9 @@ HandleSetFont(Widget w GCC_UNUSED, String * params, Cardinal *param_count) { - if (IsXtermWidget(w)) { + XtermWidget xw; + + if ((xw = getXtermWidget(w)) != 0) { int fontnum; VTFontNames fonts; @@ -2582,7 +2730,7 @@ HandleSetFont(Widget w GCC_UNUSED, } } - SetVTFont((XtermWidget) w, fontnum, True, &fonts); + SetVTFont(xw, fontnum, True, &fonts); } } @@ -2592,7 +2740,7 @@ SetVTFont(XtermWidget xw, Bool doresize, const VTFontNames * fonts) { - TScreen *screen = &xw->screen; + TScreen *screen = TScreenOf(xw); TRACE(("SetVTFont(which=%d, f_n=%s, f_b=%s)\n", which, (fonts && fonts->f_n) ? fonts->f_n : "<null>", diff --git a/app/xterm/fontutils.h b/app/xterm/fontutils.h index 8477a5c94..d30c62754 100644 --- a/app/xterm/fontutils.h +++ b/app/xterm/fontutils.h @@ -1,12 +1,8 @@ -/* $XTermId: fontutils.h,v 1.57 2006/02/13 01:14:59 tom Exp $ */ - -/* - * $XFree86: xc/programs/xterm/fontutils.h,v 1.17 2006/02/13 01:14:59 dickey Exp $ - */ +/* $XTermId: fontutils.h,v 1.71 2009/02/13 01:36:41 tom Exp $ */ /************************************************************ -Copyright 1998-2005,2006 by Thomas E. Dickey +Copyright 1998-2008,2009 by Thomas E. Dickey All Rights Reserved @@ -41,20 +37,21 @@ authorization. #include <xterm.h> -extern Bool xtermLoadDefaultFonts (XtermWidget /* w */); -extern XFontStruct * xtermOpenFont (TScreen * /* screen */, char */* name */); -extern XFontStruct * xtermCloseFont(TScreen * /* screen */, XFontStruct * /* fnt */); +extern Bool xtermLoadDefaultFonts (XtermWidget /* xw */); +extern Bool xtermOpenFont (XtermWidget /* xw */, const char */* name */, XTermFonts * /* result */, fontWarningTypes /* warn */, Bool /* force */); +extern XTermFonts * xtermCloseFont (XtermWidget /* xw */, XTermFonts * /* fnt */); extern const VTFontNames * xtermFontName (char */* normal */); -extern int lookupRelativeFontSize (TScreen * /* screen */, int /* old */, int /* relative */); -extern int xtermLoadFont (XtermWidget /* xw */, - const VTFontNames */* fonts */, - Bool /* doresize */, int /* fontnum */); +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 xtermCloseFonts(TScreen * /* screen */, XFontStruct ** /* fnts[fMAX] */); -extern void xtermComputeFontInfo (XtermWidget /* xw */, struct _vtwin */* win */, XFontStruct */* font */, int /* sbwidth */); -extern void xtermSaveFontInfo (TScreen */* screen */, XFontStruct */* font */); -extern void xtermSetCursorBox (TScreen */* screen */); +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 xtermUpdateFontInfo (XtermWidget /* xw */, Bool /* doresize */); #if OPT_DEC_CHRSET @@ -63,7 +60,7 @@ extern char *xtermSpecialFont (TScreen */* screen */, unsigned /* atts */, unsig #if OPT_BOX_CHARS extern Bool xtermMissingChar (XtermWidget /* xw */, unsigned /* ch */, XFontStruct */* font */); -extern void xtermDrawBoxChar (XtermWidget /* xw */, unsigned /* ch */, unsigned /* flags */, GC /* gc */, int /* x */, int /* y */); +extern void xtermDrawBoxChar (XtermWidget /* xw */, unsigned /* ch */, unsigned /* flags */, GC /* gc */, int /* x */, int /* y */, int /* cols */); #endif #if OPT_LOAD_VTFONTS @@ -76,8 +73,7 @@ extern Bool xtermLoadWideFonts (XtermWidget /* w */, Bool /* nullOk */); #define xtermIsDecGraphic(ch) ((ch) > 0 && (ch) < 32) -#if OPT_RENDERFONT && OPT_WIDE_CHARS -extern Bool xtermIsLineDrawing (unsigned /* wc */); +#if OPT_RENDERFONT extern Bool xtermXftMissing (XtermWidget /* xw */, XftFont * /* font */, unsigned /* wc */); #endif diff --git a/app/xterm/input.c b/app/xterm/input.c index 5603806a4..76e48c4cd 100644 --- a/app/xterm/input.c +++ b/app/xterm/input.c @@ -1,4 +1,4 @@ -/* $XTermId: input.c,v 1.303 2009/01/08 23:28:36 tom Exp $ */ +/* $XTermId: input.c,v 1.304 2009/01/26 00:09:29 tom Exp $ */ /* * Copyright 1999-2008,2009 by Thomas E. Dickey @@ -354,10 +354,10 @@ allowModifierParm(XtermWidget xw, KEY_DATA * kd) #define MODIFIER_NAME(parm, name) \ (((parm > UNMOD) && ((parm - UNMOD) & name)) ? " "#name : "") -int +unsigned xtermParamToState(XtermWidget xw, unsigned param) { - int result = 0; + unsigned result = 0; #if OPT_NUM_LOCK if (param > UNMOD && ((ShiftMask @@ -386,10 +386,10 @@ xtermParamToState(XtermWidget xw, unsigned param) return result; } -int +unsigned xtermStateToParam(XtermWidget xw, unsigned state) { - int modify_parm = UNMOD; + unsigned modify_parm = UNMOD; #if OPT_NUM_LOCK if ((state & xw->misc.other_mods) == 0) { @@ -532,7 +532,7 @@ static Bool ModifyOtherKeys(XtermWidget xw, unsigned state, KEY_DATA * kd, - int modify_parm) + unsigned modify_parm) { TKeyboard *keyboard = &(xw->keyboard); Bool result = False; @@ -642,8 +642,8 @@ ModifyOtherKeys(XtermWidget xw, } #define APPEND_PARM(number) \ - reply->a_param[(int) reply->a_nparam] = number, \ - reply->a_nparam += 1 + reply->a_param[reply->a_nparam] = (ParmType) number; \ + reply->a_nparam++ /* * Function-key code 27 happens to not be used in the vt220-style encoding. @@ -652,7 +652,7 @@ ModifyOtherKeys(XtermWidget xw, * for more information. */ static Bool -modifyOtherKey(ANSI * reply, int input_char, int modify_parm, int format_keys) +modifyOtherKey(ANSI * reply, int input_char, unsigned modify_parm, int format_keys) { Bool result = False; @@ -675,7 +675,7 @@ modifyOtherKey(ANSI * reply, int input_char, int modify_parm, int format_keys) } static void -modifyCursorKey(ANSI * reply, int modify, int *modify_parm) +modifyCursorKey(ANSI * reply, int modify, unsigned *modify_parm) { if (*modify_parm > 1) { if (modify < 0) { @@ -758,8 +758,8 @@ TranslateFromSUNPC(KeySym keysym) #undef APPEND_PARM #define APPEND_PARM(number) \ - reply.a_param[(int) reply.a_nparam] = number, \ - reply.a_nparam += 1 + reply.a_param[reply.a_nparam] = (ParmType) number, \ + reply.a_nparam++ #if OPT_MOD_FKEYS #define MODIFIER_PARM \ @@ -812,7 +812,7 @@ Input(XtermWidget xw, int key = False; ANSI reply; int dec_code; - int modify_parm = 0; + unsigned modify_parm = 0; int keypad_mode = ((keyboard->flags & MODE_DECKPAM) != 0); unsigned evt_state = event->state; unsigned mod_state; @@ -1158,7 +1158,7 @@ Input(XtermWidget xw, } MODIFIER_PARM; #endif - reply.a_param[0] = dec_code; + reply.a_param[0] = (ParmType) dec_code; reply.a_final = '~'; } if (reply.a_final != 0 @@ -1582,7 +1582,7 @@ static void sunfuncvalue(ANSI * reply, KEY_DATA * kd) { #if OPT_SUN_FUNC_KEYS - int result; + ParmType result; if (kd->is_fkey) { switch (kd->keysym) { @@ -1873,7 +1873,7 @@ VTInitModifiers(XtermWidget xw) XDisplayKeycodes(dpy, &min_keycode, &max_keycode); keycode_count = (max_keycode - min_keycode + 1); theMap = XGetKeyboardMapping(dpy, - min_keycode, + (KeyCode) min_keycode, keycode_count, &keysyms_per_keycode); diff --git a/app/xterm/main.c b/app/xterm/main.c index 43af0f2af..9552cb816 100644 --- a/app/xterm/main.c +++ b/app/xterm/main.c @@ -1,4 +1,4 @@ -/* $XTermId: main.c,v 1.588 2008/09/14 15:20:31 Paul.Lampert Exp $ */ +/* $XTermId: main.c,v 1.589 2009/01/24 16:08:01 tom Exp $ */ /* * W A R N I N G @@ -15,7 +15,7 @@ /*********************************************************** -Copyright 2002-2007,2008 by Thomas E. Dickey +Copyright 2002-2008,2009 by Thomas E. Dickey All Rights Reserved @@ -888,6 +888,9 @@ static XtResource application_resources[] = #if OPT_TOOLBAR Bres(XtNtoolBar, XtCToolBar, toolBar, True), #endif +#if OPT_MAXIMIZE + Bres(XtNmaximized, XtCMaximized, maximized, False), +#endif }; static char *fallback_resources[] = @@ -1080,6 +1083,10 @@ static XrmOptionDescRec optionDescList[] = { {"-tb", "*"XtNtoolBar, XrmoptionNoArg, (caddr_t) "on"}, {"+tb", "*"XtNtoolBar, XrmoptionNoArg, (caddr_t) "off"}, #endif +#if OPT_MAXIMIZE +{"-maximized", "*maximized", XrmoptionNoArg, (caddr_t) "on"}, +{"+maximized", "*maximized", XrmoptionNoArg, (caddr_t) "off"}, +#endif /* options that we process ourselves */ {"-help", NULL, XrmoptionSkipNArgs, (caddr_t) NULL}, {"-version", NULL, XrmoptionSkipNArgs, (caddr_t) NULL}, @@ -1252,6 +1259,9 @@ static OptionHelp xtermOptions[] = { #if OPT_SESSION_MGT { "-/+sm", "turn on/off the session-management support" }, #endif +#if OPT_MAXIMIZE +{"-/+maximized", "turn on/off maxmize on startup" }, +#endif { NULL, NULL }}; /* *INDENT-ON* */ @@ -2396,6 +2406,10 @@ main(int argc, char *argv[]ENVP_ARG) ReverseVideo(term); #endif /* OPT_COLOR_RES */ +#if OPT_MAXIMIZE + if (resource.maximized) + RequestMaximize(term, True); +#endif for (;;) { #if OPT_TEK4014 if (TEK4014_ACTIVE(term)) diff --git a/app/xterm/main.h b/app/xterm/main.h index 8f51070db..3e0cb33f8 100644 --- a/app/xterm/main.h +++ b/app/xterm/main.h @@ -1,7 +1,7 @@ -/* $XTermId: main.h,v 1.38 2008/01/27 17:40:31 tom Exp $ */ +/* $XTermId: main.h,v 1.39 2009/02/08 18:03:56 tom Exp $ */ /* - * Copyright 2000-2007,2008 by Thomas E. Dickey + * Copyright 2000-2008,2009 by Thomas E. Dickey * * All Rights Reserved * @@ -72,7 +72,7 @@ #endif #ifndef DEFXIMFONT -#define DEFXIMFONT "*" +#define DEFXIMFONT "fixed" #endif #ifndef DEFBOLDFONT diff --git a/app/xterm/menu.c b/app/xterm/menu.c index 257d8df5a..42c9642af 100644 --- a/app/xterm/menu.c +++ b/app/xterm/menu.c @@ -1,8 +1,8 @@ -/* $XTermId: menu.c,v 1.241 2008/06/03 20:05:49 tom Exp $ */ +/* $XTermId: menu.c,v 1.246 2009/02/13 19:56:04 tom Exp $ */ /* -Copyright 1999-2007,2008 by Thomas E. Dickey +Copyright 1999-2008,2009 by Thomas E. Dickey All Rights Reserved @@ -113,6 +113,8 @@ in this Software without prior written authorization from The Open Group. #include <stdio.h> #include <signal.h> + +#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; @@ -160,6 +162,14 @@ static void do_logging PROTO_XT_CALLBACK_ARGS; 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_allowTcapOps PROTO_XT_CALLBACK_ARGS; +static void do_allowFontOps 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 @@ -360,6 +370,14 @@ MenuEntry fontMenuEntries[] = { #endif #endif /* toggles for other font extensions */ +#if OPT_ALLOW_XXX_OPS + { "line3", NULL, NULL }, + { "allow-tcap-ops", do_allowTcapOps,NULL }, + { "allow-font-ops", do_allowFontOps,NULL }, + { "allow-title-ops",do_allowTitleOps,NULL }, + { "allow-window-ops",do_allowWindowOps,NULL }, +#endif + }; #if OPT_TEK4014 @@ -479,7 +497,7 @@ create_menu(Widget w, XtermWidget xtw, MenuIndex num) MenuHeader *data = &menu_names[num]; MenuList *list = select_menu(w, num); struct _MenuEntry *entries = data->entry_list; - int nentries = data->entry_len; + Cardinal nentries = data->entry_len; #if !OPT_TOOLBAR String saveLocale; #endif @@ -720,6 +738,13 @@ domenu(Widget w, update_font_utf8_mode(); update_font_utf8_title(); #endif +#if OPT_ALLOW_XXX_OPS + update_menu_allowTcapOps(); + update_menu_allowFontOps(); + update_menu_allowTitleOps(); + update_menu_allowWindowOps(); + enable_allow_xxx_ops(!(screen->allowSendEvents)); +#endif } FindFontSelection(term, NULL, True); SetItemSensitivity( @@ -848,8 +873,11 @@ do_allowsends(Widget gw GCC_UNUSED, { TScreen *screen = TScreenOf(term); - screen->allowSendEvents = !screen->allowSendEvents; + ToggleFlag(screen->allowSendEvents); update_allowsends(); +#if OPT_ALLOW_XXX_OPS + enable_allow_xxx_ops(!(screen->allowSendEvents)); +#endif } static void @@ -859,7 +887,7 @@ do_visualbell(Widget gw GCC_UNUSED, { TScreen *screen = TScreenOf(term); - screen->visualbell = !screen->visualbell; + ToggleFlag(screen->visualbell); update_visualbell(); } @@ -870,7 +898,7 @@ do_bellIsUrgent(Widget gw GCC_UNUSED, { TScreen *screen = TScreenOf(term); - screen->bellIsUrgent = !screen->bellIsUrgent; + ToggleFlag(screen->bellIsUrgent); update_bellIsUrgent(); } @@ -881,7 +909,7 @@ do_poponbell(Widget gw GCC_UNUSED, { TScreen *screen = TScreenOf(term); - screen->poponbell = !screen->poponbell; + ToggleFlag(screen->poponbell); update_poponbell(); } @@ -930,7 +958,7 @@ void show_8bit_control(Bool value) { if (term->screen.control_eight_bits != value) { - term->screen.control_eight_bits = value; + term->screen.control_eight_bits = (Boolean) value; update_8bit_control(); } } @@ -958,7 +986,7 @@ do_num_lock(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { - term->misc.real_NumLock = !term->misc.real_NumLock; + ToggleFlag(term->misc.real_NumLock); update_num_lock(); } @@ -967,7 +995,7 @@ do_alt_esc(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { - term->screen.alt_sends_esc = !term->screen.alt_sends_esc; + ToggleFlag(term->screen.alt_sends_esc); update_alt_esc(); } @@ -976,7 +1004,7 @@ do_meta_esc(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { - term->screen.meta_sends_esc = !term->screen.meta_sends_esc; + ToggleFlag(term->screen.meta_sends_esc); update_meta_esc(); } #endif @@ -1215,7 +1243,7 @@ do_scrollkey(Widget gw GCC_UNUSED, { TScreen *screen = TScreenOf(term); - screen->scrollkey = !screen->scrollkey; + ToggleFlag(screen->scrollkey); update_scrollkey(); } @@ -1226,7 +1254,7 @@ do_scrollttyoutput(Widget gw GCC_UNUSED, { TScreen *screen = TScreenOf(term); - screen->scrollttyoutput = !screen->scrollttyoutput; + ToggleFlag(screen->scrollttyoutput); update_scrollttyoutput(); } @@ -1237,7 +1265,7 @@ do_keepSelection(Widget gw GCC_UNUSED, { TScreen *screen = TScreenOf(term); - screen->keepSelection = !screen->keepSelection; + ToggleFlag(screen->keepSelection); update_keepSelection(); } @@ -1248,7 +1276,7 @@ do_selectClipboard(Widget gw GCC_UNUSED, { TScreen *screen = TScreenOf(term); - screen->selectToClipboard = !screen->selectToClipboard; + ToggleFlag(screen->selectToClipboard); update_selectToClipboard(); } @@ -1259,7 +1287,7 @@ do_allow132(Widget gw GCC_UNUSED, { TScreen *screen = TScreenOf(term); - screen->c132 = !screen->c132; + ToggleFlag(screen->c132); update_allow132(); } @@ -1270,7 +1298,7 @@ do_cursesemul(Widget gw GCC_UNUSED, { TScreen *screen = TScreenOf(term); - screen->curses = !screen->curses; + ToggleFlag(screen->curses); update_cursesemul(); } @@ -1281,7 +1309,7 @@ do_marginbell(Widget gw GCC_UNUSED, { TScreen *screen = TScreenOf(term); - if (!(screen->marginbell = !screen->marginbell)) + if (!(ToggleFlag(screen->marginbell))) screen->bellarmed = -1; update_marginbell(); } @@ -1348,7 +1376,7 @@ do_titeInhibit(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { - term->misc.titeInhibit = !term->misc.titeInhibit; + ToggleFlag(term->misc.titeInhibit); update_titeInhibit(); } @@ -1363,7 +1391,7 @@ do_activeicon(Widget gw GCC_UNUSED, if (screen->iconVwin.window) { Widget shell = XtParent(term); - term->misc.active_icon = !term->misc.active_icon; + ToggleFlag(term->misc.active_icon); XtVaSetValues(shell, XtNiconWindow, term->misc.active_icon ? screen->iconVwin.window : None, (XtPointer) 0); @@ -1443,7 +1471,7 @@ do_font_doublesize(Widget gw GCC_UNUSED, XtPointer data GCC_UNUSED) { if (term->screen.cache_doublesize != 0) - term->screen.font_doublesize = !term->screen.font_doublesize; + ToggleFlag(term->screen.font_doublesize); update_font_doublesize(); Redraw(); } @@ -1455,7 +1483,7 @@ do_font_boxchars(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { - term->screen.force_box_chars = !term->screen.force_box_chars; + ToggleFlag(term->screen.force_box_chars); update_font_boxchars(); Redraw(); } @@ -1467,7 +1495,7 @@ do_font_loadable(Widget gw GCC_UNUSED, XtPointer closure GCC_UNUSED, XtPointer data GCC_UNUSED) { - term->misc.font_loadable = !term->misc.font_loadable; + ToggleFlag(term->misc.font_loadable); update_font_loadable(); } #endif @@ -1482,7 +1510,7 @@ do_font_renderfont(Widget gw GCC_UNUSED, int fontnum = screen->menu_font_number; String name = term->screen.MenuFontName(fontnum); - term->misc.render_font = !term->misc.render_font; + ToggleFlag(term->misc.render_font); update_font_renderfont(); xtermLoadFont(term, xtermFontName(name), True, fontnum); ScrnRefresh(term, 0, 0, @@ -1527,7 +1555,7 @@ do_font_utf8_title(Widget gw GCC_UNUSED, { TScreen *screen = TScreenOf(term); - screen->utf8_title = !screen->utf8_title; + ToggleFlag(screen->utf8_title); update_font_utf8_title(); } #endif @@ -2378,7 +2406,7 @@ UpdateMenuItem( #endif MenuEntry * menu, int which, - XtArgVal val) + Bool val) { static Arg menuArgs = {XtNleftBitmap, (XtArgVal) 0}; @@ -2400,7 +2428,7 @@ UpdateMenuItem( #endif void -SetItemSensitivity(Widget mi, XtArgVal val) +SetItemSensitivity(Widget mi, Bool val) { static Arg menuArgs = {XtNsensitive, (XtArgVal) 0}; @@ -2477,7 +2505,7 @@ SetupShell(Widget *menus, MenuList * shell, int n, int m) (XtPointer) 0); (void) setMenuLocale(True, saveLocale); - return button_height + (button_border * 2); + return (Dimension) (button_height + (button_border * 2)); } #endif /* OPT_TOOLBAR */ @@ -2551,7 +2579,7 @@ SetupMenus(Widget shell, Widget *forms, Widget *menus, Dimension * menu_high) * Tell the main program how high the toolbar is, to help with the initial * layout. */ - *menu_high = (button_height + 2 * (toolbar_hSpace)); + *menu_high = (Dimension) (button_height + 2 * (toolbar_hSpace)); TRACE(("...menuHeight:%d = (%d + 2 * %d)\n", *menu_high, button_height, toolbar_hSpace)); @@ -2700,7 +2728,7 @@ ShowToolbar(Bool enable) hide_toolbar((Widget) tekWidget); #endif } - resource.toolBar = enable; + resource.toolBar = (Boolean) enable; update_toolbar(); } } @@ -2733,7 +2761,7 @@ do_toolbar(Widget gw GCC_UNUSED, if (IsIcon(&(term->screen))) { Bell(XkbBI_MinorError, 0); } else { - ShowToolbar(resource.toolBar = !resource.toolBar); + ShowToolbar(ToggleFlag(resource.toolBar)); } } @@ -3183,6 +3211,141 @@ update_font_utf8_title(void) } #endif +#if OPT_ALLOW_XXX_OPS +static void +enable_allow_xxx_ops(Bool enable) +{ + SetItemSensitivity(fontMenuEntries[fontMenu_allowFontOps].widget, enable); + SetItemSensitivity(fontMenuEntries[fontMenu_allowTcapOps].widget, enable); + SetItemSensitivity(fontMenuEntries[fontMenu_allowTitleOps].widget, enable); + SetItemSensitivity(fontMenuEntries[fontMenu_allowWindowOps].widget, enable); +} + +static void +do_allowFontOps(Widget w, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + XtermWidget xw = getXtermWidget(w); + if (xw != 0) { + ToggleFlag(xw->screen.allowFontOps); + update_menu_allowFontOps(); + } +} + +static void +do_allowTcapOps(Widget w, + XtPointer closure GCC_UNUSED, + XtPointer data GCC_UNUSED) +{ + XtermWidget xw = getXtermWidget(w); + if (xw != 0) { + ToggleFlag(xw->screen.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(xw->screen.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(xw->screen.allowWindowOps); + update_menu_allowWindowOps(); + } +} + +void +HandleAllowFontOps(Widget w, + XEvent * event GCC_UNUSED, + String * params, + Cardinal *param_count) +{ + handle_vt_toggle(do_allowFontOps, term->screen.allowFontOps, + params, *param_count, w); +} + +void +HandleAllowTcapOps(Widget w, + XEvent * event GCC_UNUSED, + String * params, + Cardinal *param_count) +{ + handle_vt_toggle(do_allowTcapOps, term->screen.allowTcapOps, + params, *param_count, w); +} + +void +HandleAllowTitleOps(Widget w, + XEvent * event GCC_UNUSED, + String * params, + Cardinal *param_count) +{ + handle_vt_toggle(do_allowTitleOps, term->screen.allowTitleOps, + params, *param_count, w); +} + +void +HandleAllowWindowOps(Widget w, + XEvent * event GCC_UNUSED, + String * params, + Cardinal *param_count) +{ + handle_vt_toggle(do_allowWindowOps, term->screen.allowWindowOps, + params, *param_count, w); +} + +void +update_menu_allowTcapOps(void) +{ + UpdateCheckbox("update_menu_allowTcapOps", + fontMenuEntries, + fontMenu_allowTcapOps, + term->screen.allowTcapOps); +} + +void +update_menu_allowFontOps(void) +{ + UpdateCheckbox("update_menu_allowFontOps", + fontMenuEntries, + fontMenu_allowFontOps, + term->screen.allowFontOps); +} + +void +update_menu_allowTitleOps(void) +{ + UpdateCheckbox("update_menu_allowTitleOps", + fontMenuEntries, + fontMenu_allowTitleOps, + term->screen.allowTitleOps); +} + +void +update_menu_allowWindowOps(void) +{ + UpdateCheckbox("update_menu_allowWindowOps", + fontMenuEntries, + fontMenu_allowWindowOps, + term->screen.allowWindowOps); +} +#endif + #if OPT_TEK4014 void update_tekshow(void) diff --git a/app/xterm/menu.h b/app/xterm/menu.h index f6a7fd2a4..f5781820f 100644 --- a/app/xterm/menu.h +++ b/app/xterm/menu.h @@ -1,8 +1,8 @@ -/* $XTermId: menu.h,v 1.106 2006/07/23 14:59:13 tom Exp $ */ +/* $XTermId: menu.h,v 1.113 2009/02/13 19:55:26 tom Exp $ */ /* -Copyright 1999-2005,2006 by Thomas E. Dickey +Copyright 1999-2007,2009 by Thomas E. Dickey All Rights Reserved @@ -49,7 +49,6 @@ other dealings in this Software without prior written authorization from The Open Group. */ -/* $XFree86: xc/programs/xterm/menu.h,v 3.41 2006/03/13 01:27:59 dickey Exp $ */ #ifndef included_menu_h #define included_menu_h @@ -70,7 +69,11 @@ extern MenuEntry tekMenuEntries[]; extern void Handle8BitControl PROTO_XT_ACTIONS_ARGS; extern void HandleAllow132 PROTO_XT_ACTIONS_ARGS; +extern void HandleAllowFontOps PROTO_XT_ACTIONS_ARGS; extern void HandleAllowSends PROTO_XT_ACTIONS_ARGS; +extern void HandleAllowTcapOps PROTO_XT_ACTIONS_ARGS; +extern void HandleAllowTitleOps PROTO_XT_ACTIONS_ARGS; +extern void HandleAllowWindowOps PROTO_XT_ACTIONS_ARGS; extern void HandleAltEsc PROTO_XT_ACTIONS_ARGS; extern void HandleAltScreen PROTO_XT_ACTIONS_ARGS; extern void HandleAppCursor PROTO_XT_ACTIONS_ARGS; @@ -78,6 +81,7 @@ extern void HandleAppKeypad PROTO_XT_ACTIONS_ARGS; extern void HandleAutoLineFeed PROTO_XT_ACTIONS_ARGS; extern void HandleAutoWrap PROTO_XT_ACTIONS_ARGS; extern void HandleBackarrow PROTO_XT_ACTIONS_ARGS; +extern void HandleBellIsUrgent PROTO_XT_ACTIONS_ARGS; extern void HandleClearSavedLines PROTO_XT_ACTIONS_ARGS; extern void HandleCreateMenu PROTO_XT_ACTIONS_ARGS; extern void HandleCursesEmul PROTO_XT_ACTIONS_ARGS; @@ -89,6 +93,7 @@ extern void HandleFontLoading PROTO_XT_ACTIONS_ARGS; extern void HandleHardReset PROTO_XT_ACTIONS_ARGS; extern void HandleHpFunctionKeys PROTO_XT_ACTIONS_ARGS; extern void HandleJumpscroll PROTO_XT_ACTIONS_ARGS; +extern void HandleKeepSelection PROTO_XT_ACTIONS_ARGS; extern void HandleLogging PROTO_XT_ACTIONS_ARGS; extern void HandleMarginBell PROTO_XT_ACTIONS_ARGS; extern void HandleMetaEsc PROTO_XT_ACTIONS_ARGS; @@ -162,6 +167,9 @@ typedef enum { #endif mainMenu_delete_del, mainMenu_old_fkeys, +#if OPT_TCAP_FKEYS + mainMenu_tcap_fkeys, +#endif #if OPT_HP_FUNC_KEYS mainMenu_hp_fkeys, #endif @@ -202,10 +210,11 @@ typedef enum { vtMenu_scrollkey, vtMenu_scrollttyoutput, vtMenu_allow132, + vtMenu_keepSelection, vtMenu_selectToClipboard, vtMenu_visualbell, + vtMenu_bellIsUrgent, vtMenu_poponbell, - vtMenu_marginbell, #if OPT_BLINK_CURS vtMenu_cursorblink, #endif @@ -231,7 +240,7 @@ typedef enum { * items in vt100 font menu */ typedef enum { - fontMenu_fontdefault, + fontMenu_default, fontMenu_font1, fontMenu_font2, fontMenu_font3, @@ -266,6 +275,13 @@ typedef enum { fontMenu_wide_title, #endif #endif +#if OPT_ALLOW_XXX_OPS + fontMenu_line3, + fontMenu_allowTcapOps, + fontMenu_allowFontOps, + fontMenu_allowTitleOps, + fontMenu_allowWindowOps, +#endif fontMenu_LAST } fontMenuIndices; @@ -297,7 +313,7 @@ typedef enum { * functions for updating menus */ -extern void SetItemSensitivity(Widget mi, XtArgVal val); +extern void SetItemSensitivity(Widget mi, Bool val); /* * there should be one of each of the following for each checkable item @@ -356,6 +372,12 @@ extern void update_sun_fkeys(void); #define update_sun_fkeys() /*nothing*/ #endif +#if OPT_TCAP_FKEYS +extern void update_tcap_fkeys(void); +#else +#define update_tcap_fkeys() /*nothing*/ +#endif + extern void update_scrollbar(void); extern void update_jumpscroll(void); extern void update_reversevideo(void); @@ -365,13 +387,23 @@ extern void update_autolinefeed(void); extern void update_appcursor(void); extern void update_appkeypad(void); extern void update_scrollkey(void); +extern void update_keepSelection(void); extern void update_selectToClipboard(void); extern void update_scrollttyoutput(void); extern void update_allow132(void); extern void update_cursesemul(void); extern void update_visualbell(void); +extern void update_bellIsUrgent(void); extern void update_poponbell(void); -extern void update_marginbell(void); + +#define update_marginbell() /* nothing */ + +#if OPT_ALLOW_XXX_OPS +extern void update_menu_allowTcapOps(void); +extern void update_menu_allowFontOps(void); +extern void update_menu_allowTitleOps(void); +extern void update_menu_allowWindowOps(void); +#endif #if OPT_BLINK_CURS extern void update_cursorblink(void); diff --git a/app/xterm/misc.c b/app/xterm/misc.c index 77b57ab38..6f6580f15 100644 --- a/app/xterm/misc.c +++ b/app/xterm/misc.c @@ -1,8 +1,8 @@ -/* $XTermId: misc.c,v 1.391 2008/12/30 17:44:50 tom Exp $ */ +/* $XTermId: misc.c,v 1.405 2009/02/13 23:39:29 tom Exp $ */ /* * - * Copyright 1999-2007,2008 by Thomas E. Dickey + * Copyright 1999-2008,2009 by Thomas E. Dickey * * All Rights Reserved * @@ -54,6 +54,7 @@ */ #include <version.h> +#include <main.h> #include <xterm.h> #include <sys/stat.h> @@ -473,12 +474,12 @@ make_hidden_cursor(XtermWidget xw) /* * 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 _somethng_. + * 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, "fixed"); + fn = XLoadQueryFont(dpy, DEFFONT); } if (fn != 0) { @@ -515,7 +516,7 @@ HandleKeyPressed(Widget w GCC_UNUSED, String * params GCC_UNUSED, Cardinal *nparams GCC_UNUSED) { - TRACE(("Handle 7bit-key\n")); + TRACE(("Handle insert-seven-bit for %p\n", w)); #ifdef ACTIVEWINDOWINPUTONLY if (w == CURRENT_EMU()) #endif @@ -529,7 +530,7 @@ HandleEightBitKeyPressed(Widget w GCC_UNUSED, String * params GCC_UNUSED, Cardinal *nparams GCC_UNUSED) { - TRACE(("Handle 8bit-key\n")); + TRACE(("Handle insert-eight-bit for %p\n", w)); #ifdef ACTIVEWINDOWINPUTONLY if (w == CURRENT_EMU()) #endif @@ -688,7 +689,7 @@ HandleInterpret(Widget w GCC_UNUSED, { if (*param_count == 1) { char *value = params[0]; - int need = strlen(value); + int need = (int) strlen(value); int used = VTbuffer->next - VTbuffer->buffer; int have = VTbuffer->last - VTbuffer->buffer; @@ -790,15 +791,58 @@ HandleFocusChange(Widget w GCC_UNUSED, 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, True); + break; + } + } + return result; +} +#endif + void -Bell(Atom which GCC_UNUSED, int percent) +xtermBell(XtermWidget xw, int which, int percent) { - TScreen *screen = TScreenOf(term); + if (percent > 0) { + TScreen *screen = TScreenOf(xw); +#if defined(HAVE_XKB_BELL_EXT) + Atom tony = AtomBell(xw, which); + if (tony != None) { + XkbBell(screen->display, VShellWindow, percent, tony); + } else +#endif + XBell(screen->display, percent); + } +} + +void +Bell(int which GCC_UNUSED, int percent) +{ + XtermWidget xw = term; + TScreen *screen = TScreenOf(xw); struct timeval curtime; long now_msecs; - TRACE(("BELL %ld %d%%\n", (long) which, percent)); - if (!XtIsRealized((Widget) term)) { + TRACE(("BELL %d %d%%\n", which, percent)); + if (!XtIsRealized((Widget) xw)) { return; } @@ -825,11 +869,7 @@ Bell(Atom which GCC_UNUSED, int percent) if (screen->visualbell) { VisualBell(); } else { -#if defined(HAVE_XKB_BELL_EXT) - XkbBell(screen->display, VShellWindow, percent, which); -#else - XBell(screen->display, percent); -#endif + xtermBell(xw, which, percent); } if (screen->poponbell) @@ -971,7 +1011,7 @@ dabbrev_prev_word(int *xp, int *yp, TScreen * screen) while ((c = dabbrev_prev_char(xp, yp, screen)) >= 0 && IS_WORD_CONSTITUENT(c)) if (abword > ab) /* store only |MAXWLEN| last chars */ - *(--abword) = c; + *(--abword) = (char) c; if (c < 0) { if (abword < ab + MAXWLEN - 1) return abword; @@ -1060,14 +1100,16 @@ dabbrev_expand(TScreen * screen) /*ARGSUSED*/ void -HandleDabbrevExpand(Widget gw, +HandleDabbrevExpand(Widget w, XEvent * event GCC_UNUSED, String * params GCC_UNUSED, Cardinal *nparams GCC_UNUSED) { - if (IsXtermWidget(gw)) { - XtermWidget w = (XtermWidget) gw; - TScreen *screen = &w->screen; + XtermWidget xw; + + TRACE(("Handle dabbrev-expand for %p\n", w)); + if ((xw = getXtermWidget(w)) != 0) { + TScreen *screen = &xw->screen; if (!dabbrev_expand(screen)) Bell(XkbBI_TerminalBell, 0); } @@ -1077,26 +1119,30 @@ HandleDabbrevExpand(Widget gw, #if OPT_MAXIMIZE /*ARGSUSED*/ void -HandleDeIconify(Widget gw, +HandleDeIconify(Widget w, XEvent * event GCC_UNUSED, String * params GCC_UNUSED, Cardinal *nparams GCC_UNUSED) { - if (IsXtermWidget(gw)) { - TScreen *screen = TScreenOf((XtermWidget) gw); + XtermWidget xw; + + if ((xw = getXtermWidget(w)) != 0) { + TScreen *screen = TScreenOf(xw); XMapWindow(screen->display, VShellWindow); } } /*ARGSUSED*/ void -HandleIconify(Widget gw, +HandleIconify(Widget w, XEvent * event GCC_UNUSED, String * params GCC_UNUSED, Cardinal *nparams GCC_UNUSED) { - if (IsXtermWidget(gw)) { - TScreen *screen = TScreenOf((XtermWidget) gw); + XtermWidget xw; + + if ((xw = getXtermWidget(w)) != 0) { + TScreen *screen = TScreenOf(xw); XIconifyWindow(screen->display, VShellWindow, DefaultScreen(screen->display)); @@ -1146,9 +1192,9 @@ QueryMaximize(XtermWidget termw, unsigned *width, unsigned *height) hints.max_height)); if ((unsigned) hints.max_width < *width) - *width = hints.max_width; + *width = (unsigned) hints.max_width; if ((unsigned) hints.max_height < *height) - *height = hints.max_height; + *height = (unsigned) hints.max_height; } return 1; } @@ -1180,8 +1226,8 @@ RequestMaximize(XtermWidget termw, int maximize) 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 = vshell_attrs.width; - screen->restore_height = vshell_attrs.height; + screen->restore_width = (unsigned) vshell_attrs.width; + screen->restore_height = (unsigned) vshell_attrs.height; TRACE(("HandleMaximize: save window position %d,%d size %d,%d\n", screen->restore_x, screen->restore_y, @@ -1190,9 +1236,11 @@ RequestMaximize(XtermWidget termw, int maximize) } /* subtract wm decoration dimensions */ - root_width -= ((wm_attrs.width - vshell_attrs.width) - + (wm_attrs.border_width * 2)); - root_height -= ((wm_attrs.height - vshell_attrs.height) + 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)); XMoveResizeWindow(screen->display, VShellWindow, @@ -1224,25 +1272,29 @@ RequestMaximize(XtermWidget termw, int maximize) /*ARGSUSED*/ void -HandleMaximize(Widget gw, +HandleMaximize(Widget w, XEvent * event GCC_UNUSED, String * params GCC_UNUSED, Cardinal *nparams GCC_UNUSED) { - if (IsXtermWidget(gw)) { - RequestMaximize((XtermWidget) gw, 1); + XtermWidget xw; + + if ((xw = getXtermWidget(w)) != 0) { + RequestMaximize(xw, 1); } } /*ARGSUSED*/ void -HandleRestoreSize(Widget gw, +HandleRestoreSize(Widget w, XEvent * event GCC_UNUSED, String * params GCC_UNUSED, Cardinal *nparams GCC_UNUSED) { - if (IsXtermWidget(gw)) { - RequestMaximize((XtermWidget) gw, 0); + XtermWidget xw; + + if ((xw = getXtermWidget(w)) != 0) { + RequestMaximize(xw, 0); } } #endif /* OPT_MAXIMIZE */ @@ -2342,20 +2394,20 @@ do_osc(XtermWidget xw, Char * oscbuf, unsigned len GCC_UNUSED, int final) switch (mode) { case 0: /* new icon name and title */ - ChangeIconName(buf); - ChangeTitle(buf); + ChangeIconName(xw, buf); + ChangeTitle(xw, buf); break; case 1: /* new icon name only */ - ChangeIconName(buf); + ChangeIconName(xw, buf); break; case 2: /* new title only */ - ChangeTitle(buf); + ChangeTitle(xw, buf); break; case 3: /* change X property */ - if (screen->allowWindowOps) + if (AllowWindowOps(xw)) ChangeXprop(buf); break; #if OPT_ISO_COLORS @@ -2409,7 +2461,7 @@ do_osc(XtermWidget xw, Char * oscbuf, unsigned len GCC_UNUSED, int final) case 50: #if OPT_SHIFT_FONTS - if (!screen->allowFontOps && xw->misc.shift_fonts) { + if (!AllowFontOps(xw) && xw->misc.shift_fonts) { ; /* disabled via resource or control-sequence */ } else if (buf != 0 && !strcmp(buf, "?")) { int num = screen->menu_font_number; @@ -2482,7 +2534,7 @@ do_osc(XtermWidget xw, Char * oscbuf, unsigned len GCC_UNUSED, int final) #if OPT_PASTE64 case 52: - if (screen->allowWindowOps) + if (AllowWindowOps(xw)) ManipulateSelectionData(xw, screen, buf, final); break; #endif @@ -2701,7 +2753,7 @@ static void parse_ansi_params(ANSI * params, char **string) { char *cp = *string; - short nparam = 0; + ParmType nparam = 0; memset(params, 0, sizeof(*params)); while (*cp != '\0') { @@ -2841,7 +2893,7 @@ do_dcs(XtermWidget xw, Char * dcsbuf, size_t dcslen) #if OPT_TCAP_QUERY case '+': cp++; - if ((*cp == 'q') && screen->allowTcapOps) { + if ((*cp == 'q') && AllowTcapOps(xw)) { Bool fkey; unsigned state; int code; @@ -2934,7 +2986,7 @@ udk_lookup(int keycode, int *len) } static void -ChangeGroup(String attribute, char *value) +ChangeGroup(XtermWidget xw, String attribute, char *value) { #if OPT_WIDE_CHARS static Char *converted; /* NO_LEAKS */ @@ -2944,7 +2996,7 @@ ChangeGroup(String attribute, char *value) Arg args[1]; char *original = (value != 0) ? value : empty; char *name = original; - TScreen *screen = TScreenOf(term); + TScreen *screen = TScreenOf(xw); Widget w = CURRENT_EMU(); Widget top = SHELL_OF(w); unsigned limit = strlen(name); @@ -2953,7 +3005,7 @@ ChangeGroup(String attribute, char *value) TRACE(("ChangeGroup(attribute=%s, value=%s)\n", attribute, name)); - if (!screen->allowTitleOps) + if (!AllowTitleOps(xw)) return; /* @@ -3020,7 +3072,7 @@ ChangeGroup(String attribute, char *value) #if OPT_WIDE_CHARS if (xtermEnvUTF8()) { - Display *dpy = XtDisplay(term); + Display *dpy = XtDisplay(xw); Atom my_atom; const char *propname = (!strcmp(attribute, XtNtitle) @@ -3044,12 +3096,12 @@ ChangeGroup(String attribute, char *value) } void -ChangeIconName(char *name) +ChangeIconName(XtermWidget xw, char *name) { if (name == 0) name = ""; #if OPT_ZICONBEEP /* If warning should be given then give it */ - if (resource.zIconBeep && term->screen.zIconBeep_flagged) { + if (resource.zIconBeep && xw->screen.zIconBeep_flagged) { char *newname = CastMallocN(char, strlen(name) + 4); if (!newname) { fprintf(stderr, "malloc failed in ChangeIconName\n"); @@ -3057,17 +3109,17 @@ ChangeIconName(char *name) } strcpy(newname, "*** "); strcat(newname, name); - ChangeGroup(XtNiconName, newname); + ChangeGroup(xw, XtNiconName, newname); free(newname); } else #endif /* OPT_ZICONBEEP */ - ChangeGroup(XtNiconName, name); + ChangeGroup(xw, XtNiconName, name); } void -ChangeTitle(char *name) +ChangeTitle(XtermWidget xw, char *name) { - ChangeGroup(XtNtitle, name); + ChangeGroup(xw, XtNtitle, name); } #define Strlen(s) strlen((char *)(s)) @@ -3876,3 +3928,25 @@ xtermVersion(void) } return result; } + +/* + * 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)); + } + TRACE(("getXtermWidget %p -> %p\n", w, xw)); + return xw; +} diff --git a/app/xterm/os2main.c b/app/xterm/os2main.c index e3b09a247..bd4c89a75 100644 --- a/app/xterm/os2main.c +++ b/app/xterm/os2main.c @@ -1,4 +1,4 @@ -/* $XTermId: os2main.c,v 1.256 2008/09/14 19:37:07 tom Exp $ */ +/* $XTermId: os2main.c,v 1.257 2009/01/24 16:24:36 tom Exp $ */ /* removed all foreign stuff to get the code more clear (hv) * and did some rewrite for the obscure OS/2 environment @@ -313,6 +313,9 @@ static XtResource application_resources[] = #if OPT_TOOLBAR Bres(XtNtoolBar, XtCToolBar, toolBar, True), #endif +#if OPT_MAXIMIZE + Bres(XtNmaximized, XtCMaximized, maximized, False), +#endif }; static char *fallback_resources[] = @@ -505,6 +508,10 @@ static XrmOptionDescRec optionDescList[] = { {"-tb", "*"XtNtoolBar, XrmoptionNoArg, (caddr_t) "on"}, {"+tb", "*"XtNtoolBar, XrmoptionNoArg, (caddr_t) "off"}, #endif +#if OPT_MAXIMIZE +{"-maximized", "*maximized", XrmoptionNoArg, (caddr_t) "on"}, +{"+maximized", "*maximized", XrmoptionNoArg, (caddr_t) "off"}, +#endif /* options that we process ourselves */ {"-help", NULL, XrmoptionSkipNArgs, (caddr_t) NULL}, {"-version", NULL, XrmoptionSkipNArgs, (caddr_t) NULL}, @@ -669,6 +676,9 @@ static OptionHelp xtermOptions[] = { #if OPT_SESSION_MGT { "-/+sm", "turn on/off the session-management support" }, #endif +#if OPT_MAXIMIZE +{"-/+maximized", "turn on/off maxmize on startup" }, +#endif { NULL, NULL }}; /* *INDENT-ON* */ @@ -860,6 +870,22 @@ save_callback(Widget w GCC_UNUSED, /* 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")); + } +} + #endif /* OPT_SESSION_MGT */ /* @@ -1010,6 +1036,7 @@ main(int argc, char **argv ENVP_ARG) &argc, argv, fallback_resources, sessionShellWidgetClass, NULL, 0); + IceAddConnectionWatch(icewatch, NULL); #else toplevel = XtAppInitialize(&app_con, my_class, optionDescList, @@ -1163,6 +1190,7 @@ main(int argc, char **argv ENVP_ARG) screen = TScreenOf(term); screen->inhibit = 0; + #ifdef ALLOWLOGGING if (term->misc.logInhibit) screen->inhibit |= I_LOG; @@ -1182,7 +1210,7 @@ main(int argc, char **argv ENVP_ARG) TEK4014_ACTIVE(term) = False; if (TEK4014_ACTIVE(term) && !TekInit()) - exit(ERROR_INIT); + SysError(ERROR_INIT); #endif /* @@ -1243,7 +1271,7 @@ main(int argc, char **argv ENVP_ARG) c[1 + u] = "--"; command_to_exec_with_luit = c; } else { - static char *luit[4]; + static char *luit[6]; luit[0] = term->misc.localefilter; if (u) { luit[1] = "-encoding"; @@ -1351,6 +1379,10 @@ main(int argc, char **argv ENVP_ARG) ReverseVideo(term); #endif /* OPT_COLOR_RES */ +#if OPT_MAXIMIZE + if (resource.maximized) + RequestMaximize(term, True); +#endif for (;;) { #if OPT_TEK4014 if (TEK4014_ACTIVE(term)) @@ -1798,6 +1830,7 @@ spawnXTerm(XtermWidget xw) xtermSetenv("DISPLAY", XDisplayString(screen->display)); xtermSetenv("XTERM_VERSION", xtermVersion()); + xtermSetenv("XTERM_LOCALE", xtermEnvLocale()); signal(SIGTERM, SIG_DFL); @@ -1818,6 +1851,8 @@ spawnXTerm(XtermWidget xw) (void) xtermResetIds(screen); if (handshake.rows > 0 && handshake.cols > 0) { + TRACE(("handshake ttysize: %dx%d\n", + handshake.rows, handshake.cols)); set_max_row(screen, handshake.rows); set_max_col(screen, handshake.cols); TTYSIZE_ROWS(ts) = MaxRows(screen); @@ -1955,6 +1990,45 @@ Exit(int n) set_owner(ttydev, 0, 0, 0666U); set_owner(ptydev, 0, 0, 0666U); } + + /* + * Close after releasing ownership to avoid race condition: other programs + * grabbing it, and *then* having us release ownership.... + */ + close(screen->respond); /* close explicitly to avoid race with slave side */ +#ifdef ALLOWLOGGING + if (screen->logging) + CloseLog(screen); +#endif + +#ifdef NO_LEAKS + if (n == 0) { + TRACE(("Freeing memory leaks\n")); + if (term != 0) { + Display *dpy = term->screen.display; + + if (toplevel) { + XtDestroyWidget(toplevel); + TRACE(("destroyed top-level widget\n")); + } + sortedOpts(0, 0, 0); + noleaks_charproc(); + noleaks_ptydata(); +#if OPT_WIDE_CHARS + noleaks_CharacterClass(); +#endif + /* XrmSetDatabase(dpy, 0); increases leaks ;-) */ + XtCloseDisplay(dpy); + XtDestroyApplicationContext(app_con); +#if OPT_SESSION_MGT + IceRemoveConnectionWatch(icewatch, NULL); +#endif + TRACE(("closed display\n")); + } + TRACE((0)); + } +#endif + exit(n); SIGNAL_RETURN; } diff --git a/app/xterm/ptydata.c b/app/xterm/ptydata.c index 2f6ebfa53..cc6eb6a6e 100644 --- a/app/xterm/ptydata.c +++ b/app/xterm/ptydata.c @@ -1,4 +1,4 @@ -/* $XTermId: ptydata.c,v 1.80 2008/04/20 22:41:25 tom Exp $ */ +/* $XTermId: ptydata.c,v 1.81 2009/01/26 00:22:33 tom Exp $ */ /* * $XFree86: xc/programs/xterm/ptydata.c,v 1.25 2006/02/13 01:14:59 dickey Exp $ @@ -6,7 +6,7 @@ /************************************************************ -Copyright 1999-2007,2008 by Thomas E. Dickey +Copyright 1999-2008,2009 by Thomas E. Dickey All Rights Reserved @@ -305,7 +305,7 @@ switchPtyData(TScreen * screen, int flag) { if (screen->utf8_mode != flag) { screen->utf8_mode = flag; - screen->utf8_inparse = (flag != 0); + screen->utf8_inparse = (Boolean) (flag != 0); TRACE(("turning UTF-8 mode %s\n", BtoS(flag))); update_font_utf8_mode(); @@ -334,7 +334,7 @@ initPtyData(PtyData ** result) TRACE(("initPtyData using minBufSize %d, maxBufSize %d\n", FRG_SIZE, BUF_SIZE)); - data = (PtyData *) XtMalloc(sizeof(*data) + BUF_SIZE + FRG_SIZE); + data = (PtyData *) XtMalloc(sizeof(*data) + (unsigned) (BUF_SIZE + FRG_SIZE)); memset(data, 0, sizeof(*data)); data->next = data->buffer; @@ -413,14 +413,14 @@ Char * convertToUTF8(Char * lp, unsigned c) { if (c < 0x80) { /* 0******* */ - *lp++ = (c); + *lp++ = (Char) (c); } else if (c < 0x800) { /* 110***** 10****** */ - *lp++ = (0xc0 | (c >> 6)); - *lp++ = (0x80 | (c & 0x3f)); + *lp++ = (Char) (0xc0 | (c >> 6)); + *lp++ = (Char) (0x80 | (c & 0x3f)); } else { /* 1110**** 10****** 10****** */ - *lp++ = (0xe0 | (c >> 12)); - *lp++ = (0x80 | ((c >> 6) & 0x3f)); - *lp++ = (0x80 | (c & 0x3f)); + *lp++ = (Char) (0xe0 | (c >> 12)); + *lp++ = (Char) (0x80 | ((c >> 6) & 0x3f)); + *lp++ = (Char) (0x80 | (c & 0x3f)); } /* * UTF-8 is defined for words of up to 31 bits, but we need only 16 @@ -444,7 +444,7 @@ writePtyData(int f, IChar * d, unsigned len) } for (n = 0; n < len; n++) - VTbuffer->write_buf[n] = d[n]; + VTbuffer->write_buf[n] = (Char) d[n]; TRACE(("writePtyData %d:%s\n", n, visibleChars(PAIRED_CHARS(VTbuffer->write_buf, 0), n))); diff --git a/app/xterm/ptyx.h b/app/xterm/ptyx.h index 6e0e26cfa..4580b3a24 100644 --- a/app/xterm/ptyx.h +++ b/app/xterm/ptyx.h @@ -1,7 +1,7 @@ -/* $XTermId: ptyx.h,v 1.536 2008/12/30 17:22:55 tom Exp $ */ +/* $XTermId: ptyx.h,v 1.542 2009/02/10 23:24:50 tom Exp $ */ /* - * Copyright 1999-2007,2008 by Thomas E. Dickey + * Copyright 1999-2008,2009 by Thomas E. Dickey * * All Rights Reserved * @@ -396,6 +396,10 @@ typedef struct { #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 @@ -1775,6 +1779,12 @@ typedef struct _TekScreen { #define MULTICLICKTIME 250 /* milliseconds */ typedef enum { + fwNever = 0, + fwResource, + fwAlways +} fontWarningTypes; + +typedef enum { keyboardIsLegacy, /* bogus vt220 codes for F1-F4, etc. */ keyboardIsDefault, keyboardIsHP, @@ -1887,6 +1897,7 @@ typedef struct _Misc { #if OPT_INPUT_METHOD char *f_x; /* font for XIM */ #endif + fontWarningTypes fontWarnings; int limit_resize; #ifdef ALLOWLOGGING Boolean log_on; @@ -2218,6 +2229,12 @@ typedef struct _TekWidgetRec { #define BorderWidth(w) ((w)->core.border_width) #define BorderPixel(w) ((w)->core.border_pixel) +#define AllowXtermOps(w,name) ((w)->screen.name && !(w)->screen.allowSendEvents) +#define AllowFontOps(w) AllowXtermOps(w, allowFontOps) +#define AllowTcapOps(w) AllowXtermOps(w, allowTcapOps) +#define AllowTitleOps(w) AllowXtermOps(w, allowTitleOps) +#define AllowWindowOps(w) AllowXtermOps(w, allowWindowOps) + #if OPT_TOOLBAR #define ToolbarHeight(w) ((resource.toolBar) \ ? (term->VT100_TB_INFO(menu_height) \ diff --git a/app/xterm/screen.c b/app/xterm/screen.c index 9c6714af7..c806b654b 100644 --- a/app/xterm/screen.c +++ b/app/xterm/screen.c @@ -1,7 +1,7 @@ -/* $XTermId: screen.c,v 1.241 2008/04/20 21:07:10 tom Exp $ */ +/* $XTermId: screen.c,v 1.246 2009/02/09 21:37:57 tom Exp $ */ /* - * Copyright 1999-2007,2008 by Thomas E. Dickey + * Copyright 1999-2008,2009 by Thomas E. Dickey * * All Rights Reserved * @@ -95,8 +95,8 @@ Allocate(int nrow, int ncol, Char ** addr) ScrnBuf base; Char *tmp; int i, j, k; - size_t entries = MAX_PTRS * nrow; - size_t length = BUF_PTRS * nrow * ncol; + size_t entries = (size_t) (MAX_PTRS * nrow); + size_t length = (size_t) (BUF_PTRS * nrow * ncol); if ((base = TypeCallocN(ScrnPtr, entries)) == 0) SysError(ERROR_SCALLOC); @@ -137,8 +137,8 @@ Reallocate(XtermWidget xw, size_t mincols; Char *oldbuf; int move_down = 0, move_up = 0; - size_t entries = MAX_PTRS * nrow; - size_t length = BUF_PTRS * nrow * ncol; + size_t entries = (size_t) (MAX_PTRS * nrow); + size_t length = (size_t) (BUF_PTRS * nrow * ncol); if (sbuf == NULL || *sbuf == NULL) { return 0; @@ -168,7 +168,7 @@ Reallocate(XtermWidget xw, move_up = 0; /* Overlapping memmove here! */ memmove(*sbuf, *sbuf + (move_up * MAX_PTRS), - MAX_PTRS * (oldrow - move_up) * sizeof((*sbuf)[0])); + (unsigned) (MAX_PTRS * (oldrow - move_up)) * sizeof((*sbuf)[0])); } *sbuf = TypeRealloc(ScrnPtr, entries, *sbuf); if (*sbuf == 0) @@ -183,7 +183,7 @@ Reallocate(XtermWidget xw, SysError(ERROR_SREALLOC); *sbufaddr = tmp; minrows = (oldrow < nrow) ? oldrow : nrow; - mincols = (oldcol < ncol) ? oldcol : ncol; + mincols = (size_t) ((oldcol < ncol) ? oldcol : ncol); if (nrow > oldrow && xw->misc.resizeGravity == SouthWestGravity) { /* move data down to bottom of expanded screen */ @@ -281,10 +281,10 @@ ReallocateBufOffsets(XtermWidget xw, dump_screen("before", xw, *sbuf, *sbufaddr, nrow, ncol); - xw->num_ptrs = new_max_offsets; + xw->num_ptrs = (int) new_max_offsets; - entries = MAX_PTRS * nrow; - length = BUF_PTRS * nrow * ncol; + entries = ((unsigned) MAX_PTRS * nrow); + length = ((unsigned) BUF_PTRS * nrow * ncol); oldbuf = *sbufaddr; *sbuf = TypeRealloc(ScrnPtr, entries, *sbuf); @@ -296,19 +296,19 @@ ReallocateBufOffsets(XtermWidget xw, SysError(ERROR_SREALLOC); *sbufaddr = tmp; - for (i = k = 0; i < nrow; i++) { + for (i = 0, k = 0; i < nrow; i++) { k += BUF_HEAD; for (j = BUF_HEAD; j < old_max_ptrs; j++) { memcpy(tmp, base[k++], ncol); tmp += ncol; } - tmp += ncol * (new_max_offsets - old_max_ptrs); + tmp += ncol * (new_max_offsets - (unsigned) old_max_ptrs); } /* * update the pointers in sbuf */ - for (i = k = 0, tmp = *sbufaddr; i < nrow; i++) { + for (i = 0, k = 0, tmp = *sbufaddr; i < nrow; i++) { for (j = 0; j < BUF_HEAD; j++) base[k++] = 0; for (j = BUF_HEAD; j < MAX_PTRS; j++) { @@ -331,7 +331,8 @@ void ChangeToWide(XtermWidget xw) { TScreen *screen = &(xw->screen); - unsigned new_bufoffset = OFF_FINAL + (screen->max_combining * 2); + unsigned new_bufoffset = (unsigned) (OFF_FINAL + + (screen->max_combining * 2)); int savelines = screen->scrollWidget ? screen->savelines : 0; if (screen->wide_chars) @@ -364,7 +365,7 @@ ChangeToWide(XtermWidget xw) } screen->wide_chars = True; - xw->num_ptrs = new_bufoffset; + xw->num_ptrs = (int) new_bufoffset; screen->visbuf = &screen->allbuf[MAX_PTRS * savelines]; /* @@ -461,7 +462,7 @@ ScrnDisownSelection(XtermWidget xw) */ void ScrnWriteText(XtermWidget xw, - PAIRED_CHARS(Char * str, Char * str2), + IChar * str, unsigned flags, unsigned cur_fg_bg, unsigned length) @@ -484,14 +485,15 @@ ScrnWriteText(XtermWidget xw, #if OPT_WIDE_CHARS Char starcol1, starcol2; #endif - unsigned real_width = visual_width(PAIRED_CHARS(str, str2), length); + unsigned n; + unsigned real_width = visual_width(str, length); (void) cur_fg_bg; if (avail <= 0) return; if (length > (unsigned) avail) - length = avail; + length = (unsigned) avail; if (length == 0 || real_width == 0) return; @@ -515,11 +517,11 @@ ScrnWriteText(XtermWidget xw, #endif /* write blanks if we're writing invisible text */ - if (flags & INVISIBLE) { - memset(chars, ' ', length); - } else { - memcpy(chars, str, length); /* This can stand for the present. If it - is wrong, we will scribble over it */ + for (n = 0; n < length; ++n) { + if ((flags & INVISIBLE)) + chars[n] = ' '; + else + chars[n] = LO_BYTE(str[n]); } #if OPT_BLINK_TEXT @@ -539,28 +541,21 @@ ScrnWriteText(XtermWidget xw, char2 = SCRN_BUF_WIDEC(screen, screen->cur_row); char2 += screen->cur_col; if (screen->cur_col && starcol1 == HIDDEN_LO && *char2 == HIDDEN_HI - && iswide(PACK_PAIR(char1, char2, -1))) { + && isWide(PACK_PAIR(char1, char2, -1))) { char1[-1] = ERROR_1; char2[-1] = ERROR_2; } /* if we are overwriting the right hand half of a wide character, make the other half vanish */ while (length) { - int ch = PACK_PAIR(str, str2, 0); + int ch = (int) str[0]; - *char1 = *str; - char1++; + *char1++ = LO_BYTE(*str); + *char2++ = HI_BYTE(*str); str++; - - if (str2) { - *char2 = *str2; - str2++; - } else - *char2 = 0; - char2++; length--; - if (iswide(ch)) { + if (isWide(ch)) { *char1 = HIDDEN_LO; *char2 = HIDDEN_HI; char1++; @@ -578,27 +573,28 @@ ScrnWriteText(XtermWidget xw, /* if we are overwriting the left hand half of a wide character, make the other half vanish */ } else { - if ((char2 = SCRN_BUF_WIDEC(screen, screen->cur_row)) != 0) { char2 += screen->cur_col; if (screen->cur_col && starcol1 == HIDDEN_LO && *char2 == HIDDEN_HI - && iswide(PACK_PAIR(chars, char2, -1))) { + && isWide(PACK_PAIR(chars, char2, -1))) { chars[-1] = ERROR_1; char2[-1] = ERROR_2; } /* if we are overwriting the right hand half of a wide character, make the other half vanish */ if (chars[length] == HIDDEN_LO && char2[length] == HIDDEN_HI && - iswide(PACK_PAIR(chars, char2, length - 1))) { + isWide(PACK_PAIR(chars, char2, length - 1))) { chars[length] = ERROR_1; char2[length] = ERROR_2; } /* if we are overwriting the left hand half of a wide character, make the other half vanish */ - if ((flags & INVISIBLE) || (str2 == 0)) - memset(char2, 0, length); - else - memcpy(char2, str2, length); + for (n = 0; n < length; ++n) { + if ((flags & INVISIBLE)) + char2[n] = 0; + else + char2[n] = HI_BYTE(str[n]); + } } } }); @@ -628,7 +624,7 @@ ScrnWriteText(XtermWidget xw, }); if_OPT_WIDE_CHARS(screen, { - screen->last_written_col = screen->cur_col + real_width - 1; + screen->last_written_col = screen->cur_col + (int) real_width - 1; screen->last_written_row = screen->cur_row; }); @@ -646,7 +642,7 @@ ScrnClearLines(XtermWidget xw, ScrnBuf sb, int where, unsigned n, unsigned size) TScreen *screen = &(xw->screen); int i, j; size_t len = ScrnPointers(screen, n); - int last = (n * MAX_PTRS); + int last = ((int) n * MAX_PTRS); TRACE(("ScrnClearLines(where %d, n %d, size %d)\n", where, n, size)); @@ -660,13 +656,13 @@ ScrnClearLines(XtermWidget xw, ScrnBuf sb, int where, unsigned n, unsigned size) /* clear contents of old rows */ if (TERM_COLOR_FLAGS(xw)) { - int flags = TERM_COLOR_FLAGS(xw); + unsigned flags = TERM_COLOR_FLAGS(xw); for (i = 0; i < last; i += MAX_PTRS) { for (j = 0; j < MAX_PTRS; j++) { if (j < BUF_HEAD) screen->save_ptr[i + j] = 0; else if (j == OFF_ATTRS) - memset(screen->save_ptr[i + j], flags, size); + memset(screen->save_ptr[i + j], (int) flags, size); #if OPT_ISO_COLORS #if OPT_EXT_COLORS else if (j == OFF_FGRND) @@ -696,7 +692,7 @@ ScrnClearLines(XtermWidget xw, ScrnBuf sb, int where, unsigned n, unsigned size) size_t ScrnPointers(TScreen * screen, size_t len) { - len *= MAX_PTRS; + len *= (unsigned) MAX_PTRS; if (len > screen->save_len) { if (screen->save_len) @@ -730,7 +726,7 @@ ScrnInsertLine(XtermWidget xw, ScrnBuf sb, int last, int where, assert(MAX_PTRS > 0); /* save n lines at bottom */ - ScrnClearLines(xw, sb, (last -= n - 1), n, size); + ScrnClearLines(xw, sb, (last -= (int) n - 1), n, size); /* * WARNING, overlapping copy operation. Move down lines (pointers). @@ -742,9 +738,9 @@ ScrnInsertLine(XtermWidget xw, ScrnBuf sb, int last, int where, * +--------|---------|----+ */ assert(last >= where); - memmove((char *) &sb[MAX_PTRS * (where + n)], + memmove((char *) &sb[MAX_PTRS * (where + (int) n)], (char *) &sb[MAX_PTRS * where], - MAX_PTRS * sizeof(char *) * (last - where)); + sizeof(char *) * (unsigned) (MAX_PTRS * (last - where))); /* reuse storage for new lines at where */ memcpy((char *) &sb[MAX_PTRS * where], @@ -773,13 +769,14 @@ ScrnDeleteLine(XtermWidget xw, ScrnBuf sb, int last, int where, /* move up lines */ memmove((char *) &sb[MAX_PTRS * where], - (char *) &sb[MAX_PTRS * (where + n)], - MAX_PTRS * sizeof(char *) * ((last -= n - 1) - where)); + (char *) &sb[MAX_PTRS * (where + (int) n)], + sizeof(char *) * (unsigned) (MAX_PTRS + * ((last -= ((int) n - 1)) - where))); /* reuse storage for new bottom lines */ memcpy((char *) &sb[MAX_PTRS * last], (char *) screen->save_ptr, - MAX_PTRS * sizeof(char *) * n); + (unsigned) MAX_PTRS * sizeof(char *) * n); } /* @@ -800,12 +797,12 @@ ScrnInsertChar(XtermWidget xw, unsigned n) Char *data; size_t nbytes; - if (last <= (int) (col + n)) { + if (last <= (col + (int) n)) { if (last <= col) return; - n = last - col; + n = (unsigned) (last - col); } - nbytes = (last - (col + n)); + nbytes = (size_t) (last - (col + (int) n)); assert(screen->cur_col >= 0); assert(screen->cur_row >= 0); @@ -819,7 +816,7 @@ ScrnInsertChar(XtermWidget xw, unsigned n) if (DamagedCells(screen, n, &kl, (int *) 0, xx, kr) && kr > kl) { ClearCells(xw, 0, (unsigned) (kr - kl + 1), row, kl); } - kr = screen->max_col - n + 1; + kr = screen->max_col - (int) n + 1; if (DamagedCells(screen, n, &kl, (int *) 0, xx, kr) && kr > kl) { ClearCells(xw, 0, (unsigned) (kr - kl + 1), row, kl); } @@ -875,12 +872,12 @@ ScrnDeleteChar(XtermWidget xw, unsigned n) Char *data; size_t nbytes; - if (last <= (int) (col + n)) { + if (last <= (col + (int) n)) { if (last <= col) return; - n = last - col; + n = (unsigned) (last - col); } - nbytes = (last - (col + n)); + nbytes = (size_t) (last - (col + (int) n)); assert(screen->cur_col >= 0); assert(screen->cur_row >= 0); @@ -923,7 +920,7 @@ ScrnDeleteChar(XtermWidget xw, unsigned n) memmove(Target, Source, nbytes); } }); - ClearCells(xw, 0, n, row, (int) (last - n)); + ClearCells(xw, 0, n, row, (last - (int) n)); ScrnClrWrapped(screen, row); #undef Source @@ -951,7 +948,7 @@ ScrnRefresh(XtermWidget xw, int maxrow = toprow + nrows - 1; int scrollamt = screen->scroll_amt; int max = screen->max_row; - int gc_changes = 0; + unsigned gc_changes = 0; #ifdef __CYGWIN__ static char first_time = 1; #endif @@ -1036,7 +1033,7 @@ ScrnRefresh(XtermWidget xw, to draw the right hand half */ if (leftcol > 0 && (PACK_PAIR(chars, widec, leftcol)) == HIDDEN_CHAR && - iswide(PACK_PAIR(chars, widec, leftcol - 1))) { + isWide(PACK_PAIR(chars, widec, leftcol - 1))) { leftcol--; ncols++; col = leftcol; @@ -1138,7 +1135,7 @@ ScrnRefresh(XtermWidget xw, flags = attrs[col]; #if OPT_WIDE_CHARS if (widec) - wideness = iswide(PACK_PAIR(chars, widec, col)); + wideness = isWide(PACK_PAIR(chars, widec, col)); else wideness = 0; #endif @@ -1175,7 +1172,7 @@ ScrnRefresh(XtermWidget xw, #endif #if OPT_WIDE_CHARS || (widec - && ((iswide(PACK_PAIR(chars, widec, col))) != wideness) + && ((isWide(PACK_PAIR(chars, widec, col))) != wideness) && !((PACK_PAIR(chars, widec, col)) == HIDDEN_CHAR)) #endif #if OPT_DEC_CHRSET @@ -1214,7 +1211,7 @@ ScrnRefresh(XtermWidget xw, int base = PACK_PAIR(chars, widec, i); int combo = PACK_PAIR(com_lo, com_hi, i); - if (iswide(base)) + if (isWide(base)) my_x = CurCursorX(screen, ROW2INX(screen, row), i - 1); @@ -1226,7 +1223,7 @@ ScrnRefresh(XtermWidget xw, gc, my_x, y, cs, PAIRED_CHARS(com_lo + i, com_hi + i), - 1, iswide(base)); + 1, isWide(base)); } } }); @@ -1254,7 +1251,7 @@ ScrnRefresh(XtermWidget xw, }); #if OPT_WIDE_CHARS if (widec) - wideness = iswide(PACK_PAIR(chars, widec, col)); + wideness = isWide(PACK_PAIR(chars, widec, col)); #endif gc = updatedXtermGC(xw, flags, fg_bg, hilite); @@ -1300,7 +1297,7 @@ ScrnRefresh(XtermWidget xw, int base = PACK_PAIR(chars, widec, i); int combo = PACK_PAIR(com_lo, com_hi, i); - if (iswide(base)) + if (isWide(base)) my_x = CurCursorX(screen, ROW2INX(screen, row), i - 1); @@ -1312,7 +1309,7 @@ ScrnRefresh(XtermWidget xw, gc, my_x, y, cs, PAIRED_CHARS(com_lo + i, com_hi + i), - 1, iswide(base)); + 1, isWide(base)); } } }); @@ -1379,7 +1376,7 @@ ClearBufRows(XtermWidget xw, int last) { TScreen *screen = &(xw->screen); - unsigned len = MaxCols(screen); + unsigned len = (unsigned) MaxCols(screen); int row; TRACE(("ClearBufRows %d..%d\n", first, last)); @@ -1529,8 +1526,8 @@ ScreenResize(XtermWidget xw, } else if (FullHeight(screen) == height && FullWidth(screen) == width) return (0); /* nothing has changed at all */ - screen->fullVwin.fullheight = height; - screen->fullVwin.fullwidth = width; + screen->fullVwin.fullheight = (Dimension) height; + screen->fullVwin.fullwidth = (Dimension) width; ResizeScrollBar(xw); ResizeSelection(screen, rows, cols); @@ -1545,10 +1542,10 @@ ScreenResize(XtermWidget xw, MaxRows(screen) * screen->iconVwin.f_height; changes.width = screen->iconVwin.fullwidth = - screen->iconVwin.width + 2 * xw->misc.icon_border_width; + (Dimension) (screen->iconVwin.width + 2 * xw->misc.icon_border_width); changes.height = screen->iconVwin.fullheight = - screen->iconVwin.height + 2 * xw->misc.icon_border_width; - changes.border_width = xw->misc.icon_border_width; + (Dimension) (screen->iconVwin.height + 2 * xw->misc.icon_border_width); + changes.border_width = (int) xw->misc.icon_border_width; TRACE(("resizing icon window %dx%d\n", changes.height, changes.width)); XConfigureWindow(XtDisplay(xw), screen->iconVwin.window, @@ -1708,9 +1705,9 @@ ScrnFillRectangle(XtermWidget xw, TRACE(("filling rectangle with '%c' flags %#x\n", value, flags)); if (validRect(xw, target)) { - unsigned left = target->left - 1; - unsigned size = target->right - left; - Char attrs = flags; + unsigned left = (unsigned) (target->left - 1); + unsigned size = (unsigned) (target->right - (int) left); + unsigned attrs = flags; int row, col; attrs &= ATTRIBUTES; @@ -1722,19 +1719,19 @@ ScrnFillRectangle(XtermWidget xw, * Fill attributes, preserving "protected" flag, as well as * colors if asked. */ - for (col = left; col < target->right; ++col) { - Char temp = SCRN_BUF_ATTRS(screen, row)[col]; + for (col = (int) left; col < target->right; ++col) { + unsigned temp = SCRN_BUF_ATTRS(screen, row)[col]; if (!keepColors) { temp &= ~(FG_COLOR | BG_COLOR); } temp = attrs | (temp & (FG_COLOR | BG_COLOR | PROTECTED)); temp |= CHARDRAWN; - SCRN_BUF_ATTRS(screen, row)[col] = temp; + SCRN_BUF_ATTRS(screen, row)[col] = (Char) temp; #if OPT_ISO_COLORS if (attrs & (FG_COLOR | BG_COLOR)) { if_OPT_EXT_COLORS(screen, { - SCRN_BUF_FGRND(screen, row)[col] = xw->sgr_foreground; - SCRN_BUF_BGRND(screen, row)[col] = xw->cur_background; + SCRN_BUF_FGRND(screen, row)[col] = (Char) xw->sgr_foreground; + SCRN_BUF_BGRND(screen, row)[col] = (Char) xw->cur_background; }); if_OPT_ISO_TRADITIONAL_COLORS(screen, { SCRN_BUF_COLOR(screen, row)[col] = xtermColorPair(xw); @@ -1785,9 +1782,9 @@ ScrnCopyRectangle(XtermWidget xw, XTermRect * source, int nparam, int *params) params, &target); if (validRect(xw, &target)) { - unsigned high = (source->bottom - source->top) + 1; - unsigned wide = (source->right - source->left) + 1; - unsigned size = (high * wide * MAX_PTRS); + int high = (source->bottom - source->top) + 1; + int wide = (source->right - source->left) + 1; + unsigned size = (unsigned) (high * wide * MAX_PTRS); int row, col, n, j; Char *cells = TypeMallocN(Char, size); @@ -1942,7 +1939,7 @@ ScrnMarkRectangle(XtermWidget xw, TRACE(("first mask-change is %#x\n", SCRN_BUF_ATTRS(screen, row)[col] ^ flags)); #endif - SCRN_BUF_ATTRS(screen, row)[col] = flags; + SCRN_BUF_ATTRS(screen, row)[col] = (Char) flags; } } ScrnRefresh(xw, diff --git a/app/xterm/scrollbar.c b/app/xterm/scrollbar.c index 8de6cf7e9..db65015d3 100644 --- a/app/xterm/scrollbar.c +++ b/app/xterm/scrollbar.c @@ -1,9 +1,9 @@ -/* $XTermId: scrollbar.c,v 1.137 2008/12/30 15:40:13 tom Exp $ */ +/* $XTermId: scrollbar.c,v 1.139 2009/02/12 00:07:53 tom Exp $ */ /* $XFree86: xc/programs/xterm/scrollbar.c,v 3.48 2006/02/13 01:14:59 dickey Exp $ */ /* - * Copyright 2000-2007,2008 by Thomas E. Dickey + * Copyright 2000-2008,2009 by Thomas E. Dickey * * All Rights Reserved * @@ -78,7 +78,7 @@ * 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) ((xw)->screen.scrollBarBorder) +#define SCROLLBAR_BORDER(xw) (TScreenOf(xw)->scrollBarBorder) #if OPT_TOOLBAR #define ScrollBarBorder(xw) (BorderWidth(xw) ? SCROLLBAR_BORDER(xw) : 0) #else @@ -96,10 +96,10 @@ static void ScrollTextUpDownBy PROTO_XT_CALLBACK_ARGS; void DoResizeScreen(XtermWidget xw) { - TScreen *screen = &xw->screen; + TScreen *screen = TScreenOf(xw); - int border = 2 * xw->screen.border; - int min_wide = border + xw->screen.fullVwin.sb_info.width; + 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; @@ -173,8 +173,8 @@ DoResizeScreen(XtermWidget xw) XSetWMNormalHints(screen->display, XtWindow(SHELL_OF(xw)), &xw->hints); - reqWidth = MaxCols(screen) * FontWidth(screen) + min_wide; - reqHeight = MaxRows(screen) * FontHeight(screen) + min_high; + reqWidth = (Dimension) (MaxCols(screen) * FontWidth(screen) + min_wide); + reqHeight = (Dimension) (MaxRows(screen) * FontHeight(screen) + min_high); TRACE(("...requesting screensize chars %dx%d, pixels %dx%d\n", MaxRows(screen), @@ -220,25 +220,6 @@ DoResizeScreen(XtermWidget xw) #endif /* NO_ACTIVE_ICON */ } -static XtermWidget -xtermScroller(Widget xw) -{ - XtermWidget result = 0; - - if (xw != 0) { - if (IsXtermWidget(xw)) { - result = (XtermWidget) xw; - } else { - /* - * This may have been the scrollbar widget. Try its parent, which - * would be the VT100 widget. - */ - result = xtermScroller(XtParent(xw)); - } - } - return result; -} - static Widget CreateScrollBar(XtermWidget xw, int x, int y, int height) { @@ -262,10 +243,10 @@ CreateScrollBar(XtermWidget xw, int x, int y, int height) void ScrollBarReverseVideo(Widget scrollWidget) { - XtermWidget xw = xtermScroller(scrollWidget); + XtermWidget xw = getXtermWidget(scrollWidget); if (xw != 0) { - SbInfo *sb = &(xw->screen.fullVwin.sb_info); + SbInfo *sb = &(TScreenOf(xw)->fullVwin.sb_info); Arg args[4]; Cardinal nargs = XtNumber(args); @@ -303,10 +284,10 @@ ScrollBarReverseVideo(Widget scrollWidget) void ScrollBarDrawThumb(Widget scrollWidget) { - XtermWidget xw = xtermScroller(scrollWidget); + XtermWidget xw = getXtermWidget(scrollWidget); if (xw != 0) { - TScreen *screen = &xw->screen; + TScreen *screen = TScreenOf(xw); int thumbTop, thumbHeight, totalHeight; thumbTop = ROW2INX(screen, screen->savedlines); @@ -322,7 +303,7 @@ ScrollBarDrawThumb(Widget scrollWidget) void ResizeScrollBar(XtermWidget xw) { - TScreen *screen = &(xw->screen); + TScreen *screen = TScreenOf(xw); if (screen->scrollWidget != 0) { int height = screen->fullVwin.height + screen->border * 2; @@ -342,10 +323,10 @@ ResizeScrollBar(XtermWidget xw) XtConfigureWidget( screen->scrollWidget, - xpos, - ypos, - width, - height, + (Position) xpos, + (Position) ypos, + (Dimension) width, + (Dimension) height, BorderWidth(screen->scrollWidget)); ScrollBarDrawThumb(screen->scrollWidget); } @@ -354,7 +335,7 @@ ResizeScrollBar(XtermWidget xw) void WindowScroll(XtermWidget xw, int top) { - TScreen *screen = &(xw->screen); + TScreen *screen = TScreenOf(xw); int i, lines; int scrolltop, scrollheight, refreshtop; @@ -390,7 +371,7 @@ WindowScroll(XtermWidget xw, int top) OriginX(screen), OriginY(screen) + refreshtop * FontHeight(screen), (unsigned) Width(screen), - (unsigned) lines * FontHeight(screen), + (unsigned) (lines * FontHeight(screen)), False); ScrnRefresh(xw, refreshtop, 0, lines, MaxCols(screen), False); @@ -407,7 +388,7 @@ WindowScroll(XtermWidget xw, int top) void updateRightScrollbar(XtermWidget xw) { - TScreen *screen = &xw->screen; + TScreen *screen = TScreenOf(xw); if (xw->misc.useRight && screen->fullVwin.fullwidth < xw->core.width) @@ -420,7 +401,7 @@ updateRightScrollbar(XtermWidget xw) void ScrollBarOn(XtermWidget xw, int init, int doalloc) { - TScreen *screen = &xw->screen; + TScreen *screen = TScreenOf(xw); int i, j, k; if (screen->fullVwin.sb_info.width || IsIcon(screen)) @@ -447,13 +428,16 @@ ScrollBarOn(XtermWidget xw, int init, int doalloc) /* FIXME: this is not integrated well with Allocate */ if ((screen->allbuf = TypeRealloc(ScrnPtr, - MAX_PTRS * (screen->max_row + 2 + screen->savelines), + (unsigned) (MAX_PTRS + * (screen->max_row + 2 + + screen->savelines)), screen->visbuf)) == NULL) { SysError(ERROR_SBRALLOC); } screen->visbuf = &screen->allbuf[MAX_PTRS * screen->savelines]; memmove((char *) screen->visbuf, (char *) screen->allbuf, - MAX_PTRS * (screen->max_row + 2) * sizeof(char *)); + (unsigned) (MAX_PTRS * (screen->max_row + 2)) + * sizeof(char *)); for (i = k = 0; i < screen->savelines; i++) { k += BUF_HEAD; for (j = BUF_HEAD; j < MAX_PTRS; j++) { @@ -499,7 +483,7 @@ ScrollBarOn(XtermWidget xw, int init, int doalloc) void ScrollBarOff(XtermWidget xw) { - TScreen *screen = &xw->screen; + TScreen *screen = TScreenOf(xw); if (!screen->fullVwin.sb_info.width || IsIcon(screen)) return; @@ -525,7 +509,7 @@ ScrollBarOff(XtermWidget xw) void ToggleScrollBar(XtermWidget xw) { - TScreen *screen = &xw->screen; + TScreen *screen = TScreenOf(xw); if (IsIcon(screen)) { Bell(XkbBI_MinorError, 0); @@ -548,11 +532,11 @@ ScrollTextTo( XtPointer client_data GCC_UNUSED, XtPointer call_data) { - XtermWidget xw = xtermScroller(scrollbarWidget); + XtermWidget xw = getXtermWidget(scrollbarWidget); if (xw != 0) { float *topPercent = (float *) call_data; - TScreen *screen = &xw->screen; + TScreen *screen = TScreenOf(xw); int thumbTop; /* relative to first saved line */ int newTopLine; @@ -573,12 +557,12 @@ ScrollTextUpDownBy( XtPointer client_data GCC_UNUSED, XtPointer call_data) { - XtermWidget xw = xtermScroller(scrollbarWidget); + XtermWidget xw = getXtermWidget(scrollbarWidget); if (xw != 0) { long pixels = (long) call_data; - TScreen *screen = &xw->screen; + TScreen *screen = TScreenOf(xw); int rowOnScreen, newTopLine; rowOnScreen = pixels / FontHeight(screen); @@ -670,24 +654,19 @@ params_to_pixels(TScreen * screen, String * params, Cardinal n) } static long -AmountToScroll(Widget xw, String * params, Cardinal nparams) +AmountToScroll(Widget w, String * params, Cardinal nparams) { - if (xw != 0) { - if (IsXtermWidget(xw)) { - TScreen *screen = TScreenOf((XtermWidget) xw); - if (nparams > 2 - && screen->send_mouse_pos != MOUSE_OFF) - return 0; - return params_to_pixels(screen, params, nparams); - } else { - /* - * This may have been the scrollbar widget. Try its parent, which - * would be the VT100 widget. - */ - return AmountToScroll(XtParent(xw), params, 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 0; + return result; } /*ARGSUSED*/ diff --git a/app/xterm/util.c b/app/xterm/util.c index 8e046f1b2..32cf4311e 100644 --- a/app/xterm/util.c +++ b/app/xterm/util.c @@ -1,7 +1,7 @@ -/* $XTermId: util.c,v 1.410 2008/12/30 16:43:46 tom Exp $ */ +/* $XTermId: util.c,v 1.420 2009/02/13 23:38:26 tom Exp $ */ /* - * Copyright 1999-2007,2008 by Thomas E. Dickey + * Copyright 1999-2008,2009 by Thomas E. Dickey * * All Rights Reserved * @@ -104,7 +104,7 @@ int DamagedCells(TScreen * screen, unsigned n, int *klp, int *krp, int row, int col) { int kl = col; - int kr = col + n; + int kr = col + (int) n; if (XTERM_CELL(row, kl) == HIDDEN_CHAR) { while (kl > 0) { @@ -214,7 +214,7 @@ FlushScroll(XtermWidget xw) ClearCurBackground(xw, (int) refreshtop * FontHeight(screen) + screen->border, (int) OriginX(screen), - (unsigned) refreshheight * FontHeight(screen), + (unsigned) (refreshheight * FontHeight(screen)), (unsigned) Width(screen)); ScrnRefresh(xw, refreshtop, 0, refreshheight, MaxCols(screen), False); @@ -422,9 +422,9 @@ xtermScroll(XtermWidget xw, int amount) int refreshheight; int scrolltop; int scrollheight; - Boolean scroll_all_lines = (screen->scrollWidget - && !screen->alternate - && screen->top_marg == 0); + Boolean scroll_all_lines = (Boolean) (screen->scrollWidget + && !screen->alternate + && screen->top_marg == 0); TRACE(("xtermScroll count=%d\n", amount)); @@ -505,7 +505,7 @@ xtermScroll(XtermWidget xw, int amount) ClearCurBackground(xw, (int) refreshtop * FontHeight(screen) + screen->border, (int) OriginX(screen), - (unsigned) refreshheight * FontHeight(screen), + (unsigned) (refreshheight * FontHeight(screen)), (unsigned) Width(screen)); if (refreshheight > shift) refreshheight = shift; @@ -610,7 +610,7 @@ RevScroll(XtermWidget xw, int amount) ClearCurBackground(xw, (int) refreshtop * FontHeight(screen) + screen->border, (int) OriginX(screen), - (unsigned) refreshheight * FontHeight(screen), + (unsigned) (refreshheight * FontHeight(screen)), (unsigned) Width(screen)); } } @@ -631,21 +631,21 @@ RevScroll(XtermWidget xw, int amount) * the current cursor position. update cursor position. */ void -WriteText(XtermWidget xw, PAIRED_CHARS(Char * str, Char * str2), Cardinal len) +WriteText(XtermWidget xw, IChar * str, Cardinal len) { TScreen *screen = &(xw->screen); ScrnPtr temp_str = 0; unsigned test; unsigned flags = xw->flags; unsigned fg_bg = makeColorPair(xw->cur_foreground, xw->cur_background); - unsigned cells = visual_width(PAIRED_CHARS(str, str2), len); + unsigned cells = visual_width(str, len); GC currentGC; TRACE(("WriteText (%2d,%2d) (%d) %3d:%s\n", screen->cur_row, screen->cur_col, curXtermChrSet(xw, screen->cur_row), - len, visibleChars(PAIRED_CHARS(str, str2), len))); + len, visibleIChar(str, len))); if (ScrnHaveSelection(screen) && ScrnIsLineInSelection(screen, INX2ROW(screen, screen->cur_row))) { @@ -673,17 +673,9 @@ WriteText(XtermWidget xw, PAIRED_CHARS(Char * str, Char * str2), Cardinal len) }); if (flags & INVISIBLE) { - if (cells > len) { - str = temp_str = TypeMallocN(Char, cells); - if (str == 0) - return; - } - len = cells; - - memset(str, ' ', len); - if_OPT_WIDE_CHARS(screen, { - str2 = 0; - }); + Cardinal n; + for (n = 0; n < cells; ++n) + str[n] = ' '; } TRACE(("WriteText calling drawXtermText (%d,%d)\n", @@ -696,16 +688,16 @@ WriteText(XtermWidget xw, PAIRED_CHARS(Char * str, Char * str2), Cardinal len) /* make sure that the correct GC is current */ currentGC = updatedXtermGC(xw, flags, fg_bg, False); - drawXtermText(xw, test & DRAWX_MASK, currentGC, - CurCursorX(screen, screen->cur_row, screen->cur_col), - CursorY(screen, screen->cur_row), - curXtermChrSet(xw, screen->cur_row), - PAIRED_CHARS(str, str2), len, 0); + drawXtermIChars(xw, test & DRAWX_MASK, currentGC, + CurCursorX(screen, screen->cur_row, screen->cur_col), + CursorY(screen, screen->cur_row), + curXtermChrSet(xw, screen->cur_row), + str, len, 0); resetXtermGC(xw, flags, False); } - ScrnWriteText(xw, PAIRED_CHARS(str, str2), flags, fg_bg, len); + ScrnWriteText(xw, str, flags, fg_bg, len); CursorForward(screen, (int) cells); #if OPT_ZICONBEEP /* Flag icon name with "***" on window output when iconified. @@ -722,15 +714,9 @@ WriteText(XtermWidget xw, PAIRED_CHARS(Char * str, Char * str2), Cardinal len) if (icon_name != NULL) { screen->zIconBeep_flagged = True; - ChangeIconName(icon_name); - } - if (resource.zIconBeep > 0) { -#if defined(HAVE_XKB_BELL_EXT) - XkbBell(XtDisplay(toplevel), VShellWindow, resource.zIconBeep, XkbBI_Info); -#else - XBell(XtDisplay(toplevel), resource.zIconBeep); -#endif + ChangeIconName(xw, icon_name); } + xtermBell(xw, resource.zIconBeep, XkbBI_Info); } mapstate = -1; #endif /* OPT_ZICONBEEP */ @@ -798,7 +784,7 @@ InsertLine(XtermWidget xw, int n) ClearCurBackground(xw, (int) refreshtop * FontHeight(screen) + screen->border, (int) OriginX(screen), - (unsigned) refreshheight * FontHeight(screen), + (unsigned) (refreshheight * FontHeight(screen)), (unsigned) Width(screen)); } } @@ -886,7 +872,7 @@ DeleteLine(XtermWidget xw, int n) ClearCurBackground(xw, (int) refreshtop * FontHeight(screen) + screen->border, (int) OriginX(screen), - (unsigned) refreshheight * FontHeight(screen), + (unsigned) (refreshheight * FontHeight(screen)), (unsigned) Width(screen)); } } @@ -933,14 +919,14 @@ InsertChar(XtermWidget xw, unsigned n) screen->do_wrap = False; assert(screen->cur_col <= screen->max_col); - limit = MaxCols(screen) - screen->cur_col; + limit = (unsigned) (MaxCols(screen) - screen->cur_col); if (n > limit) n = limit; assert(n != 0); if (AddToVisible(xw)) { - int col = MaxCols(screen) - n; + int col = MaxCols(screen) - (int) n; /* * If we shift part of a multi-column character, fill the rest @@ -953,7 +939,7 @@ InsertChar(XtermWidget xw, unsigned n) if (DamagedCurCells(screen, n, &kl, (int *) 0) && kr > kl) { ClearInLine(xw, screen->cur_row, kl, (unsigned) (kr - kl + 1)); } - kr = screen->max_col - n + 1; + kr = screen->max_col - (int) n + 1; if (DamagedCells(screen, n, &kl, (int *) 0, screen->cur_row, kr) && kr > kl) { @@ -963,7 +949,7 @@ InsertChar(XtermWidget xw, unsigned n) #if OPT_DEC_CHRSET if (CSET_DOUBLE(SCRN_BUF_CSETS(screen, screen->cur_row)[0])) { - col = MaxCols(screen) / 2 - n; + col = MaxCols(screen) / 2 - (int) n; } #endif /* @@ -981,7 +967,7 @@ InsertChar(XtermWidget xw, unsigned n) CursorY(screen, screen->cur_row), CurCursorX(screen, screen->cur_row, screen->cur_col), (unsigned) FontHeight(screen), - n * CurFontWidth(screen, screen->cur_row)); + n * (unsigned) CurFontWidth(screen, screen->cur_row)); } /* adjust screen->buf */ ScrnInsertChar(xw, n); @@ -1009,14 +995,14 @@ DeleteChar(XtermWidget xw, unsigned n) screen->do_wrap = False; assert(screen->cur_col <= screen->max_col); - limit = MaxCols(screen) - screen->cur_col; + limit = (unsigned) (MaxCols(screen) - screen->cur_col); if (n > limit) n = limit; assert(n != 0); if (AddToVisible(xw)) { - int col = MaxCols(screen) - n; + int col = MaxCols(screen) - (int) n; /* * If we delete part of a multi-column character, fill the rest @@ -1031,11 +1017,11 @@ DeleteChar(XtermWidget xw, unsigned n) #if OPT_DEC_CHRSET if (CSET_DOUBLE(SCRN_BUF_CSETS(screen, screen->cur_row)[0])) { - col = MaxCols(screen) / 2 - n; + col = MaxCols(screen) / 2 - (int) n; } #endif horizontal_copy_area(xw, - (int) (screen->cur_col + n), + (screen->cur_col + (int) n), col - screen->cur_col, -((int) n)); @@ -1043,7 +1029,7 @@ DeleteChar(XtermWidget xw, unsigned n) CursorY(screen, screen->cur_row), CurCursorX(screen, screen->cur_row, col), (unsigned) FontHeight(screen), - n * CurFontWidth(screen, screen->cur_row)); + n * (unsigned) CurFontWidth(screen, screen->cur_row)); } if (n != 0) { /* adjust screen->buf */ @@ -1061,7 +1047,7 @@ ClearAbove(XtermWidget xw) if (screen->protected_mode != OFF_PROTECT) { int row; - unsigned len = MaxCols(screen); + unsigned len = (unsigned) MaxCols(screen); assert(screen->max_col >= 0); for (row = 0; row <= screen->max_row; row++) @@ -1103,7 +1089,7 @@ ClearBelow(XtermWidget xw) if (screen->protected_mode != OFF_PROTECT) { int row; - unsigned len = MaxCols(screen); + unsigned len = (unsigned) MaxCols(screen); assert(screen->max_col >= 0); for (row = screen->cur_row + 1; row <= screen->max_row; row++) @@ -1148,7 +1134,7 @@ ClearInLine2(XtermWidget xw, int flags, int row, int col, unsigned len) } if (col + (int) len >= MaxCols(screen)) { - len = MaxCols(screen) - col; + len = (unsigned) (MaxCols(screen) - col); } /* If we've marked protected text on the screen, we'll have to @@ -1180,7 +1166,7 @@ ClearInLine2(XtermWidget xw, int flags, int row, int col, unsigned len) /* setup for another segment, past the protected text */ if (!done) { attrs += n; - col += n; + col += (int) n; len -= n; } } while (!done); @@ -1200,7 +1186,7 @@ ClearInLine2(XtermWidget xw, int flags, int row, int col, unsigned len) CursorY(screen, row), CurCursorX(screen, row, col), (unsigned) FontHeight(screen), - len * CurFontWidth(screen, row)); + len * (unsigned) CurFontWidth(screen, row)); } if (len != 0) { @@ -1236,7 +1222,7 @@ void ClearRight(XtermWidget xw, int n) { TScreen *screen = &(xw->screen); - unsigned len = (MaxCols(screen) - screen->cur_col); + unsigned len = (unsigned) (MaxCols(screen) - screen->cur_col); assert(screen->max_col >= 0); assert(screen->max_col >= screen->cur_col); @@ -1247,7 +1233,7 @@ ClearRight(XtermWidget xw, int n) n = 1; if (len > (unsigned) n) - len = n; + len = (unsigned) n; if (AddToVisible(xw)) { if_OPT_WIDE_CHARS(screen, { @@ -1261,7 +1247,7 @@ ClearRight(XtermWidget xw, int n) if (kl < xx) { ClearInLine2(xw, 0, row, kl, (unsigned) (xx - kl)); } - xx = col + len - 1; + xx = col + (int) len - 1; if (kr > xx) { ClearInLine2(xw, 0, row, xx + 1, (unsigned) (kr - xx)); } @@ -1284,7 +1270,7 @@ static void ClearLeft(XtermWidget xw) { TScreen *screen = &(xw->screen); - unsigned len = screen->cur_col + 1; + unsigned len = (unsigned) screen->cur_col + 1; assert(screen->cur_col >= 0); if (AddToVisible(xw)) { @@ -1309,7 +1295,7 @@ static void ClearLine(XtermWidget xw) { TScreen *screen = &(xw->screen); - unsigned len = MaxCols(screen); + unsigned len = (unsigned) MaxCols(screen); assert(screen->max_col >= 0); (void) ClearInLine(xw, screen->cur_row, 0, len); @@ -1417,7 +1403,7 @@ do_erase_display(XtermWidget xw, int param, int mode) if (screen->protected_mode != OFF_PROTECT) { int row; int rc = 1; - unsigned len = MaxCols(screen); + unsigned len = (unsigned) MaxCols(screen); assert(screen->max_col >= 0); for (row = 0; row <= screen->max_row; row++) @@ -1527,7 +1513,7 @@ horizontal_copy_area(XtermWidget xw, int src_y = CursorY(screen, screen->cur_row); copy_area(xw, src_x, src_y, - (unsigned) nchars * CurFontWidth(screen, screen->cur_row), + (unsigned) (nchars * CurFontWidth(screen, screen->cur_row)), (unsigned) FontHeight(screen), src_x + amount * CurFontWidth(screen, screen->cur_row), src_y); } @@ -1604,10 +1590,10 @@ HandleExposure(XtermWidget xw, XEvent * event) area being exposed. */ int both_x1 = Max(screen->copy_src_x, reply->x); int both_y1 = Max(screen->copy_src_y, reply->y); - int both_x2 = Min(screen->copy_src_x + screen->copy_width, - (unsigned) (reply->x + reply->width)); - int both_y2 = Min(screen->copy_src_y + screen->copy_height, - (unsigned) (reply->y + reply->height)); + int both_x2 = Min(screen->copy_src_x + (int) screen->copy_width, + (reply->x + (int) reply->width)); + int both_y2 = Min(screen->copy_src_y + (int) screen->copy_height, + (reply->y + (int) reply->height)); int value = 0; /* was anything copied affected? */ @@ -1864,13 +1850,13 @@ xtermRepaint(XtermWidget xw) Boolean isDefaultForeground(const char *name) { - return !x_strcasecmp(name, XtDefaultForeground); + return (Boolean) ! x_strcasecmp(name, XtDefaultForeground); } Boolean isDefaultBackground(const char *name) { - return !x_strcasecmp(name, XtDefaultBackground); + return (Boolean) ! x_strcasecmp(name, XtDefaultBackground); } #if OPT_WIDE_CHARS @@ -2017,7 +2003,7 @@ ReverseVideo(XtermWidget xw) swapVTwinGCs(xw, &(screen->iconVwin)); #endif /* NO_ACTIVE_ICON */ - xw->misc.re_verse = !xw->misc.re_verse; + xw->misc.re_verse = (Boolean) ! xw->misc.re_verse; if (XtIsRealized((Widget) xw)) { xtermDisplayCursor(xw); @@ -2212,8 +2198,8 @@ xtermXftDrawString(XtermWidget xw, continue; sbuf[dst].ucs4 = wc; - sbuf[dst].x = x + fwidth * ncells; - sbuf[dst].y = y; + sbuf[dst].x = (short) (x + fwidth * ncells); + sbuf[dst].y = (short) (y); currFont = (charWidth == 2 && wfont != 0) ? wfont : font; ncells += charWidth; @@ -2329,7 +2315,7 @@ ucs_workaround(XtermWidget xw, Char text[2]; Char text2[2]; - text[0] = eqv; + text[0] = (Char) eqv; text2[0] = 0; do { @@ -2442,7 +2428,7 @@ xtermFillCells(XtermWidget xw, XFillRectangle(screen->display, VWindow(screen), getCgsGC(xw, currentWin, dstId), x, y, - len * FontWidth(screen), + len * (Cardinal) FontWidth(screen), (unsigned) FontHeight(screen)); } } @@ -2494,8 +2480,8 @@ xtermSetClipRectangles(Display * dpy, int clip_y = y - FontHeight(screen) + FontDescent(screen); \ clip.x = 0; \ clip.y = 0; \ - clip.height = FontHeight(screen); \ - clip.width = pwidth * plength; \ + clip.height = (unsigned short) FontHeight(screen); \ + clip.width = (unsigned short) (pwidth * plength); \ xtermSetClipRectangles(screen->display, gc, \ clip_x, clip_y, \ &clip, 1, Unsorted); \ @@ -2515,8 +2501,8 @@ xtermSetClipRectangles(Display * dpy, int clip_y = py - FontHeight(screen) + FontDescent(screen); \ clip.x = 0; \ clip.y = 0; \ - clip.height = FontHeight(screen); \ - clip.width = FontWidth(screen) * plength; \ + clip.height = (unsigned short) (FontHeight(screen)); \ + clip.width = (unsigned short) (FontWidth(screen) * plength); \ XftDrawSetClipRectangles (screen->renderDraw, \ clip_x, clip_y, \ &clip, 1); \ @@ -2631,18 +2617,18 @@ drawXtermText(XtermWidget xw, rect.x = 0; rect.y = 0; - rect.width = len * font_width; - rect.height = FontHeight(screen); + rect.width = (unsigned short) ((int) len * font_width); + rect.height = (unsigned short) (FontHeight(screen)); TRACE(("drawing %s\n", visibleChrsetName(chrset))); switch (chrset) { case CSET_DHL_TOP: - rect.y = -(fs->ascent / 2); + rect.y = (short) -(fs->ascent / 2); y -= rect.y; flags |= DOUBLEHFONT; break; case CSET_DHL_BOT: - rect.y = rect.height - (fs->ascent / 2); + rect.y = (short) (rect.height - (fs->ascent / 2)); y -= rect.y; flags |= DOUBLEHFONT; break; @@ -2685,7 +2671,7 @@ drawXtermText(XtermWidget xw, x, y, 0, PAIRED_CHARS(text, text2), len, on_wide); - x += len * FontWidth(screen); + x += (int) len *FontWidth(screen); } TRACE(("drawtext [%4d,%4d]\n", y, x)); @@ -2784,7 +2770,7 @@ drawXtermText(XtermWidget xw, for (last = 0; last < (int) len; last++) { Boolean replace = False; Boolean missing = False; - unsigned ch = PACK_PAIR(text, text2, last); + unsigned ch = (unsigned) PACK_PAIR(text, text2, last); int nc; Char temp[2]; #if OPT_WIDE_CHARS @@ -2854,13 +2840,13 @@ drawXtermText(XtermWidget xw, text2 + first), (Cardinal) (last - first)); curX += nc * FontWidth(screen); - underline_len += nc; + underline_len += (Cardinal) nc; } if (missing) { old_wide = screen->fnt_wide; old_high = screen->fnt_high; - screen->fnt_wide = FontWidth(screen); - screen->fnt_high = FontHeight(screen); + screen->fnt_wide = (Dimension) FontWidth(screen); + screen->fnt_high = (Dimension) FontHeight(screen); xtermDrawBoxChar(xw, ch, flags, gc, curX, y - FontAscent(screen), 1); curX += FontWidth(screen); @@ -2882,7 +2868,7 @@ drawXtermText(XtermWidget xw, temp2), 1); curX += nc * FontWidth(screen); - underline_len += nc; + underline_len += (Cardinal) nc; } first = last + 1; } @@ -2922,7 +2908,7 @@ drawXtermText(XtermWidget xw, x + (int) underline_len * FontWidth(screen) - 1, y); } - return x + len * FontWidth(screen); + return x + (int) len *FontWidth(screen); } #endif /* OPT_RENDERFONT */ /* @@ -2971,7 +2957,7 @@ drawXtermText(XtermWidget xw, : NormalFont(screen)); int last, first = 0; for (last = 0; last < (int) len; last++) { - unsigned ch = PACK_PAIR(text, text2, last); + unsigned ch = (unsigned) PACK_PAIR(text, text2, last); Bool isMissing; int ch_width; #if OPT_WIDE_CHARS @@ -3024,13 +3010,13 @@ drawXtermText(XtermWidget xw, } } if (last <= first) { - return x + real_length * FontWidth(screen); + return x + (int) real_length *FontWidth(screen); } text += first; #if OPT_WIDE_CHARS text2 += first; #endif - len = last - first; + len = (Cardinal) (last - first); flags |= NOTRANSLATION; if (DrawX(first) != x) { return drawXtermText(xw, @@ -3070,7 +3056,7 @@ drawXtermText(XtermWidget xw, } for (src = dst = 0; src < (int) len; src++) { - unsigned ch = PACK_PAIR(text, text2, src); + unsigned ch = (unsigned) PACK_PAIR(text, text2, src); if (ch == HIDDEN_CHAR) continue; @@ -3166,9 +3152,9 @@ drawXtermText(XtermWidget xw, - NormalFont(screen)->ascent); if (thisFp->max_bounds.width == NormalFont(screen)->max_bounds.width * 2) { - underline_len = real_length = dst * 2; + underline_len = real_length = (Cardinal) (dst * 2); } else if (cgsId == gcWide || cgsId == gcWBold) { - underline_len = real_length = dst * 2; + underline_len = real_length = (Cardinal) (dst * 2); xtermFillCells(xw, flags, gc, @@ -3192,7 +3178,7 @@ drawXtermText(XtermWidget xw, } if ((flags & BOLDATTR(screen)) && screen->enbolden) { - beginClipping(screen, gc, font_width, len); + beginClipping(screen, gc, (Cardinal) font_width, len); XDrawString16(screen->display, VWindow(screen), gc, x + 1, y + ascent_adjust, @@ -3203,7 +3189,7 @@ drawXtermText(XtermWidget xw, } else #endif /* OPT_WIDE_CHARS */ { - int length = len; /* X should have used unsigned */ + int length = (int) len; /* X should have used unsigned */ if (flags & NOBACKGROUND) { XDrawString(screen->display, VWindow(screen), gc, @@ -3212,7 +3198,7 @@ drawXtermText(XtermWidget xw, XDrawImageString(screen->display, VWindow(screen), gc, x, y, (char *) text, length); } - underline_len = length; + underline_len = (Cardinal) length; if ((flags & BOLDATTR(screen)) && screen->enbolden) { beginClipping(screen, gc, font_width, length); XDrawString(screen->display, VWindow(screen), gc, @@ -3225,10 +3211,61 @@ drawXtermText(XtermWidget xw, if (FontDescent(screen) > 1) y++; XDrawLine(screen->display, VWindow(screen), gc, - x, y, (int) (x + underline_len * font_width - 1), y); + x, y, (x + (int) underline_len * font_width - 1), y); + } + + return x + (int) real_length *FontWidth(screen); +} + +#if OPT_WIDE_CHARS +/* + * Allocate buffer - workaround for wide-character interfaces. + */ +void +allocXtermChars(Char ** buffer, Cardinal length) +{ + if (*buffer == 0) { + *buffer = (Char *) XtMalloc(length); + } else { + *buffer = (Char *) XtRealloc((char *) *buffer, length); } +} +#endif - return x + real_length * FontWidth(screen); +int +drawXtermIChars(XtermWidget xw, + unsigned flags, + GC gc, + int x, + int y, + int chrset, + IChar * text, + Cardinal len, + int on_wide) +{ + int rc = 0; +#if OPT_WIDE_CHARS + static Char *text1 = 0; + static Char *text2 = 0; + static Cardinal used = 0; + Cardinal n; + + if (text != 0) { + if (len >= used) { + used = 1 + (2 * len); + allocXtermChars(&text1, used); + allocXtermChars(&text2, used); + } + for (n = 0; n < len; ++n) { + text1[n] = LO_BYTE(text[n]); + text2[n] = HI_BYTE(text[n]); + } + rc = drawXtermText(xw, flags, gc, x, y, chrset, text1, text2, len, on_wide); + } +#else + rc = drawXtermText(xw, flags, gc, x, y, chrset, text, len, on_wide); +#endif + return rc; } /* set up size hints for window manager; min 1 char by 1 char */ @@ -3288,8 +3325,8 @@ updatedXtermGC(XtermWidget xw, unsigned flags, unsigned fg_bg, Bool hilite) TScreen *screen = &(xw->screen); VTwin *win = WhichVWin(screen); CgsEnum cgsId = gcMAX; - int my_fg = extract_fg(xw, fg_bg, flags); - int my_bg = extract_bg(xw, fg_bg, flags); + unsigned my_fg = extract_fg(xw, fg_bg, flags); + unsigned my_bg = extract_bg(xw, fg_bg, flags); Pixel fg_pix = getXtermForeground(xw, flags, my_fg); Pixel bg_pix = getXtermBackground(xw, flags, my_bg); Pixel xx_pix; @@ -3297,8 +3334,10 @@ updatedXtermGC(XtermWidget xw, unsigned flags, unsigned fg_bg, Bool hilite) Pixel selbg_pix = T_COLOR(screen, HIGHLIGHT_BG); Pixel selfg_pix = T_COLOR(screen, HIGHLIGHT_FG); Boolean always = screen->hilite_color; - Boolean use_selbg = always || isNotForeground(xw, fg_pix, bg_pix, selbg_pix); - Boolean use_selfg = always && isNotBackground(xw, fg_pix, bg_pix, selfg_pix); + Boolean use_selbg = (Boolean) (always || + isNotForeground(xw, fg_pix, bg_pix, selbg_pix)); + Boolean use_selfg = (Boolean) (always && + isNotBackground(xw, fg_pix, bg_pix, selfg_pix)); #endif (void) fg_bg; @@ -3528,9 +3567,9 @@ putXtermCell(TScreen * screen, int row, int col, int ch) unsigned getXtermCellComb(TScreen * screen, int row, int col, int off) { - return PACK_PAIR(SCREEN_PTR(screen, row, off), - SCREEN_PTR(screen, row, off + 1), - col); + return (unsigned) PACK_PAIR(SCREEN_PTR(screen, row, off), + SCREEN_PTR(screen, row, off + 1), + col); } /* diff --git a/app/xterm/version.h b/app/xterm/version.h index 8b2d309c9..1a815e639 100644 --- a/app/xterm/version.h +++ b/app/xterm/version.h @@ -1,4 +1,4 @@ -/* $XTermId: version.h,v 1.295 2009/01/08 23:30:16 tom Exp $ */ +/* $XTermId: version.h,v 1.298 2009/02/08 01:58:12 tom Exp $ */ /* * These definitions are used to build the string that's printed in response to @@ -6,7 +6,7 @@ * version of X to which this version of xterm has been built. The number in * parentheses is my patch number (Thomas E. Dickey). */ -#define XTERM_PATCH 239 +#define XTERM_PATCH 242 #ifndef __vendorversion__ #define __vendorversion__ "XTerm/OpenBSD" diff --git a/app/xterm/wcwidth.c b/app/xterm/wcwidth.c index 5d0a4913d..77e101556 100644 --- a/app/xterm/wcwidth.c +++ b/app/xterm/wcwidth.c @@ -1,4 +1,4 @@ -/* $XTermId: wcwidth.c,v 1.19 2006/06/19 00:36:52 tom Exp $ */ +/* $XTermId: wcwidth.c,v 1.22 2009/02/13 19:53:12 tom Exp $ */ /* $XFree86: xc/programs/xterm/wcwidth.c,v 1.9 2006/06/19 00:36:52 dickey Exp $ */ @@ -54,7 +54,7 @@ * * http://www.unicode.org/unicode/reports/tr11/ * - * Markus Kuhn -- 2003-05-20 (Unicode 4.0) + * Markus Kuhn -- 2007-05-25 (Unicode 5.0) * * Permission to use, copy, modify, and distribute this software * for any purpose and without fee is hereby granted. The author @@ -128,15 +128,17 @@ int mk_wcwidth(wchar_t ucs) unsigned long cmp = (unsigned long) ucs; /* sorted list of non-overlapping intervals of non-spacing characters */ - /* generated by "uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B c" */ + /* generated by + * uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B c + */ static const struct interval combining[] = { { 0x0300, 0x036F }, { 0x0483, 0x0486 }, { 0x0488, 0x0489 }, - { 0x0591, 0x05B9 }, { 0x05BB, 0x05BD }, { 0x05BF, 0x05BF }, - { 0x05C1, 0x05C2 }, { 0x05C4, 0x05C5 }, { 0x05C7, 0x05C7 }, - { 0x0600, 0x0603 }, { 0x0610, 0x0615 }, { 0x064B, 0x065E }, - { 0x0670, 0x0670 }, { 0x06D6, 0x06E4 }, { 0x06E7, 0x06E8 }, - { 0x06EA, 0x06ED }, { 0x070F, 0x070F }, { 0x0711, 0x0711 }, - { 0x0730, 0x074A }, { 0x07A6, 0x07B0 }, { 0x0901, 0x0902 }, + { 0x0591, 0x05BD }, { 0x05BF, 0x05BF }, { 0x05C1, 0x05C2 }, + { 0x05C4, 0x05C5 }, { 0x05C7, 0x05C7 }, { 0x0600, 0x0603 }, + { 0x0610, 0x0615 }, { 0x064B, 0x065E }, { 0x0670, 0x0670 }, + { 0x06D6, 0x06E4 }, { 0x06E7, 0x06E8 }, { 0x06EA, 0x06ED }, + { 0x070F, 0x070F }, { 0x0711, 0x0711 }, { 0x0730, 0x074A }, + { 0x07A6, 0x07B0 }, { 0x07EB, 0x07F3 }, { 0x0901, 0x0902 }, { 0x093C, 0x093C }, { 0x0941, 0x0948 }, { 0x094D, 0x094D }, { 0x0951, 0x0954 }, { 0x0962, 0x0963 }, { 0x0981, 0x0981 }, { 0x09BC, 0x09BC }, { 0x09C1, 0x09C4 }, { 0x09CD, 0x09CD }, @@ -150,31 +152,34 @@ int mk_wcwidth(wchar_t ucs) { 0x0BCD, 0x0BCD }, { 0x0C3E, 0x0C40 }, { 0x0C46, 0x0C48 }, { 0x0C4A, 0x0C4D }, { 0x0C55, 0x0C56 }, { 0x0CBC, 0x0CBC }, { 0x0CBF, 0x0CBF }, { 0x0CC6, 0x0CC6 }, { 0x0CCC, 0x0CCD }, - { 0x0D41, 0x0D43 }, { 0x0D4D, 0x0D4D }, { 0x0DCA, 0x0DCA }, - { 0x0DD2, 0x0DD4 }, { 0x0DD6, 0x0DD6 }, { 0x0E31, 0x0E31 }, - { 0x0E34, 0x0E3A }, { 0x0E47, 0x0E4E }, { 0x0EB1, 0x0EB1 }, - { 0x0EB4, 0x0EB9 }, { 0x0EBB, 0x0EBC }, { 0x0EC8, 0x0ECD }, - { 0x0F18, 0x0F19 }, { 0x0F35, 0x0F35 }, { 0x0F37, 0x0F37 }, - { 0x0F39, 0x0F39 }, { 0x0F71, 0x0F7E }, { 0x0F80, 0x0F84 }, - { 0x0F86, 0x0F87 }, { 0x0F90, 0x0F97 }, { 0x0F99, 0x0FBC }, - { 0x0FC6, 0x0FC6 }, { 0x102D, 0x1030 }, { 0x1032, 0x1032 }, - { 0x1036, 0x1037 }, { 0x1039, 0x1039 }, { 0x1058, 0x1059 }, - { 0x1160, 0x11FF }, { 0x135F, 0x135F }, { 0x1712, 0x1714 }, - { 0x1732, 0x1734 }, { 0x1752, 0x1753 }, { 0x1772, 0x1773 }, - { 0x17B4, 0x17B5 }, { 0x17B7, 0x17BD }, { 0x17C6, 0x17C6 }, - { 0x17C9, 0x17D3 }, { 0x17DD, 0x17DD }, { 0x180B, 0x180D }, - { 0x18A9, 0x18A9 }, { 0x1920, 0x1922 }, { 0x1927, 0x1928 }, - { 0x1932, 0x1932 }, { 0x1939, 0x193B }, { 0x1A17, 0x1A18 }, - { 0x1DC0, 0x1DC3 }, { 0x200B, 0x200F }, { 0x202A, 0x202E }, - { 0x2060, 0x2063 }, { 0x206A, 0x206F }, { 0x20D0, 0x20EB }, - { 0x302A, 0x302F }, { 0x3099, 0x309A }, { 0xA806, 0xA806 }, - { 0xA80B, 0xA80B }, { 0xA825, 0xA826 }, { 0xFB1E, 0xFB1E }, - { 0xFE00, 0xFE0F }, { 0xFE20, 0xFE23 }, { 0xFEFF, 0xFEFF }, - { 0xFFF9, 0xFFFB }, { 0x10A01, 0x10A03 }, { 0x10A05, 0x10A06 }, - { 0x10A0C, 0x10A0F }, { 0x10A38, 0x10A3A }, { 0x10A3F, 0x10A3F }, - { 0x1D167, 0x1D169 }, { 0x1D173, 0x1D182 }, { 0x1D185, 0x1D18B }, - { 0x1D1AA, 0x1D1AD }, { 0x1D242, 0x1D244 }, { 0xE0001, 0xE0001 }, - { 0xE0020, 0xE007F }, { 0xE0100, 0xE01EF } + { 0x0CE2, 0x0CE3 }, { 0x0D41, 0x0D43 }, { 0x0D4D, 0x0D4D }, + { 0x0DCA, 0x0DCA }, { 0x0DD2, 0x0DD4 }, { 0x0DD6, 0x0DD6 }, + { 0x0E31, 0x0E31 }, { 0x0E34, 0x0E3A }, { 0x0E47, 0x0E4E }, + { 0x0EB1, 0x0EB1 }, { 0x0EB4, 0x0EB9 }, { 0x0EBB, 0x0EBC }, + { 0x0EC8, 0x0ECD }, { 0x0F18, 0x0F19 }, { 0x0F35, 0x0F35 }, + { 0x0F37, 0x0F37 }, { 0x0F39, 0x0F39 }, { 0x0F71, 0x0F7E }, + { 0x0F80, 0x0F84 }, { 0x0F86, 0x0F87 }, { 0x0F90, 0x0F97 }, + { 0x0F99, 0x0FBC }, { 0x0FC6, 0x0FC6 }, { 0x102D, 0x1030 }, + { 0x1032, 0x1032 }, { 0x1036, 0x1037 }, { 0x1039, 0x1039 }, + { 0x1058, 0x1059 }, { 0x1160, 0x11FF }, { 0x135F, 0x135F }, + { 0x1712, 0x1714 }, { 0x1732, 0x1734 }, { 0x1752, 0x1753 }, + { 0x1772, 0x1773 }, { 0x17B4, 0x17B5 }, { 0x17B7, 0x17BD }, + { 0x17C6, 0x17C6 }, { 0x17C9, 0x17D3 }, { 0x17DD, 0x17DD }, + { 0x180B, 0x180D }, { 0x18A9, 0x18A9 }, { 0x1920, 0x1922 }, + { 0x1927, 0x1928 }, { 0x1932, 0x1932 }, { 0x1939, 0x193B }, + { 0x1A17, 0x1A18 }, { 0x1B00, 0x1B03 }, { 0x1B34, 0x1B34 }, + { 0x1B36, 0x1B3A }, { 0x1B3C, 0x1B3C }, { 0x1B42, 0x1B42 }, + { 0x1B6B, 0x1B73 }, { 0x1DC0, 0x1DCA }, { 0x1DFE, 0x1DFF }, + { 0x200B, 0x200F }, { 0x202A, 0x202E }, { 0x2060, 0x2063 }, + { 0x206A, 0x206F }, { 0x20D0, 0x20EF }, { 0x302A, 0x302F }, + { 0x3099, 0x309A }, { 0xA806, 0xA806 }, { 0xA80B, 0xA80B }, + { 0xA825, 0xA826 }, { 0xFB1E, 0xFB1E }, { 0xFE00, 0xFE0F }, + { 0xFE20, 0xFE23 }, { 0xFEFF, 0xFEFF }, { 0xFFF9, 0xFFFB }, + { 0x10A01, 0x10A03 }, { 0x10A05, 0x10A06 }, { 0x10A0C, 0x10A0F }, + { 0x10A38, 0x10A3A }, { 0x10A3F, 0x10A3F }, { 0x1D167, 0x1D169 }, + { 0x1D173, 0x1D182 }, { 0x1D185, 0x1D18B }, { 0x1D1AA, 0x1D1AD }, + { 0x1D242, 0x1D244 }, { 0xE0001, 0xE0001 }, { 0xE0020, 0xE007F }, + { 0xE0100, 0xE01EF } }; /* test for 8-bit control characters */ @@ -185,7 +190,7 @@ int mk_wcwidth(wchar_t ucs) /* binary search in table of non-spacing characters */ if (bisearch(cmp, combining, - sizeof(combining) / sizeof(struct interval) - 1)) + (int) (sizeof(combining) / sizeof(struct interval) - 1))) return 0; /* if we arrive here, cmp is not a combining or C0/C1 control character */ @@ -198,6 +203,7 @@ int mk_wcwidth(wchar_t ucs) cmp != 0x303f) || /* CJK ... Yi */ (cmp >= 0xac00 && cmp <= 0xd7a3) || /* Hangul Syllables */ (cmp >= 0xf900 && cmp <= 0xfaff) || /* CJK Compatibility Ideographs */ + (cmp >= 0xfe10 && cmp <= 0xfe19) || /* Vertical forms */ (cmp >= 0xfe30 && cmp <= 0xfe6f) || /* CJK Compatibility Forms */ (cmp >= 0xff00 && cmp <= 0xff60) || /* Fullwidth Forms */ (cmp >= 0xffe0 && cmp <= 0xffe6) || @@ -232,7 +238,21 @@ int mk_wcswidth(const wchar_t *pwcs, size_t n) int mk_wcwidth_cjk(wchar_t ucs) { /* sorted list of non-overlapping intervals of East Asian Ambiguous - * characters, generated by "uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf c" */ + * characters, generated by + * + * uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf \ + * +E000..F8FF \ + * +F0000..FFFFD \ + * +100000..10FFFD c + * + * "WIDTH-A" is a file extracted from EastAsianWidth.txt by selecting + * only those with width "A", and omitting: + * + * 0xAD + * all lines with "COMBINING" + * + * (uniset does not recognize the range expressions in WIDTH-A). + */ static const struct interval ambiguous[] = { { 0x00A1, 0x00A1 }, { 0x00A4, 0x00A4 }, { 0x00A7, 0x00A8 }, { 0x00AA, 0x00AA }, { 0x00AE, 0x00AE }, { 0x00B0, 0x00B4 }, @@ -290,7 +310,7 @@ int mk_wcwidth_cjk(wchar_t ucs) /* binary search in table of non-spacing characters */ if (bisearch((unsigned long) ucs, ambiguous, - sizeof(ambiguous) / sizeof(struct interval) - 1)) + (int) (sizeof(ambiguous) / sizeof(struct interval) - 1))) return 2; return mk_wcwidth(ucs); diff --git a/app/xterm/xterm.h b/app/xterm/xterm.h index 4c4bb9619..ec006317d 100644 --- a/app/xterm/xterm.h +++ b/app/xterm/xterm.h @@ -1,8 +1,8 @@ -/* $XTermId: xterm.h,v 1.507 2008/12/30 15:46:41 tom Exp $ */ +/* $XTermId: xterm.h,v 1.520 2009/02/13 23:39:20 tom Exp $ */ /************************************************************ -Copyright 1999-2007,2008 by Thomas E. Dickey +Copyright 1999-2008,2009 by Thomas E. Dickey All Rights Reserved @@ -399,6 +399,7 @@ extern char **environ; #define XtNfont6 "font6" #define XtNfontDoublesize "fontDoublesize" #define XtNfontStyle "fontStyle" +#define XtNfontWarnings "fontWarnings" #define XtNforceBoxChars "forceBoxChars" #define XtNformatOtherKeys "formatOtherKeys" #define XtNfreeBoldBox "freeBoldBox" @@ -423,6 +424,7 @@ extern char **environ; #define XtNlogging "logging" #define XtNloginShell "loginShell" #define XtNmarginBell "marginBell" +#define XtNmaximized "maximized" #define XtNmenuBar "menuBar" #define XtNmenuHeight "menuHeight" #define XtNmetaSendsEscape "metaSendsEscape" @@ -551,6 +553,7 @@ extern char **environ; #define XtCFont6 "Font6" #define XtCFontDoublesize "FontDoublesize" #define XtCFontStyle "FontStyle" +#define XtCFontWarnings "FontWarnings" #define XtCForceBoxChars "ForceBoxChars" #define XtCFormatOtherKeys "FormatOtherKeys" #define XtCFreeBoldBox "FreeBoldBox" @@ -571,6 +574,7 @@ extern char **environ; #define XtCLogging "Logging" #define XtCLoginShell "LoginShell" #define XtCMarginBell "MarginBell" +#define XtCMaximized "Maximized" #define XtCMenuBar "MenuBar" #define XtCMenuHeight "MenuHeight" #define XtCMetaSendsEscape "MetaSendsEscape" @@ -734,6 +738,8 @@ extern void ReadLineButton PROTO_XT_ACTIONS_ARGS; #if OPT_WIDE_CHARS extern Bool iswide(int /* i */); +#define FIRST_WIDECHAR 256 +#define isWide(n) ((n) >= FIRST_WIDECHAR && iswide(n)) #endif /* cachedCgs.c */ @@ -833,8 +839,8 @@ extern GC xterm_DoubleGC(XtermWidget /* xw */, unsigned /* chrset */, unsigned #endif /* input.c */ -extern int xtermParamToState (XtermWidget /* xw */, unsigned /* param */); -extern int xtermStateToParam (XtermWidget /* xw */, unsigned /* state */); +extern unsigned xtermParamToState (XtermWidget /* xw */, unsigned /* param */); +extern unsigned xtermStateToParam (XtermWidget /* xw */, unsigned /* state */); extern Bool xtermDeleteIsDEL (XtermWidget /* xw */); extern void Input (XtermWidget /* xw */, XKeyEvent */* event */, Bool /* eightbit */); extern void StringInput (XtermWidget /* xw */, Char * /* string */, size_t /* nbytes */); @@ -884,6 +890,7 @@ extern Cursor make_colored_cursor (unsigned /* cursorindex */, unsigned long /* extern OptionHelp * sortedOpts(OptionHelp *, XrmOptionDescRec *, Cardinal); extern Window WMFrameWindow(XtermWidget /* termw */); extern XrmOptionDescRec * sortedOptDescs(XrmOptionDescRec *, Cardinal); +extern XtermWidget getXtermWidget(Widget /* w */); extern char *udk_lookup (int /* keycode */, int * /* len */); extern char *xtermEnvEncoding (void); extern char *xtermEnvLocale (void); @@ -897,9 +904,9 @@ extern int open_userfile (uid_t /* uid */, gid_t /* gid */, char * /* path */, extern int xerror (Display * /* d */, XErrorEvent * /* ev */); extern int xioerror (Display * /* dpy */); extern int xtermResetIds(TScreen * /* screen */); -extern void Bell (Atom /* which */, int /* percent */); -extern void ChangeIconName (char * /* name */); -extern void ChangeTitle (char * /* name */); +extern void Bell (int /* which */, int /* percent */); +extern void ChangeIconName (XtermWidget /* xw */, char * /* name */); +extern void ChangeTitle (XtermWidget /* xw */, char * /* name */); extern void ChangeXprop (char * /* name */); extern void Cleanup (int /* code */); extern void HandleBellPropertyChange PROTO_XT_EV_HANDLER_ARGS; @@ -930,6 +937,7 @@ extern void switch_modes (Bool /* tovt */); extern void timestamp_filename(char * /* dst */, const char * /* src */); extern void xevents (void); extern void xt_error (String /* message */); +extern void xtermBell(XtermWidget /* xw */, int /* which */, int /* percent */); extern void xtermCopyEnv (char ** /* oldenv */); extern void xtermDisplayCursor (XtermWidget /* xw */); extern void xtermSetenv (char * /* var */, char * /* value */); @@ -1020,7 +1028,7 @@ extern void ScrnInsertChar (XtermWidget /* xw */, unsigned /* n */); extern void ScrnInsertLine (XtermWidget /* xw */, ScrnBuf /* sb */, int /* last */, int /* where */, unsigned /* n */, unsigned /* size */); extern void ScrnRefresh (XtermWidget /* xw */, int /* toprow */, int /* leftcol */, int /* nrows */, int /* ncols */, Bool /* force */); extern void ScrnUpdate (XtermWidget /* xw */, int /* toprow */, int /* leftcol */, int /* nrows */, int /* ncols */, Bool /* force */); -extern void ScrnWriteText (XtermWidget /* xw */, PAIRED_CHARS(Char * /* str */, Char * /* str2 */), unsigned /* flags */, unsigned /* cur_fg_bg */, unsigned /* length */); +extern void ScrnWriteText (XtermWidget /* xw */, IChar * /* str */, unsigned /* flags */, unsigned /* cur_fg_bg */, unsigned /* length */); extern void xtermParseRect (XtermWidget /* xw */, int, int *, XTermRect *); #if OPT_TRACE && OPT_TRACE_FLAGS @@ -1109,6 +1117,7 @@ extern GC updatedXtermGC (XtermWidget /* xw */, unsigned /* flags */, unsigned extern int AddToRefresh (XtermWidget /* xw */); extern int ClearInLine (XtermWidget /* xw */, int /* row */, int /* col */, unsigned /* len */); extern int HandleExposure (XtermWidget /* xw */, XEvent * /* event */); +extern int drawXtermIChars(XtermWidget /* xw */, unsigned /* flags */, GC /* gc */, int /* x */, int /* y */, int /* chrset */, IChar * /* text */, Cardinal /* len */, int /* on_wide */); extern int drawXtermText (XtermWidget /* xw */, unsigned /* flags */, GC /* gc */, int /* x */, int /* y */, int /* chrset */, PAIRED_CHARS(Char * /* text */, Char * /* text2 */), Cardinal /* len */, int /* on_wide */); extern void ChangeColors (XtermWidget /* xw */, ScrnColors * /* pNew */); extern void ClearRight (XtermWidget /* xw */, int /* n */); @@ -1121,7 +1130,7 @@ extern void InsertChar (XtermWidget /* xw */, unsigned /* n */); extern void InsertLine (XtermWidget /* xw */, int /* n */); extern void RevScroll (XtermWidget /* xw */, int /* amount */); extern void ReverseVideo (XtermWidget /* termw */); -extern void WriteText (XtermWidget /* xw */, PAIRED_CHARS(Char * /* str */, Char * /* str2 */), Cardinal /* len */); +extern void WriteText (XtermWidget /* xw */, IChar * /* str */, Cardinal /* len */); extern void decode_keyboard_type (XtermWidget /* xw */, struct XTERM_RESOURCE * /* rp */); extern void decode_wcwidth (int /* mode */, int /* samplesize */, int /* samplepass */); extern void do_erase_display (XtermWidget /* xw */, int /* param */, int /* mode */); @@ -1250,6 +1259,7 @@ extern int DamagedCurCells(TScreen * /* screen */, unsigned /* n */, int * /* kl extern unsigned AsciiEquivs(unsigned /* ch */); extern unsigned getXtermCellComb (TScreen * /* screen */, int /* row */, int /* col */, int /* off */); extern void addXtermCombining (TScreen * /* screen */, int /* row */, int /* col */, unsigned /* ch */); +extern void allocXtermChars(Char ** /* buffer */, Cardinal /* length */); #endif #if OPT_XMC_GLITCH @@ -1259,7 +1269,7 @@ extern void Resolve_XMC (XtermWidget /* xw */); #endif #if OPT_WIDE_CHARS -unsigned visual_width(PAIRED_CHARS(Char * /* str */, Char * /* str2 */), Cardinal /* len */); +unsigned visual_width(IChar * /* str */, Cardinal /* len */); #else #define visual_width(a, b) (b) #endif diff --git a/app/xterm/xterm.log.html b/app/xterm/xterm.log.html index f3f840917..b4fff7a5f 100644 --- a/app/xterm/xterm.log.html +++ b/app/xterm/xterm.log.html @@ -20,7 +20,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * ***************************************************************************** - $XTermId: xterm.log.html,v 1.707 2009/01/09 02:02:49 tom Exp $ + $XTermId: xterm.log.html,v 1.731 2009/02/16 00:26:07 tom Exp $ --> <HTML> <HEAD> @@ -45,7 +45,10 @@ Most of these are summarized in the XFree86 CHANGELOG is the latest version of this file. <UL> -<LI><A HREF="#xterm_239">Patch #239 - 2001/1/8</A> +<LI><A HREF="#xterm_242">Patch #242 - 2009/2/15</A> +<LI><A HREF="#xterm_241">Patch #241 - 2009/1/26</A> +<LI><A HREF="#xterm_240">Patch #240 - 2009/1/25</A> +<LI><A HREF="#xterm_239">Patch #239 - 2009/1/8</A> <LI><A HREF="#xterm_238">Patch #238 - 2008/12/30</A> <LI><A HREF="#xterm_237">Patch #237 - 2008/09/14</A> <LI><A HREF="#xterm_236">Patch #236 - 2008/07/27</A> @@ -287,6 +290,90 @@ is the latest version of this file. <LI><A HREF="#xterm_01">Patch #1 - 1996/1/6</A> </UL> +<H1><A NAME="xterm_242">Patch #242 - 2009/2/15</A></H1> +<ul> + <li>fix configure check for <code>XkbBell</code> and provide + appropriate parameter for it. + + <li>fix a caching problem with double-size fonts versus reverse video + that could cause core dump. + + <li>repair double-size fonts from workaround + used in <a href="#xterm_240">patch #240</a>. + + <li>add new section to the VT Fonts menu which allows enabling or + disabling the font, termcap (tcap-query), title and window + operations. + + <li>add <code>fontWarnings</code> resource, to control whether to show + warnings on failure to load a font. + + <li>improve warnings for unloadable fonts introduced in + <a href="#xterm_240">patch #240</a> + by limiting those to the cases where a font would be specified + directly by a resource setting rather than a derived fontname. + + <li>further amend fix for Debian #252873 + from <a href="#xterm_197">patch #197</a> 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). + <p> + Also add the same logic when hiding cursor, so the outline matches + the in-focus cursor. + + <li>modify internals to reduce places PAIRED_CHARS() is used, making + WriteText() and ScrnWriteText() accept IChar array, as well as + providing a wrapper for drawXtermText(). + + <li>change default XIM font from "*" to "fixed" to improve startup + time in zh_CN.UTF-8 locale (Mike Fabian, SuSE Bugzilla #464930). + + <li>typo in #240 log (Slava Semushin) +</ul> + +<H1><A NAME="xterm_241">Patch #241 - 2009/1/26</A></H1> +<ul> + <li>improve checks for missing bitmap fonts, fallback to "fixed" as + needed to work around broken font-packages (report by Jacek + Luczak). + + <li>fix breakage from <a href="#xterm_240">patch #240</a> changes for + <code>xtermAddInput()</code> (patches by Jeff Chua, Julien Cristau). +</ul> + +<H1><A NAME="xterm_240">Patch #240 - 2009/1/25</A></H1> +<ul> + <li>use <code>plink.sh</code> for linking xterm (suggested by Larry + Doolittle). + + <li>add resource descriptions for input method to xterm manpage. + + <li>update configure script; consistently append to $CFLAGS rather + than prepend. + + <li>add <code>install-scripts</code> rule to makefile, to allow + koi8rxterm and uxterm scripts to be altered independently of + <code>install-bin</code> + + <li>add <code>-maximized</code> command-line option and corresponding + resource (prompted by alt.os.linux newsgroup comment). + + <li>modify translations of scrollbar widget using + <code>xtermAddInput()</code> + (see <a href="#xterm_181">patch #181</a>) to accept the actions + that the vt100 widget accepts, such as shift-insert to perform + a paste operation (request by Martin Zwickel). + + <li>change default for <code>allowTcapsOps</code> resource to false, + since it causes unexpected behavior for vim users with + <code>AltGr</code>. + + <li>update config.guess, config.sub +</ul> + <H1><A NAME="xterm_239">Patch #239 - 2009/1/8</A></H1> <ul> <li>correct a cast in input.c, which broke translation of numeric diff --git a/app/xterm/xterm.man b/app/xterm/xterm.man index 22deec87b..7f71f967b 100644 --- a/app/xterm/xterm.man +++ b/app/xterm/xterm.man @@ -1,7 +1,7 @@ '\" t -.\" $XTermId: xterm.man,v 1.413 2008/12/30 11:23:59 tom Exp $ +.\" $XTermId: xterm.man,v 1.420 2009/02/11 00:11:56 tom Exp $ .\" -.\" Copyright 1996-2007,2008 by Thomas E. Dickey +.\" Copyright 1996-2008,2009 by Thomas E. Dickey .\" .\" All Rights Reserved .\" @@ -56,13 +56,15 @@ .\" .\" updated by Thomas E. Dickey for XFree86, July 1996 - February 2006. . -.de DS +.\" these would be fallbacks for DS/DE, +.\" but groff changed the meaning of the macros. +.de NS .sp .in +4 .nf .ft C \" Courier .. -.de DE +.de NE .fi .ft P .sp @@ -693,6 +695,18 @@ because \fIxterm\ -ls\ -e\fP does write a \fI/etc/wtmp\fP entry (if configured to do so), whereas \fIxterm\ -e\fP does not. .TP 8 +.B -maximized +This option indicates that \fIxterm\fP should ask the window manager to +maximize its layout on startup. +This corresponds to the \fBmaximized\fP resource. +.IP +Maximizing is not the reverse of iconifying; +it is possible to do both with certain window managers. +.TP 8 +.B +maximized +This option indicates that \fIxterm\fP should ask the window manager to +maximize its layout on startup. +.TP 8 .B +ls This option indicates that the shell that is started should not be a login shell (i.e., it will be a normal ``subshell''). @@ -1216,6 +1230,12 @@ On some systems you may want to increase one or both of the \fBminBufSize\fP resource values to achieve better performance if the operating system prefers larger buffer sizes. .TP 8 +.B "maximized (\fPclass\fB Maximized)" +Specifies whether or not \fIxterm\fP should ask the window manager to +maximize its layout on startup. +The default is +``false.'' +.TP 8 .B "messages (\fPclass\fB Messages)" Specifies whether write access to the terminal is allowed initially. See @@ -1424,8 +1444,14 @@ The default is ``false.'' .SS VT100 Widget Resources .PP The following resources are specified as part -of the \fIvt100\fP widget (class \fIVT100\fP): -These are specified by patterns such as "\fBXTerm.vt100.\fP\fINAME\fP": +of the \fIvt100\fP widget (class \fIVT100\fP). +They are specified by patterns such as "\fBXTerm.vt100.\fP\fINAME\fP". +.PP +If your \fIxterm\fP is configured to support the "toolbar", then those +patterns need an extra level for the form-widget which holds the +toolbar and vt100 widget. A wildcard between the top-level +"XTerm" and the "vt100" widget makes the resource settings work for +either, e.g., "\fBXTerm*vt100.\fP\fINAME\fP". .TP 8 .B "activeIcon (\fPclass\fB ActiveIcon)" Specifies whether or not active icon windows are to be used when the @@ -1462,7 +1488,25 @@ The default is ``false.'' Specifies whether control sequences that query the terminal's notion of its function-key strings, as termcap or terminfo capabilities should be allowed. -The default is ``true.'' +The default is ``false.'' +.IP +A few programs, e.g,. \fIvim\fP, use this feature to get an accurate +description of the terminal's capabilities, +independent of the termcap/terminfo setting: +.RS +.TP 3 +- +\fIxterm\fP can tell the querying program how many colors it supports. +This is a constant, depending on how it is compiled, typically 16. +It does not change if you alter resource settings, +e.g., the \fBboldColors\fP resource. +.TP 3 +- +\fIxterm\fP can tell the querying program what strings are sent by modified +(shift-, control-, alt-) function- and keypad-keys. +Reporting control- and alt-modifiers is a feature that relies on the +\fIncurses\fP extended naming. +.RE .TP .B "allowTitleOps (\fPclass\fB AllowTitleOps)" Specifies whether control sequences that modify the window title or icon name @@ -2057,6 +2101,20 @@ The default is ``true''. If disabled, \fIxterm\fP will simulate doublesize characters by drawing normal characters with spaces between them. .TP 8 +.B "fontWarnings (\fPclass\fB FontWarnings)" +Specify whether \fIxterm\fP should report an error if it fails to load a font: +.RS +.TP 5 +0 +Never report an error (though the X libraries may). +.TP 5 +1 +Report an error if the font name was given as a resource setting. +.TP 5 +2 +Always report an error on failure to load a font. +.RE +.TP 8 .B "forceBoxChars (\fPclass\fB ForceBoxChars)" Specifies whether \fIxterm\fP should assume the normal and bold fonts have VT100 line-drawing characters: @@ -2246,6 +2304,10 @@ Specifies which of the VT100 fonts to use initially. Values are the same as for the \fIset-vt-font\fP action. The default is ``d'', i.e., "default". .TP 8 +.B "inputMethod (\fPclass\fB XtCInputMethod)" +Tells \fIxterm\fP which type of input method to use. +There is no default method. +.TP 8 .B "internalBorder (\fPclass\fB BorderWidth)" Specifies the number of pixels between the characters and the window border. The default is 2. @@ -2559,6 +2621,10 @@ making those inactive. On startup, \fIxterm\fP determines the maximum number of clicks by the \fBon\fP\fIX\fP\fBClicks\fP resource values which are set. .TP 8 +.B "openIm (\fPclass\fB XtCOpenIm)" +Tells \fIxterm\fP whether to open the input method at startup. +The default is ``true''. +.TP 8 .B "pointerColor (\fPclass\fB PointerColor)" Specifies the foreground color of the pointer. The default is @@ -2594,6 +2660,10 @@ The default is ``xterm.'' Specifies whether the window would be raised when Control-G is received. The default is ``false.'' .TP 8 +.B "preeditType (\fPclass\fB XtCPreeditType)" +Tells \fIxterm\fP which types of preedit (preconversion) string to display. +The default is ``OverTheSpot,Root''. +.TP 8 .B "printAttributes (\fPclass\fB PrintAttributes)" Specifies whether to print graphic attributes along with the text. A real DEC VTxxx terminal will print the underline, highlighting codes @@ -3411,7 +3481,7 @@ 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 -Allow SendEvents (allowsends ) +Allow SendEvents (allowsends) 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. @@ -3781,7 +3851,7 @@ The \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 VT102 window, or modifies the way the font is specified or displayed. -There are three sections. +There are several sections. .PP The first section allows you to select the font from a set of alternatives: .RS @@ -3858,6 +3928,29 @@ This controls whether \fIxterm\fP uses UTF-8 encoding of input/output. It is useful for temporarily switching \fIxterm\fP to display text from an application which does not follow the locale settings. .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 +Allow Font Ops (allow-font-ops) +This corresponds to the \fBallowFontOps\fP resource. +Enable or disable control sequences that set/query the font. +.TP +Allow Tcap Ops (allow-tcap-ops) +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 +Allow Title Ops (allow-title-ops) +Enable or disable control sequences that modify the window title or icon name. +This corresponds to the \fBallowTitleOps\fP resource. +.TP +Allow Window Ops (allow-window-ops) +Enable or disable extended window control sequences (as used in dtterm). +This corresponds to the \fBallowWindowOps\fP resource. +.RE . .SS "TEK Options" .PP @@ -3998,7 +4091,7 @@ UTF-8 mode, only the first 256 bytes of this table will be used. . .PP The default table starts as follows - -.DS +.NS static int charClass[256] = { /\(** NUL SOH STX ETX EOT ENQ ACK BEL */ 32, 1, 1, 1, 1, 1, 1, 1, @@ -4065,7 +4158,7 @@ static int charClass[256] = { 48, 48, 48, 48, 48, 48, 48, 247, /\(** o/ u` u' u^ u: y' P y: */ 48, 48, 48, 48, 48, 48, 48, 48}; -.DE +.NE 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. @@ -4084,10 +4177,26 @@ The following actions are provided for use within the \fIvt100\fP or \fItek4014\fP \fBtranslations\fP resources: .TP 8 +.B "allow-font-ops(\fIon/off/toggle\fP)" +This action set or toggles the \fBallowFontOps\fP resource and is also +invoked by the \fBallow-font-ops\fP entry in \fIfontMenu\fP. +.TP 8 .B "allow-send-events(\fIon/off/toggle\fP)" This action set 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 set 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 set 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 set 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 \fBeightBitInput\fP resource. .TP 8 @@ -4122,10 +4231,10 @@ 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 \fIxterm\fP which will do the same thing: -.DS +.NS *VT100*translations: #override \\n\\\& Meta <KeyPress> /:dabbrev-expand() -.DE +.NE .TP 8 .B "deiconify()" Changes the window state back to normal, if it was iconified. @@ -4592,7 +4701,7 @@ This action sends the indicated graphics input code. .PP The default bindings in the VT102 window use the SELECT token, which is set by the \fBselectToClipboard\fP resource: -.DS +.NS .ta 2.5i Shift <KeyPress> Prior:scroll-back(1,halfpage) \\n\\\& Shift <KeyPress> Next:scroll-forw(1,halfpage) \\n\\\& @@ -4637,11 +4746,11 @@ which is set by the \fBselectToClipboard\fP resource: <Btn5Down>:scroll-forw(5,line,m) \\n\\\& <BtnUp>:select-end(SELECT, CUT_BUFFER0) \\n\\\& <BtnDown>:ignore() -.DE +.NE .PP The default bindings for the scrollbar widget are separate from the VT100 widget: -.DS +.NS .ta 2.5i <Btn5Down>: StartScroll(Forward) \\n\\\& <Btn1Down>: StartScroll(Forward) \\n\\\& @@ -4650,10 +4759,10 @@ are separate from the VT100 widget: <Btn4Down>: StartScroll(Backward) \\n\\\& <Btn2Motion>: MoveThumb() NotifyThumb() \\n\\\& <BtnUp>: NotifyScroll(Proportional) EndScroll() -.DE +.NE .PP The default bindings in the Tektronix window are: -.DS +.NS .ta 2.5i ~Meta<KeyPress>: insert-seven-bit() \\n\\\& Meta<KeyPress>: insert-eight-bit() \\n\\\& @@ -4671,7 +4780,7 @@ The default bindings in the Tektronix window are: ~Meta<Btn2Down>: gin-press(m) \\n\\\& Shift ~Meta<Btn3Down>: gin-press(R) \\n\\\& ~Meta<Btn3Down>: gin-press(r) -.DE +.NE .PP Here is an example which uses shifted select/paste to copy to the clipboard, and unshifted select/paste for the primary selection. @@ -4683,18 +4792,18 @@ while selections can store data in a variety of formats and encodings. While \fIxterm\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. -.DS +.NS .ta .5i 1.5i *VT100*translations: #override \\n\\\& ~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) -.DE +.NE .PP Below is a sample how of the \fBkeymap()\fP action is used to add special keys for entering commonly-typed works: -.DS +.NS .ta .5i 1.5i *VT100.Translations: #override <Key>F13: keymap(dbx) *VT100.dbxKeymap.translations: \\\& @@ -4703,12 +4812,12 @@ keys for entering commonly-typed works: <Key>F18: string("step") string(0x0d) \\n\\\& <Key>F19: string("continue") string(0x0d) \\n\\\& <Key>F20: string("print ") insert-selection(PRIMARY, CUT_BUFFER0) -.DE +.NE .PP Some people prefer using the left pointer button for dragging the scrollbar thumb. That can be setup by altering the translations resource, e.g., -.DS +.NS .ta .5i 1.5i *VT100.scrollbar.translations: #override \\n\\\& <Btn5Down>: StartScroll(Forward) \\n\\\& @@ -4716,7 +4825,7 @@ That can be setup by altering the translations resource, e.g., <Btn4Down>: StartScroll(Backward) \\n\\\& <Btn1Motion>: MoveThumb() NotifyThumb() \\n\\\& <BtnUp>: NotifyScroll(Proportional) EndScroll() -.DE +.NE .SH "CONTROL SEQUENCES AND KEYBOARD" The \fIXterm Control Sequences\fP document lists the control sequences which an application can send \fIxterm\fP to make it perform various operations. @@ -5102,8 +5211,6 @@ On OpenBSD, the following resources have different default values: .TP 8 .B allowFontOps: false .TP 8 -.B allowTcapOps: false -.TP 8 .B allowWindowOps: false Various, potentially dangerous, extended window control sequences are disabled. .TP 8 diff --git a/app/xterm/xtermcap.c b/app/xterm/xtermcap.c index 415b61578..501c869c1 100644 --- a/app/xterm/xtermcap.c +++ b/app/xterm/xtermcap.c @@ -1,7 +1,7 @@ -/* $XTermId: xtermcap.c,v 1.14 2008/10/05 16:43:36 tom Exp $ */ +/* $XTermId: xtermcap.c,v 1.15 2009/01/26 00:10:15 tom Exp $ */ /* - * Copyright 2007,2008 by Thomas E. Dickey + * Copyright 2007-2008,2009 by Thomas E. Dickey * * All Rights Reserved * @@ -275,7 +275,7 @@ xtermcapKeycode(XtermWidget xw, char **params, unsigned *state, Bool * fkey) 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++] = (char) ((hex2int(p[0]) << 4) + hex2int(p[1])); } name[len] = 0; *params = p; |