diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2015-01-18 20:24:41 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2015-01-18 20:24:41 +0000 |
commit | 918788a505484daa2999e221dfb44e28ebfdb075 (patch) | |
tree | 2e009a31375bcd9cce175bfc233dd873e9b9bbd1 /app/xterm | |
parent | cf85b4e5aea74c9d26c95d1304de8d38f4073bff (diff) |
xterm 314. tested by naddy@
Diffstat (limited to 'app/xterm')
-rw-r--r-- | app/xterm/MANIFEST | 2 | ||||
-rw-r--r-- | app/xterm/button.c | 116 | ||||
-rw-r--r-- | app/xterm/cachedGCs.c | 6 | ||||
-rw-r--r-- | app/xterm/charproc.c | 245 | ||||
-rw-r--r-- | app/xterm/configure.in | 5 | ||||
-rw-r--r-- | app/xterm/ctlseqs.ms | 82 | ||||
-rw-r--r-- | app/xterm/ctlseqs.txt | 98 | ||||
-rw-r--r-- | app/xterm/fontutils.c | 10 | ||||
-rw-r--r-- | app/xterm/graphics.c | 31 | ||||
-rw-r--r-- | app/xterm/graphics_regis.c | 687 | ||||
-rw-r--r-- | app/xterm/graphics_sixel.c | 20 | ||||
-rw-r--r-- | app/xterm/main.c | 25 | ||||
-rw-r--r-- | app/xterm/misc.c | 64 | ||||
-rw-r--r-- | app/xterm/package/debian/changelog | 6 | ||||
-rw-r--r-- | app/xterm/package/freebsd/Makefile | 2 | ||||
-rw-r--r-- | app/xterm/package/xterm.spec | 4 | ||||
-rw-r--r-- | app/xterm/ptyx.h | 32 | ||||
-rw-r--r-- | app/xterm/resize.c | 10 | ||||
-rw-r--r-- | app/xterm/trace.c | 6 | ||||
-rw-r--r-- | app/xterm/util.c | 8 | ||||
-rw-r--r-- | app/xterm/version.h | 6 | ||||
-rw-r--r-- | app/xterm/vttests/paste64.pl | 231 | ||||
-rw-r--r-- | app/xterm/xterm.h | 28 | ||||
-rw-r--r-- | app/xterm/xterm.log.html | 112 | ||||
-rw-r--r-- | app/xterm/xterm.man | 46 |
25 files changed, 1384 insertions, 498 deletions
diff --git a/app/xterm/MANIFEST b/app/xterm/MANIFEST index b15fa8283..e135d9e5e 100644 --- a/app/xterm/MANIFEST +++ b/app/xterm/MANIFEST @@ -1,4 +1,4 @@ -MANIFEST for xterm-313, version xterm-313 +MANIFEST for xterm-314, version xterm-314 -------------------------------------------------------------------------------- MANIFEST this file 256colres.h resource-definitions for 256-color mode diff --git a/app/xterm/button.c b/app/xterm/button.c index 30412c74d..bde51e421 100644 --- a/app/xterm/button.c +++ b/app/xterm/button.c @@ -1,4 +1,4 @@ -/* $XTermId: button.c,v 1.484 2014/11/13 01:00:26 tom Exp $ */ +/* $XTermId: button.c,v 1.491 2014/12/28 22:15:03 tom Exp $ */ /* * Copyright 1999-2013,2014 by Thomas E. Dickey @@ -1773,7 +1773,7 @@ GettingSelection(Display *dpy, Atom type, Char *line, unsigned long len) name = XGetAtomName(dpy, type); - TRACE(("Getting %s (%ld)\n", name, (long int) type)); + TRACE(("Getting %s (type=%ld, length=%ld)\n", name, (long int) type, len)); for (cp = line; cp < line + len; cp++) { TRACE(("[%d:%lu]", (int) (cp + 1 - line), len)); if (isprint(*cp)) { @@ -1803,6 +1803,12 @@ static void base64_flush(TScreen *screen) { Char x; + + TRACE(("base64_flush count %d, pad %d (%d)\n", + screen->base64_count, + screen->base64_pad, + screen->base64_pad & 3)); + switch (screen->base64_count) { case 0: break; @@ -1815,10 +1821,11 @@ base64_flush(TScreen *screen) tty_vwrite(screen->respond, &x, 1); break; } - if (screen->base64_pad & 3) + if (screen->base64_pad & 3) { tty_vwrite(screen->respond, (const Char *) "===", - (unsigned) (4 - (screen->base64_pad & 3))); + (unsigned) (3 - (screen->base64_pad & 3))); + } screen->base64_count = 0; screen->base64_accu = 0; screen->base64_pad = 0; @@ -1901,6 +1908,8 @@ _qWriteSelectionData(XtermWidget xw, Char *lag, unsigned length) Char buf[64]; unsigned x = 0; + TRACE(("convert to base64 %d:%s\n", length, visibleChars(p, length))); + /* * Handle the case where the selection is from _this_ xterm, which * puts part of the reply in the buffer before the selection callback @@ -1936,12 +1945,14 @@ _qWriteSelectionData(XtermWidget xw, Char *lag, unsigned length) if (x >= 63) { /* Write 63 or 64 characters */ screen->base64_pad += x; + TRACE(("writing base64 interim %s\n", visibleChars(buf, x))); tty_vwrite(screen->respond, buf, x); x = 0; } } if (x != 0) { screen->base64_pad += x; + TRACE(("writing base64 finish %s\n", visibleChars(buf, x))); tty_vwrite(screen->respond, buf, x); } } else @@ -1954,7 +1965,10 @@ _qWriteSelectionData(XtermWidget xw, Char *lag, unsigned length) } } else #endif + { + TRACE(("writing base64 padding %s\n", visibleChars(lag, length))); tty_vwrite(screen->respond, lag, length); + } } static void @@ -2102,15 +2116,18 @@ SelectionReceived(Widget w, if (*type == 0 /*XT_CONVERT_FAIL */ || *length == 0 - || value == NULL) + || value == NULL) { + TRACE(("...no data to convert\n")); goto fail; + } text_prop.value = (unsigned char *) value; text_prop.encoding = *type; text_prop.format = *format; text_prop.nitems = *length; - TRACE(("SelectionReceived %s format %d, nitems %ld\n", + TRACE(("SelectionReceived %s %s format %d, nitems %ld\n", + XGetAtomName(screen->display, *selection), visibleSelectionTarget(dpy, text_prop.encoding), text_prop.format, text_prop.nitems)); @@ -2225,8 +2242,10 @@ SelectionReceived(Widget w, } #endif XFreeStringList(text_list); - } else + } else { + TRACE(("...empty text-list\n")); goto fail; + } XtFree((char *) client_data); XtFree((char *) value); @@ -3819,21 +3838,75 @@ _ConvertSelectionHelper(Widget w, { XtermWidget xw; + *value = 0; + *length = 0; + *type = 0; + *format = 0; + if ((xw = getXtermWidget(w)) != 0) { TScreen *screen = TScreenOf(xw); Display *dpy = XtDisplay(w); XTextProperty textprop; + int out_n = 0; + unsigned long remaining = screen->selection_length; + char *result = 0; char *the_data = (char *) screen->selection_data; + char *the_next; + TRACE(("converting %ld:'%s'\n", screen->selection_length, + visibleChars(screen->selection_data, screen->selection_length))); + /* + * For most selections, we can convert in one pass. It is possible + * that some applications contain embedded nulls, e.g., using xterm's + * paste64 feature. For those cases, we will build up the result in + * parts. + */ + if (memchr(the_data, 0, screen->selection_length) != 0) { + TRACE(("selection contains embedded nulls\n")); + result = calloc(screen->selection_length + 1, sizeof(char)); + } + + next_try: + memset(&textprop, 0, sizeof(textprop)); if (conversion_function(dpy, &the_data, 1, conversion_style, &textprop) >= Success) { - *value = (XtPointer) textprop.value; - *length = textprop.nitems; - *type = textprop.encoding; - *format = textprop.format; - return True; + if ((result != 0) + && (textprop.value != 0) + && (textprop.format == 8)) { + char *text_values = (char *) textprop.value; + unsigned long in_n; + + if (out_n == 0) { + *value = result; + *type = textprop.encoding; + *format = textprop.format; + } + for (in_n = 0; in_n < textprop.nitems; ++in_n) { + result[out_n++] = text_values[in_n]; + } + *length += textprop.nitems; + if ((the_next = memchr(the_data, 0, remaining)) != 0) { + unsigned long this_was = (unsigned long) (the_next - the_data); + this_was++; + the_data += this_was; + remaining -= this_was; + result[out_n++] = 0; + *length += 1; + if (remaining) + goto next_try; + } + return True; + } else { + free(result); + *value = (XtPointer) textprop.value; + *length = textprop.nitems; + *type = textprop.encoding; + *format = textprop.format; + return True; + } } + free(result); } return False; } @@ -3883,12 +3956,14 @@ ConvertSelection(Widget w, screen = TScreenOf(xw); - if (screen->selection_data == NULL) - return False; /* can this happen? */ - TRACE(("ConvertSelection %s\n", visibleSelectionTarget(dpy, *target))); + if (screen->selection_data == NULL) { + TRACE(("...FIXME: no selection_data\n")); + return False; /* can this happen? */ + } + if (*target == XA_TARGETS(dpy)) { Atom *allocP; Atom *targetP; @@ -4037,6 +4112,8 @@ LoseSelection(Widget w, Atom *selection) return; screen = TScreenOf(xw); + TRACE(("LoseSelection %s\n", XGetAtomName(screen->display, *selection))); + for (i = 0, atomP = screen->selection_atoms; i < screen->selection_count; i++, atomP++) { if (*selection == *atomP) @@ -4070,6 +4147,7 @@ SelectionDone(Widget w GCC_UNUSED, Atom *target GCC_UNUSED) { /* empty proc so Intrinsics know we want to keep storage */ + TRACE(("SelectionDone\n")); } static void @@ -4084,10 +4162,10 @@ _OwnSelection(XtermWidget xw, if (count == 0) return; - if (screen->selection_length == 0) - return; - TRACE(("_OwnSelection count %d\n", count)); + TRACE(("_OwnSelection count %d, length %ld value %s\n", count, + screen->selection_length, + visibleChars(screen->selection_data, screen->selection_length))); selections = MapSelections(xw, selections, count); if (count > screen->sel_atoms_size) { @@ -4124,6 +4202,8 @@ _OwnSelection(XtermWidget xw, (int) length, cutbuffer); } + } else if (screen->selection_length == 0) { + XtDisownSelection((Widget) xw, atoms[i], screen->selection_time); } else if (!screen->replyToEmacs) { have_selection |= XtOwnSelection((Widget) xw, atoms[i], diff --git a/app/xterm/cachedGCs.c b/app/xterm/cachedGCs.c index 3dd1cd967..2b346b7a5 100644 --- a/app/xterm/cachedGCs.c +++ b/app/xterm/cachedGCs.c @@ -1,4 +1,4 @@ -/* $XTermId: cachedGCs.c,v 1.62 2014/06/12 23:04:07 tom Exp $ */ +/* $XTermId: cachedGCs.c,v 1.63 2014/12/18 21:56:08 tom Exp $ */ /* * Copyright 2007-2011,2014 by Thomas E. Dickey @@ -506,9 +506,9 @@ setCgsFont(XtermWidget xw, VTwin *cgsWin, CgsEnum cgsId, XTermFonts * font) font = &(TScreenOf(xw)->fnts[fNorm]); } if (HaveFont(font) && okFont(font->fs)) { - TRACE2(("setCgsFont next: %s for %s slot %p, gc %#x\n", + TRACE2(("setCgsFont next: %s for %s slot %p, gc %p\n", traceFont(font), traceCgsEnum(cgsId), - me, (unsigned) THIS(gc))); + me, THIS(gc))); TRACE2(("...next font was %s\n", traceFont(NEXT(font)))); NEXT(font) = font; me->mask |= GCFont; diff --git a/app/xterm/charproc.c b/app/xterm/charproc.c index 185264200..4e66fa83b 100644 --- a/app/xterm/charproc.c +++ b/app/xterm/charproc.c @@ -1,4 +1,4 @@ -/* $XTermId: charproc.c,v 1.1379 2014/11/28 22:27:20 tom Exp $ */ +/* $XTermId: charproc.c,v 1.1393 2014/12/28 22:12:39 tom Exp $ */ /* * Copyright 1999-2013,2014 by Thomas E. Dickey @@ -401,7 +401,7 @@ static XtActionsRec actionsList[] = { static XtResource xterm_resources[] = { Bres(XtNallowPasteControls, XtCAllowPasteControls, - screen.allowPasteControls, False), + screen.allowPasteControl0, False), Bres(XtNallowSendEvents, XtCAllowSendEvents, screen.allowSendEvent0, False), Bres(XtNallowColorOps, XtCAllowColorOps, screen.allowColorOp0, DEF_ALLOW_COLOR), Bres(XtNallowFontOps, XtCAllowFontOps, screen.allowFontOp0, DEF_ALLOW_FONT), @@ -611,6 +611,9 @@ static XtResource xterm_resources[] = Bres(XtNcolorRVMode, XtCColorAttrMode, screen.colorRVMode, False), Bres(XtNcolorULMode, XtCColorAttrMode, screen.colorULMode, False), Bres(XtNitalicULMode, XtCColorAttrMode, screen.italicULMode, False), +#if OPT_WIDE_ATTRS + Bres(XtNcolorITMode, XtCColorAttrMode, screen.colorITMode, False), +#endif COLOR_RES("0", screen.Acolors[COLOR_0], DFT_COLOR("black")), COLOR_RES("1", screen.Acolors[COLOR_1], DFT_COLOR("red3")), @@ -633,6 +636,10 @@ static XtResource xterm_resources[] = COLOR_RES("UL", screen.Acolors[COLOR_UL], DFT_COLOR(XtDefaultForeground)), COLOR_RES("RV", screen.Acolors[COLOR_RV], DFT_COLOR(XtDefaultForeground)), +#if OPT_WIDE_ATTRS + COLOR_RES("IT", screen.Acolors[COLOR_IT], DFT_COLOR(XtDefaultForeground)), +#endif + #if !OPT_COLOR_RES2 #if OPT_256_COLORS # include <256colres.h> @@ -675,8 +682,15 @@ static XtResource xterm_resources[] = #endif #if OPT_REGIS_GRAPHICS - Sres(XtNregisScreenSize, XtCRegisScreenSize, screen.regis_screensize, - "800x1000"), + Sres(XtNregisDefaultFont, XtCRegisDefaultFont, + screen.graphics_regis_default_font, ""), + Sres(XtNregisScreenSize, XtCRegisScreenSize, + screen.graphics_regis_screensize, "auto"), +#endif + +#if OPT_GRAPHICS + Sres(XtNmaxGraphicSize, XtCMaxGraphicSize, screen.graphics_max_size, + "1000x1000"), #endif #if OPT_SHIFT_FONTS @@ -2838,6 +2852,7 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState *sp) if (param_has_subparams(item)) { switch (op) { case 38: + /* FALLTHRU */ case 48: if_OPT_ISO_COLORS(screen, { break; @@ -2852,6 +2867,7 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState *sp) switch (op) { case DEFAULT: + /* FALLTHRU */ case 0: #if OPT_WIDE_ATTRS setItalicFont(xw, False); @@ -2876,8 +2892,11 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState *sp) }); break; case 3: /* italicized */ - setItalicFont(xw, True); + setItalicFont(xw, UseItalicFont(screen)); UIntSet(xw->flags, ATR_ITALIC); + if_OPT_ISO_COLORS(screen, { + setExtendedFG(xw); + }); break; #endif case 4: /* Underscore */ @@ -2925,6 +2944,9 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState *sp) case 23: /* not italicized */ setItalicFont(xw, False); UIntClr(xw->flags, ATR_ITALIC); + if_OPT_ISO_COLORS(screen, { + setExtendedFG(xw); + }); break; #endif case 24: @@ -2957,12 +2979,19 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState *sp) break; #endif case 30: + /* FALLTHRU */ case 31: + /* FALLTHRU */ case 32: + /* FALLTHRU */ case 33: + /* FALLTHRU */ case 34: + /* FALLTHRU */ case 35: + /* FALLTHRU */ case 36: + /* FALLTHRU */ case 37: if_OPT_ISO_COLORS(screen, { xw->sgr_foreground = (op - 30); @@ -2988,12 +3017,19 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState *sp) }); break; case 40: + /* FALLTHRU */ case 41: + /* FALLTHRU */ case 42: + /* FALLTHRU */ case 43: + /* FALLTHRU */ case 44: + /* FALLTHRU */ case 45: + /* FALLTHRU */ case 46: + /* FALLTHRU */ case 47: if_OPT_ISO_COLORS(screen, { xw->sgr_background = (op - 40); @@ -3014,12 +3050,19 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState *sp) }); break; case 90: + /* FALLTHRU */ case 91: + /* FALLTHRU */ case 92: + /* FALLTHRU */ case 93: + /* FALLTHRU */ case 94: + /* FALLTHRU */ case 95: + /* FALLTHRU */ case 96: + /* FALLTHRU */ case 97: if_OPT_AIX_COLORS(screen, { xw->sgr_foreground = (op - 90 + 8); @@ -3036,11 +3079,17 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState *sp) break; #endif case 101: + /* FALLTHRU */ case 102: + /* FALLTHRU */ case 103: + /* FALLTHRU */ case 104: + /* FALLTHRU */ case 105: + /* FALLTHRU */ case 106: + /* FALLTHRU */ case 107: if_OPT_AIX_COLORS(screen, { xw->sgr_background = (op - 100 + 8); @@ -3123,6 +3172,7 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState *sp) } break; case 53: /* according to existing xterm handling */ + /* FALLTHRU */ case 55: /* according to the VT330/VT340 Text Programming Manual */ TRACE(("...request locator status\n")); if (sp->private_function @@ -3207,6 +3257,7 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState *sp) break; case CASE_HP_MEM_LOCK: + /* FALLTHRU */ case CASE_HP_MEM_UNLOCK: TRACE(("%s\n", ((sp->parsestate[c] == CASE_HP_MEM_LOCK) ? "CASE_HP_MEM_LOCK" @@ -3329,6 +3380,7 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState *sp) break; case CASE_ANSI_RC: + /* FALLTHRU */ case CASE_DECRC: TRACE(("CASE_%sRC - restore cursor\n", (sp->nextstate == CASE_DECRC) ? "DEC" : "ANSI_")); @@ -3372,7 +3424,9 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState *sp) switch (GetParam(0)) { case DEFAULT: + /* FALLTHRU */ case DEFAULT_STYLE: + /* FALLTHRU */ case BLINK_BLOCK: blinks = True; screen->cursor_shape = CURSOR_BLOCK; @@ -3425,14 +3479,18 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState *sp) xtermClearLEDs(screen); break; case 1: + /* FALLTHRU */ case 2: + /* FALLTHRU */ case 3: xtermShowLED(screen, (Cardinal) op, True); break; case 21: + /* FALLTHRU */ case 22: + /* FALLTHRU */ case 23: xtermShowLED(screen, (Cardinal) (op - 20), @@ -4248,13 +4306,18 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState *sp) TRACE(("CASE_DECSWBV\n")); switch (zero_if_default(0)) { case 2: + /* FALLTHRU */ case 3: + /* FALLTHRU */ case 4: screen->warningVolume = bvLow; break; case 5: + /* FALLTHRU */ case 6: + /* FALLTHRU */ case 7: + /* FALLTHRU */ case 8: screen->warningVolume = bvHigh; break; @@ -4270,14 +4333,20 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState *sp) TRACE(("CASE_DECSMBV\n")); switch (zero_if_default(0)) { case 2: + /* FALLTHRU */ case 3: + /* FALLTHRU */ case 4: screen->marginVolume = bvLow; break; case 0: + /* FALLTHRU */ case 5: + /* FALLTHRU */ case 6: + /* FALLTHRU */ case 7: + /* FALLTHRU */ case 8: screen->marginVolume = bvHigh; break; @@ -5738,8 +5807,11 @@ savemodes(XtermWidget xw) DoSM(DP_X_NCSM, NOCLEAR_COLM); break; case srm_VT200_MOUSE: /* mouse bogus sequence */ + /* FALLTHRU */ case srm_VT200_HIGHLIGHT_MOUSE: + /* FALLTHRU */ case srm_BTN_EVENT_MOUSE: + /* FALLTHRU */ case srm_ANY_EVENT_MOUSE: DoSM(DP_X_MOUSE, screen->send_mouse_pos); break; @@ -6052,8 +6124,11 @@ restoremodes(XtermWidget xw) bitcpy(&xw->flags, screen->save_modes[DP_X_NCSM], NOCLEAR_COLM); break; case srm_VT200_MOUSE: /* mouse bogus sequence */ + /* FALLTHRU */ case srm_VT200_HIGHLIGHT_MOUSE: + /* FALLTHRU */ case srm_BTN_EVENT_MOUSE: + /* FALLTHRU */ case srm_ANY_EVENT_MOUSE: DoRM0(DP_X_MOUSE, screen->send_mouse_pos); really_set_mousemode(xw, @@ -6666,8 +6741,11 @@ unparseseq(XtermWidget xw, ANSI *ap) } switch (ap->a_type) { case ANSI_DCS: + /* FALLTHRU */ case ANSI_OSC: + /* FALLTHRU */ case ANSI_PM: + /* FALLTHRU */ case ANSI_APC: unparseputc1(xw, ANSI_ST); break; @@ -6957,6 +7035,7 @@ VTNonMaskableEvent(Widget w GCC_UNUSED, { switch (event->type) { case GraphicsExpose: + /* FALLTHRU */ case NoExpose: VTGraphicsOrNoExpose(event); break; @@ -7308,6 +7387,7 @@ VTInitialize_locale(XtermWidget xw) if (screen->utf8_fonts == uDefault) { switch (screen->utf8_mode) { case uFalse: + /* FALLTHRU */ case uTrue: screen->utf8_fonts = screen->utf8_mode; break; @@ -7883,7 +7963,7 @@ VTInitialize(Widget wrequest, init_Bres(screen.alt_sends_esc); init_Bres(screen.meta_sends_esc); - init_Bres(screen.allowPasteControls); + init_Bres(screen.allowPasteControl0); init_Bres(screen.allowSendEvent0); init_Bres(screen.allowColorOp0); init_Bres(screen.allowFontOp0); @@ -7930,6 +8010,7 @@ VTInitialize(Widget wrequest, #endif /* make a copy so that editres cannot change the resource after startup */ + TScreenOf(wnew)->allowPasteControls = TScreenOf(wnew)->allowPasteControl0; TScreenOf(wnew)->allowSendEvents = TScreenOf(wnew)->allowSendEvent0; TScreenOf(wnew)->allowColorOps = TScreenOf(wnew)->allowColorOp0; TScreenOf(wnew)->allowFontOps = TScreenOf(wnew)->allowFontOp0; @@ -8027,6 +8108,10 @@ VTInitialize(Widget wrequest, init_Bres(screen.italicULMode); init_Bres(screen.colorRVMode); +#if OPT_WIDE_ATTRS + init_Bres(screen.colorITMode); +#endif + #if OPT_COLOR_RES2 TRACE(("...will fake resources for color%d to color%d\n", MIN_ANSI_COLORS, @@ -8328,56 +8413,128 @@ VTInitialize(Widget wrequest, BtoS(TScreenOf(wnew)->privatecolorregisters))); #endif -#if OPT_REGIS_GRAPHICS - init_Sres(screen.regis_screensize); - TScreenOf(wnew)->regis_max_high = 800; - TScreenOf(wnew)->regis_max_wide = 1000; - if (!x_strcasecmp(TScreenOf(wnew)->regis_screensize, "auto")) { - TRACE(("setting ReGIS screensize based on terminal_id %d\n", - TScreenOf(wnew)->terminal_id)); +#if OPT_GRAPHICS + { + int native_w, native_h; + switch (TScreenOf(wnew)->terminal_id) { case 125: - TScreenOf(wnew)->regis_max_high = 768; - TScreenOf(wnew)->regis_max_wide = 460; + native_w = 768; + native_h = 460; break; case 240: - TScreenOf(wnew)->regis_max_high = 800; - TScreenOf(wnew)->regis_max_wide = 460; + native_w = 800; + native_h = 460; break; case 241: - TScreenOf(wnew)->regis_max_high = 800; - TScreenOf(wnew)->regis_max_wide = 460; + native_w = 800; + native_h = 460; break; case 330: - TScreenOf(wnew)->regis_max_high = 800; - TScreenOf(wnew)->regis_max_wide = 480; + native_w = 800; + native_h = 480; break; case 340: - TScreenOf(wnew)->regis_max_high = 800; - TScreenOf(wnew)->regis_max_wide = 480; + /* FALLTHRU */ + default: + native_w = 800; + native_h = 480; break; case 382: - TScreenOf(wnew)->regis_max_high = 960; - TScreenOf(wnew)->regis_max_wide = 750; + native_w = 960; + native_h = 750; break; } - } else { - int max_high; - int max_wide; - char ignore; - if (sscanf(TScreenOf(wnew)->regis_screensize, - "%dx%d%c", - &max_high, - &max_wide, - &ignore) == 2) { - TScreenOf(wnew)->regis_max_high = (Dimension) max_high; - TScreenOf(wnew)->regis_max_wide = (Dimension) max_wide; +# if OPT_REGIS_GRAPHICS + init_Sres(screen.graphics_regis_default_font); + TRACE(("default ReGIS font: %s\n", + TScreenOf(wnew)->graphics_regis_default_font)); + + init_Sres(screen.graphics_regis_screensize); + TScreenOf(wnew)->graphics_regis_def_high = 800; + TScreenOf(wnew)->graphics_regis_def_wide = 1000; + if (!x_strcasecmp(TScreenOf(wnew)->graphics_regis_screensize, "auto")) { + TRACE(("setting default ReGIS screensize based on terminal_id %d\n", + TScreenOf(wnew)->terminal_id)); + TScreenOf(wnew)->graphics_regis_def_high = (Dimension) native_w; + TScreenOf(wnew)->graphics_regis_def_wide = (Dimension) native_h; + } else { + int conf_high; + int conf_wide; + char ignore; + + if (sscanf(TScreenOf(wnew)->graphics_regis_screensize, + "%dx%d%c", + &conf_wide, + &conf_high, + &ignore) == 2) { + if (conf_high > 0 && conf_wide > 0) { + TScreenOf(wnew)->graphics_regis_def_high = + (Dimension) conf_high; + TScreenOf(wnew)->graphics_regis_def_wide = + (Dimension) conf_wide; + } else { + TRACE(("ignoring invalid regisScreenSize %s\n", + TScreenOf(wnew)->graphics_regis_screensize)); + } + } else { + TRACE(("ignoring invalid regisScreenSize %s\n", + TScreenOf(wnew)->graphics_regis_screensize)); + } + } + TRACE(("default ReGIS graphics screensize %dx%d\n", + (int) TScreenOf(wnew)->graphics_regis_def_wide, + (int) TScreenOf(wnew)->graphics_regis_def_high)); +# endif + + init_Sres(screen.graphics_max_size); + TScreenOf(wnew)->graphics_max_high = 1000; + TScreenOf(wnew)->graphics_max_wide = 1000; + if (!x_strcasecmp(TScreenOf(wnew)->graphics_max_size, "auto")) { + TRACE(("setting max graphics screensize based on terminal_id %d\n", + TScreenOf(wnew)->terminal_id)); + TScreenOf(wnew)->graphics_max_high = (Dimension) native_w; + TScreenOf(wnew)->graphics_max_wide = (Dimension) native_h; + } else { + int conf_high; + int conf_wide; + char ignore; + + if (sscanf(TScreenOf(wnew)->graphics_max_size, + "%dx%d%c", + &conf_wide, + &conf_high, + &ignore) == 2) { + if (conf_high > 0 && conf_wide > 0) { + TScreenOf(wnew)->graphics_max_high = (Dimension) conf_high; + TScreenOf(wnew)->graphics_max_wide = (Dimension) conf_wide; + } else { + TRACE(("ignoring invalid maxGraphicSize %s\n", + TScreenOf(wnew)->graphics_regis_screensize)); + } + } else { + TRACE(("ignoring invalid maxGraphicSize %s\n", + TScreenOf(wnew)->graphics_regis_screensize)); + } + } +# if OPT_REGIS_GRAPHICS + /* Make sure the max is large enough for the default ReGIS size. */ + if (TScreenOf(wnew)->graphics_regis_def_high > + TScreenOf(wnew)->graphics_max_high) { + TScreenOf(wnew)->graphics_max_high = + TScreenOf(wnew)->graphics_regis_def_high; + } + if (TScreenOf(wnew)->graphics_regis_def_wide > + TScreenOf(wnew)->graphics_max_wide) { + TScreenOf(wnew)->graphics_max_wide = + TScreenOf(wnew)->graphics_regis_def_wide; } +# endif + TRACE(("max graphics screensize %dx%d\n", + (int) TScreenOf(wnew)->graphics_max_wide, + (int) TScreenOf(wnew)->graphics_max_high)); } - TRACE(("maximum ReGIS screensize %dx%d\n", - (int) TScreenOf(wnew)->regis_max_high, - (int) TScreenOf(wnew)->regis_max_wide)); #endif #if OPT_SIXEL_GRAPHICS @@ -8569,7 +8726,9 @@ VTDestroy(Widget w GCC_UNUSED) switch (n) { #if OPT_TEK4014 case TEK_BG: + /* FALLTHRU */ case TEK_FG: + /* FALLTHRU */ case TEK_CURSOR: break; #endif @@ -10023,7 +10182,7 @@ ShowCursor(void) } }); - if (fix_italics) { + if (fix_italics && UseItalicFont(screen)) { xtermLoadItalics(xw); if (italics_on) { setCgsFont(xw, currentWin, currentCgs, &screen->ifnts[which_font]); @@ -10064,7 +10223,7 @@ ShowCursor(void) screen->box, NBOX, CoordModePrevious); } #if OPT_WIDE_ATTRS - if (fix_italics) { + if (fix_italics && UseItalicFont(screen)) { if (italics_on) { setCgsFont(xw, currentWin, currentCgs, &screen->fnts[which_font]); } else { @@ -10189,7 +10348,7 @@ HideCursor(void) }); setCgsFont(xw, WhichVWin(screen), whichXtermCgs(xw, attr_flags, in_selection), - ((attr_flags & ATR_ITALIC) + (((attr_flags & ATR_ITALIC) && UseItalicFont(screen)) ? &screen->ifnts[which_font] : &screen->fnts[which_font])); } @@ -10231,7 +10390,7 @@ HideCursor(void) if ((attr_flags & ATR_ITALIC) ^ (xw->flags & ATR_ITALIC)) { setCgsFont(xw, WhichVWin(screen), whichXtermCgs(xw, xw->flags, in_selection), - ((xw->flags & ATR_ITALIC) + (((xw->flags & ATR_ITALIC) && UseItalicFont(screen)) ? &screen->ifnts[which_font] : &screen->fnts[which_font])); } diff --git a/app/xterm/configure.in b/app/xterm/configure.in index 40c638772..548e88320 100644 --- a/app/xterm/configure.in +++ b/app/xterm/configure.in @@ -1,4 +1,4 @@ -dnl $XTermId: configure.in,v 1.326 2014/05/08 20:47:36 tom Exp $ +dnl $XTermId: configure.in,v 1.327 2014/12/20 02:27:59 tom Exp $ dnl dnl ----------------------------------------------------------------------------- dnl this file is part of xterm @@ -55,12 +55,13 @@ esac CF_PROG_CC AC_PROG_CPP AC_PROG_AWK -CF_PROG_GROFF AC_PROG_INSTALL AC_PROG_LN_S AC_ARG_PROGRAM AC_CHECK_PROGS(LINT, tdlint lint alint) +CF_WITH_MAN2HTML + ### checks for compiler characteristics CF_XOPEN_SOURCE CF_SIGWINCH diff --git a/app/xterm/ctlseqs.ms b/app/xterm/ctlseqs.ms index e36b4f33d..d72b21c1c 100644 --- a/app/xterm/ctlseqs.ms +++ b/app/xterm/ctlseqs.ms @@ -1,6 +1,6 @@ .\"#! troff -ms $1 -*- Nroff -*- .\" "Xterm Control Sequences" document -.\" $XTermId: ctlseqs.ms,v 1.311 2014/05/27 00:23:36 tom Exp $ +.\" $XTermId: ctlseqs.ms,v 1.315 2014/12/17 10:16:03 tom Exp $ .\" .\" .\" Copyright 1996-2013,2014 by Thomas E. Dickey @@ -69,8 +69,8 @@ .\" .ds XT XTerm .ds xt xterm -.ds LF Patch #305 -.ds RF 2014/05/26 +.ds LF Patch #314 +.ds RF 2014/12/17 .\" .if n .pl 9999v \" no page breaks in nroff .ND @@ -1129,10 +1129,10 @@ ISO-8613-3 can be interpreted in more than one way; .RE .sP These ISO-8613-3 controls are supported: - \*(Ps = \*3\*8 ; \*2 ; \*(Pr ; \*(Pg ; \*(Pb \(-> Set foreground color to the closest match in \fIxterm\fP's palette for the given RGB \*(Pr/\*(Pg/\*(Pb. - \*(Ps = \*3\*8 ; \*5 ; \*(Ps \(-> Set foreground color to the second \*(Ps. - \*(Ps = \*4\*8 ; \*2 ; \*(Pr ; \*(Pg ; \*(Pb \(-> Set background color to the closest match in \fIxterm\fP's palette for the given RGB \*(Pr/\*(Pg/\*(Pb. - \*(Ps = \*4\*8 ; \*5 ; \*(Ps \(-> Set background color to the second \*(Ps. + \*(Ps = \*3\*8\*;\*2\*;\*(Pr\*;\*(Pg\*;\*(Pb \(-> Set foreground color to the closest match in \fIxterm\fP's palette for the given RGB \*(Pr/\*(Pg/\*(Pb. + \*(Ps = \*3\*8\*;\*5\*;\*(Ps \(-> Set foreground color to the second \*(Ps. + \*(Ps = \*4\*8\*;\*2\*;\*(Pr\*;\*(Pg\*;\*(Pb \(-> Set background color to the closest match in \fIxterm\fP's palette for the given RGB \*(Pr/\*(Pg/\*(Pb. + \*(Ps = \*4\*8\*;\*5\*;\*(Ps \(-> Set background color to the second \*(Ps. .sp . .IP \\*(Cs\\*>\\*(Ps\\*;\\*(Ps\\*s\\*m @@ -1151,11 +1151,13 @@ If no parameters are given, all resources are reset to their initial values. . .IP \\*(Cs\\*(Ps\\*s\\*n Device Status Report (DSR). - \*(Ps = \*5 \(-> Status Report. Result (``OK'') is + \*(Ps = \*5 \(-> Status Report. .br +Result (``OK'') is \*(Cs\*0\*n - \*(Ps = \*6 \(-> Report Cursor Position (CPR) [row;column]. Result is + \*(Ps = \*6 \(-> Report Cursor Position (CPR) [row;column]. .br +Result is \*(Cs\*(Ir\*s\*;\*(Ic\*s\*R .sp \fBNote\fP: @@ -1357,17 +1359,29 @@ Zero parameters use the display's height or width. \*(Ps = \*1\*1 \(-> Report \fIxterm\fP window state. If the \fIxterm\fP window is open (non-iconified), it returns \*(Cs\*1\*t. If the \fIxterm\fP window is iconified, it returns \*(Cs\*2\*t. - \*(Ps = \*1\*3 \(-> Report \fIxterm\fP window position. Result is + \*(Ps = \*1\*3 \(-> Report \fIxterm\fP window position. +.br +Result is \*(Cs\*3\*;\*(Ix\*s\*;\*(Iy\*s\*t - \*(Ps = \*1\*4 \(-> Report \fIxterm\fP window in pixels. Result is + \*(Ps = \*1\*4 \(-> Report \fIxterm\fP window in pixels. +.br +Result is \*(Cs\*s\*4\*s\*;\*s\fIheight\fP\*s\*;\*s\fIwidth\fP\*s\*t - \*(Ps = \*1\*8 \(-> Report the size of the text area in characters. Result is + \*(Ps = \*1\*8 \(-> Report the size of the text area in characters. +.br +Result is \*(Cs\*s\*8\*s\*;\*s\fIheight\fP\*s\*;\*s\fIwidth\fP\*s\*t - \*(Ps = \*1\*9 \(-> Report the size of the screen in characters. Result is + \*(Ps = \*1\*9 \(-> Report the size of the screen in characters. +.br +Result is \*(Cs\*s\*9\*s\*;\*s\fIheight\fP\*s\*;\*s\fIwidth\fP\*s\*t - \*(Ps = \*2\*0 \(-> Report \fIxterm\fP window's icon label. Result is + \*(Ps = \*2\*0 \(-> Report \fIxterm\fP window's icon label. +.br +Result is \*(Os\*s\*L\*s\fIlabel\fP\*s\*(ST - \*(Ps = \*2\*1 \(-> Report \fIxterm\fP window's title. Result is + \*(Ps = \*2\*1 \(-> Report \fIxterm\fP window's title. +.br +Result is \*(Os\*s\*l\*s\fIlabel\fP\*s\*(ST \*(Ps = \*2\*2\*s\*;\*s\*0 \(-> Save \fIxterm\fP icon and window title on stack. \*(Ps = \*2\*2\*s\*;\*s\*1 \(-> Save \fIxterm\fP icon title on stack. @@ -1512,7 +1526,7 @@ have been enabled with a DECEFR. .sP \(-> \*(Cs\*(Pe\*s\*;\*(Pb\*s\*;\*(Pr\*s\*;\*(Pc\*s\*;\*(Pp\*s\*&\*s\*w .sP -Parameters are [event;button;row;column;page]. +Parameters are [\fIevent\fP;\fIbutton\fP;\fIrow\fP;\fIcolumn\fP;\fIpage\fP]. .br Valid values for the event: \*(Pe = \*0 \(-> locator unavailable - no other parameters sent. @@ -1527,17 +1541,17 @@ Valid values for the event: \*(Pe = \*9 \(-> M4 button up. \*(Pe = \*1\*0 \(-> locator outside filter rectangle. .br -``button'' parameter is a bitmask indicating which buttons are pressed: +The ``\fIbutton\fP'' parameter is a bitmask indicating which buttons are pressed: \*(Pb = \*0 \(<- no buttons down. \*(Pb & \*1 \(<- right button down. \*(Pb & \*2 \(<- middle button down. \*(Pb & \*4 \(<- left button down. \*(Pb & \*8 \(<- M4 button down. .br -``row'' and ``column'' parameters are the coordinates of the locator +The ``\fIrow\fP'' and ``\fIcolumn\fP'' parameters are the coordinates of the locator position in the \fI\*(xt\fP window, encoded as ASCII decimal. .br -The ``page'' parameter is not used by \*(xt, and will be omitted. +The ``\fIpage\fP'' parameter is not used by \*(xt. . .IP \\*(Cs\\*(Pm\\*s\\*(qu\\*} Insert \*(Ps Column(s) (default = 1) (DECIC), VT420 and up. @@ -1564,10 +1578,10 @@ and window title. \*(Ps = \*3 \(-> Set X property on top-level window. \*(Pt should be in the form "\fIprop=value\fP", or just "\fIprop\fP" to delete the property - \*(Ps = \*4 ; \fIc ; spec\fP \(-> Change Color Number \fIc\fP to + \*(Ps = \*4\*;\fIc\fP\*;\fIspec\fP \(-> Change Color Number \fIc\fP to the color specified by \fIspec\fP. This can be a name or RGB specification as per \fIXParseColor\fP. -Any number of \fIc name\fP pairs may be given. +Any number of \fIc\fP/\fIspec\fP pairs may be given. The color numbers correspond to the ANSI colors 0-7, their bright versions 8-15, and if supported, the remainder of the 88-color or 256-color table. @@ -1578,17 +1592,33 @@ to set the corresponding color. Because more than one pair of color number and specification can be given in one control sequence, \fIxterm\fR can make more than one reply. .sP - \*(Ps = \*5 ; \fIc ; spec\fP \(-> Change Special Color Number \fIc\fP to + \*(Ps = \*5\*;\fIc\fP\*;\fIspec\fP \(-> Change Special Color Number \fIc\fP to the color specified by \fIspec\fP. This can be a name or RGB specification as per \fIXParseColor\fP. -Any number of \fIc name\fP pairs may be given. +Any number of \fIc\fP/\fIspec\fP pairs may be given. The special colors can also be set by adding the maximum number of colors to these codes in an \*(Os\*4 control: .sP +.in +2n \*(Pc = \*0 \(<- resource \fBcolorBD\fP (BOLD). \*(Pc = \*1 \(<- resource \fBcolorUL\fP (UNDERLINE). \*(Pc = \*2 \(<- resource \fBcolorBL\fP (BLINK). \*(Pc = \*3 \(<- resource \fBcolorRV\fP (REVERSE). + \*(Pc = \*4 \(<- resource \fBcolorIT\fP (ITALIC). +.in -2n +.sP + \*(Ps = \*6\*;\fIc\fP\*;\fIf\fP \(-> Enable/disable Special Color Number \fIc\fP. +The second parameter tells \fIxterm\fP to enable the corresponding color +mode if nonzero, disable it if zero. +.sP +.in +2n + \*(Pc = \*0 \(<- resource \fBcolorBDMode\fP (BOLD). + \*(Pc = \*1 \(<- resource \fBcolorULMode\fP (UNDERLINE). + \*(Pc = \*2 \(<- resource \fBcolorBLMode\fP (BLINK). + \*(Pc = \*3 \(<- resource \fBcolorRVMode\fP (REVERSE). + \*(Pc = \*4 \(<- resource \fBcolorITMode\fP (ITALIC). + \*(Pc = \*5 \(<- resource \fBcolorAttrMode\fP (Override ANSI). +.in -2n .sP The 10 colors (below) which may be set or queried using \*1\*0 through \*1\*9 are @@ -1640,7 +1670,7 @@ by adding a space and then the font specifier. If the "TrueType Fonts" menu entry is set (the \fBrenderFont\fP resource), then this control sets/queries the \fBfaceName\fP resource. .sP - \*(Ps = \*5\*1 (reserved for Emacs shell). + \*(Ps = \*5\*1 \(-> reserved for Emacs shell. .sP \*(Ps = \*5\*2 \(-> Manipulate Selection Data. These controls may be disabled using the \fIallowWindowOps\fP resource. @@ -1672,7 +1702,7 @@ If the second parameter is neither a base64 string nor \*?, then the selection is cleared. .Ed .sP - \*(Ps = \*1\*0\*4 ; \fIc\fP \(-> Reset Color Number \fIc\fP. It is reset to + \*(Ps = \*1\*0\*4\*;\fIc\fP \(-> Reset Color Number \fIc\fP. It is reset to the color specified by the corresponding X resource. Any number of \fIc\fP parameters may be given. These parameters correspond to the ANSI colors 0-7, @@ -1680,7 +1710,7 @@ their bright versions 8-15, and if supported, the remainder of the 88-color or 256-color table. If no parameters are given, the entire table will be reset. .sP - \*(Ps = \*1\*0\*5 ; \fIc\fP \(-> Reset Special Color Number \fIc\fP. It is reset to + \*(Ps = \*1\*0\*5\*;\fIc\fP \(-> Reset Special Color Number \fIc\fP. It is reset to the color specified by the corresponding X resource. Any number of \fIc\fP parameters may be given. These parameters correspond to the special colors which can be set diff --git a/app/xterm/ctlseqs.txt b/app/xterm/ctlseqs.txt index 58d90dc88..55cdee399 100644 --- a/app/xterm/ctlseqs.txt +++ b/app/xterm/ctlseqs.txt @@ -21,7 +21,7 @@ Thomas Dickey XFree86 Project (1996-2006) invisible-island.net (2006-2013) - updated for XTerm Patch #305 (2014/05/26) + updated for XTerm Patch #314 (2014/12/17) @@ -624,14 +624,12 @@ CSI Pm m Character Attributes (SGR). colons (but after the first colon, colons must be used). These ISO-8613-3 controls are supported: - Ps = 3 8 ; 2 ; Pr ; Pg ; Pb -> Set foreground color to the + Ps = 3 8 ; 2 ; Pr; Pg; Pb -> Set foreground color to the closest match in xterm's palette for the given RGB Pr/Pg/Pb. - Ps = 3 8 ; 5 ; Ps -> Set foreground color to the second - Ps. - Ps = 4 8 ; 2 ; Pr ; Pg ; Pb -> Set background color to the + Ps = 3 8 ; 5 ; Ps -> Set foreground color to the second Ps. + Ps = 4 8 ; 2 ; Pr; Pg; Pb -> Set background color to the closest match in xterm's palette for the given RGB Pr/Pg/Pb. - Ps = 4 8 ; 5 ; Ps -> Set background color to the second - Ps. + Ps = 4 8 ; 5 ; Ps -> Set background color to the second Ps. CSI > Ps; Ps m Set or reset resource-values used by xterm to decide whether @@ -647,11 +645,10 @@ CSI > Ps; Ps m If no parameters are given, all resources are reset to their initial values. CSI Ps n Device Status Report (DSR). - Ps = 5 -> Status Report. Result (``OK'') is - CSI 0 n + Ps = 5 -> Status Report. + Result (``OK'') is CSI 0 n Ps = 6 -> Report Cursor Position (CPR) [row;column]. - Result is - CSI r ; c R + Result is CSI r ; c R Note: it is possible for this sequence to be sent by a func- tion key. For example, with the default keyboard configura- @@ -818,18 +815,18 @@ CSI Ps ; Ps ; Ps t Ps = 1 1 -> Report xterm window state. If the xterm window is open (non-iconified), it returns CSI 1 t . If the xterm window is iconified, it returns CSI 2 t . - Ps = 1 3 -> Report xterm window position. Result is CSI 3 - ; x ; y t - Ps = 1 4 -> Report xterm window in pixels. Result is CSI - 4 ; height ; width t + Ps = 1 3 -> Report xterm window position. + Result is CSI 3 ; x ; y t + Ps = 1 4 -> Report xterm window in pixels. + Result is CSI 4 ; height ; width t Ps = 1 8 -> Report the size of the text area in characters. Result is CSI 8 ; height ; width t Ps = 1 9 -> Report the size of the screen in characters. Result is CSI 9 ; height ; width t - Ps = 2 0 -> Report xterm window's icon label. Result is - OSC L label ST - Ps = 2 1 -> Report xterm window's title. Result is OSC l - label ST + Ps = 2 0 -> Report xterm window's icon label. + Result is OSC L label ST + Ps = 2 1 -> Report xterm window's title. + Result is OSC l label ST Ps = 2 2 ; 0 -> Save xterm icon and window title on stack. Ps = 2 2 ; 1 -> Save xterm icon title on stack. @@ -965,18 +962,17 @@ CSI Ps ' | Pe = 8 -> M4 button down. Pe = 9 -> M4 button up. Pe = 1 0 -> locator outside filter rectangle. - ``button'' parameter is a bitmask indicating which buttons are - pressed: + The ``button'' parameter is a bitmask indicating which buttons + are pressed: Pb = 0 <- no buttons down. Pb & 1 <- right button down. Pb & 2 <- middle button down. Pb & 4 <- left button down. Pb & 8 <- M4 button down. - ``row'' and ``column'' parameters are the coordinates of the - locator position in the xterm window, encoded as ASCII deci- - mal. - The ``page'' parameter is not used by xterm, and will be omit- - ted. + The ``row'' and ``column'' parameters are the coordinates of + the locator position in the xterm window, encoded as ASCII + decimal. + The ``page'' parameter is not used by xterm. CSI Pm ' } Insert Ps Column(s) (default = 1) (DECIC), VT420 and up. CSI Pm ' ~ @@ -996,12 +992,12 @@ OSC Ps ; Pt BEL Ps = 3 -> Set X property on top-level window. Pt should be in the form "prop=value", or just "prop" to delete the prop- erty - Ps = 4 ; c ; spec -> Change Color Number c to the color - specified by spec. This can be a name or RGB specification as - per XParseColor. Any number of c name pairs may be given. - The color numbers correspond to the ANSI colors 0-7, their - bright versions 8-15, and if supported, the remainder of the - 88-color or 256-color table. + Ps = 4 ; c; spec -> Change Color Number c to the color spec- + ified by spec. This can be a name or RGB specification as per + XParseColor. Any number of c/spec pairs may be given. The + color numbers correspond to the ANSI colors 0-7, their bright + versions 8-15, and if supported, the remainder of the 88-color + or 256-color table. If a "?" is given rather than a name or RGB specification, xterm replies with a control sequence of the same form which @@ -1009,16 +1005,28 @@ OSC Ps ; Pt BEL one pair of color number and specification can be given in one control sequence, xterm can make more than one reply. - Ps = 5 ; c ; spec -> Change Special Color Number c to the + Ps = 5 ; c; spec -> Change Special Color Number c to the color specified by spec. This can be a name or RGB specifica- - tion as per XParseColor. Any number of c name pairs may be + tion as per XParseColor. Any number of c/spec pairs may be given. The special colors can also be set by adding the maxi- mum number of colors to these codes in an OSC 4 control: - Pc = 0 <- resource colorBD (BOLD). - Pc = 1 <- resource colorUL (UNDERLINE). - Pc = 2 <- resource colorBL (BLINK). - Pc = 3 <- resource colorRV (REVERSE). + Pc = 0 <- resource colorBD (BOLD). + Pc = 1 <- resource colorUL (UNDERLINE). + Pc = 2 <- resource colorBL (BLINK). + Pc = 3 <- resource colorRV (REVERSE). + Pc = 4 <- resource colorIT (ITALIC). + + Ps = 6 ; c; f -> Enable/disable Special Color Number c. The + second parameter tells xterm to enable the corresponding color + mode if nonzero, disable it if zero. + + Pc = 0 <- resource colorBDMode (BOLD). + Pc = 1 <- resource colorULMode (UNDERLINE). + Pc = 2 <- resource colorBLMode (BLINK). + Pc = 3 <- resource colorRVMode (REVERSE). + Pc = 4 <- resource colorITMode (ITALIC). + Pc = 5 <- resource colorAttrMode (Override ANSI). The 10 colors (below) which may be set or queried using 1 0 through 1 9 are denoted dynamic colors, since the correspond- @@ -1066,7 +1074,7 @@ OSC Ps ; Pt BEL resource), then this control sets/queries the faceName resource. - Ps = 5 1 (reserved for Emacs shell). + Ps = 5 1 -> reserved for Emacs shell. Ps = 5 2 -> Manipulate Selection Data. These controls may be disabled using the allowWindowOps resource. The parameter @@ -1087,18 +1095,18 @@ OSC Ps ; Pt BEL If the second parameter is neither a base64 string nor ? , then the selection is cleared. - Ps = 1 0 4 ; c -> Reset Color Number c. It is reset to the + Ps = 1 0 4 ; c -> Reset Color Number c. It is reset to the color specified by the corresponding X resource. Any number of c parameters may be given. These parameters correspond to the ANSI colors 0-7, their bright versions 8-15, and if sup- ported, the remainder of the 88-color or 256-color table. If no parameters are given, the entire table will be reset. - Ps = 1 0 5 ; c -> Reset Special Color Number c. It is - reset to the color specified by the corresponding X resource. - Any number of c parameters may be given. These parameters - correspond to the special colors which can be set using an OSC - 5 control (or by adding the maximum number of colors using an + Ps = 1 0 5 ; c -> Reset Special Color Number c. It is reset + to the color specified by the corresponding X resource. Any + number of c parameters may be given. These parameters corre- + spond to the special colors which can be set using an OSC 5 + control (or by adding the maximum number of colors using an OSC 4 control). The dynamic colors can also be reset to their default diff --git a/app/xterm/fontutils.c b/app/xterm/fontutils.c index 9456c43a4..63f2bf6b2 100644 --- a/app/xterm/fontutils.c +++ b/app/xterm/fontutils.c @@ -1,4 +1,4 @@ -/* $XTermId: fontutils.c,v 1.443 2014/09/03 23:58:53 tom Exp $ */ +/* $XTermId: fontutils.c,v 1.445 2014/12/28 22:52:30 tom Exp $ */ /* * Copyright 1998-2013,2014 by Thomas E. Dickey @@ -1589,7 +1589,7 @@ xtermLoadItalics(XtermWidget xw) FREE_STRING(dst.menu_font_names[n][m]); \ dst.menu_font_names[n][m] = x_strdup(src.menu_font_names[n][m]); \ } \ - TRACE((".. " #dst ".menu_fonts_names[%d] = %s\n", n, dst.menu_font_names[n][fNorm])); \ + TRACE((".. " #dst ".menu_fonts_names[%d] = %s\n", n, NonNull(dst.menu_font_names[n][fNorm]))); \ } #define COPY_DEFAULT_FONTS(target, source) \ @@ -3569,9 +3569,9 @@ SetVTFont(XtermWidget xw, SAVE_FNAME(f_wb, fWBold); #endif } else { - xtermLoadFont(xw, - xtermFontName(screen->MenuFontName(oldFont)), - doresize, oldFont); + (void) xtermLoadFont(xw, + xtermFontName(screen->MenuFontName(oldFont)), + doresize, oldFont); Bell(xw, XkbBI_MinorError, 0); } FREE_FNAME(f_n); diff --git a/app/xterm/graphics.c b/app/xterm/graphics.c index 434b4b02d..665b749c5 100644 --- a/app/xterm/graphics.c +++ b/app/xterm/graphics.c @@ -1,4 +1,4 @@ -/* $XTermId: graphics.c,v 1.58 2014/11/28 21:00:04 tom Exp $ */ +/* $XTermId: graphics.c,v 1.62 2014/12/23 00:08:58 Ross.Combs Exp $ */ /* * Copyright 2013,2014 by Ross Combs @@ -55,13 +55,12 @@ * - find a suitable default alphabet zero font instead of scaling Xft fonts * - input and output cursors * - mouse input - * - custom coordinate systems * - investigate second graphic page for ReGIS -- does it also apply to text and sixel graphics? are the contents preserved? * - fix interpolated curves to more closely match implementation (identical despite direction and starting point) * - non-ASCII alphabets * - enter/leave during a command * - command display mode - * - scaling/re-rasterization to fit screen + * - re-rasterization on resize * - macros * - improved fills for narrow angles (track actual lines not just pixels) * @@ -118,6 +117,7 @@ * - background color as stackable write control * - true color (virtual color registers created upon lookup) * - anti-aliasing + * - variable-width text */ /* font sizes: @@ -164,12 +164,14 @@ freeGraphic(Graphic *obj) } static Graphic * -allocGraphic(const TScreen *screen) +allocGraphic(int max_w, int max_h) { Graphic *result = TypeCalloc(Graphic); if (result) { - size_t max_pixels = (size_t) (screen->regis_max_wide * screen->regis_max_high); - if (!(result->pixels = TypeCallocN(RegisterNum, max_pixels))) { + result->max_width = max_w; + result->max_height = max_h; + if (!(result->pixels = TypeCallocN(RegisterNum, + (size_t) max_w * (size_t) max_h))) { result = freeGraphic(result); } else if (!(result->private_color_registers = allocRegisters())) { result = freeGraphic(result); @@ -196,7 +198,8 @@ getInactiveSlot(const TScreen *screen, unsigned n) (!displayed_graphics[n] || !displayed_graphics[n]->valid)) { if (!displayed_graphics[n]) { - displayed_graphics[n] = allocGraphic(screen); + displayed_graphics[n] = allocGraphic(screen->graphics_max_wide, + screen->graphics_max_high); } return displayed_graphics[n]; } @@ -673,8 +676,7 @@ get_color_register_count(TScreen const *screen) } static void -init_graphic(const TScreen *screen, - Graphic *graphic, +init_graphic(Graphic *graphic, unsigned type, int terminal_id, int charrow, @@ -682,7 +684,8 @@ init_graphic(const TScreen *screen, unsigned num_color_registers, int private_colors) { - size_t max_pixels = (size_t) (screen->regis_max_wide * screen->regis_max_high); + const unsigned max_pixels = (unsigned) (graphic->max_width * + graphic->max_height); unsigned i; TRACE(("initializing graphic object\n")); @@ -711,8 +714,6 @@ init_graphic(const TScreen *screen, * VT382 960x750 sixel only * dxterm ?x? ?x? variable? */ - graphic->max_width = screen->regis_max_wide; - graphic->max_height = screen->regis_max_high; graphic->actual_width = 0; graphic->actual_height = 0; @@ -778,8 +779,7 @@ get_new_graphic(XtermWidget xw, int charrow, int charcol, unsigned type) graphic->xw = xw; graphic->bufferid = bufferid; graphic->id = next_graphic_id++; - init_graphic(screen, - graphic, + init_graphic(graphic, type, terminal_id, charrow, @@ -917,6 +917,7 @@ refresh_graphic(TScreen const *screen, int const graph_y = graphic->charrow * FontHeight(screen); int const graph_w = graphic->actual_width; int const graph_h = graphic->actual_height; + int const mw = graphic->max_width; int r, c; int fillx, filly; int holes, total, out_of_range; @@ -953,7 +954,7 @@ refresh_graphic(TScreen const *screen, break; total++; - regnum = graphic->pixels[r * graphic->max_width + c]; + regnum = graphic->pixels[r * mw + c]; if (regnum == COLOR_HOLE) { holes++; continue; diff --git a/app/xterm/graphics_regis.c b/app/xterm/graphics_regis.c index ffceb2434..3a983a82f 100644 --- a/app/xterm/graphics_regis.c +++ b/app/xterm/graphics_regis.c @@ -1,4 +1,4 @@ -/* $XTermId: graphics_regis.c,v 1.52 2014/11/28 20:37:24 tom Exp $ */ +/* $XTermId: graphics_regis.c,v 1.62 2014/12/23 01:39:00 tom Exp $ */ /* * Copyright 2014 by Ross Combs @@ -79,6 +79,7 @@ #define SCALE_FIXED_POINT 16U +#undef DEBUG_ALPHABETS #undef DEBUG_BEZIER #undef DEBUG_SPLINE_SEGMENTS #undef DEBUG_SPLINE_POINTS @@ -90,6 +91,7 @@ #undef DEBUG_SPECIFIC_CHAR_METRICS #define IS_DEBUG_CHAR(CH) ((CH) == 'W') /* glyphs to dump to terminal */ #undef DEBUG_COMPUTED_FONT_METRICS +#undef DEBUG_FONT_NAME #undef DEBUG_FONT_SIZE_SEARCH #undef DEBUG_XFT_GLYPH #undef DEBUG_LOAD @@ -139,6 +141,9 @@ typedef struct RegisTextControls { int slant; /* for italic/oblique */ } RegisTextControls; +#define FixedCopy(dst, src, len) strncpy(dst, src, len - 1)[len - 1] = '\0' +#define CopyFontname(dst, src) FixedCopy(dst, src, REGIS_FONTNAME_LEN) + #define MAX_REGIS_ALPHABETS 8U #define REGIS_ALPHABET_NAME_LEN 11U #define REGIS_FONTNAME_LEN 256U @@ -209,8 +214,12 @@ typedef struct RegisParseState { typedef struct RegisGraphicsContext { Graphic *graphic; int terminal_id; + int x_off, y_off; + int x_div, y_div; + int width, height; unsigned all_planes; RegisterNum background; + char const *builtin_font; RegisAlphabet alphabets[MAX_REGIS_ALPHABETS]; RegisWriteControls persistent_write_controls; RegisWriteControls temporary_write_controls; @@ -227,6 +236,8 @@ typedef struct RegisGraphicsContext { unsigned fill_point_count; } RegisGraphicsContext; +static RegisGraphicsContext persistent_context; + #define MAX_PATTERN_BITS 8U #define WRITE_STYLE_OVERLAY 1U @@ -239,10 +250,25 @@ typedef struct RegisGraphicsContext { /* keypress event example: http://iraf.net/forum/viewtopic.php?showtopic=61692 */ +#define MIN2(X, Y) ( (X) < (Y) ? (X) : (Y) ) +#define MIN3(X, Y, Z) ( MIN2(MIN2((X), (Y)), MIN2((Y), (Z))) ) +#define MAX2(X, Y) ( (X) > (Y) ? (X) : (Y) ) +#define MAX3(X, Y, Z) ( MAX2(MAX2((X), (Y)), MAX2((Y), (Z))) ) + #define ROT_LEFT_N(V, N) ( (((V) << ((N) & 3U )) & 255U) | \ ((V) >> (8U - ((N) & 3U))) ) #define ROT_LEFT(V) ( (((V) << 1U) & 255U) | ((V) >> 7U) ) +#define SCALE_XCOORD(C, X, S) ( ( (X) * ((C)->width - 1) ) / ( (C)->x_div * (S) ) ) +#define SCALE_YCOORD(C, Y, S) ( ( (Y) * ((C)->height - 1) ) / ( (C)->y_div * (S) ) ) +#define TRANSLATE_XCOORD(C, X, S) SCALE_XCOORD((C), (X) - (C)->x_off * (S), (S) ) +#define TRANSLATE_YCOORD(C, Y, S) SCALE_YCOORD((C), (Y) - (C)->y_off * (S), (S) ) + +#define READ_PIXEL(C, X, Y) read_pixel((C)->graphic, (X), (Y)) +#define DRAW_PIXEL(C, X, Y, COL) draw_solid_pixel((C)->graphic, (X), (Y), (COL)) +#define DRAW_ALL(C, COL) \ + draw_solid_rectangle((C)->graphic, 0, 0, (C)->width, (C)->height, (COL)) + static unsigned get_shade_character_pixel(unsigned char const *pixels, unsigned w, unsigned h, unsigned smaxf, unsigned scale, @@ -318,7 +344,7 @@ draw_regis_pixel(RegisGraphicsContext *context, int x, int y, return; } - color = read_pixel(context->graphic, x, y); + color = READ_PIXEL(context, x, y); if (color == COLOR_HOLE) color = context->background; color = color ^ context->all_planes; @@ -334,7 +360,7 @@ draw_regis_pixel(RegisGraphicsContext *context, int x, int y, break; } - draw_solid_pixel(context->graphic, x, y, color); + DRAW_PIXEL(context, x, y, color); } static void @@ -717,7 +743,8 @@ draw_patterned_arc(RegisGraphicsContext *context, points_stop = (total_points * a_start + total_points * abs(a_length) + 359) / 360; TRACE(("drawing arc with %d points from %d angle for %d degrees (from point %d to %d out of %d)\n", - total_points, a_start, a_length, points_start, points_stop, total_points)); + total_points, a_start, a_length, points_start, points_stop, + total_points)); points = 0; for (iterations = 0U; iterations < 8U; iterations++) { @@ -1219,14 +1246,14 @@ plotCubicSpline(int n, int x[], int y[], int skip_first_last) int x3, y3, x4, y4; int i, x0, y0, x1, y1, x2, y2; #ifdef DEBUG_SPLINE_SEGMENTS - int color = 0; + RegisterNum color = 0; #endif assert(n > 2); /* need at least 4 points P[0]..P[n] */ #ifdef DEBUG_SPLINE_POINTS { - int save_pattern; + unsigned save_pattern; i = 0; global_context->temporary_write_controls.foreground = 11; @@ -1611,7 +1638,7 @@ get_xft_glyph_dimensions(Display *display, XftFont *font, unsigned *w, * maxw and maxh without overstepping either dimension. */ static XftFont * -find_best_xft_font_size(Display *display, Screen * screen, char const *fontname, +find_best_xft_font_size(Display *display, Screen *screen, char const *fontname, unsigned maxw, unsigned maxh, unsigned max_pixels, unsigned *w, unsigned *h, unsigned *xmin, unsigned *ymin) @@ -1620,6 +1647,7 @@ find_best_xft_font_size(Display *display, Screen * screen, char const *fontname, unsigned targeth; unsigned ii, cacheindex; static struct { + char fontname[REGIS_FONTNAME_LEN]; unsigned maxw, maxh, max_pixels; unsigned targeth; unsigned w, h; @@ -1627,10 +1655,19 @@ find_best_xft_font_size(Display *display, Screen * screen, char const *fontname, unsigned ymin; } cache[FONT_SIZE_CACHE_SIZE]; + assert(display); + assert(screen); + assert(fontname); + assert(w); + assert(h); + assert(xmin); + assert(ymin); + cacheindex = FONT_SIZE_CACHE_SIZE; for (ii = 0U; ii < FONT_SIZE_CACHE_SIZE; ii++) { if (cache[ii].maxw == maxw && cache[ii].maxh == maxh && - cache[ii].max_pixels == max_pixels) { + cache[ii].max_pixels == max_pixels && + strcmp(cache[ii].fontname, fontname) == 0) { cacheindex = ii; break; } @@ -1706,14 +1743,15 @@ find_best_xft_font_size(Display *display, Screen * screen, char const *fontname, char buffer[1024]; if (XftNameUnparse(font->pattern, buffer, (int) sizeof(buffer))) { - printf("Using font named \"%s\"\n", buffer); + printf("Testing font named \"%s\"\n", buffer); } else { - printf("Using unknown font\n"); + printf("Testing unknown font\n"); } } #endif - if (cacheindex < sizeof(cache) / sizeof(cache[0])) { + if (cacheindex < FONT_SIZE_CACHE_SIZE && + targeth == cache[cacheindex].targeth) { *w = cache[cacheindex].w; *h = cache[cacheindex].h; *xmin = cache[cacheindex].xmin; @@ -1775,11 +1813,25 @@ find_best_xft_font_size(Display *display, Screen * screen, char const *fontname, } continue; } +#ifdef DEBUG_FONT_NAME + { + char buffer[1024]; + + if (XftNameUnparse(font->pattern, buffer, (int) sizeof(buffer))) { + printf("Final font for \"%s\" max %dx%d is \"%s\"\n", + fontname, maxw, maxh, buffer); + } else { + printf("Final font for \"%s\" max %dx%d is unknown\n", + fontname, maxw, maxh); + } + } +#endif if (cacheindex == FONT_SIZE_CACHE_SIZE) { for (ii = 0U; ii < FONT_SIZE_CACHE_SIZE; ii++) { if (cache[ii].maxw == 0U || cache[ii].maxh == 0U || cache[ii].max_pixels == 0U) { + CopyFontname(cache[ii].fontname, fontname); cache[ii].maxw = maxw; cache[ii].maxh = maxh; cache[ii].max_pixels = max_pixels; @@ -1793,6 +1845,7 @@ find_best_xft_font_size(Display *display, Screen * screen, char const *fontname, } if (ii == FONT_SIZE_CACHE_SIZE) { ii = targeth % FONT_SIZE_CACHE_SIZE; + CopyFontname(cache[ii].fontname, fontname); cache[ii].maxw = maxw; cache[ii].maxh = maxh; cache[ii].max_pixels = max_pixels; @@ -1891,11 +1944,14 @@ find_best_alphabet_index(RegisGraphicsContext const *context, } } - TRACE(("found alphabet %u at index %u size %ux%u font=%s\n", - context->current_text_controls->alphabet_num, bestmatch, - bestw, besth, - context->alphabets[bestmatch].use_font ? - context->alphabets[bestmatch].fontname : "(none)")); + if (bestmatch < MAX_REGIS_ALPHABETS) { + TRACE(("found alphabet %u at index %u size %ux%u font=%s\n", + context->current_text_controls->alphabet_num, bestmatch, + bestw, besth, + context->alphabets[bestmatch].use_font ? + context->alphabets[bestmatch].fontname : "(none)")); + } + return bestmatch; } @@ -1915,17 +1971,19 @@ get_user_bitmap_of_character(RegisGraphicsContext const *context, assert(context); assert(pixels); - if (!context->alphabets[alphabet_index].loaded[(unsigned) ch]) { + if (!context->alphabets[alphabet_index].loaded[(unsigned char) ch]) { TRACE(("in alphabet %u with alphabet index %u user glyph for '%c' not loaded\n", context->current_text_controls->alphabet_num, alphabet_index, ch)); return 0; } + assert(context->alphabets[alphabet_index].bytes); + w = context->alphabets[alphabet_index].pixw; h = context->alphabets[alphabet_index].pixh; glyph = &context->alphabets[alphabet_index] - .bytes[(unsigned) ch * GLYPH_WIDTH_BYTES(w) * h]; + .bytes[(unsigned char) ch * GLYPH_WIDTH_BYTES(w) * h]; for (yy = 0U; yy < h; yy++) { for (xx = 0U; xx < w; xx++) { @@ -1940,8 +1998,8 @@ get_user_bitmap_of_character(RegisGraphicsContext const *context, /* * alphabets - * 0 built-in - * 1-(MAX_REGIS_ALPHABETS-1) custom (max is 3 on VT3X0) + * 0 built-in + * 1-N custom (max is 3 on VT3X0 -- up to MAX_REGIS_ALPHABETS with xterm) * * built-in 7-bit charsets * (B ASCII @@ -1977,54 +2035,61 @@ get_bitmap_of_character(RegisGraphicsContext const *context, char ch, unsigned maxw, unsigned maxh, unsigned char *pixels, unsigned *w, unsigned *h, unsigned max_pixels) { - char const *fontname; unsigned bestmatch; + char const *fontname = NULL; + + if (context->current_text_controls->alphabet_num == 0) { + fontname = context->builtin_font; + } *w = 0U; *h = 0U; bestmatch = find_best_alphabet_index(context, 1U, 1U, maxw, maxh, max_pixels); - if (bestmatch < MAX_REGIS_ALPHABETS && - get_user_bitmap_of_character(context, ch, bestmatch, pixels)) { - *w = context->alphabets[bestmatch].pixw; - *h = context->alphabets[bestmatch].pixh; - return; - } - - fontname = NULL; if (bestmatch < MAX_REGIS_ALPHABETS) { RegisAlphabet const *alpha = &context->alphabets[bestmatch]; - if (alpha && alpha->use_font) + + if (!alpha->use_font && + get_user_bitmap_of_character(context, ch, bestmatch, pixels)) { + TRACE(("found user glyph for alphabet number %d (index %u)\n\n", + context->current_text_controls->alphabet_num, bestmatch)); + *w = alpha->pixw; + *h = alpha->pixh; + return; + } + + if (alpha->use_font) fontname = alpha->fontname; } - if (!fontname && context->current_text_controls->alphabet_num == 0) { - fontname = ""; - } - if (fontname && get_xft_bitmap_of_character(context, fontname, ch, - maxw, maxh, pixels, - max_pixels, w, h)) { - if (*w > maxw) { - TRACE(("BUG: Xft glyph is too wide: %ux%u but max is %ux%u\n", - *w, *h, maxw, maxh)); - } else if (*h > maxh) { - TRACE(("BUG: Xft glyph is too tall: %ux%u but max is %ux%u\n", - *w, *h, maxw, maxh)); - } else if (*w * *h > max_pixels) { - TRACE(("BUG: Xft glyph has too many pixels: %u but max is %u\n", - *w * *h, max_pixels)); - } else { + if (fontname) { + if (get_xft_bitmap_of_character(context, fontname, ch, + maxw, maxh, pixels, + max_pixels, w, h)) { + if (*w > maxw) { + TRACE(("BUG: Xft glyph is too wide: %ux%u but max is %ux%u\n", + *w, *h, maxw, maxh)); + } else if (*h > maxh) { + TRACE(("BUG: Xft glyph is too tall: %ux%u but max is %ux%u\n", + *w, *h, maxw, maxh)); + } else if (*w * *h > max_pixels) { + TRACE(("BUG: Xft glyph has too many pixels: %u but max is %u\n", + *w * *h, max_pixels)); + } else { + TRACE(("got glyph from \"%s\" for alphabet number %d\n", + fontname, context->current_text_controls->alphabet_num)); #ifdef DEBUG_SPECIFIC_CHAR_METRICS - if (IS_DEBUG_CHAR(ch)) { - printf("got %ux%u Xft bitmap for '%c' target size %ux%u:\n", - *w, *h, - ch, maxw, maxh); - dump_bitmap_pixels(pixels, *w, *h); - printf("\n"); - } + if (IS_DEBUG_CHAR(ch)) { + printf("got %ux%u Xft bitmap for '%c' target size %ux%u:\n", + *w, *h, + ch, maxw, maxh); + dump_bitmap_pixels(pixels, *w, *h); + printf("\n"); + } #endif - return; + return; + } } } @@ -2035,10 +2100,10 @@ get_bitmap_of_character(RegisGraphicsContext const *context, char ch, { unsigned xx, yy; - *w = 8U; - *h = 10U; - for (yy = 0U; yy < 10U; yy++) - for (xx = 0U; xx < 8U; xx++) + *w = MIN2(8U, maxh); + *h = MIN2(10U, maxw); + for (yy = 0U; yy < *h; yy++) + for (xx = 0U; xx < *w; xx++) pixels[yy * *w + xx] = '\0'; } } @@ -2073,11 +2138,11 @@ draw_character(RegisGraphicsContext *context, char ch, int rot_shear_y, int x_sign_x, int x_sign_y, int y_sign_x, int y_sign_y) { + const unsigned xmaxd = context->current_text_controls->character_display_w; + const unsigned ymaxd = context->current_text_controls->character_display_h; + const unsigned xmaxf = context->current_text_controls->character_unit_cell_w; + const unsigned ymaxf = context->current_text_controls->character_unit_cell_h; unsigned w, h; - unsigned xmaxd = context->current_text_controls->character_display_w; - unsigned ymaxd = context->current_text_controls->character_display_h; - unsigned xmaxf = context->current_text_controls->character_unit_cell_w; - unsigned ymaxf = context->current_text_controls->character_unit_cell_h; unsigned xscale, yscale; unsigned fx, fy; unsigned px, py; @@ -2158,6 +2223,25 @@ draw_text(RegisGraphicsContext *context, char const *str) int rx, ry; int ox, oy; +#ifdef DEBUG_ALPHABETS + { + unsigned n; + + for (n = 0U; n < MAX_REGIS_ALPHABETS; n++) { + printf("alphabet index %u\n", n); + if (context->alphabets[n].alphabet_num != INVALID_ALPHABET_NUM) { + printf(" alphabet_num=%u\n", context->alphabets[n].alphabet_num); + printf(" pixw=%d\n", context->alphabets[n].pixw); + printf(" pixh=%d\n", context->alphabets[n].pixh); + printf(" name=\"%s\"\n", context->alphabets[n].name); + printf(" use_font=%d\n", context->alphabets[n].use_font); + printf(" fontname=\"%s\"\n", context->alphabets[n].fontname); + printf(" bytes=%p\n", context->alphabets[n].bytes); + } + } + } +#endif + if (context->current_text_controls->slant <= -75 || context->current_text_controls->slant >= +75) { TRACE(("ERROR: unsupported character slant angle %d\n", @@ -2924,11 +3008,6 @@ regis_num_to_int(RegisDataFragment const *input, int *out) return 1; } -#define MIN2(X, Y) ( (X) < (Y) ? (X) : (Y) ) -#define MIN3(X, Y, Z) ( MIN2(MIN2((X), (Y)), MIN2((Y), (Z))) ) -#define MAX2(X, Y) ( (X) > (Y) ? (X) : (Y) ) -#define MAX3(X, Y, Z) ( MAX2(MAX2((X), (Y)), MAX2((Y), (Z))) ) - static int load_regis_colorspec(RegisGraphicsContext const *context, RegisDataFragment const *input, @@ -3213,8 +3292,45 @@ load_regis_regnum_or_colorspec(RegisGraphicsContext const *context, } static int -load_regis_extent(char const *extent, int origx, int origy, - int *xloc, int *yloc) +to_scaled_int(char const *num, int scale, int *value) +{ + unsigned long whole, frac; + char *end; + + /* FIXME: handle whitespace? how about trailing junk? */ + whole = strtoul(num, &end, 10); + if (end[0] == '.') { + char temp[5] = "0000"; + + if (end[1] != '\0') { + temp[0] = end[1]; + if (end[2] != '\0') { + temp[1] = end[2]; + if (end[3] != '\0') { + temp[2] = end[3]; + if (end[4] != '\0') { + temp[3] = end[4]; + } + } + } + } + frac = strtoul(temp, NULL, 10); + } else if (end[0] == '\0' || end[0] == ',') { + frac = 0; + } else { + TRACE(("unexpected character %c in number %s\n", end[0], num)); + return 0; + } + + *value = (int) (whole * (unsigned) scale + + (frac * (unsigned) scale) / 10000); + + return 1; +} + +static int +load_regis_raw_extent(char const *extent, int *relx, int *rely, + int *xloc, int *yloc, int scale) { int xsign, ysign; char const *xpart; @@ -3247,18 +3363,105 @@ load_regis_extent(char const *extent, int origx, int origy, } if (xpart[0] == '\0' || xpart[0] == ',') { - *xloc = origx; + *relx = 1; + *xloc = 0; } else if (xsign == 0) { - *xloc = atoi(xpart); + int val; + + if (!to_scaled_int(xpart, scale, &val)) + return 0; + *relx = 0; + *xloc = val; } else { - *xloc = origx + xsign * atoi(xpart); + int val; + + if (!to_scaled_int(xpart, scale, &val)) + return 0; + *relx = 1; + *xloc = xsign * val; } if (ypart[0] == '\0') { - *yloc = origy; + *rely = 1; + *yloc = 0; } else if (ysign == 0) { - *yloc = atoi(ypart); + int val; + + if (!to_scaled_int(ypart, scale, &val)) + return 0; + *rely = 0; + *yloc = val; } else { - *yloc = origy + ysign * atoi(ypart); + int val; + + if (!to_scaled_int(ypart, scale, &val)) + return 0; + *rely = 1; + *yloc = ysign * val; + } + + return 1; +} + +static int +load_regis_pixel_extent(char const *extent, int origx, int origy, + int *xloc, int *yloc) +{ + int relx, rely; + int px, py; + + if (!load_regis_raw_extent(extent, &relx, &rely, &px, &py, 1)) { + TRACE(("invalid coordinates in extent %s\n", extent)); + return 0; + } + + *xloc = px; + *yloc = py; + + if (relx) + *xloc += origx; + if (rely) + *yloc += origy; + + return 1; +} + +#define COORD_SCALE 1000 + +static int +load_regis_coord_extent(RegisGraphicsContext const *context, char const *extent, + int origx, int origy, int *xloc, int *yloc) +{ + int relx, rely; + int ux, uy; + + if (!load_regis_raw_extent(extent, &relx, &rely, &ux, &uy, COORD_SCALE)) { + TRACE(("invalid coordinates in extent %s\n", extent)); + return 0; + } + + if (relx) { + const int px = SCALE_XCOORD(context, ux, COORD_SCALE); + TRACE(("converted relative X coord %.03f to relative pixel coord %d (width=%d xoff=%d xdiv=%d)\n", + ux / (double) COORD_SCALE, px, context->width, + context->x_off, context->x_div)); + *xloc = origx + px; + } else { + const int px = TRANSLATE_XCOORD(context, ux, COORD_SCALE); + TRACE(("converted absolute X coord %.03f to absolute pixel coord %d\n", + ux / (double) COORD_SCALE, px)); + *xloc = px; + } + if (rely) { + const int py = SCALE_YCOORD(context, uy, COORD_SCALE); + TRACE(("converted relative Y coord %.03f to relative pixel coord %d (height=%d, yoff=%d, ydiv=%d)\n", + uy / (double) COORD_SCALE, py, context->height, + context->y_off, context->y_div)); + *yloc = origy + py; + } else { + const int py = TRANSLATE_YCOORD(context, uy, COORD_SCALE); + TRACE(("converted absolute Y coord %.03f to absolute pixel coord %d\n", + uy / (double) COORD_SCALE, py)); + *yloc = py; } return 1; @@ -3425,7 +3628,9 @@ load_regis_write_control(RegisParseState *state, char suboption; while (arg->pos < arg->len) { - skip_regis_whitespace(arg); + if (skip_regis_whitespace(arg)) + continue; + TRACE(("looking for option in \"%s\"\n", fragment_to_tempstr(arg))); if (extract_regis_parenthesized_data(arg, &suboptionset)) { @@ -3612,7 +3817,8 @@ load_regis_write_control(RegisParseState *state, int shading_enabled = 0; while (arg->pos < arg->len) { - skip_regis_whitespace(arg); + if (skip_regis_whitespace(arg)) + continue; if (extract_regis_string(arg, state->temp, state->templen)) { TRACE(("found fill char \"%s\"\n", state->temp)); @@ -3670,9 +3876,10 @@ load_regis_write_control(RegisParseState *state, } if (extract_regis_extent(arg, &item)) { - if (!load_regis_extent(fragment_to_tempstr(&item), - ref_x, ref_y, - &ref_x, &ref_y)) { + if (!load_regis_coord_extent(context, + fragment_to_tempstr(&item), + ref_x, ref_y, + &ref_x, &ref_y)) { TRACE(("DATA_ERROR: unable to parse extent in write shading option '%c': \"%s\"\n", option, fragment_to_tempstr(&item))); return 0; @@ -3750,7 +3957,8 @@ load_regis_write_control_set(RegisParseState *state, char option; while (controls->pos < controls->len) { - skip_regis_whitespace(controls); + if (skip_regis_whitespace(controls)) + continue; if (extract_regis_parenthesized_data(controls, &optionset)) { TRACE(("got write control optionset: \"%s\"\n", @@ -3884,14 +4092,23 @@ init_regis_alphabets(RegisGraphicsContext *context) } static void -init_regis_graphics_context(int terminal_id, RegisGraphicsContext *context) +init_regis_graphics_context(int terminal_id, int width, int height, + unsigned max_colors, const char *builtin_font, + RegisGraphicsContext *context) { + context->graphic = NULL; context->terminal_id = terminal_id; + context->width = width; + context->height = height; + context->x_off = 0; + context->y_off = 0; + context->x_div = width - 1; + context->y_div = height - 1; /* * Generate a mask covering all valid color register address bits * (but don't bother past 2**16). */ - context->all_planes = (unsigned) context->graphic->valid_registers; + context->all_planes = max_colors; context->all_planes--; context->all_planes |= 1U; context->all_planes |= context->all_planes >> 1U; @@ -3899,6 +4116,8 @@ init_regis_graphics_context(int terminal_id, RegisGraphicsContext *context) context->all_planes |= context->all_planes >> 4U; context->all_planes |= context->all_planes >> 8U; + context->builtin_font = builtin_font; + init_regis_write_controls(terminal_id, context->all_planes, &context->persistent_write_controls); copy_regis_write_controls(&context->persistent_write_controls, @@ -4251,26 +4470,26 @@ parse_regis_option(RegisParseState *state, RegisGraphicsContext *context) switch (state->curve_mode) { case CURVE_POSITION_CLOSED_CURVE: { - int i; + unsigned i; #ifdef DEBUG_SPLINE_POINTS printf("points: \n"); - for (i = 0; i < (int) state->num_points; i++) + for (i = 0; i < state->num_points; i++) printf(" %d,%d\n", state->x_points[i], state->y_points[i]); #endif #ifdef DEBUG_SPLINE_WITH_ROTATION { - static int shift = 0; + static unsigned shift = 0; int temp_x[MAX_CURVE_POINTS], temp_y[MAX_CURVE_POINTS]; shift++; shift = shift % state->num_points; - for (i = 0; i < (int) state->num_points; i++) { + for (i = 0; i < state->num_points; i++) { temp_x[i] = state->x_points[i]; temp_y[i] = state->y_points[i]; } - for (i = 0; i < (int) state->num_points; i++) { + for (i = 0; i < state->num_points; i++) { state->x_points[i] = temp_x[(i + shift) % state->num_points]; state->y_points[i] = @@ -4279,21 +4498,21 @@ parse_regis_option(RegisParseState *state, RegisGraphicsContext *context) #ifdef DEBUG_SPLINE_POINTS printf("after shift %d: \n", shift); - for (i = 0; i < (int) state->num_points; i++) + for (i = 0; i < state->num_points; i++) printf(" %d,%d\n", state->x_points[i], state->y_points[i]); #endif } #endif - for (i = (int) state->num_points; i > 0; i--) { + for (i = state->num_points; i > 0; i--) { state->x_points[i] = state->x_points[i - 1]; state->y_points[i] = state->y_points[i - 1]; } state->x_points[0] = state->x_points[state->num_points]; state->y_points[0] = state->y_points[state->num_points]; state->num_points++; - for (i = (int) state->num_points; i > 0; i--) { + for (i = state->num_points; i != 0; i--) { state->x_points[i] = state->x_points[i - 1]; state->y_points[i] = state->y_points[i - 1]; } @@ -4313,7 +4532,7 @@ parse_regis_option(RegisParseState *state, RegisGraphicsContext *context) #endif #ifdef DEBUG_SPLINE_POINTS printf("after points added: \n"); - for (i = 0; i < (int) state->num_points; i++) + for (i = 0; i < state->num_points; i++) printf(" %d,%d\n", state->x_points[i], state->y_points[i]); #endif @@ -4525,14 +4744,17 @@ parse_regis_option(RegisParseState *state, RegisGraphicsContext *context) if (skip_regis_whitespace(&optionarg)) continue; + if (extract_regis_extent(&optionarg, &sizearg)) { int w, h; unsigned size; TRACE(("glyph size: %s\n", fragment_to_tempstr(&sizearg))); - if (!load_regis_extent(fragment_to_tempstr(&sizearg), 0, 0, - &w, &h)) { + /* FIXME: verify this is in pixels, not user coordinates */ + if (!load_regis_pixel_extent(fragment_to_tempstr(&sizearg), + 0, 0, + &w, &h)) { TRACE(("DATA_ERROR: unable to parse extent in glyph size option: \"%s\"\n", fragment_to_tempstr(&sizearg))); break; @@ -4886,13 +5108,99 @@ parse_regis_option(RegisParseState *state, RegisGraphicsContext *context) switch (state->option) { case 'A': case 'a': - TRACE(("found address definition \"%s\" FIXME\n", + TRACE(("found address definition \"%s\"\n", fragment_to_tempstr(&optionarg))); - /* FIXME: handle */ - if (!fragment_len(&optionarg)) { - TRACE(("DATA_ERROR: ignoring malformed ReGIS screen address definition option value \"%s\"\n", - fragment_to_tempstr(&optionarg))); - return 1; + { + RegisDataFragment address_extent; + int got_ul = 0; + int got_lr = 0; + int ulx = 0, uly = 0, lrx = 0, lry = 0; + + while (fragment_len(&optionarg)) { + if (skip_regis_whitespace(&optionarg)) + continue; + + if (extract_regis_extent(&optionarg, &address_extent)) { + int x, y; + + /* FIXME: are relative values supposed to be handled? */ + if (!load_regis_pixel_extent(fragment_to_tempstr(&address_extent), + 0, 0, &x, &y)) { + TRACE(("DATA_ERROR: unable to parse extent in address definition: \"%s\"\n", + fragment_to_tempstr(&address_extent))); + break; + } + + if (!got_ul) { + ulx = x; + uly = y; + got_ul = 1; + } else if (!got_lr) { + lrx = x; + lry = y; + got_lr = 1; + } else { + TRACE(("DATA_ERROR: ignoring extra extent argument in address definition: \"%s\"\n", + fragment_to_tempstr(&address_extent))); + } + continue; + } + + TRACE(("DATA_ERROR: ignoring malformed ReGIS screen address definition: expected extent argument but found: \"%s\"\n", + fragment_to_tempstr(&optionarg))); + return 1; + } + + if (!got_ul || !got_lr) { + TRACE(("DATA_ERROR: ignoring malformed ReGIS screen address definition: one or both locations missing in definition\n")); + return 1; + } + if (ulx == lrx || uly == lry) { + TRACE(("DATA_ERROR: ignoring malformed ReGIS screen address definition: one or both dimensions are zero: ul=%d,%d lr=%d,%d\n", + ulx, uly, lrx, lry)); + return 1; + } { + const int cw = abs(ulx - lrx) + 1; + const int ch = abs(uly - lry) + 1; + int scale; + int width, height; + + width = cw; + height = ch; + + scale = 1; + while (width * scale < 200 || + height * scale < 200) { + scale++; + } + width *= scale; + height *= scale; + + scale = 1; + while (width / scale > context->graphic->max_width || + height / scale > context->graphic->max_height) { + scale++; + } + width /= scale; + height /= scale; + + TRACE(("custom screen address: ul=%d,%d lr=%d,%d\n", + ulx, uly, lrx, lry)); + + context->x_off = ulx; + context->y_off = uly; + context->x_div = lrx - ulx; + context->y_div = lry - uly; + context->width = width; + context->height = height; + context->graphic->actual_width = width; + context->graphic->actual_height = height; + + TRACE(("conversion factors: off=%+d,%+d div=%+d,%+d width=%d, height=%d\n", + context->x_off, context->y_off, + context->x_div, context->y_div, + context->width, context->height)); + } } break; case 'C': @@ -4915,10 +5223,7 @@ parse_regis_option(RegisParseState *state, RegisGraphicsContext *context) fragment_to_tempstr(&optionarg))); return 1; } - draw_solid_rectangle(context->graphic, 0, 0, - context->graphic->actual_width, - context->graphic->actual_height, - context->background); + DRAW_ALL(context, context->background); break; case 'F': case 'f': @@ -4930,10 +5235,7 @@ parse_regis_option(RegisParseState *state, RegisGraphicsContext *context) return 1; } /* We aren't going to print anything so no need to deduplicate. */ - draw_solid_rectangle(context->graphic, 0, 0, - context->graphic->actual_width, - context->graphic->actual_height, - context->background); + DRAW_ALL(context, context->background); break; case 'H': case 'h': @@ -4968,6 +5270,7 @@ parse_regis_option(RegisParseState *state, RegisGraphicsContext *context) while (fragment_len(&optionarg)) { if (skip_regis_whitespace(&optionarg)) continue; + if (extract_regis_num(&optionarg, ®num)) { int register_num; int color_only; @@ -5304,8 +5607,9 @@ parse_regis_option(RegisParseState *state, RegisGraphicsContext *context) } TRACE(("size multiplier: %s\n", fragment_to_tempstr(&sizemultiplierarg))); - if (!load_regis_extent(fragment_to_tempstr(&sizemultiplierarg), - 0, 0, &ww, &hh)) { + /* FIXME: verify this is in pixels, not user coordinates */ + if (!load_regis_pixel_extent(fragment_to_tempstr(&sizemultiplierarg), + 0, 0, &ww, &hh)) { TRACE(("DATA_ERROR: unable to parse extent in '%c' command: \"%s\"\n", state->option, fragment_to_tempstr(&sizemultiplierarg))); break; @@ -5354,8 +5658,9 @@ parse_regis_option(RegisParseState *state, RegisGraphicsContext *context) TRACE(("custom display size: %s\n", fragment_to_tempstr(&displaysizearg))); - if (!load_regis_extent(fragment_to_tempstr(&displaysizearg), - 0, 0, &disp_w, &disp_h)) { + /* FIXME: verify this is in pixels, not user coordinates */ + if (!load_regis_pixel_extent(fragment_to_tempstr(&displaysizearg), + 0, 0, &disp_w, &disp_h)) { TRACE(("DATA_ERROR: unable to parse extent in text display size option: \"%s\"\n", fragment_to_tempstr(&displaysizearg))); break; @@ -5453,8 +5758,10 @@ parse_regis_option(RegisParseState *state, RegisGraphicsContext *context) } TRACE(("unitsize cell size: %s\n", fragment_to_tempstr(&unitsizearg))); - if (!load_regis_extent(fragment_to_tempstr(&unitsizearg), 0, 0, - &unit_w, &unit_h)) { + /* FIXME: verify this is in pixels, not user coordinates */ + if (!load_regis_pixel_extent(fragment_to_tempstr(&unitsizearg), + 0, 0, + &unit_w, &unit_h)) { TRACE(("DATA_ERROR: unable to parse extent in '%c' command: \"%s\"\n", state->option, fragment_to_tempstr(&unitsizearg))); break; @@ -5648,9 +5955,10 @@ parse_regis_items(RegisParseState *state, RegisGraphicsContext *context) orig_x = context->graphics_output_cursor_x; orig_y = context->graphics_output_cursor_y; } - if (!load_regis_extent(fragment_to_tempstr(&item), - orig_x, orig_y, - &new_x, &new_y)) { + if (!load_regis_coord_extent(context, + fragment_to_tempstr(&item), + orig_x, orig_y, + &new_x, &new_y)) { TRACE(("DATA_ERROR: unable to parse extent in '%c' command: \"%s\"\n", state->command, fragment_to_tempstr(&item))); break; @@ -5695,32 +6003,27 @@ parse_regis_items(RegisParseState *state, RegisGraphicsContext *context) &e_x_final, &e_y_final); #ifdef DEBUG_ARC_CENTER - draw_solid_pixel(context->graphic, c_x + 1, c_y, 3U); - draw_solid_pixel(context->graphic, c_x - 1, c_y, 3U); - draw_solid_pixel(context->graphic, c_x, c_y + 1, 3U); - draw_solid_pixel(context->graphic, c_x, c_y - 1, 3U); - draw_solid_pixel(context->graphic, c_x, c_y, 3U); + DRAW_PIXEL(context, c_x + 1, c_y, 3U); + DRAW_PIXEL(context, c_x - 1, c_y, 3U); + DRAW_PIXEL(context, c_x, c_y + 1, 3U); + DRAW_PIXEL(context, c_x, c_y - 1, 3U); + DRAW_PIXEL(context, c_x, c_y, 3U); #endif #ifdef DEBUG_ARC_START - draw_solid_pixel(context->graphic, e_x + 1, e_y, 2U); - draw_solid_pixel(context->graphic, e_x - 1, e_y, 2U); - draw_solid_pixel(context->graphic, e_x, e_y + 1, 2U); - draw_solid_pixel(context->graphic, e_x, e_y - 1, 2U); - draw_solid_pixel(context->graphic, e_x, e_y, 2U); + DRAW_PIXEL(context, e_x + 1, e_y, 2U); + DRAW_PIXEL(context, e_x - 1, e_y, 2U); + DRAW_PIXEL(context, e_x, e_y + 1, 2U); + DRAW_PIXEL(context, e_x, e_y - 1, 2U); + DRAW_PIXEL(context, e_x, e_y, 2U); #endif #ifdef DEBUG_ARC_END - draw_solid_pixel(context->graphic, e_x_final + 1, - e_y_final + 1, 1U); - draw_solid_pixel(context->graphic, e_x_final + 1, - e_y_final - 1, 1U); - draw_solid_pixel(context->graphic, e_x_final - 1, - e_y_final + 1, 1U); - draw_solid_pixel(context->graphic, e_x_final - 1, - e_y_final - 1, 1U); - draw_solid_pixel(context->graphic, e_x_final, - e_y_final, 1U); + DRAW_PIXEL(context, e_x_final + 1, e_y_final + 1, 1U); + DRAW_PIXEL(context, e_x_final + 1, e_y_final - 1, 1U); + DRAW_PIXEL(context, e_x_final - 1, e_y_final + 1, 1U); + DRAW_PIXEL(context, e_x_final - 1, e_y_final - 1, 1U); + DRAW_PIXEL(context, e_x_final, e_y_final, 1U); #endif if (state->curve_mode == CURVE_POSITION_ARC_CENTER) { @@ -5759,11 +6062,12 @@ parse_regis_items(RegisParseState *state, RegisGraphicsContext *context) break; case 'p': /* FIXME TRACE(("DATA_ERROR: ignoring pen command with no location\n")); */ - if (!load_regis_extent(fragment_to_tempstr(&item), - context->graphics_output_cursor_x, - context->graphics_output_cursor_y, - &context->graphics_output_cursor_x, - &context->graphics_output_cursor_y)) { + if (!load_regis_coord_extent(context, + fragment_to_tempstr(&item), + context->graphics_output_cursor_x, + context->graphics_output_cursor_y, + &context->graphics_output_cursor_x, + &context->graphics_output_cursor_y)) { TRACE(("DATA_ERROR: unable to parse extent in '%c' command: \"%s\"\n", state->command, fragment_to_tempstr(&item))); break; @@ -5778,32 +6082,37 @@ parse_regis_items(RegisParseState *state, RegisGraphicsContext *context) int new_x, new_y; int copy_w, copy_h; - if (!load_regis_extent(fragment_to_tempstr(&item), - 0, 0, &new_x, &new_y)) { + if (!load_regis_coord_extent(context, + fragment_to_tempstr(&item), + 0, 0, &new_x, &new_y)) { TRACE(("DATA_ERROR: unable to parse extent in '%c' command: \"%s\"\n", state->command, fragment_to_tempstr(&item))); break; } - TRACE(("scrolling image to location %d,%d\n", new_x, new_y)); - /* FIXME: does any write mode (like mode) affect background? */ + TRACE(("scrolling image to coordinates %d,%d\n", new_x, new_y)); + new_x -= context->x_off; + new_y -= context->y_off; + TRACE(("scrolling image to buffer location %d,%d\n", new_x, new_y)); + /* FIXME: does any write mode affect background? */ if (new_y < 0) - copy_h = context->graphic->actual_height - new_y; + copy_h = context->height - new_y; else - copy_h = context->graphic->actual_height; + copy_h = context->height; if (new_x < 0) - copy_w = context->graphic->actual_width - new_x; + copy_w = context->width - new_x; else - copy_w = context->graphic->actual_width; + copy_w = context->width; copy_overlapping_area(context->graphic, 0, 0, new_x, new_y, (unsigned) copy_w, (unsigned) copy_h, context->background); } break; case 't': - if (!load_regis_extent(fragment_to_tempstr(&item), - 0, 0, - &context->current_text_controls->character_inc_x, - &context->current_text_controls->character_inc_y)) { + /* FIXME: verify this is in pixels, not user coordinates */ + if (!load_regis_pixel_extent(fragment_to_tempstr(&item), + 0, 0, + &context->current_text_controls->character_inc_x, + &context->current_text_controls->character_inc_y)) { TRACE(("DATA_ERROR: unable to parse extent in '%c' command: \"%s\"\n", state->command, fragment_to_tempstr(&item))); break; @@ -5818,10 +6127,11 @@ parse_regis_items(RegisParseState *state, RegisGraphicsContext *context) orig_x = context->graphics_output_cursor_x; orig_y = context->graphics_output_cursor_y; - if (!load_regis_extent(fragment_to_tempstr(&item), - orig_x, orig_y, - &context->graphics_output_cursor_x, - &context->graphics_output_cursor_y)) { + if (!load_regis_coord_extent(context, + fragment_to_tempstr(&item), + orig_x, orig_y, + &context->graphics_output_cursor_x, + &context->graphics_output_cursor_y)) { TRACE(("DATA_ERROR: unable to parse extent in '%c' command: \"%s\"\n", state->command, fragment_to_tempstr(&item))); break; @@ -5880,16 +6190,19 @@ parse_regis_items(RegisParseState *state, RegisGraphicsContext *context) state->command, fragment_to_tempstr(&item))); break; } - TRACE(("scrolling image to location %d,%d\n", new_x, new_y)); - /* FIXME: does any write mode (like mode) affect background? */ + TRACE(("scrolling image to coordinates %d,%d\n", new_x, new_y)); + new_x -= context->x_off; + new_y -= context->y_off; + TRACE(("scrolling image to buffer location %d,%d\n", new_x, new_y)); + /* FIXME: does any write mode affect background? */ if (new_y < 0) - copy_h = context->graphic->actual_height - new_y; + copy_h = context->height - new_y; else - copy_h = context->graphic->actual_height; + copy_h = context->height; if (new_x < 0) - copy_w = context->graphic->actual_width - new_x; + copy_w = context->width - new_x; else - copy_w = context->graphic->actual_width; + copy_w = context->width; copy_overlapping_area(context->graphic, 0, 0, new_x, new_y, (unsigned) copy_w, (unsigned) copy_h, context->background); @@ -6215,7 +6528,7 @@ void parse_regis(XtermWidget xw, ANSI *params, char const *string) { TScreen *screen = TScreenOf(xw); - RegisGraphicsContext context; + RegisGraphicsContext *const context = &persistent_context; RegisParseState state; struct timeval prev_tv; struct timeval curr_tv; @@ -6223,9 +6536,15 @@ parse_regis(XtermWidget xw, ANSI *params, char const *string) int charrow = 0; int charcol = 0; unsigned type = 1; /* FIXME: use page number */ + int Pmode; - (void) params; /* ..only used here in a trace */ - TRACE(("ReGIS vector graphics mode, params=%d\n", params->a_nparam)); + if (params->a_nparam > 0) + Pmode = params->a_param[0]; + else + Pmode = 0; + + TRACE(("ReGIS vector graphics mode, param_count=%d mode=%d\n", + params->a_nparam, Pmode)); init_fragment(&state.input, string); state.templen = (unsigned) strlen(string) + 1U; @@ -6239,26 +6558,30 @@ parse_regis(XtermWidget xw, ANSI *params, char const *string) state.stack_next = 0U; state.load_index = MAX_REGIS_ALPHABETS; - memset(&context, 0, sizeof(context)); - /* Update the screen scrolling and do a refresh. * The refresh may not cover the whole graphic. */ if (screen->scroll_amt) FlushScroll(xw); - context.graphic = get_new_or_matching_graphic(xw, - charrow, charcol, - screen->regis_max_wide, - screen->regis_max_high, - type); - /* - * FIXME: Don't initialize parameters for continued command mode, - * or when reusing the same graphic. - */ - init_regis_graphics_context(screen->terminal_id, &context); - context.graphic->valid = 1; - context.graphic->dirty = 1; + /* Only reset on the first ReGIS image unless it is being requested. */ + if (context->width == 0 || context->height == 0 || + Pmode == 1 || Pmode == 3) { + init_regis_graphics_context(screen->terminal_id, + screen->graphics_regis_def_wide, + screen->graphics_regis_def_high, + get_color_register_count(screen), + screen->graphics_regis_default_font, + context); + } + + context->graphic = get_new_or_matching_graphic(xw, + charrow, charcol, + context->width, + context->height, + type); + context->graphic->valid = 1; + context->graphic->dirty = 1; X_GETTIMEOFDAY(&prev_tv); iterations = 0U; @@ -6268,7 +6591,7 @@ parse_regis(XtermWidget xw, ANSI *params, char const *string) if (skip_regis_whitespace(&state.input)) continue; iterations++; - if (parse_regis_toplevel(&state, &context)) { + if (parse_regis_toplevel(&state, context)) { if (iterations > MIN_ITERATIONS_BEFORE_REFRESH) { int need_refresh = 0; diff --git a/app/xterm/graphics_sixel.c b/app/xterm/graphics_sixel.c index 81c9f30e7..1b59ba680 100644 --- a/app/xterm/graphics_sixel.c +++ b/app/xterm/graphics_sixel.c @@ -1,4 +1,4 @@ -/* $XTermId: graphics_sixel.c,v 1.10 2014/10/06 09:28:00 Ross.Combs Exp $ */ +/* $XTermId: graphics_sixel.c,v 1.11 2014/12/12 09:47:29 Ross.Combs Exp $ */ /* * Copyright 2014 by Ross Combs @@ -122,6 +122,7 @@ typedef struct { static void init_sixel_background(Graphic *graphic, SixelContext const *context) { + const int mw = graphic->max_width; int r, c; TRACE(("initializing sixel background to size=%dx%d bgcolor=%hu\n", @@ -134,7 +135,7 @@ init_sixel_background(Graphic *graphic, SixelContext const *context) for (r = 0; r < graphic->actual_height; r++) { for (c = 0; c < graphic->actual_width; c++) { - graphic->pixels[r * graphic->max_width + c] = context->background; + graphic->pixels[r * mw + c] = context->background; } } graphic->color_registers_used[context->background] = 1; @@ -143,6 +144,8 @@ init_sixel_background(Graphic *graphic, SixelContext const *context) static void set_sixel(Graphic *graphic, SixelContext const *context, int sixel) { + const int mh = graphic->max_height; + const int mw = graphic->max_width; RegisterNum color; int pix; @@ -159,8 +162,7 @@ set_sixel(Graphic *graphic, SixelContext const *context, int sixel) ((color != COLOR_HOLE) ? (unsigned) graphic->color_registers[color].b : 0U))); for (pix = 0; pix < 6; pix++) { - if (context->col < graphic->max_width && - context->row + pix < graphic->max_height) { + if (context->col < mw && context->row + pix < mh) { if (sixel & (1 << pix)) { if (context->col + 1 > graphic->actual_width) { graphic->actual_width = context->col + 1; @@ -168,10 +170,8 @@ set_sixel(Graphic *graphic, SixelContext const *context, int sixel) if (context->row + pix + 1 > graphic->actual_height) { graphic->actual_height = context->row + pix + 1; } - graphic->pixels[ - (((context->row + pix) * graphic->max_width) - + context->col) - ] = color; + graphic->pixels[((context->row + pix) * mw) + context->col] = + color; } } else { TRACE(("sixel pixel %d out of bounds\n", pix)); @@ -290,7 +290,7 @@ parse_sixel(XtermWidget xw, ANSI *params, char const *string) context.aspect_vertical = Pan; context.aspect_horizontal = Pad; - if (Ph == 0 || Pv == 0) { + if (Ph <= 0 || Pv <= 0) { TRACE(("DATA_ERROR: raster image dimensions are invalid %dx%d\n", Ph, Pv)); return; @@ -540,7 +540,7 @@ parse_sixel(XtermWidget xw, ANSI *params, char const *string) int Pv = raster_params.a_param[3]; TRACE(("sixel raster attribute with h=%d v=%d\n", Ph, Pv)); - if (Ph == 0 || Pv == 0) { + if (Ph <= 0 || Pv <= 0) { TRACE(("DATA_ERROR: raster image dimensions are invalid %dx%d\n", Ph, Pv)); return; diff --git a/app/xterm/main.c b/app/xterm/main.c index e5a4f2919..5f0e7d3e0 100644 --- a/app/xterm/main.c +++ b/app/xterm/main.c @@ -1,4 +1,4 @@ -/* $XTermId: main.c,v 1.762 2014/07/24 22:47:09 tom Exp $ */ +/* $XTermId: main.c,v 1.767 2014/12/29 00:17:32 tom Exp $ */ /* * Copyright 2002-2013,2014 by Thomas E. Dickey @@ -779,7 +779,8 @@ static char etc_wtmp[] = WTMP_FILENAME; static char bin_login[] = LOGIN_FILENAME; #endif -static char passedPty[PTYCHARLEN + 1]; /* name if pty if slave */ +static char noPassedPty[2]; +static char *passedPty = noPassedPty; /* name if pty if slave */ #if defined(TIOCCONS) || defined(SRIOCSREDIR) static int Console; @@ -960,6 +961,10 @@ static XrmOptionDescRec optionDescList[] = { {"-fd", "*faceNameDoublesize", XrmoptionSepArg, (XPointer) NULL}, {"-fs", "*faceSize", XrmoptionSepArg, (XPointer) NULL}, #endif +#if OPT_WIDE_ATTRS && OPT_ISO_COLORS +{"-itc", "*colorITMode", XrmoptionNoArg, (XPointer) "off"}, +{"+itc", "*colorITMode", XrmoptionNoArg, (XPointer) "on"}, +#endif #if OPT_WIDE_CHARS {"-fw", "*wideFont", XrmoptionSepArg, (XPointer) NULL}, {"-fwb", "*wideBoldFont", XrmoptionSepArg, (XPointer) NULL}, @@ -1252,6 +1257,9 @@ static OptionHelp xtermOptions[] = { #endif { "-/+vb", "turn on/off visual bell" }, { "-/+pob", "turn on/off pop on bell" }, +#if OPT_WIDE_ATTRS && OPT_ISO_COLORS +{ "-/+itc", "turn off/on display of italic as color"}, +#endif #if OPT_WIDE_CHARS { "-/+wc", "turn on/off wide-character mode" }, { "-/+mk_width", "turn on/off simple width convention" }, @@ -1760,6 +1768,7 @@ ParseSccn(char *option) char *leaf = x_basename(option); Bool code = False; + passedPty = x_strdup(option); if (leaf != option) { if (leaf - option > 0 && isdigit(CharOf(*leaf)) @@ -1771,13 +1780,13 @@ ParseSccn(char *option) * the /dev/pts/XXX value, but since we do not need to reopen it, * it is useful mainly for display in a "ps -ef". */ - strncpy(passedPty, option, len); passedPty[len] = 0; code = True; } } else { code = (sscanf(option, "%c%c%d", passedPty, passedPty + 1, &am_slave) == 3); + passedPty[2] = '\0'; } TRACE(("ParseSccn(%s) = '%s' %d (%s)\n", option, passedPty, am_slave, code ? "OK" : "ERR")); @@ -4691,9 +4700,13 @@ spawnXTerm(XtermWidget xw) signal(SIGHUP, SIG_DFL); #endif - shname_minus = CastMallocN(char, strlen(shname) + 2); - (void) strcpy(shname_minus, "-"); - (void) strcat(shname_minus, shname); + if ((shname_minus = CastMallocN(char, strlen(shname) + 2)) != 0) { + (void) strcpy(shname_minus, "-"); + (void) strcat(shname_minus, shname); + } else { + static char default_minus[] = "-sh"; + shname_minus = default_minus; + } #ifndef TERMIO_STRUCT ldisc = (!XStrCmp("csh", shname + strlen(shname) - 3) ? NTTYDISC diff --git a/app/xterm/misc.c b/app/xterm/misc.c index 38705c14b..50f570e0c 100644 --- a/app/xterm/misc.c +++ b/app/xterm/misc.c @@ -1,4 +1,4 @@ -/* $XTermId: misc.c,v 1.715 2014/10/29 00:54:25 tom Exp $ */ +/* $XTermId: misc.c,v 1.719 2014/12/28 22:17:58 tom Exp $ */ /* * Copyright 1999-2013,2014 by Thomas E. Dickey @@ -2916,6 +2916,12 @@ ManipulateSelectionData(XtermWidget xw, TScreen *screen, char *buf, int final) XtLastTimestampProcessed(TScreenOf(xw)->display), select_args, n, NULL); + /* + * select_args is used via SelectionReceived, cannot + * free it here. + */ + } else { + free(select_args); } } else { if (AllowWindowOps(xw, ewSetSelection)) { @@ -2925,8 +2931,8 @@ ManipulateSelectionData(XtermWidget xw, TScreen *screen, char *buf, int final) AppendToSelectionBuffer(screen, CharOf(*buf++)); CompleteSelection(xw, select_args, n); } + free(select_args); } - free(select_args); } free(used); } @@ -3602,6 +3608,57 @@ do_osc(XtermWidget xw, Char *oscbuf, size_t len, int final) if (ChangeAnsiColorRequest(xw, buf, ansi_colors, final)) xw->misc.palette_changed = True; break; + case 6: + TRACE(("parse colorXXMode:%s\n", buf)); + while (*buf != '\0') { + long which = 0; + long value = 0; + char *next; + if (*buf == ';') { + ++buf; + } else { + which = strtol(buf, &next, 10); + if (next == 0) + break; + buf = next; + if (*buf == ';') + ++buf; + } + if (*buf == ';') { + ++buf; + } else { + value = strtol(buf, &next, 10); + if (next == 0) + break; + buf = next; + if (*buf == ';') + ++buf; + } + TRACE(("updating colorXXMode which=%ld, value=%ld\n", which, value)); + switch (which) { + case 0: + screen->colorBDMode = (value != 0); + break; + case 1: + screen->colorULMode = (value != 0); + break; + case 2: + screen->colorBLMode = (value != 0); + break; + case 3: + screen->colorRVMode = (value != 0); + break; +#if OPT_WIDE_ATTRS + case 4: + screen->colorITMode = (value != 0); + break; +#endif + default: + TRACE(("...unknown colorXXMode\n")); + break; + } + } + break; case OSC_Reset(5): ansi_colors = NUM_ANSI_COLORS; /* FALLTHRU */ @@ -3752,6 +3809,9 @@ parse_decudk(XtermWidget xw, const char *cp) int lo, hi; int len = 0; + if (str == NULL) + break; + while (isdigit(CharOf(*cp))) key = (key * 10) + (unsigned) (*cp++ - '0'); if (*cp == '/') { diff --git a/app/xterm/package/debian/changelog b/app/xterm/package/debian/changelog index e4e5ea0f1..9d9552568 100644 --- a/app/xterm/package/debian/changelog +++ b/app/xterm/package/debian/changelog @@ -1,3 +1,9 @@ +xterm-dev (314) unstable; urgency=low + + * maintenance updates + + -- Thomas E. Dickey <dickey@invisible-island.net> Mon, 01 Dec 2014 04:54:46 -0500 + xterm-dev (313) unstable; urgency=low * maintenance updates diff --git a/app/xterm/package/freebsd/Makefile b/app/xterm/package/freebsd/Makefile index 68404de1c..ce37b0d78 100644 --- a/app/xterm/package/freebsd/Makefile +++ b/app/xterm/package/freebsd/Makefile @@ -5,7 +5,7 @@ # and "make makesum". PORTNAME= xterm -PORTVERSION= 313 +PORTVERSION= 314 CATEGORIES= x11 MASTER_SITES= ftp://invisible-island.net/xterm/ \ CRITICAL diff --git a/app/xterm/package/xterm.spec b/app/xterm/package/xterm.spec index beb0c7017..84e5695b3 100644 --- a/app/xterm/package/xterm.spec +++ b/app/xterm/package/xterm.spec @@ -1,11 +1,11 @@ -# $XTermId: xterm.spec,v 1.78 2014/10/06 09:26:38 tom Exp $ +# $XTermId: xterm.spec,v 1.79 2014/12/01 09:54:46 tom Exp $ Summary: X terminal emulator (development version) %global my_middle xterm %global my_suffix -dev %global fullname %{my_middle}%{my_suffix} %global my_class XTermDev Name: %{fullname} -Version: 313 +Version: 314 Release: 1 License: X11 Group: User Interface/X diff --git a/app/xterm/ptyx.h b/app/xterm/ptyx.h index 002c74c2a..edb223e0d 100644 --- a/app/xterm/ptyx.h +++ b/app/xterm/ptyx.h @@ -1,4 +1,4 @@ -/* $XTermId: ptyx.h,v 1.816 2014/11/28 19:31:59 tom Exp $ */ +/* $XTermId: ptyx.h,v 1.821 2014/12/28 21:50:14 tom Exp $ */ /* * Copyright 1999-2013,2014 by Thomas E. Dickey @@ -1229,11 +1229,20 @@ typedef enum { #define COLOR_UL (NUM_ANSI_COLORS+1) /* UNDERLINE */ #define COLOR_BL (NUM_ANSI_COLORS+2) /* BLINK */ #define COLOR_RV (NUM_ANSI_COLORS+3) /* REVERSE */ + +#if OPT_WIDE_ATTRS +#define COLOR_IT (NUM_ANSI_COLORS+4) /* ITALIC */ +#define MAXCOLORS (NUM_ANSI_COLORS+5) +#else #define MAXCOLORS (NUM_ANSI_COLORS+4) +#endif + #ifndef DFT_COLORMODE #define DFT_COLORMODE True /* default colorMode resource */ #endif +#define UseItalicFont(screen) (!(screen)->colorITMode) + #define ReverseOrHilite(screen,flags,hilite) \ (( screen->colorRVMode && hilite ) || \ ( !screen->colorRVMode && \ @@ -1250,6 +1259,7 @@ typedef enum { #define TERM_COLOR_FLAGS(xw) 0 +#define UseItalicFont(screen) True #define ReverseOrHilite(screen,flags,hilite) \ (( (flags & INVERSE) && !hilite) || \ (!(flags & INVERSE) && hilite)) @@ -1912,6 +1922,9 @@ typedef struct { Boolean colorBLMode; /* use color for blink? */ Boolean colorRVMode; /* use color for reverse? */ Boolean colorAttrMode; /* prefer colorUL/BD to SGR */ +#if OPT_WIDE_ATTRS + Boolean colorITMode; /* use color for italics? */ +#endif #endif #if OPT_DEC_CHRSET Boolean font_doublesize;/* enable font-scaling */ @@ -2010,6 +2023,7 @@ typedef struct { Boolean allowTitleOps; /* TitleOps mode */ Boolean allowWindowOps; /* WindowOps mode */ + Boolean allowPasteControl0; /* PasteControls mode */ Boolean allowColorOp0; /* initial ColorOps mode */ Boolean allowFontOp0; /* initial FontOps mode */ Boolean allowSendEvent0;/* initial SendEvent mode */ @@ -2228,10 +2242,18 @@ typedef struct { unsigned restore_height; #endif -#if OPT_SIXEL_GRAPHICS - String regis_screensize; /* ReGIS given screensize */ - Dimension regis_max_high; /* ...corresponding height */ - Dimension regis_max_wide; /* ...and width */ +#if OPT_REGIS_GRAPHICS + String graphics_regis_default_font; /* font for "builtin" */ + + String graphics_regis_screensize; /* given a size in pixels */ + Dimension graphics_regis_def_wide; /* ...corresponding width */ + Dimension graphics_regis_def_high; /* ...and height */ +#endif + +#if OPT_GRAPHICS + String graphics_max_size; /* given a size in pixels */ + Dimension graphics_max_wide; /* ...corresponding width */ + Dimension graphics_max_high; /* ...and height */ #endif #if OPT_SCROLL_LOCK diff --git a/app/xterm/resize.c b/app/xterm/resize.c index 01d69b036..9fdf4bea4 100644 --- a/app/xterm/resize.c +++ b/app/xterm/resize.c @@ -1,4 +1,4 @@ -/* $XTermId: resize.c,v 1.132 2014/07/24 22:47:09 tom Exp $ */ +/* $XTermId: resize.c,v 1.133 2014/12/28 22:50:41 tom Exp $ */ /* * Copyright 2003-2013,2014 by Thomas E. Dickey @@ -554,8 +554,8 @@ main(int argc, char **argv ENVP_ARG) i = (int) (ptr - termcap) + 3; strncpy(newtc, termcap, (size_t) i); sprintf(newtc + i, "%d", cols); - ptr = strchr(ptr, ':'); - strcat(newtc, ptr); + if ((ptr = strchr(ptr, ':')) != 0) + strcat(newtc, ptr); /* now do lines */ if ((ptr = x_strindex(newtc, "li#")) == NULL) { @@ -566,8 +566,8 @@ main(int argc, char **argv ENVP_ARG) i = (int) (ptr - newtc) + 3; strncpy(termcap, newtc, (size_t) i); sprintf(termcap + i, "%d", rows); - ptr = strchr(ptr, ':'); - strcat(termcap, ptr); + if ((ptr = strchr(ptr, ':')) != 0) + strcat(termcap, ptr); } #endif /* USE_TERMCAP */ diff --git a/app/xterm/trace.c b/app/xterm/trace.c index 4fedd38d9..77f84b6d3 100644 --- a/app/xterm/trace.c +++ b/app/xterm/trace.c @@ -1,4 +1,4 @@ -/* $XTermId: trace.c,v 1.156 2014/11/13 01:03:02 tom Exp $ */ +/* $XTermId: trace.c,v 1.157 2014/12/25 22:01:07 tom Exp $ */ /* * Copyright 1997-2013,2014 by Thomas E. Dickey @@ -306,7 +306,7 @@ visibleChars(const Char *buf, unsigned len) result = 0; used = 0; } - return result; + return NonNull(result); } char * @@ -342,7 +342,7 @@ visibleIChars(const IChar *buf, unsigned len) result = 0; used = 0; } - return result; + return NonNull(result); } char * diff --git a/app/xterm/util.c b/app/xterm/util.c index f678e498f..a09f53728 100644 --- a/app/xterm/util.c +++ b/app/xterm/util.c @@ -1,4 +1,4 @@ -/* $XTermId: util.c,v 1.665 2014/11/13 00:54:35 tom Exp $ */ +/* $XTermId: util.c,v 1.668 2014/12/18 09:27:49 tom Exp $ */ /* * Copyright 1999-2013,2014 by Thomas E. Dickey @@ -2735,6 +2735,9 @@ getWideXftFont(XtermWidget xw, #if OPT_WIDE_ATTRS if ((attr_flags & ATR_ITALIC) +#if OPT_ISO_COLORS + && !screen->colorITMode +#endif && XFT_FONT(renderWideItal[fontnum])) { wfont = XFT_FONT(renderWideItal[fontnum]); } else @@ -2769,6 +2772,9 @@ getNormXftFont(XtermWidget xw, #if OPT_WIDE_ATTRS if ((attr_flags & ATR_ITALIC) +#if OPT_ISO_COLORS + && !screen->colorITMode +#endif && XFT_FONT(renderFontItal[fontnum])) { font = XFT_FONT(renderFontItal[fontnum]); } else diff --git a/app/xterm/version.h b/app/xterm/version.h index c80679f58..a83b4d03c 100644 --- a/app/xterm/version.h +++ b/app/xterm/version.h @@ -1,4 +1,4 @@ -/* $XTermId: version.h,v 1.401 2014/11/29 02:25:05 tom Exp $ */ +/* $XTermId: version.h,v 1.403 2014/12/29 00:54:37 tom Exp $ */ /* * Copyright 1998-2013,2014 by Thomas E. Dickey @@ -38,8 +38,8 @@ * version of X to which this version of xterm has been built. The resulting * number in parentheses is my patch number (Thomas E. Dickey). */ -#define XTERM_PATCH 313 -#define XTERM_DATE 2014-11-28 +#define XTERM_PATCH 314 +#define XTERM_DATE 2014-12-28 #ifndef __vendorversion__ #define __vendorversion__ "XTerm/OpenBSD" diff --git a/app/xterm/vttests/paste64.pl b/app/xterm/vttests/paste64.pl index 152bcff21..6eeeeedc0 100644 --- a/app/xterm/vttests/paste64.pl +++ b/app/xterm/vttests/paste64.pl @@ -1,12 +1,12 @@ #!/usr/bin/env perl -# $XTermId: paste64.pl,v 1.11 2014/02/26 20:14:32 tom Exp $ +# $XTermId: paste64.pl,v 1.13 2014/12/28 21:16:36 tom Exp $ # ----------------------------------------------------------------------------- # this file is part of xterm # # Copyright 2006,2014 by Thomas E. Dickey -# +# # All Rights Reserved -# +# # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including @@ -14,10 +14,10 @@ # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: -# +# # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. -# +# # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. @@ -25,7 +25,7 @@ # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# +# # Except as contained in this notice, the name(s) of the above copyright # holders shall not be used in advertising or otherwise to promote the # sale, use or other dealings in this Software without prior written @@ -36,7 +36,6 @@ use strict; use warnings; - use Term::ReadKey; use IO::Handle; use MIME::Base64; @@ -44,130 +43,148 @@ use MIME::Base64; our $target = ""; sub to_hex($) { - my $value = $_[0]; - my $result = ""; - my $n; - - for ( $n = 0; $n < length($value); ++$n) { - $result .= sprintf("%02X", ord substr($value,$n,1)); - } - return $result; + my $value = $_[0]; + my $result = ""; + my $n; + + for ( $n = 0 ; $n < length($value) ; ++$n ) { + $result .= sprintf( "%02X", ord substr( $value, $n, 1 ) ); + } + return $result; } sub show_string($) { - my $value = $_[0]; - my $n; - - my $result = ""; - for ( $n = 0; $n < length($value); $n += 1) { - my $c = ord substr($value,$n,1); - if ( $c == ord '\\' ) { - $result .= "\\\\"; - } elsif ( $c == 0x1b ) { - $result .= "\\E"; - } elsif ( $c == 0x7f ) { - $result .= "^?"; - } elsif ( $c == 32 ) { - $result .= "\\s"; - } elsif ( $c < 32 ) { - $result .= sprintf("^%c", $c + 64); - } elsif ( $c > 128 ) { - $result .= sprintf("\\%03o", $c); - } else { - $result .= chr($c); - } - } - - printf "%s\r\n", $result; + my $value = $_[0]; + my $n; + + my $result = ""; + for ( $n = 0 ; $n < length($value) ; $n += 1 ) { + my $c = ord substr( $value, $n, 1 ); + if ( $c == ord '\\' ) { + $result .= "\\\\"; + } + elsif ( $c == 0x1b ) { + $result .= "\\E"; + } + elsif ( $c == 0x7f ) { + $result .= "^?"; + } + elsif ( $c == 32 ) { + $result .= "\\s"; + } + elsif ( $c < 32 ) { + $result .= sprintf( "^%c", $c + 64 ); + } + elsif ( $c > 128 ) { + $result .= sprintf( "\\%03o", $c ); + } + else { + $result .= chr($c); + } + } + + printf "%s\r\n", $result; } sub get_reply($) { - my $command = $_[0]; - my $reply = ""; - - printf "send: "; - show_string($command); - - print STDOUT $command; - autoflush STDOUT 1; - while (1) { - my $test=ReadKey 1; - last if not defined $test; - #printf "%d:%s\r\n", length($reply), to_hex($test); - $reply .= $test; - } - return $reply; + my $command = $_[0]; + my $reply = ""; + + printf "send: "; + show_string($command); + + print STDOUT $command; + autoflush STDOUT 1; + while (1) { + my $test = ReadKey 1; + last if not defined $test; + + #printf "%d:%s\r\n", length($reply), to_hex($test); + $reply .= $test; + } + return $reply; } sub get_paste() { - my $reply = get_reply("\x1b]52;" . $target . ";?\x1b\\"); + my $reply = get_reply( "\x1b]52;" . $target . ";?\x1b\\" ); - printf "read: "; - show_string($reply); + printf "read: "; + show_string($reply); - my $data = $reply; - $data =~ s/^\x1b]52;[[:alnum:]]*;//; - $data =~ s/\x1b\\$//; - printf "chop: "; - show_string($data); + my $data = $reply; + $data =~ s/^\x1b]52;[[:alnum:]]*;//; + $data =~ s/\x1b\\$//; + printf "chop: "; + show_string($data); - $data = decode_base64($data); - printf "data: "; - show_string($data); + $data = decode_base64($data); + printf "data: "; + show_string($data); } sub put_paste() { - ReadMode 1; + ReadMode 1; - printf "data: "; - my $data = ReadLine 0; - chomp $data; - ReadMode 5; + printf "data: "; + my $data = ReadLine 0; + chomp $data; + ReadMode 5; - $data = encode_base64($data); - chomp $data; - printf "data: "; - show_string($data); + $data = encode_base64($data); + chomp $data; + printf "data: "; + show_string($data); - my $send = "\x1b]52;" . $target . ";" . $data . "\x1b\\"; + my $send = "\x1b]52;" . $target . ";" . $data . "\x1b\\"; - printf "send: "; - show_string($send); + printf "send: "; + show_string($send); + print STDOUT $send; + autoflush STDOUT 1; } sub set_target() { - ReadMode 1; + ReadMode 1; - printf "target: "; - $target = ReadLine 0; - $target =~ s/[^[:alnum:]]//g; - ReadMode 5; - printf "result: %s\r\n", $target; + printf "target: "; + $target = ReadLine 0; + $target =~ s/[^[:alnum:]]//g; + ReadMode 5; + printf "result: %s\r\n", $target; } -ReadMode 5, 'STDIN'; # allow single-character inputs +ReadMode 5, 'STDIN'; # allow single-character inputs while (1) { - my $cmd; - - printf "\r\nCommand (? for help):"; - $cmd = ReadKey 0; - if ( $cmd eq "?" ) { - printf "\r\np=put selection, g=get selection, q=quit, r=reset target, s=set target\r\n"; - } elsif ($cmd eq "p") { - printf " ...put selection\r\n"; - put_paste(); - } elsif ($cmd eq "g") { - printf " ...get selection\r\n"; - get_paste(); - } elsif ($cmd eq "q") { - printf " ...quit\r\n"; - last; - } elsif ($cmd eq "r") { - printf " ...reset\r\n"; - $target = ""; - } elsif ($cmd eq "s") { - printf " ...set target\r\n"; - set_target(); - } + my $cmd; + + printf "\r\nCommand (? for help):"; + $cmd = ReadKey 0; + if ( $cmd eq "?" ) { + printf "\r\np=put selection," + . " g=get selection," + . " q=quit," + . " r=reset target," + . " s=set target\r\n"; + } + elsif ( $cmd eq "p" ) { + printf " ...put selection\r\n"; + put_paste(); + } + elsif ( $cmd eq "g" ) { + printf " ...get selection\r\n"; + get_paste(); + } + elsif ( $cmd eq "q" ) { + printf " ...quit\r\n"; + last; + } + elsif ( $cmd eq "r" ) { + printf " ...reset\r\n"; + $target = ""; + } + elsif ( $cmd eq "s" ) { + printf " ...set target\r\n"; + set_target(); + } } -ReadMode 0, 'STDIN'; # Reset tty mode before exiting +ReadMode 0, 'STDIN'; # Reset tty mode before exiting diff --git a/app/xterm/xterm.h b/app/xterm/xterm.h index 952da4c5c..ec65470db 100644 --- a/app/xterm/xterm.h +++ b/app/xterm/xterm.h @@ -1,4 +1,4 @@ -/* $XTermId: xterm.h,v 1.749 2014/11/28 19:30:12 tom Exp $ */ +/* $XTermId: xterm.h,v 1.753 2014/12/23 00:08:58 Ross.Combs Exp $ */ /* * Copyright 1999-2013,2014 by Thomas E. Dickey @@ -417,6 +417,7 @@ extern char **environ; #define XtNcolorAttrMode "colorAttrMode" #define XtNcolorBDMode "colorBDMode" #define XtNcolorBLMode "colorBLMode" +#define XtNcolorITMode "colorITMode" #define XtNcolorMode "colorMode" #define XtNcolorRVMode "colorRVMode" #define XtNcolorULMode "colorULMode" @@ -484,6 +485,7 @@ extern char **environ; #define XtNloginShell "loginShell" #define XtNmarginBell "marginBell" #define XtNmaximized "maximized" +#define XtNmaxGraphicSize "maxGraphicSize" #define XtNmenuBar "menuBar" #define XtNmenuHeight "menuHeight" #define XtNmetaSendsEscape "metaSendsEscape" @@ -517,6 +519,7 @@ extern char **environ; #define XtNprinterNewLine "printerNewLine" #define XtNprivateColorRegisters "privateColorRegisters" #define XtNquietGrab "quietGrab" +#define XtNregisDefaultFont "regisDefaultFont" #define XtNregisScreenSize "regisScreenSize" #define XtNrenderFont "renderFont" #define XtNresizeGravity "resizeGravity" @@ -666,6 +669,7 @@ extern char **environ; #define XtCLoginShell "LoginShell" #define XtCMarginBell "MarginBell" #define XtCMaximized "Maximized" +#define XtCMaxGraphicSize "MaxGraphicSize" #define XtCMenuBar "MenuBar" #define XtCMenuHeight "MenuHeight" #define XtCMetaSendsEscape "MetaSendsEscape" @@ -695,6 +699,7 @@ extern char **environ; #define XtCPrinterNewLine "PrinterNewLine" #define XtCPrivateColorRegisters "PrivateColorRegisters" #define XtCQuietGrab "QuietGrab" +#define XtCRegisDefaultFont "RegisDefaultFont" #define XtCRegisScreenSize "RegisScreenSize" #define XtCRenderFont "RenderFont" #define XtCResizeGravity "ResizeGravity" @@ -1408,6 +1413,15 @@ extern Pixel xtermGetColorRes(XtermWidget /* xw */, ColorRes * /* res */); #define ExtractForeground(color) (unsigned) GetCellColorFG(color) #define ExtractBackground(color) (unsigned) GetCellColorBG(color) +#if OPT_WIDE_ATTRS +#define MapToWideColorMode(fg, screen, flags) \ + (((screen)->colorITMode && ((flags) & ATR_ITALIC)) \ + ? COLOR_IT \ + : fg) +#else +#define MapToWideColorMode(fg, screen, flags) fg +#endif + #define MapToColorMode(fg, screen, flags) \ (((screen)->colorBLMode && ((flags) & BLINK)) \ ? COLOR_BL \ @@ -1415,7 +1429,7 @@ extern Pixel xtermGetColorRes(XtermWidget /* xw */, ColorRes * /* res */); ? COLOR_BD \ : (((screen)->colorULMode && ((flags) & UNDERLINE)) \ ? COLOR_UL \ - : fg))) + : MapToWideColorMode(fg, screen, flags)))) #define checkVeryBoldAttr(flags, fg, code, attr) \ if ((flags & FG_COLOR) != 0 \ @@ -1424,11 +1438,19 @@ extern Pixel xtermGetColorRes(XtermWidget /* xw */, ColorRes * /* res */); && (fg == code)) \ UIntClr(flags, attr) +#if OPT_WIDE_ATTRS +#define checkVeryBoldWideAttr(flags, fg, it, atr) \ + checkVeryBoldAttr(flags, fg, it, atr) +#else +#define checkVeryBoldWideAttr(flags, fg, it, atr) (void) flags +#endif + #define checkVeryBoldColors(flags, fg) \ checkVeryBoldAttr(flags, fg, COLOR_RV, INVERSE); \ checkVeryBoldAttr(flags, fg, COLOR_UL, UNDERLINE); \ checkVeryBoldAttr(flags, fg, COLOR_BD, BOLD); \ - checkVeryBoldAttr(flags, fg, COLOR_BL, BLINK) + checkVeryBoldAttr(flags, fg, COLOR_BL, BLINK); \ + checkVeryBoldWideAttr(flags, fg, COLOR_IT, ATR_ITALIC) #else /* !OPT_ISO_COLORS */ diff --git a/app/xterm/xterm.log.html b/app/xterm/xterm.log.html index ffdbba782..b567247c3 100644 --- a/app/xterm/xterm.log.html +++ b/app/xterm/xterm.log.html @@ -30,7 +30,7 @@ * sale, use or other dealings in this Software without prior written * * authorization. * ***************************************************************************** - $XTermId: xterm.log.html,v 1.1538 2014/11/29 02:25:58 tom Exp $ + $XTermId: xterm.log.html,v 1.1557 2014/12/29 00:55:21 tom Exp $ --> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> @@ -72,6 +72,8 @@ CHANGELOG</a>).</p> <ul> + <li><a href="#xterm_314">Patch #314 - 2014/12/28</a></li> + <li><a href="#xterm_313">Patch #313 - 2014/11/28</a></li> <li><a href="#xterm_312">Patch #312 - 2014/09/28</a></li> @@ -911,6 +913,107 @@ <li><a href="#xterm_01">Patch #1 - 1996/1/6</a></li> </ul> + <h1><a name="xterm_314" id="xterm_314">Patch #314 - + 2014/12/28</a></h1> + + <ul> + <li>fix a minor bug in the termcap-specific version of + <code>resize</code> when the lines or columns values are at the + very end of an incomplete termcap string (prompted by coverity + report).</li> + + <li>improve paste64 feature (report by Olaf Rogalsky) + + <ul> + <li>fix “<code>p</code>;” command in + <code>paste64.pl</code> example.</li> + + <li>modify <code>_OwnSelection</code> to allow the paste64 + control to cause primary/clipboard selections to be + disowned and cleared.</li> + + <li>omit an extra "=" used in padding, to make the base64 + response a multiple of four characters.</li> + + <li>modify <code>_ConvertSelectionHelper</code> to not stop + converting on embedded nulls in the primary or clipboard + selection. That makes the behavior consistent with + cut-buffers. Nulls are not passed on to the application + because they are used for separators in the X library calls + that convert <code>XTextProperty</code> values.</li> + </ul> + </li> + + <li>add configure option <code>--with-man2html</code> to allow + an alternative to groff's man/html conversion.</li> + + <li>review and modify resource-settings which can be set via + control sequences, etc: + + <ul> + <li>add <code>OSC 6</code>, to enable/disable colors + set via <code>OSC 5</code>, without changing the color + assignments (prompted by patch by Ingo Brückl).</li> + + <li>add command-line option <code>-itc</code> for + italics.</li> + + <li>add <code>colorIT</code> and <code>colorITMode</code> + for italics, like <code>colorBD</code>, etc.</li> + + <li>guard <code>allowPasteControls</code> against + modification by <code>editres</code>.</li> + </ul> + </li> + + <li>change <code>passedPty</code> from fixed-length to + allocated to ensure that it is long enough to hold the + <code>-S</code> option value (report by Ben Longbons).</li> + + <li>improve ReGIS graphics initialization (Ross Combs): + + <ul> + <li>add a new string resource to set the default ReGIS + font.</li> + + <li>fix a caching problem where the font name wasn't taken + into consideration when looking up cached metrics.</li> + + <li>enables use of fractional values in coordinates (which + in turn allows setting the coordinates to something like + [0,1][1,0])</li> + + <li>doubles the minimum ReGIS graphic to 200x200</li> + + <li>set the default ReGIS image size to "auto"</li> + + <li>fix some swapped width/height parameters in TRACE + messages</li> + + <li>add support for scaling and mirrored coordinate systems + to the screen address command</li> + + <li>sets a minimum ReGIS graphics size of 100x100 -- + smaller address ranges will be scaled up</li> + + <li>reset the image if either the width or height is zero + (which should happen together or not at all, but switching + the logic gets rid of some parentheses)</li> + + <li>adds support for alternate screen coordinates (just + offsets, not inverted coordinates or scaling)</li> + + <li>keeps the graphics state across ReGIS calls unless P1 + or P3 entry codes are used</li> + + <li>changes loops to continue after parsing whitespace to + allow trailing whitespace</li> + + <li>fixes some incorrect character casts</li> + </ul> + </li> + </ul> + <h1><a name="xterm_313" id="xterm_313">Patch #313 - 2014/11/28</a></h1> @@ -967,9 +1070,10 @@ screen (patch by Ross Combs).</li> <li>amend change to focus-change events in <a href= - "xterm_287">patch #287</a> to limit it to suppressing the reset - of the urgency-hint, because some useful <code>FocusOut</code> - events were lost (report by Joe Peterson).</li> + "#xterm_287">patch #287</a> to limit it to suppressing the + reset of the urgency-hint, because some useful + <code>FocusOut</code> events were lost (report by Joe + Peterson).</li> <li>modify dpkg build-script to configure xterm-dev as an <code>x-terminal-emulator</code> alternative.</li> diff --git a/app/xterm/xterm.man b/app/xterm/xterm.man index 52dda7fb4..a6b855694 100644 --- a/app/xterm/xterm.man +++ b/app/xterm/xterm.man @@ -1,5 +1,5 @@ '\" t -.\" $XTermId: xterm.man,v 1.586 2014/11/28 22:33:56 tom Exp $ +.\" $XTermId: xterm.man,v 1.587 2014/12/17 10:10:02 tom Exp $ .\" .\" Copyright 1996-2013,2014 by Thomas E. Dickey .\" @@ -427,12 +427,12 @@ set the amount of time text cursor is on when blinking via the .TP 8 .B "\-bdc" Set the \fIvt100\fP resource \fBcolorBDMode\fR to \*(``false\*('', -disabling the display of characters with bold attribute as color +disabling the display of characters with bold attribute as color. .TP 8 .B "+bdc" Set the \fIvt100\fP resource \fBcolorBDMode\fR to \*(``true\*('', enabling the display of characters with bold attribute as color -rather than bold +rather than bold. .TP 8 .B "\-cb" Set the \fIvt100\fP resource \fBcutToBeginningOfLine\fP to \*(``false\*(''. @@ -693,6 +693,15 @@ to demonstrate the feature. When using Gtk, there is a limitation of that toolkit which requires that \fI\*n\fP's \fBallowSendEvents\fP resource is enabled. .TP 8 +.B "\-itc" +Set the \fIvt100\fP resource \fBcolorITMode\fR to \*(``false\*('', +disabling the display of characters with italic attribute as italic. +.TP 8 +.B "+itc" +Set the \fIvt100\fP resource \fBcolorITMode\fR to \*(``true\*('', +enabling the display of characters with italic attribute as color +rather than italic. +.TP 8 .B \-j This option indicates that \fI\*n\fP should do jump scrolling. It corresponds to the \fBjumpScroll\fP resource. @@ -2345,6 +2354,26 @@ color. Note that setting \fBcolorMode\fR off disables all colors, including this. The default is \*(``false\*(''. .TP 8 +.B "colorIT (\fPclass\fB ColorIT)" +This specifies the color to use to display italic characters if +the \*(``colorITMode\*('' resource is enabled. +The default is \*(``XtDefaultForeground\*(''. +.IP +See also the \fBveryBoldColors\fP resource which allows combining attributes and color. +.TP 8 +.B "colorITMode (\fPclass\fB ColorAttrMode)" +Specifies whether characters with the italic attribute should be displayed in +color or as italic characters. +The default is \*(``false\*(''. +.IP +Note that: +.RS +.bP +Setting \fBcolorMode\fR off disables all colors, including italic. +.bP +The \fBitalicULMode\fP resource overrides \fBcolorITMode\fP. +.RE +.TP 8 .B "colorMode (\fPclass\fB ColorMode)" Specifies whether or not recognition of ANSI (ISO-6429) color change escape sequences should be enabled. @@ -4096,14 +4125,19 @@ The default is \*(``false\*(''. .TP 8 .B "veryBoldColors (\fPclass\fB VeryBoldColors)" Specifies whether to combine video attributes with colors specified by -\fBcolorBD\fR, \fBcolorBL\fR, \fBcolorRV\fR and \fBcolorUL\fR. +\fBcolorBD\fR, +\fBcolorBL\fR, +\fBcolorIT\fR, +\fBcolorRV\fR, and +\fBcolorUL\fR. The resource value is the sum of values for each attribute: .RS 10 .nf 1 for reverse, 2 for underline, -4 for bold and -8 for blink. +4 for bold, +8 for blink, and +512 for italic .fi .RE .IP |