I'm working on a simple code editor in Cocoa. I have a text view, and I want it so that when the user hits return, the new line is indented the same as the previous line (like in Xcode or any other code editor).
My problem is that I can't figure out how to either intercept when the return/enter key is pressed or when a new line is created in the text view. What would be the easiest way to do this?