Skip to content

Commit

Permalink
Merge pull request #617 from o-sdn-o/gui-bridge
Browse files Browse the repository at this point in the history
Implement DECCRA
  • Loading branch information
o-sdn-o authored Jul 25, 2024
2 parents e7e3445 + adbe34a commit 9cd1b58
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 47 deletions.
4 changes: 2 additions & 2 deletions src/netxs/apps/test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ namespace netxs::app::test
"𜸩 𜸩𜸾𜸟𜸤𜸩𜸩𜸫𜸹𜸩 𜸧 𜸩 𜸨𜸟𜸶𜸨𜸟𜸷𜸩 𜸧𜸨𜸟 𜸩 𜸫𜸳𜸻𜸨𜸟𜹃𜸨𜸟 𜸨𜸟𜹃𜸩𜸨𜸟 𜸩 𜸨𜸟 𜸾𜸟𜸤\n"
"𜸾𜸟𜹃𜸾𜸟𜹃𜸼𜸼 𜸼𜸾𜸟𜹃 𜸽𜸟𜸥𜸼 𜸼𜸼 𜸼𜸾𜸟𜹃𜸽𜸟𜸥 𜸼 𜸼 𜸼 𜸽𜸟𜸥 𜸼 𜸼𜸽𜸟𜸥𜸾𜸟𜹃𜸽𜸟𜸥𜸾𜸟𜹃\n")
.add("\n")
.add(header("Styled Underlines"))
.add(header("Styled Underline"))
.add("\n")
.add(" ").ovr(true).add("Single Overline").ovr(faux).eol()
.add(" ").und(unln::biline).add("Double Underline").und(unln::none).eol()
Expand All @@ -170,7 +170,7 @@ namespace netxs::app::test
//.add(" ").und(unln::wavy ).unc(argb{ pureblack }).add("Black Wavy Underline").und(unln::none).eol()
.nil()
.add("\n")
.add(header("Font Styles"))
.add(header("Font Style"))
.add("\n")
.bld(faux).itc(faux).add("Normal WVMQWERTYUIOPASDFGHJKLZXCVBNM韓M😎M 🥵🥵", vss<11>, "🦚😀⛷🏂😁😂😃😄😅😆👌🐞😎👪\n")
.blk(true) .add("Blinking WVMQWERTYUIOPASDFGHJKLZXCVBNM韓M😎M 🥵🥵", vss<11>, "🦚😀⛷🏂😁😂😃😄😅😆👌🐞😎👪\n")
Expand Down
1 change: 1 addition & 0 deletions src/netxs/desktopio/ansivt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ namespace netxs::ansi
static const auto csi_exl_rst = 'p'; // CSI ! p — Reset terminal to initial state.
static const auto csi_qst_rtb = 'W'; // CSI ? W — Reset tabstops to the defaults.
static const auto csi_dlr_fra = 'x'; // CSI Char ; Top ; Left ; Bottom ; Right $ x — Fill rectangular area (DECFRA).
static const auto csi_dlr_cra = 'v'; // CSI srcTop ; srcLeft ; srcBottom ; srcRight ; srcBuffIndex ; dstTop ; dstLeft ; dstBuffIndex $ v — Copy rectangular area (DECCRA). BuffIndex: 1..6, 1 is default index. All coords are 1-based.
static const auto csi_cuu = 'A'; // CSI n A — Cursor Up.
static const auto csi_cud = 'B'; // CSI n B — Cursor Down.
static const auto csi_cud2 = 'e'; // CSI n e — Cursor Down.
Expand Down
2 changes: 1 addition & 1 deletion src/netxs/desktopio/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace netxs::app

