losnoco / Cog

Cog - A Free and Open Source Audio Player for macOS 10.13+
https://cog.losno.co
GNU General Public License v2.0
700 stars 45 forks source link

Add "Show in the File Tree" functionality #271

Open gkarag opened 2 years ago

gkarag commented 2 years ago

I have a long list of folders in the file tree pane. For one or another reason when the tree is scrolled in the pane or folders are expanded or collapsed it can be difficult to find the place of the currently selected folder or file.

I would like to have in the context menu of the files in the playlist to have a new item "Show in the File Tree" and as a consequence of selecting it, the file would show in the folder structure in the file tree pane.

LennyLip commented 2 years ago

I wanted to create the same issue, but it's already here. Some inspiration can be found in JetBrains IDE. Button for select opened file in the tree:

Screenshot 2022-07-17 at 18 46 16
kode54 commented 2 years ago

And that only has "inspiration" in showing me how it should behave, not how to code it. Because that IDE is written in Java, and I need to write this in native Cocoa code, either Objective C or Swift.

kode54 commented 2 years ago

Not to diss this. I like the idea. I can try to implement this one soonish. I just need to implement functionality into the tree handler. Single file highlighting will be a lot easier than making a full search feature as requested elsewhere.

kode54 commented 2 years ago

I'm just kind of taking a bit of a break right now, because my last few days of marathons have left me dreaming about coding stuff, and that annoys me as I think of the wackiest things while doing that, and none of them are all that useful, and I have a hard time tearing away from it to actually drag myself out of bed in the morning.

LennyLip commented 2 years ago

And that only has "inspiration" in showing me how it should behave, not how to code it. Because that IDE is written in Java, and I need to write this in native Cocoa code, either Objective C or Swift.

I meant just how it can look and works. I can't help, not familiar with Apple programming languages. But thank you for your hard work and take you time.

kode54 commented 2 years ago

It won't be hard to focus a single item. There's already code in the tree implementation to pick out the node for a given path. The only problem is, if you haven't expanded a particular node, its contents aren't filled in yet. So walking down the tree to a particular item will involve asynchronously expanding a node, waiting for its contents to be enumerated, then walking further down the tree.

Contents stay cached and remain resident in the tree even if you close a node later, but are lost when you quit the app and restart it. Naturally, I could abuse the method that is used to restore the preferences settings that remember which branches you've expanded.

gkarag commented 2 years ago

For the record I happen to use an open source editor on Mac, TextMate, that has such functionality. It has "File Browser" menu from which one could select the currently edited file that may not be immediately selected in the browser.