From 9aa6949e5f98e580f91320bb7255f985b5bd6103 Mon Sep 17 00:00:00 2001 From: Jochen Dolze Date: Sat, 15 May 2010 21:37:48 +0200 Subject: Fixed various things --- command/marks.cpp | 56 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 17 deletions(-) (limited to 'command/marks.cpp') diff --git a/command/marks.cpp b/command/marks.cpp index d84fafd..6935175 100644 --- a/command/marks.cpp +++ b/command/marks.cpp @@ -64,17 +64,23 @@ void clMarks::Del(int Type) } } -void clMarks::Clear() +void clMarks::Clear(int Before) { clMark *next,*mark=first; while (mark) { next=mark->Next(); - Del(mark); + if (mark->positionNext(); + if (first) + { + first->SetPrev(NULL); + } + else + { + last=NULL; + } } else { @@ -118,28 +132,35 @@ clMark *clMarks::Get(int Position) return mark; } -clMark *clMarks::GetPrev(int Position, int Type) +clMark *clMarks::GetPrev(int Position, int Type, int Mask) { if (!first) return NULL; // no elements yet + // first advance clMark *mark=first; while (mark) { - if (Type==0xFF) - { - if (mark->position>=Position) break; - } - else + if (mark->position>=Position) break; + mark=mark->Next(); + } + if (Type==0xFF) + { + if (mark) return mark->Prev(); + return last; + } + else + { + if (!mark) mark=last; + while (mark) { - if ((mark->position>=Position) && (mark->type==Type)) break; + if ((mark->type & Mask)==Type) break; + mark=mark->Prev(); } - mark=mark->Next(); + return mark; } - if (mark) return mark->Prev(); - return last; } -clMark *clMarks::GetNext(int Position, int Type) +clMark *clMarks::GetNext(int Position, int Type, int Mask) { if (!first) return NULL; // no elements yet clMark *mark=first; @@ -151,11 +172,12 @@ clMark *clMarks::GetNext(int Position, int Type) } else { - if ((mark->position>=Position) && (mark->type==Type)) break; + if ((mark->position>=Position) && ((mark->type & Mask)==Type)) break; } mark=mark->Next(); } - return mark->Next(); + if (mark) return mark->Next(); + return NULL; } clMark *clMarks::Add(int Type, int Position,const char *Comment) -- cgit v1.2.3