namespace netxs::app::shared
{
static const auto version = "v0.9.97";
static const auto version = "v0.9.98";
static const auto repository = "https://github.com/directvt/vtm";
static const auto usr_config = "~/.config/vtm/settings.xml"s;
static const auto sys_config = "/etc/vtm/settings.xml"s;
Expand Down
4 changes: 2 additions & 2 deletions src/netxs/desktopio/canvas.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1187,8 +1187,8 @@ namespace netxs
ui32 hyperlink : 1; // cell::px strores string hash.
ui32 blinks : 1;
ui32 bitmap : 2; // body::pxtype: Cursor losts its colors when it covers bitmap.
ui32 fusion : 2; // Background interpolation current c0 with neighbor c1 and c2 cells:
//
ui32 fusion : 2; // todo The outlines of object boundaries must be set when rendering each window (pro::shape).
// Background interpolation current c0 with neighbor c1 and c2 cells:
// c0 c1
// c2
// BG interpolation type (two 1-bit values):
Expand Down
32 changes: 3 additions & 29 deletions src/netxs/desktopio/consrv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2381,32 +2381,6 @@ struct impl : consrv
codepage == CP_UTF8 ? "UTF-8"s :
"OEM-"s + std::to_string(codepage);
}
template<class S, class P>
auto write_block(S& scrollback, core const& block, twod coor, rect trim, P fuse)
{
auto size = block.size();
auto clip = block.clip();
auto dest = rect{ coor, clip.size };
trim.trimby(dest);
clip -= dest - trim;
coor = trim.coor;
auto head = block.begin() + clip.coor.y * size.x;
auto tail = head + clip.size.y * size.x;
auto rest = size.x - (clip.coor.x + clip.size.x);
auto save = scrollback.coord;
assert(rest >= 0);
while (head != tail)
{
head += clip.coor.x;
auto next = head + clip.size.x;
auto line = std::span(head, next);
scrollback.cup0(coor);
scrollback._data<true>(clip.size.x, line, fuse);
head = next + rest;
coor.y++;
}
scrollback.cup0(save);
}
auto newbuf(auto& client) // MSVC bug; It doesn't see constexpr inside lambdas (even constexpr functions).
{
if constexpr (isreal())
Expand Down Expand Up @@ -3456,7 +3430,7 @@ struct impl : consrv
netxs::onbody(dest, copy, allfx, eolfx);
auto success = direct(packet.target, [&](auto& scrollback)
{
write_block(scrollback, dest, crop.coor, rect{ dot_00, window_inst.panel }, cell::shaders::full); // cell::shaders::skipnuls for transparency?
uiterm.write_block(scrollback, dest, crop.coor, rect{ dot_00, window_inst.panel }, cell::shaders::full); // cell::shaders::skipnuls for transparency?
});
if (!success) crop = {};
}
Expand Down Expand Up @@ -4394,8 +4368,8 @@ struct impl : consrv
filler.size(scrl.size);
direct(packet.target, [&](auto& scrollback)
{
write_block(scrollback, filler, scrl.coor, clip, cell::shaders::full);
write_block(scrollback, mirror, dest, clip, cell::shaders::full);
uiterm.write_block(scrollback, filler, scrl.coor, clip, cell::shaders::full);
uiterm.write_block(scrollback, mirror, dest, clip, cell::shaders::full);
});
}
else
Expand Down
20 changes: 7 additions & 13 deletions src/netxs/desktopio/intmath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,12 +753,10 @@ namespace netxs
{
auto& size1 = bitmap1.size();
auto& size2 = bitmap2.size();

if (size1 == size2)
{
auto data1 = bitmap1.begin();
auto data2 = bitmap2.begin();

auto limit = data1 + size1.y * size2.x;
while (limit != data1)
{
Expand All @@ -774,16 +772,13 @@ namespace netxs
void inbody(auto&& canvas, auto&& bitmap, R const& region, C const& base2, P handle, NewlineFx online = {})
{
if (region.size.y == 0) return;
auto& base1 = region.coor;

auto& size1 = canvas.size();
auto& size2 = bitmap.size();

auto data1 = canvas.begin() + base1.x + base1.y * size1.x;
auto data2 = bitmap.begin() + base2.x + base2.y * size2.x;

auto skip1 = size1.x - region.size.x;
auto skip2 = size2.x;
auto base1 = region.coor;
auto size1 = canvas.size();
auto size2 = bitmap.size();
auto data1 = canvas.begin() + base1.x + base1.y * size1.x;
auto data2 = bitmap.begin() + base2.x + base2.y * size2.x;
auto skip1 = size1.x - region.size.x;
auto skip2 = size2.x;
if constexpr (RtoL)
{
data2 += region.size.x;
Expand All @@ -793,7 +788,6 @@ namespace netxs
{
skip2 -= region.size.x;
}

auto bound = data1 + region.size.x;
auto limit = bound + (region.size.y - 1) * size1.x;
while (true)
Expand Down
76 changes: 76 additions & 0 deletions src/netxs/desktopio/terminal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ namespace netxs::ui
vt.csier.table_excl [csi_exl_rst] = V{ p->owner.decstr( ); }; // CSI ! p Soft terminal reset (DECSTR).

vt.csier.table_dollarsn[csi_dlr_fra] = V{ p->fra(q); }; // CSI Char ; Top ; Left ; Bottom ; Right $ x — Fill rectangular area (DECFRA).
vt.csier.table_dollarsn[csi_dlr_cra] = V{ p->owner.deccra(q); }; // CSI srcTop ; srcLeft ; srcBottom ; srcRight ; srcBuffIndex ; dstTop ; dstLeft ; dstBuffIndex $ v — Copy rectangular area (DECCRA). BuffIndex: 1..6, 1 is default index. All coords are 1-based.

vt.csier.table[csi_sgr][sgr_fg_blk ] = V{ p->owner.ctrack.fgc(tint::blackdk ); };
vt.csier.table[csi_sgr][sgr_fg_red ] = V{ p->owner.ctrack.fgc(tint::reddk ); };
Expand Down Expand Up @@ -6382,6 +6383,7 @@ namespace netxs::ui
using buffer_ptr = bufferbase*;
using vtty = os::vt::vtty;

std::array<face, 5> pocket; // term: Buffers for DECCRA.
termconfig config; // term: Terminal settings.
scroll_buf normal; // term: Normal screen buffer.
alt_screen altbuf; // term: Alternate screen buffer.
Expand Down Expand Up @@ -6416,6 +6418,80 @@ namespace netxs::ui
hook onerun; // term: One-shot token for restart session.
vtty ipccon; // term: IPC connector. Should be destroyed first.

// term: Place rectangle block to the scrollback buffer.
template<class S, class P>
auto write_block(S& scrollback, core const& block, twod coor, rect trim, P fuse)
{
auto size = block.size();
auto clip = block.clip();
auto dest = rect{ coor, clip.size };
trim.trimby(dest);
clip -= dest - trim;
coor = trim.coor;
auto head = block.begin() + clip.coor.y * size.x;
auto tail = head + clip.size.y * size.x;
auto rest = size.x - (clip.coor.x + clip.size.x);
auto save = scrollback.coord;
assert(rest >= 0);
while (head != tail)
{
head += clip.coor.x;
auto next = head + clip.size.x;
auto line = std::span(head, next);
scrollback.cup0(coor);
scrollback.template _data<true>(clip.size.x, line, fuse);
head = next + rest;
coor.y++;
}
scrollback.cup0(save);
}
// term: CSI srcTop ; srcLeft ; srcBottom ; srcRight ; srcBuffIndex ; dstTop ; dstLeft ; dstBuffIndex $ v — Copy rectangular area (DECCRA). BuffIndex: 1..6, 1 is default index. All coords are 1-based (inclusive).
void deccra(fifo& q)
{
auto srcTop = q(0);
auto srcLeft = q(0);
auto srcBottom = q(0);
auto srcRight = q(0);
auto srcBuffIndex = std::clamp(q(0), 1, 6) - 2; // Pocket buffers are 2..6 (0..4). -1 it is a real buffer.
auto dstTop = q(0);
auto dstLeft = q(0);
auto dstBuffIndex = std::clamp(q(0), 1, 6) - 2; // Pocket buffers are 2..6 (0..4). -1 it is a real buffer.
auto fragment = face{};
auto& console = *target;
auto size = srcBuffIndex == -1 ? console.panel : pocket[srcBuffIndex].size();
srcRight += srcRight ? 0 : size.x;
srcBottom += srcBottom ? 0 : size.y;
srcLeft -= srcLeft ? 1 : 0;
srcTop -= srcTop ? 1 : 0;
dstLeft -= dstLeft ? 1 : 0;
dstTop -= dstTop ? 1 : 0;
auto area = rect{{ srcLeft, srcTop }, { srcRight - srcLeft, srcBottom - srcTop }};
auto src_area = rect{ dot_00, size };
area.trimby(src_area);
fragment.full(src_area);
fragment.core::crop(area.size, defclr);
fragment.core::area(area);
// Take fragment.
if (srcBuffIndex == -1) console.do_viewport_copy(fragment);
else netxs::onbody(fragment, pocket[srcBuffIndex], cell::shaders::full);
// Put fragment.
auto coor = twod{ dstLeft, dstTop };
if (dstBuffIndex == -1) // Dst is real buffer.
{
area.coor = {};
fragment.area(area);
if (target == &normal) write_block(normal, fragment, coor, src_area, cell::shaders::full);
else if (target == &altbuf) write_block(altbuf, fragment, coor, src_area, cell::shaders::full);
}
else
{
area.coor = coor;
fragment.area(area);
auto& dst = pocket[dstBuffIndex];
dst.crop(console.panel, defclr);
dst.plot(fragment, cell::shaders::full);
}
}
// term: Set semantic marker (OSC 133).
void osc_marker(view data)
{
Expand Down

0 comments on commit 9cd1b58

Please sign in to comment.