feat: add Show script trace in terminal setting
Settings -> Terminal gains a 'Show script trace in terminal' checkbox (AppSettings.ShowScriptTrace, default on). When off, TTL trace lines ([wait] progress, sent-command echo, errors) are no longer drawn in the terminal. dispstr moves to a dedicated Display event and always shows, since it is the script explicitly printing something. Trace was already display-only (never written to session logs, the AI serial bridge, or the device) - docs now state this explicitly. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -189,7 +189,7 @@ public sealed class AboutView : UserControl
|
||||
"New Settings → Highlight page: add your own keywords (like ERROR or FAIL) and they light up in red wherever they appear.",
|
||||
"When a keyword shows up in a tab you're not looking at, that tab's dot turns red so you don't miss it.",
|
||||
"TTL scripting grew from ~15 commands to 90+, matching Tera Term macros: loops (for / do / until), goto and subroutines, waitln / waitregex with regex capture, string and file operations, input dialogs, and serial line control (sendbreak, setbaud).",
|
||||
"Scripts now show their progress in gray right inside the terminal, so you can watch what they're doing.",
|
||||
"Scripts now show their progress in gray right inside the terminal — display only, never written to session logs; turn it off in Settings → Terminal (Show script trace) if you want a clean screen.",
|
||||
"See the full command table with examples in docs/ttl-script-reference.md.",
|
||||
]),
|
||||
new("0.4.0", new DateOnly(2026, 7, 2), "Performance & stability overhaul",
|
||||
|
||||
@@ -94,6 +94,14 @@ public sealed class SettingsView : UserControl
|
||||
flow.Controls.Add(MakeRow("Scrollback Lines", scrollback));
|
||||
flow.Controls.Add(MakeRow("Color Scheme", scheme));
|
||||
flow.Controls.Add(MakeRow("Default Newline", newline));
|
||||
|
||||
var scriptTrace = new CheckBox
|
||||
{
|
||||
Text = "Show script trace in terminal ([wait] / sent commands / errors in gray; dispstr always shows)",
|
||||
Checked = s.ShowScriptTrace, AutoSize = true,
|
||||
ForeColor = Theme.Text, Font = Theme.UiFont, Margin = new Padding(0, 6, 0, 0)
|
||||
};
|
||||
flow.Controls.Add(scriptTrace);
|
||||
flow.Controls.Add(MakeSpacer(16));
|
||||
|
||||
// Shell settings
|
||||
@@ -161,6 +169,7 @@ public sealed class SettingsView : UserControl
|
||||
s.ScrollbackLines = (int)scrollback.Value;
|
||||
s.ColorScheme = scheme.Text;
|
||||
s.DefaultNewLine = newline.Text;
|
||||
s.ShowScriptTrace = scriptTrace.Checked;
|
||||
s.ShellType = shellType.Text;
|
||||
s.ShellStartupDir = shellDir.Text;
|
||||
s.Save();
|
||||
|
||||
@@ -22,6 +22,9 @@ public sealed class AppSettings
|
||||
public int ScrollbackLines { get; set; } = 5000;
|
||||
public string DefaultNewLine { get; set; } = "\\r\\n";
|
||||
public string ColorScheme { get; set; } = "Dark";
|
||||
/// <summary>TTL 腳本執行時,[wait] / >> 送出回顯 / 錯誤等 trace 是否以灰色顯示在終端機
|
||||
/// (只影響畫面;本來就不會寫進側錄 log。dispstr 一律顯示,不受此開關影響)。</summary>
|
||||
public bool ShowScriptTrace { get; set; } = true;
|
||||
|
||||
// ── Shell ──
|
||||
public string ShellType { get; set; } = "PowerShell"; // PowerShell, Bash, Cmd
|
||||
|
||||
@@ -14,9 +14,12 @@ public sealed class ScriptRunner
|
||||
/// <summary>(檔名, 行號, 指令) 進度。</summary>
|
||||
public event Action<string, int, string>? StatusChanged;
|
||||
|
||||
/// <summary>輸出訊息(log / 提示 / 錯誤)。</summary>
|
||||
/// <summary>trace 訊息([wait] 進度 / >> 送出回顯 / 錯誤);顯示與否由 UI 依設定決定。</summary>
|
||||
public event Action<string>? Output;
|
||||
|
||||
/// <summary>dispstr 的顯示輸出(一律顯示)。</summary>
|
||||
public event Action<string>? Display;
|
||||
|
||||
/// <summary>結束:(成功, 訊息)。</summary>
|
||||
public event Action<bool, string>? Finished;
|
||||
|
||||
@@ -37,6 +40,7 @@ public sealed class ScriptRunner
|
||||
var interp = new TTLInterpreter(channel, sync, memberLabel);
|
||||
interp.StatusChanged += (f, l, c) => StatusChanged?.Invoke(f, l, c);
|
||||
interp.Output += m => Output?.Invoke(m);
|
||||
interp.Display += m => Display?.Invoke(m);
|
||||
_interp = interp;
|
||||
|
||||
try
|
||||
|
||||
@@ -56,9 +56,13 @@ public sealed class TTLInterpreter : IDisposable
|
||||
/// <summary>(檔名, 行號, 當前指令) 進度更新。</summary>
|
||||
public event Action<string, int, string>? StatusChanged;
|
||||
|
||||
/// <summary>輸出訊息(log / 提示 / 錯誤 / dispstr),供 UI 顯示。</summary>
|
||||
/// <summary>trace 訊息([wait] 進度 / >> 送出回顯 / 錯誤),供 UI 顯示;
|
||||
/// 可由 Settings 的 Show script trace 開關關閉顯示。</summary>
|
||||
public event Action<string>? Output;
|
||||
|
||||
/// <summary>dispstr 的顯示輸出:腳本明確要顯示的內容,一律顯示(不受 trace 開關影響)。</summary>
|
||||
public event Action<string>? Display;
|
||||
|
||||
public TTLInterpreter(ISessionChannel channel, GroupSyncContext? groupSync = null, string memberLabel = "")
|
||||
{
|
||||
_channel = channel ?? throw new ArgumentNullException(nameof(channel));
|
||||
@@ -1065,7 +1069,7 @@ public sealed class TTLInterpreter : IDisposable
|
||||
var t = TokenizeArgs(args);
|
||||
var sb = new StringBuilder();
|
||||
foreach (var tok in t) sb.Append(ValS(tok));
|
||||
Output?.Invoke(sb.ToString());
|
||||
Display?.Invoke(sb.ToString());
|
||||
}
|
||||
|
||||
private void SendFile(string args)
|
||||
|
||||
@@ -100,8 +100,15 @@ public sealed class SessionPage : UserControl
|
||||
|
||||
_runner.StatusChanged += (_, line, cmd) => Ui(() => _status.Text = $"line {line}: {Trunc(cmd)}");
|
||||
_runner.Finished += (_, msg) => Ui(() => { _status.Text = msg; SetRunning(false); });
|
||||
// 腳本輸出(dispstr / [wait] 進度 / 錯誤)以灰色 echo 到終端機,執行過程看得見
|
||||
_runner.Output += m => Ui(() =>
|
||||
// 腳本 trace([wait] 進度 / >> 送出回顯 / 錯誤)以灰色 echo 到終端機;
|
||||
// 可由 Settings → Terminal 的 Show script trace 關閉。只影響畫面,不會進側錄 log。
|
||||
_runner.Output += m =>
|
||||
{
|
||||
if (!AppSettings.Instance.ShowScriptTrace) return;
|
||||
Ui(() => _term.Feed(System.Text.Encoding.UTF8.GetBytes($"\x1b[90m{m}\x1b[0m\r\n")));
|
||||
};
|
||||
// dispstr 是腳本明確要顯示的內容,一律顯示(不受開關影響)
|
||||
_runner.Display += m => Ui(() =>
|
||||
_term.Feed(System.Text.Encoding.UTF8.GetBytes($"\x1b[90m{m}\x1b[0m\r\n")));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user