Skip to content

Commit

Permalink
Merge pull request #689 from o-sdn-o/gui-bridge
Browse files Browse the repository at this point in the history
Fix some multithreaded deadlocks
  • Loading branch information
o-sdn-o authored Nov 24, 2024
2 parents c5a38c5 + ccd2567 commit 57cba57
Show file tree
Hide file tree
Showing 13 changed files with 158 additions and 128 deletions.
18 changes: 9 additions & 9 deletions doc/apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ Note: It is possible to combine multiple command into a single sequence using a

### Custom menu configuration
Terminal window menu can be composed from scratch by specifying a list of menu items in the `<config/term/menu/>` configuration file section.
Terminal window menu can be composed from scratch by specifying a list of menu items in the `<config/terminal/menu/>` configuration file section.

### Attributes for the `<config/term/menu/item>` object
### Attributes for the `<config/terminal/menu/item>` object

Attribute | Description
-----------|------------
Expand All @@ -79,7 +79,7 @@ tooltip | Tooltip text.
action | The function name which called on item activation. Inherited by the label attribute.
data | Textual parameter for function call. Inherited by the label attribute.

### Attributes for the `<config/term/menu/item/label>` sub-object
### Attributes for the `<config/terminal/menu/item/label>` sub-object

Attribute | Description
-----------------|------------
Expand All @@ -105,7 +105,7 @@ Value | Arguments (`data=`) | Description
Noop | | Ignore all events for the specified key combination. No further processing.
DropAutoRepeat | | Ignore `Key Repeat` events for the specified key combination. This binding should be specified before the main action for the key combination.
SwitchHotkeyScheme | _`Scheme name`_ | Switch the hotkey scheme to the specified one.
TerminalCwdSync | | Current working directory sync toggle. The command to send for synchronization is configurable via the `<config><term cwdsync=" cd $P\n"/></config>` setting's option. Where `$P` is a variable containing current path received via OSC 9;9 notification. <br>To enable OSC9;9 shell notifications:<br>- Windows Command Prompt:<br> `setx PROMPT $e]9;9;$P$e\$P$G`<br>- PowerShell:<br> `function prompt{ $e=[char]27; "$e]9;9;$(Convert-Path $pwd)$e\PS $pwd$('>' * ($nestedPromptLevel + 1)) " }`<br>- Bash:<br> `export PS1='\[\033]9;9;\w\033\\\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '`
TerminalCwdSync | | Current working directory sync toggle. The command to send for synchronization is configurable via the `<config><terminal cwdsync=" cd $P\n"/></config>` setting's option. Where `$P` is a variable containing current path received via OSC 9;9 notification. <br>To enable OSC9;9 shell notifications:<br>- Windows Command Prompt:<br> `setx PROMPT $e]9;9;$P$e\$P$G`<br>- PowerShell:<br> `function prompt{ $e=[char]27; "$e]9;9;$(Convert-Path $pwd)$e\PS $pwd$('>' * ($nestedPromptLevel + 1)) " }`<br>- Bash:<br> `export PS1='\[\033]9;9;\w\033\\\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '`
TerminalWrapMode | `on` \| `off` | Set terminal scrollback lines wrapping mode. Applied to the active selection if it is.
TerminalAlignMode | `left` \| `right` \| `center` | Set terminal scrollback lines aligning mode. Applied to the active selection if it is.
TerminalFindNext | | Highlight next match of selected text fragment. Clipboard content is used if no active selection.
Expand Down Expand Up @@ -174,7 +174,7 @@ Hotkey | Description
#### Terminal configuration example
```xml
<config>
<term>
<terminal>
<menu item*>
<item label="<" action=TerminalFindPrev> <!-- type=Command is a default item's attribute. -->
<label="\e[38:2:0:255:0m<\e[m"/>
Expand Down Expand Up @@ -304,14 +304,14 @@ Hotkey | Description
</tooltip>
</item>
</menu>
</term>
</terminal>
<hotkeys> <!-- The required key combination sequence can be generated on the Info page, accessible by clicking on the label in the lower right corner of the vtm desktop. -->
<tui key*> <!-- TUI matrix layer key bindings. -->
<key="Space-Backspace | Backspace-Space" action=ToggleDebugOverlay/> <!-- Toggle debug overlay. -->
<key="Ctrl-Alt | Alt-Ctrl" scheme=""><action=SwitchHotkeyScheme data="1"/></key> <!-- Switch the hotkey scheme to "1" by pressing and releasing Ctrl-Alt or Alt-Ctrl (reversed release order). -->
<key="Ctrl-Alt | Alt-Ctrl" scheme="1"><action=SwitchHotkeyScheme data=""/></key> <!-- Switch the hotkey scheme to default by pressing and releasing Ctrl-Alt or Alt-Ctrl (reversed release order). -->
</tui>
<term key*>
<terminal key*>
<key="Alt+RightArrow" action=TerminalFindNext/> <!-- Highlight next match of selected text fragment. Clipboard content is used if no active selection. -->
<key="Alt+LeftArrow" action=TerminalFindPrev/> <!-- Highlight previous match of selected text fragment. Clipboard content is used if no active selection. -->
<key="Shift+Ctrl+PageUp" ><action=TerminalScrollViewportByPage data=" 0, 1"/></key> <!-- Scroll viewport one page up. -->
Expand Down Expand Up @@ -339,7 +339,7 @@ Hotkey | Description
<key="" action=TerminalClipboardFormat/> <!-- Switch terminal text selection copy format. -->
<key="" action=TerminalUndo/> <!-- (Win32 Cooked/ENABLE_LINE_INPUT mode only) Discard the last input. -->
<key="" action=TerminalRedo/> <!-- (Win32 Cooked/ENABLE_LINE_INPUT mode only) Discard the last Undo command. -->
<key="" action=TerminalCwdSync/> <!-- Toggle the current working directory sync mode. The command to send for synchronization is configurable via the `<config><term cwdsync=" cd $P\n"/></config>` setting's option. Where `$P` is a variable containing current path received via OSC 9;9 notification. To enable OSC9;9 shell notifications: - Windows Command Prompt: `setx PROMPT $e]9;9;$P$e\$P$G` - PowerShell: `function prompt{ $e=[char]27; "$e]9;9;$(Convert-Path $pwd)$e\PS $pwd$('>' * ($nestedPromptLevel + 1)) " }` - Bash: `export PS1='\[\033]9;9;\w\033\\\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '` -->
<key="" action=TerminalCwdSync/> <!-- Toggle the current working directory sync mode. The command to send for synchronization is configurable via the `<config><terminal cwdsync=" cd $P\n"/></config>` setting's option. Where `$P` is a variable containing current path received via OSC 9;9 notification. To enable OSC9;9 shell notifications: - Windows Command Prompt: `setx PROMPT $e]9;9;$P$e\$P$G` - PowerShell: `function prompt{ $e=[char]27; "$e]9;9;$(Convert-Path $pwd)$e\PS $pwd$('>' * ($nestedPromptLevel + 1)) " }` - Bash: `export PS1='\[\033]9;9;\w\033\\\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '` -->
<key="" action=TerminalWrapMode/> <!-- Toggle terminal scrollback lines wrapping mode. Applied to the active selection if it is. The argument is boolean. -->
<key="" action=TerminalFullscreen/> <!-- Toggle fullscreen mode. -->
<key="" action=TerminalMaximize/> <!-- Toggle between maximized and normal window size. -->
Expand All @@ -350,7 +350,7 @@ Hotkey | Description
<key="" action=TerminalSelectionRect/> <!-- Toggle between linear(0) and rectangular(1) selection form. -->
<key="Esc" action=TerminalSelectionCancel/> <!-- Deselect a selection. -->
<key="" action=TerminalSelectionOneShot/> <!-- One-shot toggle to copy text while mouse tracking is active. Keep selection if 'Ctrl' key is pressed. -->
</term>
</terminal>
</hotkeys>
</config>
```
Expand Down
4 changes: 2 additions & 2 deletions doc/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,8 @@ echo "vtm.del()" | vtm
```
# Add new menu items
echo "vtm.set(id=Term label='Terminal' type=dtvt cmd='vtm -r term')" | vtm
echo "vtm.set(id=White label='White Terminal' type=dtvt cmd='vtm -r term' cfg='<config><term><colors><default fgc=0xFF000000 bgc=0xFFffffff/></colors></term></config>')" | vtm
echo "vtm.set(id=Huge label='Huge Terminal' type=dtvt cmd='vtm -r term' cfg='<config><term><scrollback size=500000/></term></config>')" | vtm
echo "vtm.set(id=White label='White Terminal' type=dtvt cmd='vtm -r term' cfg='<config><terminal><colors><default fgc=0xFF000000 bgc=0xFFffffff/></colors></terminal></config>')" | vtm
echo "vtm.set(id=Huge label='Huge Terminal' type=dtvt cmd='vtm -r term' cfg='<config><terminal><scrollback size=500000/></terminal></config>')" | vtm
echo "vtm.set(id=Tile label='Three Terminals' type=tile cmd='v(h(Term, White), Huge)')" | vtm
echo "vtm.set(id=cmd label='Remote cmd over SSH' type=dtty cmd='ssh user@server vtm cmd')" | vtm
```
Expand Down
4 changes: 2 additions & 2 deletions doc/command-line-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ Option | Description
The plain xml-data could be specified in place of `<file>` in `--config <file>` option:
- `command-line`:
```cmd
vtm -c "<config><term><scrollback size=1000000/></term></config>" -r term
vtm -c "<config><terminal><scrollback size=1000000/></terminal></config>" -r term
```
or (using compact syntax)
- `command-line`:
```cmd
vtm -c "<config/term/scrollback size=1000000/>" -r term
vtm -c "<config/terminal/scrollback size=1000000/>" -r term
```

