Files
DodoSSH/tests/DodoSSH.Client.Terminal.Tests/OutputTailTests.cs
jaap-jan 367cebae9b
ci / build and test (push) Successful in 4m52s
ci / desktop nightly (push) Failing after 58s
ci / android head (push) Successful in 5m59s
ci / api image (push) Successful in 8s
Android: a customisable key bar, a quick-access keyboard, a long-press cursor gesture, and a side panel on tablets
The key bar above the software keyboard is now the user's own: which keys, in what order, up to sixteen
in two rows that never scroll. Ctrl and Alt latch across the bar and the phone's keyboard, and Ctrl or Alt
with a cursor key sends the modified CSI form. Seven predefined groups (essentials, cursor, control,
symbols, tmux, vim, function) and keys of one's own, written in \e / ^C notation, are arranged on a
customise sheet that saves as it goes.

A grid button swaps the software keyboard for a quick-access keyboard of the same height, with KEYS,
SNIPPETS, HISTORY and APPEARANCE tabs; it reopens to the tab last used. Snippets go through the shell's
existing InsertSnippet. History keeps a typed command only once the remote has echoed it, so nothing
typed at a password prompt is ever recorded; it is memory-only and LOCK clears it. Each session pump now
keeps its last kilobyte of output and the alternate-screen state for that test (OutputTail).

Long-press and drag on the terminal sends arrow keys, as a joystick with three speeds by distance;
scrolling is unchanged and there is no mode switch. It takes the touch before Chromium's own long press,
so a held finger no longer pastes; paste is on the bar by default instead. A switch in APPEARANCE turns
the gesture off. The text-size buttons moved from the bar to APPEARANCE.

On wide screens the same tabs open as a side panel beside the terminal, toggled from the top bar, with
the bar's own keys repeated at the top of KEYS while the bar stands down.

The model, gesture arithmetic, echo reading and history are in DodoSSH.Client.Shell and covered by
TerminalKeyboardTests and OutputTailTests. Builds clean; not yet exercised on a device, because the
emulator's install is locked behind a passphrase that was not recorded.
2026-10-03 14:29:22 +02:00

82 lines
2.2 KiB
C#

using System.Text;
namespace DodoSSH.Client.Terminal.Tests;
/// <summary>
/// That a session keeps the last of its output for the phone's history to read back, and knows when a
/// full-screen program has it.
/// </summary>
public sealed class OutputTailTests
{
private static byte[] Ascii(string text) => Encoding.ASCII.GetBytes(text);
[Fact]
public void WhatIsHeld_IsTheLastKilobyte_InOrder()
{
var tail = new OutputTail();
tail.Append(Ascii(new string('a', OutputTail.Capacity)));
tail.Append(Ascii("stan@box:~$ ls"));
var held = Encoding.ASCII.GetString(tail.Snapshot().Tail);
held.Length.ShouldBe(OutputTail.Capacity);
held.ShouldEndWith("aaastan@box:~$ ls");
}
[Fact]
public void AReadLargerThanTheTail_KeepsItsEnd()
{
var tail = new OutputTail();
tail.Append(Ascii(new string('x', 5000) + "the end"));
Encoding.ASCII.GetString(tail.Snapshot().Tail).ShouldEndWith("xthe end");
}
[Fact]
public void TheAlternateScreen_IsOnBetweenItsTwoSwitches()
{
var tail = new OutputTail();
tail.Append(Ascii("$ vi notes\r\n\x1b[?1049h\x1b[H~\r\n~"));
tail.Snapshot().AlternateScreen.ShouldBeTrue();
tail.Append(Ascii("\x1b[?1049l$ "));
tail.Snapshot().AlternateScreen.ShouldBeFalse();
}
[Fact]
public void ASwitchSplitAcrossTwoReads_IsStillSeen()
{
var tail = new OutputTail();
tail.Append(Ascii("$ less log\r\n\x1b[?10"));
tail.Append(Ascii("49h"));
tail.Snapshot().AlternateScreen.ShouldBeTrue();
}
[Fact]
public void ASwitchAtTheStartOfAHugeRead_IsNotLostWithTheBytesThatFallOffTheTail()
{
var tail = new OutputTail();
// A full-screen program's first frame: the switch, and then a screenful of paint.
tail.Append(Ascii("\x1b[?1049h" + new string('#', 60_000)));
tail.Snapshot().AlternateScreen.ShouldBeTrue();
}
[Fact]
public void OtherPrivateModes_AreNotTheAlternateScreen()
{
var tail = new OutputTail();
// Bracketed paste and cursor visibility, which every prompt sends.
tail.Append(Ascii("\x1b[?2004h\x1b[?25h$ "));
tail.Snapshot().AlternateScreen.ShouldBeFalse();
}
}