4coder » Forums » A question on seek_whitespace_right.
swifton
Anton Swifton
30 posts / 1 project

PhD Student in Math at the University of South Carolina.

#15916 A question on seek_whitespace_right.
3 months, 2 weeks ago Edited by Anton Swifton on Aug. 4, 2018, 8:51 a.m. 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.
mrmixer
Simon Anciaux
480 posts
#15917 A question on seek_whitespace_right.
3 months, 2 weeks ago Edited by Simon Anciaux on Aug. 4, 2018, 12:50 p.m. 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);
swifton
Anton Swifton
30 posts / 1 project

PhD Student in Math at the University of South Carolina.

#15920 A question on seek_whitespace_right.
3 months, 2 weeks ago

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?
Mr4thDimention
Allen Webster
428 posts / 2 projects

Heyo

#15921 A question on seek_whitespace_right.
3 months, 2 weeks ago

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.
swifton
Anton Swifton
30 posts / 1 project

PhD Student in Math at the University of South Carolina.

#15928 A question on seek_whitespace_right.
3 months, 2 weeks ago

Cool, thanks.