I’m trying to create a package that hides semicolons in CSS files and causes Atom to act as if they aren’t there. In this way you can achieve a slightly neater syntax like Sass, but without having to constantly convert from Sass to CSS if you are working locally. The semicolons will still be there in the file, just hidden.
Hiding the semicolons is easily done by adding a CSS rule but then comes the harder challenge of making Atom skip past them when moving the text cursor around in the file. I’ve managed to achieve the desired effect when moving around with the arrow keys and Home and End, it acts as if there’s no semicolon at the end of a line. I’ve done this by detecting when the text cursor comes after after a semicolon at the end of a line and then moving it back before it if the key that was used was ArrowLeft, End, etc, and putting it on the next line if the key used was ArrowRight.
For clicking the mouse at the end of a line I’ve set it up using jQuery but it doesn’t work as well as with the arrow keys as it works significantly slower so that the movement of the text cursor going back before the semicolon is visible.
So there doesn’t seem to be a way to detect mouse clicks in Atom, but is there some way to do it? It seems that if I want to achieve the behaviour I’m looking for I would need to detect mouse clicks in some way because I tried using onDidChangeCursorPosition but that doesn’t tell you what caused the change in position, if it was the keyboard or mouse, and you need to know that because clicking at the end of a row is different from pressing ArrowRight. In the same way, onDidDispatch for commands doesn’t detect mouse clicks.
Hopefully it makes sense what I’m saying and thanks for any help.