1741
1776
ReportAnsiColorRequest(XtermWidget xw, int colornum, int final)
1744
Colormap cmap = xw->core.colormap;
1778
if (AllowColorOps(xw, ecGetAnsiColor)) {
1780
Colormap cmap = xw->core.colormap;
1747
TRACE(("ReportAnsiColorRequest %d\n", colornum));
1748
color.pixel = GET_COLOR_RES(xw, TScreenOf(xw)->Acolors[colornum]);
1749
XQueryColor(TScreenOf(xw)->display, cmap, &color);
1750
sprintf(buffer, "4;%d;rgb:%04x/%04x/%04x",
1755
unparseputc1(xw, ANSI_OSC);
1756
unparseputs(xw, buffer);
1757
unparseputc1(xw, final);
1783
TRACE(("ReportAnsiColorRequest %d\n", colornum));
1784
color.pixel = GET_COLOR_RES(xw, TScreenOf(xw)->Acolors[colornum]);
1785
XQueryColor(TScreenOf(xw)->display, cmap, &color);
1786
sprintf(buffer, "4;%d;rgb:%04x/%04x/%04x",
1791
unparseputc1(xw, ANSI_OSC);
1792
unparseputs(xw, buffer);
1793
unparseputc1(xw, final);
1761
1798
static unsigned
2312
2349
ReportColorRequest(XtermWidget xw, int ndx, int final)
2315
Colormap cmap = xw->core.colormap;
2319
* ChangeColorsRequest() has "always" chosen the opposite color when
2320
* reverse-video is set. Report this as the original color index, but
2321
* reporting the opposite color which would be used.
2323
int i = (xw->misc.re_verse) ? oppositeColor(ndx) : ndx;
2326
color.pixel = pOldColors->colors[ndx];
2327
XQueryColor(TScreenOf(xw)->display, cmap, &color);
2328
sprintf(buffer, "%d;rgb:%04x/%04x/%04x", i + 10,
2332
TRACE(("ReportColors %d: %#lx as %s\n", ndx, pOldColors->colors[ndx], buffer));
2333
unparseputc1(xw, ANSI_OSC);
2334
unparseputs(xw, buffer);
2335
unparseputc1(xw, final);
2351
if (AllowColorOps(xw, ecGetColor)) {
2353
Colormap cmap = xw->core.colormap;
2357
* ChangeColorsRequest() has "always" chosen the opposite color when
2358
* reverse-video is set. Report this as the original color index, but
2359
* reporting the opposite color which would be used.
2361
int i = (xw->misc.re_verse) ? oppositeColor(ndx) : ndx;
2364
color.pixel = pOldColors->colors[ndx];
2365
XQueryColor(TScreenOf(xw)->display, cmap, &color);
2366
sprintf(buffer, "%d;rgb:%04x/%04x/%04x", i + 10,
2370
TRACE(("ReportColors %d: %#lx as %s\n",
2371
ndx, pOldColors->colors[ndx], buffer));
2372
unparseputc1(xw, ANSI_OSC);
2373
unparseputs(xw, buffer);
2374
unparseputc1(xw, final);
2532
* Initially, 'source' points to '#' or '?'.
2534
* Look for an optional sign and optional number. If those are found, lookup
2535
* the corresponding menu font entry.
2538
ParseShiftedFont(XtermWidget xw, char *source, char **target)
2540
TScreen *screen = TScreenOf(xw);
2541
int num = screen->menu_font_number;
2544
if (*++source == '+') {
2547
} else if (*source == '-') {
2552
if (isdigit(CharOf(*source))) {
2553
int val = atoi(source);
2563
num = lookupRelativeFontSize(xw,
2564
screen->menu_font_number, rel);
2567
TRACE(("ParseShiftedFont(%s) ->%d (%s)\n", *target, num, source));
2573
QueryFontRequest(XtermWidget xw, char *buf, int final)
2575
if (AllowFontOps(xw, efGetFont)) {
2576
TScreen *screen = TScreenOf(xw);
2577
Bool success = True;
2579
char *base = buf + 1;
2583
num = ParseShiftedFont(xw, buf, &buf);
2585
|| num > fontMenu_lastBuiltin) {
2586
Bell(XkbBI_MinorError, 0);
2590
if (UsingRenderFont(xw)) {
2591
name = getFaceName(xw, False);
2594
if ((name = screen->MenuFontName(num)) == 0) {
2599
unparseputc1(xw, ANSI_OSC);
2600
unparseputs(xw, "50");
2603
unparseputc(xw, ';');
2605
/* identify the font-entry, unless it is the current one */
2607
unparseputc(xw, '#');
2608
sprintf(temp, "%d", num);
2609
unparseputs(xw, temp);
2611
unparseputc(xw, ' ');
2614
unparseputs(xw, name);
2617
unparseputc1(xw, final);
2623
ChangeFontRequest(XtermWidget xw, char *buf)
2625
if (AllowFontOps(xw, efSetFont)) {
2626
TScreen *screen = TScreenOf(xw);
2627
Bool success = True;
2633
* If the font specification is a "#", followed by an optional sign and
2634
* optional number, lookup the corresponding menu font entry.
2636
* Further, if the "#", etc., is followed by a font name, use that
2637
* to load the font entry.
2640
num = ParseShiftedFont(xw, buf, &buf);
2643
|| num > fontMenu_lastBuiltin) {
2644
Bell(XkbBI_MinorError, 0);
2648
* Skip past the optional number, and any whitespace to look
2649
* for a font specification within the control.
2651
while (isdigit(CharOf(*buf))) {
2654
while (isspace(CharOf(*buf))) {
2658
if (UsingRenderFont(xw)) {
2659
; /* there is only one font entry to load */
2664
* Normally there is no font specified in the control.
2665
* But if there is, simply overwrite the font entry.
2668
if ((buf = screen->MenuFontName(num)) == 0) {
2675
num = screen->menu_font_number;
2677
name = x_strtrim(buf);
2678
if (success && !IsEmpty(name)) {
2680
if (UsingRenderFont(xw)) {
2681
setFaceName(xw, name);
2682
xtermUpdateFontInfo(xw, True);
2686
memset(&fonts, 0, sizeof(fonts));
2688
SetVTFont(xw, num, True, &fonts);
2691
Bell(XkbBI_MinorError, 0);
2696
#endif /* OPT_SHIFT_FONTS */
2490
2698
/***====================================================================***/
2699
2907
#if OPT_SHIFT_FONTS
2700
if (!AllowFontOps(xw) && xw->misc.shift_fonts) {
2701
; /* disabled via resource or control-sequence */
2702
} else if (buf != 0 && !strcmp(buf, "?")) {
2703
int num = screen->menu_font_number;
2705
unparseputc1(xw, ANSI_OSC);
2706
unparseputs(xw, "50");
2708
if ((buf = screen->MenuFontName(num)) != 0) {
2709
unparseputc(xw, ';');
2710
unparseputs(xw, buf);
2712
unparseputc1(xw, final);
2714
} else if (buf != 0) {
2715
int num = screen->menu_font_number;
2718
memset(&fonts, 0, sizeof(fonts));
2721
* If the font specification is a "#", followed by an
2722
* optional sign and optional number, lookup the
2723
* corresponding menu font entry.
2728
if (*++buf == '+') {
2731
} else if (*buf == '-') {
2736
if (isdigit(CharOf(*buf))) {
2737
int val = atoi(buf);
2744
} else if (rel == 0) {
2749
num = lookupRelativeFontSize(xw,
2750
screen->menu_font_number, rel);
2754
|| num > fontMenu_lastBuiltin
2755
|| (buf = screen->MenuFontName(num)) == 0) {
2756
Bell(XkbBI_MinorError, 0);
2760
num = fontMenu_fontescape;
2763
SetVTFont(xw, num, True, &fonts);
2909
QueryFontRequest(xw, buf, final);
2910
} else if (xw->misc.shift_fonts) {
2911
ChangeFontRequest(xw, buf);
2765
2913
#endif /* OPT_SHIFT_FONTS */
3134
3282
#if OPT_TCAP_QUERY
3137
if ((*cp == 'q') && AllowTcapOps(xw)) {
3142
const char *parsed = ++cp;
3144
code = xtermcapKeycode(xw, &parsed, &state, &fkey);
3146
unparseputc1(xw, ANSI_DCS);
3148
unparseputc(xw, code >= 0 ? '1' : '0');
3150
unparseputc(xw, '+');
3151
unparseputc(xw, 'r');
3153
while (*cp != 0 && (code >= -1)) {
3155
break; /* no data found, error */
3157
for (tmp = cp; tmp != parsed; ++tmp)
3158
unparseputc(xw, *tmp);
3161
unparseputc(xw, '=');
3162
screen->tc_query_code = code;
3163
screen->tc_query_fkey = fkey;
3287
if (AllowTcapOps(xw, etSetTcap)) {
3288
set_termcap(xw, cp + 1);
3292
if (AllowTcapOps(xw, etGetTcap)) {
3297
const char *parsed = ++cp;
3299
code = xtermcapKeycode(xw, &parsed, &state, &fkey);
3301
unparseputc1(xw, ANSI_DCS);
3303
unparseputc(xw, code >= 0 ? '1' : '0');
3305
unparseputc(xw, '+');
3306
unparseputc(xw, 'r');
3308
while (*cp != 0 && (code >= -1)) {
3310
break; /* no data found, error */
3312
for (tmp = cp; tmp != parsed; ++tmp)
3313
unparseputc(xw, *tmp);
3316
unparseputc(xw, '=');
3317
screen->tc_query_code = code;
3318
screen->tc_query_fkey = fkey;
3164
3319
#if OPT_ISO_COLORS
3165
/* XK_COLORS is a fake code for the "Co" entry (maximum
3166
* number of colors) */
3167
if (code == XK_COLORS) {
3168
unparseputn(xw, NUM_ANSI_COLORS);
3320
/* XK_COLORS is a fake code for the "Co" entry (maximum
3321
* number of colors) */
3322
if (code == XK_COLORS) {
3323
unparseputn(xw, NUM_ANSI_COLORS);
3173
event.state = state;
3174
Input(xw, &event, False);
3326
if (code == XK_TCAPNAME) {
3327
unparseputs(xw, xterm_name);
3330
event.state = state;
3331
Input(xw, &event, False);
3333
screen->tc_query_code = -1;
3335
break; /* no match found, error */
3176
screen->tc_query_code = -1;
3178
break; /* no match found, error */
3182
if (*parsed == ';') {
3183
unparseputc(xw, *parsed++);
3185
code = xtermcapKeycode(xw, &parsed, &state, &fkey);
3339
if (*parsed == ';') {
3340
unparseputc(xw, *parsed++);
3342
code = xtermcapKeycode(xw, &parsed, &state, &fkey);
3345
unparseputc1(xw, ANSI_ST);
3188
unparseputc1(xw, ANSI_ST);
3468
3627
const char *name)
3471
TScreen *screen = TScreenOf(xw);
3472
Colormap cmap = xw->core.colormap;
3475
if (XParseColor(screen->display, cmap, name, &def)
3476
&& (XAllocColor(screen->display, cmap, &def)
3477
|| find_closest_color(screen->display, cmap, &def))
3478
&& (newName = x_strdup(name)) != 0) {
3479
if (COLOR_DEFINED(pNew, ndx))
3480
free(pNew->names[ndx]);
3481
SET_COLOR_VALUE(pNew, ndx, def.pixel);
3482
SET_COLOR_NAME(pNew, ndx, newName);
3483
TRACE(("AllocateTermColor #%d: %s (pixel %#lx)\n", ndx, newName, def.pixel));
3629
Bool result = False;
3631
if (AllowColorOps(xw, ecSetColor)) {
3633
TScreen *screen = TScreenOf(xw);
3634
Colormap cmap = xw->core.colormap;
3637
if (XParseColor(screen->display, cmap, name, &def)
3638
&& (XAllocColor(screen->display, cmap, &def)
3639
|| find_closest_color(screen->display, cmap, &def))
3640
&& (newName = x_strdup(name)) != 0) {
3641
if (COLOR_DEFINED(pNew, ndx))
3642
free(pNew->names[ndx]);
3643
SET_COLOR_VALUE(pNew, ndx, def.pixel);
3644
SET_COLOR_NAME(pNew, ndx, newName);
3645
TRACE(("AllocateTermColor #%d: %s (pixel %#lx)\n", ndx, newName, def.pixel));
3648
TRACE(("AllocateTermColor #%d: %s (failed)\n", ndx, name));
3486
TRACE(("AllocateTermColor #%d: %s (failed)\n", ndx, name));
3489
3653
/***====================================================================***/