Go to top when trying to go past bottom and viceversa in file lister


Trying to do something really simple here, I would like to have an option to go to the last file/folder in a lister when I press UP ARROW being at the first one and viceversa. Currently when you're at the first or last element in a file lister and try to go past it, you stay at that element. Of course, this should only happen when you press UP/DOWN ARROW, not SHIFT+ARROW.

I tried searching for an option but couldn't find any. Then tried to do something with scripting (way overkill, I know) but was unable to find a way to read the current selected element index in a file lister (I found the index column and {sel:index} for the status bar but nothing for scripting).

Thank you.

Note: don't know exactly what's the proper technical name for this feature so feel free to edit the post or the subject to include it.

You can go to the top by pushing the Home key.

I'd call it "wrap-around", which I did :smiley:

You can assign these 2 commands to 2 new lister hotkeys for up & down arrows. It works albeit slower than unmodified arrow keys:

function OnInit(initData) {
    initData.name           = 'CuWrapAround';
    initData.default_enable = true;
    var userCmd;
    userCmd             = initData.addCommand();
    userCmd.name        = 'CuWrapAroundNext';
    userCmd.method      = 'OnAutoWrapAroundNext';
    userCmd.label		= 'Wrap around';
    userCmd.desc        = 'Jumps back to first file after selecting past last file with down arrow';
    userCmd             = initData.addCommand();
    userCmd.name        = 'CuWrapAroundPrev';
    userCmd.method      = 'OnAutoWrapAroundPrev';
    userCmd.label		= 'Wrap around';
    userCmd.desc        = 'Jumps back to last file after selecting past first file with up arrow';
    return false;

function OnAutoWrapAroundNext(cmdData) {
    cmd.runCommand('Select NEXT');
function OnAutoWrapAroundPrev(cmdData) {
    cmd.runCommand('Select PREV');
var cmd = DOpus.create().command();

1 Like

Unless I'm missing something, it would be slightly quicker, and simpler, to not use a script at all and bind the Select NEXT and Select PREV commands to hotkeys directly.

(Instead of a hotkeys which run script commands which just run the real commands without any extra logic on top.)

1 Like

@Leo Indeed, that's much simpler :smiley: I was writing another script, totally fixated at the script idea :smiley:

The behavior is, however, the same. The selection moves and it wrap arounds fine, but if you press the key in a lister where not all files fit into the viewed portion, the selected file moves into viewport after some delay, whereas unmodified arrows keep the selected file always visible. That's why I described it "albeit slower" in my initial reply.

Change the commands to these to make it instant:

Select NEXT MAKEVISIBLE=immediate
Select PREV MAKEVISIBLE=immediate
1 Like

:smiley: Is there anything which you haven't thought about already? :smiley:

Wow, thank you both, binding DOWN ARROW to Select NEXT MAKEVISIBLE=immediate is exactly what I was looking for.