To give you the best experience, this site uses cookies. Continuing to use 9bis.net means you agree to our use of cookies.
 

English version Russian version Version française Nederlandse versie Versión española Version portuguese Version polonaise Italian version Versiunea româna   KiTTY News

KiTTY : Forum

Last modification : -

KiTTY web site




Forum Home
 

[Patch] Upload file to the current directory on drag'n'drop

Yang - Thu 31/03/2011 03:21:49 CEST +0200

Hi Cyd,

First of all, I would like to thank you very much for such a wonderful program. I use Kitty on a daily base and find the drag'n'drop feature very convenient. I notice that when uploading files using pscp(drag'n'drop), it always uploads to the home directory. So I created a patch which allows uploading to the current directory. Basically it will firstly try to retrieve the current directory from the osc_string. Otherwise it will just fall back to use the home directory. Please see if this fits to be merged into the source tree.

Here is the patch file:
========================================================================
--- C:/Playground/kitty_src_new/kitty.c.orig Thu Mar 03 17:11:57 2011
+++ C:/Playground/kitty_src_new/kitty.c Tue Mar 29 13:13:37 2011
@@ -508,6 +508,29 @@
}
#endif

+char * kitty_current_dir()
+{
+ static char cdir[1024];
+ char * dir = strstr(term->osc_string, ":") + 1;
+ if(dir)
+ {
+ if(*dir == '~')
+ {
+ if(strlen(cfg.username)>0)
+ {
+ snprintf(cdir, 1024, "\"/home/%s/%s\"", cfg.username, dir + 1);
+ return cdir;
+ }
+ }
+ else if(*dir == '/')
+ {
+ snprintf(cdir, 1024, "\"%s\"", dir);
+ return cdir;
+ }
+ }
+ return NULL;
+}
+
// Centre un dialog au milieu de la fenetre parent
void CenterDlgInParent(HWND hDlg)
{
@@ -1833,6 +1856,9 @@
void SendOneFile( HWND hwnd, char * directory, char * filename, char * distantdir) {
char buffer[4096], pscppath[4096]="", pscpport[16]="22", remotedir[4096]=".",dir[4096], b1[256] ;

+ if( distantdir == NULL ) {
+ distantdir = kitty_current_dir();
+ }
if( PSCPPath==NULL ) {
if( IniFileFlag == SAVEMODE_REG ) return ;
else if( !SearchPSCP() ) return ;
@@ -3496,6 +3522,9 @@
void StartWinSCP( HWND hwnd, char * directory ) {
char cmd[4096], shortpath[1024], buffer[256] ;

+ if( directory == NULL ) {
+ directory = kitty_current_dir();
+ }
if( WinSCPPath==NULL ) {
if( IniFileFlag == SAVEMODE_REG ) return ;
else if( !SearchWinSCP() ) return ;

Tom - Thu 10/12/2015 00:55:30 CET +0100

Has this ever been included ?

If so how do I use it ?

Thanks

Jason - Tue 21/06/2016 13:20:01 CEST +0200

I looked at the source code and it looks like it was included in the current version. But I can't seem to make it work.

It looks like it works off of the current window title, so I changed the settings to respond with window title for remote title query, just in case, and manually set the window title to %%u@%%h:%%f. Still no dice.

It's a pity, as this really needs to work for the drag-n-drop feature to be useful.

Jason - Tue 21/06/2016 20:38:03 CEST +0200

On closer inspection, there is a comment in the source saying "This code is very specific and does not work everywhere" and the whole subroutine is basically disabled.

I do think there is a good/easy way to do what we're looking for. Essentially when a file is dropped in the window, you should call SendAutoCommand with the command 'printf "3];__pw:"`pwd`"{CONTENT}7";' to capture the directory, and then call the transfer routine, using the existing variable RemotePath to set your destination.

This should work. I just can't test it since I can't even get the bone stock kitty to compile. (missing libraries and no documentation)




Answer


The forum is actually closed