Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ The toolbar provides the following buttons:
* _Settings_: Access settings dialogs.
* _Show Message Window_: Hide or Show the messages window.

The same current-file upload action is also available from the Notepad++ **Plugins > NppFTP > Upload Current File** menu item. Assign a shortcut to that command with Notepad++'s Shortcut Mapper if you want to upload the active local file without clicking the NppFTP toolbar.

## Treeview
If an FTP session is active, the treeview will show the files on the server. Some actions of the toolbar depend on the selected object in the treeview (see toolbar). Double-clicking on a directory will show its contents. Double-clicking on a file will download it to the cache and open it.

Expand Down
7 changes: 7 additions & 0 deletions src/NppFTP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ int NppFTP::ShowAboutDialog() const {
return 0;
}

int NppFTP::UploadCurrentFile() {
if (!m_ftpWindow) {
return -1;
}
return m_ftpWindow->UploadCurrentFile();
}

int NppFTP::OnSave(const TCHAR* path) {
if (!path || !m_ftpSession)
return -1;
Expand Down
1 change: 1 addition & 0 deletions src/NppFTP.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class NppFTP {
int ShowFTPWindow();
int FocusFTPWindow();
int ShowAboutDialog() const;
int UploadCurrentFile();

int OnSave(const TCHAR* path);
int OnActivateLocalFile(const TCHAR* path);
Expand Down
13 changes: 12 additions & 1 deletion src/PluginInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

typedef void* BufferID;

const int nrFuncItem = 3;
const int nrFuncItem = 4;
FuncItem funcItems[nrFuncItem];
NppData nppData;
NppFTP nppFTP;
Expand All @@ -38,6 +38,7 @@ bool isStarted = false;

void __cdecl ShowFTPWindow();
void __cdecl FocusFTPWindow();
void __cdecl UploadCurrentFile();
void __cdecl ShowAboutDialog();
void __cdecl FakeItem();

Expand Down Expand Up @@ -91,6 +92,11 @@ FuncItem * getFuncsArray(int * arraysize) {
funcItems[2]._pShKey = NULL;
lstrcpyn(funcItems[2]._itemName, TEXT("About NppFTP"), menuItemSize);

funcItems[3]._pFunc = &UploadCurrentFile;
funcItems[3]._init2Check = false;
funcItems[3]._pShKey = NULL;
lstrcpyn(funcItems[3]._itemName, TEXT("Upload Current File"), menuItemSize);

return &funcItems[0];
}

Expand Down Expand Up @@ -169,5 +175,10 @@ void __cdecl ShowAboutDialog() {
nppFTP.ShowAboutDialog();
}

void __cdecl UploadCurrentFile() {
if (isStarted)
nppFTP.UploadCurrentFile();
}

void __cdecl FakeItem() {
}
51 changes: 32 additions & 19 deletions src/Windows/FTPWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,37 @@ int FTPWindow::OnActivateLocalFile(const TCHAR* filename) {
return 0;
}

int FTPWindow::UploadCurrentFile(bool promptForFile) {
if (!m_ftpSession || !m_currentSelection) {
return -1;
}

TCHAR source[MAX_PATH]{};
BOOL doUpload = FALSE;

if (promptForFile) {
source[0] = 0;
int res = PU::GetOpenFilename(source, MAX_PATH, m_hParent);
if (res == 0) {
doUpload = TRUE;
}
} else {
doUpload = ::SendMessage(m_hNpp, NPPM_GETFULLCURRENTPATH, (WPARAM)MAX_PATH, (LPARAM)source);
}

if (doUpload != TRUE) {
return -1;
}

if (m_currentSelection->isDir()) {
m_ftpSession->UploadFile(source, m_currentSelection->GetPath(), true);
} else {
m_ftpSession->UploadFile(source, m_currentSelection->GetParent()->GetPath(), true);
}

return 0;
}

int FTPWindow::RegisterClass() {
WNDCLASSEX FTPWindowClass{};
FTPWindowClass.cbSize = sizeof(WNDCLASSEX);
Expand Down Expand Up @@ -469,26 +500,8 @@ LRESULT FTPWindow::MessageProc(UINT uMsg, WPARAM wParam, LPARAM lParam) {
break; }
case IDM_POPUP_UPLOADFILE:
case IDB_BUTTON_TOOLBAR_UPLOAD: {
//upload(TRUE, TRUE); //upload to cached folder is present, else upload to last selected folder
//m_ftpSession->UploadFile();
TCHAR source[MAX_PATH]{};
BOOL doUpload = FALSE;
SHORT state = GetKeyState(VK_CONTROL);
if ((state & 0x8000) && LOWORD(wParam) == IDB_BUTTON_TOOLBAR_UPLOAD) {
source[0] = 0;
int res = PU::GetOpenFilename(source, MAX_PATH, m_hParent);
if (res == 0)
doUpload = TRUE;
} else {
doUpload = ::SendMessage(m_hNpp, NPPM_GETFULLCURRENTPATH, (WPARAM)MAX_PATH, (LPARAM)source);
}
if (doUpload == TRUE) {
if (m_currentSelection->isDir()) {
m_ftpSession->UploadFile(source, m_currentSelection->GetPath(), true);
} else {
m_ftpSession->UploadFile(source, m_currentSelection->GetParent()->GetPath(), true);
}
}
UploadCurrentFile((state & 0x8000) && LOWORD(wParam) == IDB_BUTTON_TOOLBAR_UPLOAD);
result = TRUE;
break;}
case IDM_POPUP_UPLOADOTHERFILE: {
Expand Down
2 changes: 1 addition & 1 deletion src/Windows/FTPWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class FTPWindow : public DockableWindow, public DropTargetWindow, public DropDat
virtual int OnSize(int newWidth, int newHeight);
virtual int OnProfileChange();
virtual int OnActivateLocalFile(const TCHAR* filename);
virtual int UploadCurrentFile(bool promptForFile = false);

static int RegisterClass();

Expand Down Expand Up @@ -104,7 +105,6 @@ class FTPWindow : public DockableWindow, public DropTargetWindow, public DropDat
virtual int Copy(FileObject* fo, FileObject* _newParent);
virtual int VScrollTreeView(LONG pos);

//virtual int UploadCurrentFile(FileObject * parent);
//virtual int UploadOtherFile(FileObject * parent);

Toolbar m_toolbar;
Expand Down