Skip to content

Commit

Permalink
impl. F3 to search next occurence in search-boxes [#40]
Browse files Browse the repository at this point in the history
  • Loading branch information
t0815 committed Sep 12, 2024
1 parent 9452111 commit 478ce35
Show file tree
Hide file tree
Showing 8 changed files with 1,128 additions and 1,061 deletions.
5 changes: 5 additions & 0 deletions MyCBZ/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,12 @@ private void MainForm_Shown(object sender, EventArgs e)

ComboBoxCompressionLevel.SelectedIndex = 0;

// ---------------------------- DEBUG --------------------------------
DebugToolsToolStripMenuItem.Visible = Program.DebugMode;
CheckBoxSplitDoublePages.Enabled = Program.DebugMode;

// -------------------------------------------------------------------


TextBoxMetaDataFilename.Text = Win_CBZSettings.Default.MetaDataFilename;

Expand Down
118 changes: 59 additions & 59 deletions MyCBZ/Forms/MainForm.resx

Large diffs are not rendered by default.

1,679 changes: 840 additions & 839 deletions MyCBZ/Forms/SettingsDialog.Designer.cs

Large diffs are not rendered by default.

32 changes: 31 additions & 1 deletion MyCBZ/Forms/SettingsDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ internal partial class SettingsDialog : Form

DataValidation validation;

private int lastSearchOccurence = 0;

private int occurence = 0;

private int nextOccurence = 0;

public SettingsDialog()
{
InitializeComponent();
Expand Down Expand Up @@ -1451,7 +1457,29 @@ private void ToolStripTextBoxSearchTag_KeyUp(object sender, KeyEventArgs e)
{
String itemsText = ValidTags.Text;

int occurence = itemsText.IndexOf(ToolStripTextBoxSearchTag.Text, 0, StringComparison.CurrentCultureIgnoreCase);
if (e.KeyCode == Keys.F3)
{
lastSearchOccurence = occurence + ToolStripTextBoxSearchTag.Text.Length;

ValidTags.SelectionStart = lastSearchOccurence + ToolStripTextBoxSearchTag.Text.Length;
ValidTags.SelectionLength = 0;

nextOccurence = itemsText.IndexOf(ToolStripTextBoxSearchTag.Text, lastSearchOccurence, StringComparison.CurrentCultureIgnoreCase);


if (nextOccurence < 0)
{
ApplicationMessage.Show("Search reached the end of the document. Starting from the beginning.", "Search", ApplicationMessage.DialogType.MT_INFORMATION, ApplicationMessage.DialogButtons.MB_OK);

lastSearchOccurence = 0;
}
}
else
{
lastSearchOccurence = 0;
}

occurence = itemsText.IndexOf(ToolStripTextBoxSearchTag.Text, lastSearchOccurence, StringComparison.CurrentCultureIgnoreCase);

ValidTags.SelectionStart = 0;
ValidTags.SelectionLength = 0;
Expand All @@ -1460,6 +1488,8 @@ private void ToolStripTextBoxSearchTag_KeyUp(object sender, KeyEventArgs e)
ValidTags.SelectionStart = occurence;
ValidTags.SelectionLength = ToolStripTextBoxSearchTag.Text.Length;
ValidTags.ScrollToCaret();

lastSearchOccurence = occurence;
}
}

Expand Down
10 changes: 5 additions & 5 deletions MyCBZ/Forms/SettingsDialog.resx
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
</value>
</data>
<metadata name="ItemEditorToolBar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>167, 17</value>
</metadata>
<metadata name="DialogImages.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>615, 17</value>
</metadata>
Expand All @@ -305,7 +308,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAEZTeXN0ZW0uV2luZG93cy5Gb3JtcywgQ3VsdHVyZT1uZXV0cmFs
LCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5BQEAAAAmU3lzdGVtLldpbmRvd3MuRm9ybXMu
SW1hZ2VMaXN0U3RyZWFtZXIBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAoAIAAAJNU0Z0AUkBTAIBAQIB
AAHAAQYBwAEGARABAAEQAQAE/wEZAQAI/wFCAU0BNgcAATYDAAEoAwABQAMAARADAAEBAQABGAYAAQz/
AAHwAQYB8AEGARABAAEQAQAE/wEZAQAI/wFCAU0BNgcAATYDAAEoAwABQAMAARADAAEBAQABGAYAAQz/
AAwAA+cBUgFUAVUD+g8AA7gBtgK4ewAD9gO+A70D4BgAA+YDUAMlA30D+gYAA/0DtAMrAyUDungAAdEC
0gYlAYoCixUAA+cMJQNGA/oDAAO0DCUBtgK4dQAB0QLSBiUBigKLFQAD6AM1DCUDfQO0AysJJQMrA7h1
AAHRAtIGJQGKAosYAAPzAzUbJQO0bwADlAGKAosBigKLAWYCZwYlA0cBigKLAYoCiwGKAosD4A8AA+AD
Expand All @@ -328,9 +331,6 @@ VERSION_2 = &lt;Image="[FileName]" Key="[UniqueID]" ...&gt;

(VERSION_1 is the current comicinfo.xml specification)</value>
</data>
<metadata name="ItemEditorToolBar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>167, 17</value>
</metadata>
<metadata name="AutocompleteIcons.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>768, 17</value>
</metadata>
Expand All @@ -339,7 +339,7 @@ VERSION_2 = &lt;Image="[FileName]" Key="[UniqueID]" ...&gt;
AAEAAAD/////AQAAAAAAAAAMAgAAAEZTeXN0ZW0uV2luZG93cy5Gb3JtcywgQ3VsdHVyZT1uZXV0cmFs
LCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5BQEAAAAmU3lzdGVtLldpbmRvd3MuRm9ybXMu
SW1hZ2VMaXN0U3RyZWFtZXIBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAGCIAAAJNU0Z0AUkBTAIBAQ0B
AAEwAQUBMAEFARABAAEQAQAE/wEhAQAI/wFCAU0BNgcAATYDAAEoAwABQAMAAUADAAEBAQABIAYAAUD/
AAFgAQUBYAEFARABAAEQAQAE/wEhAQAI/wFCAU0BNgcAATYDAAEoAwABQAMAAUADAAEBAQABIAYAAUD/
ABsAA0wBkAMlAf8DYgHhCAADJAE0AyUB/wMlAf8DKgE/3AADMgFPAyUB/wMlAf8DGgEkBAAEAgNZAe8D
JQH/A0YBgNgAAxABFQMbASYDQAH9AyUB/wNAAW8DEAEVAxABFQNYAboDJQH/A1oBxAMQARUDDwET0AAD
XAHZAyUB/wMlAf8DJQH/AyUB/wMlAf8DJQH/AyUB/wMlAf8DJQH/AyUB/wMrAfwDDgESzAADTgGXAyUB
Expand Down
5 changes: 3 additions & 2 deletions MyCBZ/Forms/TextEditorForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 33 additions & 2 deletions MyCBZ/Forms/TextEditorForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ public partial class TextEditorForm : Form

private DataValidation Validation;

private int lastSearchOccurence = 0;

private int occurence = 0;

private int nextOccurence = 0;

public TextEditorForm(EditorTypeConfig editorTypeConfig)
{
InitializeComponent();
Expand Down Expand Up @@ -163,7 +169,28 @@ private void ToolStripTextBoxSearch_KeyUp(object sender, KeyEventArgs e)
{
String itemsText = ItemsText.Text;

int occurence = itemsText.IndexOf(ToolStripTextBoxSearch.Text, 0, StringComparison.CurrentCultureIgnoreCase);
if (e.KeyCode == Keys.F3)
{
lastSearchOccurence = occurence + ToolStripTextBoxSearch.Text.Length;

ItemsText.SelectionStart = lastSearchOccurence + ToolStripTextBoxSearch.Text.Length;
ItemsText.SelectionLength = 0;

nextOccurence = itemsText.IndexOf(ToolStripTextBoxSearch.Text, lastSearchOccurence, StringComparison.CurrentCultureIgnoreCase);


if (nextOccurence < 0)
{
ApplicationMessage.Show("Search reached the end of the document. Starting from the beginning.", "Search", ApplicationMessage.DialogType.MT_INFORMATION, ApplicationMessage.DialogButtons.MB_OK);

lastSearchOccurence = 0;
}
} else
{
lastSearchOccurence = 0;
}

occurence = itemsText.IndexOf(ToolStripTextBoxSearch.Text, lastSearchOccurence, StringComparison.CurrentCultureIgnoreCase);

ItemsText.SelectionStart = 0;
ItemsText.SelectionLength = 0;
Expand All @@ -172,7 +199,11 @@ private void ToolStripTextBoxSearch_KeyUp(object sender, KeyEventArgs e)
ItemsText.SelectionStart = occurence;
ItemsText.SelectionLength = ToolStripTextBoxSearch.Text.Length;
ItemsText.ScrollToCaret();
}

lastSearchOccurence = occurence;
}


}
}
}
Loading

0 comments on commit 478ce35

Please sign in to comment.