Koder seems to use BScintillaView to do that. I don’t know if BTextVIew can but there’s a source package in HaikuDepot if you want to see how it does it.
BTextView does not support line numbers but adding them would be fairly trivial (for me anyway) since beta3. You’d have to add get/set methods (document), set the left inset, draw the bg and line numbers (stored in lines array along with line height) and add a setting in StyledEdit to turn line numbers on and off (used to test.)