4coder»Forums
60 posts
None
Move up and down in lister with custom keys
Edited by erpeo93 on
Hi,

so I'm playing around and trying to customize 4coder, and one of the things I'd like to do is to change the way I move up or down into listers.
As far as I can tell, it seems like the KeyCode_Up and KeyCode_Down are just hardcoded into the run_lister function.

Sure I can add the two KeyCodes I want in there, but then I would have to modify the code everytime a new 4coder version comes out.

Is there a better way to do this?

I was thinking about two possible solutions, but idn if any of these two are implemented:

1) some sort of hook that gets attached to all listeners, and in there I just handle my two special cases
2) a way to detect if there's an active listener, so that in my custom command I can:
1
2
3
4
5
6
CUSTOM_COMMAND_SIG(move_lister_up)
Listener* listener = detect_active_listener();
             if(listener)
             {
                    MoveUp(listener);
             }



For reference, here's the part of the run_lister function that I'm talking about:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
                    case KeyCode_Up:
                    {
                        if (lister->handlers.navigate != 0){
                            lister->handlers.navigate(app, view, lister, -1);
                        }
                        else if (lister->handlers.key_stroke != 0){
                            result = lister->handlers.key_stroke(app);
                        }
                        else{
                            handled = false;
                        }
                    }break;
                    
                    case KeyCode_Down:
                    {
                        if (lister->handlers.navigate != 0){
                            lister->handlers.navigate(app, view, lister, 1);
                        }
                        else if (lister->handlers.key_stroke != 0){
                            result = lister->handlers.key_stroke(app);
                        }
                        else{
                            handled = false;
                        }
                    }break;
                    


Leonardo
Simon Anciaux
1337 posts
Move up and down in lister with custom keys
Edited by Simon Anciaux on
There is no better way than to modify the run_lister function. There is a section about that in 4coder's wiki.

In addition to that I personally put files that I copy from or modify under source control so that when there is a 4coder update, I can diff the files to know if I need to update my customization with fixes from Allen.

erpeo93
1) some sort of hook that gets attached to all listeners, and in there I just handle my two special cases


A solution I think would be to have a special key map for the listers.

erpeo93
2) a way to detect if there's an active listener, so that in my custom command I can:


By default, when a lister is on the screen, there are no key map set. So you can't use any commands.

Edit: I thought that 4.1.6 removed the binding to `mapid_global` when a lister is visible. After checking `mapid_global` is still active and so you should be able to call commands.