IsaacElenbaas / fff

📁 A simple file manager written in bash.
MIT License
0 stars 0 forks source link

Can't use arrow keys to edit in rename/mkdir etc. #3

Open IsaacElenbaas opened 4 years ago

IsaacElenbaas commented 4 years ago

Disabling keybinds temporarily or permanently prevents going up a directory, but the cursor doesn't move.

IsaacElenbaas commented 3 years ago

My test implementation might not have worked because I wasn't getting the full escape sequence, which was just fixed in 63e3e0e. Should try again.

bogdan-the-great commented 11 months ago

Hi! I added this ability in my fork of fff. You can move around with arrow keys, delete every character from filename and filename is added for you to edit, not to write again. Also I added shortcut - ctrl + a which moves cursor to the beginning of the filename.

IsaacElenbaas commented 10 months ago

Thanks for the heads-up - I would love to steal it, but unfortunately this fork is not up to date. I semi-recently basically redid fff from scratch to make it even fucking faster, fix key queueing and improve prompt handling in a clean way globally (+ a bunch of other random issues), and make it modular and extensible to be used as a selector by my other scripts. I am just lazy and copied that between my machines instead of cleaning it up, commiting, and pushing :stuck_out_tongue_closed_eyes:

bogdan-the-great commented 10 months ago

Well, I would like to steal it too. Would you kindly upload it somewhere? I'm currently working on fixing and adding some stuff to my fork too.

IsaacElenbaas commented 10 months ago

I was going to wrap it up this weekend and push but apparently it is a lot further from ready than I thought haha. I'll procrastinate some more. Attached what I have as .txt because Github only takes certain filetypes.

I am not sure how much you could take from it given how divorced from the original it is. One of the more worthwhile improvements was separating resize signal handling and key reading from the main thread, however, and that could be copied - line 777 to the end. It looks horrible but you can get rid of the while loop I use for my state handling which is the bulk of the mess - line 828 to 878 - and just call the fff key function like the original.

The f_prompt_draw section might also be worth a look if you want to support characters that are printed with a width > 1 in the terminal for prompts. Not very useful but nice if you accidentally presses ctrl and a key while trying to rename or something like that.

I have used this for one other script already as a selector w/ search for something that generates a bunch of entries. If I remember correctly one defines a bunch of state_draw and state_key functions and an f_base_key to go to the other states (e.g. rename when you hit r) before sourcing fff-base. fff-base.txt fff.txt

bogdan-the-great commented 10 months ago

Thanks. It looks like neovim to vim "Neovim is a project that seeks to aggressively refactor Vim". What these #{{{ cmd_line() before function statements do?

IsaacElenbaas commented 10 months ago

Those are manual fold markers. When I open the file each is collapsed into one line which is highlighted and displays the text following the three open curly braces (e.g. cmd_line()) and then I can go over one and hit a bind to open or close it. For large single-file things like this they are very helpful for organization.

The indentation is just my convention, I indent each fold comment according to how many fold comments it is nested in.