code: private int countNLs() {
          String s = getText();
          int c = 0;
          for(int i=0; i< s.length(); i++)
              if ( s.charAt(i) == '\n' )
                  c++;
          return c;
      }
docs: /*
  This is part of a hack to fix the setCaretPosition() bug
  Count the newlines in the text