View Issue Details

IDProjectCategoryView StatusLast Update
0001595Double CommanderGraphical user interfacepublic2020-11-30 07:44
Reportercordylus Assigned Tocordylus  
PrioritynormalSeverityfeatureReproducibilityalways
Status closedResolutionopen 
ProjectionnoneETAnone 
Product Version0.7.6 
Summary0001595: Shift with up/down arrow to select items during quick search
DescriptionПри быстром поиске удерживание Shift со стрелкой не выделяет элемент, только переходит на следующий результат, не выделяя предыдущий. В TC такое работает.
TagsNo tags attached.
Attached Files
bug1595.patch (6,655 bytes)   
Index: src/fileviews/uorderedfileview.pas
===================================================================
--- src/fileviews/uorderedfileview.pas	(revision 7902)
+++ src/fileviews/uorderedfileview.pas	(working copy)
@@ -45,7 +45,7 @@
     pmOperationsCancel: TPopupMenu;
     procedure lblFilterClick(Sender: TObject);
     procedure pmOperationsCancelClick(Sender: TObject);
-    procedure quickSearchChangeSearch(Sender: TObject; ASearchText: String; const ASearchOptions: TQuickSearchOptions);
+    procedure quickSearchChangeSearch(Sender: TObject; ASearchText: String; const ASearchOptions: TQuickSearchOptions; InvertSelection: Boolean = False);
     procedure quickSearchChangeFilter(Sender: TObject; AFilterText: String; const AFilterOptions: TQuickSearchOptions);
     procedure quickSearchExecute(Sender: TObject);
     procedure quickSearchHide(Sender: TObject);
@@ -84,7 +84,7 @@
        Search and position in a file that matches name taking into account
        passed options.
     }
-    procedure SearchFile(SearchTerm,SeparatorCharset: String; SearchOptions: TQuickSearchOptions);
+    procedure SearchFile(SearchTerm,SeparatorCharset: String; SearchOptions: TQuickSearchOptions; InvertSelection: Boolean = False);
     procedure Selection(Key: Word; CurIndex: PtrInt);
     procedure SelectRange(FileIndex: PtrInt);
     procedure SetActiveFile(FileIndex: PtrInt; ScrollTo: Boolean = True); overload; virtual; abstract;
@@ -486,13 +486,13 @@
   lblFilter.Visible := Filtered;
 end;
 
-procedure TOrderedFileView.quickSearchChangeSearch(Sender: TObject; ASearchText: String; const ASearchOptions: TQuickSearchOptions);
+procedure TOrderedFileView.quickSearchChangeSearch(Sender: TObject; ASearchText: String; const ASearchOptions: TQuickSearchOptions; InvertSelection: Boolean);
 var
   Index, MaybeFoundIndex: PtrInt;
 begin
   Index:=GetActiveFileIndex;
   Active := True;
-  SearchFile(ASearchText,';, ', ASearchOptions);
+  SearchFile(ASearchText,';, ', ASearchOptions, InvertSelection);
   MaybeFoundIndex:=GetActiveFileIndex;
 
   if (MaybeFoundIndex <= Index) AND (ASearchOptions.CancelSearchMode=qscmCancelIfNoFound) then
@@ -519,10 +519,12 @@
     SetFocus;
 end;
 
-procedure TOrderedFileView.SearchFile(SearchTerm,SeparatorCharset: String; SearchOptions: TQuickSearchOptions);
+procedure TOrderedFileView.SearchFile(SearchTerm,SeparatorCharset: String; SearchOptions: TQuickSearchOptions; InvertSelection: Boolean);
 var
-  i, StartIndex, Index: PtrInt;
+  i, Index, StopIndex, ActiveIndex: PtrInt;
   s :string;
+  NewSelectedState,
+  FirstFound,
   Result: Boolean;
   sFileName,
   sSearchName,
@@ -575,7 +577,20 @@
 
   Index := GetActiveFileIndex; // start search from current position
   if not IsFileIndexInRange(Index) then
+  begin
     Index := 0;
+    InvertSelection := False;
+  end;
+
+  if InvertSelection then
+  begin
+    ActiveIndex := Index;
+    FirstFound := False;
+    NewSelectedState := not FFiles[Index].Selected;
+    MarkFile(FFiles[Index], NewSelectedState, False);
+    DoSelectionChanged(Index);
+  end;
+
   case SearchOptions.Direction of
     qsdFirst:
       Index := 0;                  // begin search from first file
