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

[DRAFT] Clipboard History #151

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft

Conversation

joadoumie
Copy link
Collaborator

@joadoumie joadoumie commented Nov 12, 2024

This is at a reasonable place right now, but still needs some TLC before it is finished... and I got a little stuck so switching gears for sanity's sake.

My primary issue was trying to figure out how to use IRandomAccessStream as a valid ctor param and wiring that all up... I tried... and I'm reverting back to this commit and PR.

Here are the main things that need to be added:

  • IRandomAccessStream can be passed as the Hero Image in the details view -- this stumped me for now.
  • Event Handler for new clipboard events and raise items changed in that case to update the list items with whatever changes were made to the clipboard history (marked as TODO in code)
  • Clean up the details pane so the previews look cleaner
  • Fix the weird behavior for CommandResult.Dismiss() not giving the right level of focus back to the window before (e.g. Word has cursor focus, command palette is launched, command is invoked, dismiss() is called, Word should have focus WITH the cursor again)
  • Add ShowToast result when copying

@zadjii-msft zadjii-msft mentioned this pull request Dec 9, 2024
zadjii-msft added a commit that referenced this pull request Dec 10, 2024
This adds a magic helper to load icons for us. Any time you want an icon, just do this:

```xaml
<Border Width="16"
        Height="16"
        Margin="4,4,4,4">
    <Interactivity:Interaction.Behaviors>
        <cmdpalUI:LoadIconBehavior Source="{x:Bind ViewModel.PrimaryAction.Icon, Mode=OneWay}"/>
    </Interactivity:Interaction.Behaviors>
</Border>
```

And that'll magically give us a border filled with the icon, and updating with the binding.

I believe it'll also work with `IRandomAccessStreamReference`s, but I didn't actually test that with #151 yet. 

I didn't actually implement the "caching" bit of this yet. That'll involve doing some locking per-key inside the factory and I didn't want to futz with that in this initial PR to restore icons

---------

Co-authored-by: Mike Griese <[email protected]>
@zadjii-msft
Copy link
Owner

For my own notes:

@zadjii-msft
Copy link
Owner

GAH we can't use randomaccessstreams in icons till #333 is fixed

@zadjii-msft
Copy link
Owner

go look at f25302a

namespace Microsoft.CmdPal.UI.Deferred;

/// <summary>
/// Extensions to <see cref="TypedEventHandler{TSender, TResult}"/> for Deferred Events.

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

TSender is not a recognized word. (unrecognized-spelling)
namespace Microsoft.CmdPal.UI.Deferred;

/// <summary>
/// Extensions to <see cref="TypedEventHandler{TSender, TResult}"/> for Deferred Events.

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

TResult is not a recognized word. (unrecognized-spelling)
public static class TypedEventHandlerExtensions
{
/// <summary>
/// Use to invoke an async <see cref="TypedEventHandler{TSender, TResult}"/> using <see cref="DeferredEventArgs"/>.

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

TSender is not a recognized word. (unrecognized-spelling)
public static class TypedEventHandlerExtensions
{
/// <summary>
/// Use to invoke an async <see cref="TypedEventHandler{TSender, TResult}"/> using <see cref="DeferredEventArgs"/>.

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

TResult is not a recognized word. (unrecognized-spelling)
/// </summary>
/// <typeparam name="S">Type of sender.</typeparam>
/// <typeparam name="R"><see cref="EventArgs"/> type.</typeparam>
/// <param name="eventHandler"><see cref="TypedEventHandler{TSender, TResult}"/> to be invoked.</param>

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

TSender is not a recognized word. (unrecognized-spelling)
/// </summary>
/// <typeparam name="S">Type of sender.</typeparam>
/// <typeparam name="R"><see cref="EventArgs"/> type.</typeparam>
/// <param name="eventHandler"><see cref="TypedEventHandler{TSender, TResult}"/> to be invoked.</param>

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

TResult is not a recognized word. (unrecognized-spelling)
where R : DeferredEventArgs => InvokeAsync(eventHandler, sender, eventArgs, CancellationToken.None);

/// <summary>
/// Use to invoke an async <see cref="TypedEventHandler{TSender, TResult}"/> using <see cref="DeferredEventArgs"/> with a <see cref="CancellationToken"/>.

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

TSender is not a recognized word. (unrecognized-spelling)
where R : DeferredEventArgs => InvokeAsync(eventHandler, sender, eventArgs, CancellationToken.None);

/// <summary>
/// Use to invoke an async <see cref="TypedEventHandler{TSender, TResult}"/> using <see cref="DeferredEventArgs"/> with a <see cref="CancellationToken"/>.

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

TResult is not a recognized word. (unrecognized-spelling)
/// </summary>
/// <typeparam name="S">Type of sender.</typeparam>
/// <typeparam name="R"><see cref="EventArgs"/> type.</typeparam>
/// <param name="eventHandler"><see cref="TypedEventHandler{TSender, TResult}"/> to be invoked.</param>

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

TSender is not a recognized word. (unrecognized-spelling)
/// </summary>
/// <typeparam name="S">Type of sender.</typeparam>
/// <typeparam name="R"><see cref="EventArgs"/> type.</typeparam>
/// <param name="eventHandler"><see cref="TypedEventHandler{TSender, TResult}"/> to be invoked.</param>

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

TResult is not a recognized word. (unrecognized-spelling)
Copy link

github-actions bot commented Feb 5, 2025

@check-spelling-bot Report

🔴 Please review

See the 📂 files view, the 📜action log, or 📝 job summary for details.

Unrecognized words (2)

TResult
TSender

These words are not needed and should be removed AVery mtu rsdk

To accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands

... in a clone of the [email protected]:zadjii-msft/PowerToys.git repository
on the joadoumie/clipboard-history branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.24/apply.pl' |
perl - 'https://github.com/zadjii-msft/PowerToys/actions/runs/13156797219/attempts/1'

OR

To have the bot accept them for you, comment in the PR quoting the following line:
@check-spelling-bot apply updates.

Errors (1)

See the 📂 files view, the 📜action log, or 📝 job summary for details.

❌ Errors Count
❌ ignored-expect-variant 5

See ❌ Event descriptions for more information.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CommandResult.Dismiss() should leave the user in the precise state they were in before launching
3 participants