trzsz / trzsz.js

trzsz.js is the js version of trzsz, makes terminal built with electron and webshell to support trzsz ( trz / tsz ).
https://trzsz.github.io/js
MIT License
189 stars 12 forks source link

Does electron enable drag-and-drop uploads #7

Closed wenbingzhang closed 2 years ago

wenbingzhang commented 2 years ago

Does electron enable drag-and-drop uploads

lonnywong commented 2 years ago

Not yet. trzsz.js will support the feature.

It should be an api of TrzszFilter and TrzszAddon. I may name it uploadFiles.

The client of trzsz.js can listen on the drag event, and call trzsz.js api to upload the dragging files.

See also: https://www.geeksforgeeks.org/drag-and-drop-files-in-electronjs/

https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/File_drag_and_drop

wenbingzhang commented 2 years ago

I'm looking forward to this feature being developed

lonnywong commented 2 years ago

v0.4.0 supports dragging files and directories to upload.

wenbingzhang commented 2 years ago

Drag and drop uploads work fine, the display is just a little unfriendly.

image
lonnywong commented 2 years ago

I've try to hide the trz. Sounds like it's not working.

https://github.com/trzsz/trzsz.js/blob/7f43fe43f63a8271ec36107765e50426b555d583/src/filter.ts#L130-L139

Could you try to figure out why?

lonnywong commented 2 years ago

What's the type of the server output? Blob, or Uint8Array, or ArrayBuffer?

wenbingzhang commented 2 years ago

https://github.com/trzsz/trzsz.js/blob/7f43fe43f63a8271ec36107765e50426b555d583/src/filter.ts#L233

Although the complete command is sent here, "processServerOutput" may receive split characters.

lonnywong commented 2 years ago

Maybe. Could you print some log in here?

https://github.com/trzsz/trzsz.js/blob/7f43fe43f63a8271ec36107765e50426b555d583/src/filter.ts#L130-L139

Figure out the server output, then we can skip it.

wenbingzhang commented 2 years ago
image
wenbingzhang commented 2 years ago

I've tested it many times. Sometimes it's a different result.

lonnywong commented 2 years ago

Is it Uint8Array? It may has some characters unprintable. Could you print the char codes too?

lonnywong commented 2 years ago

I've tested it many times. Sometimes it's a different result.

Collect all the cases, we can do it. We need to print each ascii code.

wenbingzhang commented 2 years ago
image
wenbingzhang commented 2 years ago

https://github.com/trzsz/trzsz.js/blob/7f43fe43f63a8271ec36107765e50426b555d583/src/filter.ts#L130-L139 If no breakpoint is set, the returned data is the same, but after setting a breakpoint, the automatic upload will be disabled and a file selection dialog will be prompted.

lonnywong commented 2 years ago
image

Could you print the printable log and char codes together? It would be easy to analyze. Thanks very much.

lonnywong commented 2 years ago

https://github.com/trzsz/trzsz.js/blob/7f43fe43f63a8271ec36107765e50426b555d583/src/filter.ts#L130-L139

If no breakpoint is set, the returned data is the same, but after setting a breakpoint, the automatic upload will be disabled and a file selection dialog will be prompted.

The reason is: https://github.com/trzsz/trzsz.js/blob/7f43fe43f63a8271ec36107765e50426b555d583/src/filter.ts#L235-L245

wenbingzhang commented 2 years ago

I think "trz" can be displayed in "xterm", but it needs the correct line break.

lonnywong commented 2 years ago

I think "trz" can be displayed in "xterm", but it needs the correct line break.

But we need to figure out the server output first. Could you print the printable log and ascii codes together?

wenbingzhang commented 2 years ago
image

Is that right?

lonnywong commented 2 years ago

That's it. Thanks. Looks like I have to learn more about vt100.

lonnywong commented 2 years ago

@wenbingzhang If just remove these code, What will it show?

https://github.com/trzsz/trzsz.js/blob/7f43fe43f63a8271ec36107765e50426b555d583/src/filter.ts#L130-L139

wenbingzhang commented 2 years ago
image
lonnywong commented 2 years ago

It looks not bad.

Type some garbage into the command line without a carriage return, what will it show after dragging files to upload?

And If move the cursor to the middle of the garbage, what will it show after dragging files to upload?

wenbingzhang commented 2 years ago
image
lonnywong commented 2 years ago

All right. I want to keep the garbage unchanged.

Since it doesn't work in some environments ( e.g., yours ), I'm going to remove it.

lonnywong commented 2 years ago

Should be solved with v0.4.1.

wenbingzhang commented 2 years ago

It has been updated and tested, and it works fine.

lonnywong commented 2 years ago

@wenbingzhang

Thanks for your feedback.