Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add placeholder blinks setting #177

Merged
merged 22 commits into from
Oct 27, 2020
Merged

Add placeholder blinks setting #177

merged 22 commits into from
Oct 27, 2020

Conversation

SymboLinker
Copy link
Contributor

In issue #175 a feature request was done for stopping the blinking of the placeholder (but still have a blinking carret if it moves to a spot without a placeholder).

The proposed pull request #176 just removes the blinking of the placeholder and does not leave it as an option.

This pull request adds a setting LaTeXSetting.PlaceholderBlinks that keeps the default value true and does not break any existing unit tests.

Tests are added

  • to make sure that the setting for a non-blinking placeholder works
  • to document how it should work
  • to make sure that it will not be removed in a whim

@charlesroddie Please verify that the effect of changing the "PlaceholderBlinks"-setting results in the behaviour you like.

@codecov-io
Copy link

codecov-io commented Oct 24, 2020

Codecov Report

Merging #177 into master will increase coverage by 0.01%.
The diff coverage is 97.61%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #177      +/-   ##
==========================================
+ Coverage   87.32%   87.34%   +0.01%     
==========================================
  Files         156      156              
  Lines       11314    11329      +15     
==========================================
+ Hits         9880     9895      +15     
  Misses       1434     1434              
Impacted Files Coverage Δ
CSharpMath.Forms/MathKeyboardExtensions.cs 0.00% <0.00%> (ø)
CSharpMath.Rendering/FrontEnd/MathKeyboard.cs 10.34% <0.00%> (ø)
CSharpMath.Editor.Tests/CaretTests.cs 100.00% <100.00%> (ø)
CSharpMath.Editor/MathKeyboard.cs 89.02% <100.00%> (-0.12%) ⬇️
CSharpMath/Atom/LaTeXSettings.cs 98.75% <100.00%> (+<0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 476beb0...944e307. Read the comment docs.

@SymboLinker SymboLinker marked this pull request as draft October 24, 2020 10:58
@SymboLinker
Copy link
Contributor Author

O, I made a stupid mistake. The caret does not blink anymore if the setting is used. I will copy what charlesroddie proposed.

@SymboLinker SymboLinker marked this pull request as ready for review October 24, 2020 11:22
…rue then don't change the CaretState instead of ignoring the changed state later on
CSharpMath/Atom/LaTeXSettings.cs Outdated Show resolved Hide resolved
@charlesroddie
Copy link
Collaborator

charlesroddie commented Oct 24, 2020

I don't understand the enum

  public enum MathKeyboardCaretState : byte {
    Hidden,
    TemporarilyHidden,
    ShownThroughPlaceholder,
    Shown
  }

Is anyone able to document this enum assuming that it makes sense @Happypig375 @SymboLinker @FoggyFinder ?

It seems a little strange to me that, if PlaceholderBlinks, then the path is ShownThroughPlaceholder -> TemporarilyHidden -> Shown -> Hidden -> Shown -> Hidden ... . This suggests to me that ShownThroughPlaceholder is not a valid case. But it's only a guess as I don't understand the meanings.

@Happypig375
Copy link
Collaborator

TemporarilyHidden -> Shown
should be
TemporarilyHidden -> ShownThroughPlaceholder

So this may be a bug.

@Happypig375
Copy link
Collaborator

Shown: Caret is drawn. Invalid for placeholders. Will disappear when blink timer fires.
ShownThroughPlaceholder: Caret is not drawn. Placeholder is activated. Will disappear when blink timer fires.
TemporarilyHidden: Caret is not drawn. Placeholder is deactivated. Will reappear when blink timer fires.
Hidden: Caret is not drawn. Placeholder is deactivated. Will not reappear when blink timer fires.

@Happypig375
Copy link
Collaborator

Trying to set to Shown when caret is a placeholder will be automatically set to ShownThroughPlaceholder instead.

@charlesroddie
Copy link
Collaborator

charlesroddie commented Oct 24, 2020

Thanks. Is this better than having only the cases Hidden/TemporarilyHidden/Shown and having Shown display as a cursor or active placeholder depending on the position?

Wouldn't removing the ShownThroughPlaceholder case remove two possibilities for invalid data combinations (Shown and in a placeholder, ShownThroughPlaceholder and not in a placeholder)?

@SymboLinker
Copy link
Contributor Author

SymboLinker commented Oct 24, 2020

Maybe this would be more clear:

  public enum MathKeyboardCaretState : byte {
    Hidden,
    TemporarilyHidden,
    TemporarilyShown,
  }

and then as charlesroddie suggested

display as a cursor or active placeholder depending on the position?

We could also re-add a Shown enum value that means "don't ever disappear, not even if the timer elapses".

and avoid invoking RedrawRequested when state has not changed
@charlesroddie
Copy link
Collaborator

charlesroddie commented Oct 24, 2020

I've pushed a change to this branch c89ac9e which:

  • Removes ShownThroughPlaceholder as per Add placeholder blinks setting #177 (comment)
  • Adjusts the CaretState setter to actually set it to the requested value!
  • Avoids triggering RedrawRequested when the CaretState is set to its current value [Edit: this was a mistake, now reverted]

@charlesroddie
Copy link
Collaborator

@SymboLinker your first idea wouldn't be more clear because placeholders won't be TemporarilyShown (except in the case where you had set PlaceholderBlinks to true) and the second idea requires an extra case and enables options (non-blinking cursor) which would be better expressed as a setting.

@charlesroddie
Copy link
Collaborator

charlesroddie commented Oct 24, 2020

Can't merge as there is a problem with the cursor showing:
image
Investigating

@charlesroddie charlesroddie self-requested a review October 24, 2020 16:49
@charlesroddie
Copy link
Collaborator

Fixed

@charlesroddie
Copy link
Collaborator

Thank you for adjusting the tests.

@Happypig375 Looks like @SymboLinker 's VS is also adding a nuget.config file not just mine. I guess it doesn't matter a lot whether we keep it or gitignore it or find out why it's happening? Anyone with an opinion?

@SymboLinker
Copy link
Contributor Author

Good defaults are extremely important (...) .

Thinking about defaults with such avidity has given me a thought that I will keep in mind for some time. Thanks for this possibly useful insight. This led me to read the following again:

because a large block blinks which is already easy to identify, unlike the cursor where a small line blinks which is harder to identify

Yes, nice. Those subtle things are what LaTeX is about.

Because you mentioned "what others do" first, I concluded too quickly that the argumention for a request for changing the default was weak. I should not have overlooked the second part.

And here I am, ditching the "I decided not to work on...".

@SymboLinker
Copy link
Contributor Author

(...) also adding a nuget.config file not just mine. I guess it doesn't matter a lot whether we keep it or gitignore it or find out why it's happening? Anyone with an opinion?

Sometimes a NuGet.Config should be included, for example if CSharpMath would go use NightlyPackages as a dependency. That is not the case (yet), so that seems no reason to be against ignoring it now.
However, in my case today was the first time that a NuGet.Config was generated. That may solve the question how it was generated so that that can be stopped. Could ed72190 have done a change that causes it?

@Happypig375
Copy link
Collaborator

@charlesroddie If you don't add unit tests testing your desired behaviour, then there is no guarantee that it will continue to function correctly aside from manual testing. And why test it manually instead of automatically?

@SymboLinker
Copy link
Contributor Author

SymboLinker commented Oct 25, 2020

I suspect this can be tested by calling the Keyboard's DrawCaret method with a Mock<ICanvas> and verify that mock.StartNewPath has not been called. I will look into that later today.

@SymboLinker SymboLinker marked this pull request as draft October 25, 2020 08:33
…tionHighlighted" and "ShouldDrawCaret"

General notes:
Having a CaretState that says "MathKeyboardCaretState.Shown" while actually no caret is shown because a placeholder is shown is wrong. Having a CaretState "MathKeyboardCaretState.Hidden" and "MathKeyboardCaretState.TemporarilyHidden" is not needed: you can use StopBlinking() just after setting the CaretState you want to keep until the next key press. These two observations resulted in the boolean properties "InsertionPositionHighlighted" (that makes sense for both the caret AND the placeholder appearance) and "ShouldDrawCaret".

Because Drawing the caret is done in CSharpMath.Rendering.FrontEnd, the unit tests of CSharpMath.Editor can only test "ShouldDraw" and unit tests that do that can cover the same as before (when it was tested via a MathKeyboardCaretState enum).

Notes about moved unit tests:
- CaretIsOverriddenByPlaceholder has been replaced by PlaceholderDoesNotBlinkAndNoCaretVisible.
- CaretMovesWithPlaceholder has been replaced by NonBlinkingActivePlaceholderMoves.
@SymboLinker SymboLinker marked this pull request as ready for review October 25, 2020 14:03
@SymboLinker
Copy link
Contributor Author

The merge conflict cannot be solved by me. If the changes of cfeb157 are OK, then the MathKeyboardCaretState enum should be deleted in the merge.

@charlesroddie
Copy link
Collaborator

If the changes of cfeb157 are OK

They make sense to me

@charlesroddie
Copy link
Collaborator

Thanks @SymboLinker !

@charlesroddie charlesroddie merged commit 892eaec into verybadcat:master Oct 27, 2020
@Happypig375 Happypig375 added the Resolution/Implemented The described enhancement or housekeeping work has been implemented. label Oct 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution/Implemented The described enhancement or housekeeping work has been implemented. Type/Enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants