~ubuntu-branches/ubuntu/trusty/xterm/trusty

« back to all changes in this revision

Viewing changes to button.c

  • Committer: Bazaar Package Importer
  • Author(s): Lorenzo De Liso
  • Date: 2011-02-12 15:58:09 UTC
  • mfrom: (1.4.11 upstream) (11.1.24 sid)
  • Revision ID: james.westby@ubuntu.com-20110212155809-cpkfynhfxzgbje2l
Tags: 268-1ubuntu1
* Merge from debian unstable (LP: #717301), remaining changes:
  - debian/patches/950_ubuntu_charclass_highlight.diff: Enabled URL
    highlighting
  - debian/patches/Add 951_uxterm_utf8_title.diff: Set utf8Titles to true by
    default when using uxterm, so that it displays utf8 directories in titles
    properly.  May cause issues with apps that use control sequences for
    updating the xterm titlebar - users should use xterm or set utf8Title
    to false in this case.
  - debian/gbp.conf: Use "Ubuntu" in "debian-branch" directly

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $XTermId: button.c,v 1.391 2010/11/11 11:50:13 tom Exp $ */
 
1
/* $XTermId: button.c,v 1.395 2011/02/09 10:15:46 tom Exp $ */
2
2
 
3
3
/*
4
 
 * Copyright 1999-2009,2010 by Thomas E. Dickey
 
4
 * Copyright 1999-2010,2011 by Thomas E. Dickey
5
5
 *
6
6
 *                         All Rights Reserved
7
7
 *
1261
1261
                (void) UTF8toLatin1(screen, data, size, &size);
1262
1262
                new_size += size + 1;
1263
1263
            }
1264
 
            new_text_list =
1265
 
                (char **) XtMalloc((Cardinal) sizeof(char *) * (unsigned) *text_list_count);
 
1264
            new_text_list = TypeXtMallocN(char *, *text_list_count);
1266
1265
            new_text_list[0] = tmp = XtMalloc((Cardinal) new_size);
1267
1266
            for (i = 0; i < (*text_list_count); ++i) {
1268
1267
                data = (Char *) (*text_list)[i];
1342
1341
                    if (copied[n] == ',')
1343
1342
                        ++count;
1344
1343
                }
1345
 
                result = (Atom *) XtMalloc(((2 * count) + 1)
1346
 
                                           * (Cardinal) sizeof(Atom));
 
1344
                result = TypeXtMallocN(Atom, (2 * count) + 1);
1347
1345
                if (result == NULL) {
1348
1346
                    TRACE(("Couldn't allocate selection types\n"));
1349
1347
                } else {
1355
1353
                        size_t len = strlen(listp);
1356
1354
 
1357
1355
                        if (len == 0) {
1358
 
                            ;
 
1356
                            /* EMPTY */ ;
1359
1357
                        }
