Skip to content

Commit

Permalink
Highlight occurrences of selected text (altbuf)
Browse files Browse the repository at this point in the history
Merge pull request #210 from netxs-group/dev/sdn
  • Loading branch information
o-sdn-o authored May 2, 2022
2 parents f9c5fd7 + 33139a5 commit a132342
Show file tree
Hide file tree
Showing 27 changed files with 583 additions and 390 deletions.
4 changes: 2 additions & 2 deletions .resources/status/freebsd.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions .resources/status/linux.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions .resources/status/macos.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions .resources/status/netbsd.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions .resources/status/openbsd.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions .resources/status/windows.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions src/netxs/abstract/duplet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ namespace netxs
//duplet operator << (T i) const { return { x << i, y << i }; }
//duplet operator >> (T i) const { return { x >> i, y >> i }; }

template<class D> duplet<D> operator /(D i) const { return { x / i, y / i }; }
template<class D> duplet<D> operator +(D i) const { return { x + i, y + i }; }
template<class D> duplet<D> operator -(D i) const { return { x - i, y - i }; }
template<class D> duplet<D> operator *(D i) const { return { x * i, y * i }; }
template<class D> duplet<D> operator / (D i) const { return { x / i, y / i }; }
template<class D> duplet<D> operator + (D i) const { return { x + i, y + i }; }
template<class D> duplet<D> operator - (D i) const { return { x - i, y - i }; }
template<class D> duplet<D> operator * (D i) const { return { x * i, y * i }; }

bool operator ()(duplet const& p)
bool operator () (duplet const& p)
{
if (*this != p)
{
Expand Down Expand Up @@ -123,7 +123,7 @@ namespace netxs
{
return "{ " + std::to_string(x) + ", " + std::to_string(y) + " }";
}
friend auto& operator<< (std::ostream& s, duplet const& p)
friend auto& operator << (std::ostream& s, duplet const& p)
{
return s << "{ " << p.x << ", " << p.y << " }";
}
Expand Down
2 changes: 1 addition & 1 deletion src/netxs/abstract/fifo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace netxs::generics
constexpr operator bool () const { return size; }
constexpr ITEM front (ITEM const& dflt = {}) { return size ? *item : dflt; }
constexpr
ITEM operator() (ITEM const& dflt = {})
ITEM operator () (ITEM const& dflt = {})
{
if (size)
{
Expand Down
2 changes: 1 addition & 1 deletion src/netxs/abstract/hash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ namespace netxs
return iter->second;
}
template<class K>
auto& operator[] (K&& key) { return at(std::forward<K>(key)); }
auto& operator [] (K&& key) { return at(std::forward<K>(key)); }

imap()
{ }
Expand Down
12 changes: 6 additions & 6 deletions src/netxs/abstract/iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ namespace netxs

it(iterator<T> * source) : source(source) { next(); }

reference operator* () const { return *source->current; };
pointer operator->() const { return source->current; };
reference operator * () const { return *source->current; };
pointer operator -> () const { return source->current; };

it& operator++() { next(); return *this; }
friend bool operator==(it const& lhs, it const& rhs) { return lhs.source == rhs.source; }
friend bool operator!=(it const& lhs, it const& rhs) { return !(lhs == rhs); }
it& operator ++ () { next(); return *this; }
friend bool operator == (it const& lhs, it const& rhs) { return lhs.source == rhs.source; }
friend bool operator != (it const& lhs, it const& rhs) { return !(lhs == rhs); }
};

public:
Expand All @@ -107,7 +107,7 @@ namespace netxs
instance = this;
x.instance = nullptr;
}
iterator<T>& operator=(iterator<T>&& x)
iterator<T>& operator = (iterator<T>&& x)
{
current = std::move(x.current);
return *(instance = this);
Expand Down
4 changes: 2 additions & 2 deletions src/netxs/abstract/ptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace netxs
T last;
bool test = faux;

bool operator()(T newvalue)
bool operator () (T newvalue)
{
prev = last;
test = last != newvalue;
Expand All @@ -34,7 +34,7 @@ namespace netxs

struct null_deleter
{
void operator()(void const*) const
void operator () (void const*) const
{ }
};

Expand Down
2 changes: 1 addition & 1 deletion src/netxs/abstract/queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace netxs
auto guard = std::lock_guard{ d_mutex };
d_queue = std::move(x.d_queue);
}
mt_queue<T>& operator=(mt_queue<T>&& x)
mt_queue<T>& operator = (mt_queue<T>&& x)
{
//todo *this is not a MT safe (only x.d_mutex is locked)
auto guard = std::lock_guard{ d_mutex };
Expand Down
38 changes: 19 additions & 19 deletions src/netxs/abstract/ring.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,25 @@ namespace netxs::generics
virtual void undock_base_front(type&) { };
virtual void undock_base_back (type&) { };

auto current_it() { return iter< ring>{ *this, cart }; }
auto begin() { return iter< ring>{ *this, head }; }
auto end() { return iter< ring>{ *this, mod(tail + 1) }; }
auto begin() const { return iter<const ring>{ *this, head }; }
auto end() const { return iter<const ring>{ *this, mod(tail + 1) }; }
auto& length() const { return size; }
auto& back() { return buff[tail]; }
auto& back() const { return buff[tail]; }
auto& front() { return buff[head]; }
auto& front() const { return buff[head]; }
auto& current () { return buff[cart]; }
auto& operator * () { return buff[cart]; }
auto operator -> () { return buff.begin() + cart; }
auto& at (si32 i) { assert(i >= 0 && i < size); return buff[mod(head + i)]; }
auto& operator[] (si32 i) { return at(i); }
auto index() const { return dst(head, cart); }
void index(si32 i) { assert(i >= 0 && i < size); cart = mod(head + i); }
void prev() { dec(cart); test(); }
void next() { inc(cart); test(); }
auto current_it() { return iter< ring>{ *this, cart }; }
auto begin() { return iter< ring>{ *this, head }; }
auto end() { return iter< ring>{ *this, mod(tail + 1) }; }
auto begin() const { return iter<const ring>{ *this, head }; }
auto end() const { return iter<const ring>{ *this, mod(tail + 1) }; }
auto& length() const { return size; }
auto& back() { return buff[tail]; }
auto& back() const { return buff[tail]; }
auto& front() { return buff[head]; }
auto& front() const { return buff[head]; }
auto& current () { return buff[cart]; }
auto& operator * () { return buff[cart]; }
auto operator -> () { return buff.begin() + cart; }
auto& at (si32 i) { assert(i >= 0 && i < size); return buff[mod(head + i)]; }
auto& operator [] (si32 i) { return at(i); }
auto index() const { return dst(head, cart); }
void index(si32 i) { assert((i > 0 && i < size) || i == 0); cart = mod(head + i); }
void prev() { dec(cart); test(); }
void next() { inc(cart); test(); }

private:
void test()
Expand Down
2 changes: 1 addition & 1 deletion src/netxs/apps/calc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace netxs::console
: inside{ faux },
seized{ faux }
{ }
operator bool(){ return inside || seized || region.size; }
operator bool () { return inside || seized || region.size; }
auto grab(twod const& coord, bool resume)
{
if (inside)
Expand Down
10 changes: 5 additions & 5 deletions src/netxs/console/ansi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -856,11 +856,11 @@ namespace netxs::ansi
} v;
ui64 token;

friend auto operator!= (deco const& a, deco const& b)
{ return a.token != b.token; }
constexpr deco() : token { 0 } { }
constexpr deco (deco const& d) : token { d.token } { }
constexpr void operator = (deco const& d) { token = d.token; }
friend auto operator != (deco const& a, deco const& b)
{ return a.token != b.token; }
constexpr deco() : token { 0 } { }
constexpr deco (deco const& d) : token { d.token } { }
constexpr void operator = (deco const& d) { token = d.token; }
constexpr deco(si32)
: v{ .wrapln = deco::defwrp,
.adjust = bias::left,
Expand Down
32 changes: 22 additions & 10 deletions src/netxs/console/console.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,9 @@ namespace netxs::events::userland

SUBSET_XS( clipboard )
{
EVENT_XS( set, const view ), // Set data to clipboard.
EVENT_XS( get, view ), // Get data from clipboard.
EVENT_XS( set , const view ), // Set data to clipboard.
EVENT_XS( get , view ), // Get data from clipboard.
EVENT_XS( layout, twod ), // Clipboard preview size.
};
};
SUBSET_XS( form )
Expand Down Expand Up @@ -1281,7 +1282,7 @@ namespace netxs::console
: id{ ctrl },
count{ 0 }
{ }
operator bool(){ return T::operator bool(); }
operator bool () { return T::operator bool(); }
};

std::vector<sock> items; // sock: Registered hids.
Expand Down Expand Up @@ -1362,7 +1363,7 @@ namespace netxs::console
: inside{ faux },
seized{ faux }
{ }
operator bool(){ return inside || seized; }
operator bool () { return inside || seized; }
auto corner(twod const& length)
{
return dtcoor.less(dot_11, length, dot_00);
Expand Down Expand Up @@ -1629,7 +1630,7 @@ namespace netxs::console
{
twod cursor; // sock: Coordinates of the active cursor.
bool inside = faux; // sock: Is active.
operator bool(){ return inside; }
operator bool () { return inside; }
auto calc(base const& master, twod curpos)
{
auto area = rect{ dot_00, master.base::size() };
Expand Down Expand Up @@ -2379,7 +2380,7 @@ namespace netxs::console
if (visible) show();
}

operator bool() const { return memo.count(); }
operator bool () const { return memo.count(); }

// pro::caret: Set caret style.
void style(bool new_form)
Expand Down Expand Up @@ -5621,15 +5622,26 @@ namespace netxs::console
{
clip_rawtext = clipbrd_data;
page block{ clipbrd_data };
clip_preview.mark(cell{});
clip_preview.wipe();
//todo revise
//clip_preview.set_style(clip_preview.get_style().wrp(faux));
clip_preview.output(block, cell::shaders::xlucent(0x1f)); //todo make transparency configurable
};
SUBMIT_T(tier::release, e2::command::clipboard::get, token, clipbrd_data)
{
clipbrd_data = clip_rawtext;
};
SUBMIT_T(tier::release, e2::command::clipboard::layout, token, clipbrd_size)
{
clip_preview.size(clipbrd_size);
clip_preview.mark(cell{});
clip_preview.wipe();
page block{ clip_rawtext };
clip_preview.output(block, cell::shaders::xlucent(0x1f)); //todo make transparency configurable
};
SUBMIT_T(tier::request, e2::command::clipboard::layout, token, clipbrd_size)
{
clipbrd_size = clip_preview.size();
};

world->SUBMIT_T(tier::release, e2::form::proceed::render, token, render_scene)
{
Expand Down Expand Up @@ -5883,7 +5895,7 @@ namespace netxs::console
{
auto coor = input.coord + dot_21 * 2;
clip_preview.move(coor);
parent_canvas.plot(clip_preview, cell::shaders::fuse);
parent_canvas.plot(clip_preview, cell::shaders::lite);
}

#ifdef REGIONS
Expand Down Expand Up @@ -5944,7 +5956,7 @@ namespace netxs::console
#endif
}

friend auto& operator<< (std::ostream& s, conf const& c)
friend auto& operator << (std::ostream& s, conf const& c)
{
return s << "\n\t ip: " <<(c.ip.empty() ? text{} : (c.ip + ":" + c.port))
<< "\n\tregion: " << c.region
Expand Down
4 changes: 2 additions & 2 deletions src/netxs/console/input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ namespace netxs::input

ui32 ctlstate = 0;

bool operator !=(sysmouse const& m) const
bool operator != (sysmouse const& m) const
{
bool result;
if ((result = coor == m.coor))
Expand Down Expand Up @@ -780,7 +780,7 @@ namespace netxs::input
}

// hids: Whether event processing is complete.
operator bool() const
operator bool () const
{
return alive;
}
Expand Down
Loading

0 comments on commit a132342

Please sign in to comment.