mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
Core: Array::Add(One<T>&&), RichEdit: Removed 'new', Sqlite3: Fixed to compile
git-svn-id: svn://ultimatepp.org/upp/trunk@15191 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
c4e67cc6b9
commit
c1dbe598d0
13 changed files with 173 additions and 162 deletions
|
|
@ -110,6 +110,8 @@ public:
|
|||
T& AddTail(T *newt) { bv.AddTail(newt); return *newt; }
|
||||
template <class TT> TT& CreateHead() { TT *q = new TT; bv.AddHead(q); return *q; }
|
||||
template <class TT> TT& CreateTail() { TT *q = new TT; bv.AddTail(q); return *q; }
|
||||
T& AddHead(One<T>&& one) { ASSERT(one); return AddHead(one.Detach()); }
|
||||
T& AddTail(One<T>&& one) { ASSERT(one); return AddTail(one.Detach()); }
|
||||
T& Head() { return *(T *) bv.Head(); }
|
||||
T& Tail() { return *(T *) bv.Tail(); }
|
||||
const T& Head() const { return *(const T *) bv.Head(); }
|
||||
|
|
|
|||
|
|
@ -18,67 +18,6 @@ int StaticTypeNo() {
|
|||
return typeno;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
class One : MoveableAndDeepCopyOption< One<T> > {
|
||||
mutable T *ptr;
|
||||
|
||||
void Free() { if(ptr && ptr != (T*)1) delete ptr; }
|
||||
template <class TT>
|
||||
void Pick(One<TT>&& data) { ptr = data.Detach(); }
|
||||
|
||||
public:
|
||||
void Attach(T *data) { Free(); ptr = data; }
|
||||
T *Detach() { T *t = ptr; ptr = NULL; return t; }
|
||||
void Clear() { Free(); ptr = NULL; }
|
||||
|
||||
void operator=(T *data) { Attach(data); }
|
||||
|
||||
template <class TT>
|
||||
void operator=(One<TT>&& d) { if((void *)this != (void *)&d) { Free(); Pick(pick(d)); }}
|
||||
|
||||
const T *operator->() const { ASSERT(ptr); return ptr; }
|
||||
T *operator->() { ASSERT(ptr); return ptr; }
|
||||
const T *operator~() const { return ptr; }
|
||||
T *operator~() { return ptr; }
|
||||
const T *Get() const { return ptr; }
|
||||
T *Get() { return ptr; }
|
||||
const T& operator*() const { ASSERT(ptr); return *ptr; }
|
||||
T& operator*() { ASSERT(ptr); return *ptr; }
|
||||
|
||||
template <class TT, class... Args>
|
||||
TT& Create(Args&&... args) { TT *q = new TT(std::forward<Args>(args)...); Attach(q); return *q; }
|
||||
template <class TT> // with C++ conforming compiler, this would not be needed - GCC bug workaround
|
||||
TT& Create() { TT *q = new TT; Attach(q); return *q; }
|
||||
template <class... Args>
|
||||
T& Create(Args&&... args) { T *q = new T(std::forward<Args>(args)...); Attach(q); return *q; }
|
||||
T& Create() { T *q = new T; Attach(q); return *q; }
|
||||
|
||||
template <class TT>
|
||||
bool Is() const { return dynamic_cast<const TT *>(ptr); }
|
||||
|
||||
bool IsEmpty() const { return !ptr; }
|
||||
|
||||
operator bool() const { return ptr; }
|
||||
|
||||
String ToString() const { return ptr ? AsString(*ptr) : "<empty>"; }
|
||||
|
||||
One() { ptr = NULL; }
|
||||
One(T *newt) { ptr = newt; }
|
||||
template <class TT>
|
||||
One(One<TT>&& p) { Pick(pick(p)); }
|
||||
One(const One<T>& p, int) { ptr = p.IsEmpty() ? NULL : new T(clone(*p)); }
|
||||
One(const One<T>& p) = delete;
|
||||
void operator=(const One<T>& p) = delete;
|
||||
~One() { Free(); }
|
||||
};
|
||||
|
||||
template <class T, class... Args>
|
||||
One<T> MakeOne(Args... args) {
|
||||
One<T> r;
|
||||
r.Create(args...);
|
||||
return r;
|
||||
}
|
||||
|
||||
class Any : Moveable<Any> {
|
||||
struct BaseData {
|
||||
int typeno;
|
||||
|
|
|
|||
|
|
@ -100,6 +100,67 @@ public:
|
|||
Buffer(std::initializer_list<T> init) : Buffer(init.size(), init) {}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class One : MoveableAndDeepCopyOption< One<T> > {
|
||||
mutable T *ptr;
|
||||
|
||||
void Free() { if(ptr && ptr != (T*)1) delete ptr; }
|
||||
template <class TT>
|
||||
void Pick(One<TT>&& data) { ptr = data.Detach(); }
|
||||
|
||||
public:
|
||||
void Attach(T *data) { Free(); ptr = data; }
|
||||
T *Detach() { T *t = ptr; ptr = NULL; return t; }
|
||||
void Clear() { Free(); ptr = NULL; }
|
||||
|
||||
void operator=(T *data) { Attach(data); }
|
||||
|
||||
template <class TT>
|
||||
void operator=(One<TT>&& d) { if((void *)this != (void *)&d) { Free(); Pick(pick(d)); }}
|
||||
|
||||
const T *operator->() const { ASSERT(ptr); return ptr; }
|
||||
T *operator->() { ASSERT(ptr); return ptr; }
|
||||
const T *operator~() const { return ptr; }
|
||||
T *operator~() { return ptr; }
|
||||
const T *Get() const { return ptr; }
|
||||
T *Get() { return ptr; }
|
||||
const T& operator*() const { ASSERT(ptr); return *ptr; }
|
||||
T& operator*() { ASSERT(ptr); return *ptr; }
|
||||
|
||||
template <class TT, class... Args>
|
||||
TT& Create(Args&&... args) { TT *q = new TT(std::forward<Args>(args)...); Attach(q); return *q; }
|
||||
template <class TT> // with C++ conforming compiler, this would not be needed - GCC bug workaround
|
||||
TT& Create() { TT *q = new TT; Attach(q); return *q; }
|
||||
template <class... Args>
|
||||
T& Create(Args&&... args) { T *q = new T(std::forward<Args>(args)...); Attach(q); return *q; }
|
||||
T& Create() { T *q = new T; Attach(q); return *q; }
|
||||
|
||||
template <class TT>
|
||||
bool Is() const { return dynamic_cast<const TT *>(ptr); }
|
||||
|
||||
bool IsEmpty() const { return !ptr; }
|
||||
|
||||
operator bool() const { return ptr; }
|
||||
|
||||
String ToString() const { return ptr ? AsString(*ptr) : "<empty>"; }
|
||||
|
||||
One() { ptr = NULL; }
|
||||
One(T *newt) { ptr = newt; }
|
||||
template <class TT>
|
||||
One(One<TT>&& p) { Pick(pick(p)); }
|
||||
One(const One<T>& p, int) { ptr = p.IsEmpty() ? NULL : new T(clone(*p)); }
|
||||
One(const One<T>& p) = delete;
|
||||
void operator=(const One<T>& p) = delete;
|
||||
~One() { Free(); }
|
||||
};
|
||||
|
||||
template <class T, class... Args>
|
||||
One<T> MakeOne(Args&&... args) {
|
||||
One<T> r;
|
||||
r.Create(std::forward<Args>(args)...);
|
||||
return r;
|
||||
}
|
||||
|
||||
template <class U> class Index;
|
||||
|
||||
template <class T>
|
||||
|
|
@ -286,6 +347,7 @@ public:
|
|||
T& Add(const T& x) { T *q = new T(x); vector.Add(q); return *q; }
|
||||
T& Add(T&& x) { T *q = new T(pick(x)); vector.Add(q); return *q; }
|
||||
T& Add(T *newt) { vector.Add(newt); return *newt; }
|
||||
T& Add(One<T>&& one) { ASSERT(one); return Add(one.Detach()); }
|
||||
template<class TT, class... Args>
|
||||
TT& Create(Args&&... args) { TT *q = new TT(std::forward<Args>(args)...); Add(q); return *q; }
|
||||
const T& operator[](int i) const { return Get(i); }
|
||||
|
|
|
|||
|
|
@ -131,11 +131,18 @@ can be either T or a type derived from T. No constructor is applied.
|
|||
[s7; [*/ Return value]-|Reference to the new element (that is [* `*newt]).&]
|
||||
[s0;*%- &]
|
||||
[s4;%- &]
|
||||
[s5;:Upp`:`:Array`:`:Add`(Upp`:`:One`<T`>`&`&`):%- [*@4 T][@(0.0.255) `&]_[* Add]([_^Upp`:`:One^ O
|
||||
ne]<[*@4 T]>`&`&_[*@3 one])&]
|
||||
[s2; Creates a new element in the Array, moving the content of [%-*@3 one]
|
||||
to it. [%-*@3 one] must contain a value, otherwise the behavior
|
||||
is undefined.&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:Upp`:`:Array`:`:Create`(Args`&`&`.`.`.args`):%- [@(0.0.255) template]_<[@(0.0.255) c
|
||||
lass]_[*@4 TT], [@(0.0.255) class...]_[*@4 Args]>_[*@4 TT][@(0.0.255) `&]_[* Create]([*@4 Args][@(0.0.255) `&
|
||||
`&...]_[*@3 args])&]
|
||||
[s2; Creates and adds a new element to the Array. [%-*@3 args] are
|
||||
forwarded to constructor.&]
|
||||
[s2; Creates a new element in the Array. [%-*@3 args] are forwarded
|
||||
to constructor.&]
|
||||
[s3;%- &]
|
||||
[s4;%- &]
|
||||
[s5;:Array`:`:operator`[`]`(int`)const:%- [@(0.0.255) const]_[*@4 T][@(0.0.255) `&]_[* operat
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
topic "BiArray";
|
||||
[2 $$0,0#00000000000000000000000000000000:Default]
|
||||
[i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class]
|
||||
[l288;2 $$2,0#27521748481378242620020725143825:desc]
|
||||
[0 $$3,0#96390100711032703541132217272105:end]
|
||||
|
|
@ -9,6 +8,7 @@ topic "BiArray";
|
|||
[l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param]
|
||||
[i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam]
|
||||
[b42;2 $$9,9#13035079074754324216151401829390:normal]
|
||||
[2 $$0,0#00000000000000000000000000000000:Default]
|
||||
[{_}%EN-US
|
||||
[ {{10000@(113.42.0) [s0; [*@7;4 BiArray]]}}&]
|
||||
[s3; &]
|
||||
|
|
@ -176,6 +176,22 @@ _[*@4 TT][@(0.0.255) `&]_[* CreateTail]()&]
|
|||
[s2; Creates a new element of type [%-*@4 TT] at the tail.&]
|
||||
[s3;%- &]
|
||||
[s4;%- &]
|
||||
[s5;:Upp`:`:BiArray`:`:AddHead`(Upp`:`:One`<T`>`&`&`):%- [*@4 T][@(0.0.255) `&]_[* AddHead](
|
||||
[_^Upp`:`:One^ One]<[*@4 T]>`&`&_[*@3 one])&]
|
||||
[s2; Creates a new element at the head, moving the content of [%-*@3 one]
|
||||
to it. [%-*@3 one] must contain a value, otherwise the behavior
|
||||
is undefined.&]
|
||||
[s6; Invalidates iterators to the BiArray.&]
|
||||
[s0; &]
|
||||
[s4;%- &]
|
||||
[s5;:Upp`:`:BiArray`:`:AddTail`(Upp`:`:One`<T`>`&`&`):%- [*@4 T][@(0.0.255) `&]_[* AddTail](
|
||||
[_^Upp`:`:One^ One]<[*@4 T]>`&`&_[*@3 one])&]
|
||||
[s2; Creates a new element at the tail, moving the content of [%-*@3 one]
|
||||
to it. [%-*@3 one] must contain a value, otherwise the behavior
|
||||
is undefined.&]
|
||||
[s6; Invalidates iterators to the BiArray.&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:BiArray`:`:Head`(`):%- [*@4 T][@(0.0.255) `&]_[* Head]()&]
|
||||
[s2; Returns reference to the head of the BiArray. Same as operator`[`](0).&]
|
||||
[s7; [*/ Return value]-|Reference to the head of BiArray.&]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
topic "BiVector";
|
||||
[2 $$0,0#00000000000000000000000000000000:Default]
|
||||
[i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class]
|
||||
[l288;2 $$2,0#27521748481378242620020725143825:desc]
|
||||
[0 $$3,0#96390100711032703541132217272105:end]
|
||||
|
|
@ -9,6 +8,7 @@ topic "BiVector";
|
|||
[l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param]
|
||||
[i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam]
|
||||
[b42;2 $$9,9#13035079074754324216151401829390:normal]
|
||||
[2 $$0,0#00000000000000000000000000000000:Default]
|
||||
[{_}%EN-US
|
||||
[ {{10000@(113.42.0) [s0; [*@7;4 BiVector]]}}&]
|
||||
[s3; &]
|
||||
|
|
@ -105,24 +105,6 @@ of the [* BiVector]. The new element will be at position [* GetCount]()
|
|||
[s6; Invalidates iterators and references to the BiVector.&]
|
||||
[s3;%- &]
|
||||
[s4;%- &]
|
||||
[s5;:Upp`:`:BiVector`:`:AddHeadPick`(T`&`&`):%- [@(0.0.255) void]_[* AddHeadPick]([*@4 T][@(0.0.255) `&
|
||||
`&]_[*@3 x])&]
|
||||
[s2; Adds a new element at the head of the [* BiVector] and picks value
|
||||
of the parameter [%-*@3 x]. The new element will be at position
|
||||
0.&]
|
||||
[s6; Requires T to have pick constructor.&]
|
||||
[s2; Invalidates iterators and references to the BiVector.&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:Upp`:`:BiVector`:`:AddTailPick`(T`&`&`):%- [@(0.0.255) void]_[* AddTailPick]([*@4 T][@(0.0.255) `&
|
||||
`&]_[*@3 x])&]
|
||||
[s2; Adds a new element at the tail of the [* BiVector] and picks value
|
||||
of the parameter [%-*@3 x]. The new element will be at position
|
||||
[* GetCount]() `- 1.&]
|
||||
[s6; Requires T to have pick constructor.&]
|
||||
[s2; Invalidates iterators and references to the BiVector.&]
|
||||
[s3;%- &]
|
||||
[s4;%- &]
|
||||
[s5;:BiVector`:`:Head`(`):%- [*@4 T][@(0.0.255) `&]_[* Head]()&]
|
||||
[s2; Returns a reference to the head of the [* BiVector] . Same as
|
||||
operator`[`](0).&]
|
||||
|
|
|
|||
|
|
@ -435,6 +435,8 @@ private:
|
|||
public:
|
||||
void Put(Item *newitem) { item.Add(newitem); }
|
||||
|
||||
void Put(One<Item>&& newitem) { item.Add(newitem.Detach()); }
|
||||
|
||||
template <class T>
|
||||
void Put(Ctrl& ctrl, T& val);
|
||||
|
||||
|
|
|
|||
|
|
@ -31,9 +31,9 @@ void RichEdit::UndoBegSelFix::Apply(RichText& txt)
|
|||
BegSelUnFixRaw(txt);
|
||||
}
|
||||
|
||||
RichEdit::UndoRec *RichEdit::UndoBegSelFix::GetRedo(const RichText& txt)
|
||||
One<RichEdit::UndoRec> RichEdit::UndoBegSelFix::GetRedo(const RichText& txt)
|
||||
{
|
||||
return new RichEdit::UndoBegSelUnFix;
|
||||
return MakeOne<RichEdit::UndoBegSelUnFix>();
|
||||
}
|
||||
|
||||
void RichEdit::UndoBegSelUnFix::Apply(RichText& text)
|
||||
|
|
@ -41,16 +41,16 @@ void RichEdit::UndoBegSelUnFix::Apply(RichText& text)
|
|||
BegSelFixRaw(text);
|
||||
}
|
||||
|
||||
RichEdit::UndoRec * RichEdit::UndoBegSelUnFix::GetRedo(const RichText& txt)
|
||||
One<RichEdit::UndoRec> RichEdit::UndoBegSelUnFix::GetRedo(const RichText& txt)
|
||||
{
|
||||
return new RichEdit::UndoBegSelFix;
|
||||
return MakeOne<RichEdit::UndoBegSelFix>();
|
||||
}
|
||||
|
||||
bool RichEdit::BegSelTabFix(int& count)
|
||||
{
|
||||
if(begtabsel) { // If selection starts with first table which is the first element in the text
|
||||
int c = cursor;
|
||||
AddUndo(new UndoBegSelFix);
|
||||
AddUndo(MakeOne<UndoBegSelFix>());
|
||||
BegSelFixRaw(text); // adds an empty paragraph at the start
|
||||
Move(0);
|
||||
Move(c + 1, true); // and changes the selection
|
||||
|
|
@ -65,7 +65,7 @@ void RichEdit::BegSelTabFixEnd(bool fix)
|
|||
{ // removes empty paragraph added by BegSelTabFix
|
||||
if(fix && GetLength() > 0) {
|
||||
int c = cursor;
|
||||
AddUndo(new UndoBegSelUnFix);
|
||||
AddUndo(MakeOne<UndoBegSelUnFix>());
|
||||
BegSelUnFixRaw(text);
|
||||
Move(0);
|
||||
Move(c - 1, true);
|
||||
|
|
@ -78,7 +78,7 @@ bool RichEdit::InvalidRange(int l, int h)
|
|||
return !InSameTxt(text.GetRichPos(min(l, h)), text.GetRichPos(max(l, h)));
|
||||
}
|
||||
|
||||
void RichEdit::AddUndo(UndoRec *ur)
|
||||
void RichEdit::AddUndo(One<UndoRec>&& ur)
|
||||
{
|
||||
redo.Clear();
|
||||
SetModify();
|
||||
|
|
@ -89,23 +89,23 @@ void RichEdit::AddUndo(UndoRec *ur)
|
|||
found = false;
|
||||
ur->cursor = cursor;
|
||||
ur->serial = undoserial;
|
||||
undo.AddTail(ur);
|
||||
undo.AddTail(pick(ur));
|
||||
}
|
||||
|
||||
void RichEdit::SaveStylesUndo()
|
||||
{
|
||||
AddUndo(new UndoStyles(text));
|
||||
AddUndo(MakeOne<UndoStyles>(text));
|
||||
}
|
||||
|
||||
void RichEdit::SaveStyleUndo(const Uuid& id)
|
||||
{
|
||||
AddUndo(new UndoStyle(text, id));
|
||||
AddUndo(MakeOne<UndoStyle>(text, id));
|
||||
}
|
||||
|
||||
void RichEdit::SaveFormat(int pos, int count)
|
||||
{
|
||||
Limit(pos, count);
|
||||
AddUndo(new UndoFormat(text, pos, count));
|
||||
AddUndo(MakeOne<UndoFormat>(text, pos, count));
|
||||
}
|
||||
|
||||
void RichEdit::SaveFormat()
|
||||
|
|
@ -156,7 +156,7 @@ void RichEdit::Remove(int pos, int len, bool forward)
|
|||
RichTxt::FormatInfo fi;
|
||||
if(forward)
|
||||
fi = text.GetFormatInfo(pos, 0);
|
||||
AddUndo(new UndoRemove(text, pos, len));
|
||||
AddUndo(MakeOne<UndoRemove>(text, pos, len));
|
||||
text.Remove(pos, len);
|
||||
if(forward) {
|
||||
SaveFormat(pos, 0);
|
||||
|
|
@ -194,7 +194,7 @@ void RichEdit::Insert(int pos, const RichText& txt, bool typing)
|
|||
}
|
||||
}
|
||||
}
|
||||
AddUndo(new UndoInsert(pos, l, typing));
|
||||
AddUndo(MakeOne<UndoInsert>(pos, l, typing));
|
||||
}
|
||||
|
||||
void RichEdit::Undo()
|
||||
|
|
@ -208,10 +208,10 @@ void RichEdit::Undo()
|
|||
while(undo.GetCount()) {
|
||||
UndoRec& u = undo.Tail();
|
||||
if(u.serial != serial) break;
|
||||
UndoRec *r = u.GetRedo(text);
|
||||
One<UndoRec> r = u.GetRedo(text);
|
||||
r->serial = u.serial;
|
||||
r->cursor = cursor;
|
||||
redo.Add(r);
|
||||
redo.Add(pick(r));
|
||||
u.Apply(text);
|
||||
c = u.cursor;
|
||||
undo.DropTail();
|
||||
|
|
@ -233,10 +233,10 @@ void RichEdit::Redo()
|
|||
while(redo.GetCount()) {
|
||||
UndoRec& r = redo.Top();
|
||||
if(r.serial != serial) break;
|
||||
UndoRec *u = r.GetRedo(text);
|
||||
One<UndoRec> u = r.GetRedo(text);
|
||||
u->serial = r.serial;
|
||||
u->cursor = cursor;
|
||||
undo.AddTail(u);
|
||||
undo.AddTail(pick(u));
|
||||
r.Apply(text);
|
||||
c = r.cursor;
|
||||
redo.Drop();
|
||||
|
|
|
|||
|
|
@ -306,10 +306,10 @@ private:
|
|||
int serial;
|
||||
int cursor;
|
||||
|
||||
virtual void Apply(RichText& txt) = 0;
|
||||
virtual UndoRec *GetRedo(const RichText& txt) = 0;
|
||||
virtual void Apply(RichText& txt) = 0;
|
||||
virtual One<UndoRec> GetRedo(const RichText& txt) = 0;
|
||||
|
||||
UndoRec *Serial(int s) { serial = s; return this; }
|
||||
One<UndoRec> Serial(int s) { serial = s; return this; }
|
||||
|
||||
virtual ~UndoRec() {}
|
||||
};
|
||||
|
|
@ -319,8 +319,8 @@ private:
|
|||
int length;
|
||||
bool typing;
|
||||
|
||||
virtual void Apply(RichText& txt);
|
||||
virtual UndoRec *GetRedo(const RichText& txt);
|
||||
virtual void Apply(RichText& txt);
|
||||
virtual One<UndoRec> GetRedo(const RichText& txt);
|
||||
|
||||
UndoInsert(int pos, int length, bool typing = false);
|
||||
};
|
||||
|
|
@ -329,8 +329,8 @@ private:
|
|||
int pos;
|
||||
RichText text;
|
||||
|
||||
virtual void Apply(RichText& txt);
|
||||
virtual UndoRec *GetRedo(const RichText& txt);
|
||||
virtual void Apply(RichText& txt);
|
||||
virtual One<UndoRec> GetRedo(const RichText& txt);
|
||||
|
||||
UndoRemove(const RichText& txt, int pos, int length);
|
||||
};
|
||||
|
|
@ -340,8 +340,8 @@ private:
|
|||
int length;
|
||||
RichText::Formating format;
|
||||
|
||||
virtual void Apply(RichText& txt);
|
||||
virtual UndoRec *GetRedo(const RichText& txt);
|
||||
virtual void Apply(RichText& txt);
|
||||
virtual One<UndoRec> GetRedo(const RichText& txt);
|
||||
|
||||
UndoFormat(const RichText& txt, int pos, int length);
|
||||
};
|
||||
|
|
@ -350,8 +350,8 @@ private:
|
|||
Uuid id;
|
||||
RichStyle style;
|
||||
|
||||
virtual void Apply(RichText& txt);
|
||||
virtual UndoRec *GetRedo(const RichText& txt);
|
||||
virtual void Apply(RichText& txt);
|
||||
virtual One<UndoRec> GetRedo(const RichText& txt);
|
||||
|
||||
UndoStyle(const RichText& txt, const Uuid& id);
|
||||
};
|
||||
|
|
@ -359,8 +359,8 @@ private:
|
|||
struct UndoStyles : UndoRec {
|
||||
RichStyles styles;
|
||||
|
||||
virtual void Apply(RichText& txt);
|
||||
virtual UndoRec *GetRedo(const RichText& txt);
|
||||
virtual void Apply(RichText& txt);
|
||||
virtual One<UndoRec> GetRedo(const RichText& txt);
|
||||
|
||||
UndoStyles(const RichText& txt);
|
||||
};
|
||||
|
|
@ -369,8 +369,8 @@ private:
|
|||
int table;
|
||||
RichTable::Format format;
|
||||
|
||||
virtual void Apply(RichText& txt);
|
||||
virtual UndoRec *GetRedo(const RichText& txt);
|
||||
virtual void Apply(RichText& txt);
|
||||
virtual One<UndoRec> GetRedo(const RichText& txt);
|
||||
|
||||
UndoTableFormat(const RichText& txt, int table);
|
||||
};
|
||||
|
|
@ -378,8 +378,8 @@ private:
|
|||
struct UndoCreateTable : UndoRec {
|
||||
int table;
|
||||
|
||||
virtual void Apply(RichText& txt);
|
||||
virtual UndoRec *GetRedo(const RichText& txt);
|
||||
virtual void Apply(RichText& txt);
|
||||
virtual One<UndoRec> GetRedo(const RichText& txt);
|
||||
|
||||
UndoCreateTable(int table) : table(table) {}
|
||||
};
|
||||
|
|
@ -388,8 +388,8 @@ private:
|
|||
int pos;
|
||||
RichTable table;
|
||||
|
||||
virtual void Apply(RichText& txt);
|
||||
virtual UndoRec *GetRedo(const RichText& txt);
|
||||
virtual void Apply(RichText& txt);
|
||||
virtual One<UndoRec> GetRedo(const RichText& txt);
|
||||
|
||||
UndoDestroyTable(const RichText& txt, int pos);
|
||||
};
|
||||
|
|
@ -399,8 +399,8 @@ private:
|
|||
bool before;
|
||||
RichPara::Format format;
|
||||
|
||||
virtual void Apply(RichText& txt);
|
||||
virtual UndoRec *GetRedo(const RichText& txt);
|
||||
virtual void Apply(RichText& txt);
|
||||
virtual One<UndoRec> GetRedo(const RichText& txt);
|
||||
|
||||
UndoRemoveParaSpecial(const RichText& txt, int table, bool before);
|
||||
};
|
||||
|
|
@ -409,8 +409,8 @@ private:
|
|||
int table;
|
||||
bool before;
|
||||
|
||||
virtual void Apply(RichText& txt);
|
||||
virtual UndoRec *GetRedo(const RichText& txt);
|
||||
virtual void Apply(RichText& txt);
|
||||
virtual One<UndoRec> GetRedo(const RichText& txt);
|
||||
|
||||
UndoInsertParaSpecial(int table, bool before) : table(table), before(before) {}
|
||||
};
|
||||
|
|
@ -419,25 +419,25 @@ private:
|
|||
int table;
|
||||
RichTable copy;
|
||||
|
||||
virtual void Apply(RichText& txt);
|
||||
virtual UndoRec *GetRedo(const RichText& txt);
|
||||
virtual void Apply(RichText& txt);
|
||||
virtual One<UndoRec> GetRedo(const RichText& txt);
|
||||
|
||||
UndoTable(const RichText& txt, int table);
|
||||
};
|
||||
|
||||
struct UndoBegSelFix : UndoRec {
|
||||
virtual void Apply(RichText& txt);
|
||||
virtual UndoRec *GetRedo(const RichText& txt);
|
||||
virtual void Apply(RichText& txt);
|
||||
virtual One<UndoRec> GetRedo(const RichText& txt);
|
||||
};
|
||||
|
||||
struct UndoBegSelUnFix : UndoRec {
|
||||
virtual void Apply(RichText& txt);
|
||||
virtual UndoRec *GetRedo(const RichText& txt);
|
||||
virtual void Apply(RichText& txt);
|
||||
virtual One<UndoRec> GetRedo(const RichText& txt);
|
||||
};
|
||||
|
||||
BiArray<UndoRec> undo;
|
||||
Array<UndoRec> redo;
|
||||
|
||||
|
||||
FileSel imagefs;
|
||||
|
||||
struct StyleKey {
|
||||
|
|
@ -494,7 +494,7 @@ private:
|
|||
void Limit(int& pos, int& count);
|
||||
bool InvalidRange(int c1, int c2);
|
||||
void NextUndo() { undoserial += incundoserial; incundoserial = false; }
|
||||
void AddUndo(UndoRec *undo);
|
||||
void AddUndo(One<UndoRec>&& ur);
|
||||
|
||||
void BeginRulerTrack();
|
||||
void RulerTrack();
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ namespace Upp {
|
|||
|
||||
void RichEdit::SaveTableFormat(int table)
|
||||
{
|
||||
AddUndo(new UndoTableFormat(text, table));
|
||||
AddUndo(MakeOne<UndoTableFormat>(text, table));
|
||||
}
|
||||
|
||||
void RichEdit::SaveTable(int table)
|
||||
{
|
||||
AddUndo(new UndoTable(text, table));
|
||||
AddUndo(MakeOne<UndoTable>(text, table));
|
||||
}
|
||||
|
||||
void RichEdit::InsertTable()
|
||||
|
|
@ -52,7 +52,7 @@ void RichEdit::InsertTable()
|
|||
begtabsel = false;
|
||||
}
|
||||
SaveFormat(cursor, 0);
|
||||
AddUndo(new UndoCreateTable(text.SetTable(cursor, table)));
|
||||
AddUndo(MakeOne<UndoCreateTable>(text.SetTable(cursor, table)));
|
||||
Finish();
|
||||
}
|
||||
|
||||
|
|
@ -72,12 +72,12 @@ struct CtrlRetrieveItemValueNN : public CtrlRetriever::Item {
|
|||
template <class T>
|
||||
void Advn(CtrlRetriever& r, Ctrl& ctrl, T& value) {
|
||||
ctrl <<= value;
|
||||
r.Put(new CtrlRetrieveItemValueNN<T>(ctrl, value));
|
||||
r.Put(MakeOne<CtrlRetrieveItemValueNN<T>>(ctrl, value));
|
||||
}
|
||||
|
||||
void RichEdit::DestroyTable()
|
||||
{
|
||||
AddUndo(new UndoDestroyTable(text, cursorp.table));
|
||||
AddUndo(MakeOne<UndoDestroyTable>(text, cursorp.table));
|
||||
int c = text.GetCellPos(cursorp.table, 0, 0).pos;
|
||||
text.DestroyTable(cursorp.table);
|
||||
Move(c);
|
||||
|
|
@ -208,13 +208,13 @@ bool RichEdit::RemoveSpecial(int ll, int hh, bool back)
|
|||
if(InSameTxt(p1, p2))
|
||||
return false;
|
||||
if(p1.paralen == 0 && p2.posintab == 0 && text.CanRemoveParaSpecial(p2.table, true)) {
|
||||
AddUndo(new UndoRemoveParaSpecial(text, p2.table, true));
|
||||
AddUndo(MakeOne<UndoRemoveParaSpecial>(text, p2.table, true));
|
||||
text.RemoveParaSpecial(p2.table, true);
|
||||
Move(cursor - back);
|
||||
}
|
||||
else
|
||||
if(p2.paralen == 0 && p1.posintab == p1.tablen && text.CanRemoveParaSpecial(p1.table, false)) {
|
||||
AddUndo(new UndoRemoveParaSpecial(text, p1.table, false));
|
||||
AddUndo(MakeOne<UndoRemoveParaSpecial>(text, p1.table, false));
|
||||
text.RemoveParaSpecial(p1.table, false);
|
||||
Move(cursor - back);
|
||||
}
|
||||
|
|
@ -230,13 +230,13 @@ bool RichEdit::InsertLineSpecial()
|
|||
fmt.newpage = false;
|
||||
fmt.label.Clear();
|
||||
if(cursorp.posintab == 0 && text.ShouldInsertParaSpecial(cursorp.table, true)) {
|
||||
AddUndo(new UndoInsertParaSpecial(cursorp.table, true));
|
||||
AddUndo(MakeOne<UndoInsertParaSpecial>(cursorp.table, true));
|
||||
text.InsertParaSpecial(cursorp.table, true, fmt);
|
||||
Move(cursor + 1);
|
||||
return true;
|
||||
}
|
||||
if(cursorp.posintab == cursorp.tablen && text.ShouldInsertParaSpecial(cursorp.table, false)) {
|
||||
AddUndo(new UndoInsertParaSpecial(cursorp.table, false));
|
||||
AddUndo(MakeOne<UndoInsertParaSpecial>(cursorp.table, false));
|
||||
text.InsertParaSpecial(cursorp.table, false, fmt);
|
||||
Move(cursor + 1);
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ void RichEdit::UndoTableFormat::Apply(RichText& txt)
|
|||
txt.SetTableFormat(table, format);
|
||||
}
|
||||
|
||||
RichEdit::UndoRec *RichEdit::UndoTableFormat::GetRedo(const RichText& txt)
|
||||
One<RichEdit::UndoRec> RichEdit::UndoTableFormat::GetRedo(const RichText& txt)
|
||||
{
|
||||
return new UndoTableFormat(txt, table);
|
||||
return MakeOne<UndoTableFormat>(txt, table);
|
||||
}
|
||||
|
||||
RichEdit::UndoTableFormat::UndoTableFormat(const RichText& txt, int table)
|
||||
|
|
@ -26,9 +26,9 @@ void RichEdit::UndoCreateTable::Apply(RichText& txt)
|
|||
txt.DestroyTable(table);
|
||||
}
|
||||
|
||||
RichEdit::UndoRec *RichEdit::UndoCreateTable::GetRedo(const RichText& txt)
|
||||
One<RichEdit::UndoRec> RichEdit::UndoCreateTable::GetRedo(const RichText& txt)
|
||||
{
|
||||
return new UndoDestroyTable(txt, table);
|
||||
return MakeOne<UndoDestroyTable>(txt, table);
|
||||
}
|
||||
|
||||
// -----------------------
|
||||
|
|
@ -38,9 +38,9 @@ void RichEdit::UndoDestroyTable::Apply(RichText& txt)
|
|||
txt.SetTable(pos, table);
|
||||
}
|
||||
|
||||
RichEdit::UndoRec *RichEdit::UndoDestroyTable::GetRedo(const RichText& txt)
|
||||
One<RichEdit::UndoRec> RichEdit::UndoDestroyTable::GetRedo(const RichText& txt)
|
||||
{
|
||||
return new UndoCreateTable(txt.GetRichPos(pos).table + 1);
|
||||
return MakeOne<UndoCreateTable>(txt.GetRichPos(pos).table + 1);
|
||||
}
|
||||
|
||||
RichEdit::UndoDestroyTable::UndoDestroyTable(const RichText& txt, int tab)
|
||||
|
|
@ -57,9 +57,9 @@ void RichEdit::UndoInsertParaSpecial::Apply(RichText& txt)
|
|||
RichCellPos p = txt.GetCellPos(table, 0, 0);
|
||||
}
|
||||
|
||||
RichEdit::UndoRec *RichEdit::UndoInsertParaSpecial::GetRedo(const RichText& txt)
|
||||
One<RichEdit::UndoRec> RichEdit::UndoInsertParaSpecial::GetRedo(const RichText& txt)
|
||||
{
|
||||
return new UndoRemoveParaSpecial(txt, table, before);
|
||||
return MakeOne<UndoRemoveParaSpecial>(txt, table, before);
|
||||
}
|
||||
|
||||
// -----------------------
|
||||
|
|
@ -69,9 +69,9 @@ void RichEdit::UndoRemoveParaSpecial::Apply(RichText& txt)
|
|||
txt.InsertParaSpecial(table, before, format);
|
||||
}
|
||||
|
||||
RichEdit::UndoRec *RichEdit::UndoRemoveParaSpecial::GetRedo(const RichText& txt)
|
||||
One<RichEdit::UndoRec> RichEdit::UndoRemoveParaSpecial::GetRedo(const RichText& txt)
|
||||
{
|
||||
return new UndoInsertParaSpecial(table, before);
|
||||
return MakeOne<UndoInsertParaSpecial>(table, before);
|
||||
}
|
||||
|
||||
RichEdit::UndoRemoveParaSpecial::UndoRemoveParaSpecial(const RichText& txt, int table, bool before)
|
||||
|
|
@ -88,9 +88,9 @@ void RichEdit::UndoTable::Apply(RichText& txt)
|
|||
txt.ReplaceTable(table, copy);
|
||||
}
|
||||
|
||||
RichEdit::UndoRec *RichEdit::UndoTable::GetRedo(const RichText& txt)
|
||||
One<RichEdit::UndoRec> RichEdit::UndoTable::GetRedo(const RichText& txt)
|
||||
{
|
||||
return new UndoTable(txt, table);
|
||||
return MakeOne<UndoTable>(txt, table);
|
||||
}
|
||||
|
||||
RichEdit::UndoTable::UndoTable(const RichText& txt, int tab)
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ void RichEdit::UndoInsert::Apply(RichText& txt)
|
|||
txt.Remove(pos, length);
|
||||
}
|
||||
|
||||
RichEdit::UndoRec *RichEdit::UndoInsert::GetRedo(const RichText& txt)
|
||||
One<RichEdit::UndoRec> RichEdit::UndoInsert::GetRedo(const RichText& txt)
|
||||
{
|
||||
return new UndoRemove(txt, pos, length);
|
||||
return MakeOne<UndoRemove>(txt, pos, length);
|
||||
}
|
||||
|
||||
RichEdit::UndoInsert::UndoInsert(int pos, int length, bool typing)
|
||||
|
|
@ -22,9 +22,9 @@ void RichEdit::UndoRemove::Apply(RichText& txt)
|
|||
txt.Insert(pos, text);
|
||||
}
|
||||
|
||||
RichEdit::UndoRec *RichEdit::UndoRemove::GetRedo(const RichText& txt)
|
||||
One<RichEdit::UndoRec> RichEdit::UndoRemove::GetRedo(const RichText& txt)
|
||||
{
|
||||
return new UndoInsert(pos, text.GetLength());
|
||||
return MakeOne<UndoInsert>(pos, text.GetLength());
|
||||
}
|
||||
|
||||
RichEdit::UndoRemove::UndoRemove(const RichText& txt, int pos, int length)
|
||||
|
|
@ -40,9 +40,9 @@ void RichEdit::UndoFormat::Apply(RichText& txt)
|
|||
txt.RestoreFormat(pos, format);
|
||||
}
|
||||
|
||||
RichEdit::UndoRec *RichEdit::UndoFormat::GetRedo(const RichText& txt)
|
||||
One<RichEdit::UndoRec> RichEdit::UndoFormat::GetRedo(const RichText& txt)
|
||||
{
|
||||
return new UndoFormat(txt, pos, length);
|
||||
return MakeOne<UndoFormat>(txt, pos, length);
|
||||
}
|
||||
|
||||
RichEdit::UndoFormat::UndoFormat(const RichText& txt, int pos, int length)
|
||||
|
|
@ -58,9 +58,9 @@ void RichEdit::UndoStyle::Apply(RichText& txt)
|
|||
txt.SetStyle(id, style);
|
||||
}
|
||||
|
||||
RichEdit::UndoRec *RichEdit::UndoStyle::GetRedo(const RichText& txt)
|
||||
One<RichEdit::UndoRec> RichEdit::UndoStyle::GetRedo(const RichText& txt)
|
||||
{
|
||||
return new UndoStyle(txt, id);
|
||||
return MakeOne<UndoStyle>(txt, id);
|
||||
}
|
||||
|
||||
RichEdit::UndoStyle::UndoStyle(const RichText& txt, const Uuid& id)
|
||||
|
|
@ -76,9 +76,9 @@ void RichEdit::UndoStyles::Apply(RichText& txt)
|
|||
txt.SetStyles(styles);
|
||||
}
|
||||
|
||||
RichEdit::UndoRec *RichEdit::UndoStyles::GetRedo(const RichText& txt)
|
||||
One<RichEdit::UndoRec> RichEdit::UndoStyles::GetRedo(const RichText& txt)
|
||||
{
|
||||
return new UndoStyles(txt);
|
||||
return MakeOne<UndoStyles>(txt);
|
||||
}
|
||||
|
||||
RichEdit::UndoStyles::UndoStyles(const RichText& txt)
|
||||
|
|
|
|||
|
|
@ -433,6 +433,7 @@ void Sqlite3Session::Close() {
|
|||
sql.Clear();
|
||||
if (NULL != db) {
|
||||
SessionClose();
|
||||
DEBUGCODE(int retval =)
|
||||
sqlite3_close(db);
|
||||
// If this function fails, that means that some of the
|
||||
// prepared statements have not been finalized.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue