summaryrefslogtreecommitdiff
path: root/UMain.pas
diff options
context:
space:
mode:
Diffstat (limited to 'UMain.pas')
-rw-r--r--UMain.pas82
1 files changed, 63 insertions, 19 deletions
diff --git a/UMain.pas b/UMain.pas
index aee982c..2e06dbc 100644
--- a/UMain.pas
+++ b/UMain.pas
@@ -1463,14 +1463,18 @@ begin
CommandLineCombo.Entry.SetFocus;
CommandLineCombo.Entry.SelectAll;
end else begin
- if QuickFind then QuickFindSendKey(LeftPanel, Key)
- else if Assigned(AListView.Selected) and (AListView.ConvertToSorted(AListView.Selected.Index) = AListView.Items.Count - 1) then Accept := False;
+ if QuickFind and (Shift = []) then begin
+ QuickFindSendKey(LeftPanel, Key);
+ Accept := False;
+ end else if Assigned(AListView.Selected) and (AListView.ConvertToSorted(AListView.Selected.Index) = AListView.Items.Count - 1) then Accept := False;
end;
end;
GDK_Up : begin
KeyHandled := True;
- if QuickFind then QuickFindSendKey(LeftPanel, Key)
- else if Assigned(AListView.Selected) and (AListView.ConvertToSorted(AListView.Selected.Index) = 0) then Accept := False;
+ if QuickFind and (Shift = []) then begin
+ QuickFindSendKey(LeftPanel, Key);
+ Accept := False;
+ end else if Assigned(AListView.Selected) and (AListView.ConvertToSorted(AListView.Selected.Index) = 0) then Accept := False;
end;
GDK_Page_Up, GDK_Page_Down: begin
KeyHandled := True;
@@ -1511,7 +1515,6 @@ begin
KeyHandled := True;
ActivateQuickFind(LeftPanel);
end;
-// else if not KeyHandled then Accept := not HandleKey(Key, Shift, LeftPanel);
end;
if not KeyHandled then Accept := not HandleKey(Key, Shift, LeftPanel);
end;
@@ -2817,9 +2820,9 @@ var Entry: TGTKEntry;
AListView: TGTKListView;
DataList: TList;
Data: PDataItem;
- Found: boolean;
OldSelectionChangedEvent: TNotifyEvent;
g: PChar;
+ NewIndex, StartIndex: Longint;
begin
Result := False;
if not QuickFind then Exit;
@@ -2832,6 +2835,8 @@ begin
AListView := RightListView;
DataList := RightPanelData;
end;
+
+// DebugMsg(['TFMain.QuickFindSendKey: Key = ', Key, ', GDK_Down = ', GDK_Down, ', GDK_Up = ', GDK_Up]);
if Key = GDK_BACKSPACE then begin
if g_utf8_strlen(PChar(Entry.Text), -1) > 0 then begin
// DebugMsg(['TFMain.QuickFindSendKey: before delete: "', Entry.Text, '", ansi = "', UTF8ToStr(Entry.Text), '"']);
@@ -2843,27 +2848,66 @@ begin
Libc.free(g);
end;
NewText := Entry.Text;
+ end else
+ if (Key = GDK_Down) or (Key = GDK_Up) then begin
+ NewText := Entry.Text;
end else begin
s := UTF8Encode(WideChar(KeyValToUnicode(Key)));
if (Length(s) = 0) or (s = #0) then Exit;
NewText := Entry.Text + s;
end;
+
if (DataList.Count > 0) and (Length(NewText) > 0) then begin
- Found := False;
- for i := 0 to DataList.Count - 1 do begin
- Data := DataList[AListView.ConvertFromSorted(i)];
- if Assigned(Data) and (not Data^.UpDir) and (Pos(WideUpperCase(NewText), WideUpperCase(Data^.FDisplayName)) = 1) then begin
- Found := True;
- OldSelectionChangedEvent := AListView.OnSelectionChanged;
- AListView.OnSelectionChanged := nil;
- AListView.Selected := AListView.Items[AListView.ConvertFromSorted(i)];
- AListView.Items[AListView.ConvertFromSorted(i)].SetCursor(0, False, False, 0, 0);
- AListView.OnSelectionChanged := OldSelectionChangedEvent;
- Break;
+ NewIndex := -1;
+ StartIndex := (AListView.ConvertToSorted(AListView.Selected.Index) + Ord(Key = GDK_Down) - Ord(Key = GDK_Up)) mod DataList.Count;
+ if StartIndex < 0 then StartIndex := 0;
+ if StartIndex > DataList.Count - 1 then StartIndex := DataList.Count - 1;
+// DebugMsg(['TFMain.QuickFindSendKey: StartIndex = ', StartIndex]);
+
+ if Key <> GDK_Up then begin
+ // Search down
+ for i := StartIndex to DataList.Count - 1 do begin
+ Data := DataList[AListView.ConvertFromSorted(i)];
+ if Assigned(Data) and (not Data^.UpDir) and (Pos(WideUpperCase(NewText), WideUpperCase(Data^.FDisplayName)) = 1) then begin
+ NewIndex := i;
+ Break;
+ end;
+ end;
+ if NewIndex < 0 then
+ for i := 0 to StartIndex do begin
+ Data := DataList[AListView.ConvertFromSorted(i)];
+ if Assigned(Data) and (not Data^.UpDir) and (Pos(WideUpperCase(NewText), WideUpperCase(Data^.FDisplayName)) = 1) then begin
+ NewIndex := i;
+ Break;
+ end;
+ end;
+ end else begin
+ // Search up
+ for i := StartIndex downto 0 do begin
+ Data := DataList[AListView.ConvertFromSorted(i)];
+ if Assigned(Data) and (not Data^.UpDir) and (Pos(WideUpperCase(NewText), WideUpperCase(Data^.FDisplayName)) = 1) then begin
+ NewIndex := i;
+ Break;
+ end;
end;
+ if NewIndex < 0 then
+ for i := DataList.Count - 1 downto StartIndex do begin
+ Data := DataList[AListView.ConvertFromSorted(i)];
+ if Assigned(Data) and (not Data^.UpDir) and (Pos(WideUpperCase(NewText), WideUpperCase(Data^.FDisplayName)) = 1) then begin
+ NewIndex := i;
+ Break;
+ end;
+ end;
end;
- if Found then Entry.Text := NewText
- else Beep;
+
+ if NewIndex >= 0 then begin
+ OldSelectionChangedEvent := AListView.OnSelectionChanged;
+ AListView.OnSelectionChanged := nil;
+ AListView.Selected := AListView.Items[AListView.ConvertFromSorted(NewIndex)];
+ AListView.Items[AListView.ConvertFromSorted(NewIndex)].SetCursor(0, False, False, 0, 0);
+ AListView.OnSelectionChanged := OldSelectionChangedEvent;
+ Entry.Text := NewText;
+ end else Beep;
Result := True;
end;
end;