From e3f212119c5e8904953073278b3a7152a69852cc Mon Sep 17 00:00:00 2001 From: niksedk Date: Wed, 5 Aug 2026 06:05:53 +0200 Subject: [PATCH] Group the Source view status numbers and answer the help shortcut A source file runs to tens of thousands of lines and characters, so the line, column, selection and subtitle counts in the status line are only readable with thousand separators - grouped in the current culture, as the statistics window already does. The window also answers the configured help shortcut (F1 by default) and opens the Source view help page, which every other dialog already did. Co-Authored-By: Claude Opus 5 --- docs/features/source-view.md | 2 ++ .../Shared/SourceView/SourceViewViewModel.cs | 34 +++++++++++++++---- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/docs/features/source-view.md b/docs/features/source-view.md index fb7f59cf02..5d67ccc198 100644 --- a/docs/features/source-view.md +++ b/docs/features/source-view.md @@ -58,6 +58,8 @@ On macOS, use Cmd where Ctrl is shown, and Option+Backspace / Option+Delete for The same commands — plus find, replace and go to line — are in the editor's right-click menu. +**F1** opens this help page. + ## See also - [Edit Menu](edit.md) — find and replace across subtitle lines rather than raw source diff --git a/src/ui/Features/Shared/SourceView/SourceViewViewModel.cs b/src/ui/Features/Shared/SourceView/SourceViewViewModel.cs index a32c50a3c3..2a593f41fe 100644 --- a/src/ui/Features/Shared/SourceView/SourceViewViewModel.cs +++ b/src/ui/Features/Shared/SourceView/SourceViewViewModel.cs @@ -14,6 +14,7 @@ using Nikse.SubtitleEdit.Logic; using Nikse.SubtitleEdit.Logic.Config; using System; +using System.Globalization; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -220,7 +221,10 @@ private void UpdateCaretInfo() var document = _editor.Document; var position = document.GetPosition(_editor.CaretOffset); - LineAndColumnInfo = string.Format(Se.Language.General.LineXColumnY, position.Line + 1, position.Column + 1); + LineAndColumnInfo = string.Format( + Se.Language.General.LineXColumnY, + Grouped(position.Line + 1), + Grouped(position.Column + 1)); var selectionLength = _editor.SelectionLength; if (selectionLength == 0) @@ -233,10 +237,16 @@ private void UpdateCaretInfo() var lastLine = document.GetPosition(_editor.SelectionStart + selectionLength).Line; SelectionInfo = string.Format( Se.Language.SourceView.SelectedXCharactersYLines, - selectionLength, - lastLine - firstLine + 1); + Grouped(selectionLength), + Grouped(lastLine - firstLine + 1)); } + /// + /// A source file runs to tens of thousands of lines and characters, so the status line counts + /// are only readable with thousand separators. + /// + private static string Grouped(int value) => value.ToString("#,##0", CultureInfo.CurrentCulture); + private void ValidationTimerTick(object? sender, EventArgs e) { _validationTimer.Stop(); @@ -260,7 +270,7 @@ internal void Validate() if (source.Length > MaxValidationTextLength) { IsValidationError = false; - ValidationInfo = string.Format(Se.Language.SourceView.XLinesYSubtitles, lineCount, "?"); + ValidationInfo = string.Format(Se.Language.SourceView.XLinesYSubtitles, Grouped(lineCount), "?"); return; } @@ -293,8 +303,12 @@ internal void Validate() var errorCount = _subtitleFormat.ErrorCount; IsValidationError = errorCount > 0; ValidationInfo = errorCount > 0 - ? string.Format(Se.Language.SourceView.XLinesYSubtitlesZErrors, lineCount, subtitle.Paragraphs.Count, errorCount) - : string.Format(Se.Language.SourceView.XLinesYSubtitles, lineCount, subtitle.Paragraphs.Count); + ? string.Format( + Se.Language.SourceView.XLinesYSubtitlesZErrors, + Grouped(lineCount), + Grouped(subtitle.Paragraphs.Count), + Grouped(errorCount)) + : string.Format(Se.Language.SourceView.XLinesYSubtitles, Grouped(lineCount), Grouped(subtitle.Paragraphs.Count)); } // ---------------------------------------------------------------------------------------- @@ -692,6 +706,14 @@ internal void OnKeyDown(object? sender, KeyEventArgs e) : (e.KeyModifiers & KeyModifiers.Control) != 0; var shift = (e.KeyModifiers & KeyModifiers.Shift) != 0; + // Help is user-configurable, so it cannot be a case in the switch below. + if (UiUtil.IsHelp(e)) + { + e.Handled = true; + UiUtil.ShowHelp("features/source-view"); + return; + } + switch (e.Key) { case Key.Escape: