jmoenig / Snap

a visual programming language inspired by Scratch
http://snap.berkeley.edu
GNU Affero General Public License v3.0
1.5k stars 744 forks source link

Control-A with a Mac does the wrong thing (should jump to beginning of the line) #2390

Closed cycomachead closed 3 years ago

cycomachead commented 5 years ago

In the saga of things that are weird with text elements... This is definitely a fairly recent regression: Control-A now selects all the text in an element on my Mac. It should jump the cursor to the beginning of the text input.

jmoenig commented 5 years ago

Ha! now I finally know how to do that on my Mac! :-)

I don't think that's a recent regression. Also, this might be a problem with Windows users who don't have both CTRL and CMD keys and who expect CTRL-A to select all.

Sigh.

brianharvey commented 5 years ago

How does that differ from command-leftarrow?

cycomachead commented 5 years ago

They're system-wide sort of "emacs-style" keyboard shortcuts which work in all native inputs. I Guess command left arrow works too, but for me Control-A and Control-E are much easier because they can be done with my left hand.

bromagosa commented 5 years ago

Wait, I don't care know about Windows users, but in Linux CTRL+A has always selected all (I suspect that's the same in Windows), and so it is in Snap! as well, since I modeled all those keyboard shortcuts based on what I could test on my computer. Is CTRL+A not working for you expensive BSD users?

cycomachead commented 5 years ago

The issue is that Snap! no longer distinguishes between the command and control keys. I don’t believe there’s a keyboard shortcut on windows for the command key (it’s the windows logo), and I’m not sure what that maps to on standard *nix boxes, but they’re very different keys on the Mac.

brianharvey commented 5 years ago

Hmm. I do command-A to select-all all the time, so I wouldn't want to lose that, I selfishly (as a Mac user) would be happy for command-A and control-A to do different things, but that's not really a good solution because, alas, some people don't have Macs. :-) But people without Macs do have "Home" and "End" keys; could we use those, along with command-leftarrow, to mean beginning of line?

There are other problems with our text editing, too, but I guess they belong in separate issue reports? Or would it be more convenient to have them all in one place?

cycomachead commented 5 years ago

So, the thing is Snap! used to to the right thing....What I believe was happening, is that on the Mac, Control-A wasn't being intercepted. And too Snap!, Control-A has no reason to be intercepted on a Mac -- but that requires checking the OS. I haven't figured out when this change was made, or if it was that the shortcuts didn't work before on other OSes.

I especially use them while working on JSFunctions, since that's also how I program.

jmoenig commented 5 years ago

I'm pretty sure ctrl-a was always selecting all, because I wrote that myself. I'm also rather certain that I made cmd-a do the same. I don't think this is a regression case.

I do know that text editing used to be less painful but also less feature-packed. I'm unhappy because it was such a big issue to the EDC people and we sorta got coerced into adding all kinds of shortcuts that people felt they absolutely needed. Personally I'd rather have less features - also in text editing - but have them be right.

brianharvey commented 5 years ago

I think "all kinds of shortcuts" is unfair; we didn't add meta-F for forward word, which I personally miss, for example.

But we did introduce bugs, most notably the one where the cursor magically jumps to the beginning or end of the buffer (even multiline buffers). And I still say that the correct behavior for multiline buffers is different from the correct behavior for single-line buffers.

towerofnix commented 5 years ago

in Linux CTRL+A has always selected all (I suspect that's the same in Windows), and so it is in Snap! as well, since I modeled all those keyboard shortcuts based on what I could test on my computer.

@bromagosa Just if you're curious, as it were, ctrl-A usually selects all on Linux, but at least on my Debian/GNOME (in the gnome-tweaks), there's a setting to have emacs-style keybindings everywhere! Having used macOS a ton before I naturally enabled that as soon as I found it :P

'Course, that means you shouldn't be trying to choose what to do based on the system. I dunno if this is already implemented, but I recall discussion about using a separate textarea/input/whatever and letting the browser do all the cursor movement / selection handling, then visually displaying that in Morphic? It seems like that would make this 'do the right thing' just about all the time.

bromagosa commented 5 years ago

@cycomachead I understand now. I thought you wanted ctrl+A to select all in Mac, but you want it to behave as in Emacs, I see.

@towerofnix yes, of course. I meant that Linux does that by default, usually. You can of course set up your own shortcuts in Linux and customize your system to your particular needs, I don't even use a window system in my computers, and my "windows" key does all sorts of useful things. By the way, we already use a hidden textarea for text input, but some things won't work anyway. When you double click a word, you're not double-clicking it in the textarea, so you'd need to transfer that event to the textarea, and that's just not possible. In these cases you need to decide on a behavior that may or may not be the same as in the host browser/system.

For history: I see that the shortcuts I implemented at the request of EDC were essentially arrow key and mouse combinations. I thought I did ctrl+a but that was there before already.

bromagosa commented 5 years ago

@jmoenig I use these text-editing shortcuts all the time! For what it's worth, they ended up being useful to me at least!

brianharvey commented 5 years ago

Speaking of history, if you follow that ratpoison link and then follow the "where did the name come from" link, you get to a 1999 post that mentions pop-11! That's pretty obscure. The poster must be British.

Yay, Emacs keybindings! Especially, newline in a multiline slot should figure out what language you're in, and indent appropriately. And tab... Whereas in a single-line slot, tab should go to the next one.

I use those keybindings, too, but the quantum probabilistic cursor undoes the benefit. :-(

cycomachead commented 5 years ago

I tried checking git history and I couldn’t figure when Control-A did the emacs- thing on the Mac. I swear it used to...

In general, it’s not to replicate OS functionality, but since Morphic is basically its own OS, well, it’s nice when it can respect platform defaults.

Anyway, I didn’t mean for this to be a huge thing. It’s very minor in terms what affects normal people. :)

-- Michael Ball From my iPhone michaelball.co

On May 2, 2019, at 11:49 PM, Brian Harvey notifications@github.com wrote:

Speaking of history, if you follow that ratpoison link and then follow the "where did the name come from" link, you get to a 1999 post that mentions pop-11! That's pretty obscure. The poster must be British.

Yay, Emacs keybindings! Especially, newline in a multiline slot should figure out what language you're in, and indent appropriately. And tab... Whereas in a single-line slot, tab should go to the next one.

I use those keybindings, too, but the quantum probabilistic cursor undoes the benefit. :-(

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

cycomachead commented 3 years ago

At some point along the way, Control-A once again began to do the right thing. :D