"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "button.c" between
xterm-365.tgz and xterm-366.tgz

About: xterm is a terminal emulator for X with ISO/ANSI color and vt220 enhancements.

button.c  (xterm-365.tgz):button.c  (xterm-366.tgz)
/* $XTermId: button.c,v 1.631 2021/02/04 01:00:26 tom Exp $ */ /* $XTermId: button.c,v 1.636 2021/02/10 01:14:51 tom Exp $ */
/* /*
* Copyright 1999-2020,2021 by Thomas E. Dickey * Copyright 1999-2020,2021 by Thomas E. Dickey
* *
* All Rights Reserved * All Rights Reserved
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the * copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including * "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish, * without limitation the rights to use, copy, modify, merge, publish,
skipping to change at line 412 skipping to change at line 412
int state = scanMods; int state = scanMods;
int state2 = scanMods; int state2 = scanMods;
unsigned first; unsigned first;
unsigned last; unsigned last;
int have_button = -1; int have_button = -1;
Bool want_button = False; Bool want_button = False;
Bool have_shift = False; Bool have_shift = False;
unsigned allowed = 0; unsigned allowed = 0;
unsigned disallow = 0; unsigned disallow = 0;
TRACE(("xtermButtonInit length %ld\n", strlen(result))); TRACE(("xtermButtonInit length %ld\n", (long) strlen(result)));
xw->keyboard.print_translations = data; xw->keyboard.print_translations = data;
while ((next = scanTrans(data, &state, &state2, &first, &last)) != 0) { while ((next = scanTrans(data, &state, &state2, &first, &last)) != 0) {
unsigned len = (last - first); unsigned len = (last - first);
TRACE2(("parse %s:%d..%d '%.*s'\n", TRACE2(("parse %s:%d..%d '%.*s'\n",
visibleScan(state), first, last, visibleScan(state), first, last,
len, data + first)); len, data + first));
if (state == scanMods) { if (state == scanMods) {
if (len > 1 && data[first] == '~') { if (len > 1 && data[first] == '~') {
len--; len--;
first++; first++;
skipping to change at line 4326 skipping to change at line 4326
SaltTextAway(XtermWidget xw, SaltTextAway(XtermWidget xw,
int which, int which,
CELL *cellc, CELL *cellc,
CELL *cell) CELL *cell)
{ {
TScreen *screen = TScreenOf(xw); TScreen *screen = TScreenOf(xw);
SelectedCells *scp; SelectedCells *scp;
int i; int i;
int eol; int eol;
int need = 0; int need = 0;
size_t have = 0;
Char *line; Char *line;
Char *lp; Char *lp;
CELL first = *cellc; CELL first = *cellc;
CELL last = *cell; CELL last = *cell;
if (which < 0 || which >= MAX_SELECTIONS) { if (which < 0 || which >= MAX_SELECTIONS) {
TRACE(("SaltTextAway - which selection?\n")); TRACE(("SaltTextAway - which selection?\n"));
return; return;
} }
scp = &(screen->selected_cells[which]); scp = &(screen->selected_cells[which]);
skipping to change at line 4360 skipping to change at line 4361
} else { /* two cases, cut is on same line, cut spans mult iple lines */ } else { /* two cases, cut is on same line, cut spans mult iple lines */
need += Length(screen, first.row, first.col, screen->max_col) + 1; need += Length(screen, first.row, first.col, screen->max_col) + 1;
for (i = first.row + 1; i < last.row; i++) for (i = first.row + 1; i < last.row; i++)
need += Length(screen, i, 0, screen->max_col) + 1; need += Length(screen, i, 0, screen->max_col) + 1;
if (last.col >= 0) if (last.col >= 0)
need += Length(screen, last.row, 0, last.col); need += Length(screen, last.row, 0, last.col);
} }
/* UTF-8 may require more space */ /* UTF-8 may require more space */
if_OPT_WIDE_CHARS(screen, { if_OPT_WIDE_CHARS(screen, {
need *= 4; if (need > 0) {
if (screen->max_combining > 0)
need += screen->max_combining;
need *= 6;
}
}); });
/* now get some memory to save it in */ /* now get some memory to save it in */
if (need < 0) if (need < 0)
return; return;
if (scp->data_limit <= (unsigned) need) { if (scp->data_limit <= (unsigned) need) {
if ((line = (Char *) malloc((size_t) need + 1)) == 0) if ((line = (Char *) malloc((size_t) need + 1)) == 0)
SysError(ERROR_BMALLOC2); SysError(ERROR_BMALLOC2);
free(scp->data_buffer); free(scp->data_buffer);
skipping to change at line 4398 skipping to change at line 4403
for (i = first.row + 1; i < last.row; i++) { for (i = first.row + 1; i < last.row; i++) {
lp = SaveText(screen, i, 0, screen->max_col, lp, &eol); lp = SaveText(screen, i, 0, screen->max_col, lp, &eol);
if (eol) if (eol)
*lp++ = '\n'; *lp++ = '\n';
} }
if (last.col >= 0) if (last.col >= 0)
lp = SaveText(screen, last.row, 0, last.col, lp, &eol); lp = SaveText(screen, last.row, 0, last.col, lp, &eol);
} }
*lp = '\0'; /* make sure we have end marked */ *lp = '\0'; /* make sure we have end marked */
TRACE(("Salted TEXT:%u:%s\n", (unsigned) (lp - line), have = (size_t) (lp - line);
visibleChars(line, (unsigned) (lp - line)))); /*
* Scanning the buffer twice is unnecessary. Discard unwanted memory if
* the estimate is too-far off.
*/
if ((have * 2) < (size_t) need) {
Char *next;
scp->data_limit = have + 1;
next = realloc(line, scp->data_limit);
if (next == NULL) {
free(line);
scp->data_length = 0;
scp->data_limit = 0;
}
scp->data_buffer = next;
}
scp->data_length = have;
scp->data_length = (size_t) (lp - line); TRACE(("Salted TEXT:%u:%s\n", (unsigned) have,
visibleChars(scp->data_buffer, (unsigned) have)));
} }
#if OPT_PASTE64 #if OPT_PASTE64
void void
ClearSelectionBuffer(TScreen *screen, String selection) ClearSelectionBuffer(TScreen *screen, String selection)
{ {
int which = TargetToSelection(screen, selection); int which = TargetToSelection(screen, selection);
SelectedCells *scp = &(screen->selected_cells[okSelectionCode(which)]); SelectedCells *scp = &(screen->selected_cells[okSelectionCode(which)]);
FreeAndNull(scp->data_buffer); FreeAndNull(scp->data_buffer);
scp->data_limit = 0; scp->data_limit = 0;
skipping to change at line 4880 skipping to change at line 4901
} }
XmuInternStrings(dpy, selections, count, atoms); XmuInternStrings(dpy, selections, count, atoms);
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
int cutbuffer = CutBuffer(atoms[i]); int cutbuffer = CutBuffer(atoms[i]);
if (cutbuffer >= 0) { if (cutbuffer >= 0) {
unsigned long limit = unsigned long limit =
(unsigned long) (4 * XMaxRequestSize(dpy) - 32); (unsigned long) (4 * XMaxRequestSize(dpy) - 32);
scp = &(screen->selected_cells[CutBufferToCode(cutbuffer)]); scp = &(screen->selected_cells[CutBufferToCode(cutbuffer)]);
if (scp->data_length > limit) { if (scp->data_length > limit) {
TRACE(("selection too big (%lu bytes), not storing in CUT_BUFFER% d\n", TRACE(("selection too big (%lu bytes), not storing in CUT_BUFFER% d\n",
scp->data_length, cutbuffer)); (unsigned long) scp->data_length, cutbuffer));
xtermWarning("selection too big (%lu bytes), not storing in CUT_B UFFER%d\n", xtermWarning("selection too big (%lu bytes), not storing in CUT_B UFFER%d\n",
(unsigned long) scp->data_length, cutbuffer); (unsigned long) scp->data_length, cutbuffer);
} else { } else {
/* This used to just use the UTF-8 data, which was totally /* This used to just use the UTF-8 data, which was totally
* broken as not even the corresponding paste code in xterm * broken as not even the corresponding paste code in xterm
* understood this! So now it converts to Latin1 first. * understood this! So now it converts to Latin1 first.
* Robert Brady, 2000-09-05 * Robert Brady, 2000-09-05
*/ */
unsigned long length = scp->data_length; unsigned long length = scp->data_length;
Char *data = scp->data_buffer; Char *data = scp->data_buffer;
skipping to change at line 4936 skipping to change at line 4957
TraceAtomName(screen->display, atoms[i]), TraceAtomName(screen->display, atoms[i]),
(long) screen->selection_time)); (long) screen->selection_time));
have_selection |= have_selection |=
XtOwnSelection((Widget) xw, atoms[i], XtOwnSelection((Widget) xw, atoms[i],
screen->selection_time, screen->selection_time,
ConvertSelection, ConvertSelection,
LoseSelection, LoseSelection,
SelectionDone); SelectionDone);
} }
} }
TRACE(("... _OwnSelection used length %ld value %s\n", TRACE(("... _OwnSelection used length %lu value %s\n",
scp->data_length, (unsigned long) scp->data_length,
visibleChars(scp->data_buffer, visibleChars(scp->data_buffer,
(unsigned) scp->data_length))); (unsigned) scp->data_length)));
} }
if (!screen->replyToEmacs) if (!screen->replyToEmacs)
screen->selection_count = count; screen->selection_count = count;
if (!have_selection) if (!have_selection)
UnHiliteText(xw); UnHiliteText(xw);
} }
static void static void
 End of changes. 8 change blocks. 
9 lines changed or deleted 30 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)