Develop and Download Open Source Software

Browse Subversion Repository

Diff of /trunk/teraterm/teraterm/vtterm.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3993 by doda, Fri Aug 13 18:07:02 2010 UTC revision 3997 by doda, Sat Aug 14 18:37:44 2010 UTC
# Line 42  Line 42 
42  #define NParamMax 16  #define NParamMax 16
43  #define IntCharMax 5  #define IntCharMax 5
44    
45    /* DEC Locator Flag */
46    #define DecLocatorOneShot    1
47    #define DecLocatorPixel      2
48    #define DecLocatorButtonDown 4
49    #define DecLocatorButtonUp   8
50    #define DecLocatorFiltered   16
51    
52  void VisualBell();  void VisualBell();
53    
54  /* character attribute */  /* character attribute */
# Line 55  static BOOL AutoWrapMode; Line 62  static BOOL AutoWrapMode;
62  static BOOL FocusReportMode;  static BOOL FocusReportMode;
63  static BOOL AltScr;  static BOOL AltScr;
64  BOOL BracketedPaste;  BOOL BracketedPaste;
 int MouseReportMode;  
65    
66  // save/restore cursor  // save/restore cursor
67  typedef struct {  typedef struct {
# Line 120  static BOOL DirectPrn = FALSE; Line 126  static BOOL DirectPrn = FALSE;
126  static BYTE NewKeyStr[FuncKeyStrMax];  static BYTE NewKeyStr[FuncKeyStrMax];
127  static int NewKeyId, NewKeyLen;  static int NewKeyId, NewKeyLen;
128    
129    /* Mouse Report */
130    int MouseReportMode;
131    unsigned int DecLocatorFlag;
132    int LastX, LastY;
133    int ButtonStat;
134    
135  static _locale_t CLocale = NULL;  static _locale_t CLocale = NULL;
136    
137  void ResetSBuffer(PStatusBuff sbuff)  void ResetSBuffer(PStatusBuff sbuff)
# Line 196  void ResetTerminal() /*reset variables b Line 208  void ResetTerminal() /*reset variables b
208    Send8BitMode = ts.Send8BitCtrl;    Send8BitMode = ts.Send8BitCtrl;
209    FocusReportMode = FALSE;    FocusReportMode = FALSE;
210    MouseReportMode = IdMouseTrackNone;    MouseReportMode = IdMouseTrackNone;
211      DecLocatorFlag = 0;
212    
213      LastX = 0;
214      LastY = 0;
215      ButtonStat = 0;
216    
217    if (CLocale == NULL) {    if (CLocale == NULL) {
218      CLocale = _create_locale(LC_ALL, "C");      CLocale = _create_locale(LC_ALL, "C");
# Line 2288  void CSSetAttr()               // SGR Line 2305  void CSSetAttr()               // SGR
2305            case 1000: // Mouse Tracking            case 1000: // Mouse Tracking
2306            case 1001: // Hilite Mouse Tracking            case 1001: // Hilite Mouse Tracking
2307            case 1002: // Button-Event Mouse Tracking            case 1002: // Button-Event Mouse Tracking
2308            case 1003: MouseReportMode = IdMouseTrackNone; break; // Any-Event Mouse Tracking            case 1003: // Any-Event Mouse Tracking
2309                MouseReportMode = IdMouseTrackNone;
2310                break;
2311            case 1004: FocusReportMode = FALSE; break; // Focus Report            case 1004: FocusReportMode = FALSE; break; // Focus Report
2312            case 1047: // Alternate Screen Buffer            case 1047: // Alternate Screen Buffer
2313              if ((ts.TermFlag & TF_ALTSCR) && AltScr) {              if ((ts.TermFlag & TF_ALTSCR) && AltScr) {
# Line 2414  void CSSetAttr()               // SGR Line 2433  void CSSetAttr()               // SGR
2433      }      }
2434    }    }
2435    
2436      void CSQuote(BYTE b)
2437      {
2438        switch (b) {
2439          case 'w': // Enable Filter Rectangle (DECEFR)
2440            break;
2441    
2442          case 'z': // Enable DEC Locator reporting (DECELR)
2443            if (Param[1] < 0) {
2444              Param[1] = 0;
2445            }
2446            switch (Param[1]) {
2447            case 0:
2448              if (MouseReportMode == IdMouseTrackDECELR) {
2449                MouseReportMode = IdMouseTrackNone;
2450              }
2451              break;
2452            case 1:
2453              if (ts.MouseEventTracking) {
2454                MouseReportMode = IdMouseTrackDECELR;
2455                DecLocatorFlag &= ~DecLocatorOneShot;
2456              }
2457              break;
2458            case 2:
2459              if (ts.MouseEventTracking) {
2460                MouseReportMode = IdMouseTrackDECELR;
2461                DecLocatorFlag |= DecLocatorOneShot;
2462              }
2463              break;
2464            }
2465            if (NParam > 1 && Param[2] == 1) {
2466              DecLocatorFlag |= DecLocatorPixel;
2467            }
2468            break;
2469    
2470          case '{': // Select Locator Events (DECSLE)
2471            if (Param[1] < 0) {
2472              Param[1] = 0;
2473            }
2474            switch (Param[1]) {
2475            case 0:
2476              DecLocatorFlag &= ~(DecLocatorButtonUp | DecLocatorButtonDown);
2477              break;
2478            case 1:
2479              DecLocatorFlag |= DecLocatorButtonDown;
2480              break;
2481            case 2:
2482              DecLocatorFlag &= ~DecLocatorButtonDown;
2483              break;
2484            case 3:
2485              DecLocatorFlag |= DecLocatorButtonUp;
2486              break;
2487            case 4:
2488              DecLocatorFlag &= ~DecLocatorButtonUp;
2489              break;
2490            }
2491            break;
2492    
2493          case '|': // Request Locator Position (DECRQLP)
2494            DecLocatorReport(IdMouseEventCurStat, 0);
2495            break;
2496        }
2497      }
2498    
2499    void CSSpace(BYTE b) {    void CSSpace(BYTE b) {
2500      switch (b) {      switch (b) {
2501        case 'q':        case 'q':
# Line 2575  void ParseCS(BYTE b) /* b is the final c Line 2657  void ParseCS(BYTE b) /* b is the final c
2657          case '"': CSDouble(b); break;          case '"': CSDouble(b); break;
2658          /* intermediate char = '$' */          /* intermediate char = '$' */
2659          case '$': CSDol(b); break;          case '$': CSDol(b); break;
2660            /* intermediate char = '\'' */
2661            case '\'': CSQuote(b); break;
2662        }        }
2663        break;        break;
2664    } /* of case Icount */    } /* of case Icount */
# Line 3648  int MakeMouseReportStr(char *buff, size_ Line 3732  int MakeMouseReportStr(char *buff, size_
3732    return _snprintf_s_l(buff, buffsize, _TRUNCATE, "M%c%c%c", CLocale, mb+32, x+32, y+32);    return _snprintf_s_l(buff, buffsize, _TRUNCATE, "M%c%c%c", CLocale, mb+32, x+32, y+32);
3733  }  }
3734    
3735    BOOL DecLocatorReport(int Event, int Button) {
3736      int x, y, MaxX, MaxY, len = 0;
3737      char buff[24];
3738    
3739      if (DecLocatorFlag & DecLocatorPixel) {
3740        x = LastX;
3741        y = LastY;
3742        DispConvScreenToWin(NumOfColumns+1, NumOfLines+1, &MaxX, &MaxY);
3743        if (x >= MaxX || y < 0 || y >= MaxY) {
3744          x = -1;
3745        }
3746      }
3747      else {
3748        DispConvWinToScreen(LastX, LastY, &x, &y, NULL);
3749        x++; y++;
3750        if (x < 1 || x > NumOfColumns || y < 1 || y > NumOfLines) {
3751          x = -1;
3752        }
3753      }
3754    
3755      switch (Event) {
3756      case IdMouseEventCurStat:
3757        if (MouseReportMode == IdMouseTrackDECELR) {
3758          if (x < 0) {
3759            len = _snprintf_s_l(buff, sizeof(buff), _TRUNCATE, "%d;%d&w", CLocale, 1, ButtonStat);
3760          }
3761          else {
3762            len = _snprintf_s_l(buff, sizeof(buff), _TRUNCATE, "%d;%d;%d;%d;0&w", CLocale, 1, ButtonStat, y, x);
3763          }
3764        }
3765        else {
3766          len = _snprintf_s_l(buff, sizeof(buff), _TRUNCATE, "0&w", CLocale);
3767        }
3768        break;
3769    
3770      case IdMouseEventBtnDown:
3771        if (DecLocatorFlag & DecLocatorButtonDown) {
3772          if (x < 0) {
3773            len = _snprintf_s_l(buff, sizeof(buff), _TRUNCATE, "%d;%d&w", CLocale, Button*2+2, ButtonStat);
3774          }
3775          else {
3776            len = _snprintf_s_l(buff, sizeof(buff), _TRUNCATE, "%d;%d;%d;%d;0&w", CLocale, Button*2+2, ButtonStat, y, x);
3777          }
3778        }
3779        break;
3780    
3781      case IdMouseEventBtnUp:
3782        if (DecLocatorFlag & DecLocatorButtonUp) {
3783          if (x < 0) {
3784            len = _snprintf_s_l(buff, sizeof(buff), _TRUNCATE, "%d;%d&w", CLocale, Button*2+3, ButtonStat);
3785          }
3786          else {
3787            len = _snprintf_s_l(buff, sizeof(buff), _TRUNCATE, "%d;%d;%d;%d;0&w", CLocale, Button*2+3, ButtonStat, y, x);
3788          }
3789        }
3790        break;
3791    
3792      case IdMouseEventMove:
3793        // not supported yet
3794        break;
3795      }
3796    
3797      if (len == 0) {
3798        return FALSE;
3799      }
3800    
3801      SendCSIstr(buff, len);
3802    
3803      if (DecLocatorFlag & DecLocatorOneShot) {
3804        MouseReportMode = IdMouseTrackNone;
3805      }
3806      return TRUE;
3807    }
3808    
3809  BOOL MouseReport(int Event, int Button, int Xpos, int Ypos) {  BOOL MouseReport(int Event, int Button, int Xpos, int Ypos) {
3810    char Report[10];    char Report[10];
3811    int x, y, len, modifier;    int x, y, len, modifier;
3812    static int LastX = -1, LastY = -1, LastButton = 3;    static int LastSendX = -1, LastSendY = -1, LastButton = IdButtonRelease;
3813    
3814    len = 0;    len = 0;
3815    
3816      switch (Event) {
3817      case IdMouseEventBtnDown:
3818        ButtonStat |= (8>>(3-Button));
3819        break;
3820      case IdMouseEventBtnUp:
3821        ButtonStat &= ~(8>>(3-Button));
3822        break;
3823      }
3824      LastX = Xpos;
3825      LastY = Ypos;
3826    
3827    if (MouseReportMode == IdMouseTrackNone)    if (MouseReportMode == IdMouseTrackNone)
3828      return FALSE;      return FALSE;
3829    
3830    if (ts.DisableMouseTrackingByCtrl && ControlKey())    if (ts.DisableMouseTrackingByCtrl && ControlKey())
3831      return FALSE;      return FALSE;
3832    
3833      if (MouseReportMode == IdMouseTrackDECELR)
3834        return DecLocatorReport(Event, Button);
3835    
3836    DispConvWinToScreen(Xpos, Ypos, &x, &y, NULL);    DispConvWinToScreen(Xpos, Ypos, &x, &y, NULL);
3837    x++; y++;    x++; y++;
3838    
# Line 3696  BOOL MouseReport(int Event, int Button, Line 3868  BOOL MouseReport(int Event, int Button,
3868          case IdMouseTrackBtnEvent:          case IdMouseTrackBtnEvent:
3869          case IdMouseTrackAllEvent:          case IdMouseTrackAllEvent:
3870            len = MakeMouseReportStr(Report, sizeof Report, Button | modifier, x, y);            len = MakeMouseReportStr(Report, sizeof Report, Button | modifier, x, y);
3871            LastX = x;            LastSendX = x;
3872            LastY = y;            LastSendY = y;
3873            LastButton = Button;            LastButton = Button;
3874            break;            break;
3875    
         case IdMouseTrackDECELR: /* not supported yet */  
3876          case IdMouseTrackVT200Hl: /* not supported yet */          case IdMouseTrackVT200Hl: /* not supported yet */
3877          default:          default:
3878            return FALSE;            return FALSE;
# Line 3713  BOOL MouseReport(int Event, int Button, Line 3884  BOOL MouseReport(int Event, int Button,
3884          case IdMouseTrackVT200:          case IdMouseTrackVT200:
3885          case IdMouseTrackBtnEvent:          case IdMouseTrackBtnEvent:
3886          case IdMouseTrackAllEvent:          case IdMouseTrackAllEvent:
3887            len = MakeMouseReportStr(Report, sizeof Report, 3 | modifier, x, y);            len = MakeMouseReportStr(Report, sizeof Report, IdButtonRelease | modifier, x, y);
3888            LastX = x;            LastSendX = x;
3889            LastY = y;            LastSendY = y;
3890            LastButton = 3; // Release            LastButton = IdButtonRelease;
3891            break;            break;
3892    
3893          case IdMouseTrackX10: /* nothing to do */          case IdMouseTrackX10: /* nothing to do */
         case IdMouseTrackDECELR: /* not supported yet */  
3894          case IdMouseTrackVT200Hl: /* not supported yet */          case IdMouseTrackVT200Hl: /* not supported yet */
3895          default:          default:
3896            return FALSE;            return FALSE;
# Line 3735  BOOL MouseReport(int Event, int Button, Line 3905  BOOL MouseReport(int Event, int Button,
3905            }            }
3906            /* FALLTHROUGH */            /* FALLTHROUGH */
3907          case IdMouseTrackAllEvent:          case IdMouseTrackAllEvent:
3908            if (x == LastX && y == LastY) {            if (x == LastSendX && y == LastSendY) {
3909              return FALSE;              return FALSE;
3910            }            }
3911            len = MakeMouseReportStr(Report, sizeof Report, LastButton | modifier | ((LastButton==3)?0:32), x, y);            len = MakeMouseReportStr(Report, sizeof Report, LastButton | modifier | ((LastButton==IdButtonRelease)?0:32), x, y);
3912            LastX = x;            LastSendX = x;
3913            LastY = y;            LastSendY = y;
3914            break;            break;
3915    
         case IdMouseTrackDECELR: /* not supported yet */  
3916          case IdMouseTrackVT200Hl: /* not supported yet */          case IdMouseTrackVT200Hl: /* not supported yet */
3917          case IdMouseTrackX10: /* nothing to do */          case IdMouseTrackX10: /* nothing to do */
3918          case IdMouseTrackVT200: /* nothing to do */          case IdMouseTrackVT200: /* nothing to do */
# Line 3761  BOOL MouseReport(int Event, int Button, Line 3930  BOOL MouseReport(int Event, int Button,
3930            break;            break;
3931    
3932          case IdMouseTrackX10: /* nothing to do */          case IdMouseTrackX10: /* nothing to do */
         case IdMouseTrackDECELR: /* not supported yet */  
3933          case IdMouseTrackVT200Hl: /* not supported yet */          case IdMouseTrackVT200Hl: /* not supported yet */
3934            return FALSE;            return FALSE;
3935        }        }

Legend:
Removed from v.3993  
changed lines
  Added in v.3997

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26