added getLineNumberAtCursor() method to ZString.

This commit is contained in:
Brad Arant 2024-11-26 09:45:37 -08:00
parent d6d16a1b7f
commit 52d3985ffa
2 changed files with 16 additions and 0 deletions

View File

@ -575,4 +575,13 @@ namespace coreutils {
return temp;
}
int ZString::getLineNumberAtCursor() {
int line = 1;
while(cursor != data)
if(*cursor-- == '\n')
++line;
return line;
}
}

View File

@ -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;