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

Fixes #3777 - HexView Focus Issue - Adds View.AdvancingFocus events #3783

Merged
merged 30 commits into from
Oct 15, 2024

Conversation

tig
Copy link
Collaborator

@tig tig commented Oct 9, 2024

Fixes

Proposed Changes/Todos

  • Code cleanup
  • Add View.AdvancingFocus
  • Fix HexView focus issue
  • Fix HexView right side editing
  • Add Utf8 / Unicode input and editing
  • Fix display issues

Pull Request checklist:

  • I've named my PR in the form of "Fixes #issue. Terse description."
  • My code follows the style guidelines of Terminal.Gui - if you use Visual Studio, hit CTRL-K-D to automatically reformat your files before committing.
  • My code follows the Terminal.Gui library design guidelines
  • I ran dotnet test before commit
  • I have made corresponding changes to the API documentation (using /// style comments)
  • My changes generate no new warnings
  • I have checked my code and corrected any poor grammar or misspellings
  • I conducted basic QA to assure all features are working

@tig tig requested a review from BDisp October 10, 2024 22:23
@tig tig marked this pull request as ready for review October 10, 2024 22:23
@tig
Copy link
Collaborator Author

tig commented Oct 10, 2024

Kt5ILpC 1

@BDisp
Copy link
Collaborator

BDisp commented Oct 10, 2024

The HexView is the only focusable view in the HexView scenario and it has two focusable subviews. Isn't possible to navigate between them with only tabbing, without forcing pressing Shift-Tab to go from the text view to the hexa view?

@BDisp
Copy link
Collaborator

BDisp commented Oct 11, 2024

If you paste this glyph 🦱https://www.compart.com/en/unicode/U+1F9B1 it will throw this exception.

image

But is a surrogate pair and WindowsDriver and NetDriver doesn't support it. Only CursesDriver support it by paste the UTF-8 Encoding: 0xF0 0x9F 0xA6 0xB1. Only for memorize later.

image

@BDisp
Copy link
Collaborator

BDisp commented Oct 11, 2024

When have edited changes the text stays selected. That's ok but the cursor is invisible and it's more harder to know where is it.

@tig tig changed the title Fixes #3777 - HexView Focus Issue - Adds View.AdvanceingFocus events Fixes #3777 - HexView Focus Issue - Adds View.AdvancingFocus events Oct 11, 2024
@tig
Copy link
Collaborator Author

tig commented Oct 11, 2024

The HexView is the only focusable view in the HexView scenario and it has two focusable subviews. Isn't possible to navigate between them with only tabbing, without forcing pressing Shift-Tab to go from the text view to the hexa view?

Sorry, but I don't understand. The HexEDITOR scenario has only ONE focusable view.

@tig
Copy link
Collaborator Author

tig commented Oct 11, 2024

When have edited changes the text stays selected. That's ok but the cursor is invisible and it's more harder to know where is it.

I don't understand.

What's wrong with this?

7o1whua 1

@tig
Copy link
Collaborator Author

tig commented Oct 11, 2024

🦱

This happen with TextField and TextView too. Please raise a separate issue for this.

@BDisp
Copy link
Collaborator

BDisp commented Oct 11, 2024

Sorry, but I don't understand. The HexEDITOR scenario has only ONE focusable view.

Sorry @tig, I made confusing because I though it was using a TextView. I was a long time I saw the code and I didn't remember that. If we are in editing in the hex and press tab then the cursor go to the text. When we press tab again it stay in the text. I have to press Shift+Tab to go to the hex editor and I think that only press tab should be enough. That really doesn't have nothing with navigation but only HexView realted. But there is no big problem if it stay like it's right now. I think that before, pressing the Enter key it toggle between text and hex, but not sure. With the mouse is more easy, of course. Thanks.

@BDisp
Copy link
Collaborator

BDisp commented Oct 11, 2024

Sorry, but I don't understand. The HexEDITOR scenario has only ONE focusable view.

Sorry @tig, I made confusing because I though it was using a TextView. I was a long time I saw the code and I didn't remember that. If we are in editing in the hex and press tab then the cursor go to the text. When we press tab again it stay in the text. I have to press Shift+Tab to go to the hex editor and I think that only press tab should be enough. That really doesn't have nothing with navigation but only HexView realted. But there is no big problem if it stay like it's right now. I think that before, pressing the Enter key it toggle between text and hex, but not sure. With the mouse is more easy, of course. Thanks.

Whoooo. You already did that. Thanks.

@BDisp
Copy link
Collaborator

BDisp commented Oct 11, 2024

I don't understand.

What's wrong with this?

When we don't edit anything, navigating in the hex side will highlight the text side at the hex side position, so the highlighting is always visible. When we are navigating on edited values the text are already highlighted and doesn't highlight the current hex position on the text side, because the attribute is the same, no matter the values was or wasn't edited. I think that if the text was edited then the current position should have a different attribute, because if we are navigating in the text side on edited values, the hex side doesn't highlight the current text position. Thus, we don't know where the current position of the other side is, if the side that have the cursor is navigating, if the values were edited.

@tig
Copy link
Collaborator Author

tig commented Oct 11, 2024

Sorry, but I don't understand. The HexEDITOR scenario has only ONE focusable view.

Sorry @tig, I made confusing because I though it was using a TextView. I was a long time I saw the code and I didn't remember that. If we are in editing in the hex and press tab then the cursor go to the text. When we press tab again it stay in the text. I have to press Shift+Tab to go to the hex editor and I think that only press tab should be enough. That really doesn't have nothing with navigation but only HexView realted. But there is no big problem if it stay like it's right now. I think that before, pressing the Enter key it toggle between text and hex, but not sure. With the mouse is more easy, of course. Thanks.

Whoooo. You already did that. Thanks.

Yeah, this is why this PR aslo adds View.AdvancingFocus events.

The idea is, if someone wants to override the behavior of AdvanceFocus because they have "internal subviews that are not really subviews" like HexView, they can get notified. Here's how HexView does it

    /// <inheritdoc />
    protected override bool OnAdvancingFocus (NavigationDirection direction, TabBehavior? behavior)
    {
        if (behavior is { } && behavior != TabStop)
        {
            return false;
        }

        if ((direction == NavigationDirection.Forward && _leftSideHasFocus)
            || (direction == NavigationDirection.Backward && !_leftSideHasFocus))
        {
            _leftSideHasFocus = !_leftSideHasFocus;
            RedisplayLine (Address);
            _firstNibble = true;

            return true;
        }

        return false;
    }

@tig
Copy link
Collaborator Author

tig commented Oct 11, 2024

I don't understand.
What's wrong with this?

When we don't edit anything, navigating in the hex side will highlight the text side at the hex side position, so the highlighting is always visible. When we are navigating on edited values the text are already highlighted and doesn't highlight the current hex position on the text side, because the attribute is the same, no matter the values was or wasn't edited. I think that if the text was edited then the current position should have a different attribute, because if we are navigating in the text side on edited values, the hex side doesn't highlight the current text position. Thus, we don't know where the current position of the other side is, if the side that have the cursor is navigating, if the values were edited.

How's this?

2gUIJFT 1

@BDisp
Copy link
Collaborator

BDisp commented Oct 11, 2024

How's this?

Wonderful. Thanks.

@tig
Copy link
Collaborator Author

tig commented Oct 11, 2024

This is ready to review again.

@tig
Copy link
Collaborator Author

tig commented Oct 11, 2024

Oops. I pushed my fix to #3757 to a different branch. Just fixed here too.

@tig tig merged commit d6a652b into gui-cs:v2_develop Oct 15, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants