«Aggiungi account» ha una sola casella: mentre Alberto scrive compaiono subito i suggerimenti locali, poi i profili di Instagram con la foto, come chiesto in #37. Il browser di Febe scrive nella casella «Cerca» di Instagram con tasti veri da una mappa chiusa (mai Invio, Tab o Esc), controlla prima il fuoco, legge la risposta della pagina e non clicca mai un risultato. La ricerca ha una categoria propria nel Governatore, con tetti larghi che non consumano quelli della raccolta, e si dà il turno con il motore sull'unica pagina; a fine sessione la pagina torna comunque al riposo. Le foto passano dal CDN con un permesso ciascuna e restano solo in memoria. Le risposte di Alberto del 15 novembre (controllo del fuoco, turni, evento requestWillBeSent, niente foto dei seguiti per ora) sono in §6.1 e in docs/decisioni.md. Su Instagram vero la ricerca parte quando i bersagli search-open e search-box saranno raccolti dal vivo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
55 lines
2.7 KiB
C#
55 lines
2.7 KiB
C#
using System.Text;
|
|
|
|
namespace Febe.Core.Collection.Recipes;
|
|
|
|
/// <summary>
|
|
/// What the focus check of the site's search box says (issue #37). Never the text: only whether the box is on the
|
|
/// page, whether the focus is in it, how many characters it holds and whether the caret is at the end.
|
|
/// </summary>
|
|
/// <param name="BoxFound">The search box is on the page and visible.</param>
|
|
/// <param name="Focused">The focus is in the box.</param>
|
|
/// <param name="Length">Characters in the box, only when the focus is in it (null otherwise).</param>
|
|
/// <param name="CaretAtEnd">The caret is at the end of the text, with nothing selected.</param>
|
|
public sealed record SearchFocus(bool BoxFound, bool Focused, int? Length, bool CaretAtEnd)
|
|
{
|
|
/// <summary>No box on the page.</summary>
|
|
public static SearchFocus None { get; } = new(false, false, null, false);
|
|
|
|
/// <summary>The box has the focus and the caret is at the end: keys go where Febe wants them.</summary>
|
|
public bool Ready => BoxFound && Focused && Length is not null && CaretAtEnd;
|
|
|
|
private bool PrintMembers(StringBuilder builder)
|
|
{
|
|
builder.Append($"BoxFound = {BoxFound}, Focused = {Focused}, Length = {Length}, CaretAtEnd = {CaretAtEnd}");
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Typing into the site's own search box (issue #37), with <c>Input.dispatchKeyEvent</c> only: letters, digits,
|
|
/// «.», «_» and spaces, Backspace and End, never Enter, Tab or Escape. Separate from <see cref="IPageDriver"/>, which
|
|
/// the recipes use: only the profile search types.
|
|
/// </summary>
|
|
public interface ISearchInput
|
|
{
|
|
/// <summary>The read-only focus check of the search box.</summary>
|
|
Task<SearchFocus> FocusAsync(CancellationToken ct);
|
|
|
|
/// <summary>Presses End: the caret goes to the end of the text.</summary>
|
|
Task EndKeyAsync(CancellationToken ct);
|
|
|
|
/// <summary>
|
|
/// Presses Backspace <paramref name="count"/> times at a human rhythm; <paramref name="beforeKey"/> runs right
|
|
/// before every key (the search notes where the page's requests stand).
|
|
/// </summary>
|
|
Task EraseAsync(int count, Action? beforeKey, CancellationToken ct);
|
|
|
|
/// <summary>
|
|
/// Types the characters <paramref name="next"/> gives, one at a time at a human rhythm, until it returns null.
|
|
/// <paramref name="next"/> receives how many characters were typed so far, and may run its own checks (it is
|
|
/// awaited before every key). Returns how many characters were typed. A character outside the closed key map stops
|
|
/// the burst with <see cref="ArgumentException"/> before its key is sent.
|
|
/// </summary>
|
|
Task<int> TypeAsync(Func<int, CancellationToken, ValueTask<char?>> next, CancellationToken ct);
|
|
}
|