@@ -906,6 +906,7 @@ static inline bool s_femto_inner_kbdHandle(
906
906
break ;
907
907
case VK_TAB :
908
908
{
909
+ fData_cancelHighlight (peditor );
909
910
// Shuffle between tabs
910
911
if ((GetAsyncKeyState (VK_LCONTROL ) & 0x8000 ) || (GetAsyncKeyState (VK_RCONTROL ) & 0x8000 ))
911
912
{
@@ -944,12 +945,14 @@ static inline bool s_femto_inner_kbdHandle(
944
945
}
945
946
case VK_F2 :
946
947
case VK_F3 :
948
+ fData_cancelHighlight (peditor );
947
949
send = false;
948
950
peditor -> bDirBack = (wVirtKey == VK_F2 );
949
951
s_femto_inner_searchTerm (peditor , tempstr , false);
950
952
break ;
951
953
case VK_DELETE :
952
954
{
955
+ fData_cancelHighlight (peditor );
953
956
// Check for shift to alt key
954
957
if (shift ^ ((GetAsyncKeyState (VK_LMENU ) & 0x8000 ) || (GetAsyncKeyState (VK_RMENU ) & 0x8000 )))
955
958
{
@@ -966,6 +969,7 @@ static inline bool s_femto_inner_kbdHandle(
966
969
// Check for alt key
967
970
if ((GetAsyncKeyState (VK_LMENU ) & 0x8000 ) || (GetAsyncKeyState (VK_RMENU ) & 0x8000 ))
968
971
{
972
+ fData_cancelHighlight (peditor );
969
973
swprintf_s (tempstr , MAX_STATUS , L"'ALT' + \u2191 #%u" , keyCount );
970
974
wVirtKey = FEMTO_MOVELINE_UP ;
971
975
}
@@ -978,6 +982,7 @@ static inline bool s_femto_inner_kbdHandle(
978
982
// Check for alt key
979
983
if ((GetAsyncKeyState (VK_LMENU ) & 0x8000 ) || (GetAsyncKeyState (VK_RMENU ) & 0x8000 ))
980
984
{
985
+ fData_cancelHighlight (peditor );
981
986
swprintf_s (tempstr , MAX_STATUS , L"'ALT' + \u2193 #%u" , keyCount );
982
987
wVirtKey = FEMTO_MOVELINE_DOWN ;
983
988
}
@@ -988,12 +993,14 @@ static inline bool s_femto_inner_kbdHandle(
988
993
break ;
989
994
case VK_RETURN : // Enter key
990
995
case VK_BACK : // Backspace
991
- case VK_LEFT : // Left arrow
992
- case VK_RIGHT : // Right arrow
993
996
case VK_PRIOR : // Page up
994
997
case VK_NEXT : // Page down
995
998
case VK_END :
996
999
case VK_HOME :
1000
+ fData_cancelHighlight (peditor );
1001
+ /* fall through */
1002
+ case VK_LEFT : // Left arrow
1003
+ case VK_RIGHT : // Right arrow
997
1004
{
998
1005
static const wchar * buf [] = {
999
1006
[VK_RETURN ] = L"'RET'" ,
@@ -1161,11 +1168,17 @@ static inline bool s_femto_inner_mouseHandle(
1161
1168
// If not, don't draw anything on the statusbar
1162
1169
draw = s_femto_inner_calcMousePos (peditor , ir , & pos );
1163
1170
1171
+ struct fFileHighLight * restrict hl = & pfile -> data .hl ;
1172
+ assert (hl != NULL );
1173
+
1174
+ bool moved = false;
1175
+
1164
1176
// Check if mouse is moving
1165
1177
if (ir -> dwEventFlags & MOUSE_MOVED )
1166
1178
{
1167
1179
if (draw )
1168
1180
{
1181
+ moved = true;
1169
1182
swprintf_s (tempstr , MAX_STATUS , L"'LCLICK' + MOVE @%hd, %hd" , pos .X , pos .Y );
1170
1183
}
1171
1184
}
@@ -1175,19 +1188,37 @@ static inline bool s_femto_inner_mouseHandle(
1175
1188
{
1176
1189
fProf_write ("Mouse click @%hd, %hd" , pos .X , pos .Y );
1177
1190
1178
- if (pfile -> data .pcury != NULL )
1191
+ fData_cancelHighlight (peditor );
1192
+
1193
+ swprintf_s (tempstr , MAX_STATUS , L"'LCLICK' @%hd, %hd" , pos .X , pos .Y );
1194
+ }
1195
+ }
1196
+
1197
+ if (draw )
1198
+ {
1199
+ if (pfile -> data .pcury != NULL )
1200
+ {
1201
+ pfile -> data .currentNode = pfile -> data .pcury ;
1202
+ const fLine_t * restrict lastcurnode = pfile -> data .currentNode ;
1203
+ fLine_moveCursorVert (& pfile -> data .currentNode , (isize )pos .Y );
1204
+ fLine_t * restrict curNode = pfile -> data .currentNode ;
1205
+ pfile -> data .bUpdateAll |= (curNode != lastcurnode ) & peditor -> settings .bRelLineNums ;
1206
+ // Now move the cursor to correct X position
1207
+ fLine_moveCursorAbs (curNode , fLine_calcCursor (curNode , (usize )pos .X + pfile -> data .curx , peditor -> settings .tabWidth ));
1208
+ fLine_calcVirtCursor (curNode , peditor -> settings .tabWidth );
1209
+ pfile -> data .lastx = curNode -> virtcurx ;
1210
+
1211
+ if (moved && (hl -> beg == NULL ))
1179
1212
{
1180
- pfile -> data .currentNode = pfile -> data .pcury ;
1181
- const fLine_t * restrict lastcurnode = pfile -> data .currentNode ;
1182
- fLine_moveCursorVert (& pfile -> data .currentNode , (isize )pos .Y );
1183
- pfile -> data .bUpdateAll |= (pfile -> data .currentNode != lastcurnode ) & peditor -> settings .bRelLineNums ;
1184
- // Now move the cursor to correct X position
1185
- fLine_moveCursorAbs (pfile -> data .currentNode , fLine_calcCursor (pfile -> data .currentNode , (usize )pos .X + pfile -> data .curx , peditor -> settings .tabWidth ));
1186
- fLine_calcVirtCursor (pfile -> data .currentNode , peditor -> settings .tabWidth );
1187
- pfile -> data .lastx = pfile -> data .currentNode -> virtcurx ;
1188
- fData_refreshEditAsync (peditor );
1213
+ hl -> beg = pfile -> data .currentNode ;
1214
+ hl -> begx = pfile -> data .currentNode -> curx & USIZE_BIT_1_MASK ;
1189
1215
}
1190
- swprintf_s (tempstr , MAX_STATUS , L"'LCLICK' @%hd, %hd" , pos .X , pos .Y );
1216
+ if (hl -> beg != NULL )
1217
+ {
1218
+ hl -> backwards = (hl -> beg -> lineNumber > curNode -> lineNumber ) ||
1219
+ ((hl -> beg == curNode ) && (hl -> begx > curNode -> curx ));
1220
+ }
1221
+ fData_refreshEditAsync (peditor );
1191
1222
}
1192
1223
}
1193
1224
}
0 commit comments