savedra1 / clipse

Configurable TUI clipboard manager for Unix
MIT License
228 stars 8 forks source link

Not clearing screen on Enter to copy and exit #53

Closed BrayanLope5 closed 1 month ago

BrayanLope5 commented 2 months ago

When entering the tui and using Enter to copy an entry, the screen is not cleared. If instead I press q to exit, then it is cleared. I am using the latest release v0.0.71. I am using fish as my shell, wezterm as my terminal emulator, and hyprland as my window manager.

savedra1 commented 2 months ago

Hi @BrayanLope5 :wave:

To make sure I understand, is your desired behaviour for the fish terminal window to stay open after you've made a selection in the clipse TUI? The advice given is to get the terminal window to close after selection, or keep the TUI view open with clipse keep.

If you want the window to close I would recommend binding a command like fish -exec clipse to create a temporary window that closes after the command executes.

If you want the TUI to exit but the terminal window stay open by calling clipse from a persistent window, the clipboard contents would need to be cleared manually as there's nothing implemented to do this.

BrayanLope5 commented 2 months ago

Thank you for the quick reply. And it's I don't think it's about the tui/window not closing. It does close but it leaves behind the last view of the tui. I tried your suggestion -exec or --exec are not valid options in fish. I did fish -c clipse but I get the same problem. I also tried using zsh with zsh -c clipse and I also get the same problem.

The problem is that when I open the tui, then I use the Enter key to copy from the history, I do get back to a new prompt as expected, but right above the new prompt I can still see the last state of the tui. Basically like it's still open but it is not. It is just the last view of the tui in my terminal history. Sorry I can't take a screenshot because I just started setting up hyprland and I don't have a way to take a screenshot yet.

The closest example I could find is on reddit and the first comment makes mention of an "Alternate Screen" and also this other forum.

savedra1 commented 2 months ago

@BrayanLope5 thanks for the update.

If the intended behaviour is for the window to stay open rather than close, you should simply be able to use a command like clipse && clear.

This is not necessarily how the app is intended to be used, but that should help with what you're trying to achieve :)

savedra1 commented 2 months ago

Here's an example Hyprland config I've seen from other users for binding a floating window that exits on selection:

exec-once = clipse -listen 
windowrulev2 = float,class:(floating)
bind = SUPER, V, exec, foot --class floating -e fish -c 'clipse'

EDIT: to force the window to close (if wanted) you could also use

clipse -fc $fish_pid
maydayv7 commented 2 months ago

And it's I don't think it's about the tui/window not closing. It does close but it leaves behind the last view of the tui

I was initially facing this issue when trying to use it as a scratchpad via Pyprland

This currently works well for me:

[scratchpads.clip]
animation = "fromBottom"
command = "kitty --class clipse sh -c 'clipse -fc $PPID'"
class = "clipse"

And then bind it like this:

bind = $mod, V, exec, sh -c "if ! hyprctl clients | grep 'class: clipse'; then pypr show clip; fi"
BrayanLope5 commented 2 months ago

Sorry about the very late reply. I was finally able to figure out how to take screenshots in hyprland.

So, if I run clipse from the terminal, and then I exit WITHOUT copying anything, say by pressing q or Esc, the Tui closes and this is what I get. out_1

But when I do the same except that I press Enter to copy one of the entries, the Tui closes but this is what I am left with. out_2 There is a new prompt but I can still see the last state of the TUI above it.

savedra1 commented 2 months ago

Hi @BrayanLope5 thanks for getting back.

I fully understand the issue. Did you attempt the previous suggestions here from me or @maydayv7? That should help achieve what you're looking for here :smile:

BrayanLope5 commented 1 month ago

I don't use Pyprland and I am not very good with linux either so I don't quite follow what he did. I tried to make it work but I just wasn't able to get what I wanted.

I think he is implementing something like what you show on the docs, a floating window that closes immediately after closing the the Tui because the shell is killed. And I've been able to get something like this working. But sometimes I already have a terminal window open doing something else and I just quickly launch the tui with an alias but then I get the result I showed in the pictures. Not a big deal, I think I'll just go with using an alias like cm="clipse && clear".

savedra1 commented 1 month ago

Thanks for giving it a go @BrayanLope5 :blue_heart:

I'll close this issue with the alias as the solution for now and I'll try and get the selection to mirror the same behavior as exiting with q or esc as part of the next release. Have added it to my notes.

Thanks again for using clipse!

savedra1 commented 1 month ago

@BrayanLope5 found a fix btw. see commit 5dd436b

You can either build this from source or wait for it to be included in the next release :smile: