diff --git a/uppsrc/CtrlLib/ArrayCtrl.cpp b/uppsrc/CtrlLib/ArrayCtrl.cpp index 38e9d3191..ecc61b386 100644 --- a/uppsrc/CtrlLib/ArrayCtrl.cpp +++ b/uppsrc/CtrlLib/ArrayCtrl.cpp @@ -2386,6 +2386,16 @@ void ArrayCtrl::SortB(const Vector& o) } } +void ArrayCtrl::ReArrange(const Vector& order) +{ + CHECK(KillCursor()); + ClearCache(); + SortA(); + SortB(order); + Refresh(); + SyncInfo(); +} + void ArrayCtrl::Sort(const ArrayCtrl::Order& order) { CHECK(KillCursor()); ClearCache(); @@ -2430,6 +2440,17 @@ void ArrayCtrl::Sort(int from, int count, const ArrayCtrl::Order& order) Sort(from, count, THISBACK1(OrderPred, &order)); } +struct sAC_ColumnSort : public ValueOrder { + bool descending; + const ValueOrder *order; + int (*cmp)(const Value& a, const Value& b); + + virtual bool operator()(const Value& a, const Value& b) const { + return descending ? cmp ? (*cmp)(b, a) < 0 : (*order)(b, a) + : cmp ? (*cmp)(a, b) < 0 : (*order)(a, b); + } +}; + bool ArrayCtrl::ColumnSortPred(int i1, int i2, int column, const ValueOrder *o) { return (*o)(GetConvertedColumn(i1, column), GetConvertedColumn(i2, column)); @@ -2451,6 +2472,17 @@ void ArrayCtrl::ColumnSort(int column, const ValueOrder& order) ColumnSort(column, THISBACK2(ColumnSortPred, column, &order)); } +void ArrayCtrl::ColumnSort(int column, int (*compare)(const Value& a, const Value& b)) +{ + sAC_ColumnSort cs; + cs.descending = false; + cs.order = NULL; + cs.cmp = compare; + if(!cs.cmp) + cs.cmp = StdValueCompare; + ColumnSort(column, cs); +} + void ArrayCtrl::SetSortColumn(int ii, bool desc) { sortcolumn = ii; @@ -2469,17 +2501,6 @@ void ArrayCtrl::ToggleSortColumn(int ii) DoColumnSort(); } -struct sAC_ColumnSort : public ValueOrder { - bool descending; - const ValueOrder *order; - int (*cmp)(const Value& a, const Value& b); - - virtual bool operator()(const Value& a, const Value& b) const { - return descending ? cmp ? (*cmp)(b, a) < 0 : (*order)(b, a) - : cmp ? (*cmp)(a, b) < 0 : (*order)(a, b); - } -}; - void ArrayCtrl::DoColumnSort() { if(sortcolumn < 0) { @@ -2855,8 +2876,11 @@ void ArrayCtrl::InsertDrop(int line, const Vector< Vector >& data, PasteC } } else - if(IsCursor()) + if(IsCursor()) { + if(GetCursor() < line) + line--; Remove(GetCursor()); + } KillCursor(); d.SetAction(DND_COPY); } diff --git a/uppsrc/CtrlLib/ArrayCtrl.h b/uppsrc/CtrlLib/ArrayCtrl.h index 8ff80f782..bbff77d2e 100644 --- a/uppsrc/CtrlLib/ArrayCtrl.h +++ b/uppsrc/CtrlLib/ArrayCtrl.h @@ -528,6 +528,8 @@ public: bool FindSetCursor(const Value& val, int ii = 0, int from = 0); bool FindSetCursor(const Value& val, const Id& id, int from = 0); + void ReArrange(const Vector& order); + void Sort(Gate2 order); void Sort(int from, int count, Gate2 order); void Sort(const ArrayCtrl::Order& order); @@ -543,6 +545,7 @@ public: void ColumnSort(int column, Gate2 order); void ColumnSort(int column, const ValueOrder& order); + void ColumnSort(int column, int (*compare)(const Value& a, const Value& b) = StdValueCompare); void SetSortColumn(int ii, bool descending = false); void ToggleSortColumn(int ii); diff --git a/uppsrc/CtrlLib/src.tpp/ArrayCtrl$en-us.tpp b/uppsrc/CtrlLib/src.tpp/ArrayCtrl$en-us.tpp index 49495773c..2023a812a 100644 --- a/uppsrc/CtrlLib/src.tpp/ArrayCtrl$en-us.tpp +++ b/uppsrc/CtrlLib/src.tpp/ArrayCtrl$en-us.tpp @@ -1891,6 +1891,16 @@ moving it up.&] [s2; Exchanges the cursor row with following row, effectively moving it down.&] [s3; &] +[s4;%- &] +[s5;:Upp`:`:ArrayCtrl`:`:ReArrange`(const Upp`:`:Vector``&`):%- [@(0.0.255) void]_ +[* ReArrange]([@(0.0.255) const]_[_^Upp`:`:Vector^ Vector]<[@(0.0.255) int]>`&_[*@3 order]) +&] +[s2; Rearranges lines of array by [%-*@3 order] of former line indices. +The count of items in [%-*@3 order] must be the same as GetCount +of ArrayCtrl and it must contain all indices from zero to GetCount() +`- 1. [%-*@3 order] establishes a new order expressed in former +indices of lines.&] +[s3; &] [s4; &] [s5;:ArrayCtrl`:`:Sort`(Gate2``): [@(0.0.255) void]_[* Sort]([_^Gate2^ Gate2]<[@(0.0.255) i nt], [@(0.0.255) int]>_[*@3 order])&] @@ -1990,6 +2000,14 @@ ColumnSortSecondary and ColumnSortFindKey flags.&] because the final converted value of column is used (which can even be combination of more indexes).&] [s3; &] +[s4;%- &] +[s5;:Upp`:`:ArrayCtrl`:`:ColumnSort`(int`,int`(`*`)`(const Valua`&a`,const Upp`:`:Value`&b`)`):%- [@(0.0.255) v +oid]_[* ColumnSort]([@(0.0.255) int]_[*@3 column], [@(0.0.255) int]_(`*[*@3 compare])([@(0.0.255) c +onst]_Valua[@(0.0.255) `&]_a, [@(0.0.255) const]_Value[@(0.0.255) `&]_b))&] +[s2; Sorts by the column. Note that this is different from Sort, +because the final converted value of column is used (which can +even be combination of more indexes).&] +[s3; &] [s4; &] [s5;:ArrayCtrl`:`:SetSortColumn`(int`,bool`): [@(0.0.255) void]_[* SetSortColumn]([@(0.0.255) i nt]_[*@3 ii], [@(0.0.255) bool]_[*@3 descending]_`=_[@(0.0.255) false])&] diff --git a/uppsrc/ide/build_info.h b/uppsrc/ide/build_info.h new file mode 100644 index 000000000..dc977410d --- /dev/null +++ b/uppsrc/ide/build_info.h @@ -0,0 +1,9 @@ +#define bmYEAR 2016 +#define bmMONTH 3 +#define bmDAY 16 +#define bmHOUR 18 +#define bmMINUTE 44 +#define bmSECOND 55 +#define bmTIME Time(2016, 3, 16, 18, 44, 55) +#define bmMACHINE "MAIN" +#define bmUSER "cxl"