If text wrapping was set to off, then this would be a trivial matter of course, because lines can be easily counted by counting the number of newline characters. Unfortunately, when text wrapping is on, there does not seem to be any obvious and non-messy way to do this, other than actually putting in newline characters at the end of every row when initializing the box.
Up until now, this is how I solved the problem, however it is highly undesirable since, in many cases, it inserts a newline into the middle of a word, and of course, this solution is convoluted and messy. Does anyone have any suggestions? If I were to wrap my text area inside a textflow container, would there be a way to get around this?