nightroman / FarNet

Far Manager framework for .NET modules and scripts in PowerShell, F#, JavaScript.
https://github.com/nightroman/FarNet/wiki
BSD 3-Clause "New" or "Revised" License
136 stars 19 forks source link

Explorer problems #13

Closed jesterret closed 7 years ago

jesterret commented 7 years ago
  1. Exiting Explorer returned from OpenFile closes parents panel, also without notifying on UIClosing, not letting to interrupt. Is that intended behaviour? If so, is there a way to implement file explorer chaining (like archive within archive)?
  2. First created Explorer does not notify ExploreParent until other folder is opened.
  3. After setting CanExploreLocation, only File.Name is passed to GetContent & OpenFile, without File.Data
nightroman commented 7 years ago
  1. I need some more details:

    • What do you want to do in OpenFile?
    • How do you code this?
  2. I do not understand the description of the problem, to be honest.

  3. From the brief description, it looks normal. If an explorer use ExploreLocation then

/// It implements <see cref="Explorer.ExploreLocation"/>, works with pure paths, i.e. files without <see cref="FarFile.Data"/>.

Please do not be shy to provide more details and describe the scenarios you are coding. Some pieces of your code will help, too. Note that I wrote this API several years ago.

jesterret commented 7 years ago
  1. I basically expected OpenFile to allow me to handle specific file format like a directory, so that I can view it, and after go back to where I was earlier. Kind of like with arclite plugin, where you can explore archive within archive within archive etc, but here it would just return to original file directory instead of previous archive object. Here's my code, but basically returning any explorer in OpenFile, even empty one and trying to go back just closes the panel instead of returning control to parent explorer. My use case is viewing Unreal Engine 4's pak file. Within this file, in some directory is a Vorbis sound bank, which is basically storing audio tracks in a file. I'd like to be able to view the bank file and return to viewing pak file after.

  2. Maybe I'm initializing Explorer in a wrong way, but basically Location isn't applied (just empty line) and ExploreParent isn't called for the first Explorer, after ExploreDirectory is called and returns valid explorer, UIExplorerEntered is called for the first time, ExploreParent returns previous Explorer and then Location is applied and ExploreParent will be called. Example: Created empty Explorer, going back to parent folder, UIExplorerEntered and ExploreParent aren't called at all. Created Explorer with single directory, open directory, ExploreDirectory is called as expected, go back to original folder, UIExplorerEntered and ExploreParent are called twice.

  3. Oh, ok, got it. Didn't see that, since neither description of ExploreLocation nor CanExploreLocation mentions that, only function enum which I'm not using in code, so it felt like changing one thing that would allow to view directory size and do recursive search without changing the code breaks other stuff. Thanks for clarifying.

nightroman commented 7 years ago

(1) I think you mix two concepts and two kinds of code and operation in your descriptions.

The problem you are describing is about panels. I need to see your panel code. Just a guess, I think you do not open the child panel as a child. As a result, you just replace the current panel with a new one instead of making a stack of panels (sound like you want this).

Here is what the default UIOpenFile does: https://github.com/nightroman/FarNet/blob/3d6d4f4d9f7f0d8df71bedb6f4caa026d231b382/FarNet/FarNet/Panel.UI.cs#L495

Note that it opens the child panel by explorer.OpenPanelChild(this).

In other words, if you program correctly, i.e. open a new panel as a child then closing the new panel should get you to the old panel as it was on opening. I guess at some point you override something incorrectly and open a new panel directly, not as a child.

nightroman commented 7 years ago

(3) Mind you, if you use File.Data (OO "locations" instead of "paths") then you should not use the approach with ExploreLocation (pure text paths and nothing else). They are orthogonal.

nightroman commented 7 years ago

(2) more details, please

nightroman commented 7 years ago

(2) Here is the example of 4 different explorers and panels in 1: https://github.com/nightroman/FarNet/blob/master/PowerShellFar/Bench/Test/Test-Explorer-.ps1

It's PowerShell and the script is for PowerShellFar. But ideas of coding and API is similar.

The 4th explorer "Location" is the location kind, your kind. It works fine, i.e. when we enter "Location" and open the panel of this explorer and the go up then the parent path panel is opened. That means all works fine.

I think if your current location/"path" is empty then you cannot expect going up. Something wrong is with your paths model, I think.

jesterret commented 7 years ago
  1. As you noticed I'm using default panel, just changing some visual properties. So, not overriding any panel methods
  2. Basically any location I've tried is ignored, made a gif illustrating it. And yes, it does have parent ".." item, but it handles it like explorer doesn't exist
