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

💡 [FEAT] Ability to yank and paste entire todo's #76

Closed
atidyshirt opened this issue Nov 18, 2022 · 12 comments
Closed

💡 [FEAT] Ability to yank and paste entire todo's #76

atidyshirt opened this issue Nov 18, 2022 · 12 comments
Labels
completed Issues that are fixed and will be out in the next release enhancement New feature or request

Comments

@atidyshirt
Copy link

Is your feature request related to a problem? 😢 Please describe.

I would like the ability to copy and paste entire todo's between topics, and have the ability to copy multiple todo's.

Describe the solution you'd like 🤔

I would like to have a solution that does the following:

  1. Y to yank entire todo's
  2. Y if triggered on a parent todo, should copy all child todo's to the clipboard
  3. p or P to paste a todo that has been copied
  4. Ideally, If a child node has been copied, it can be made a parent or child todo depending on where it is pasted
  5. A parent node can only be pasted as a parent todo

Describe alternatives you've considered 🧐

An extension of this idea would be to use D to delete and copy the selected todo, and of course I am open to alternative default bindings.

Additional context 📝

I don't know how hard this is to implement as I have only recently started using the app and am loving it so far.

When I have some available time I will take a look at the code and if this is something you would like to include, I would be happy to help.

@atidyshirt atidyshirt added the enhancement New feature or request label Nov 18, 2022
@kraanzu
Copy link
Member

kraanzu commented Nov 18, 2022

Hi @atidyshirt! Thanks for the feature idea!

I was actually wondering how to make such a feature to move the todos within the app! This sounds good and can be a great implementation!

I don't know how hard this is to implement as I have only recently started using the app and am loving it so far.

Thanks, bud! I really appreciate it 😄

When I have some available time I will take a look at the code and if this is something you would like to include, I would be happy to help.

Of course, I am also willing to help if you need any 😄
I saw that you forked the project a couple of hours ago. Just wanted you to know that you should ignore the main branch and have a look at the redesign branch as the implementation is kinda totally different 😅
That'll make it easier to implement stuff 😃

@atidyshirt
Copy link
Author

Hi @kraanzu, Oh I have been working on this using the main branch, thanks for letting me know :)

I will switch branches and take a look at how to bring my implementation across. (I have never used rich or TUI interfaces in python before, but starting to understand the code now).

Hopefully I will be back with a PR soon

@kraanzu
Copy link
Member

kraanzu commented Nov 18, 2022

Awesoome! Good luck :)

Here's the documention for textual if you need any help:
https://textual.textualize.io/

@atidyshirt
Copy link
Author

Quick question, I am guessing that the redesign branch is a bit of a work in progress? I.e a massive refactor of the entire project, is there by chance a list of known bugs on this branch at all?

Just wondering as I have seen some weird events while debugging and am not sure if it is the new code or if I have configured something wrong or written some bad code 😄

@kraanzu
Copy link
Member

kraanzu commented Nov 18, 2022

Haha...thought so! But there aren't many now :(
Ummm... If you can maybe wait for one more day? I guess I'll finish it up ( there will be bugs surely but I'll try to solve most of them by Sunday? )

this is the test file I use which should run the app:

from dooit.__init__ import main
main()

Can I ask what Kind of issues are you facing? Have you upgraded textual to the latest version?

@atidyshirt
Copy link
Author

atidyshirt commented Nov 18, 2022

I think I may have introduced one, not sure. I have experienced occasional freezing and sometimes TODO's get removed if we do things too quickly (I think some async issue).

Issues (at least in my build env...) first time using poetry so could be doing something wrong;

  • Cannot quit using ctrl + q
  • Cannot use escape to exit help menu
  • Freezing (seems to be when doing things quickly)
  • Sometimes todo's go away (I think I have caused this)

Potentially its the way I am running it, my current method is using these three commands:

poetry shell
poetry run dooit
poetry install

Do not feel pressured at all, I am in no rush 😄 , just curios if there was any known issues.

Might also be note worthy that I am currently on a ARM Macbook

@kraanzu
Copy link
Member

kraanzu commented Nov 18, 2022

we do things too quickly (I think some async issue)

Hmm.. This might be because well I'm updating the data and then re-updating the UI. I'll have to optimize this :)

Cannot quit using ctrl + q

