Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/features/source-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 28 additions & 6 deletions src/ui/Features/Shared/SourceView/SourceViewViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand All @@ -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));
}

/// <summary>
/// A source file runs to tens of thousands of lines and characters, so the status line counts
/// are only readable with thousand separators.
/// </summary>
private static string Grouped(int value) => value.ToString("#,##0", CultureInfo.CurrentCulture);

private void ValidationTimerTick(object? sender, EventArgs e)
{
_validationTimer.Stop();
Expand All @@ -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;
}

Expand Down Expand Up @@ -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));
}

// ----------------------------------------------------------------------------------------
Expand Down Expand Up @@ -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:
Expand Down
Loading