mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
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
This commit is contained in:
parent
a69fbf7e0f
commit
82dd4aa45f
11 changed files with 76 additions and 21 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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); }
|
||||
|
|
|
|||
|
|
@ -271,6 +271,15 @@ void Vector<T>::Insert(int q, const T& x, int count) {
|
|||
DeepCopyConstructFill(vector + q, vector + q + count, x);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Vector<T>::InsertPick(int i, pick_ T& x)
|
||||
{
|
||||
if(!count) return;
|
||||
ASSERT(&x < vector || &x > vector + items);
|
||||
RawInsert(q, count);
|
||||
::new(vector[q]) T(x);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Vector<T>::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<T>::Insert(int i, const T& x, int count) {
|
|||
Init(vector.Begin() + i, vector.Begin() + i + count, x);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Array<T>::InsertPick(int i, pick_ T& x)
|
||||
{
|
||||
vector.InsertN(i, 1);
|
||||
vector[i] = new T(x);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Array<T>::Insert(int i, T *newt) {
|
||||
vector.InsertN(i, 1);
|
||||
|
|
|
|||
|
|
@ -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.&]
|
||||
|
|
|
|||
|
|
@ -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)).&]
|
||||
|
|
|
|||
|
|
@ -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<Rect>& area, Draw& w, Rect r, const Rect& clip);
|
||||
bool PaintOpaqueAreas(SystemDraw& w, const Rect& r, const Rect& clip, bool nochild = false);
|
||||
void GatherTransparentAreas(Vector<Rect>& 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;
|
||||
|
|
|
|||
|
|
@ -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<Rect>& area, const Rect& r)
|
|||
area.Add(r);
|
||||
}
|
||||
|
||||
void Ctrl::GatherTransparentAreas(Vector<Rect>& area, Draw& w, Rect r, const Rect& clip)
|
||||
void Ctrl::GatherTransparentAreas(Vector<Rect>& 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<SystemDraw *>(&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<SystemDraw *>(&w);
|
||||
if(ws)
|
||||
UpdateArea(*ws, GetRect().GetSize());
|
||||
w.End();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<char> cmd_buf(strlen(cmdline) + 1);
|
||||
char *cmd_out = cmd_buf;
|
||||
|
|
@ -302,7 +302,7 @@ void LocalHost::AddFlags(Index<String>& cfg)
|
|||
cfg.Add("BSD");
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_BSD
|
||||
#ifdef PLATFORM_FREEBSD
|
||||
cfg.Add("FREEBSD");
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ Array<LayoutItem> 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(',');
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue