tursilion / classic99

Classic99 TI-99/4A Emulator for Windows, QI3xx series
75 stars 7 forks source link

Paste from clipboard not working #4

Closed hanshuebner closed 3 years ago

hanshuebner commented 3 years ago

I am running Classic99 on Windows 10. I have some issues with copying text from the clipboard into Classic99 using Alt-F1. The clipboard contents seem to be okay, but whatever is pasted (sometimes) prefixed by a control character. Here is some clipboard contents:

image

The hashmark in the end is a NUL character, supposedly terminating the string. If I paste this into TI Basic, it looks like this:

image

In TurboForth, the same clipboard contents comes out like this:

image

Pasting the same clipboard contents into other applications works as expected. Any ideas what could be causing this? I looked at the handbook for options regarding clipboard treatment. It mentions some Rich Text copying option that should be present in the dialog, but it does not appear to be there in QI399.032.

tursilion commented 3 years ago

Classic99 needs to take the text that is found and try to convert it to TI keypresses, so keep it as simple as possible. I realize that there are fewer and fewer applications that will copy raw text to the clipboard, but I make no promises for anything else. ;)

Currently, it first tries CF_UNICODETEXT. so we'd need to see what you had on the clipboard for that. It does this because people using IE to copy programs over on the AtariAge forums were having no luck - the forum software at the time resulted in the CF_TEXT data being completely unusable (no line endings, IIRC), so I had to try and parse the CF_UNICODETEXT data instead. It does this with WideCharToMultiByte. CF_TEXT is used only if there's no CF_UNICODETEXT.

The filter code only checks for 7-bit ASCII, it looks like, so codes from 128-255 would cause effects like you're seeing. What are you copying from - any idea what the character being inserted in CF_UNICODETEXT is?

I probably should filter it anyway, but it'd be helpful to know if this is yet another change in the way apps are copying data...

hanshuebner commented 3 years ago

I've found another clipboard viewer that displays the clipboard data in a hex dump:

image

There does not seem to be anything in front of the string "Hello" for the UTF-16 data.

I'm copying text from Emacs, but I have just verified that the problem also occurs when copying from vsCode, Wordpad or Microsoft Word. Pasting text from Notepad works, as does pasting from Chrome's URL entry field. From a web page in Chrome, it does not work. In all non-working cases, the pasted string is prefixed by an inverse Q character.

tursilion commented 3 years ago

Oh, I see the problem. It's not coming from the clipboard... Ctrl-F1 is being interpreted as a keypress. I've literally never used that shortcut.

Use Edit->Paste for now.

tursilion commented 3 years ago

Fixed in the next version. Thanks for your help!

hanshuebner commented 3 years ago

Thank you for fixing this, I'll check it out and report if it still does not work.