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

more keyboard shortcuts in tools menu #448

Closed
stevekrouse opened this issue Jul 24, 2017 · 9 comments · Fixed by #564
Closed

more keyboard shortcuts in tools menu #448

stevekrouse opened this issue Jul 24, 2017 · 9 comments · Fixed by #564
Assignees

Comments

@stevekrouse
Copy link
Owner

shortcuts for commenting out code ctl-/ and selecting the next occurrence of a word ctl-d

@stevekrouse
Copy link
Owner Author

stevekrouse commented Jul 24, 2017

Also copy and cut and paste

@truthgoddess truthgoddess self-assigned this May 28, 2019
@truthgoddess
Copy link
Contributor

@madduccino Thoughts on what else we might add? Here's what my mind and research tells me we should add and emphasize to students that they exist:

Copy Ctrl+C
Cut Ctrl+X
Paste Ctrl+V

Select Next Occurrence Ctrl+D
Place Multiple Cursors Ctrl+LeftMouseClick

Replace Ctrl+Shift+F

Column Selection Alt+Select

Comment Code Ctrl+/

@truthgoddess
Copy link
Contributor

@stevekrouse @madduccino Maddy, you told me that Steve was out of town this week, so I believe this is a safe enough issue for us to work out what we want, for me to make a branch and pull request, and let Steve add his thoughts to it after the pull request and I'll make those changes, or he (or you) can merge?

@truthgoddess
Copy link
Contributor

truthgoddess commented May 30, 2019

List of current happenings on this issue:

  • Copy Ctrl+C
  • Cut Ctrl+X
  • Paste Ctrl+V

Select Next Occurrence Ctrl+D
Place Multiple Cursors Ctrl+LeftMouseClick
Column Select

  • Replace Ctrl+H

  • Comment Code Ctrl+/

  • Fixed issue with CTRL-B not cleaning code if no selection

@truthgoddess
Copy link
Contributor

truthgoddess commented May 30, 2019

I know this is a tiny bit of a no-no, but in working on this issue, I believe I have found an ok solution for #453. Basically, there was a previous attempt to fix that issue in which someone placed a "disabled" class to the link rather than the line item. Placing the class in the line item made it even more clear that clean code wasn't going to work, even though the menu disappears.

I'm also currently researching how to make bootstrap menus stay up for disabled items. I think that all these things still fit within this branch, but if someone wants me to do that fix separately, let me know.

@truthgoddess
Copy link
Contributor

Fixed an issue that I discovered when working with the menu. As it is the Clean Code button in the menu works, but CTRL-B doesn't work if there is no selection. It was a simple fix to get it to work, you'll see it in the pull request.

@truthgoddess
Copy link
Contributor

truthgoddess commented May 31, 2019

I've tried a number of things to try and get the get next occurrence functioning to work on menu click and I can't quite figure it out.

It seems the sublime javascript assigns the CTRL+D function to that key pair, but doesn't provide any way to access that function otherwise. I've tried using that base code to try and recreate what it does, but that hasn't been working.

https://www.cs.princeton.edu/~dp6/CodeMirror/keymap/sublime.js

cmds[map[ctrl + "D"] = "selectNextOccurrence"] = function(cm) {
    var from = cm.getCursor("from"), to = cm.getCursor("to");
    var fullWord = cm.state.sublimeFindFullWord == cm.doc.sel;
    if (CodeMirror.cmpPos(from, to) == 0) {
      var word = wordAt(cm, from);
      if (!word.word) return;
      cm.setSelection(word.from, word.to);
      fullWord = true;
    } else {
      var text = cm.getRange(from, to);
      var query = fullWord ? new RegExp("\\b" + text + "\\b") : text;
      var cur = cm.getSearchCursor(query, to);
      if (cur.findNext()) {
        cm.addSelection(cur.from(), cur.to());
      } else {
        cur = cm.getSearchCursor(query, Pos(cm.firstLine(), 0));
        if (cur.findNext())
          cm.addSelection(cur.from(), cur.to());
      }
    }
    if (fullWord)
      cm.state.sublimeFindFullWord = cm.doc.sel;
  };

(that's the relevant code I believe can be used to get it to work) I think that 'cm' can be replaced with 'editor'. but confused about what to do with 'CodeMirror')

@stevekrouse If you happen to know a very quick tip here, I'd love to hear it.

I'm going to stop trying to get that to work. The menu is looking pretty good with the functions that are there and the small fix I made. It'd be sad not to get the Crtl-D in the menu, but since I think place multiple cursors is cool, I'm going to try and think about a clever way to put things we don't want clickable there.

@truthgoddess
Copy link
Contributor

@stevekrouse Actually, ignore that longer thing at the moment. I think I've figured out a good way to handle this stuff. Explanation forthcoming.

(Forgive the over communication, but I'm following your advice: to over-communicate.)

@truthgoddess
Copy link
Contributor

truthgoddess commented May 31, 2019

First, fixes and additions here:

Copy button added to tools menu (desired functionality)
Cut button added to tools menu (desired functionality)
Paste button added to tools menu (desired functionality)

Replace button added to tools menu (desired functionality)
Comment code button added to tools menu (desired functionality)

Fixed issue with CMD/CTRL-B not working if no text is selected.
Fixed issue with improper disabling of clean code button (previously intended fix). This makes it even clearer that button will not work if there is an error.

Next, reasons for not including two things:

Did not include the CMD/CTRL - D button for two reasons. The first was I could not figure it out. The second, after some thought, is that it is not useful to go to the menu to click the find next occurrence button multiple times because it requires too many user actions to get what they want. Other menu functions are only used one time to get the desired result. CTRL - D is better used as a keyboard shortcut. Please see #563. Including that Codemirror Sublime shortcut is important since we use it. I just think it is better communicated in another way.

Select column was not added because it is not that useful, and alt-click on many Chromebooks is a right click.

I'm going to double check things here to make sure I don't have uncaught problems, and then initiate a pull request. Looking forward to getting feedback.

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

Successfully merging a pull request may close this issue.

2 participants