4coder»Forums
Anton Swifton
32 posts / 1 project
PhD Student in Math at the University of South Carolina.
A question on seek_whitespace_right.
Edited by Anton Swifton on Reason: Initial post
Hello Allen!

I was trying to customize the bindings and found this code in remapping.h:

1
2
bind(context, key_right, MDFR_CTRL, seek_whitespace_right);
bind(context, key_left, MDFR_CTRL, seek_whitespace_left);


I thought it means that seek_whitespace_right and left is what the cursor normally does when you press ctrl and arrows -- skip words and stop at underscores (which is very convenient, btw). But I tried to do the following:

1
2
bind(context, 's', MDFR_ALT | MDFR_CTRL, seek_whitespace_left);
bind(context, 'f', MDFR_ALT | MDFR_CTRL, seek_whitespace_right);


and the cursor actually seeks white spaces in this case (I want it to seek underscores). How is it possible that the same functions in two different situations do different things? Am I misunderstanding something? What are these functions supposed to do?

When I do a very similar thing:

1
2
bind(context, 'e', MDFR_ALT | MDFR_CTRL, seek_whitespace_up_end_line);
bind(context, 'd', MDFR_ALT | MDFR_CTRL, seek_whitespace_down_end_line);


everything works perfectly -- it seeks empty lines up and down.
Simon Anciaux
1337 posts
A question on seek_whitespace_right.
Edited by Simon Anciaux on Reason: clarity
seek_whitespace_right seeks white space. It's what is bound if you're not editing code. When editing code CTRL + key_right is bound to seek_alphanumeric_or_camel_right.
1
2
bind(context, key_right, MDFR_CTRL, seek_alphanumeric_or_camel_right);
bind(context, key_left, MDFR_CTRL, seek_alphanumeric_or_camel_left);
Also make sure you edit the right key map:
  • For non-code file you need to edit lines between begin_map(context, mapid_file); and end_map(context);
  • For code you need to edit lines between begin_map(context, default_code_map); and end_map(context);
Anton Swifton
32 posts / 1 project
PhD Student in Math at the University of South Carolina.
A question on seek_whitespace_right.
Got it, thank you.

I edited mapid_global. Does it correspond to both code and non-code? Also, is there a way to remap bindings for menu? Like when you open a file or try to search the file for a word?
Allen Webster
476 posts / 6 projects
Heyo
A question on seek_whitespace_right.
mapid_global applies everywhere, but for something that is bound for both code AND global or both text files AND global, the more specific map overrides the global map. So you cannot just stick it in global and expect to see it without checking if something else overrides that binding.

There isn't a lot of flexibility in the menus in 4.0.28. You can call set_gui_up_down_keys_doc to change the keybindings for up/down navigation in menus in the current version, but you can't call it from the get_binding_data function, since it's not a binding, it's a part of the custom API. You can instead call it from the start hook which you will find in 4coder_default_hooks.cpp.

In the next upcoming version (4.0.29) I am moving off of the old GUI system and you will be able to fully rebind and recustomize the menus as much as you want.
Anton Swifton
32 posts / 1 project
PhD Student in Math at the University of South Carolina.
A question on seek_whitespace_right.
Cool, thanks.