diff --git a/ZString.cpp b/ZString.cpp index 5f0b1ec..172c31d 100644 --- a/ZString.cpp +++ b/ZString.cpp @@ -575,4 +575,13 @@ namespace coreutils { return temp; } + int ZString::getLineNumberAtCursor() { + int line = 1; + while(cursor != data) + if(*cursor-- == '\n') + ++line; + return line; + } + + } diff --git a/ZString.h b/ZString.h index dc1436e..d870b95 100644 --- a/ZString.h +++ b/ZString.h @@ -438,6 +438,13 @@ namespace coreutils { /// ZString removeTrailingZeros(); + + /// + /// Returns the number of line termination characters + 1 based upon + /// the cursor position. + /// + + int getLineNumberAtCursor(); protected: char *data;