Skip to content

Commit

Permalink
Merge pull request #660 from o-sdn-o/gui-bridge
Browse files Browse the repository at this point in the history
Add hardcoded hotkeys to scroll terminal viewport
  • Loading branch information
o-sdn-o authored Oct 24, 2024
2 parents e3ab71e + efbb25f commit 30b70e6
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 56 deletions.
100 changes: 50 additions & 50 deletions doc/apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,56 +113,56 @@ Repeat | Selects the next label and exec the function specified by the `actio

`*` - Not implemented.

Value | Description
-----------------------------|------------
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\]\$ '`
TerminalWrapMode | Set terminal scrollback lines wrapping mode. Applied to the active selection if it is. The `data=` attribute can have the following values `on`, `off`.
TerminalAlignMode | Set terminal scrollback lines aligning mode. Applied to the active selection if it is. The `data=` attribute can have the following values `left`, `right`, `center`.
TerminalFindNext | Highlight next match of selected text fragment. Clipboard content is used if no active selection.
TerminalFindPrev | Highlight previous match of selected text fragment. Clipboard content is used if no active selection.
TerminalOutput | Direct output the `data=` value to the terminal scrollback.
TerminalSendKey | Simulating keypresses using the `data=` string.
TerminalQuit | Terminate runnning console apps and close terminal.
TerminalRestart | Terminate runnning console apps and restart current session.
TerminalFullscreen | Toggle fullscreen mode.
TerminalUndo | (Win32 Cooked/ENABLE_LINE_INPUT mode only) Discard the last input.
TerminalRedo | (Win32 Cooked/ENABLE_LINE_INPUT mode only) Discard the last Undo command.
TerminalClipboardPaste | Paste from clipboard.
TerminalClipboardWipe | Reset clipboard.
TerminalSelectionMode | Set terminal text selection mode.<br>The `data=` attribute can have the following values `none`, `text`, `ansi`, `rich`, `html`, `protected`.
TerminalSelectionCopy | Сopy selection to clipboard.
TerminalSelectionRect | Set linear(false) or rectangular(true) selection form using boolean value.
TerminalSelectionClear | Deselect a selection.
TerminalSelectionOneShot | One-shot toggle to copy text while mouse tracking is active. Keep selection if `Ctrl` key is pressed.<br>The `data=` attribute can have the following values `none`, `text`, `ansi`, `rich`, `html`, `protected`.
TerminalViewportCopy | Сopy viewport to clipboard.
TerminalViewportPageUp | Scroll one page up.
TerminalViewportPageDown | Scroll one page down.
TerminalViewportLineUp | Scroll N lines up.
TerminalViewportLineDown | Scroll N lines down.
TerminalViewportPageLeft | Scroll one page to the left.
TerminalViewportPageRight | Scroll one page to the right.
TerminalViewportColumnLeft | Scroll N cells to the left.
TerminalViewportColumnRight | Scroll N cells to the right.
TerminalViewportTop | Scroll to the scrollback top.
TerminalViewportEnd | Scroll to the scrollback bottom (reset viewport position).
TerminalStdioLog | Stdin/stdout log toggle.
*TerminalLogStart | Start logging to file.
*TerminalLogPause | Pause logging.
*TerminalLogStop | Stop logging.
*TerminalLogAbort | Abort logging.
*TerminalLogRestart | Restart logging to file.
*TerminalVideoRecStart | Start DirectVT(dtvt) video recording to file.
*TerminalVideoRecStop | Stop dtvt-video recording.
*TerminalVideoRecPause | Pause dtvt-video recording.
*TerminalVideoRecAbort | Abort dtvt-video recording.
*TerminalVideoRecRestart | Restart dtvt-video recording to file.
*TerminalVideoPlay | Play dtvt-video from file.
*TerminalVideoPause | Pause dtvt-video.
*TerminalVideoStop | Stop dtvt-video.
*TerminalVideoForward | Fast forward dtvt-video by N ms.
*TerminalVideoBackward | Rewind dtvt-video by N ms.
*TerminalVideoHome | Rewind dtvt-video to the beginning.
*TerminalVideoEnd | Rewind dtvt-video to the end.
Value | Default Hotkey | Description
-----------------------------|-------------------------|------------
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\]\$ '`
TerminalWrapMode | | Set terminal scrollback lines wrapping mode. Applied to the active selection if it is. The `data=` attribute can have the following values `on`, `off`.
TerminalAlignMode | | Set terminal scrollback lines aligning mode. Applied to the active selection if it is. The `data=` attribute can have the following values `left`, `right`, `center`.
TerminalFindNext | | Highlight next match of selected text fragment. Clipboard content is used if no active selection.
TerminalFindPrev | | Highlight previous match of selected text fragment. Clipboard content is used if no active selection.
TerminalOutput | | Direct output the `data=` value to the terminal scrollback.
TerminalSendKey | | Simulating keypresses using the `data=` string.
TerminalQuit | | Terminate runnning console apps and close terminal.
TerminalRestart | | Terminate runnning console apps and restart current session.
TerminalFullscreen | | Toggle fullscreen mode.
TerminalUndo | | (Win32 Cooked/ENABLE_LINE_INPUT mode only) Discard the last input.
TerminalRedo | | (Win32 Cooked/ENABLE_LINE_INPUT mode only) Discard the last Undo command.
TerminalClipboardPaste | | Paste from clipboard.
TerminalClipboardWipe | | Reset clipboard.
TerminalSelectionMode | | Set terminal text selection mode.<br>The `data=` attribute can have the following values `none`, `text`, `ansi`, `rich`, `html`, `protected`.
TerminalSelectionCopy | | Сopy selection to clipboard.
TerminalSelectionRect | | Set linear(false) or rectangular(true) selection form using boolean value.
TerminalSelectionClear | `Esc` | Deselect a selection.
TerminalSelectionOneShot | | One-shot toggle to copy text while mouse tracking is active. Keep selection if `Ctrl` key is pressed.<br>The `data=` attribute can have the following values `none`, `text`, `ansi`, `rich`, `html`, `protected`.
TerminalViewportCopy | | Сopy viewport to clipboard.
TerminalViewportPageUp | `Shift+PageUp` | Scroll one page up.
TerminalViewportPageDown | `Shift+PageDown` | Scroll one page down.
TerminalViewportLineUp | `Shift+ArrowUp` | Scroll N lines up.
TerminalViewportLineDown | `Shift+ArrowDown` | Scroll N lines down.
TerminalViewportPageLeft | `Shift+Ctrl+ArrowLeft` | Scroll one page to the left.
TerminalViewportPageRight | `Shift+Ctrl+ArrowRight` | Scroll one page to the right.
TerminalViewportColumnLeft | `Shift+ArrowLeft` | Scroll N cells to the left.
TerminalViewportColumnRight | `Shift+ArrowRight` | Scroll N cells to the right.
TerminalViewportTop | `Shift+Home` | Scroll to the scrollback top.
TerminalViewportEnd | `Shift+End` | Scroll to the scrollback bottom (reset viewport position).
TerminalStdioLog | | Stdin/stdout log toggle.
*TerminalLogStart | | Start logging to file.
*TerminalLogPause | | Pause logging.
*TerminalLogStop | | Stop logging.
*TerminalLogAbort | | Abort logging.
*TerminalLogRestart | | Restart logging to file.
*TerminalVideoRecStart | | Start DirectVT(dtvt) video recording to file.
*TerminalVideoRecStop | | Stop dtvt-video recording.
*TerminalVideoRecPause | | Pause dtvt-video recording.
*TerminalVideoRecAbort | | Abort dtvt-video recording.
*TerminalVideoRecRestart | | Restart dtvt-video recording to file.
*TerminalVideoPlay | | Play dtvt-video from file.
*TerminalVideoPause | | Pause dtvt-video.
*TerminalVideoStop | | Stop dtvt-video.
*TerminalVideoForward | | Fast forward dtvt-video by N ms.
*TerminalVideoBackward | | Rewind dtvt-video by N ms.
*TerminalVideoHome | | Rewind dtvt-video to the beginning.
*TerminalVideoEnd | | Rewind dtvt-video to the end.

#### Terminal configuration example
```xml
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.29";
static const auto version = "v0.9.99.30";
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
16 changes: 13 additions & 3 deletions src/netxs/desktopio/baseui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -861,10 +861,20 @@ namespace netxs::ui
// base: Fire an event on yourself and pass it parent if not handled.
// Usage example:
// base::riseup<tier::preview>(e2::form::prop::ui::header, txt);
template<tier Tier, class Event, class T>
void riseup(Event, T&& param, bool forced = faux)
template<tier Tier, class Event>
void riseup(Event, Event::type&& param = {}, bool forced = faux)
{
raw_riseup<Tier>(Event::id, std::forward<T>(param), forced);
raw_riseup<Tier>(Event::id, std::move(param), forced);
}
template<tier Tier, class Event>
void riseup(Event, Event::type& param, bool forced = faux)
{
raw_riseup<Tier>(Event::id, param, forced);
}
template<tier Tier, class Event>
void riseup(Event, Event::type const& param, bool forced = faux)
{
raw_riseup<Tier>(Event::id, param, forced);
}
// base: Syntax sugar helper.
void _saveme()
Expand Down
2 changes: 1 addition & 1 deletion src/netxs/desktopio/input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,7 @@ namespace netxs::input
alive = faux;
if (set_nodbl) nodbl = true;
}
void set_handled(bool b)
void set_handled(bool b = true)
{
handled = b;
}
Expand Down
16 changes: 15 additions & 1 deletion src/netxs/desktopio/terminal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7769,6 +7769,20 @@ namespace netxs::ui
case keybd::type::keypress:
//todo configurable Ctrl+Ins, Shift+Ins etc.
if (gear.handled) return; // Don't pass registered keyboard shortcuts.
if (io_log) log(prompt::key, ansi::hi(input::key::map::data(gear.keycode).name), gear.pressed ? " pressed" : " released");
if (gear.pressed && gear.meta(hids::anyShift))
{
if (gear.keycode == input::key::LeftArrow && gear.meta(hids::anyCtrl)){ base::riseup<tier::preview>(e2::form::upon::scroll::bypage::x, { .vector = dot_10 }); gear.set_handled(); return; }
else if (gear.keycode == input::key::RightArrow && gear.meta(hids::anyCtrl)){ base::riseup<tier::preview>(e2::form::upon::scroll::bypage::x, { .vector = -dot_10 }); gear.set_handled(); return; }
else if (gear.keycode == input::key::LeftArrow ){ base::riseup<tier::preview>(e2::form::upon::scroll::bystep::x, { .vector = { 1, 0 }}); gear.set_handled(); return; }
else if (gear.keycode == input::key::RightArrow ){ base::riseup<tier::preview>(e2::form::upon::scroll::bystep::x, { .vector = {-1, 0 }}); gear.set_handled(); return; }
else if (gear.keycode == input::key::UpArrow ){ base::riseup<tier::preview>(e2::form::upon::scroll::bystep::y, { .vector = { 0, 1 }}); gear.set_handled(); return; }
else if (gear.keycode == input::key::DownArrow ){ base::riseup<tier::preview>(e2::form::upon::scroll::bystep::y, { .vector = { 0,-1 }}); gear.set_handled(); return; }
else if (gear.keycode == input::key::Home ){ base::riseup<tier::preview>(e2::form::upon::scroll::to_top::y); gear.set_handled(); return; }
else if (gear.keycode == input::key::End ){ base::riseup<tier::preview>(e2::form::upon::scroll::to_end::y); gear.set_handled(); return; }
else if (gear.keycode == input::key::PageUp ){ base::riseup<tier::preview>(e2::form::upon::scroll::bypage::y, { .vector = dot_01 }); gear.set_handled(); return; }
else if (gear.keycode == input::key::PageDown ){ base::riseup<tier::preview>(e2::form::upon::scroll::bypage::y, { .vector = -dot_01 }); gear.set_handled(); return; }
}
if (config.resetonkey && gear.doinput())
{
this->RISEUP(tier::release, e2::form::animate::reset, 0); // Reset scroll animation.
Expand All @@ -7780,7 +7794,6 @@ namespace netxs::ui
{
selection_cancel();
}
if (io_log) log(prompt::key, ansi::hi(input::key::map::data(gear.keycode).name), gear.pressed ? " pressed" : " released");
ipccon.keybd(gear, decckm, kbmode);
break;
case keybd::type::imeinput:
Expand Down Expand Up @@ -7813,6 +7826,7 @@ namespace netxs::ui
else unsync = std::exchange(ime_on, imebox.length()) != ime_on;
break;
case keybd::type::kblayout:
//todo
break;
}
};
Expand Down

0 comments on commit 30b70e6

Please sign in to comment.