@@ -587,8 +602,7 @@
       Index := PrevIndexWrap(Index);   // begin search from previous file
   end;
 
-
-  StartIndex := Index;
+  StopIndex := Index;
   try
 //    Mask := TMask.Create(sSearchName, SearchOptions.SearchCase = qscSensitive);
     Masks:=TMaskList.Create(SearchTerm,';,', SearchOptions.SearchCase = qscSensitive);
@@ -629,8 +643,26 @@
 
         if Result then
         begin
-          SetActiveFile(Index);
-          Break;
+          if InvertSelection and (SearchOptions.Direction in [qsdFirst, qsdLast]) then
+          begin
+            if not FirstFound then
+            begin
+              FirstFound := True;
+              SetActiveFile(Index);
+              if ((SearchOptions.Direction = qsdFirst) and (Index < ActiveIndex) or
+                  (SearchOptions.Direction = qsdLast) and (Index > ActiveIndex)) then
+                StopIndex := ActiveIndex // continue to mark files until the starting index
+              else
+                break;
+            end;
+            MarkFile(FFiles[Index], NewSelectedState, False);
+            DoSelectionChanged(Index);
+          end
+          else
+          begin
+            SetActiveFile(Index);
+            Break;
+          end;
         end;
 
         // check next file depending on search direction
@@ -639,7 +671,7 @@
         else
           Index := PrevIndexWrap(Index);
 
-      until Index = StartIndex;
+      until Index = StopIndex;
     finally
 //      Mask.Free;
       Masks.Free;
Index: src/frames/fquicksearch.pas
===================================================================
--- src/frames/fquicksearch.pas	(revision 7902)
+++ src/frames/fquicksearch.pas	(working copy)
@@ -25,7 +25,7 @@
     CancelSearchMode: TQuickSearchCancelMode;
   end;
 
-  TOnChangeSearch = procedure(Sender: TObject; ASearchText: String; const ASearchOptions: TQuickSearchOptions) of Object;
+  TOnChangeSearch = procedure(Sender: TObject; ASearchText: String; const ASearchOptions: TQuickSearchOptions; InvertSelection: Boolean = False) of Object;
   TOnChangeFilter = procedure(Sender: TObject; AFilterText: String; const AFilterOptions: TQuickSearchOptions) of Object;
   TOnExecute = procedure(Sender: TObject) of Object;
   TOnHide = procedure(Sender: TObject) of Object;
@@ -552,7 +552,7 @@
       if Assigned(Self.OnChangeSearch) then
       begin
         Options.Direction:=qsdNext;
-        Self.OnChangeSearch(Self, edtSearch.Text, Options);
+        Self.OnChangeSearch(Self, edtSearch.Text, Options, ssShift in Shift);
       end;
     end;
 
@@ -563,7 +563,7 @@
       if Assigned(Self.OnChangeSearch) then
       begin
         Options.Direction:=qsdPrevious;
-        Self.OnChangeSearch(Self, edtSearch.Text, Options);
+        Self.OnChangeSearch(Self, edtSearch.Text, Options, ssShift in Shift);
       end;
     end;
 
@@ -578,7 +578,7 @@
         if Assigned(Self.OnChangeSearch) then
         begin
           Options.Direction := qsdFirst;
-          Self.OnChangeSearch(Self, edtSearch.Text, Options);
+          Self.OnChangeSearch(Self, edtSearch.Text, Options, ssShift in Shift);
         end;
       end;
     end;
@@ -594,7 +594,7 @@
         if Assigned(Self.OnChangeSearch) then
         begin
           Options.Direction := qsdLast;
-          Self.OnChangeSearch(Self, edtSearch.Text, Options);
+          Self.OnChangeSearch(Self, edtSearch.Text, Options, ssShift in Shift);
         end;
       end;
     end;
bug1595.patch (6,655 bytes)   
Fixed in Revision7933
Operating system
Widgetset
Architecture

Activities

cordylus

2017-12-10 06:46

developer   ~0002409

The patch also handles Ctrl+Shift+Home and Ctrl+Shift+End.

Issue History

Date Modified Username Field Change
2016-11-05 07:10 cordylus New Issue
2017-12-10 06:46 cordylus Note Added: 0002409
2017-12-10 06:47 cordylus File Added: bug1595.patch
2017-12-20 00:08 cordylus Fixed in Revision => 7933
2017-12-20 00:08 cordylus Assigned To => cordylus
2017-12-20 00:08 cordylus Status new => resolved
2020-11-30 07:44 Alexx2000 Status resolved => closed