EnterHandler and SplitLineAction
Mathematica has only one type of comment, a block comment, started by (* and closed by *). To make life easier, I implemented an EnterHandler that inserts a new block comment on the next line when Enter is pressed and I put the caret inside it. Unfortunately, on pressing Ctrl+Enter, which should split the comment to the next line, I get an empty (* *) on the next line. What I really want is the following
- give the user a way to continue typing into a new comment pair on the next line on pressing Enter or XXX+Enter
- give the user a way to really insert a line feed and push the closing *) to the next line
What is the best to approach this? Is there a way to skip my EnterHandler when Ctrl+Enter is pressed?
Cheers
Patrick
Please sign in to leave a comment.
I'm not sure I understand your problem exactly (some example would be great), but 'Split Line' action (invoked by Ctrl+Enter) is conceptually just Enter followed by moving caret to the end of original line. So if Ctrl+Enter doesn't work as expected in some situation, just Enter probably also works incorrectly in the same situation, and the way to fix it is to fix your EnterHandler. If you want 'Split Line' to mean something else for you language though, you can register an EditorActionHandler for the 'Split Line' action, and it will override the default logic.
Thanks Dmitry,
I guess your comment cleared it up. I shouldn't implement special behaviour when pressing Enter but rather use a SmartEnterProcessor and leave Enter doing its normal job.
Cheers
Patrick