Skip to content

Commit

Permalink
Merge pull request #590 from o-sdn-o/gui-bridge
Browse files Browse the repository at this point in the history
8x4 character matrix support
  • Loading branch information
o-sdn-o authored May 20, 2024
2 parents 1ddffac + 8ed18e1 commit 6eba5cc
Show file tree
Hide file tree
Showing 29 changed files with 3,418 additions and 2,382 deletions.
199 changes: 111 additions & 88 deletions doc/apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,94 +167,117 @@ TerminalStdioLog | Stdin/stdout log toggle.
#### Terminal configuration example
```xml
<config>
<term>
<menu item*>
<autohide=true /> <!-- If true, show menu only on hover. -->
<enabled=1 />
<slim=1 />
<item label="<" action=TerminalFindPrev> <!-- type=Command is a default item's attribute. -->
<label="\e[38:2:0:255:0m<\e[m"/>
<notes>
" Previous match \n"
" LeftClick to jump to previous match or scroll \n"
" one page up if nothing to search \n"
" Match clipboard data if no selection \n"
" Left+RightClick to clear clipboard "
</notes>
</item>
<item label=">" action=TerminalFindNext>
<label="\e[38:2:0:255:0m>\e[m"/>
<notes>
" Next match \n"
" LeftClick to jump to next match or scroll \n"
" one page down if nothing to search \n"
" Match clipboard data if no selection \n"
" Left+RightClick to clear clipboard "
</notes>
</item>
<item label="Wrap" type=Option action=TerminalWrapMode data="off">
<label="\e[38:2:0:255:0mWrap\e[m" data="on"/>
<notes>
" Wrapping text lines on/off \n"
" - applied to selection if it is "
</notes>
</item>
<item label="Selection" notes=" Text selection mode " type=Option action=TerminalSelectionMode data="none"> <!-- type=Option means that the тext label will be selected when clicked. -->
<label="\e[38:2:0:255:0mPlaintext\e[m" data="text"/>
<label="\e[38:2:255:255:0mANSI-text\e[m" data="ansi"/>
<label data="rich">
"\e[38:2:109:231:237m""R"
"\e[38:2:109:237:186m""T"
"\e[38:2:60:255:60m" "F"
"\e[38:2:189:255:53m" "-"
"\e[38:2:255:255:49m" "s"
"\e[38:2:255:189:79m" "t"
"\e[38:2:255:114:94m" "y"
"\e[38:2:255:60:157m" "l"
"\e[38:2:255:49:214m" "e" "\e[m"
</label>
<label="\e[38:2:0:255:255mHTML-code\e[m" data="html"/>
<label="\e[38:2:0:255:255mProtected\e[m" data="protected"/>
</item>
<item label="Log" notes=" Stdin/out logging is off " type=Option action=TerminalStdioLog data="off">
<label="\e[38:2:0:255:0mLog\e[m" notes=" Stdin/out logging is on \n Run Logs to see output " data="on"/>
</item>
<item label=" " notes=" ...empty menu block/splitter for safety "/>
<item label="Clear" notes=" Clear TTY viewport " action=TerminalOutput data="\e[2J"/>
<item label="Reset" notes=" Clear scrollback and SGR-attributes " action=TerminalOutput data="\e[!p"/>
<item label="Restart" type=Command action=TerminalRestart/>
<item label="Top" action=TerminalViewportTop/>
<item label="End" action=TerminalViewportEnd/>

<item label="PgLeft" type=Repeat action=TerminalViewportPageLeft/>
<item label="PgRight" type=Repeat action=TerminalViewportPageRight/>
<item label="CharLeft" type=Repeat action=TerminalViewportCharLeft/>
<item label="CharRight" type=Repeat action=TerminalViewportCharRight/>

<item label="PgUp" type=Repeat action=TerminalViewportPageUp/>
<item label="PgDn" type=Repeat action=TerminalViewportPageDown/>
<item label="LineUp" type=Repeat action=TerminalViewportLineUp/>
<item label="LineDn" type=Repeat action=TerminalViewportLineDown/>

<item label="PrnScr" action=TerminalViewportCopy/>
<item label="Deselect" action=TerminalSelectionClear/>

<item label="Line" type=Option action=TerminalSelectionRect data="false">
<label="Rect" data="true"/>
</item>
<item label="Copy" type=Repeat action=TerminalSelectionCopy/>
<item label="Paste" type=Repeat action=TerminalClipboardPaste/>
<item label="Undo" type=Command action=TerminalUndo/>
<item label="Redo" type=Command action=TerminalRedo/>
<item label="Quit" type=Command action=TerminalQuit/>
<item label="Fullscreen" type=Command action=TerminalFullscreen/>

<item label="Hello, World!" notes=" Simulating keypresses " action=TerminalSendKey data="Hello World!"/>
<item label="Push Me" notes=" test " type=Repeat action=TerminalOutput data="pressed ">
<label="\e[37mPush Me\e[m"/>
</item>
</menu>
</term>
<term>
<menu item*>
<autohide=true /> <!-- If true, show menu only on hover. -->
<enabled=1 />
<slim=1 />
<item label="<" action=TerminalFindPrev> <!-- type=Command is a default item's attribute. -->
<label="\e[38:2:0:255:0m<\e[m"/>
<notes>
" Previous match \n"
" LeftClick to jump to previous match or scroll \n"
" one page up if nothing to search \n"
" Match clipboard data if no selection \n"
" Left+RightClick to clear clipboard "
</notes>
</item>
<item label=">" action=TerminalFindNext>
<label="\e[38:2:0:255:0m>\e[m"/>
<notes>
" Next match \n"
" LeftClick to jump to next match or scroll \n"
" one page down if nothing to search \n"
" Match clipboard data if no selection \n"
" Left+RightClick to clear clipboard "
</notes>
</item>
<item label="Wrap" type=Option action=TerminalWrapMode data="off">
<label="\e[38:2:0:255:0mWrap\e[m" data="on"/>
<notes>
" Wrapping text lines on/off \n"
" - applied to selection if it is "
</notes>
</item>
<item label="Selection" notes=" Text selection mode " type=Option action=TerminalSelectionMode data="none"> <!-- type=Option means that the тext label will be selected when clicked. -->
<label="\e[38:2:0:255:0mPlaintext\e[m" data="text"/>
<label="\e[38:2:255:255:0mANSI-text\e[m" data="ansi"/>
<label data="rich">
"\e[38:2:109:231:237m""R"
"\e[38:2:109:237:186m""T"
"\e[38:2:60:255:60m" "F"
"\e[38:2:189:255:53m" "-"
"\e[38:2:255:255:49m" "s"
"\e[38:2:255:189:79m" "t"
"\e[38:2:255:114:94m" "y"
"\e[38:2:255:60:157m" "l"
"\e[38:2:255:49:214m" "e" "\e[m"
</label>
<label="\e[38:2:0:255:255mHTML-code\e[m" data="html"/>
<label="\e[38:2:0:255:255mProtected\e[m" data="protected"/>
</item>
<item label="Log" notes=" Stdin/out logging is off " type=Option action=TerminalStdioLog data="off">
<label="\e[38:2:0:255:0mLog\e[m" notes=" Stdin/out logging is on \n Run Logs to see output " data="on"/>
</item>
<item label=" " notes=" ...empty menu block/splitter for safety "/>
<item label="Clear" notes=" Clear TTY viewport " action=TerminalOutput data="\e[2J"/>
<item label="Reset" notes=" Clear scrollback and SGR-attributes " action=TerminalOutput data="\e[!p"/>
<item label="Restart" type=Command action=TerminalRestart/>
<item label="Top" action=TerminalViewportTop/>
<item label="End" action=TerminalViewportEnd/>

<item label="PgLeft" type=Repeat action=TerminalViewportPageLeft/>
<item label="PgRight" type=Repeat action=TerminalViewportPageRight/>
<item label="CharLeft" type=Repeat action=TerminalViewportCharLeft/>
<item label="CharRight" type=Repeat action=TerminalViewportCharRight/>

<item label="PgUp" type=Repeat action=TerminalViewportPageUp/>
<item label="PgDn" type=Repeat action=TerminalViewportPageDown/>
<item label="LineUp" type=Repeat action=TerminalViewportLineUp/>
<item label="LineDn" type=Repeat action=TerminalViewportLineDown/>

<item label="PrnScr" action=TerminalViewportCopy/>
<item label="Deselect" action=TerminalSelectionClear/>

<item label="Line" type=Option action=TerminalSelectionRect data="false">
<label="Rect" data="true"/>
</item>
<item label="Copy" type=Repeat action=TerminalSelectionCopy/>
<item label="Paste" type=Repeat action=TerminalClipboardPaste/>
<item label="Undo" type=Command action=TerminalUndo/>
<item label="Redo" type=Command action=TerminalRedo/>
<item label="Quit" type=Command action=TerminalQuit/>
<item label="Fullscreen" type=Command action=TerminalFullscreen/>

<item label="Hello, World!" notes=" Simulating keypresses " action=TerminalSendKey data="Hello World!"/>
<item label="Push Me" notes=" test " type=Repeat action=TerminalOutput data="pressed ">
<label="\e[37mPush Me\e[m"/>
</item>

<item label=" HTML " data=none type=Option action=TerminalSelectionOneShot>
<label="\e[48:2:0:128:128;38:2:0:255:255m HTML \e[m" data=html/>
<notes>
" One-shot toggle to copy as HTML \n"
" while mouse tracking is active. "
</notes>
</item>
<item label=" Text " data=none type=Option action=TerminalSelectionOneShot>
<label="\e[48:2:0:128:0;38:2:0:255:0m Text \e[m" data=text/>
<notes>
" One-shot toggle to copy as Text \n"
" while mouse tracking is active. "
</notes>
</item>
<item label="One-Shot" data=none type=Option action=TerminalSelectionOneShot>
<label="\e[48:2:0:128:0;38:2:0:255:0m Text \e[m" data=text/>
<label="\e[48:2:0:128:128;38:2:0:255:255m HTML \e[m" data=html/>
<notes>
" One-shot toggle to copy as Text/HTML \n"
" while mouse tracking is active. "
</notes>
</item>
</menu>
</term>
</config>
```

Expand Down
11 changes: 7 additions & 4 deletions doc/vt-input-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Anyone who wants to:
- Track position dependent keys such as WASD.
- Distinguish between Left and Right physical keys.
- Get consistent output regardless of terminal window resize.
- Track mouse on a pixel-wise level.
- Track mouse outside the terminal window (getting negative coordinates).
- Take advantage of high-resolution wheel scrolling.
- Track scrollback text manipulation.
Expand All @@ -30,19 +31,21 @@ Existing approaches have the following drawbacks:

## Conventions

- All numeric values used in this protocol are decimal and zero-based.
- ~~All numeric values used in this protocol are decimal and zero-based.~~ todo: Should we use HEX-form of the uint32 (IEEE-754 32-bit binary float, Little-Endian) for the floating point value representation?
- Space characters are not used in sequence payloads and are only used for readability of the description.
- All unescaped symbols outside of this protocol should be treated as clipboard pasted data.

### Format

Signaling uses APC `ESC _ <payload> ESC \` with a specific payload syntax.
Signaling uses APC `ESC _ <payload> ESC \` with an event-specific payload syntax.

The payload consists of a list of attributes in the following format:
```
<attr>=<val>,...,<val>; ...; <attr>=<val>,...,<val>
```

todo: representation of the floating point values: float32 -> uint32 IEEE-754 form -> hex? or just round it up to 0.00001?

Field | Descriprtion
------------------|-------------
`<attr>` | Attribute name.
Expand Down Expand Up @@ -350,9 +353,9 @@ ESC _ event=mouse ; kbmods=<KeyMods> ; coord=<X>,<Y> ; buttons=<ButtonState> ; w
Attribute | Description
--------------------------|------------
`kbmods=<KeyMods>` | Keyboard modifiers (see Keyboard event).
`coord=<X>,<Y>` | Mouse pointer coorinates.
`coord=<X>,<Y>` | Pixel-wise coordinates of the mouse pointer. Each coordinate is represented in the form of a floating point value of the sum of the integer coordinate of the cell in the terminal window grid and the relative offset within the cell in the range `[0.0f, 1.0f)`.
`buttons=<ButtonState>` | Mouse button state.
`wheel=<DeltaY>,<DeltaX>` | Vertical and horizontal wheel high-resolution delta.
`wheel=<DeltaY>,<DeltaX>` | Vertical and horizontal wheel high-resolution delta represented as floating point value.

In response to the activation of `mouse` tracking, the application receives a vt-sequence containing current mouse state:
```
Expand Down
2 changes: 1 addition & 1 deletion src/netxs/apps/calc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ int main(int argc, char* argv[])
else
{
auto config = app::shared::load::settings(defaults, cfpath, os::dtvt::config);
app::shared::start(params, app::calc::id, os::dtvt::vtmode, os::dtvt::win_sz, config);
app::shared::start(params, app::calc::id, os::dtvt::vtmode, os::dtvt::window.size, config);
}
}
30 changes: 23 additions & 7 deletions src/netxs/apps/desk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,17 +670,33 @@ namespace netxs::app::desk
->active()
->invoke([&](auto& boss)
{
auto drag_origin = ptr::shared<fp2d>();
boss.mouse.template draggable<hids::buttons::left>(true);
boss.LISTEN(tier::release, e2::form::drag::pull::_<hids::buttons::left>, gear)
boss.LISTEN(tier::release, e2::form::drag::start::_<hids::buttons::left>, gear, -, (drag_origin))
{
*drag_origin = gear.coord;
};
boss.LISTEN(tier::release, e2::form::drag::pull::_<hids::buttons::left>, gear, -, (drag_origin))
{
if (auto taskbar_grips = boss.base::parent())
{
auto delta = twod{ gear.delta.get() };
taskbar_grips->base::min_sz.x = std::max(1, taskbar_grips->base::min_sz.x + delta.x);
taskbar_grips->base::max_sz.x = taskbar_grips->base::min_sz.x;
active ? menu_max_size = taskbar_grips->base::min_sz.x
: menu_min_size = taskbar_grips->base::min_sz.x;
taskbar_grips->base::reflow();

//todo fp2d
//auto delta = twod{ gear.delta.get() };
//taskbar_grips->base::min_sz.x = std::max(1, taskbar_grips->base::min_sz.x + delta.x);
//taskbar_grips->base::max_sz.x = taskbar_grips->base::min_sz.x;
//active ? menu_max_size = taskbar_grips->base::min_sz.x
// : menu_min_size = taskbar_grips->base::min_sz.x;
//taskbar_grips->base::reflow();

if (auto delta = twod{ gear.coord - *drag_origin }[axis::X])
{
taskbar_grips->base::min_sz.x = std::max(1, taskbar_grips->base::min_sz.x + delta);
taskbar_grips->base::max_sz.x = taskbar_grips->base::min_sz.x;
active ? menu_max_size = taskbar_grips->base::min_sz.x
: menu_min_size = taskbar_grips->base::min_sz.x;
taskbar_grips->base::reflow();
}
}
};
boss.LISTEN(tier::release, events::ui::sync, state)
Expand Down
2 changes: 1 addition & 1 deletion src/netxs/apps/term.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ int main(int argc, char* argv[])
else
{
auto config = app::shared::load::settings(defaults, cfpath, os::dtvt::config);
app::shared::start(params, app::terminal::id, os::dtvt::vtmode, os::dtvt::win_sz, config);
app::shared::start(params, app::terminal::id, os::dtvt::vtmode, os::dtvt::window.size, config);
}
}
2 changes: 1 addition & 1 deletion src/netxs/apps/tile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ namespace netxs::app::tile
master.RISEUP(tier::request, e2::config::creator, world_ptr, ());

// Take coor and detach from the tiling wm.
gear.coord -= applet.base::coor(); // Localize mouse coor.
gear.coord -= applet.base::coor(); // Rebase mouse coor.
what.square.size = applet.base::size();
applet.global(what.square.coor);
what.square.coor = -what.square.coor;
Expand Down
Loading

0 comments on commit 6eba5cc

Please sign in to comment.