Revision: 8400 https://osdn.net/projects/ttssh2/scm/svn/commits/8400 Author: doda Date: 2019-11-23 00:25:44 +0900 (Sat, 23 Nov 2019) Log Message: ----------- マウスでのドラッグを行った時間が短い場合にドラッグとみなさないようにした。 Ticket: #39591 問題: ウィンドウをアクティブにする為に VT ウィンドウをクリックした時、マウスが 少し動いた事でドラッグした事になり選択内容が消える事が有る。 対処: 短時間でのドラッグをドラッグとみなさないよう設定できるようにした。 Ticket Links: ------------ https://osdn.net/projects/ttssh2/tracker/detail/39591 Modified Paths: -------------- trunk/installer/release/TERATERM.INI trunk/teraterm/common/tttypes.h trunk/teraterm/teraterm/buffer.c trunk/teraterm/ttpset/ttset.c -------------- next part -------------- Modified: trunk/installer/release/TERATERM.INI =================================================================== --- trunk/installer/release/TERATERM.INI 2019-11-22 15:15:05 UTC (rev 8399) +++ trunk/installer/release/TERATERM.INI 2019-11-22 15:25:44 UTC (rev 8400) @@ -585,6 +585,9 @@ ; Maximized window bug tweak (0..2) MaximizedBugTweak=2 +; Delay for starting of text selection +MouseSelectStartDelay=0 + ; Nonblinking cursor NonblinkingCursor=off Modified: trunk/teraterm/common/tttypes.h =================================================================== --- trunk/teraterm/common/tttypes.h 2019-11-22 15:15:05 UTC (rev 8399) +++ trunk/teraterm/common/tttypes.h 2019-11-22 15:25:44 UTC (rev 8400) @@ -707,6 +707,7 @@ int DialogFontCharSet; int ConfigVersion; int RunningVersion; + DWORD SelectStartDelay; }; typedef struct tttset TTTSet, *PTTSet; Modified: trunk/teraterm/teraterm/buffer.c =================================================================== --- trunk/teraterm/teraterm/buffer.c 2019-11-22 15:15:05 UTC (rev 8399) +++ trunk/teraterm/teraterm/buffer.c 2019-11-22 15:25:44 UTC (rev 8400) @@ -57,7 +57,7 @@ int StatusLine; //0: none 1: shown /* top, bottom, left & right margin */ int CursorTop, CursorBottom, CursorLeftM, CursorRightM; -BOOL Selected; +BOOL Selected, Selecting; BOOL Wrap; static WORD TabStops[256]; @@ -84,7 +84,8 @@ static LONG BufferSize; static int NumOfLinesInBuff; static int BuffStartAbs, BuffEndAbs; -static POINT SelectStart, SelectEnd, SelectEndOld; +static POINT SelectStart, SelectStartTmp, SelectEnd, SelectEndOld; +static DWORD SelectStartTime; static BOOL BoxSelect; static POINT DblClkStart, DblClkEnd; @@ -416,6 +417,7 @@ SelectEnd.y = BuffEnd; // SelectEnd.x = NumOfColumns; // SelectEnd.y = BuffEnd - 1; + Selecting = TRUE; } void BuffScreenSelect() @@ -428,6 +430,7 @@ SelectEnd.y = SelectStart.y + NumOfLines; // SelectEnd.x = X + NumOfColumns; // SelectEnd.y = Y + PageStart + NumOfLines - 1; + Selecting = TRUE; } void BuffCancelSelection() @@ -436,6 +439,7 @@ SelectStart.y = 0; SelectEnd.x = 0; SelectEnd.y = 0; + Selecting = FALSE; } void BuffReset() @@ -2726,6 +2730,11 @@ CaretOff(); + if (!Selecting) { + SelectStart = SelectStartTmp; + Selecting = TRUE; + } + DispConvWinToScreen(Xw,Yw,&X,&Y,NULL); Y = Y + PageStart; if ((Y<0) || (Y>=BuffEnd)) { @@ -2997,31 +3006,23 @@ ChangeSelectRegion(); UnlockBuffer(); - SelectStart.x = X; - SelectStart.y = Y; - if (SelectStart.x<0) { - SelectStart.x = 0; - } - if (SelectStart.x > NumOfColumns) { - SelectStart.x = NumOfColumns; - } - if (SelectStart.y < 0) { - SelectStart.y = 0; - } - if (SelectStart.y >= BuffEnd) { - SelectStart.y = BuffEnd - 1; - } + SelectStartTime = GetTickCount(); + Selecting = FALSE; +#define range_check(v, min, max) ((v)<(min) ? (min) : (v)>(max) ? (max) : (v)) + SelectStartTmp.x = range_check(X, 0, NumOfColumns); + SelectStartTmp.y = range_check(Y, 0, BuffEnd-1); + TmpPtr = GetLinePtr(SelectStart.y); // check if the cursor is on the right half of a character - if ((SelectStart.x>0) && - ((AttrBuff[TmpPtr+SelectStart.x-1] & AttrKanji) != 0) || - ((AttrBuff[TmpPtr+SelectStart.x] & AttrKanji) == 0) && + if ((SelectStartTmp.x>0) && + ((AttrBuff[TmpPtr+SelectStartTmp.x-1] & AttrKanji) != 0) || + ((AttrBuff[TmpPtr+SelectStartTmp.x] & AttrKanji) == 0) && Right) { - SelectStart.x++; + SelectStartTmp.x++; } - SelectEnd = SelectStart; + SelectEnd = SelectStartTmp; SelectEndOld = SelectEnd; CaretOff(); Selected = TRUE; @@ -3041,6 +3042,14 @@ BYTE b; BOOL DBCS; + if (!Selecting) { + if (GetTickCount() - SelectStartTime < ts.SelectStartDelay) { + return; + } + SelectStart = SelectStartTmp; + Selecting = TRUE; + } + DispConvWinToScreen(Xw,Yw,&X,&Y,&Right); Y = Y + PageStart; @@ -3197,6 +3206,19 @@ void BuffEndSelect() // End text selection by mouse button up { + if (!Selecting) { + if (GetTickCount() - SelectStartTime < ts.SelectStartDelay) { + SelectEnd = SelectStart; + SelectEndOld = SelectEnd; + LockBuffer(); + ChangeSelectRegion(); + UnlockBuffer(); + Selected = FALSE; + return; + } + SelectStart = SelectStartTmp; + } + Selected = (SelectStart.x!=SelectEnd.x) || (SelectStart.y!=SelectEnd.y); if (Selected) { Modified: trunk/teraterm/ttpset/ttset.c =================================================================== --- trunk/teraterm/ttpset/ttset.c 2019-11-22 15:15:05 UTC (rev 8399) +++ trunk/teraterm/ttpset/ttset.c 2019-11-22 15:25:44 UTC (rev 8400) @@ -2231,6 +2231,10 @@ if (GetOnOff(Section, "ClearScrollBufferFromRemote", FName, TRUE)) ts->TermFlag |= TF_REMOTECLEARSBUFF; + // Delay for start of mouse selection + ts->SelectStartDelay = + GetPrivateProfileInt(Section, "MouseSelectStartDelay", 0, FName); + // Fallback to CP932 (Experimental) ts->FallbackToCP932 = GetOnOff(Section, "FallbackToCP932", FName, FALSE); @@ -3555,6 +3559,9 @@ WriteOnOff(Section, "ClearScrollBufferFromRemote", FName, (WORD) (ts->PasteFlag & TF_REMOTECLEARSBUFF)); + // Delay for start of mouse selection + WriteInt(Section, "MouseSelectStartDelay", FName, ts->SelectStartDelay); + // CygTerm Configuration File WriteCygtermConfFile(ts);