summaryrefslogtreecommitdiff
path: root/UMain.pas
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2008-06-14 13:16:51 +0200
committerTomas Bzatek <tbzatek@users.sourceforge.net>2008-06-14 13:16:51 +0200
commitb1dfa430702770c83c815bec24f1dc72175e1e5e (patch)
treef32fff8cd27db1842d3e2dbefdb0af04f5f0b064 /UMain.pas
parent0e9829d522373f39770b317dcff7095c02dbc4be (diff)
downloadtuxcmd-b1dfa430702770c83c815bec24f1dc72175e1e5e.tar.xz
Added option to exclude filename extension from selection on quick-rename
Resolves #1982347 Fixed some minor quickrename-related issues
Diffstat (limited to 'UMain.pas')
-rw-r--r--UMain.pas66
1 files changed, 56 insertions, 10 deletions
diff --git a/UMain.pas b/UMain.pas
index a7dd28a..0d4d0fa 100644
--- a/UMain.pas
+++ b/UMain.pas
@@ -231,6 +231,8 @@ type
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;
+ function IsEditing(AListView: TGTKListView): boolean;
+ function PanelFindEditableWidget(AListView: TGTKListView): PGtkWidget;
public
LeftPanelEngine, RightPanelEngine : TPanelEngine;
ColumnSortIDs: array[1..ConstNumPanelColumns] of integer;
@@ -1400,8 +1402,8 @@ begin
Accept:= False;
KeyHandled := True;
if ssShift in Shift then begin
- if not Assigned(AListView.Columns[0].FColumn^.editable_widget) then Editing := False;
- DoQuickRename(LeftPanel, AListView, True)
+ Editing := IsEditing(AListView);
+ DoQuickRename(LeftPanel, AListView, True);
end else F6ButtonClick(Sender);
end;
GDK_F7 : begin
@@ -2108,20 +2110,41 @@ begin
end;
end;
+function TFMain.IsEditing(AListView: TGTKListView): boolean;
+var i: integer;
+begin
+ Result := False;
+ for i := 0 to AListView.Columns.Count - 1 do
+ if Assigned(AListView.Columns[i].FColumn^.editable_widget) then Result := True;
+end;
+
+function TFMain.PanelFindEditableWidget(AListView: TGTKListView): PGtkWidget;
+var i: integer;
+begin
+ Result := nil;
+ for i := 0 to AListView.Columns.Count - 1 do
+ if Assigned(AListView.Columns[i].FColumn^.editable_widget) then begin
+ Result := AListView.Columns[i].FColumn^.editable_widget;
+ Break;
+ end;
+end;
+
procedure TFMain.ProcessMarkKey(KeyType, Key: integer);
var LeftPanel: boolean;
ListView: TGTKListView;
Pos: integer;
+ editable: PGtkEditable;
begin
if LeftListView.Focused then LeftPanel := True else
if RightListView.Focused then LeftPanel := False else
LeftPanel := LeftLastFocused;
if LeftPanel then ListView := LeftListView
else ListView := RightListView;
- if Editing and Assigned(ListView.Columns[0].FColumn^.editable_widget) then begin
- Pos := gtk_editable_get_position(PGtkEditable(ListView.Columns[0].FColumn^.editable_widget));
- gtk_editable_insert_text(PGtkEditable(ListView.Columns[0].FColumn^.editable_widget), PChar(UTF8Encode(WideChar(KeyValToUnicode(Key)))), 1, @Pos);
- gtk_editable_set_position(PGtkEditable(ListView.Columns[0].FColumn^.editable_widget), Pos);
+ editable := PanelFindEditableWidget(ListView);
+ if Editing and Assigned(editable) then begin
+ Pos := gtk_editable_get_position(editable);
+ gtk_editable_insert_text(editable, PChar(UTF8Encode(WideChar(KeyValToUnicode(Key)))), 1, @Pos);
+ gtk_editable_set_position(editable, Pos);
end;
if CommandLineCombo.Entry.Focused then ActivateCommandLine(Key, True) else
if QuickFind then QuickFindSendKey(LeftPanel, Key)
@@ -2472,6 +2495,8 @@ var i: integer;
AFProgress: TFProgress;
CurrentEngine, OppositeEngine: TPanelEngine;
s: string;
+ p: PChar;
+ BypassSelAll: boolean;
begin
try
InternalLock;
@@ -2486,6 +2511,7 @@ begin
Exit;
end;
+ BypassSelAll := False;
SelSingle := '';
if SelCount = 0 then begin
SelCount := 1;
@@ -2510,12 +2536,23 @@ begin
FCopyMove.Label1.Caption := Format(LANGMoveRenameDFileDirectoriesTo, [SelCount]);
end;
if ShiftPressed then begin
- if SelSingle <> '' then FCopyMove.Entry.Text := SelSingle
- else FCopyMove.Entry.Text := '*.*';
+ if SelSingle <> '' then begin
+ FCopyMove.Entry.Text := SelSingle;
+ if ConfQuickRenameSkipExt then begin
+ p := gtk_entry_get_text(PGtkEntry(FCopyMove.Entry.FWidget));
+ if (p <> nil) and (g_utf8_strlen(p, -1) > 0) then begin
+// DebugMsg(['TFMain.DoCopyMove: p = "', p, '", g_utf8_strlen(p) = ', g_utf8_strlen(p, -1)]);
+ if AnsiPos('.', p) > 0 then begin
+ FCopyMove.Entry.SelectRegion(0, g_utf8_strlen(p, -1) - g_utf8_strlen(PChar(ExtractFileExt(p)), -1));
+ BypassSelAll := True;
+ end;
+ end;
+ end;
+ end else FCopyMove.Entry.Text := '*.*';
end else
if OppositeEngine is TLocalTreeEngine then FCopyMove.Entry.Text := OppositeEngine.Path
else FCopyMove.Entry.Text := Format(ConstFullPathFormatStr, [OppositeEngine.GetPrefix, OppositeEngine.Path]);
- FCopyMove.Entry.SelectAll;
+ if not BypassSelAll then FCopyMove.Entry.SelectAll;
if FCopyMove.Run <> mbOK then Exit;
NewPathx := FCopyMove.Entry.Text;
NewPath := UTF8ToStr(FCopyMove.Entry.Text);
@@ -2685,6 +2722,7 @@ end;
procedure TFMain.DoQuickRename(LeftPanel: boolean; ListView: TGTKListView; const CalledFromKey: boolean);
var i: integer;
+ s: PChar;
begin
if (not Assigned(ListView.Selected)) or (not Assigned(ListView.Selected.Data)) or
PDataItem(ListView.Selected.Data)^.UpDir or Editing then Exit;
@@ -2694,7 +2732,15 @@ begin
if ColumnSortIDs[i] in [1, 2] then begin
ListView.Columns[i - 1].SetProperty('editable', 1);
ListView.StartEditing(i - 1);
- Break;
+ if ConfQuickRenameSkipExt and (ListView.Columns[i - 1].FColumn^.editable_widget <> nil) then begin
+ s := gtk_entry_get_text(PGtkEntry(ListView.Columns[i - 1].FColumn^.editable_widget));
+ if (s <> nil) and (g_utf8_strlen(s, -1) > 0) then begin
+ DebugMsg(['TFMain.DoQuickRename: s = "', s, '", g_utf8_strlen(s) = ', g_utf8_strlen(s, -1)]);
+ if AnsiPos('.', s) > 0 then
+ gtk_editable_select_region(PGtkEditable(ListView.Columns[i - 1].FColumn^.editable_widget), 0, g_utf8_strlen(s, -1) - g_utf8_strlen(PChar(ExtractFileExt(s)), -1));
+ end;
+ end;
+ Break;
end;
end;