From 2de5693e8795630fa6f9d696720f7d3a83d121f9 Mon Sep 17 00:00:00 2001 From: Brad Arant Date: Tue, 26 Nov 2024 10:33:31 -0800 Subject: [PATCH] added moveBackToLineStart() method on ZString. --- ZString.cpp | 12 ++++++++++-- ZString.h | 9 ++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/ZString.cpp b/ZString.cpp index e802d0a..b183547 100644 --- a/ZString.cpp +++ b/ZString.cpp @@ -583,6 +583,14 @@ namespace coreutils { ++line; return line; } - - + + void ZString::moveBackToLineStart() { + while(cursor != data) { + if(*cursor == '\n') + break; + cursor--; + } + return; + } + } diff --git a/ZString.h b/ZString.h index d870b95..029e0f4 100644 --- a/ZString.h +++ b/ZString.h @@ -445,7 +445,14 @@ namespace coreutils { /// int getLineNumberAtCursor(); - + + /// + /// Move the cursor to the beginning of a line or to the beginning of + /// the ZString. + /// + + void moveBackToLineStart(); + protected: char *data; char *cursor;