1360
1358
#if OPT_WIDE_CHARS
1361
1359
                        else if (sameItem(listp, "UTF8")) {
1403
1401
        Atom *result;
1404
1402
 
1405
1403
        if (!overrideTargets(w, screen->utf8_select_types, &result)) {
1406
 
            result = (Atom *) XtMalloc((Cardinal) (5 * sizeof(Atom)));
 
1404
            result = TypeXtMallocN(Atom, 5);
1407
1405
            if (result == NULL) {
1408
1406
                TRACE(("Couldn't allocate utf-8 selection targets\n"));
1409
1407
            } else {
1437
1435
        Atom *result = 0;
1438
1436
 
1439
1437
        if (!overrideTargets(w, screen->eightbit_select_types, &result)) {
1440
 
            result = (Atom *) XtMalloc((Cardinal) (5 * sizeof(Atom)));
 
1438
            result = TypeXtMallocN(Atom, 5);
1441
1439
            if (result == NULL) {
1442
1440
                TRACE(("Couldn't allocate 8bit selection targets\n"));
1443
1441
            } else {
1682
1680
 
1683
1681
            if (num_params) {
1684
1682
                /* 'list' is freed in SelectionReceived */
1685
 
                list = XtNew(struct _SelectionList);
 
1683
                list = TypeXtMalloc(struct _SelectionList);
1686
1684
                if (list != 0) {
1687
1685
                    list->params = params;
1688
1686
                    list->count = num_params;
1984
1982
 
1985
1983
#if OPT_PASTE64
1986
1984
        if (screen->base64_paste) {
1987
 
            ;
 
1985
            /* EMPTY */ ;
1988
1986
        } else
1989
1987
#endif
1990
1988
#if OPT_READLINE
3633
3631
            Atom *my_targets = _SelectionTargets(w);
3634
3632
 
3635
3633
            TRACE(("XmuConvertStandardSelection - success\n"));
3636
 
            std_targets = (Atom *) (std_return);
 
3634
            std_targets = (Atom *) (void *) (std_return);
3637
3635
            *length = std_length + 6;
3638
3636
 
3639
 
            targetP = (Atom *) XtMalloc((Cardinal) (sizeof(Atom) * (*length)));
 
3637
            targetP = TypeXtMallocN(Atom, *length);
3640
3638
            allocP = targetP;
3641
3639
 
3642
3640
            *value = (XtPointer) targetP;
3821
3819
 
3822
3820
    if (count > screen->sel_atoms_size) {
3823
3821
        XtFree((char *) atoms);
3824
 
        atoms = (Atom *) XtMalloc((Cardinal) (count * sizeof(Atom)));
 
3822
        atoms = TypeXtMallocN(Atom, count);
3825
3823
        screen->selection_atoms = atoms;
3826
3824
        screen->sel_atoms_size = count;
3827
3825
    }
4046
4044
*/
4047
4045
 
4048
4046
/* Position: 32 - 255. */
4049
 
 
4050
 
static Char
 
4047
static int
4051
4048
BtnCode(XButtonEvent * event, int button)
4052
4049
{
4053
4050
    int result = (int) (32 + (KeyState(event->state) << 2));
4061
4058
            result += 32;
4062
4059
        result += button;
4063
4060
    }
4064
 
    return CharOf(result);
 
4061
    return result;
 
4062
}
 
4063
 
 
4064
static unsigned
 
4065
EmitButtonCode(TScreen * screen, Char * line, unsigned count, XButtonEvent * event)
 
4066
{
 
4067
    int value = BtnCode(event, screen->mouse_button);
 
4068
 
 
4069
    if (!screen->ext_mode_mouse || value < 128) {
 
4070
        line[count++] = CharOf(value);
 
4071
    } else {
 
4072
        line[count++] = CharOf(0xC0 + (value >> 6));
 
4073
        line[count++] = CharOf(0x80 + (value & 0x3F));
 
4074
    }
 
4075
    return count;
4065
4076
}
4066
4077
 
4067
4078
static void
4127
4138
        /* Button-Motion events */
4128
4139
        switch (event->type) {
4129
4140
        case ButtonPress:
4130
 
            line[count++] = BtnCode(event, screen->mouse_button = button);
 
4141
            screen->mouse_button = button;
 
4142
            count = EmitButtonCode(screen, line, count, event);
4131
4143
            break;
4132
4144
        case ButtonRelease:
4133
4145
            /*
4137
4149
             */
4138
4150
            if (button < 3)
4139
4151
                button = -1;
4140
 
            line[count++] = BtnCode(event, screen->mouse_button = button);
 
4152
            screen->mouse_button = button;
 
4153
            count = EmitButtonCode(screen, line, count, event);
4141
4154
            break;
4142
4155
        case MotionNotify:
4143
4156
            /* BTN_EVENT_MOUSE and ANY_EVENT_MOUSE modes send motion
4147
4160
                && (col == screen->mouse_col)) {
4148
4161
                changed = False;
4149
4162
            } else {
4150
 
                line[count++] = BtnCode(event, screen->mouse_button);
 
4163
                count = EmitButtonCode(screen, line, count, event);
4151
4164
            }
4152
4165
            break;
4153
4166
        default: