diff options
| -rw-r--r-- | UConfig.pas | 9 | ||||
| -rw-r--r-- | UMain.pas | 66 | ||||
| -rw-r--r-- | UPreferences.pas | 44 |
3 files changed, 87 insertions, 32 deletions
diff --git a/UConfig.pas b/UConfig.pas index d68fc01..e295e2d 100644 --- a/UConfig.pas +++ b/UConfig.pas @@ -25,8 +25,8 @@ uses Classes, ULocale; resourcestring ConstAppTitle = 'Tux Commander'; - ConstAboutVersion = '0.6.42-dev'; - ConstAboutBuildDate = '2008-06-11'; + ConstAboutVersion = '0.6.43-dev'; + ConstAboutBuildDate = '2008-06-14'; {$IFDEF __FPC__} {$INCLUDE fpcver.inc} @@ -95,7 +95,7 @@ var ConfPanelSep, ConfRowHeight, ConfRowHeightReal, ConfNumHistoryItems, ConfLinkItemDefaultColors, ConfDotFileItemDefaultColors, ConfLynxLikeMotion, ConfSizeGroupRequestZeroDigits, ConfDisableFileTips, ConfInsMoveDown, ConfSpaceMovesDown, ConfShowFuncButtons, ConfSelectAllDirs, ConfOctalPerm: boolean; ConfMounterUseFSTab, ConfShowTextUIDs, ConfMounterPushDown, ConfSavePanelTabs, ConfDuplicateTabWarning, - ConfOpenConnectionsWarning, ConfSortDirectoriesLikeFiles: boolean; + ConfOpenConnectionsWarning, ConfSortDirectoriesLikeFiles, ConfQuickRenameSkipExt: boolean; ConfShowMounterBar: integer; ConfColumnSizes, ConfColumnIDs: array[1..ConstNumPanelColumns] of integer; @@ -244,6 +244,7 @@ begin ConfCustomTimeFormat := '%X'; ConfQuickSearchActivationKey := 0; ConfSortDirectoriesLikeFiles := False; + ConfQuickRenameSkipExt := True; // Setup default values for colors @@ -468,6 +469,7 @@ begin ConfCustomTimeFormat := IniFile.ReadString(ConfProfileName, 'CustomTimeFormat', ConfCustomTimeFormat); ConfQuickSearchActivationKey := IniFile.ReadInteger(ConfProfileName, 'QuickSearchActivationKey', ConfQuickSearchActivationKey); ConfSortDirectoriesLikeFiles := IniFile.ReadBool(ConfProfileName, 'SortDirectoriesLikeFiles', ConfSortDirectoriesLikeFiles); + ConfQuickRenameSkipExt := IniFile.ReadBool(ConfProfileName, 'QuickRenameSkipExt', ConfQuickRenameSkipExt); SearchForDefaultApps; @@ -557,6 +559,7 @@ begin IniFile.WriteString(ConfProfileName, 'CustomTimeFormat', ConfCustomTimeFormat); IniFile.WriteInteger(ConfProfileName, 'QuickSearchActivationKey', ConfQuickSearchActivationKey); IniFile.WriteBool(ConfProfileName, 'SortDirectoriesLikeFiles', ConfSortDirectoriesLikeFiles); + IniFile.WriteBool(ConfProfileName, 'QuickRenameSkipExt', ConfQuickRenameSkipExt); except @@ -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; diff --git a/UPreferences.pas b/UPreferences.pas index 82ea5f3..9c73adc 100644 --- a/UPreferences.pas +++ b/UPreferences.pas @@ -79,6 +79,7 @@ type SortDirectoriesLikeFilesCheckBox: TGTKCheckButton; TempPathLabel, VFSTempPathLabel: TGTKLabel; VFSTempPathEntry: TGTKEntry; + QuickRenameSkipExtCheckBox: TGTKCheckButton; procedure FormCreate(Sender: TObject); override; procedure FormDestroy(Sender: TObject); @@ -111,7 +112,7 @@ procedure TFPreferences.FormCreate(Sender: TObject); var i: integer; Item: TGTKMenuItem; begin - SetDefaultSize(450, 570); + SetDefaultSize(450, 600); Caption := LANGPreferences_Caption; Buttons := [mbOK, mbCancel]; ShowSeparator := False; @@ -335,54 +336,57 @@ begin PanelsPage.AddControlEx(PanelsLabel2, False, False, 5); Table5 := TGTKTable.Create(Self); - Table5.SetRowColCount(17, 2); + Table5.SetRowColCount(18, 2); PanelsPage.AddControlEx(Table5, False, False, 0); DisableMouseRename := TGTKCheckButton.CreateWithLabel(Self, LANGPreferences_DisableMouseRenaming); DisableMouseRename.Tooltip := LANGPreferencesDisableMouseRename_Tooltip; Table5.AddControl(0, 0, 2, 1, DisableMouseRename, 30, 2); + QuickRenameSkipExtCheckBox := TGTKCheckButton.CreateWithLabel(Self, 'Select name part only on quick-rename'); + QuickRenameSkipExtCheckBox.Tooltip := 'Exclude filename extension from the selection when doing quick-rename'; + Table5.AddControl(0, 1, 2, 1, QuickRenameSkipExtCheckBox, 30, 2); DisableFileTipsCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGPreferencesDisableFileTipsCheckBox_Caption); DisableFileTipsCheckBox.Tooltip := LANGPreferencesDisableFileTipsCheckBox_Tooltip; - Table5.AddControl(0, 1, 2, 1, DisableFileTipsCheckBox, 30, 2); + Table5.AddControl(0, 2, 2, 1, DisableFileTipsCheckBox, 30, 2); SortDirectoriesLikeFilesCheckBox := TGTKCheckButton.CreateWithLabel(Self, 'Sort directories lik_e files'); SortDirectoriesLikeFilesCheckBox.Tooltip := 'Check this to allow sorting directories along with files. Directories are always first in the list.'#10'Unchecked: directories are always sorted by name.'; - Table5.AddControl(0, 2, 2, 1, SortDirectoriesLikeFilesCheckBox, 30, 2); - Table5.AddControl(0, 3, 2, 1, TGTKVBox.Create(Self), 0, 7); + Table5.AddControl(0, 3, 2, 1, SortDirectoriesLikeFilesCheckBox, 30, 2); + Table5.AddControl(0, 4, 2, 1, TGTKVBox.Create(Self), 0, 7); PanelsLabel3 := TGTKLabel.Create(Self); PanelsLabel3.XAlign := 0; PanelsLabel3.XPadding := 0; PanelsLabel3.Caption := Format('<span weight="ultrabold">%s</span>', [LANGPreferencesShow]); PanelsLabel3.UseMarkup := True; - Table5.AddControl(0, 4, 2, 1, PanelsLabel3, 10, 2); + Table5.AddControl(0, 5, 2, 1, PanelsLabel3, 10, 2); ShowFiletypeIcons := TGTKCheckButton.CreateWithLabel(Self, LANGPreferences_ShowFiletypeIconsInList); - Table5.AddControl(0, 5, 2, 1, ShowFiletypeIcons, 30, 2); + Table5.AddControl(0, 6, 2, 1, ShowFiletypeIcons, 30, 2); DirsInBoldCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGPreferencesDirsInBoldCheckBox_Caption); - Table5.AddControl(0, 6, 2, 1, DirsInBoldCheckBox, 30, 2); + Table5.AddControl(0, 7, 2, 1, DirsInBoldCheckBox, 30, 2); DisableDirectoryBracketsCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGPreferencesDisableDirectoryBracketsCheckBox_Caption); - Table5.AddControl(0, 7, 2, 1, DisableDirectoryBracketsCheckBox, 30, 2); + Table5.AddControl(0, 8, 2, 1, DisableDirectoryBracketsCheckBox, 30, 2); OctalPermissionsCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGPreferencesOctalPermissionsCheckBox_Caption); OctalPermissionsCheckBox.Tooltip := LANGPreferencesOctalPermissionsCheckBox_Tooltip; - Table5.AddControl(0, 8, 2, 1, OctalPermissionsCheckBox, 30, 2); + Table5.AddControl(0, 9, 2, 1, OctalPermissionsCheckBox, 30, 2); ShowTextUIDsCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGShowTextUIDsCheckBox_Caption); ShowTextUIDsCheckBox.Tooltip := LANGShowTextUIDsCheckBox_Tooltip; - Table5.AddControl(0, 9, 2, 1, ShowTextUIDsCheckBox, 30, 2); - Table5.AddControl(0, 10, 2, 1, TGTKVBox.Create(Self), 0, 7); + Table5.AddControl(0, 10, 2, 1, ShowTextUIDsCheckBox, 30, 2); + Table5.AddControl(0, 11, 2, 1, TGTKVBox.Create(Self), 0, 7); PanelsLabel4 := TGTKLabel.Create(Self); PanelsLabel4.XAlign := 0; PanelsLabel4.XPadding := 0; PanelsLabel4.Caption := Format('<span weight="ultrabold">%s</span>', [LANGPreferencesMovement]); PanelsLabel4.UseMarkup := True; - Table5.AddControl(0, 11, 2, 1, PanelsLabel4, 10, 2); + Table5.AddControl(0, 12, 2, 1, PanelsLabel4, 10, 2); LynxLikeMotionCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGPreferencesLynxLikeMotionCheckBox_Caption); - Table5.AddControl(0, 12, 2, 1, LynxLikeMotionCheckBox, 30, 2); + Table5.AddControl(0, 13, 2, 1, LynxLikeMotionCheckBox, 30, 2); InsertMovesDownCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGPreferencesInsertMovesDownCheckBox_Caption); - Table5.AddControl(0, 13, 2, 1, InsertMovesDownCheckBox, 30, 2); + Table5.AddControl(0, 14, 2, 1, InsertMovesDownCheckBox, 30, 2); SpaceMovesDownCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGPreferencesSpaceMovesDownCheckBox_Caption); - Table5.AddControl(0, 14, 2, 1, SpaceMovesDownCheckBox, 30, 2); + Table5.AddControl(0, 15, 2, 1, SpaceMovesDownCheckBox, 30, 2); QuickSearchLabel := TGTKLabel.Create(Self); QuickSearchLabel.Caption := 'Quick search _keystroke:'; @@ -403,9 +407,9 @@ begin Item := TGTKMenuItem.CreateTyped(Self, itLabel); Item.Caption := 'letters directly'; QuickSearchOptionMenu.Items.Add(Item); - Table5.AddControl(0, 15, 2, 1, TGTKVBox.Create(Self), 0, 2); - Table5.AddControlEx(0, 16, 1, 1, QuickSearchLabel, [taoShrink], [taoShrink], 35, 2); - Table5.AddControlEx(1, 16, 1, 1, QuickSearchOptionMenu, [taoExpand, taoFill], [taoShrink, taoExpand, taoFill], 20, 2); + Table5.AddControl(0, 16, 2, 1, TGTKVBox.Create(Self), 0, 2); + Table5.AddControlEx(0, 17, 1, 1, QuickSearchLabel, [taoShrink], [taoShrink], 35, 2); + Table5.AddControlEx(1, 17, 1, 1, QuickSearchOptionMenu, [taoExpand, taoFill], [taoShrink, taoExpand, taoFill], 20, 2); // ********* PAGE Applications @@ -914,6 +918,7 @@ begin QuickSearchOptionMenu.ItemIndex := ConfQuickSearchActivationKey; SortDirectoriesLikeFilesCheckBox.Checked := ConfSortDirectoriesLikeFiles; VFSTempPathEntry.Text := StrToUTF8(ConfTempPath); + QuickRenameSkipExtCheckBox.Checked := ConfQuickRenameSkipExt; DefaultFontCheckBoxToggled(Self); ColorButtonDefaultsToggled(Self); @@ -986,6 +991,7 @@ begin ConfQuickSearchActivationKey := QuickSearchOptionMenu.ItemIndex; ConfSortDirectoriesLikeFiles := SortDirectoriesLikeFilesCheckBox.Checked; ConfTempPath := UTF8ToStr(VFSTempPathEntry.Text); + ConfQuickRenameSkipExt := QuickRenameSkipExtCheckBox.Checked; end; (********************************************************************************************************************************) |