nightroman commented 7 years ago

But it looks like you do not have any parent location according to your current path (empty?).

nightroman commented 7 years ago

BTW, when you are in the root (just opened the first panel) what you expect on going up?

jesterret commented 7 years ago

But it looks like you do not have any parent location according to your current path (empty?).

That's the problem, idk why it doesn't apply location I pass until I explore something and go back.

BTW, when you are in the root (just opened the first panel) what you expect on going up?

Getting ExploreParent called so that I may set PostName, close pak file handle and allow it to clean up memory. The location at the bottom would be nice, but not necessary.

nightroman commented 7 years ago

(1) I think your problem is that in OpenFile you return a different explorer type. The same panel is reused with new Explorer. You may need to override open file and instead of letting FarNet do things open you child panel yourself.

UPD: Not sure, perhaps ignore that. I do not see your model clearly yet.

nightroman commented 7 years ago

That's the problem, idk why it doesn't apply location I pass until I explore something and go back.

Did you define/override the property Location in your explorer?

jesterret commented 7 years ago
  1. Tried opening just empty explorer of the same type, same thing. I believe it's connected to (2), added directory to this empty explorer, opened it, went back and now it works like expected. So, fix to (2) should be a fix to this as well

  2. It's not virtual/abstract so I can't override. No overlapping definitions either. I'm assigning it here, actually passing string.Empty here, but locally changing that to whatever, doesn't register.

nightroman commented 7 years ago

OK, so all looks like by design (though it does not do what you want).

Hint: If you want "up" to work then think of some artificial "root" in your paths models. I.e. avoid empty locations. Empty means "you cannot go up".

nightroman commented 7 years ago

I.e. something like "Pak\something". Then you will get "go to the parent" working as you want.

jesterret commented 7 years ago

Are you sure? Seems like an odd design decision, this is how it behaves right now (it's ~30s, it doesn't loop right away). But sure, I can work around it that way.

nightroman commented 7 years ago

Odd design of what? FarNet is the API to the Far panel model. It adds some helpers, yes, but overall it just follows some rules.

nightroman commented 7 years ago

NB Gifs are not so helpful (sorry, if it is me a bit slow). Better try to explain in words.

nightroman commented 7 years ago

NB To be honest, I would not call this "odd". Far is initially designed to work with paths. An empty path means "no parent". Is this odd? It seems to be normal.

jesterret commented 7 years ago

No no, I understand that, no issue here. My problem is with the fact that the first Explorer object is not registered as actually existing by the panel, until a child explorer is used. As I said before, UIExplorerEntered is not called leading me to believe that Panel doesn't register explorer as valid or something. I can see that it's actually set in Panel.Explorer, but it doesn't parse it properly in my understanding

An empty path means "no parent"

Ok, but even if I'm setting the path, to the filesystem path + filename + my locations after, it's ignored until I explore directory. That's what's odd for me.

jesterret commented 7 years ago

Like, you're even setting a "*" as a Location if no location was provided here, but it's also ignored until some folder is opened.

nightroman commented 7 years ago

I suggested Pak\something, not *, please try this, too. Make you sure you see this path in your panel.

Anyway, I will investigate if you provide a problem sample that I can compile and see what's happening. Otherwise, it is a little difficult to guess just looking at GitHub source pages.

nightroman commented 7 years ago

Here is some simple panel project to start with a sample: https://github.com/nightroman/FarNet/tree/master/Modules/TryPanelCSharp

jesterret commented 7 years ago

Ok, added bare minimum of code needed to show what I'm talking about. https://github.com/jesterret/ExplorerExample I'd expect that it would always show the message on the ExploreParent and the location it was set to.

nightroman commented 7 years ago

Thank you, now I see what you mean. Let me investigate.

nightroman commented 7 years ago

For some historical or technical reasons panels have their own CurrentLocation. In some cases they are synced with explorers locations automatically ("second" explorer and panel in your case), in some cases they are not ("first" panel). Maybe it's the bug but a quick fix breaks some tests, so maybe it's a feature.

I need some time in order to fix this properly. But hopefully I can suggest a workaround. In your explorer override EnterPanel and for the passed panel set its CurrentLocation explicitly. I think this should solve your problem for now.

jesterret commented 7 years ago

Thanks a lot, I really appreciate it :)

nightroman commented 7 years ago

Done, hopefully, you can remove the workaround. I also tweaked help a little bit, as you mentioned.