Skip to content

Commit

Permalink
Merge pull request #157 from netxs-group/dev/sdn
Browse files Browse the repository at this point in the history
Closes #151, #152, #153, #154, #155, #156
  • Loading branch information
o-sdn-o authored Jan 16, 2022
2 parents 0fb4e48 + 5749029 commit a1a0478
Show file tree
Hide file tree
Showing 18 changed files with 1,583 additions and 1,084 deletions.
4 changes: 2 additions & 2 deletions src/netxs/abstract/duplet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ namespace netxs
y{ queue(0) }
{ }

constexpr T& operator [] (int selector) { return selector ? x : y; }
constexpr T const& operator [] (int selector) const { return selector ? x : y; }
constexpr T& operator [] (int selector) { return selector ? y : x; }
constexpr T const& operator [] (int selector) const { return selector ? y : x; }
constexpr explicit operator bool() const { return x != 0 || y != 0; }
constexpr duplet& operator ++ () { x++; y++; return *this; }
constexpr duplet& operator -- () { x--; y--; return *this; }
Expand Down
102 changes: 61 additions & 41 deletions src/netxs/abstract/ring.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,21 @@ namespace netxs::generics
auto& current () { return buff[cart]; }
auto& operator * () { return buff[cart]; }
auto operator -> () { return buff.begin() + cart; }
auto& at (iota i) { return buff[mod(head + i)]; }
auto& at (iota i) { assert(i >= 0 && i < size); return buff[mod(head + i)]; }
auto& operator[] (iota i) { return at(i); }
auto index() const { return dst(head, cart); }
void index(iota i) { cart = mod(head + i); }
void prev() { dec(cart); }
void next() { inc(cart); }
void index(iota i) { assert(i >= 0 && i < size); cart = mod(head + i); }
void prev() { dec(cart); test(); }
void next() { inc(cart); test(); }

private:
void test()
{
assert((head == tail && cart == head)
|| (head < tail && cart >= head && cart <= tail)
|| (head > tail && (cart >= head && cart >= tail
|| cart <= head && cart <= tail)));
}
auto full()
{
if (size == peak - 1)
Expand Down Expand Up @@ -113,40 +120,10 @@ namespace netxs::generics
if (cart == tail) dec(tail), cart = tail;
else dec(tail);
}
public:
template<class ...Args>
auto& push_back(Args&&... args)
{
if (full()) undock_front();
else ++size;
inc(tail);
auto& item = back();
item = type(std::forward<Args>(args)...);
return item;
}
template<class ...Args>
auto& push_front(Args&&... args)
{
if (full()) undock_back();
else ++size;
dec(head);
auto& item = front();
item = type(std::forward<Args>(args)...);
return item;
}
template<bool USE_BACK = faux>
void pop_front() { undock_front<USE_BACK>(); --size; }
void pop_back () { undock_back(); --size; }
// ring: Insert an item before the specified position. Pop front when full. Return an iterator pointing to the new item.
template<class ...Args>
auto insert(iota at, Args&&... args) // Pop front always if ring is full.
auto insert_impl(iota at, Args&&... args) // Pop front always if ring is full.
{
assert(at >= 0 && at <= size);

auto tmp = index();
if (tmp >= at) tmp++;
index(tmp);

if (at == 0)
{
push_front(std::forward<Args>(args)...);
Expand All @@ -164,19 +141,19 @@ namespace netxs::generics
{
auto it_1 = begin();
auto it_2 = it_1 + d;
if (!full())
if (full())
{
++size;
dec(head);
auto& item = front();
if constexpr (USE_UNDOCK) undock_base_front(item);
item = type(std::forward<Args>(args)...);
++it_1;
}
else
{
++size;
dec(head);
auto& item = front();
if constexpr (USE_UNDOCK) undock_base_front(item);
item = type(std::forward<Args>(args)...);
++it_1;
}
swap_block<true>(it_1, it_2, begin());
--it_2;
Expand Down Expand Up @@ -204,6 +181,49 @@ namespace netxs::generics
return it_2;
}
}

public:
template<class ...Args>
type& push_back(Args&&... args)
{
if (full()) undock_front();
else ++size;
inc(tail);
auto& item = back();
item = type(std::forward<Args>(args)...);
return item;
}
template<class ...Args>
type& push_front(Args&&... args)
{
if (full()) undock_back();
else ++size;
dec(head);
auto& item = front();
item = type(std::forward<Args>(args)...);
return item;
}
template<bool USE_BACK = faux>
void pop_front() { undock_front<USE_BACK>(); --size; }
void pop_back () { undock_back(); --size; }
// ring: Insert an item before the specified position. Pop front when full. Return an iterator pointing to the new item.
template<class ...Args>
auto insert(iota at, Args&&... args) // Pop front always if ring is full.
{
assert(at >= 0 && at <= size);
auto temp = index();
if (full())
{
if (temp > 0 && temp < at) temp--;
}
else
{
if (temp >= at) temp++;
}
auto iter = insert_impl(at, std::forward<Args>(args)...);
index(temp);
return iter;
}
auto remove(iota at, iota n)
{
assert(at >= 0 && at < size);
Expand All @@ -214,7 +234,7 @@ namespace netxs::generics
auto vol = n;
auto tmp = index();
if (tmp >= at + n) tmp -= n;
else if (tmp >= at ) tmp = at - 1;
else if (tmp >= at ) tmp = std::max(at - 1, 0);

auto top_block = at;
auto btm_block = max - n;
Expand Down
24 changes: 20 additions & 4 deletions src/netxs/abstract/tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,17 @@ namespace netxs::generics
}
else last = &next;
}
else break;
else
{
if (last->stop) break;
else queue.pop_front();
}
}
else
{
if (last->stop) break;
else queue.pop_front();
}
else break;
}
}

Expand Down Expand Up @@ -97,9 +105,17 @@ namespace netxs::generics
}
else last = &next;
}
else break;
else
{
if (last->stop) break;
else queue.pop_front();
}
}
else
{
if (last->stop) break;
else queue.pop_front();
}
else break;
}
}
}
Expand Down
11 changes: 5 additions & 6 deletions src/netxs/apps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ namespace netxs::app::shared
log("app_limit: max count reached");
auto timeout = tempus::now() + APPS_DEL_TIMEOUT;
auto shadow = ptr::shadow(boss);
boss->SUBMIT_BYVAL(tier::general, e2::tick, timestamp)
boss->SUBMIT_BYVAL(tier::general, e2::timer::any, timestamp)
{
if (timestamp > timeout)
{
Expand Down Expand Up @@ -343,7 +343,7 @@ namespace netxs::app::shared
->attach(ui::mock::ctor());
auto strob_shadow = ptr::shadow(strob);
bool stobe_state = true;
strob->SUBMIT_BYVAL(tier::general, e2::tick, now)
strob->SUBMIT_BYVAL(tier::general, e2::timer::any, now)
{
stobe_state = !stobe_state;
if (auto strob = strob_shadow.lock())
Expand Down Expand Up @@ -556,10 +556,9 @@ namespace netxs::app::shared
auto test_stat_area = object->attach(slot::_2, ui::fork::ctor(axis::Y));
auto layers = test_stat_area->attach(slot::_1, ui::cake::ctor());
auto scroll = layers->attach(ui::rail::ctor())
->config(true, true)
->colors(whitelt, reddk);
scroll->attach(ui::post::ctor())
->upload(truecolor);
->upload(truecolor);
auto scroll_bars = layers->attach(ui::fork::ctor());
auto vt = scroll_bars->attach(slot::_2, ui::grip<axis::Y>::ctor(scroll));
auto hz = test_stat_area->attach(slot::_2, ui::grip<axis::X>::ctor(scroll));
Expand Down Expand Up @@ -897,9 +896,9 @@ namespace netxs::app::shared
#ifdef DEMO
auto shell = os::get_shell();
#ifdef PROD
app::shared::objs_config[objs_lookup["Tile"]].param = "VTM_PROFILE_1=\"Tile\", \"Tiling Window Manager\", h(v(\"" + shell + " -c 'LC_ALL=en_US.UTF-8 mc -c -x -d; cat'\", h(\"" + shell + " -c 'ls /bin | nl | ccze -A; " + shell + "'\", a(\"Settings\",\"Settings\",\"\"))), a(\"Calc\",\"\",\"\"))";
app::shared::objs_config[objs_lookup["Tile"]].param = "VTM_PROFILE_1=\"Tile\", \"Tiling Window Manager\", h(v(a(\"MC\",\"\",\"\"), h(\"" + shell + " -c 'ls /bin | nl | ccze -A; " + shell + "'\", a(\"Settings\",\"Settings\",\"\"))), a(\"Calc\",\"\",\"\"))";
#else
app::shared::objs_config[objs_lookup["Tile"]].param = "VTM_PROFILE_1=\"Tile\", \"Tiling Window Manager\", h1:1(v1:1(\"" + shell + " -c 'LC_ALL=en_US.UTF-8 mc -c -x -d; cat'\", h1:1(\"\",\"" + shell + " -c 'ls /bin | nl | ccze -A; " + shell + "'\")), a(\"Calc\",\"\",\"\"))";
app::shared::objs_config[objs_lookup["Tile"]].param = "VTM_PROFILE_1=\"Tile\", \"Tiling Window Manager\", h1:1(v1:1(a(\"MC\",\"\",\"\"), h1:1(\"\",\"" + shell + " -c 'ls /bin | nl | ccze -A; " + shell + "'\")), a(\"Calc\",\"\",\"\"))";
#endif

for (auto& [menu_item_id, app_data] : app::shared::objs_config)
Expand Down
32 changes: 15 additions & 17 deletions src/netxs/apps/calc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,22 +256,22 @@ namespace netxs::app::calc
{
auto clr = topclr - 0x0f0f0f;
cellatix_text_head.bgc(clr - step * 0 /* 0xf0f0f0 */).add(" ")
.bgc(clr - step * 1 /* 0xededed */).add(" ")
.bgc(clr - step * 2 /* 0xeaeaea */).add(c)
.bgc(clr - step * 3 /* 0xe7e7e7 */).add(" ")
.bgc(clr - step * 4 /* 0xe4e4e4 */).add(" ");
.bgc(clr - step * 1 /* 0xededed */).add(" ")
.bgc(clr - step * 2 /* 0xeaeaea */).add(c)
.bgc(clr - step * 3 /* 0xe7e7e7 */).add(" ")
.bgc(clr - step * 4 /* 0xe4e4e4 */).add(" ");
}
auto clr = topclr;
auto cellatix_text_01 = ansi::bgc(clr - step * 0 /* 0xffffff */).add(" ")
.bgc(clr - step * 1 /* 0xfcfcfc */).add(" ")
.bgc(clr - step * 2 /* 0xf9f9f9 */).add(" ")
.bgc(clr - step * 3 /* 0xf6f6f6 */).add(" ")
.bgc(clr - step * 4 /* 0xf3f3f3 */).add(" ");
.bgc(clr - step * 1 /* 0xfcfcfc */).add(" ")
.bgc(clr - step * 2 /* 0xf9f9f9 */).add(" ")
.bgc(clr - step * 3 /* 0xf6f6f6 */).add(" ")
.bgc(clr - step * 4 /* 0xf3f3f3 */).add(" ");
auto cellatix_text_00 = ansi::bgc(clr - step * 4 /* 0xf3f3f3 */).add(" ")
.bgc(clr - step * 3 /* 0xf6f6f6 */).add(" ")
.bgc(clr - step * 2 /* 0xf9f9f9 */).add(" ")
.bgc(clr - step * 1 /* 0xfcfcfc */).add(" ")
.bgc(clr - step * 0 /* 0xffffff */).add(" ");
.bgc(clr - step * 3 /* 0xf6f6f6 */).add(" ")
.bgc(clr - step * 2 /* 0xf9f9f9 */).add(" ")
.bgc(clr - step * 1 /* 0xfcfcfc */).add(" ")
.bgc(clr - step * 0 /* 0xffffff */).add(" ");
cellatix_cols = ansi::nil().wrp(wrap::off)
+ cellatix_text_head;
cellatix_text = ansi::nil().wrp(wrap::off);
Expand Down Expand Up @@ -360,8 +360,7 @@ namespace netxs::app::calc
auto rows_body = body_area->attach(slot::_2, ui::fork::ctor());
auto layers = rows_body->attach(slot::_2, ui::cake::ctor());
auto scroll = layers->attach(ui::rail::ctor())
->plugin<pro::limit>(twod{ -1,1 }, twod{ -1,-1 })
->config(true, true);
->plugin<pro::limit>(twod{ -1,1 }, twod{ -1,-1 });
auto grid = scroll->attach(ui::post::ctor())
->colors(0xFF000000, 0xFFffffff)
->plugin<pro::cell_highlight>()
Expand All @@ -375,7 +374,7 @@ namespace netxs::app::calc
{
grid->SUBMIT(tier::release, e2::data::text, data)
{
boss.upload(ansi::bgc(whitelt).fgc(blacklt).add(data));
boss.upload(ansi::bgc(whitelt).fgc(blacklt).add(data));
};
});
auto cols_area = corner_cols->attach(slot::_2, ui::rail::ctor(axes::X_ONLY, axes::X_ONLY))
Expand All @@ -389,8 +388,7 @@ namespace netxs::app::calc
auto rows = rows_area->attach(ui::post::ctor())
->upload(cellatix_rows); //todo grid 1 \n 2 \n 3 \n ...
auto stat_area = all_stat->attach(slot::_2, ui::rail::ctor())
->plugin<pro::limit>(twod{ -1,1 }, twod{ -1,1 })
->moveby<axis::X>(-5);
->plugin<pro::limit>(twod{ -1,1 }, twod{ -1,1 });
auto sheet_plus = stat_area->attach(ui::fork::ctor());
auto sheet = sheet_plus->attach(slot::_1, ui::post::ctor())
->plugin<pro::limit>(twod{ -1,-1 }, twod{ 13,-1 })
Expand Down
Loading

0 comments on commit a1a0478

Please sign in to comment.