Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy/paste macros for WSL #15

Open
emendelson opened this issue Aug 25, 2022 · 6 comments
Open

Copy/paste macros for WSL #15

emendelson opened this issue Aug 25, 2022 · 6 comments

Comments

@emendelson
Copy link
Contributor

emendelson commented Aug 25, 2022

For keyboard-only copy/paste between WSL Linux and the Windows clipboard, here are two macros. They are filled with ancient code left over from WPDOS 5.1 and dosemu2 versions, and could easily be cleaned up, but at least they seem to work. I haven't tested any optional features found in the code.

I found the required commands here:

https://superuser.com/questions/1618537/use-clipboard-through-wsl

If you use the pasting macro in the Windows Console Host with the Ubuntu terminal, it triggers the bug described here, which changes the display font to raster fonts:

https://superuser.com/questions/1617959/on-wsl1-getting-clipboard-contents-using-powerhshell-changes-terminal-appearanc/1617985#1617985

On my system, this problem doesn't occur with xterm or the Windows Terminal, but it does occur with the Windows Console Host.

Here are the macros:

https://www.dropbox.com/s/v7pzk8tx7w1saen/wlcopy.wpm?dl=0

https://www.dropbox.com/s/0u8pzizs97xsgbd/wlpaste.wpm?dl=0

Any improvements, suggestions, etc., will be welcome. This is rough-and-ready code.

If you edit the macros in the WP macro editor, note that you enter the ASCII tilde by pressing Ctrl-V, then the tilde (Shift-backquote on a US keyboard). The tilde that you enter into the editor when you simply type the tilde key is a special code, not an ASCII tilde. (I haven't tried using the macro edtior from @taviso but instead edited the macros in the DOS ed.exe editor.)

@taviso
Copy link
Owner

taviso commented Aug 25, 2022

Thanks, I'll test them out maybe I should add these to the distribution!

Note that I think paste isn't necessary, because Shift+Ins will work in XTerm -- or at least, it will on real X11 -- I don't know about Windows!

The main problem is copying. It's not easy to copy more text than is visible on the screen from fullscreen terminal programs, and I think it's not possible at all with just the keyboard. Even if the text you want is visible, it won't respect things like column layouts (some terminals do have rectangle select, but not all).

So WP block -> clipboard could definitely be useful.

@taviso
Copy link
Owner

taviso commented Aug 25, 2022

Oh I'm wrong - it is possible to copy visible text with just the keyboard in XTerm, just not by default.

You have to bind the select-cursor-start() Xt intrinsic to something, then move the cursor and select-cursor-end().... is there anything XTerm can't do? 😃

Still, a macro might be better for the reasons mentioned above.

@emendelson
Copy link
Contributor Author

emendelson commented Aug 25, 2022

You're absolutely right about xterm and pasting: Shift-Insert does the job. I didn't know this.

And in the Windows Console Host (EDIT: also the Windows terminal), Shift-Alt-V does the same job. I didn't need to waste time on that pasting macro at all.

Copying, as you say is a different matter. If you use the mouse in the Windows console, you can select text and press Enter, and that gets it into the clipboard - but with line breaks and blank lines if you select more than one line. I think a macro probably makes sense for copying. Will look into this further.

But let's definitely forget about the pasting macro...

EDIT: And here's a copying macro for non WSL-Unix; works in Ubuntu Mate, at least:

https://www.dropbox.com/s/40yhgs4rrffokza/uxcopy.wpm?dl=0

@emendelson
Copy link
Contributor Author

Just to add to this: one reason that WPDOS needs elaborate copy/paste macros for sharing the clipboard with the host OS is that Windows and macOS don't share a character set with WP, so anything other than ASCII text can't be shared via the host clipboard. And the same thing applies to WPDOS running under dosemu2. So the macros have to convert between character sets before copying to or pasting from the clipboard. This doesn't apply in WP Unix. I opened the WP5.1 charmap.tst document in WP for Windows, copied it to the Windows clipboard and pasted it (via the keyboard) into WP Unix in WSL, apparently with most or all characters correctly pasted.

@emendelson
Copy link
Contributor Author

Question: if mouse support can be disabled in WP, would it then be possible to use the mouse in xterm to select text and copy it to the clipboard? This is possible outside WP, where there is no mouse support to get in the way. I'm not sure I want to give up mouse support in WP, but I can imagine that it might be useful to be able to copy with the mouse.

@taviso
Copy link
Owner

taviso commented Aug 30, 2022

Yes - you should be able to just hold Shift while selecting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants