Skip to content

Commit

Permalink
fix weird tabstop problems on all forms
Browse files Browse the repository at this point in the history
1. ComboBoxes had tabstop issues on all forms previously;
    now those issues are gone, and they are treated normally.
2. The find/replace form and the RegexSearchForm
    now both have complete tabstop coverage.
3. Tabstops now correctly ignore invisible and disabled controls.
4. RemesPath benchmarks now more accurately capture
    effects of caching.
  • Loading branch information
molsonkiko committed Dec 13, 2023
1 parent 34afcc8 commit 30382b6
Show file tree
Hide file tree
Showing 18 changed files with 286 additions and 168 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
}
```
3. Add option for users to choose newline in JSON Lines.
4. Option for users to choose whether to escape newlines in CSV files.

### To Be Changed

Expand Down Expand Up @@ -69,6 +68,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3. Made [`offer_to_show_lint` setting](/docs/README.md#parser-settings) (which controls whether a prompt is shown when errors are found) true by default, so that a fresh installation will show the prompt.
4. Change RemesPath indexers to reduce the number of backslash escapes needed to get keys containing special characters like `"a\\b"` or `"\"foo\"\tbar"`. For instance, previously ``@.`\\n\\\\a\"` `` would be required to match the key `"\n\\a\""`, whereas now `` @.`\n\\a"` `` matches it.
5. Running a RemesPath query only causes an attempted re-parsing of the document if the treeview's current file is open.
6. Running a replace query on the [find/replace form](/docs/README.md#find-and-replace-form) now causes the tree to display only the values that were mutated.
7. Changed the tabstop order of some forms, made it so that the find/replace form has complete tabstop coverage, and eliminated some tabstop-related issues associated with combo boxes in some forms.
8. Benchmarks for compiling RemesPath queries now more accurately represent the effect of caching on performance.

### Fixed

Expand Down
70 changes: 35 additions & 35 deletions JsonToolsNppPlugin/Forms/FindReplaceForm.Designer.cs

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

30 changes: 23 additions & 7 deletions JsonToolsNppPlugin/Forms/FindReplaceForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ private void FindReplaceForm_KeyDown(object sender, KeyEventArgs e)
e.SuppressKeyPress = true;
}

/// <summary>
/// suppress the default response to the Tab key
/// </summary>
/// <param name="keyData"></param>
/// <returns></returns>
protected override bool ProcessDialogKey(Keys keyData)
{
if (keyData.HasFlag(Keys.Tab)) // this covers Tab with or without modifiers
return true;
return base.ProcessDialogKey(keyData);
}

private void FindReplaceForm_KeyUp(object sender, KeyEventArgs e)
{
SortForm.GenericKeyUpHandler(this, sender, e);
Expand All @@ -76,14 +88,14 @@ private void TextBox_KeyPress(object sender, KeyPressEventArgs e)
e.Handled = true;
}

private void AdvancedGroupBoxLabel_Click(object sender, EventArgs e)
private void ShowAdvancedOptionsCheckBox_CheckedChanged(object sender, EventArgs e)
{
// show the advanced controls and expand the box
if (!RegexBox.Visible)
{
if (Height < EXTENDED_HEIGHT)
Height = EXTENDED_HEIGHT;
AdvancedGroupBoxLabel.Text = "Hide advanced options";
ShowAdvancedOptionsCheckBox.Text = "Hide advanced options";
AdvancedGroupBox.Height = ADVANCED_CONTROLS_EXTENDED_HEIGHT;
foreach (Control control in AdvancedGroupBox.Controls)
{
Expand All @@ -95,7 +107,7 @@ private void AdvancedGroupBoxLabel_Click(object sender, EventArgs e)
{
if (Height == EXTENDED_HEIGHT)
Height = COLLAPSED_HEIGHT;
AdvancedGroupBoxLabel.Text = "Show advanced options";
ShowAdvancedOptionsCheckBox.Text = "Show advanced options";
AdvancedGroupBox.Height = ADVANCED_CONTROLS_COLLAPSED_HEIGHT;
foreach (Control control in AdvancedGroupBox.Controls)
{
Expand Down Expand Up @@ -233,11 +245,15 @@ private void ReplaceButton_Click(object sender, EventArgs e)
// for math find/replace we want to filter before performing the operation
// for regex find/replace the s_sub function naturally filters (because it's only replacing the target substring)
// thus, we only want to use the findQuery to filter when doing math find/replace
treeViewer.QueryBox.Text = (MathBox.Checked)
? findQuery + " = " + replaceQuery
: $"{root}[is_str(@)] = {replaceQuery}";
//treeViewer.QueryBox.Text = findQuery + " = " + replaceQuery;
string findPart = MathBox.Checked
? $"var x = {findQuery}"
: $"var x = {root}[is_str(@)]";
treeViewer.QueryBox.Text = $"{findPart};\r\nx = {replaceQuery};\r\nx";
// use variable assignment, then mutate the variable, then show the variable.
// this is nice because (1) it introduces variable assignment,
// and (2) it displays exactly the values that were mutated rather than forcing the user to find them
treeViewer.SubmitQueryButton.PerformClick();
treeViewer.Tree.Nodes[0].Expand();
KeysValsBothBox.SelectedIndex = keysvals_index;
}

Expand Down
12 changes: 12 additions & 0 deletions JsonToolsNppPlugin/Forms/GrepperForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,18 @@ private void GrepperForm_FormClosing(object sender, FormClosingEventArgs e)
}
}

/// <summary>
/// suppress the default response to the Tab key
/// </summary>
/// <param name="keyData"></param>
/// <returns></returns>
protected override bool ProcessDialogKey(Keys keyData)
{
if (keyData.HasFlag(Keys.Tab)) // this covers Tab with or without modifiers
return true;
return base.ProcessDialogKey(keyData);
}

private void GrepperForm_KeyUp(object sender, KeyEventArgs e)
{
SortForm.GenericKeyUpHandler(this, sender, e);
Expand Down
2 changes: 1 addition & 1 deletion JsonToolsNppPlugin/Forms/JsonToCsvForm.Designer.cs

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

12 changes: 12 additions & 0 deletions JsonToolsNppPlugin/Forms/JsonToCsvForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ public JsonToCsvForm(JNode json)
eolComboBox.SelectedIndex = (int)Main.settings.csv_newline;
}

/// <summary>
/// suppress the default response to the Tab key
/// </summary>
/// <param name="keyData"></param>
/// <returns></returns>
protected override bool ProcessDialogKey(Keys keyData)
{
if (keyData.HasFlag(Keys.Tab)) // this covers Tab with or without modifiers
return true;
return base.ProcessDialogKey(keyData);
}

private void JsonToCsvForm_KeyUp(object sender, KeyEventArgs e)
{
SortForm.GenericKeyUpHandler(this, sender, e, true);
Expand Down
Loading

0 comments on commit 30382b6

Please sign in to comment.