summaryrefslogtreecommitdiff
path: root/app/xterm/charproc.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/xterm/charproc.c')
-rw-r--r--app/xterm/charproc.c121
1 files changed, 88 insertions, 33 deletions
diff --git a/app/xterm/charproc.c b/app/xterm/charproc.c
index 07dd84902..a570707bf 100644
--- a/app/xterm/charproc.c
+++ b/app/xterm/charproc.c
@@ -1,4 +1,4 @@
-/* $XTermId: charproc.c,v 1.1888 2022/02/22 09:00:26 Vladimir.A.Pavlov Exp $ */
+/* $XTermId: charproc.c,v 1.1906 2022/10/10 15:42:50 tom Exp $ */
/*
* Copyright 1999-2021,2022 by Thomas E. Dickey
@@ -384,10 +384,10 @@ static XtActionsRec actionsList[] = {
{ "scroll-lock", HandleScrollLock },
#endif
#if OPT_SELECTION_OPS
-#if OPT_EXEC_XTERM
+#if OPT_EXEC_SELECTION
{ "exec-formatted", HandleExecFormatted },
{ "exec-selectable", HandleExecSelectable },
-#endif /* OPT_EXEC_XTERM */
+#endif
{ "insert-formatted", HandleInsertFormatted },
{ "insert-selectable", HandleInsertSelectable },
#endif
@@ -733,12 +733,16 @@ static XtResource xterm_resources[] =
"1000x1000"),
#endif
+#if OPT_ISO_COLORS && OPT_WIDE_ATTRS && OPT_SGR2_HASH
+ Bres(XtNfaintIsRelative, XtCFaintIsRelative, screen.faint_relative, False),
+#endif
+
#if OPT_SHIFT_FONTS
Bres(XtNshiftFonts, XtCShiftFonts, misc.shift_fonts, True),
#endif
#if OPT_SIXEL_GRAPHICS
- Bres(XtNsixelScrolling, XtCSixelScrolling, screen.sixel_scrolling, False),
+ Bres(XtNsixelScrolling, XtCSixelScrolling, screen.sixel_scrolling, True),
Bres(XtNsixelScrollsRight, XtCSixelScrollsRight,
screen.sixel_scrolls_right, False),
#endif
@@ -816,6 +820,12 @@ static XtResource xterm_resources[] =
#if OPT_RENDERFONT
Bres(XtNforceXftHeight, XtCForceXftHeight, screen.force_xft_height, False),
+ Ires(XtNxftMaxGlyphMemory, XtCXftMaxGlyphMemory,
+ screen.xft_max_glyph_memory, 0),
+ Ires(XtNxftMaxUnrefFonts, XtCXftMaxUnrefFonts,
+ screen.xft_max_unref_fonts, 0),
+ Bres(XtNxftTrackMemUsage, XtCXftTrackMemUsage,
+ screen.xft_track_mem_usage, DEF_TRACK_USAGE),
#define RES_FACESIZE(n) Dres(XtNfaceSize #n, XtCFaceSize #n, misc.face_size[n], "0.0")
RES_FACESIZE(1),
RES_FACESIZE(2),
@@ -2271,7 +2281,7 @@ typedef enum {
SLnone = 0, /* no status-line timer needed */
SLclock = 1, /* status-line updates once/second */
SLcoords = 2, /* status-line shows cursor-position */
- SLwritten = 3 /* status-line may need asynchonous repainting */
+ SLwritten = 3 /* status-line may need asynchronous repainting */
} SL_MODE;
#define SL_BUFSIZ 80
@@ -4051,8 +4061,11 @@ doparsing(XtermWidget xw, unsigned c, struct ParseState *sp)
}
reply.a_param[count++] = (ParmType) value;
- if (sp->private_function
- && screen->vtXX_level >= 4) { /* VT420 */
+ if (sp->private_function &&
+ (screen->vtXX_level >= 4 ||
+ (screen->terminal_id >= 330 &&
+ screen->vtXX_level >= 3))) {
+ /* VT330 (not VT320) and VT420 */
reply.a_param[count++] = 1;
}
reply.a_final = 'R';
@@ -5721,7 +5734,7 @@ static Char *v_bufend; /* end of physical buffer */
or generated by us in response to a query ESC sequence. */
void
-v_write(int f, const Char *data, unsigned len)
+v_write(int f, const Char *data, size_t len)
{
TRACE2(("v_write(%d:%s)\n", len, visibleChars(data, len)));
if (v_bufstr == NULL) {
@@ -5736,10 +5749,11 @@ v_write(int f, const Char *data, unsigned len)
}
}
if_DEBUG({
- fprintf(stderr, "v_write called with %u bytes (%ld left over)",
- len, (long) (v_bufptr - v_bufstr));
+ fprintf(stderr, "v_write called with %lu bytes (%lu left over)",
+ (unsigned long) len,
+ (unsigned long) (v_bufptr - v_bufstr));
if (len > 1 && len < 10)
- fprintf(stderr, " \"%.*s\"", len, (const char *) data);
+ fprintf(stderr, " \"%.*s\"", (int) len, (const char *) data);
fprintf(stderr, "\n");
});
@@ -5783,12 +5797,12 @@ v_write(int f, const Char *data, unsigned len)
if (v_bufend < v_bufptr + len) {
/* still won't fit: get more space */
/* Don't use XtRealloc because an error is not fatal. */
- unsigned size = (unsigned) (v_bufptr - v_buffer);
+ size_t size = (size_t) (v_bufptr - v_buffer);
v_buffer = TypeRealloc(Char, size + len, v_buffer);
if (v_buffer) {
if_DEBUG({
- fprintf(stderr, "expanded buffer to %u\n",
- size + len);
+ fprintf(stderr, "expanded buffer to %lu\n",
+ (unsigned long) (size + len));
});
v_bufstr = v_buffer;
v_bufptr = v_buffer + size;
@@ -5829,9 +5843,9 @@ v_write(int f, const Char *data, unsigned len)
#ifdef VMS
riten = tt_write(v_bufstr,
- ((v_bufptr - v_bufstr <= VMS_TERM_BUFFER_SIZE)
- ? v_bufptr - v_bufstr
- : VMS_TERM_BUFFER_SIZE));
+ (size_t) ((v_bufptr - v_bufstr <= VMS_TERM_BUFFER_SIZE)
+ ? v_bufptr - v_bufstr
+ : VMS_TERM_BUFFER_SIZE));
if (riten == 0)
return (riten);
#else /* VMS */
@@ -5864,9 +5878,9 @@ v_write(int f, const Char *data, unsigned len)
*/
if (v_bufend - v_bufptr > 1024) { /* arbitrary hysteresis */
/* save pointers across realloc */
- int start = (int) (v_bufstr - v_buffer);
- int size = (int) (v_bufptr - v_buffer);
- unsigned allocsize = (unsigned) (size ? size : 1);
+ size_t start = (size_t) (v_bufstr - v_buffer);
+ size_t size = (size_t) (v_bufptr - v_buffer);
+ size_t allocsize = (size ? size : 1);
v_buffer = TypeRealloc(Char, allocsize, v_buffer);
if (v_buffer) {
@@ -5874,7 +5888,7 @@ v_write(int f, const Char *data, unsigned len)
v_bufptr = v_buffer + size;
v_bufend = v_buffer + allocsize;
if_DEBUG({
- fprintf(stderr, "shrunk buffer to %u\n", allocsize);
+ fprintf(stderr, "shrunk buffer to %lu\n", (unsigned long) allocsize);
});
} else {
/* should we print a warning if couldn't return memory? */
@@ -7034,12 +7048,12 @@ dpmodes(XtermWidget xw, BitFunc func)
}
break;
#if OPT_SIXEL_GRAPHICS
- case srm_DECSDM: /* sixel scrolling */
+ case srm_DECSDM: /* sixel display mode (no scrolling) */
if (optSixelGraphics(screen)) { /* FIXME: VT24x did not scroll sixel graphics */
(*func) (&xw->keyboard.flags, MODE_DECSDM);
- TRACE(("DECSET/DECRST DECSDM %s (resource default is %d)\n",
+ TRACE(("DECSET/DECRST DECSDM %s (resource default is %s)\n",
BtoS(xw->keyboard.flags & MODE_DECSDM),
- TScreenOf(xw)->sixel_scrolling));
+ BtoS(!TScreenOf(xw)->sixel_scrolling)));
update_decsdm();
}
break;
@@ -7385,7 +7399,7 @@ savemodes(XtermWidget xw)
DoSM(DP_X_LRMM, LEFT_RIGHT);
break;
#if OPT_SIXEL_GRAPHICS
- case srm_DECSDM: /* sixel scrolling */
+ case srm_DECSDM: /* sixel display mode (no scroll) */
DoSM(DP_DECSDM, xw->keyboard.flags & MODE_DECSDM);
update_decsdm();
break;
@@ -7748,7 +7762,7 @@ restoremodes(XtermWidget xw)
}
break;
#if OPT_SIXEL_GRAPHICS
- case srm_DECSDM: /* sixel scrolling */
+ case srm_DECSDM: /* sixel display mode (no scroll) */
bitcpy(&xw->keyboard.flags, screen->save_modes[DP_DECSDM], MODE_DECSDM);
update_decsdm();
break;
@@ -8652,7 +8666,13 @@ SwitchBufs(XtermWidget xw, int toBuf, Bool clearFirst)
HideCursor(xw);
rows = MaxRows(screen);
- SwitchBufPtrs(screen, toBuf);
+#if OPT_STATUS_LINE
+ if (IsStatusShown(screen) && (rows > 0)) {
+ /* avoid clearing the status-line in this function */
+ --rows;
+ }
+#endif
+ SwitchBufPtrs(xw, toBuf);
if ((top = INX2ROW(screen, 0)) < rows) {
if (screen->scroll_amt) {
@@ -8682,10 +8702,26 @@ CheckBufPtrs(TScreen *screen)
* Swap buffer line pointers between alternate and regular screens.
*/
void
-SwitchBufPtrs(TScreen *screen, int toBuf)
+SwitchBufPtrs(XtermWidget xw, int toBuf)
{
+ TScreen *screen = TScreenOf(xw);
+
if (CheckBufPtrs(screen)) {
- screen->visbuf = screen->editBuf_index[toBuf];
+#if OPT_STATUS_LINE
+ if (IsStatusShown(screen)
+ && (screen->visbuf != screen->editBuf_index[toBuf])) {
+ LineData *oldLD;
+ LineData *newLD;
+ int row = MaxRows(screen);
+
+ oldLD = getLineData(screen, row);
+ screen->visbuf = screen->editBuf_index[toBuf];
+ newLD = getLineData(screen, row);
+
+ copyLineData(newLD, oldLD);
+ } else
+#endif
+ screen->visbuf = screen->editBuf_index[toBuf];
}
}
@@ -8715,7 +8751,7 @@ VTRun(XtermWidget xw)
#if OPT_TEK4014
if (Tpushb > Tpushback) {
- fillPtyData(xw, VTbuffer, (char *) Tpushback, (int) (Tpushb - Tpushback));
+ fillPtyData(xw, VTbuffer, (char *) Tpushback, (size_t) (Tpushb - Tpushback));
Tpushb = Tpushback;
}
#endif
@@ -10189,6 +10225,9 @@ VTInitialize(Widget wrequest,
for (i = 0; i <= fontMenu_lastBuiltin; ++i) {
init_Dres2(misc.face_size, i);
}
+ init_Ires(screen.xft_max_glyph_memory);
+ init_Ires(screen.xft_max_unref_fonts);
+ init_Bres(screen.xft_track_mem_usage);
#define ALLOC_FONTLIST(name,which,field) \
init_Sres(misc.default_xft.field);\
@@ -10297,6 +10336,9 @@ VTInitialize(Widget wrequest,
#if OPT_DIRECT_COLOR
init_Bres(screen.direct_color);
#endif
+#if OPT_WIDE_ATTRS && OPT_SGR2_HASH
+ init_Bres(screen.faint_relative);
+#endif
TRACE(("...will fake resources for color%d to color%d\n",
MIN_ANSI_COLORS,
@@ -10439,6 +10481,11 @@ VTInitialize(Widget wrequest,
#if OPT_RENDERFONT
init_Ires(misc.limit_fontsets);
wnew->work.max_fontsets = (unsigned) wnew->misc.limit_fontsets;
+ if (wnew->work.max_fontsets > 255) {
+ xtermWarning("limiting number of fontsets to 255 (was %u)\n",
+ wnew->work.max_fontsets);
+ wnew->work.max_fontsets = 255;
+ }
init_Sres(misc.render_font_s);
wnew->work.render_font =
@@ -10588,9 +10635,12 @@ VTInitialize(Widget wrequest,
BtoS(wnew->keyboard.flags & MODE_DECBKM)));
#if OPT_SIXEL_GRAPHICS
+ /* Sixel scrolling is opposite of Sixel Display Mode */
init_Bres(screen.sixel_scrolling);
if (screen->sixel_scrolling)
- wnew->keyboard.flags |= MODE_DECSDM;
+ UIntClr(wnew->keyboard.flags, MODE_DECSDM);
+ else
+ UIntSet(wnew->keyboard.flags, MODE_DECSDM);
TRACE(("initialized DECSDM %s\n",
BtoS(wnew->keyboard.flags & MODE_DECSDM)));
#endif
@@ -11121,6 +11171,9 @@ VTDestroy(Widget w GCC_UNUSED)
TRACE_FREE_LEAK(xw->misc.localefilter);
#endif
+ TRACE_FREE_LEAK(xw->misc.cdXtraScroll_s);
+ TRACE_FREE_LEAK(xw->misc.tiXtraScroll_s);
+
#if OPT_RENDERFONT
TRACE_FREE_LEAK(xw->misc.default_xft.f_n);
#if OPT_WIDE_CHARS
@@ -13234,10 +13287,12 @@ ReallyReset(XtermWidget xw, Bool full, Bool saved)
screen->pointer_mode = screen->pointer_mode0;
#if OPT_SIXEL_GRAPHICS
if (TScreenOf(xw)->sixel_scrolling)
- xw->keyboard.flags |= MODE_DECSDM;
+ UIntClr(xw->keyboard.flags, MODE_DECSDM);
+ else
+ UIntSet(xw->keyboard.flags, MODE_DECSDM);
TRACE(("full reset DECSDM to %s (resource default is %s)\n",
BtoS(xw->keyboard.flags & MODE_DECSDM),
- BtoS(TScreenOf(xw)->sixel_scrolling)));
+ BtoS(!TScreenOf(xw)->sixel_scrolling)));
#endif
#if OPT_GRAPHICS