### Desktop Applets
Expand Down
27 changes: 13 additions & 14 deletions doc/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ The following declarations have the same meaning:
</taskbar>
... <!-- Set of additional desktop settings. -->
</desktop>
<term ... > <!-- Built-in terminal configuration section. -->
<terminal ... > <!-- Built-in terminal configuration section. -->
...
</term>
</terminal>
<hotkeys> <!-- The required key combination sequence can be generated on the Info page, accessible by clicking on the label in the lower right corner of the vtm desktop. -->
<gui> <!-- Native GUI window layer key bindings. -->
<key="Key+Chord">
Expand All @@ -251,12 +251,12 @@ The following declarations have the same meaning:
</key>
...
</desktop>
<term> <!-- Application specific layer key bindings. -->
<terminal> <!-- Application specific layer key bindings. -->
<key="Key+Chord">
<action="ActionName" data="parameter"/>
</key>
...
</term>
</terminal>
</hotkeys>
</config>
```
Expand Down Expand Up @@ -599,22 +599,22 @@ Notes
" RightClick to set as default "
</tooltip>
<config> <!-- The following config partially overrides the base configuration. It is valid for DirectVT apps only. -->
<term>
<terminal>
<scrollback>
<size=40000/> <!-- Scrollback buffer length. -->
<wrap=on/> <!-- Lines wrapping mode. -->
</scrollback>
<selection>
<mode=/config/set/selection/mode/> <!-- Clipboard copy format: "text" | "ansi" | "rich" | "html" | "protected" | "none" . -->
</selection>
</term>
</terminal>
</config>
</item>
<item id="Tile" label="Tile" type="tile" title="Tiling Window Manager" cmd="h1:1(Term, Term)" tooltip=" Tiling Window Manager \n LeftClick to launch instance \n RightClick to set as default "/>
<item id="Site" label="Site" type="site" title="\e[11:3pSite " cmd="@" winform="maximized" tooltip=" Desktop Region Marker \n LeftClick to launch instance \n RightClick to set as default "/> <!-- "\e[11:3p" for center alignment, cmd="@" for instance numbering -->
<item id="Logs" label="Logs" type="dtvt" title="Logs" cmd="$0 -q -r term $0 -m" tooltip=" Log Monitor \n LeftClick to launch instance \n RightClick to set as default ">
<config>
<term>
<terminal>
<scrollback>
<size=5000/>
<wrap="off"/>
Expand Down Expand Up @@ -668,7 +668,7 @@ Notes
</item>
<item label="Reset" tooltip=" Clear scrollback and SGR-attributes " action=TerminalOutput data="\e[!p"/>
</menu>
</term>
</terminal>
</config>
</item>
<autorun item*> <!-- Autorun specified menu items: -->
Expand Down Expand Up @@ -707,7 +707,7 @@ Notes
<offset=2,1/> <!-- 2D offset relative to the window (in cells). Default is "2,1". -->
</shadow>
</desktop>
<term> <!-- Base settings for the Term app. It can be partially overridden by the menu item's config subarg. -->
<terminal> <!-- Base settings for the built-in terminal. It can be partially overridden by the menu item's config subarg. -->
<sendinput=""/> <!-- Send input on startup. E.g. sendinput="echo \"test\"\n" -->
<cwdsync=" cd $P\n"/> <!-- Command to sync the current working directory. When 'Sync' is active, $P (case sensitive) will be replaced with the current path received via OSC9;9 notification. Prefixed with a space to avoid touching command history. -->
<scrollback>
Expand Down Expand Up @@ -774,8 +774,7 @@ Notes
" Left+RightClick to clear clipboard "
</tooltip>
</item>
<item type="Command" action=SwitchHotkeyScheme>
<label=" Keys0 " data=""/>
<item type="Option" action=SwitchHotkeyScheme label=" Keys0 " data="">
<label="\e[48:2:0:128:128;38:2:0:255:0m Keys1 \e[m" data="1"/>
<tooltip>
" Toggle hotkey scheme \n"
Expand Down Expand Up @@ -827,7 +826,7 @@ Notes
close: Always close.
restart: Restart session.
retry: Restart session if exit code != 0. -->
</term>
</terminal>
<defapp>
<menu>
<autohide=menu/autohide/> <!-- Link to global <config/set/menu/autohide>. -->
Expand Down Expand Up @@ -871,7 +870,7 @@ Notes
<key="F10" action=TryToQuit/> <!-- Shut down the desktop server if no applications are running. -->
<key="Alt+Shift+N" action=RunApplication/> <!-- Run default application. -->
</desktop>
<term key*> <!-- Application specific layer key bindings. -->
<terminal key*> <!-- Application specific layer key bindings. -->
<key="Alt+RightArrow" action=TerminalFindNext/> <!-- Highlight next match of selected text fragment. Clipboard content is used if no active selection. -->
<key="Alt+LeftArrow" action=TerminalFindPrev/> <!-- Highlight previous match of selected text fragment. Clipboard content is used if no active selection. -->
<key="Shift+Ctrl+PageUp" ><action=TerminalScrollViewportByPage data=" 0, 1"/></key> <!-- Scroll viewport one page up. -->
Expand Down Expand Up @@ -911,7 +910,7 @@ Notes
<key="" action=TerminalStdioLog/> <!-- Toggle stdin/stdout logging. -->
<key="" action=TerminalRestart/> <!-- Terminate runnning console apps and restart current session. -->
<key="" action=TerminalQuit/> <!-- Terminate runnning console apps and close terminal. -->
</term>
</terminal>
</hotkeys>
</config>
```
2 changes: 1 addition & 1 deletion src/netxs/apps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ namespace netxs::app::shared
->active(window_clr);
auto dtvt = ui::dtvt::ctor();
auto scrl = term->attach(ui::rail::ctor());
auto defclr = config.take("/config/term/colors/default", cell{}.fgc(whitelt).bgc(blackdk));
auto defclr = config.take("/config/terminal/colors/default", cell{}.fgc(whitelt).bgc(blackdk));
auto inst = scrl->attach(ui::term::ctor(config))
->plugin<pro::focus>(pro::focus::mode::focused)
->colors(defclr.fgc(), defclr.bgc())
Expand Down
10 changes: 5 additions & 5 deletions src/netxs/apps/term.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ namespace netxs::app::terminal

