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 options to enable and disable read only mode #14995

Merged
merged 14 commits into from
Mar 22, 2023

Conversation

Swinkid
Copy link
Contributor

@Swinkid Swinkid commented Mar 14, 2023

Summary of the Pull Request

PR adds functionality to enable or disable readOnly mode within panes. This functionality is different to toggling as if you call the same functionality twice, it will not toggle between states.

References and Relevant Issues

Validation Steps Performed

  • Checked readOnly is enabled when command triggered
  • Checked readOnly is enabled when command triggered while read only already enabled
  • Checked readOnly is disabled when command triggered while read only is enabled
  • Checked readOnly stays disabled when command triggered while read only is disabled
  • Checked above with multiple tabs and split panes

PR Checklist

@Swinkid
Copy link
Contributor Author

Swinkid commented Mar 14, 2023

@microsoft-github-policy-service agree

@Swinkid Swinkid marked this pull request as ready for review March 15, 2023 00:57
@Swinkid
Copy link
Contributor Author

Swinkid commented Mar 15, 2023

@zadjii-msft Not sure why PR is failing, unrelated to my code change?

@microsoft-github-policy-service microsoft-github-policy-service bot added Issue-Task It's a feature request, but it doesn't really need a major design. Area-Settings Issues related to settings and customizability, for console or terminal Product-Terminal The new Windows Terminal. labels Mar 15, 2023
src/cascadia/TerminalApp/TerminalTab.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/TerminalTab.cpp Outdated Show resolved Hide resolved
@lhecker
Copy link
Member

lhecker commented Mar 16, 2023

Not sure why PR is failing, unrelated to my code change?

This will be fixed #15002. You can merge with main once that PR is merged.
Edit: I merged it by hand so you can use it right away.

@Swinkid
Copy link
Contributor Author

Swinkid commented Mar 16, 2023

@lhecker Made changes on the back of your review - Has been pushed and is building now.

Merged latest main into branch, but now getting an error to do with my code formatting - resolving that now.

@Swinkid
Copy link
Contributor Author

Swinkid commented Mar 20, 2023

@lhecker @zadjii-msft Whats the next steps? Is there something I need to do to get this progressed?

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, just the one question. The rest looks great to me!

Comment on lines +1594 to +1621
void TerminalTab::SetPaneReadOnly(const bool readOnlyState)
{
auto hasReadOnly = false;
auto allReadOnly = true;
_activePane->WalkTree([&](const auto& p) {
if (const auto& control{ p->GetTerminalControl() })
{
hasReadOnly |= control.ReadOnly();
allReadOnly &= control.ReadOnly();
}
});
_activePane->WalkTree([&](const auto& p) {
if (const auto& control{ p->GetTerminalControl() })
{
// If all controls have the same read only state then just disable
if (allReadOnly || !hasReadOnly)
{
control.SetReadOnly(readOnlyState);
}
// otherwise set to all read only.
else if (!control.ReadOnly())
{
control.SetReadOnly(readOnlyState);
}
}
});
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is all of this logic necessary? Why wouldn't this just be a

WalkTree([&](const auto& p){ 
    if (const auto& control{ p->GetTerminalControl() })
    {
        control.SetReadOnly(readOnlyState);
    }
});

Maybe I just haven't had enough coffee yet

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ill push my changes for this, I dont see any issue when ive tested it.

src/cascadia/TerminalControl/ControlCore.cpp Outdated Show resolved Hide resolved
@Swinkid
Copy link
Contributor Author

Swinkid commented Mar 20, 2023

@zadjii-msft If i take your changes about the tree into account it fails the tests - they must be related to something but can't figure out what. I've tested the changes but it works as it should.

@zadjii-msft
Copy link
Member

If i take your changes about the tree into account it fails the tests - they must be related to something but can't figure out what. I've tested the changes but it works as it should.

That's w a c k y but okay! Thanks for confirming

@zadjii-msft zadjii-msft merged commit 2acdc9d into microsoft:main Mar 22, 2023
Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thanks so much for doing this!

@Swinkid
Copy link
Contributor Author

Swinkid commented Mar 23, 2023

Hey, thanks so much for doing this!

You're welcome - this is why I love opensource.. helping fellow developers out!

DHowett pushed a commit that referenced this pull request Apr 25, 2023
## Summary of the Pull Request
PR adds functionality to enable or disable readOnly mode within panes.
This functionality is different to toggling as if you call the same
functionality twice, it will not toggle between states.

## References and Relevant Issues
- Closes #14415
- Documentation MicrosoftDocs/terminal#645

## Validation Steps Performed
- Checked readOnly is enabled when command triggered
- Checked readOnly is enabled when command triggered while read only
already enabled
- Checked readOnly is disabled when command triggered while read only is
enabled
- Checked readOnly stays disabled when command triggered while read only
is disabled
- Checked above with multiple tabs and split panes

## PR Checklist
- [ ] Closes #14415
- [X] Tests added/passed
- [x] Documentation updated
- If checked, please file a pull request on [our docs
repo](https://github.com/MicrosoftDocs/terminal) and link it here:
MicrosoftDocs/terminal#645
- [X] Schema updated (if necessary)

---------

Co-authored-by: Mike Griese <migrie@microsoft.com>
(cherry picked from commit 2acdc9d)
Service-Card-Id: 89002012
Service-Version: 1.17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Enable/Disable actions alongside "Toggle pane read-only mode"
4 participants