summaryrefslogtreecommitdiff
path: root/UMain.pas
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@tbzatek.englab.brq.redhat.com>2008-06-10 18:36:02 +0200
committerTomas Bzatek <tbzatek@tbzatek.englab.brq.redhat.com>2008-06-10 18:36:02 +0200
commit675412adbdeb5c743d2dadc4d1b376a8675d771b (patch)
treea82d8ed0d0ff4feba59a97747c131d3d48ecf0e3 /UMain.pas
parente57a008756356c17e647d27dc81a123ed23722a6 (diff)
downloadtuxcmd-675412adbdeb5c743d2dadc4d1b376a8675d771b.tar.xz
Configurable quick search shortcuts [Part I]
Diffstat (limited to 'UMain.pas')
-rw-r--r--UMain.pas236
1 files changed, 150 insertions, 86 deletions
diff --git a/UMain.pas b/UMain.pas
index f140fa3..773293a 100644
--- a/UMain.pas
+++ b/UMain.pas
@@ -230,6 +230,7 @@ type
procedure CopyFilenamesToClipboard(FullPaths, LeftPanel: boolean);
function HandleRunFromArchive(var APath: string; Engine: TPanelEngine; Command, FileTypeDesc: string; BypassDialog: boolean): boolean;
function HandleSetPassword(Engine: TPanelEngine): boolean;
+ function HandleKey(Key: Word; Shift: TShiftState; LeftPanel: boolean): boolean;
public
LeftPanelEngine, RightPanelEngine : TPanelEngine;
ColumnSortIDs: array[1..ConstNumPanelColumns] of integer;
@@ -1274,7 +1275,7 @@ end;
procedure TFMain.ListViewKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean);
var AListView: TGTKListView;
ANotebook: TEphyNotebook;
- LeftPanel: boolean;
+ LeftPanel, KeyHandled: boolean;
x: integer;
begin
if not Assigned(Sender) or not (Sender is TGTKListView) then DebugMsg(['**** ListViewKeyDown: Sender is not TGTKListView or not valid']);
@@ -1285,39 +1286,52 @@ begin
if LeftPanel then ANotebook := LeftPanelNotebook
else ANotebook := RightPanelNotebook;
FileListTipsHide;
+ KeyHandled := False;
case Key of
GDK_TAB, 65056 : if (ssCtrl in Shift) and ANotebook.Visible then begin
Accept := False;
+ KeyHandled := True;
x := (ANotebook.PageIndex + 1 - 2*Ord(ssShift in Shift)) mod ANotebook.ChildrenCount;
if x < 0 then x := ANotebook.ChildrenCount - 1;
ANotebook.PageIndex := x;
end else begin
Accept := False;
+ KeyHandled := True;
DeactivateQuickFind(LeftPanel);
- Application.ProcessMessages;
+// Application.ProcessMessages;
if InternalLockUnlocked then // prevent changing focus when busy
if LeftPanel then RightListView.SetFocus
else LeftListView.SetFocus;
end;
- GDK_RETURN, GDK_KP_ENTER : if {(Key = GDK_RETURN) and} (Shift = [ssAlt, ssShift]) then DoGetDirSize(True) else
- if ([ssAlt] = Shift) or ([ssCtrl] = Shift) then begin
- CommandLineComboKeyDown(Sender, Key, Shift, Accept);
- Accept := False;
- CommandLineCombo.Entry.SetFocus;
- CommandLineCombo.Entry.SelectRegion(Length(CommandLineCombo.Entry.Text), Length(CommandLineCombo.Entry.Text));
- end else
- if Length(Trim(CommandLineCombo.Entry.Text)) > 0 then CommandLineComboKeyDown(Sender, Key, Shift, Accept)
- else if Assigned(AListView.Selected) then ActivateItem(AListView.Selected.Index, False);
- GDK_BACKSPACE : if QuickFind then begin Accept := False; QuickFindSendKey(LeftPanel, Key); end
- else if LeftPanel then PathButtonClick(LeftUpButton)
- else PathButtonClick(RightUpButton);
+ GDK_RETURN, GDK_KP_ENTER : begin
+ KeyHandled := True;
+ if {(Key = GDK_RETURN) and} (Shift = [ssAlt, ssShift]) then DoGetDirSize(True)
+ else
+ if ([ssAlt] = Shift) or ([ssCtrl] = Shift) then begin
+ CommandLineComboKeyDown(Sender, Key, Shift, Accept);
+ Accept := False;
+ CommandLineCombo.Entry.SetFocus;
+ CommandLineCombo.Entry.SelectRegion(Length(CommandLineCombo.Entry.Text), Length(CommandLineCombo.Entry.Text));
+ end else
+ if Length(Trim(CommandLineCombo.Entry.Text)) > 0 then CommandLineComboKeyDown(Sender, Key, Shift, Accept)
+ else if Assigned(AListView.Selected) then ActivateItem(AListView.Selected.Index, False);
+ end;
+ GDK_BACKSPACE : begin
+ KeyHandled := True;
+ if QuickFind then QuickFindSendKey(LeftPanel, Key)
+ else begin
+ if LeftPanel then PathButtonClick(LeftUpButton)
+ else PathButtonClick(RightUpButton);
+ end;
+ end;
GDK_Right : begin
if [ssCtrl] = Shift then SwitchPanelCtrlLeftRight(LeftPanel, False) else
if ConfLynxLikeMotion then begin
if Assigned(AListView.Selected) then ActivateItem(AListView.Selected.Index, False);
end;
Accept := False;
+ KeyHandled := True;
end;
GDK_Left : begin
if [ssCtrl] = Shift then SwitchPanelCtrlLeftRight(LeftPanel, True) else
@@ -1325,52 +1339,66 @@ begin
if LeftPanel then PathButtonClick(LeftUpButton)
else PathButtonClick(RightUpButton);
Accept := False;
+ KeyHandled := True;
end;
- GDK_INSERT : DoSelect(5);
- GDK_SPACE : begin
+ GDK_INSERT : begin
+ KeyHandled := True;
+ DoSelect(5);
+ end;
+ GDK_SPACE : if not QuickFind then begin
Accept := False;
- if QuickFind then QuickFindSendKey(LeftPanel, Key)
- else if Length(CommandLineCombo.Entry.Text) > 0 then ActivateCommandLine(Key)
+ KeyHandled := True;
+ if Length(CommandLineCombo.Entry.Text) > 0 then ActivateCommandLine(Key)
else begin
if not PDataItem(AListView.Selected.Data)^.Selected then DoGetDirSize(False);
DoSelect(8);
end;
end;
- GDK_F1 : if Shift = [ssAlt] then begin
- ShowBookmarkQuick(True);
- Accept := False;
+ GDK_F1 : begin
+ KeyHandled := True;
+ if Shift = [ssAlt] then begin
+ ShowBookmarkQuick(True);
+ Accept := False;
+ end;
end;
- GDK_F2 : if Shift = [ssAlt] then begin
- ShowBookmarkQuick(False);
- Accept := False;
- end else
- if (Shift = [ssShift]) or (Shift = [ssCtrl]) then begin
- CopyFilenamesToClipboard(Shift = [ssCtrl], LeftPanel);
- end else begin
- DeactivateQuickFind(LeftPanel);
- Accept:= False;
- F6ButtonClick(nil);
+ GDK_F2 : begin
+ KeyHandled := True;
+ if Shift = [ssAlt] then begin
+ ShowBookmarkQuick(False);
+ Accept := False;
+ end else
+ if (Shift = [ssShift]) or (Shift = [ssCtrl]) then begin
+ CopyFilenamesToClipboard(Shift = [ssCtrl], LeftPanel);
+ end else begin
+ DeactivateQuickFind(LeftPanel);
+ Accept:= False;
+ F6ButtonClick(nil);
+ end;
end;
GDK_F3 : begin
DeactivateQuickFind(LeftPanel);
Accept:= False;
+ KeyHandled := True;
F3F4ButtonClick(F3Button);
end;
GDK_F4 : begin
DeactivateQuickFind(LeftPanel);
Accept:= False;
+ KeyHandled := True;
if ssShift in Shift then EditViewFile(LeftPanel, AListView, False, True)
else F3F4ButtonClick(F4Button);
end;
GDK_F5 : begin
DeactivateQuickFind(LeftPanel);
Accept:= False;
+ KeyHandled := True;
if ssShift in Shift then F5ButtonClick(nil)
else F5ButtonClick(Sender);
end;
GDK_F6 : begin
DeactivateQuickFind(LeftPanel);
Accept:= False;
+ KeyHandled := True;
if ssShift in Shift then begin
if not Assigned(AListView.Columns[0].FColumn^.editable_widget) then Editing := False;
DoQuickRename(Sender = LeftListView, AListView, True)
@@ -1379,98 +1407,134 @@ begin
GDK_F7 : begin
DeactivateQuickFind(LeftPanel);
Accept:= False;
+ KeyHandled := True;
if ssAlt in Shift then miSearchClick(Sender)
else F7ButtonClick(Sender);
end;
GDK_F8, GDK_Delete_Key : begin
DeactivateQuickFind(LeftPanel);
Accept:= False;
+ KeyHandled := True;
F8ButtonClick(Sender);
end;
GDK_ESCAPE : begin
if not QuickFind then CommandLineCombo.Entry.Text := '';
DeactivateQuickFind(LeftPanel);
+ KeyHandled := True;
if RunningEscSensitive > 0 then FMainEscPressed := True;
end;
GDK_WIN_POPUP : begin
Accept := False;
+ KeyHandled := True;
PopupFileMenuPos;
end;
- GDK_HOME: if Shift = [ssCtrl] then begin
- if LeftPanel then PathButtonClick(LeftHomeButton)
- else PathButtonClick(RightHomeButton);
- Accept := False;
- end else if Assigned(AListView.Selected) and (AListView.ConvertToSorted(AListView.Selected.Index) = 0) then Accept := False;
- GDK_END: if Assigned(AListView.Selected) and (AListView.ConvertToSorted(AListView.Selected.Index) = AListView.Items.Count - 1) then Accept := False;
- GDK_SLASH, GDK_KP_SLASH: if Shift = [ssCtrl] then begin
- if LeftPanel then PathButtonClick(LeftRootButton)
- else PathButtonClick(RightRootButton);
- Accept := False;
- end else
- if (Shift = []) then ActivateQuickFind(Sender = LeftListView);
+ GDK_HOME: begin
+ if Shift = [ssCtrl] then begin
+ if LeftPanel then PathButtonClick(LeftHomeButton)
+ else PathButtonClick(RightHomeButton);
+ Accept := False;
+ end else if Assigned(AListView.Selected) and (AListView.ConvertToSorted(AListView.Selected.Index) = 0) then Accept := False;
+ KeyHandled := True;
+ end;
+ GDK_END: begin
+ if Assigned(AListView.Selected) and (AListView.ConvertToSorted(AListView.Selected.Index) = AListView.Items.Count - 1)
+ then Accept := False;
+ KeyHandled := True;
+ end;
+ GDK_SLASH, GDK_KP_SLASH: begin
+ if Shift = [ssCtrl] then begin
+ if LeftPanel then PathButtonClick(LeftRootButton)
+ else PathButtonClick(RightRootButton);
+ Accept := False;
+ end else
+ if (Shift = []) then ActivateQuickFind(Sender = LeftListView);
+ KeyHandled := True;
+ end;
{ GDK_0..GDK_9: if ConfBookmarkQuickJump and (Shift = [ssAlt]) then QuickJumpToBookmark(LeftPanel, Key - GDK_1)
else begin
Accept := False;
if QuickFind then QuickFindSendKey(LeftPanel, Key)
else ActivateCommandLine(Key);
end; }
- GDK_Down : if [ssCtrl] = Shift then begin
- Accept := False;
- 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;
+ GDK_Down : begin
+ KeyHandled := True;
+ if [ssCtrl] = Shift then begin
+ Accept := False;
+ 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;
+ end;
end;
- GDK_Up : if Assigned(AListView.Selected) and (AListView.ConvertToSorted(AListView.Selected.Index) = 0) then Accept := False;
-
- GDK_Page_Up, GDK_Page_Down: if (Shift = [ssCtrl]) and ANotebook.Visible then
- begin
- Accept := False;
- x := (ANotebook.PageIndex + 1 - 2*Ord(Key = GDK_Page_Up)) mod ANotebook.ChildrenCount;
- if x < 0 then x := ANotebook.ChildrenCount - 1;
- ANotebook.PageIndex := x;
- end else begin
- if Assigned(AListView.Selected) and
- (((Key = GDK_Page_Up) and (AListView.ConvertToSorted(AListView.Selected.Index) = 0)) or
- ((Key = GDK_Page_Down) and (AListView.ConvertToSorted(AListView.Selected.Index) = AListView.Items.Count - 1)))
- then Accept := False;
+ 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;
+ end;
+ GDK_Page_Up, GDK_Page_Down: begin
+ KeyHandled := True;
+ if (Shift = [ssCtrl]) and ANotebook.Visible then begin
+ Accept := False;
+ x := (ANotebook.PageIndex + 1 - 2*Ord(Key = GDK_Page_Up)) mod ANotebook.ChildrenCount;
+ if x < 0 then x := ANotebook.ChildrenCount - 1;
+ ANotebook.PageIndex := x;
+ end else begin
+ if Assigned(AListView.Selected) and
+ (((Key = GDK_Page_Up) and (AListView.ConvertToSorted(AListView.Selected.Index) = 0)) or
+ ((Key = GDK_Page_Down) and (AListView.ConvertToSorted(AListView.Selected.Index) = AListView.Items.Count - 1)))
+ then Accept := False;
+ end;
end;
- GDK_A, GDK_Capital_A: if (Shift = [ssAlt]) or (Shift = [ssCtrl]) or ((Shift = []) and (not QuickFind))
- then CommandLineComboKeyDown(Sender, Key, Shift, Accept)
- else if QuickFind then QuickFindSendKey(LeftPanel, Key);
+ GDK_A, GDK_Capital_A: if (Shift = [ssAlt]) or (Shift = [ssCtrl]) then begin
+ KeyHandled := True;
+ CommandLineComboKeyDown(Sender, Key, Shift, Accept);
+ end;
GDK_D, GDK_Capital_D: if Shift = [ssCtrl] then begin
Accept := False;
+ KeyHandled := True;
ShowBookmarkQuick(LeftPanel);
- end else begin
- Accept := False;
- if QuickFind then QuickFindSendKey(LeftPanel, Key)
- else ActivateCommandLine(Key);
end;
- GDK_O, GDK_Capital_O : if (Shift = [ssAlt]) then SwitchOtherPanel(LeftPanel, False)
- else begin
+ GDK_O, GDK_Capital_O : if (Shift = [ssAlt]) then begin
Accept := False;
- if QuickFind then QuickFindSendKey(LeftPanel, Key)
- else ActivateCommandLine(Key);
+ KeyHandled := True;
+ SwitchOtherPanel(LeftPanel, False);
end;
GDK_P, GDK_Capital_P, GDK_N, GDK_Capital_N:
- if ((Shift = [ssAlt]) or (Shift = [ssCtrl]) or ((Shift = []) and (not QuickFind))) { and (CommandLineHistory.Count > 0) }
- then CommandLineComboKeyDown(Sender, Key, Shift, Accept)
- else if QuickFind then QuickFindSendKey(LeftPanel, Key);
- GDK_S, GDK_Capital_S : if (Shift = [ssAlt]) or (Shift = [ssCtrl])
- then ActivateQuickFind(Sender = LeftListView)
- else begin
- Accept := False;
- if QuickFind then QuickFindSendKey(LeftPanel, Key)
- else ActivateCommandLine(Key);
- end;
- else if QuickFind then Accept := not QuickFindSendKey(LeftPanel, Key)
- else Accept := not ActivateCommandLine(Key);
+ if ((Shift = [ssAlt]) or (Shift = [ssCtrl])) { and (CommandLineHistory.Count > 0) } then begin
+ KeyHandled := True;
+ CommandLineComboKeyDown(Sender, Key, Shift, Accept);
+ end;
+ GDK_S, GDK_Capital_S : if (Shift = [ssAlt]) or (Shift = [ssCtrl]) then begin
+ KeyHandled := True;
+ ActivateQuickFind(Sender = LeftListView);
+ end;
+// else if not KeyHandled then Accept := not HandleKey(Key, Shift, LeftPanel);
end;
+ if not KeyHandled then Accept := not HandleKey(Key, Shift, LeftPanel);
end;
+function TFMain.HandleKey(Key: Word; Shift: TShiftState; LeftPanel: boolean): boolean;
+var s: string;
+begin
+ Result := False;
+ if Key = 0 then Exit;
+
+ // Filter out all non-character keys
+ s := UTF8Encode(WideChar(KeyValToUnicode(Key)));
+ if (Length(s) = 0) or (s = #0) then begin
+ DebugMsg(['HandleKey: not a character key. Exiting.']);
+ Exit;
+ end;
+
+ if QuickFind then Result := QuickFindSendKey(LeftPanel, Key)
+ else Result := ActivateCommandLine(Key);
+end;
+
+
+(******************************************************************************************************************************************)
procedure TFMain.ListViewEnter(Sender: TObject; var Accept: boolean);
var s: string;
begin