Skip to content

Commit 8a4618b

Browse files
committed
Rename file path copy methods and add remote file support
Refactored the copy file operation methods to use clearer, more descriptive names that better reflect their functionality. Updated method implementations to support remote files in addition to local files. Method renames: - OnCopyFilePath → OnCopyFileFullPath - OnCopyFilePathOnly → OnCopyFolder - OnCopyFileName → OnCopyFileFullName Enhanced the copy operations to detect remote files and handle path operations appropriately. For remote files, use the remote path API; for local files, use wxFileName. Updated OnCopyFilePathRelativeToWorkspace to correctly handle both remote and local workspaces, with proper path separator handling (UNIX vs. NATIVE). * LiteEditor/frame.h * LiteEditor/frame.cpp Generated by CodeLite Signed-off-by: Eran Ifrah <eran@codelite.org>
1 parent 7ae922a commit 8a4618b

File tree

2 files changed

+31
-19
lines changed

2 files changed

+31
-19
lines changed

LiteEditor/frame.cpp

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -654,9 +654,9 @@ EVT_MENU(XRCID("detach_debugger_tab"), clMainFrame::OnDetachDebuggerViewTab)
654654
EVT_MENU(XRCID("close_other_tabs"), clMainFrame::OnCloseAllButThis)
655655
EVT_MENU(XRCID("close_tabs_to_the_right"), clMainFrame::OnCloseTabsToTheRight)
656656
EVT_MENU(XRCID("copy_file_relative_path_to_workspace"), clMainFrame::OnCopyFilePathRelativeToWorkspace)
657-
EVT_MENU(XRCID("copy_file_name"), clMainFrame::OnCopyFilePath)
658-
EVT_MENU(XRCID("copy_file_path"), clMainFrame::OnCopyFilePathOnly)
659-
EVT_MENU(XRCID("copy_file_name_only"), clMainFrame::OnCopyFileName)
657+
EVT_MENU(XRCID("copy_file_name"), clMainFrame::OnCopyFileFullPath)
658+
EVT_MENU(XRCID("copy_file_path"), clMainFrame::OnCopyFolder)
659+
EVT_MENU(XRCID("copy_file_name_only"), clMainFrame::OnCopyFileFullName)
660660
EVT_MENU(XRCID("open_shell_from_filepath"), clMainFrame::OnOpenShellFromFilePath)
661661
EVT_MENU(XRCID("open_file_explorer"), clMainFrame::OnOpenFileExplorerFromFilePath)
662662
EVT_MENU(XRCID("ID_DETACH_EDITOR"), clMainFrame::OnDetachEditor)
@@ -3875,30 +3875,32 @@ void clMainFrame::OnViewDisplayEOL_UI(wxUpdateUIEvent& e)
38753875
e.Check(m_frameGeneralInfo.GetFlags() & CL_SHOW_EOL ? true : false);
38763876
}
38773877

3878-
void clMainFrame::OnCopyFileName(wxCommandEvent& event)
3878+
void clMainFrame::OnCopyFileFullName(wxCommandEvent& event)
38793879
{
38803880
clEditor* editor = GetEditorFromEvent(GetMainBook(), event);
38813881
CHECK_PTR_RET(editor);
38823882

3883-
wxString fileName = editor->GetFileName().GetFullName();
3884-
::CopyToClipboard(fileName);
3883+
wxString file_name;
3884+
file_name = editor->IsRemoteFile() ? editor->GetRemotePath().AfterLast('/') : editor->GetFileName().GetFullName();
3885+
::CopyToClipboard(file_name);
38853886
}
38863887

3887-
void clMainFrame::OnCopyFilePath(wxCommandEvent& event)
3888+
void clMainFrame::OnCopyFileFullPath(wxCommandEvent& event)
38883889
{
38893890
clEditor* editor = GetEditorFromEvent(GetMainBook(), event);
38903891
CHECK_PTR_RET(editor);
38913892

3892-
wxString fileName = editor->GetFileName().GetFullPath();
3893-
::CopyToClipboard(fileName);
3893+
::CopyToClipboard(editor->GetRemotePathOrLocal());
38943894
}
38953895

3896-
void clMainFrame::OnCopyFilePathOnly(wxCommandEvent& event)
3896+
void clMainFrame::OnCopyFolder(wxCommandEvent& event)
38973897
{
38983898
clEditor* editor = GetEditorFromEvent(GetMainBook(), event);
38993899
CHECK_PTR_RET(editor);
3900-
wxString fileName = editor->GetFileName().GetPath(wxPATH_GET_VOLUME);
3901-
::CopyToClipboard(fileName);
3900+
3901+
wxString file_name;
3902+
file_name = editor->IsRemoteFile() ? editor->GetRemotePath().BeforeLast('/') : editor->GetFileName().GetPath();
3903+
::CopyToClipboard(file_name);
39023904
}
39033905

39043906
void clMainFrame::OnWorkspaceMenuUI(wxUpdateUIEvent& e)
@@ -5701,13 +5703,23 @@ void clMainFrame::OnCopyFilePathRelativeToWorkspace(wxCommandEvent& event)
57015703
{
57025704
wxUnusedVar(event);
57035705
IEditor* editor = GetIEditorFromEvent(GetMainBook(), event);
5706+
auto workspace = clWorkspaceManager::Get().GetWorkspace();
57045707
CHECK_PTR_RET(editor);
5705-
CHECK_COND_RET(clWorkspaceManager::Get().IsWorkspaceOpened());
5708+
CHECK_PTR_RET(workspace);
57065709

5707-
wxFileName fn(editor->GetFileName());
5708-
fn.MakeRelativeTo(clWorkspaceManager::Get().GetWorkspace()->GetDir());
5710+
wxString path_to_copy;
5711+
if (workspace->IsRemote()) {
5712+
wxString workspace_path = workspace->GetDir();
5713+
wxFileName fn(editor->GetRemotePathOrLocal(), wxPATH_UNIX);
5714+
fn.MakeRelativeTo(workspace_path);
5715+
path_to_copy = fn.GetFullPath(wxPATH_UNIX);
5716+
} else {
5717+
wxFileName fn(editor->GetFileName());
5718+
fn.MakeRelativeTo(clWorkspaceManager::Get().GetWorkspace()->GetDir());
5719+
path_to_copy = fn.GetFullPath(wxPATH_NATIVE);
5720+
}
57095721

5710-
::CopyToClipboard(fn.GetFullPath());
5722+
::CopyToClipboard(path_to_copy);
57115723
}
57125724

57135725
void clMainFrame::OnCopyFilePathRelativeToWorkspaceUI(wxUpdateUIEvent& event)

LiteEditor/frame.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -552,10 +552,10 @@ class clMainFrame : public wxFrame
552552
void OnQuickOutline(wxCommandEvent& event);
553553
void OnImportMSVS(wxCommandEvent& e);
554554
void OnDebugAttach(wxCommandEvent& event);
555-
void OnCopyFilePath(wxCommandEvent& event);
555+
void OnCopyFileFullPath(wxCommandEvent& event);
556556
void OnCopyFilePathRelativeToWorkspace(wxCommandEvent& event);
557-
void OnCopyFilePathOnly(wxCommandEvent& event);
558-
void OnCopyFileName(wxCommandEvent& event);
557+
void OnCopyFolder(wxCommandEvent& event);
558+
void OnCopyFileFullName(wxCommandEvent& event);
559559
void OnHighlightWord(wxCommandEvent& event);
560560
void OnHighlightWordUI(wxUpdateUIEvent& event);
561561
void OnShowNavBar(wxCommandEvent& e);

0 commit comments

Comments
 (0)