341
341
#if OPT_SCROLL_LOCK
342
342
{ "scroll-lock", HandleScrollLock },
344
#if OPT_SELECTION_OPS
345
{ "exec-formatted", HandleExecFormatted },
346
{ "exec-selectable", HandleExecSelectable },
347
{ "insert-formatted", HandleInsertFormatted },
348
{ "insert-selectable", HandleInsertSelectable },
344
350
#if OPT_SHIFT_FONTS
345
351
{ "larger-vt-font", HandleLargerFont },
346
352
{ "smaller-vt-font", HandleSmallerFont },
434
440
Bres(XtNtrimSelection, XtCTrimSelection, screen.trim_selection, False),
435
441
Bres(XtNunderLine, XtCUnderLine, screen.underline, True),
436
442
Bres(XtNvisualBell, XtCVisualBell, screen.visualbell, False),
443
Bres(XtNvisualBellLine, XtCVisualBellLine, screen.flash_line, False),
445
Dres(XtNscaleHeight, XtCScaleHeight, screen.scale_height, "1.0"),
438
447
Ires(XtNbellSuppressTime, XtCBellSuppressTime, screen.bellSuppressTime, BELLSUPPRESSMSEC),
439
448
Ires(XtNfontWarnings, XtCFontWarnings, misc.fontWarnings, fwResource),
471
480
screen.disallowedTcapOps, DEF_DISALLOWED_TCAP),
472
481
Sres(XtNdisallowedWindowOps, XtCDisallowedWindowOps,
473
482
screen.disallowedWinOps, DEF_DISALLOWED_WINDOW),
483
Sres(XtNeightBitMeta, XtCEightBitMeta, screen.eight_bit_meta_s, DEF_8BIT_META),
474
484
Sres(XtNeightBitSelectTypes, XtCEightBitSelectTypes,
475
485
screen.eightbit_select_types, NULL),
476
486
Sres(XtNfont, XtCFont, misc.default_font.f_n, DEFFONT),
1568
1569
if (sp->nextstate == CASE_PRINT) {
1569
1570
SafeAlloc(IChar, sp->print_area, sp->print_used, sp->print_size);
1570
1571
if (new_string == 0) {
1572
"Cannot allocate %lu bytes for printable text\n",
1573
(unsigned long) new_length);
1572
xtermWarning("Cannot allocate %lu bytes for printable text\n",
1573
(unsigned long) new_length);
1576
1576
#if OPT_VT52_MODE
1606
1606
if (sp->parsestate == sos_table) {
1607
1607
SafeAlloc(Char, sp->string_area, sp->string_used, sp->string_size);
1608
1608
if (new_string == 0) {
1610
"Cannot allocate %lu bytes for string mode %d\n",
1611
(unsigned long) new_length, sp->string_mode);
1609
xtermWarning("Cannot allocate %lu bytes for string mode %d\n",
1610
(unsigned long) new_length, sp->string_mode);
1614
1613
#if OPT_WIDE_CHARS
2762
2761
ResetState(sp);
2764
case CASE_SL: /* ISO 6429, non-DEC */
2765
TRACE(("CASE_SL - scroll left\n"));
2766
if ((count = param[0]) < 1)
2768
xtermScrollLR(xw, count, True);
2772
case CASE_SR: /* ISO 6429, non-DEC */
2773
TRACE(("CASE_SR - scroll right\n"));
2774
if ((count = param[0]) < 1)
2776
xtermScrollLR(xw, count, False);
2781
TRACE(("CASE_DC - delete column\n"));
2782
if (screen->terminal_id >= 400) {
2783
if ((count = param[0]) < 1)
2785
xtermColScroll(xw, count, True, screen->cur_col);
2791
TRACE(("CASE_IC - insert column\n"));
2792
if (screen->terminal_id >= 400) {
2793
if ((count = param[0]) < 1)
2795
xtermColScroll(xw, count, False, screen->cur_col);
2801
TRACE(("CASE_BI - back index\n"));
2802
if (screen->terminal_id >= 400) {
2803
xtermColIndex(xw, True);
2809
TRACE(("CASE_FI - forward index\n"));
2810
if (screen->terminal_id >= 400) {
2811
xtermColIndex(xw, False);
2766
2817
TRACE(("CASE_IND - index\n"));
2767
2818
xtermIndex(xw, 1);
3732
3784
return nextPtyData(screen, VTbuffer);
3735
#if OPT_INPUT_METHOD
3787
#if OPT_I18N_SUPPORT && OPT_INPUT_METHOD
3737
3789
* For OverTheSpot, client has to inform the position for XIM preedit.
3740
PreeditPosition(TScreen * screen)
3792
PreeditPosition(XtermWidget xw)
3794
TInput *input = lookupTInput(xw, (Widget) xw);
3795
TScreen *screen = TScreenOf(xw);
3744
3798
XVaNestedList list;
3747
3801
&& (ld = getLineData(screen, screen->cur_row)) != 0) {
3748
3802
spot.x = (short) LineCursorX(screen, ld, screen->cur_col);
3749
spot.y = (short) (CursorY(screen, screen->cur_row) + screen->fs_ascent);
3803
spot.y = (short) (CursorY(screen, screen->cur_row) + xw->misc.xim_fs_ascent);
3750
3804
list = XVaCreateNestedList(0,
3751
3805
XNSpotLocation, &spot,
3752
3806
XNForeground, T_COLOR(screen, TEXT_FG),
3753
3807
XNBackground, T_COLOR(screen, TEXT_BG),
3755
XSetICValues(screen->xic, XNPreeditAttributes, list, NULL);
3809
XSetICValues(input->xic, XNPreeditAttributes, list, (void *) 0);
4356
4410
case SET_EXT_MODE_MOUSE:
4357
set_bool_mode(screen->ext_mode_mouse);
4412
case SET_SGR_EXT_MODE_MOUSE:
4414
case SET_URXVT_EXT_MODE_MOUSE:
4416
* Rather than choose an arbitrary precedence among the coordinate
4417
* modes, they are mutually exclusive. For consistency, a reset is
4418
* only effective against the matching mode.
4421
screen->extend_coords = param[i];
4422
} else if (screen->extend_coords == param[i]) {
4423
screen->extend_coords = 0;
4359
4426
case 1010: /* rxvt */
4360
4427
set_bool_mode(screen->scrollttyoutput);
5857
5936
/* *INDENT-ON* */
5859
String res = TScreenOf(wreq)->onClick[item];
5860
String next = x_skip_nonblanks(res);
5938
TScreen *screen = TScreenOf(xw);
5939
String next = x_skip_nonblanks(value);
5863
TScreenOf(wnew)->selectMap[item] = NSELECTUNITS;
5942
screen->selectMap[item] = NSELECTUNITS;
5864
5943
for (n = 0; n < XtNumber(table); ++n) {
5865
if (!x_strncasecmp(table[n].name, res, (unsigned) (next - res))) {
5866
TScreenOf(wnew)->selectMap[item] = table[n].code;
5944
if (!x_strncasecmp(table[n].name, value, (unsigned) (next - value))) {
5945
screen->selectMap[item] = table[n].code;
5867
5946
#if OPT_SELECT_REGEX
5868
5947
if (table[n].code == Select_REGEX) {
5869
TScreenOf(wnew)->selectExpr[item] = x_strtrim(next);
5870
TRACE(("Parsed regex \"%s\"\n", TScreenOf(wnew)->selectExpr[item]));
5948
screen->selectExpr[item] = x_strtrim(next);
5949
TRACE(("Parsed regex \"%s\"\n", screen->selectExpr[item]));
6183
6276
init_Bres(screen.scrollttyoutput);
6184
6277
init_Bres(screen.scrollkey);
6279
init_Dres(screen.scale_height);
6280
if (TScreenOf(wnew)->scale_height < 0.9)
6281
TScreenOf(wnew)->scale_height = (float) 0.9;
6282
if (TScreenOf(wnew)->scale_height > 1.5)
6283
TScreenOf(wnew)->scale_height = (float) 1.5;
6186
6285
init_Bres(misc.autoWrap);
6187
6286
init_Bres(misc.login_shell);
6188
6287
init_Bres(misc.reverseWrap);
6686
6786
xtermSaveVTFonts(wnew);
6687
6787
#endif /* OPT_WIDE_CHARS */
6789
init_Sres(screen.eight_bit_meta_s);
6790
wnew->screen.eight_bit_meta =
6791
extendedBoolean(request->screen.eight_bit_meta_s, tbl8BitMeta, uLast);
6792
if (wnew->screen.eight_bit_meta == ebLocale) {
6794
if (xtermEnvUTF8()) {
6795
wnew->screen.eight_bit_meta = ebFalse;
6796
TRACE(("...eightBitMeta is false due to locale\n"));
6798
#endif /* OPT_WIDE_CHARS */
6800
wnew->screen.eight_bit_meta = ebTrue;
6801
TRACE(("...eightBitMeta is true due to locale\n"));
6689
6805
init_Bres(screen.always_bold_mode);
6690
6806
init_Bres(screen.bold_mode);
6691
6807
init_Bres(screen.underline);
7015
7152
screen->menu_font_number)) {
7016
7153
if (XmuCompareISOLatin1(myfont->f_n, DEFFONT) != 0) {
7017
7154
char *use_font = x_strdup(DEFFONT);
7019
"%s: unable to open font \"%s\", trying \"%s\"....\n",
7020
ProgramName, myfont->f_n, use_font);
7155
xtermWarning("unable to open font \"%s\", trying \"%s\"....\n",
7156
myfont->f_n, use_font);
7021
7157
(void) xtermLoadFont(xw,
7022
7158
xtermFontName(use_font),
7367
7501
XPointer client_data GCC_UNUSED,
7368
7502
XPointer call_data GCC_UNUSED)
7370
TScreenOf(term)->xic = NULL;
7372
XRegisterIMInstantiateCallback(XtDisplay(term), NULL, NULL, NULL,
7504
XtermWidget xw = term;
7505
TInput *input = lookupTInput(xw, (Widget) xw);
7507
TRACE(("xim_destroy_cb im=%lx, client=%p, call=%p\n",
7508
(long) im, client_data, call_data));
7511
XRegisterIMInstantiateCallback(XtDisplay(xw), NULL, NULL, NULL,
7373
7512
xim_instantiate_cb, NULL);
7375
7514
#endif /* X11R6+ */
7517
xim_create_fs(XtermWidget xw)
7519
XFontStruct **fonts;
7520
char **font_name_list;
7521
char **missing_charset_list;
7523
int missing_charset_count;
7526
if (xw->misc.xim_fs == 0) {
7527
xw->misc.xim_fs = XCreateFontSet(XtDisplay(xw),
7529
&missing_charset_list,
7530
&missing_charset_count,
7532
if (xw->misc.xim_fs == NULL) {
7533
xtermWarning("Preparation of font set "
7534
"\"%s\" for XIM failed.\n", xw->misc.f_x);
7535
xw->misc.xim_fs = XCreateFontSet(XtDisplay(xw),
7537
&missing_charset_list,
7538
&missing_charset_count,
7542
if (xw->misc.xim_fs == NULL) {
7543
xtermWarning("Preparation of default font set "
7544
"\"%s\" for XIM failed.\n", DEFXIMFONT);
7545
cleanupInputMethod(xw);
7546
xw->misc.cannot_im = True;
7548
(void) XExtentsOfFontSet(xw->misc.xim_fs);
7549
j = (unsigned) XFontsOfFontSet(xw->misc.xim_fs, &fonts, &font_name_list);
7550
for (i = 0, xw->misc.xim_fs_ascent = 0; i < j; i++) {
7551
if (xw->misc.xim_fs_ascent < (*fonts)->ascent)
7552
xw->misc.xim_fs_ascent = (*fonts)->ascent;
7555
return (Boolean) ! (xw->misc.cannot_im);
7378
xim_real_init(XtermWidget xw)
7559
xim_create_xic(XtermWidget xw, Widget theInput)
7380
TScreen *screen = TScreenOf(xw);
7561
Display *myDisplay = XtDisplay(theInput);
7562
Window myWindow = XtWindow(theInput);
7382
char *p, *s, *t, *ns, *end, buf[32];
7564
char *p = NULL, *s, *t, *ns, *end, buf[32];
7383
7565
XIMStyles *xim_styles;
7384
7566
XIMStyle input_style = 0;
7397
7579
"Root", (XIMPreeditNothing | XIMStatusNothing)
7582
TInput *input = lookupTInput(xw, theInput);
7403
7584
if (xw->misc.cannot_im) {
7407
if (!xw->misc.input_method || !*xw->misc.input_method) {
7408
if ((p = XSetLocaleModifiers("")) != NULL && *p)
7409
screen->xim = XOpenIM(XtDisplay(xw), NULL, NULL, NULL);
7589
for (i = 0; i < NINPUTWIDGETS; ++i) {
7590
if (xw->misc.inputs[i].w == 0) {
7591
input = xw->misc.inputs + i;
7592
input->w = theInput;
7599
xtermWarning("attempted to add too many input widgets\n");
7603
TRACE(("xim_real_init\n"));
7605
if (IsEmpty(xw->misc.input_method)) {
7606
if ((p = XSetLocaleModifiers("")) != NULL && *p) {
7607
input->xim = XOpenIM(myDisplay, NULL, NULL, NULL);
7411
7610
s = xw->misc.input_method;
7412
7611
i = 5 + (unsigned) strlen(s);
7447
if (screen->xim == NULL
7647
if (input->xim == NULL
7448
7648
&& (p = XSetLocaleModifiers("@im=none")) != NULL
7450
screen->xim = XOpenIM(XtDisplay(xw), NULL, NULL, NULL);
7650
input->xim = XOpenIM(myDisplay, NULL, NULL, NULL);
7454
fprintf(stderr, "Failed to open input method\n");
7654
xtermWarning("Failed to open input method\n");
7457
TRACE(("VTInitI18N opened input method\n"));
7657
TRACE(("VTInitI18N opened input method:%s\n", NonNull(p)));
7459
if (XGetIMValues(screen->xim, XNQueryInputStyle, &xim_styles, NULL)
7659
if (XGetIMValues(input->xim, XNQueryInputStyle, &xim_styles, (void *) 0)
7461
7661
|| !xim_styles->count_styles) {
7462
fprintf(stderr, "input method doesn't support any style\n");
7463
cleanupInputMethod(screen);
7662
xtermWarning("input method doesn't support any style\n");
7663
cleanupInputMethod(xw);
7464
7664
xw->misc.cannot_im = True;
7529
7727
* same font cannot be used for XIM preedit.
7531
7729
if (input_style != (XIMPreeditNothing | XIMStatusNothing)) {
7532
char **missing_charset_list;
7533
int missing_charset_count;
7535
7730
XVaNestedList p_list;
7538
XFontStruct **fonts;
7539
char **font_name_list;
7541
screen->fs = XCreateFontSet(XtDisplay(xw),
7543
&missing_charset_list,
7544
&missing_charset_count,
7546
if (screen->fs == NULL) {
7547
fprintf(stderr, "Preparation of font set "
7548
"\"%s\" for XIM failed.\n", xw->misc.f_x);
7549
screen->fs = XCreateFontSet(XtDisplay(xw),
7551
&missing_charset_list,
7552
&missing_charset_count,
7555
if (screen->fs == NULL) {
7556
fprintf(stderr, "Preparation of default font set "
7557
"\"%s\" for XIM failed.\n", DEFXIMFONT);
7558
cleanupInputMethod(screen);
7559
xw->misc.cannot_im = True;
7562
(void) XExtentsOfFontSet(screen->fs);
7563
j = (unsigned) XFontsOfFontSet(screen->fs, &fonts, &font_name_list);
7564
for (i = 0, screen->fs_ascent = 0; i < j; i++) {
7565
if (screen->fs_ascent < (*fonts)->ascent)
7566
screen->fs_ascent = (*fonts)->ascent;
7568
p_list = XVaCreateNestedList(0,
7569
XNSpotLocation, &spot,
7570
XNFontSet, screen->fs,
7572
screen->xic = XCreateIC(screen->xim,
7573
XNInputStyle, input_style,
7574
XNClientWindow, XtWindow(xw),
7575
XNFocusWindow, XtWindow(xw),
7576
XNPreeditAttributes, p_list,
7734
if (xim_create_fs(xw)) {
7735
p_list = XVaCreateNestedList(0,
7736
XNSpotLocation, &spot,
7737
XNFontSet, xw->misc.xim_fs,
7739
input->xic = XCreateIC(input->xim,
7740
XNInputStyle, input_style,
7741
XNClientWindow, myWindow,
7742
XNFocusWindow, myWindow,
7743
XNPreeditAttributes, p_list,
7579
screen->xic = XCreateIC(screen->xim, XNInputStyle, input_style,
7580
XNClientWindow, XtWindow(xw),
7581
XNFocusWindow, XtWindow(xw),
7747
input->xic = XCreateIC(input->xim, XNInputStyle, input_style,
7748
XNClientWindow, myWindow,
7749
XNFocusWindow, myWindow,
7586
fprintf(stderr, "Failed to create input context\n");
7587
cleanupInputMethod(screen);
7754
xtermWarning("Failed to create input context\n");
7755
cleanupInputMethod(xw);
7589
7757
#if defined(USE_XIM_INSTANTIATE_CB)
7593
7761
destroy_cb.callback = xim_destroy_cb;
7594
7762
destroy_cb.client_data = NULL;
7595
if (XSetIMValues(screen->xim, XNDestroyCallback, &destroy_cb, NULL))
7596
fprintf(stderr, "Could not set destroy callback to IM\n");
7763
if (XSetIMValues(input->xim,
7767
xtermWarning("Could not set destroy callback to IM\n");
8533
8726
if (numbers != 2) {
8534
fprintf(stderr, errfmt, ProgramName, "bad value number",
8727
xtermWarning(FMT, "bad value number", s, i);
8536
8728
} else if (SetCharacterClassRange(low, high, acc) != 0) {
8537
fprintf(stderr, errfmt, ProgramName, "bad range", s, i);
8729
xtermWarning(FMT, "bad range", s, i);
8540
8732
low = high = -1;
8561
8753
if (numbers < 1 || numbers > 2) {
8562
fprintf(stderr, errfmt, ProgramName, "bad value number", s, i);
8754
xtermWarning(FMT, "bad value number", s, i);
8563
8755
} else if (SetCharacterClassRange(low, high, acc) != 0) {
8564
fprintf(stderr, errfmt, ProgramName, "bad range", s, i);
8756
xtermWarning(FMT, "bad range", s, i);
8652
8845
XtermWidget xw;
8654
TRACE(("Handle ignore for %p\n", (void *) w));
8847
TRACE(("Handle ignore for %p %s\n",
8848
(void *) w, visibleEventType(event->type)));
8655
8849
if ((xw = getXtermWidget(w)) != 0) {
8656
8850
/* do nothing, but check for funny escape sequences */
8657
8851
(void) SendMousePosition(xw, event);