rgieseke / textredux

Text-based interfaces for Textadept
http://rgieseke.github.io/textredux/
Other
59 stars 11 forks source link

Limit open to one instance #49

Open ghost opened 5 years ago

ghost commented 5 years ago

Currently it's possible to "stack" open dialogs on top of each other. Would it be a good idea to only allow one open dialog at a time? Do you happen to have a clever idea to implement this?

rgieseke commented 5 years ago

That would be a great addition! One way could be to identify the shortcut for „Open file“ and disable/overwrite it in the Textredux dialog. It‘s already found in the hijack function. So maybe it only needs to be re-used.

rgieseke commented 5 years ago

Another way might be to check for a visible Textredux buffer in the current view and re-use this one if a new Textredux buffer is created. This would be a way to go from a "buffer list" to an "open dialog" as well without having to close one Textredux buffer first. (Use-case, realise file not already open, switch to "file open")

ghost commented 5 years ago

Your first suggestion seems to work well enough. There are still some rough edges but it certainly is the right direction.
The other use-case you mention is also interesting, might look into that in the future.

rgieseke commented 5 years ago

Did you just add it manually or did you find a generic way?

ghost commented 5 years ago

Did you just add it manually or did you find a generic way?

Generic but really ghetto. Don't care though since no one except me will use it anyways so it doesn't have to be some super slick solution.

rgieseke commented 5 years ago

I'd care and be happy if you could share it! This would be definitely a good addition to Textredux.

ghost commented 5 years ago

Be my guest. I'll make a feature branch for it soon™.
Just check https://github.com/loomer/textredux/branches in a bit.

ghost commented 5 years ago

As requested the branch exists. Since it's unlikely to get merged in it's current state I'd like to close this. That is unless you see the need for more discussion?

rgieseke commented 5 years ago

I'd like to keep it open because i think it would be a valuable addition - if we find a way that works even if someone doesn't use hijack.

Your version prevents certain keys, maybe the opposite is also possible - explicitly setting permissable keys. Or the other approach could work, re-using Textredux buffers in a view.

ghost commented 5 years ago

I think whitelisting keys would create a much longer list than a blacklist and is IMO not feasible.
The other approach seems more promising but I'm unsure how it could be done. Have you had a chance to think about it?

rgieseke commented 5 years ago

Likely you're right, it could become quite a long list ... (buffer close, quite, switch view, navigate ... on all platforms) -- haven't had a chance to look into filtering on buffer creation ...

rgieseke commented 4 years ago

https://github.com/rgieseke/textredux/commit/5d0941e5c90f20be9a4058631a194b95c552a0bd handles this for the open dialog. One can still open e.g. a buffer list. Still not sure how to handle this (there might be other Textredux buffers a user might want to open) but it seems like an improvement.