From 82dd4aa45f672a91761b0276f9040c8cb009d1b2 Mon Sep 17 00:00:00 2001 From: cxl Date: Sun, 10 May 2009 15:39:30 +0000 Subject: [PATCH] Array, Vector: InsertPick, correct CharFilter for type/variable in LayDes, SystemDraw fixes git-svn-id: svn://ultimatepp.org/upp/trunk@1155 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/Value.cpp | 2 +- uppsrc/Core/Vcont.h | 4 +++- uppsrc/Core/Vcont.hpp | 16 ++++++++++++++++ uppsrc/Core/src.tpp/Array$en-us.tpp | 7 +++++++ uppsrc/Core/src.tpp/Vector$en-us.tpp | 12 ++++++++++++ uppsrc/CtrlCore/CtrlCore.h | 12 ++++++------ uppsrc/CtrlCore/CtrlDraw.cpp | 24 ++++++++++++++---------- uppsrc/ide/Core/Host.cpp | 4 ++-- uppsrc/ide/Insert.cpp | 2 ++ uppsrc/ide/LayDes/layout.cpp | 2 +- uppsrc/ide/LayDes/laywin.cpp | 12 ++++++++++++ 11 files changed, 76 insertions(+), 21 deletions(-) diff --git a/uppsrc/Core/Value.cpp b/uppsrc/Core/Value.cpp index 640926de3..d6748db60 100644 --- a/uppsrc/Core/Value.cpp +++ b/uppsrc/Core/Value.cpp @@ -165,7 +165,7 @@ void Value::Serialize(Stream& s) { } else { type = GetType(); - ASSERT_(!type || Typemap().Find(type) >= 0, "Missing RichValueType<" + AsString(type) + ">::Register"); + ASSERT_(!type || type == ERROR_V || type == UNKNOWN_V || Typemap().Find(type) >= 0, "Missing RichValueType<" + AsString(type) + ">::Register"); s / type; ptr->Serialize(s); } diff --git a/uppsrc/Core/Vcont.h b/uppsrc/Core/Vcont.h index 28210c43c..49ee012f2 100644 --- a/uppsrc/Core/Vcont.h +++ b/uppsrc/Core/Vcont.h @@ -54,6 +54,7 @@ public: void InsertN(int i, int count = 1); T& Insert(int i) { InsertN(i); return Get(i); } void Insert(int i, const T& x, int count = 1); + void InsertPick(int i, pick_ T& x); void Insert(int i, const Vector& x); void Insert(int i, const Vector& x, int offset, int count); void InsertPick(int i, pick_ Vector& x); @@ -114,7 +115,7 @@ public: friend void Swap(Vector& a, Vector& b) { UPP::Swap(a.items, b.items); UPP::Swap(a.alloc, b.alloc); UPP::Swap(a.vector, b.vector); } friend void Append(Vector& dst, const Vector& src) { dst.Append(src); } -//obsolete names +//deprecated T& DoIndex(int i) { return At(i); } T& DoIndex(int i, const T& x) { return At(i, x); } @@ -164,6 +165,7 @@ public: void InsertN(int i, int count = 1); T& Insert(int i) { InsertN(i); return Get(i); } void Insert(int i, const T& x, int count = 1); + void InsertPick(int i, pick_ T& x); void Insert(int i, const Array& x); void Insert(int i, const Array& x, int offset, int count); void Append(const Array& x) { Insert(GetCount(), x); } diff --git a/uppsrc/Core/Vcont.hpp b/uppsrc/Core/Vcont.hpp index 0c34fec9a..c859a28c7 100644 --- a/uppsrc/Core/Vcont.hpp +++ b/uppsrc/Core/Vcont.hpp @@ -271,6 +271,15 @@ void Vector::Insert(int q, const T& x, int count) { DeepCopyConstructFill(vector + q, vector + q + count, x); } +template +void Vector::InsertPick(int i, pick_ T& x) +{ + if(!count) return; + ASSERT(&x < vector || &x > vector + items); + RawInsert(q, count); + ::new(vector[q]) T(x); +} + template void Vector::Insert(int q, const Vector& x, int offset, int count) { ASSERT(offset >= 0 && count >= 0 && offset + count <= x.GetCount()); @@ -438,6 +447,13 @@ void Array::Insert(int i, const T& x, int count) { Init(vector.Begin() + i, vector.Begin() + i + count, x); } +template +void Array::InsertPick(int i, pick_ T& x) +{ + vector.InsertN(i, 1); + vector[i] = new T(x); +} + template void Array::Insert(int i, T *newt) { vector.InsertN(i, 1); diff --git a/uppsrc/Core/src.tpp/Array$en-us.tpp b/uppsrc/Core/src.tpp/Array$en-us.tpp index 93c4e6bea..e01420a8d 100644 --- a/uppsrc/Core/src.tpp/Array$en-us.tpp +++ b/uppsrc/Core/src.tpp/Array$en-us.tpp @@ -331,6 +331,13 @@ value.&] [s7; [*C@3 count]-|Number of elements to insert.&] [s3;%- &] [s4;%- &] +[s5;:Array`:`:InsertPick`(int`,pick`_ T`&`):%- [@(0.0.255) void]_[* InsertPick]([@(0.0.255) i +nt]_[*@3 i], [@(0.128.128) pick`_]_[*@4 T][@(0.0.255) `&]_[*@3 x])&] +[s2; Inserts an element at [%-*@3 i] picking the content of [%-*@3 x].&] +[s6;~~~.992; Requires T to have pick constructor.&] +[s6;~~~.992; Invalidates iterators to the Array.&] +[s3; &] +[s4;%- &] [s5;:Array`:`:Insert`(int`,const Array`&`):%- [@(0.0.255) void]_[* Insert]([@(0.0.255) int]_ [*@3 i], [@(0.0.255) const]_[_^Array^ Array][@(0.0.255) `&]_[*@3 x])&] [s2; Inserts all elements from another Array.&] diff --git a/uppsrc/Core/src.tpp/Vector$en-us.tpp b/uppsrc/Core/src.tpp/Vector$en-us.tpp index b7656cedb..156492045 100644 --- a/uppsrc/Core/src.tpp/Vector$en-us.tpp +++ b/uppsrc/Core/src.tpp/Vector$en-us.tpp @@ -300,6 +300,13 @@ value.&] [s7; [*C@3 count]-|Number of elements to insert.&] [s3;%- &] [s4;%- &] +[s5;:Vector`:`:InsertPick`(int`,pick`_ T`&`):%- [@(0.0.255) void]_[* InsertPick]([@(0.0.255) i +nt]_[*@3 i], [@(0.128.128) pick`_]_[*@4 T][@(0.0.255) `&]_[*@3 x])&] +[s2; Inserts an element at [%-*@3 i] picking the content of [%-*@3 x].&] +[s6;~~~.992; Requires T to have pick constructor.&] +[s6;~~~.992; Invalidates iterators and references to Vector.&] +[s3; &] +[s4;%- &] [s5;:Vector`:`:Insert`(int`,const Vector`&`):%- [@(0.0.255) void]_[* Insert]([@(0.0.255) in t]_[*@3 i], [@(0.0.255) const]_[_^Vector^ Vector][@(0.0.255) `&]_[*@3 x])&] [s2; Inserts all elements from another Vector.&] @@ -360,6 +367,11 @@ T, but destroys source Vector by picking.&] [s7; [*C@3 x]-|Source Vector.&] [s3;%- &] [s4;%- &] +[s5;:Vector`:`:Swap`(int`,int`):%- [@(0.0.255) void]_[* Swap]([@(0.0.255) int]_[*@3 i1], +[@(0.0.255) int]_[*@3 i2])&] +[s2; Swaps elements at [%-*@3 i1] and [%-*@3 i2].&] +[s3; &] +[s4;%- &] [s5;:Vector`:`:Drop`(int`):%- [@(0.0.255) void]_[* Drop]([@(0.0.255) int]_[*@3 n]_`=_[@3 1])&] [s2; Drops specified number of last elements in the Vector (same as Trim(GetCount() `- n)).&] diff --git a/uppsrc/CtrlCore/CtrlCore.h b/uppsrc/CtrlCore/CtrlCore.h index 478271014..a65072edd 100644 --- a/uppsrc/CtrlCore/CtrlCore.h +++ b/uppsrc/CtrlCore/CtrlCore.h @@ -557,14 +557,14 @@ private: Rect GetClippedView(); void ScrollRefresh(const Rect& r, int dx, int dy); void SyncScroll(); - void PaintCaret(Draw& w); - void CtrlPaint(Draw& w, const Rect& clip); + void PaintCaret(SystemDraw& w); + void CtrlPaint(SystemDraw& w, const Rect& clip); void RemoveFullRefresh(); - bool PaintOpaqueAreas(Draw& w, const Rect& r, const Rect& clip, bool nochild = false); - void GatherTransparentAreas(Vector& area, Draw& w, Rect r, const Rect& clip); + bool PaintOpaqueAreas(SystemDraw& w, const Rect& r, const Rect& clip, bool nochild = false); + void GatherTransparentAreas(Vector& area, SystemDraw& w, Rect r, const Rect& clip); Ctrl *FindBestOpaque(const Rect& clip); - void UpdateArea0(Draw& draw, const Rect& clip, int backpaint); - void UpdateArea(Draw& draw, const Rect& clip); + void UpdateArea0(SystemDraw& draw, const Rect& clip, int backpaint); + void UpdateArea(SystemDraw& draw, const Rect& clip); Ctrl *GetTopRect(Rect& r, bool inframe); void DoSync(Ctrl *q, Rect r, bool inframe); bool HasDHCtrl() const; diff --git a/uppsrc/CtrlCore/CtrlDraw.cpp b/uppsrc/CtrlCore/CtrlDraw.cpp index 50f5338d9..7e508a711 100644 --- a/uppsrc/CtrlCore/CtrlDraw.cpp +++ b/uppsrc/CtrlCore/CtrlDraw.cpp @@ -235,7 +235,7 @@ struct sDrawLevelCheck { #define DOLEVELCHECK #endif -void Ctrl::PaintCaret(Draw& w) +void Ctrl::PaintCaret(SystemDraw& w) { #ifdef PLATFORM_X11 if(this == caretCtrl && WndCaretVisible) @@ -243,7 +243,7 @@ void Ctrl::PaintCaret(Draw& w) #endif } -void Ctrl::CtrlPaint(Draw& w, const Rect& clip) { +void Ctrl::CtrlPaint(SystemDraw& w, const Rect& clip) { LEVELCHECK(w, this); LTIMING("CtrlPaint"); Rect rect = GetRect().GetSize(); @@ -324,16 +324,16 @@ void Ctrl::ShowRepaint(int q) sShowRepaint = q; } -void ShowRepaintRect(Draw& w, const Rect& r, Color c) +void ShowRepaintRect(SystemDraw& w, const Rect& r, Color c) { if(sShowRepaint) { w.DrawRect(r, c); - Draw::Flush(); + SystemDraw::Flush(); Sleep(sShowRepaint); } } -bool Ctrl::PaintOpaqueAreas(Draw& w, const Rect& r, const Rect& clip, bool nochild) +bool Ctrl::PaintOpaqueAreas(SystemDraw& w, const Rect& r, const Rect& clip, bool nochild) { LTIMING("PaintOpaqueAreas"); if(!IsShown() || r.IsEmpty() || !r.Intersects(clip) || !w.IsPainting(r)) @@ -402,7 +402,7 @@ void CombineArea(Vector& area, const Rect& r) area.Add(r); } -void Ctrl::GatherTransparentAreas(Vector& area, Draw& w, Rect r, const Rect& clip) +void Ctrl::GatherTransparentAreas(Vector& area, SystemDraw& w, Rect r, const Rect& clip) { LTIMING("GatherTransparentAreas"); Point off = r.TopLeft(); @@ -454,7 +454,7 @@ Ctrl *Ctrl::FindBestOpaque(const Rect& clip) return w; } -void Ctrl::UpdateArea0(Draw& draw, const Rect& clip, int backpaint) +void Ctrl::UpdateArea0(SystemDraw& draw, const Rect& clip, int backpaint) { LTIMING("UpdateArea"); LLOG("========== UPDATE AREA " << UPP::Name(this) << " =========="); @@ -496,7 +496,7 @@ void Ctrl::UpdateArea0(Draw& draw, const Rect& clip, int backpaint) LLOG("========== END"); } -void Ctrl::UpdateArea(Draw& draw, const Rect& clip) +void Ctrl::UpdateArea(SystemDraw& draw, const Rect& clip) { if(IsPanicMode()) return; @@ -570,7 +570,9 @@ void Ctrl::DrawCtrlWithParent(Draw& w, int x, int y) Ctrl *top = parent->GetTopRect(r, inframe); w.Clip(x, y, r.Width(), r.Height()); w.Offset(x - r.left, y - r.top); - top->UpdateArea(w, r); + SystemDraw *ws = dynamic_cast(&w); + if(ws) + top->UpdateArea(*ws, r); w.End(); w.End(); } @@ -581,7 +583,9 @@ void Ctrl::DrawCtrlWithParent(Draw& w, int x, int y) void Ctrl::DrawCtrl(Draw& w, int x, int y) { w.Offset(x, y); - UpdateArea(w, GetRect().GetSize()); + SystemDraw *ws = dynamic_cast(&w); + if(ws) + UpdateArea(*ws, GetRect().GetSize()); w.End(); } diff --git a/uppsrc/ide/Core/Host.cpp b/uppsrc/ide/Core/Host.cpp index 78791411b..455c7f4f7 100644 --- a/uppsrc/ide/Core/Host.cpp +++ b/uppsrc/ide/Core/Host.cpp @@ -214,7 +214,7 @@ void LocalHost::Launch(const char *_cmdline, bool console) out << "#!/bin/sh\n" << cmdline << '\n' << "echo \"<--- Finished, press any key to close the window --->\"\nread\n"; - cmdline = LinuxHostConsole + " bash " + script; + cmdline = LinuxHostConsole + " sh " + script; } Buffer cmd_buf(strlen(cmdline) + 1); char *cmd_out = cmd_buf; @@ -302,7 +302,7 @@ void LocalHost::AddFlags(Index& cfg) cfg.Add("BSD"); #endif -#ifdef PLATFORM_BSD +#ifdef PLATFORM_FREEBSD cfg.Add("FREEBSD"); #endif diff --git a/uppsrc/ide/Insert.cpp b/uppsrc/ide/Insert.cpp index 46a087b95..ff72858ec 100644 --- a/uppsrc/ide/Insert.cpp +++ b/uppsrc/ide/Insert.cpp @@ -83,6 +83,8 @@ void Ide::InsertTpp(const String& fn) void Ide::InsertMenu(Bar& bar) { + if(bar.IsScanKeys()) + return; bar.Add("Insert color..", THISBACK(InsertColor)); int pi = GetPackageIndex(); const Workspace& wspc = IdeWorkspace(); diff --git a/uppsrc/ide/LayDes/layout.cpp b/uppsrc/ide/LayDes/layout.cpp index 6cc76839d..918670bca 100644 --- a/uppsrc/ide/LayDes/layout.cpp +++ b/uppsrc/ide/LayDes/layout.cpp @@ -61,7 +61,7 @@ Array ReadItems(CParser& p, byte charset) LayoutItem& m = items.Add(); m.Create(type); m.SetCharset(charset); - if(p.IsId()) m.variable = ReadVar(p); + m.variable = ReadVar(p); if(strncmp(m.variable, "dv___", 5) == 0) m.variable.Clear(); p.PassChar(','); diff --git a/uppsrc/ide/LayDes/laywin.cpp b/uppsrc/ide/LayDes/laywin.cpp index bbb215d3f..53d44f41a 100644 --- a/uppsrc/ide/LayDes/laywin.cpp +++ b/uppsrc/ide/LayDes/laywin.cpp @@ -225,6 +225,16 @@ void LayDes::Serialize(Stream& s) SetBar(); } +int TypeFilter(int c) +{ + return iscid(c) || c == '<' || c == '>' || c == ':' || c == ',' ? c : 0; +} + +int VariableFilter(int c) +{ + return iscid(c) || c == '.' || c == '[' || c == ']' ? c : 0; +} + LayDes::LayDes() { charset = CHARSET_UTF8; @@ -256,6 +266,8 @@ LayDes::LayDes() variable <<= THISBACK(VariableEdit); type.Disable(); variable.Disable(); + type.SetFilter(TypeFilter); + variable.SetFilter(VariableFilter); item.AddColumn("Type", 20).Margin(0); item.AddColumn("Var / lbl", 10).Margin(0);