Ticket #2662: xterm-276-urxvt-mouse-mode.patch

File xterm-276-urxvt-mouse-mode.patch, 9.7 KB (added by egmont, 13 years ago)
  • button.c

    diff -ur xterm-276.orig/button.c xterm-276/button.c
    old new  
    176176static unsigned 
    177177EmitMousePosition(TScreen * screen, Char line[], unsigned count, int value) 
    178178{ 
    179     int mouse_limit = (screen->ext_mode_mouse 
     179    int mouse_limit = (screen->urxvt_ext_mode_mouse 
     180                       ? -1 
     181                       : screen->ext_mode_mouse 
    180182                       ? EXT_MOUSE_LIMIT 
    181183                       : MOUSE_LIMIT); 
    182184 
     
    192194     */ 
    193195    if (value == mouse_limit) { 
    194196        line[count++] = CharOf(0); 
     197    } else if (screen->urxvt_ext_mode_mouse) { 
     198        count += sprintf(line + count, "%d", value + 1); 
    195199    } else if (!screen->ext_mode_mouse || value < EXT_MOUSE_START) { 
    196200        line[count++] = CharOf(' ' + value + 1); 
    197201    } else { 
     
    202206    return count; 
    203207} 
    204208 
     209static unsigned 
     210EmitMousePositionSeparator(TScreen * screen, Char line[], unsigned count) 
     211{ 
     212    if (screen->urxvt_ext_mode_mouse) { 
     213        line[count++] = ';'; 
     214    } 
     215    return count; 
     216} 
     217 
    205218Bool 
    206219SendMousePosition(XtermWidget xw, XEvent * event) 
    207220{ 
     
    22422255    CELL cell; 
    22432256    unsigned count; 
    22442257    TScreen *screen = TScreenOf(xw); 
    2245     Char line[20]; 
     2258    Char line[64]; 
    22462259 
    22472260    if (use_cursor_loc) { 
    22482261        cell = screen->cursorp; 
     
    22642277            if (isSameCELL(&(screen->rawPos), &(screen->startSel)) 
    22652278                && isSameCELL(&cell, &(screen->endSel))) { 
    22662279                /* Use short-form emacs select */ 
    2267                 line[count++] = 't'; 
     2280                if (!screen->urxvt_ext_mode_mouse) { 
     2281                    line[count++] = 't'; 
     2282                } 
    22682283                count = EmitMousePosition(screen, line, count, screen->endSel.col); 
     2284                count = EmitMousePositionSeparator(screen, line, count); 
    22692285                count = EmitMousePosition(screen, line, count, screen->endSel.row); 
     2286                if (screen->urxvt_ext_mode_mouse) { 
     2287                    line[count++] = 't'; 
     2288                } 
    22702289            } else { 
    22712290                /* long-form, specify everything */ 
    2272                 line[count++] = 'T'; 
     2291                if (!screen->urxvt_ext_mode_mouse) { 
     2292                    line[count++] = 'T'; 
     2293                } 
    22732294                count = EmitMousePosition(screen, line, count, screen->startSel.col); 
     2295                count = EmitMousePositionSeparator(screen, line, count); 
    22742296                count = EmitMousePosition(screen, line, count, screen->startSel.row); 
     2297                count = EmitMousePositionSeparator(screen, line, count); 
    22752298                count = EmitMousePosition(screen, line, count, screen->endSel.col); 
     2299                count = EmitMousePositionSeparator(screen, line, count); 
    22762300                count = EmitMousePosition(screen, line, count, screen->endSel.row); 
     2301                count = EmitMousePositionSeparator(screen, line, count); 
    22772302                count = EmitMousePosition(screen, line, count, cell.col); 
     2303                count = EmitMousePositionSeparator(screen, line, count); 
    22782304                count = EmitMousePosition(screen, line, count, cell.row); 
     2305                if (screen->urxvt_ext_mode_mouse) { 
     2306                    line[count++] = 'T'; 
     2307                } 
    22792308            } 
    22802309            v_write(screen->respond, line, count); 
    22812310            TrackText(xw, &zeroCELL, &zeroCELL); 
     
    40664095} 
    40674096 
    40684097static unsigned 
    4069 EmitButtonCode(TScreen * screen, Char * line, unsigned count, XButtonEvent * event) 
     4098EmitButtonCode(TScreen * screen, Char * line, unsigned count, int value) 
    40704099{ 
    4071     int value = BtnCode(event, screen->mouse_button); 
    4072  
    4073     if (!screen->ext_mode_mouse || value < 128) { 
     4100    if (screen->urxvt_ext_mode_mouse) { 
     4101        count += sprintf(line + count, "%d", value); 
     4102    } else if (!screen->ext_mode_mouse || value < 128) { 
    40744103        line[count++] = CharOf(value); 
    40754104    } else { 
    40764105        line[count++] = CharOf(0xC0 + (value >> 6)); 
     
    40844113{ 
    40854114    TScreen *screen = TScreenOf(xw); 
    40864115    int pty = screen->respond; 
    4087     int mouse_limit = screen->ext_mode_mouse ? EXT_MOUSE_LIMIT : MOUSE_LIMIT; 
    4088     Char line[10]; 
     4116    int mouse_limit = screen->urxvt_ext_mode_mouse ? -1 : screen->ext_mode_mouse ? EXT_MOUSE_LIMIT : MOUSE_LIMIT; 
     4117    Char line[32]; 
    40894118    int row, col; 
    40904119    int button; 
    40914120    unsigned count = 0; 
     
    41114140    else if (col > screen->max_col) 
    41124141        col = screen->max_col; 
    41134142 
    4114     /* Limit to representable mouse dimensions */ 
    4115     if (row > mouse_limit) 
    4116         row = mouse_limit; 
    4117     if (col > mouse_limit) 
    4118         col = mouse_limit; 
     4143    if (mouse_limit > 0) { 
     4144        /* Limit to representable mouse dimensions */ 
     4145        if (row > mouse_limit) 
     4146            row = mouse_limit; 
     4147        if (col > mouse_limit) 
     4148            col = mouse_limit; 
     4149    } 
    41194150 
    41204151    /* Build key sequence starting with \E[M */ 
    41214152    if (screen->control_eight_bits) { 
     
    41334164        line[count++] = '>'; 
    41344165    } 
    41354166#endif 
    4136     line[count++] = 'M'; 
     4167    if (!screen->urxvt_ext_mode_mouse) { 
     4168        line[count++] = 'M'; 
     4169    } 
    41374170 
    41384171    /* Add event code to key sequence */ 
    41394172    if (screen->send_mouse_pos == X10_MOUSE) { 
    4140         line[count++] = CharOf(' ' + button); 
     4173        count = EmitButtonCode(screen, line, count, CharOf(' ' + button)); 
    41414174    } else { 
    41424175        /* Button-Motion events */ 
    41434176        switch (event->type) { 
    41444177        case ButtonPress: 
    41454178            screen->mouse_button = button; 
    4146             count = EmitButtonCode(screen, line, count, event); 
     4179            count = EmitButtonCode(screen, line, count, BtnCode(event, button)); 
    41474180            break; 
    41484181        case ButtonRelease: 
    41494182            /* 
     
    41544187            if (button < 3) 
    41554188                button = -1; 
    41564189            screen->mouse_button = button; 
    4157             count = EmitButtonCode(screen, line, count, event); 
     4190            count = EmitButtonCode(screen, line, count, BtnCode(event, button)); 
    41584191            break; 
    41594192        case MotionNotify: 
    41604193            /* BTN_EVENT_MOUSE and ANY_EVENT_MOUSE modes send motion 
     
    41644197                && (col == screen->mouse_col)) { 
    41654198                changed = False; 
    41664199            } else { 
    4167                 count = EmitButtonCode(screen, line, count, event); 
     4200                count = EmitButtonCode(screen, line, count, BtnCode(event, screen->mouse_button)); 
    41684201            } 
    41694202            break; 
    41704203        default: 
     
    41804213        TRACE(("mouse at %d,%d button+mask = %#x\n", row, col, line[count - 1])); 
    41814214 
    41824215        /* Add pointer position to key sequence */ 
     4216        count = EmitMousePositionSeparator(screen, line, count); 
    41834217        count = EmitMousePosition(screen, line, count, col); 
     4218        count = EmitMousePositionSeparator(screen, line, count); 
    41844219        count = EmitMousePosition(screen, line, count, row); 
    41854220 
     4221        if (screen->urxvt_ext_mode_mouse) { 
     4222            line[count++] = 'M'; 
     4223        } 
     4224 
    41864225        /* Transmit key sequence to process running under xterm */ 
    41874226        v_write(pty, line, count); 
    41884227    } 
  • charproc.c

    diff -ur xterm-276.orig/charproc.c xterm-276/charproc.c
    old new  
    43604360        case SET_EXT_MODE_MOUSE: 
    43614361            set_bool_mode(screen->ext_mode_mouse); 
    43624362            break; 
     4363        case SET_URXVT_EXT_MODE_MOUSE: 
     4364            set_bool_mode(screen->urxvt_ext_mode_mouse); 
     4365            break; 
    43634366        case 1010:              /* rxvt */ 
    43644367            set_bool_mode(screen->scrollttyoutput); 
    43654368            update_scrollttyoutput(); 
     
    45654568        case SET_EXT_MODE_MOUSE: 
    45664569            DoSM(DP_X_EXT_MOUSE, screen->ext_mode_mouse); 
    45674570            break; 
     4571        case SET_URXVT_EXT_MODE_MOUSE: 
     4572            DoSM(DP_X_EXT_MOUSE, screen->urxvt_ext_mode_mouse); 
     4573            break; 
    45684574        case 1048: 
    45694575            if (!xw->misc.titeInhibit) { 
    45704576                CursorSave(xw); 
     
    47364742        case SET_EXT_MODE_MOUSE: 
    47374743            DoRM(DP_X_EXT_MOUSE, screen->ext_mode_mouse); 
    47384744            break; 
     4745        case SET_URXVT_EXT_MODE_MOUSE: 
     4746            DoRM(DP_X_EXT_MOUSE, screen->urxvt_ext_mode_mouse); 
     4747            break; 
    47394748        case 1048: 
    47404749            if (!xw->misc.titeInhibit) { 
    47414750                CursorRestore(xw); 
     
    83858394        screen->send_mouse_pos = MOUSE_OFF; 
    83868395        screen->send_focus_pos = OFF; 
    83878396        screen->ext_mode_mouse = OFF; 
     8397        screen->urxvt_ext_mode_mouse = OFF; 
    83888398        screen->waitingForTrackInfo = False; 
    83898399        screen->eventMode = NORMAL; 
    83908400 
  • ctlseqs.ms

    diff -ur xterm-276.orig/ctlseqs.ms xterm-276/ctlseqs.ms
    old new  
    20102010#define SET_FOCUS_EVENT_MOUSE       1004 
    20112011 
    20122012#define SET_EXT_MODE_MOUSE          1005 
     2013 
     2014#define SET_URXVT_EXT_MODE_MOUSE    1015 
    20132015.DE 
    20142016.br 
    20152017The motion reporting modes are strictly \fIxterm\fP extensions, and are not 
  • ctlseqs.txt

    diff -ur xterm-276.orig/ctlseqs.txt xterm-276/ctlseqs.txt
    old new  
    13561356 
    13571357                #define SET_EXT_MODE_MOUSE          1005 
    13581358 
     1359                #define SET_URXVT_EXT_MODE_MOUSE    1015 
     1360 
    13591361The motion reporting modes are strictly xterm extensions, and are not 
    13601362part of any standard, though they are analogous to the DEC VT200 DECELR 
    13611363locator reports. 
  • xterm-276

    diff -ur xterm-276.orig/misc.c xterm-276/misc.c
    old new  
    37763776        case SET_EXT_MODE_MOUSE: 
    37773777            result = MdBool(screen->ext_mode_mouse); 
    37783778            break; 
     3779        case SET_URXVT_EXT_MODE_MOUSE: 
     3780            result = MdBool(screen->urxvt_ext_mode_mouse); 
     3781            break; 
    37793782        case 1010:              /* rxvt */ 
    37803783            result = MdBool(screen->scrollttyoutput); 
    37813784            break; 
  • xterm-276

    diff -ur xterm-276.orig/ptyx.h xterm-276/ptyx.h
    old new  
    16351635        unsigned        send_mouse_pos; /* user wants mouse transition  */ 
    16361636                                        /* and position information     */ 
    16371637        Boolean         ext_mode_mouse; /* support large terminals      */ 
     1638        Boolean         urxvt_ext_mode_mouse; /* support large terminals */ 
    16381639        Boolean         send_focus_pos; /* user wants focus in/out info */ 
    16391640        Boolean         quiet_grab;     /* true if no cursor change on focus */ 
    16401641#if OPT_PASTE64 
  • xcharmouse.h

    diff -ur xterm-276.orig/xcharmouse.h xterm-276/xcharmouse.h
    old new  
    4848 
    4949/* Extend mouse tracking for terminals wider(taller) than 223 cols(rows) */ 
    5050#define SET_EXT_MODE_MOUSE          1005 /* compatible with above */ 
     51#define SET_URXVT_EXT_MODE_MOUSE    1015 
    5152 
    5253#define SET_BUTTON1_MOVE_POINT      2001 /* click1 emit Esc seq to move point*/ 
    5354#define SET_BUTTON2_MOVE_POINT      2002 /* press2 emit Esc seq to move point*/