namespace attr
{
static constexpr auto cwdsync = "/config/term/cwdsync";
static constexpr auto borders = "/config/term/border";
static constexpr auto menuitems = "/config/term/menu/item";
static constexpr auto cwdsync = "/config/terminal/cwdsync";
static constexpr auto borders = "/config/terminal/border";
static constexpr auto menuitems = "/config/terminal/menu/item";
}

using events = netxs::events::userland::terminal;
Expand Down Expand Up @@ -642,7 +642,7 @@ namespace netxs::app::terminal
};
list.push_back({ item, setup });
}
config.cd("/config/term", "/config/defapp");
config.cd("/config/terminal", "/config/defapp");
return menu::create(config, list);
}
}
Expand Down Expand Up @@ -760,7 +760,7 @@ namespace netxs::app::terminal
window//->plugin<pro::track>()
//->plugin<pro::acryl>()
->plugin<pro::cache>();
auto defclr = config.take("/config/term/colors/default", cell{}.fgc(whitelt).bgc(blackdk));
auto defclr = config.take("/config/terminal/colors/default", cell{}.fgc(whitelt).bgc(blackdk));
auto layers = window->attach(ui::cake::ctor())
->colors(window_clr)
->limits(dot_11);
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.99.51";
static const auto version = "v0.9.99.52";
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
14 changes: 11 additions & 3 deletions src/netxs/desktopio/console.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ namespace netxs::ui
pipe& canal; // link: Data highway.
gate& owner; // link: Link owner.
flag alive; // link: sysclose isn't sent.
wptr owner_wptr; // link: .

// link: Send data outside.
void run()
Expand All @@ -134,20 +135,27 @@ namespace netxs::ui
canal{ canal },
owner{ owner },
alive{ true }
{ }
{
auto oneshot = ptr::shared(hook{});
owner.LISTEN(tier::anycast, e2::form::upon::started, root, *oneshot, (oneshot))
{
owner_wptr = owner.This();
oneshot->reset();
};
}

// link: Send an event message to the link owner.
template<class E, class T>
void notify(E, T&& data, si32 Tier = tier::release)
{
owner.bell::enqueue(owner.This(), [Tier, d = data](auto& boss) mutable
owner.bell::enqueue(owner_wptr, [Tier, d = data](auto& boss) mutable
{
boss.bell::signal(Tier, E::id, d);
});
}
void handle(s11n::xs::req_input_fields lock)
{
owner.bell::enqueue(owner.This(), [&, item = lock.thing](auto& /*boss*/) mutable
owner.bell::enqueue(owner_wptr, [&, item = lock.thing](auto& /*boss*/) mutable
{
auto ext_gear_id = item.gear_id;
auto int_gear_id = owner.get_int_gear_id(ext_gear_id);
Expand Down
Loading

0 comments on commit 57cba57

Please sign in to comment.