mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-23 11:42:36 +01:00
parent
2f3d3d6d9a
commit
24dec1f230
@ -6417,11 +6417,11 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
if (found)
|
||||
{
|
||||
SelectListViewIndexAndEnsureVisible(_findHelper.SelectedIndex);
|
||||
SelectListViewIndexAndEnsureVisible(_findHelper.SelectedLineIndex);
|
||||
tb.Focus();
|
||||
tb.SelectionStart = _findHelper.SelectedPosition;
|
||||
tb.SelectionLength = _findHelper.FindTextLength;
|
||||
ShowStatus(string.Format(_language.XFoundAtLineNumberY, _findHelper.FindText, _findHelper.SelectedIndex + 1));
|
||||
ShowStatus(string.Format(_language.XFoundAtLineNumberY, _findHelper.FindText, _findHelper.SelectedLineIndex + 1));
|
||||
_findHelper.SelectedPosition++;
|
||||
}
|
||||
else
|
||||
@ -6433,7 +6433,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
if (_findHelper.Find(textBoxSource, textBoxSource.SelectionStart))
|
||||
{
|
||||
textBoxSource.SelectionStart = _findHelper.SelectedIndex;
|
||||
textBoxSource.SelectionStart = _findHelper.SelectedLineIndex;
|
||||
textBoxSource.SelectionLength = _findHelper.FindTextLength;
|
||||
textBoxSource.ScrollToCaret();
|
||||
ShowStatus(string.Format(_language.XFoundAtLineNumberY, _findHelper.FindText, textBoxSource.GetLineFromCharIndex(textBoxSource.SelectionStart)));
|
||||
@ -6500,8 +6500,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
tb = GetFindReplaceTextBox();
|
||||
|
||||
SelectListViewIndexAndEnsureVisible(_findHelper.SelectedIndex);
|
||||
ShowStatus(string.Format(_language.XFoundAtLineNumberY, _findHelper.FindText, _findHelper.SelectedIndex + 1));
|
||||
SelectListViewIndexAndEnsureVisible(_findHelper.SelectedLineIndex);
|
||||
ShowStatus(string.Format(_language.XFoundAtLineNumberY, _findHelper.FindText, _findHelper.SelectedLineIndex + 1));
|
||||
tb.Focus();
|
||||
tb.SelectionStart = _findHelper.SelectedPosition;
|
||||
tb.SelectionLength = _findHelper.FindTextLength;
|
||||
@ -6516,11 +6516,11 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_findHelper.StartLineIndex = 0;
|
||||
if (_findHelper.Find(_subtitle, _subtitleOriginal, 0))
|
||||
{
|
||||
SelectListViewIndexAndEnsureVisible(_findHelper.SelectedIndex);
|
||||
SelectListViewIndexAndEnsureVisible(_findHelper.SelectedLineIndex);
|
||||
tb.Focus();
|
||||
tb.SelectionStart = _findHelper.SelectedPosition;
|
||||
tb.SelectionLength = _findHelper.FindTextLength;
|
||||
ShowStatus(string.Format(_language.XFoundAtLineNumberY, _findHelper.FindText, _findHelper.SelectedIndex + 1));
|
||||
ShowStatus(string.Format(_language.XFoundAtLineNumberY, _findHelper.FindText, _findHelper.SelectedLineIndex + 1));
|
||||
_findHelper.SelectedPosition++;
|
||||
return;
|
||||
}
|
||||
@ -6534,7 +6534,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
if (_findHelper.FindNext(textBoxSource.Text, textBoxSource.SelectionStart))
|
||||
{
|
||||
textBoxSource.SelectionStart = _findHelper.SelectedIndex;
|
||||
textBoxSource.SelectionStart = _findHelper.SelectedLineIndex;
|
||||
textBoxSource.SelectionLength = _findHelper.FindTextLength;
|
||||
textBoxSource.ScrollToCaret();
|
||||
ShowStatus(string.Format(_language.XFoundAtLineNumberY, _findHelper.FindText, textBoxSource.GetLineFromCharIndex(textBoxSource.SelectionStart)));
|
||||
@ -6591,8 +6591,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (_findHelper.FindPrevious(_subtitle, _subtitleOriginal, selectedIndex, textBoxStart, Configuration.Settings.General.AllowEditOfOriginalSubtitle))
|
||||
{
|
||||
tb = GetFindReplaceTextBox();
|
||||
SelectListViewIndexAndEnsureVisible(_findHelper.SelectedIndex);
|
||||
ShowStatus(string.Format(_language.XFoundAtLineNumberY, _findHelper.FindText, _findHelper.SelectedIndex + 1));
|
||||
SelectListViewIndexAndEnsureVisible(_findHelper.SelectedLineIndex);
|
||||
ShowStatus(string.Format(_language.XFoundAtLineNumberY, _findHelper.FindText, _findHelper.SelectedLineIndex + 1));
|
||||
tb.Focus();
|
||||
tb.SelectionStart = _findHelper.SelectedPosition;
|
||||
tb.SelectionLength = _findHelper.FindTextLength;
|
||||
@ -6607,7 +6607,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
if (_findHelper.FindPrevious(textBoxSource.Text, textBoxSource.SelectionStart))
|
||||
{
|
||||
textBoxSource.SelectionStart = _findHelper.SelectedIndex;
|
||||
textBoxSource.SelectionStart = _findHelper.SelectedLineIndex;
|
||||
textBoxSource.SelectionLength = _findHelper.FindTextLength;
|
||||
textBoxSource.ScrollToCaret();
|
||||
ShowStatus(string.Format(_language.XFoundAtLineNumberY, _findHelper.FindText, textBoxSource.GetLineFromCharIndex(textBoxSource.SelectionStart)));
|
||||
@ -6686,7 +6686,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
if (_findHelper.FindNext(textBoxSource.Text, start))
|
||||
{
|
||||
textBoxSource.SelectionStart = _findHelper.SelectedIndex;
|
||||
textBoxSource.SelectionStart = _findHelper.SelectedLineIndex;
|
||||
textBoxSource.SelectionLength = _findHelper.FindTextLength;
|
||||
if (!replaceDialog.FindOnly)
|
||||
{
|
||||
@ -6702,7 +6702,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
if (_findHelper.FindNext(textBoxSource.Text, start))
|
||||
{
|
||||
textBoxSource.SelectionStart = _findHelper.SelectedIndex;
|
||||
textBoxSource.SelectionStart = _findHelper.SelectedLineIndex;
|
||||
textBoxSource.SelectionLength = _findHelper.FindTextLength;
|
||||
textBoxSource.ScrollToCaret();
|
||||
}
|
||||
@ -6779,8 +6779,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
if (_findHelper.FindNext(text, start))
|
||||
{
|
||||
text = text.Remove(findHelper.SelectedIndex, findHelper.FindTextLength).Insert(findHelper.SelectedIndex, findHelper.ReplaceText);
|
||||
start = findHelper.SelectedIndex + findHelper.FindTextLength;
|
||||
text = text.Remove(findHelper.SelectedLineIndex, findHelper.FindTextLength).Insert(findHelper.SelectedLineIndex, findHelper.ReplaceText);
|
||||
start = findHelper.SelectedLineIndex + findHelper.FindTextLength;
|
||||
replaceCount++;
|
||||
searchStringFound = true;
|
||||
}
|
||||
@ -6888,7 +6888,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
index = SubtitleListview1.SelectedItems[0].Index;
|
||||
}
|
||||
|
||||
_findHelper.SelectedIndex = index;
|
||||
_findHelper.SelectedLineIndex = index;
|
||||
if (textBoxListViewTextOriginal.Focused)
|
||||
{
|
||||
_findHelper.SelectedPosition = textBoxListViewTextOriginal.SelectionStart;
|
||||
@ -6922,12 +6922,12 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
else
|
||||
{
|
||||
int line = _findHelper.SelectedIndex;
|
||||
int line = _findHelper.SelectedLineIndex;
|
||||
int pos = _findHelper.ReplaceFromPosition;
|
||||
bool success = _findHelper.Success;
|
||||
var matchInOriginal = _findHelper.MatchInOriginal;
|
||||
_findHelper = replaceDialog.GetFindDialogHelper(_subtitleListViewIndex);
|
||||
_findHelper.SelectedIndex = line;
|
||||
_findHelper.SelectedLineIndex = line;
|
||||
_findHelper.SelectedPosition = pos;
|
||||
_findHelper.Success = success;
|
||||
_findHelper.MatchInOriginal = matchInOriginal;
|
||||
@ -6967,7 +6967,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
stopAtIndex = firstIndex;
|
||||
_findHelper.StartLineIndex = 0;
|
||||
_findHelper.SelectedIndex = 0;
|
||||
_findHelper.SelectedLineIndex = 0;
|
||||
replaceCount = ReplaceAllHelper.ReplaceAll(_findHelper, _subtitle, _subtitleOriginal, Configuration.Settings.General.AllowEditOfOriginalSubtitle, stopAtIndex);
|
||||
SubtitleListview1.Fill(_subtitle, _subtitleOriginal);
|
||||
}
|
||||
@ -6977,16 +6977,16 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
else if (replaceDialog.FindOnly)
|
||||
{
|
||||
if (_findHelper.FindNext(_subtitle, _subtitleOriginal, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle))
|
||||
if (_findHelper.FindNext(_subtitle, _subtitleOriginal, _findHelper.SelectedLineIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle))
|
||||
{
|
||||
var tb = GetFindReplaceTextBox();
|
||||
SelectListViewIndexAndEnsureVisible(_findHelper.SelectedIndex);
|
||||
SelectListViewIndexAndEnsureVisible(_findHelper.SelectedLineIndex);
|
||||
tb.Focus();
|
||||
tb.SelectionStart = _findHelper.SelectedPosition;
|
||||
tb.SelectionLength = _findHelper.FindTextLength;
|
||||
_findHelper.ReplaceFromPosition = _findHelper.SelectedPosition;
|
||||
_findHelper.SelectedPosition += _findHelper.FindTextLength;
|
||||
ShowStatus(string.Format(_language.NoXFoundAtLineY, _findHelper.SelectedIndex + 1, _findHelper.FindText));
|
||||
ShowStatus(string.Format(_language.NoXFoundAtLineY, _findHelper.SelectedLineIndex + 1, _findHelper.FindText));
|
||||
Replace(replaceDialog);
|
||||
if (replaceDialog != null && !replaceDialog.IsDisposed)
|
||||
{
|
||||
@ -7004,19 +7004,19 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
SelectListViewIndexAndEnsureVisible(0);
|
||||
_findHelper.StartLineIndex = 0;
|
||||
_findHelper.SelectedIndex = 0;
|
||||
_findHelper.SelectedLineIndex = 0;
|
||||
_findHelper.SelectedPosition = 0;
|
||||
_findHelper.ReplaceFromPosition = 0;
|
||||
if (_findHelper.FindNext(_subtitle, _subtitleOriginal, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle))
|
||||
if (_findHelper.FindNext(_subtitle, _subtitleOriginal, _findHelper.SelectedLineIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle))
|
||||
{
|
||||
var tb = GetFindReplaceTextBox();
|
||||
SelectListViewIndexAndEnsureVisible(_findHelper.SelectedIndex);
|
||||
SelectListViewIndexAndEnsureVisible(_findHelper.SelectedLineIndex);
|
||||
tb.Focus();
|
||||
tb.SelectionStart = _findHelper.SelectedPosition;
|
||||
tb.SelectionLength = _findHelper.FindTextLength;
|
||||
_findHelper.ReplaceFromPosition = _findHelper.SelectedPosition;
|
||||
_findHelper.SelectedPosition += _findHelper.FindTextLength;
|
||||
ShowStatus(string.Format(_language.NoXFoundAtLineY, _findHelper.SelectedIndex + 1, _findHelper.FindText));
|
||||
ShowStatus(string.Format(_language.NoXFoundAtLineY, _findHelper.SelectedLineIndex + 1, _findHelper.FindText));
|
||||
Replace(replaceDialog);
|
||||
if (replaceDialog != null)
|
||||
{
|
||||
@ -7068,9 +7068,9 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_findHelper.SelectedPosition += _findHelper.ReplaceText.Length;
|
||||
}
|
||||
|
||||
if (_findHelper.FindNext(_subtitle, _subtitleOriginal, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle))
|
||||
if (_findHelper.FindNext(_subtitle, _subtitleOriginal, _findHelper.SelectedLineIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle))
|
||||
{
|
||||
SelectListViewIndexAndEnsureVisible(_findHelper.SelectedIndex);
|
||||
SelectListViewIndexAndEnsureVisible(_findHelper.SelectedLineIndex);
|
||||
tb = GetFindReplaceTextBox();
|
||||
tb.Focus();
|
||||
tb.SelectionStart = _findHelper.SelectedPosition;
|
||||
@ -7080,7 +7080,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_findHelper.SelectedPosition += _findHelper.ReplaceText.Length;
|
||||
}
|
||||
|
||||
ShowStatus(string.Format(msg + _language.XFoundAtLineNumberY, _findHelper.FindText, _findHelper.SelectedIndex + 1));
|
||||
ShowStatus(string.Format(msg + _language.XFoundAtLineNumberY, _findHelper.FindText, _findHelper.SelectedLineIndex + 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -7094,18 +7094,18 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
SelectListViewIndexAndEnsureVisible(0);
|
||||
_findHelper.StartLineIndex = 0;
|
||||
_findHelper.SelectedIndex = 0;
|
||||
_findHelper.SelectedLineIndex = 0;
|
||||
_findHelper.SelectedPosition = 0;
|
||||
_findHelper.ReplaceFromPosition = 0;
|
||||
if (_findHelper.FindNext(_subtitle, _subtitleOriginal, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle))
|
||||
if (_findHelper.FindNext(_subtitle, _subtitleOriginal, _findHelper.SelectedLineIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle))
|
||||
{
|
||||
SelectListViewIndexAndEnsureVisible(_findHelper.SelectedIndex);
|
||||
SelectListViewIndexAndEnsureVisible(_findHelper.SelectedLineIndex);
|
||||
tb = GetFindReplaceTextBox();
|
||||
tb.Focus();
|
||||
tb.SelectionStart = _findHelper.SelectedPosition;
|
||||
tb.SelectionLength = _findHelper.FindTextLength;
|
||||
_findHelper.SelectedPosition += _findHelper.ReplaceText.Length;
|
||||
ShowStatus(string.Format(msg + _language.XFoundAtLineNumberY, _findHelper.FindText, _findHelper.SelectedIndex + 1));
|
||||
ShowStatus(string.Format(msg + _language.XFoundAtLineNumberY, _findHelper.FindText, _findHelper.SelectedLineIndex + 1));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -7141,7 +7141,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return;
|
||||
}
|
||||
|
||||
if (_findHelper.SelectedIndex > stopAtIndex)
|
||||
if (_findHelper.SelectedLineIndex > stopAtIndex)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -10359,7 +10359,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (_findHelper != null && !_findHelper.InProgress)
|
||||
{
|
||||
_findHelper.StartLineIndex = _subtitleListViewIndex;
|
||||
_findHelper.SelectedIndex = _subtitleListViewIndex;
|
||||
_findHelper.SelectedLineIndex = _subtitleListViewIndex;
|
||||
_findHelper.SelectedPosition = 0;
|
||||
_findHelper.ReplaceFromPosition = 0;
|
||||
_findHelper.MatchInOriginal = false;
|
||||
|
@ -3495,7 +3495,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
|
||||
{
|
||||
string text = _vobSubOcrCharacter.ManualRecognizedCharacters;
|
||||
|
||||
if (!_vobSubOcrCharacter.UseOnce)
|
||||
if (!_vobSubOcrCharacter.UseOnce)
|
||||
{
|
||||
string name = SaveCompareItemNew(item, text, _vobSubOcrCharacter.IsItalic, null);
|
||||
var addition = new ImageCompareAddition(name, text, item.NikseBitmap, _vobSubOcrCharacter.IsItalic, listViewIndex);
|
||||
@ -3822,7 +3822,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
list.Add(imageSplitterItem);
|
||||
}
|
||||
UpdateLineHeights(list);
|
||||
@ -3913,7 +3913,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
|
||||
}
|
||||
else if (result == DialogResult.OK)
|
||||
{
|
||||
if (!_vobSubOcrNOcrCharacter.UseOnce)
|
||||
if (!_vobSubOcrNOcrCharacter.UseOnce)
|
||||
{
|
||||
_nOcrDb.Add(_vobSubOcrNOcrCharacter.NOcrChar);
|
||||
SaveNOcrWithCurrentLanguage();
|
||||
@ -4826,7 +4826,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
|
||||
|
||||
var parentBitmap = new NikseBitmap(bmp);
|
||||
bmp.Dispose();
|
||||
|
||||
|
||||
|
||||
var minLineHeight = GetMinLineHeight();
|
||||
var list = NikseBitmapImageSplitter.SplitBitmapToLettersNew(parentBitmap, p.NumberOfPixelsIsSpace, p.RightToLeft, Configuration.Settings.VobSubOcr.TopToBottom, minLineHeight, _autoLineHeight);
|
||||
@ -6941,20 +6941,31 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
|
||||
{
|
||||
using (var findDialog = new FindDialog(_subtitle))
|
||||
{
|
||||
var idx = _selectedIndex + 1;
|
||||
var idx = _selectedIndex;
|
||||
|
||||
findDialog.Initialize(string.Empty, _findHelper);
|
||||
if (findDialog.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
_findHelper = findDialog.GetFindDialogHelper(idx);
|
||||
if (_findHelper.Find(_subtitle, null, idx + 1))
|
||||
if (_findHelper.Find(_subtitle, null, idx, textBoxCurrentText.SelectionStart))
|
||||
{
|
||||
subtitleListView1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex, true);
|
||||
subtitleListView1.SelectIndexAndEnsureVisible(_findHelper.SelectedLineIndex, true);
|
||||
textBoxCurrentText.SelectionStart = _findHelper.SelectedPosition;
|
||||
textBoxCurrentText.SelectionLength = _findHelper.FindTextLength;
|
||||
_findNextLastLineIndex = idx;
|
||||
_findNextLastTextPosition = _findHelper.SelectedPosition;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(_findHelper.FindText) && (Configuration.Settings.Tools.FindHistory.Count == 0 || Configuration.Settings.Tools.FindHistory[0] != _findHelper.FindText))
|
||||
{
|
||||
Configuration.Settings.Tools.FindHistory.Insert(0, _findHelper.FindText);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int _findNextLastLineIndex = -1;
|
||||
private int _findNextLastTextPosition = -1;
|
||||
private void FindNext()
|
||||
{
|
||||
if (_findHelper == null)
|
||||
@ -6962,10 +6973,21 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
|
||||
return;
|
||||
}
|
||||
|
||||
var idx = _selectedIndex + 1;
|
||||
if (_findHelper.Find(_subtitle, null, idx + 1))
|
||||
var idx = _selectedIndex;
|
||||
if (_findHelper.Find(_subtitle, null, idx, textBoxCurrentText.SelectionStart + 1))
|
||||
{
|
||||
subtitleListView1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex, true);
|
||||
if (_findHelper.SelectedLineIndex == _findNextLastLineIndex &&
|
||||
_findHelper.SelectedPosition == _findNextLastTextPosition &&
|
||||
!_findHelper.Find(_subtitle, null, idx, textBoxCurrentText.SelectionStart + _findHelper.FindTextLength))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
subtitleListView1.SelectIndexAndEnsureVisible(_findHelper.SelectedLineIndex, true);
|
||||
textBoxCurrentText.SelectionStart = _findHelper.SelectedPosition;
|
||||
textBoxCurrentText.SelectionLength = _findHelper.FindTextLength;
|
||||
_findNextLastLineIndex = idx;
|
||||
_findNextLastTextPosition = _findHelper.SelectedPosition;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
|
||||
public bool Success { get; set; }
|
||||
public ReplaceType FindReplaceType { get; set; }
|
||||
public int SelectedIndex { get; set; }
|
||||
public int SelectedLineIndex { get; set; }
|
||||
public int SelectedPosition { get; set; }
|
||||
public int ReplaceFromPosition { get; set; }
|
||||
public int StartLineIndex { get; set; }
|
||||
@ -101,7 +101,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
|
||||
if (match.Success)
|
||||
{
|
||||
string groupName = RegexUtils.GetRegExGroup(FindText);
|
||||
var groupName = RegexUtils.GetRegExGroup(FindText);
|
||||
if (groupName != null && match.Groups[groupName] != null && match.Groups[groupName].Success)
|
||||
{
|
||||
FindTextLength = match.Groups[groupName].Length;
|
||||
@ -117,14 +117,14 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
public bool FindNext(Subtitle subtitle, Subtitle originalSubtitle, int startIndex, int position, bool allowEditOfOriginalSubtitle)
|
||||
{
|
||||
Success = false;
|
||||
int index = 0;
|
||||
var index = 0;
|
||||
if (position < 0)
|
||||
{
|
||||
position = 0;
|
||||
}
|
||||
|
||||
bool first = true;
|
||||
foreach (Paragraph p in subtitle.Paragraphs)
|
||||
var first = true;
|
||||
foreach (var p in subtitle.Paragraphs)
|
||||
{
|
||||
if (index >= startIndex)
|
||||
{
|
||||
@ -140,7 +140,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
if (pos >= 0)
|
||||
{
|
||||
MatchInOriginal = false;
|
||||
SelectedIndex = index;
|
||||
SelectedLineIndex = index;
|
||||
SelectedPosition = pos;
|
||||
ReplaceFromPosition = pos;
|
||||
Success = true;
|
||||
@ -148,6 +148,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
}
|
||||
position = 0;
|
||||
}
|
||||
|
||||
if (index < subtitle.Paragraphs.Count - 1)
|
||||
{
|
||||
MatchInOriginal = false;
|
||||
@ -155,14 +156,14 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
|
||||
if (originalSubtitle != null && allowEditOfOriginalSubtitle)
|
||||
{
|
||||
Paragraph o = Utilities.GetOriginalParagraph(index, p, originalSubtitle.Paragraphs);
|
||||
var o = Utilities.GetOriginalParagraph(index, p, originalSubtitle.Paragraphs);
|
||||
if (o != null)
|
||||
{
|
||||
pos = FindPositionInText(o.Text, position);
|
||||
if (pos >= 0)
|
||||
{
|
||||
MatchInOriginal = true;
|
||||
SelectedIndex = index;
|
||||
SelectedLineIndex = index;
|
||||
SelectedPosition = pos;
|
||||
ReplaceFromPosition = pos;
|
||||
Success = true;
|
||||
@ -174,6 +175,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -208,7 +210,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
{
|
||||
pos += position - j;
|
||||
MatchInOriginal = true;
|
||||
SelectedIndex = index;
|
||||
SelectedLineIndex = index;
|
||||
SelectedPosition = pos;
|
||||
ReplaceFromPosition = pos;
|
||||
Success = true;
|
||||
@ -237,7 +239,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
{
|
||||
pos += position - j;
|
||||
MatchInOriginal = false;
|
||||
SelectedIndex = index;
|
||||
SelectedLineIndex = index;
|
||||
SelectedPosition = pos;
|
||||
ReplaceFromPosition = pos;
|
||||
Success = true;
|
||||
@ -305,32 +307,34 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
{
|
||||
if (FindReplaceType.FindType == FindType.RegEx)
|
||||
{
|
||||
Match match = _regEx.Match(text, startIndex);
|
||||
var match = _regEx.Match(text, startIndex);
|
||||
if (match.Success)
|
||||
{
|
||||
string groupName = RegexUtils.GetRegExGroup(FindText);
|
||||
var groupName = RegexUtils.GetRegExGroup(FindText);
|
||||
if (groupName != null && match.Groups[groupName] != null && match.Groups[groupName].Success)
|
||||
{
|
||||
FindTextLength = match.Groups[groupName].Length;
|
||||
SelectedIndex = match.Groups[groupName].Index;
|
||||
SelectedLineIndex = match.Groups[groupName].Index;
|
||||
}
|
||||
else
|
||||
{
|
||||
FindTextLength = match.Length;
|
||||
SelectedIndex = match.Index;
|
||||
SelectedLineIndex = match.Index;
|
||||
}
|
||||
Success = true;
|
||||
}
|
||||
return match.Success;
|
||||
}
|
||||
string searchText = text.Substring(startIndex);
|
||||
int pos = FindPositionInText(searchText, 0);
|
||||
|
||||
var searchText = text.Substring(startIndex);
|
||||
var pos = FindPositionInText(searchText, 0);
|
||||
if (pos >= 0)
|
||||
{
|
||||
SelectedIndex = pos + startIndex;
|
||||
SelectedLineIndex = pos + startIndex;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -350,12 +354,12 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
if (groupName != null && last.Groups[groupName] != null && last.Groups[groupName].Success)
|
||||
{
|
||||
FindTextLength = last.Groups[groupName].Length;
|
||||
SelectedIndex = last.Groups[groupName].Index;
|
||||
SelectedLineIndex = last.Groups[groupName].Index;
|
||||
}
|
||||
else
|
||||
{
|
||||
FindTextLength = last.Length;
|
||||
SelectedIndex = last.Index;
|
||||
SelectedLineIndex = last.Index;
|
||||
}
|
||||
Success = true;
|
||||
}
|
||||
@ -387,7 +391,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
}
|
||||
if (pos >= 0)
|
||||
{
|
||||
SelectedIndex = pos;
|
||||
SelectedLineIndex = pos;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -43,8 +43,8 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
var start = -1;
|
||||
while (findHelper.FindNext(p.Text, start))
|
||||
{
|
||||
p.Text = p.Text.Remove(findHelper.SelectedIndex, findHelper.FindTextLength).Insert(findHelper.SelectedIndex, findHelper.ReplaceText);
|
||||
start = findHelper.SelectedIndex + findHelper.ReplaceText.Length -1;
|
||||
p.Text = p.Text.Remove(findHelper.SelectedLineIndex, findHelper.FindTextLength).Insert(findHelper.SelectedLineIndex, findHelper.ReplaceText);
|
||||
start = findHelper.SelectedLineIndex + findHelper.ReplaceText.Length -1;
|
||||
replaceCount++;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user