Oh you can use ctrl+c for now. I thought I would take care of these stuffs in the end haha

Cannot use escape to exit help menu

Hmm...this should be running fine. Will check!

Sometimes todo's go away (I think I have caused this)

Haha Probably :)

atidyshirt added a commit to atidyshirt/dooit that referenced this issue Nov 18, 2022
CHANGES:

- Implemented `insert_item` method
  * NOTE: this should probably be updated to be independent of
    `Storage.clipboard` function as this might be nice to re-use.
  * TODO: Update this method to take in a parameter to insert a node and
    its sub-entities.
- Added `Storage.clipboard` singleton class to store elements of any
  type on the clipboard.
- Added wrapper functions in `todo_list` and `tree` for insert method
atidyshirt added a commit to atidyshirt/dooit that referenced this issue Nov 18, 2022
CHANGES:

- Added a flag to be passed through to indicate whether to be pusing the
  result as a child node or as a parent node
- Enforcing that we are clearing the paste bin on each paste
- Refactored the `insert_item` method as a generic (independent of using
  clipboard or not), can now be re-used for future functionality
@atidyshirt
Copy link
Author

Thats all I have in me tonight! Couple of notes on this:

If you can think of a better method to handle the clipboard management then the implemented method, I am all ears (i.e the following):

@dataclass
class S_Storage:
    instance = None
    def __init__(self):
        S_Storage.instance = self
        self._clipboard = None

class Storage:
    clipboard = S_Storage.instance._clipboard if S_Storage.instance else S_Storage()._clipboard

There is still a couple of things to fix in here, will submit a PR when this is ready

@kraanzu
Copy link
Member

kraanzu commented Nov 18, 2022

Awesome! This looks good. Thanks for the wonderful addition!

There is still a couple of things to fix in here, will submit a PR when this is ready

Yep Yep. I'll work on it too and hopefully remove some bugs along the way :)

@kraanzu
Copy link
Member

kraanzu commented Nov 18, 2022

Cannot quit using ctrl + q

Done!

Cannot use escape to exit the help menu

Fixed!

Freezing (seems to be when doing things quickly)

I've implemented lazy load. Can you check if it's still freezing for ya?

Edit:

I've implemented lazy load. Can you check if it's still freezing for ya?

Nah Ig this ain't making any difference. It's the framework :(

@atidyshirt
Copy link
Author

atidyshirt commented Nov 19, 2022

I will retest tomorrow and see if what problems are present, pasting todos is now functional, 'P' go paste as child, 'p' to paste as sibling, and todo's are copied using the 'remove' method ('x') (removed and copied node to the clipboard).

I have a couple of questions about copying todo's, I have noticed that we cannot have two todos with the same description at the same level? So as far as implementing copy, I guess we want to achieve the following implementation:

  • Copy a Todo to clipboard
  • Extend pasting method to do as follows
    ** Pasting will only paste node if List[TreeNode] does not contain the existing node

Is this how you would want it to work?

Possibly implemented with 'y' for copying the node and only description with 'Y' would be my personal preference of keybinds, but as they are interchangable I'm happy to set the defaults to anything 😀

@kraanzu
Copy link
Member

kraanzu commented Nov 19, 2022

I have noticed that we cannot have two todos with the same description at the same level?

Yes, that is correct! That makes some implementation stuff easier (when the todos are changed in some other instance or changed through some plugins i.e the change in data file is not done by the user using the current instance)
The only case I see where you need the same todo description is to do some recurring tasks such as:

  • Solve a problem every day
  • Get a haircut every 6 weeks

For that, I've implemented recurring tasks which when marked as completed just shift their date accordingly

Possibly implemented with 'y' for copying the node and only description with 'Y' would be my personal preference

I suppose we can include some of the special keybindings in the configuration file to tweak as per the user's preference
I was also thinking to implement multi-key presses as we have in vim (if you are familiar) such as <space>p and dd but that would require some good implementation. We can do that tho!

@kraanzu kraanzu added completed Issues that are fixed and will be out in the next release enhancement New feature or request and removed enhancement New feature or request labels Aug 14, 2023
kraanzu added a commit that referenced this issue Aug 14, 2023
@kraanzu kraanzu closed this as completed in 2dbcc62 Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completed Issues that are fixed and will be out in the next release enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants