Skip to content

Commit

Permalink
cleanup and comments before the PR
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Feb 17, 2023
1 parent 0e0d857 commit 091660e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 20 deletions.
6 changes: 5 additions & 1 deletion src/cascadia/Remoting/Monarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,11 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE),
TraceLoggingKeyword(TIL_KEYWORD_TRACE));

// TODO! create a window for that name / ID?
// TODO GH#5000
//
// In the case where window couldn't be found, then create a window
// for that name / ID. Do this as a part of tear-out (different than
// drag/drop)
}
}
}
30 changes: 17 additions & 13 deletions src/cascadia/TerminalApp/Pane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,23 +175,27 @@ NewTerminalArgs Pane::GetTerminalArgsForPane(const bool asContent) const
// Arguments:
// - currentId: the id to use for the current/first pane
// - nextId: the id to use for a new pane if we split
// - asContent: We're serializing this set of actions as content actions for
// moving to other windows, so we need to make sure to include ContentGuid's
// in the final actions.
// - asMovePane: only used with asContent. When this is true, we're building
// these actions as a part of moving the pane to another window, but without
// the context of the hosting tab. In that case, we'll want to build a
// splitPane action even if we're just a single leaf, because there's no other
// parent to try and build an action for us.
// Return Value:
// - The state from building the startup actions, includes a vector of commands,
// the original root pane, the id of the focused pane, and the number of panes
// created.
Pane::BuildStartupState Pane::BuildStartupActions(uint32_t currentId, uint32_t nextId, const bool asContent, const bool asMovePane)
{
// TODO! I f'ed something up here recently. Just moving a single pane no longer seems to work.
//
// If we call this directly on a leaf, then CURRENTLY, we'll return {} for
// the actions. Moving that will just move nothing, cause obviously.
//
// But this all works fine for a _tab_, where there's a parent Tab to build
// a newTab action first.
//
// So if we're moving a pane, as content, then we need to special case here where even moving just us returns a splitPane

// if we are a leaf then all there is to do is defer to the parent.
Pane::BuildStartupState Pane::BuildStartupActions(uint32_t currentId,
uint32_t nextId,
const bool asContent,
const bool asMovePane)
{
// Normally, if we're a leaf, return an empt set of actions, because the
// parent pane will build the SplitPane action for us. If we're building
// actions for a movePane action though, we'll still need to include
// ourselves.
if (!asMovePane && _IsLeaf())
{
if (_lastActive)
Expand Down
26 changes: 24 additions & 2 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1889,6 +1889,8 @@ namespace winrt::TerminalApp::implementation
return false;
}

// If there was a windowId in the action, try to move it to the
// specified window instead of moving it in our tab row.
if (!windowId.empty())
{
if (const auto terminalTab{ _GetFocusedTabImpl() })
Expand Down Expand Up @@ -1934,6 +1936,8 @@ namespace winrt::TerminalApp::implementation
return true;
}

// Detach a tree of panes from this terminal. Helper used for moving panes
// and tabs to other windows.
void TerminalPage::_DetachPaneFromWindow(std::shared_ptr<Pane> pane)
{
pane->WalkTree([&](auto p) {
Expand All @@ -1946,13 +1950,18 @@ namespace winrt::TerminalApp::implementation

void TerminalPage::_DetachTabFromWindow(const winrt::com_ptr<TerminalTab>& terminalTab)
{
// Collect all the content we're about to detach.
// Detach the root pane, which will act like the whole tab got detached.
if (const auto rootPane = terminalTab->GetRootPane())
{
_DetachPaneFromWindow(rootPane);
}
}

// Method Description:
// - Serialize these actions to json, and raise them as a RequestMoveContent
// event. Our Window will raise that to the window manager / monarch, who
// will dispatch this blob of json back to the window that should handle
// this.
void TerminalPage::_MoveContent(std::vector<Settings::Model::ActionAndArgs>& actions,
const winrt::hstring& windowName,
const uint32_t tabIndex)
Expand All @@ -1967,6 +1976,8 @@ namespace winrt::TerminalApp::implementation

bool TerminalPage::_MoveTab(MoveTabArgs args)
{
// If there was a windowId in the action, try to move it to the
// specified window instead of moving it in our tab row.
const auto windowId{ args.Window() };
if (!windowId.empty())
{
Expand Down Expand Up @@ -1994,7 +2005,18 @@ namespace winrt::TerminalApp::implementation
return true;
}

winrt::fire_and_forget TerminalPage::AttachContent(winrt::hstring content, uint32_t tabIndex)
// Method Description:
// - Called when it is determined that an existing tab or pane should be
// attached to our window. content represents a blob of JSON describing
// some startup actions for resbuilding the specified panes. They will
// include `__content` properties with the GUID of the existing
// ControlInteractivities we should use, rather than starting new ones.
// - _MakePane is already enlightened to use the ContentGuid property to
// reattach instead of create new content, so this method simply needs to
// parse the JSON and pump it into our action handler. Almost the same as
// doing something like `wt -w 0 nt`.
winrt::fire_and_forget TerminalPage::AttachContent(winrt::hstring content,
uint32_t tabIndex)
{
auto args = ActionAndArgs::Deserialize(content);

Expand Down
4 changes: 0 additions & 4 deletions src/cascadia/TerminalSettingsModel/ActionArgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
JsonUtils::GetValueForKey(json, SuppressApplicationTitleKey, args->_SuppressApplicationTitle);
JsonUtils::GetValueForKey(json, ColorSchemeKey, args->_ColorScheme);
JsonUtils::GetValueForKey(json, ElevateKey, args->_Elevate);

// TODO! We should probably have the ContentGuid be optional, or at
// least serialized smarter, so we definitely don't write it to the
// file, ever.
JsonUtils::GetValueForKey(json, ContentKey, args->_ContentGuid);
return *args;
}
Expand Down

1 comment on commit 091660e

@github-actions
Copy link

Choose a reason for hiding this comment

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

@check-spelling-bot Report

🔴 Please review

See the 📜action log for details.

Unrecognized words (2)

Interactivities
resbuilding

Previously acknowledged words that are now absent CLA demoable everytime Hirots inthread reingest unmark :arrow_right:
To accept ✔️ these unrecognized words as correct and remove the previously acknowledged and now absent words, run the following commands

... in a clone of the git@github.com:microsoft/terminal.git repository
on the dev/migrie/oop/3/quenta-silmarillion branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.21/apply.pl' |
perl - 'https://github.com/microsoft/terminal/actions/runs/4205901781/attempts/1'
✏️ Contributor please read this

By default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.

⚠️ The command is written for posix shells. If it doesn't work for you, you can manually add (one word per line) / remove items to expect.txt and the excludes.txt files.

If the listed items are:

  • ... misspelled, then please correct them instead of using the command.
  • ... names, please add them to .github/actions/spelling/allow/names.txt.
  • ... APIs, you can add them to a file in .github/actions/spelling/allow/.
  • ... just things you're using, please add them to an appropriate file in .github/actions/spelling/expect/.
  • ... tokens you only need in one place and shouldn't generally be used, you can add an item in an appropriate file in .github/actions/spelling/patterns/.

See the README.md in each directory for more information.

🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Please sign in to comment.