added getLineNumberAtCursor() method to ZString.

This commit is contained in:
Brad Arant committed 2024-11-26 09:45:37 -08:00
1 parent d6d16a1b7f
commit 52d3985ffa
2 files changed
+16

No files matched your search

+9
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;
}
}
+7
View File
@@ -439,6 +439,13 @@ namespace coreutils {
ZString removeTrailingZeros();
///
/// Returns the number of line termination characters + 1 based upon
/// the cursor position.
///
int getLineNumberAtCursor();
protected:
char *data;
char *cursor;