2016-03-15 14:12:06 +00:00
2016-03-21 22:27:27 +00:00
// TOP
2016-06-28 22:58:50 +00:00
# ifndef FCODER_DEFAULT_BINDINGS
# define FCODER_DEFAULT_BINDINGS
2016-05-06 16:45:50 +00:00
# include "4coder_default_include.cpp"
2016-03-15 14:12:06 +00:00
2016-03-19 00:17:26 +00:00
// NOTE(allen|a3.3): All of your custom ids should be enumerated
// as shown here, they may start at 0, and you can only have
// 2^24 of them so don't be wasteful!
enum My_Maps {
my_code_map ,
2016-06-21 14:00:07 +00:00
2016-03-24 01:05:28 +00:00
my_maps_count
2016-03-19 00:17:26 +00:00
} ;
2016-03-15 14:12:06 +00:00
CUSTOM_COMMAND_SIG ( write_allen_todo ) {
write_string ( app , make_lit_string ( " // TODO(allen): " ) ) ;
}
CUSTOM_COMMAND_SIG ( write_allen_note ) {
write_string ( app , make_lit_string ( " // NOTE(allen): " ) ) ;
}
2016-07-04 20:40:57 +00:00
CUSTOM_COMMAND_SIG ( write_allen_doc ) {
write_string ( app , make_lit_string ( " /* DOC() */ " ) ) ;
}
2016-05-19 01:22:35 +00:00
CUSTOM_COMMAND_SIG ( write_zero_struct ) {
write_string ( app , make_lit_string ( " = {0}; " ) ) ;
}
2016-03-15 14:12:06 +00:00
CUSTOM_COMMAND_SIG ( write_capital ) {
2016-09-17 00:03:09 +00:00
User_Input command_in = get_command_input ( app ) ;
2016-03-15 14:12:06 +00:00
char c = command_in . key . character_no_caps_lock ;
if ( c ! = 0 ) {
c = char_to_upper ( c ) ;
write_string ( app , make_string ( & c , 1 ) ) ;
}
}
CUSTOM_COMMAND_SIG ( switch_to_compilation ) {
2016-06-20 20:34:48 +00:00
2016-03-15 14:12:06 +00:00
char name [ ] = " *compilation* " ;
2016-08-29 01:03:26 +00:00
int32_t name_size = sizeof ( name ) - 1 ;
2016-06-20 20:34:48 +00:00
2016-08-29 01:03:26 +00:00
uint32_t access = AccessOpen ;
2016-09-17 00:03:09 +00:00
View_Summary view = get_active_view ( app , access ) ;
Buffer_Summary buffer = get_buffer_by_name ( app , name , name_size , access ) ;
2016-06-20 20:34:48 +00:00
2016-09-17 00:03:09 +00:00
view_set_buffer ( app , & view , buffer . buffer_id , 0 ) ;
2016-03-15 14:12:06 +00:00
}
CUSTOM_COMMAND_SIG ( rewrite_as_single_caps ) {
2016-08-29 01:03:26 +00:00
uint32_t access = AccessOpen ;
2016-09-17 00:03:09 +00:00
View_Summary view = get_active_view ( app , access ) ;
2016-06-28 19:48:12 +00:00
Full_Cursor cursor = view . cursor ;
2016-05-25 22:43:58 +00:00
2016-06-28 19:48:12 +00:00
// TODO(allen): This can be rewritten now without moving the
// cursor around, instead just calling the boundary seek.
Range range = { 0 } ;
2016-05-25 22:43:58 +00:00
exec_command ( app , seek_token_left ) ;
2016-06-23 23:11:09 +00:00
refresh_view ( app , & view ) ;
2016-03-15 14:12:06 +00:00
range . min = view . cursor . pos ;
2016-05-25 22:43:58 +00:00
2016-03-15 14:12:06 +00:00
exec_command ( app , seek_token_right ) ;
2016-06-23 23:11:09 +00:00
refresh_view ( app , & view ) ;
2016-03-15 14:12:06 +00:00
range . max = view . cursor . pos ;
2016-05-25 22:43:58 +00:00
2016-06-28 19:48:12 +00:00
String string = { 0 } ;
2016-03-15 14:12:06 +00:00
string . str = ( char * ) app - > memory ;
string . size = range . max - range . min ;
assert ( string . size < app - > memory_size ) ;
2016-06-20 20:34:48 +00:00
2016-09-17 00:03:09 +00:00
Buffer_Summary buffer = get_buffer ( app , view . buffer_id , access ) ;
buffer_read_range ( app , & buffer , range . min , range . max , string . str ) ;
2016-05-25 22:43:58 +00:00
2016-08-29 01:03:26 +00:00
int32_t is_first = true ;
for ( int32_t i = 0 ; i < string . size ; + + i ) {
2016-03-15 14:12:06 +00:00
if ( char_is_alpha_true ( string . str [ i ] ) ) {
2016-06-28 19:48:12 +00:00
if ( is_first ) {
is_first = false ;
}
else {
string . str [ i ] = char_to_lower ( string . str [ i ] ) ;
}
2016-03-15 14:12:06 +00:00
}
else {
2016-06-28 19:48:12 +00:00
is_first = true ;
2016-03-15 14:12:06 +00:00
}
}
2016-05-25 22:43:58 +00:00
2016-09-17 00:03:09 +00:00
buffer_replace_range ( app , & buffer , range . min , range . max , string . str , string . size ) ;
2016-05-25 22:43:58 +00:00
2016-09-17 00:03:09 +00:00
view_set_cursor ( app , & view ,
2016-05-25 22:43:58 +00:00
seek_line_char ( cursor . line + 1 , cursor . character ) ,
2016-06-28 19:48:12 +00:00
true ) ;
2016-03-15 14:12:06 +00:00
}
CUSTOM_COMMAND_SIG ( open_my_files ) {
2016-08-29 01:03:26 +00:00
uint32_t access = AccessAll ;
2016-09-17 00:03:09 +00:00
View_Summary view = get_active_view ( app , access ) ;
2016-09-01 00:26:52 +00:00
view_open_file ( app , & view , literal ( " w:/4ed/data/test/basic.cpp " ) , true ) ;
2016-03-15 14:12:06 +00:00
}
CUSTOM_COMMAND_SIG ( build_at_launch_location ) {
2016-08-29 01:03:26 +00:00
uint32_t access = AccessAll ;
2016-09-17 00:03:09 +00:00
View_Summary view = get_active_view ( app , access ) ;
exec_system_command ( app , & view ,
2016-06-13 16:56:33 +00:00
buffer_identifier ( literal ( " *compilation* " ) ) ,
literal ( " . " ) ,
literal ( " build " ) ,
CLI_OverlapWithConflict ) ;
2016-03-15 14:12:06 +00:00
}
2016-06-28 19:48:12 +00:00
CUSTOM_COMMAND_SIG ( seek_whitespace_up_end_line ) {
exec_command ( app , seek_whitespace_up ) ;
exec_command ( app , seek_end_of_line ) ;
}
CUSTOM_COMMAND_SIG ( seek_whitespace_down_end_line ) {
exec_command ( app , seek_whitespace_down ) ;
exec_command ( app , seek_end_of_line ) ;
}
2016-05-12 02:15:54 +00:00
HOOK_SIG ( my_start ) {
2016-07-14 16:41:23 +00:00
init_memory ( app ) ;
2016-10-28 14:11:56 +00:00
process_config_file ( app ) ;
2016-10-27 23:45:41 +00:00
2016-09-17 00:03:09 +00:00
change_theme ( app , literal ( " 4coder " ) ) ;
change_font ( app , literal ( " Liberation Sans " ) , true ) ;
2016-07-14 16:41:23 +00:00
2016-09-17 01:54:24 +00:00
exec_command ( app , open_panel_vsplit ) ;
exec_command ( app , hide_scrollbar ) ;
exec_command ( app , change_active_panel ) ;
2016-06-29 18:38:58 +00:00
exec_command ( app , hide_scrollbar ) ;
2016-05-07 17:25:45 +00:00
2016-05-12 02:15:54 +00:00
// Theme options:
// "4coder"
// "Handmade Hero"
// "Twilight"
// "Woverine"
// "stb"
2016-06-21 17:43:25 +00:00
2016-05-12 02:15:54 +00:00
// Font options:
2016-06-21 17:43:25 +00:00
// "Liberation Sans"
// "Liberation Mono"
// "Hack"
// "Cutive Mono"
// "Inconsolata"
2016-05-12 02:15:54 +00:00
// no meaning for return
return ( 0 ) ;
}
2016-09-09 13:04:51 +00:00
HOOK_SIG ( my_exit ) {
// if this returns zero it cancels the exit.
return ( 1 ) ;
2016-11-02 03:27:51 +00:00
}
2016-09-09 13:04:51 +00:00
2016-11-02 03:27:51 +00:00
// TODO(allen): delete this
CUSTOM_COMMAND_SIG ( weird_buffer_test ) {
for ( Buffer_Summary buffer = get_buffer_first ( app , AccessAll ) ;
buffer . exists ;
get_buffer_next ( app , & buffer , AccessAll ) ) {
print_message ( app , literal ( " filename: " ) ) ;
if ( buffer . file_name ) {
print_message ( app , buffer . file_name , buffer . file_name_len ) ;
}
else {
print_message ( app , literal ( " *NULL* " ) ) ;
}
print_message ( app , literal ( " buffername: " ) ) ;
if ( buffer . buffer_name ) {
print_message ( app , buffer . buffer_name , buffer . buffer_name_len ) ;
}
else {
print_message ( app , literal ( " *NULL* " ) ) ;
}
}
}
2016-10-25 02:45:34 +00:00
// NOTE(allen|a4.0.12): This is for testing it may be removed and replaced with a better test for the buffer_get_font when you eventally read this and wonder what it's about.
CUSTOM_COMMAND_SIG ( write_name_of_font ) {
View_Summary view = get_active_view ( app , AccessOpen ) ;
Buffer_Summary buffer = get_buffer ( app , view . buffer_id , AccessOpen ) ;
char font_name [ 256 ] ;
int32_t font_max = 256 ;
int32_t font_len = buffer_get_font ( app , & buffer , font_name , font_max ) ;
if ( font_len ! = 0 ) {
write_string ( app , & view , & buffer , make_string ( font_name , font_len ) ) ;
}
}
2016-07-12 18:20:06 +00:00
CUSTOM_COMMAND_SIG ( newline_or_goto_position ) {
2016-09-17 00:03:09 +00:00
View_Summary view = get_active_view ( app , AccessProtected ) ;
Buffer_Summary buffer = get_buffer ( app , view . buffer_id , AccessProtected ) ;
2016-07-12 18:20:06 +00:00
if ( buffer . lock_flags & AccessProtected ) {
2016-07-13 19:59:42 +00:00
exec_command ( app , goto_jump_at_cursor ) ;
2016-09-01 00:26:52 +00:00
lock_jump_buffer ( buffer ) ;
2016-07-12 18:20:06 +00:00
}
else {
exec_command ( app , write_character ) ;
}
}
// TODO(allen): Eliminate this hook if you can.
2016-06-23 23:11:09 +00:00
OPEN_FILE_HOOK_SIG ( my_file_settings ) {
2016-09-17 00:03:09 +00:00
// NOTE(allen|a4.0.8): The get_parameter_buffer was eliminated
2016-06-29 18:23:14 +00:00
// and instead the buffer is passed as an explicit parameter through
// the function call. That is where buffer_id comes from here.
2016-10-25 02:45:34 +00:00
uint32_t access = AccessAll ;
2016-09-17 00:03:09 +00:00
Buffer_Summary buffer = get_buffer ( app , buffer_id , access ) ;
2016-05-12 02:15:54 +00:00
assert ( buffer . exists ) ;
2016-06-21 14:00:07 +00:00
2016-08-29 01:03:26 +00:00
int32_t treat_as_code = 0 ;
int32_t wrap_lines = 1 ;
2016-06-21 14:00:07 +00:00
2016-05-12 02:15:54 +00:00
if ( buffer . file_name & & buffer . size < ( 16 < < 20 ) ) {
String ext = file_extension ( make_string ( buffer . file_name , buffer . file_name_len ) ) ;
2016-08-28 04:31:06 +00:00
if ( match_ss ( ext , make_lit_string ( " cpp " ) ) ) treat_as_code = 1 ;
else if ( match_ss ( ext , make_lit_string ( " h " ) ) ) treat_as_code = 1 ;
else if ( match_ss ( ext , make_lit_string ( " c " ) ) ) treat_as_code = 1 ;
else if ( match_ss ( ext , make_lit_string ( " hpp " ) ) ) treat_as_code = 1 ;
2016-05-12 02:15:54 +00:00
}
2016-06-21 14:00:07 +00:00
2016-05-12 02:15:54 +00:00
if ( treat_as_code ) {
wrap_lines = 0 ;
}
if ( buffer . file_name [ 0 ] = = ' * ' ) {
wrap_lines = 0 ;
}
2016-06-21 14:00:07 +00:00
2016-10-27 23:45:41 +00:00
buffer_set_setting ( app , & buffer , BufferSetting_WrapPosition , default_wrap_width ) ;
buffer_set_setting ( app , & buffer , BufferSetting_MapID , ( treat_as_code ) ? ( ( int32_t ) my_code_map ) : ( ( int32_t ) mapid_file ) ) ;
2016-10-29 19:51:59 +00:00
if ( treat_as_code & & enable_code_wrapping & & buffer . size < ( 1 < < 18 ) ) {
2016-10-28 14:11:56 +00:00
// NOTE(allen|a4.0.12): There is a little bit of grossness going on here.
// If we set BufferSetting_Lex to true, it will launch a lexing job.
// If a lexing job is active when we set BufferSetting_VirtualWhitespace on
// that call can fail.
// Unfortunantely without tokens virtual whitespace doesn't really make sense.
// So for now I have it automatically turning on lexing when virtual whitespace
// is turned on.
// Cleaning some of that up is a goal for future versions.
2016-10-27 23:45:41 +00:00
buffer_set_setting ( app , & buffer , BufferSetting_WrapLine , 1 ) ;
buffer_set_setting ( app , & buffer , BufferSetting_VirtualWhitespace , 1 ) ;
}
2016-10-28 14:11:56 +00:00
else {
buffer_set_setting ( app , & buffer , BufferSetting_WrapLine , wrap_lines ) ;
buffer_set_setting ( app , & buffer , BufferSetting_Lex , treat_as_code ) ;
}
2016-06-03 16:20:45 +00:00
2016-05-12 02:15:54 +00:00
// no meaning for return
return ( 0 ) ;
}
2016-06-29 19:11:37 +00:00
// NOTE(allen|a4.0.9): The input filter allows you to modify the input
// to a frame before 4coder starts processing it at all.
//
// Right now it only has access to the mouse state, but it will be
// extended to have access to the key presses soon.
2016-08-29 02:14:02 +00:00
static int32_t suppressing_mouse = false ;
2016-06-29 19:11:37 +00:00
INPUT_FILTER_SIG ( my_suppress_mouse_filter ) {
if ( suppressing_mouse ) {
2016-09-01 19:40:25 +00:00
* mouse = null_mouse_state ;
2016-06-29 19:11:37 +00:00
mouse - > x = - 100 ;
mouse - > y = - 100 ;
}
}
2016-07-01 05:42:19 +00:00
static void
2016-08-29 02:14:02 +00:00
set_mouse_suppression ( Application_Links * app , int32_t suppress ) {
2016-07-01 05:42:19 +00:00
if ( suppress ) {
suppressing_mouse = true ;
2016-09-17 00:03:09 +00:00
show_mouse_cursor ( app , MouseCursorShow_Never ) ;
2016-07-01 05:42:19 +00:00
}
else {
suppressing_mouse = false ;
2016-09-17 00:03:09 +00:00
show_mouse_cursor ( app , MouseCursorShow_Always ) ;
2016-07-01 05:42:19 +00:00
}
}
2016-06-29 19:11:37 +00:00
CUSTOM_COMMAND_SIG ( suppress_mouse ) {
2016-07-01 05:42:19 +00:00
set_mouse_suppression ( app , true ) ;
2016-06-29 19:11:37 +00:00
}
CUSTOM_COMMAND_SIG ( allow_mouse ) {
2016-07-01 05:42:19 +00:00
set_mouse_suppression ( app , false ) ;
2016-06-29 19:11:37 +00:00
}
CUSTOM_COMMAND_SIG ( toggle_mouse ) {
2016-07-01 05:42:19 +00:00
set_mouse_suppression ( app , ! suppressing_mouse ) ;
2016-06-29 19:11:37 +00:00
}
2016-05-12 02:15:54 +00:00
void
2016-05-19 16:23:12 +00:00
default_keys ( Bind_Helper * context ) {
2016-03-15 14:12:06 +00:00
begin_map ( context , mapid_global ) ;
2016-06-03 16:20:45 +00:00
2016-07-05 01:36:30 +00:00
bind ( context , ' p ' , MDFR_CTRL , open_panel_vsplit ) ;
bind ( context , ' _ ' , MDFR_CTRL , open_panel_hsplit ) ;
bind ( context , ' P ' , MDFR_CTRL , close_panel ) ;
2016-07-12 19:16:48 +00:00
bind ( context , ' , ' , MDFR_CTRL , change_active_panel ) ;
2016-03-15 14:12:06 +00:00
bind ( context , ' n ' , MDFR_CTRL , cmdid_interactive_new ) ;
bind ( context , ' o ' , MDFR_CTRL , cmdid_interactive_open ) ;
2016-07-12 19:16:48 +00:00
bind ( context , ' o ' , MDFR_ALT , open_in_other ) ;
2016-03-15 14:12:06 +00:00
bind ( context , ' k ' , MDFR_CTRL , cmdid_interactive_kill_buffer ) ;
bind ( context , ' i ' , MDFR_CTRL , cmdid_interactive_switch_buffer ) ;
2016-07-12 19:16:48 +00:00
bind ( context , ' w ' , MDFR_CTRL , save_as ) ;
2016-03-15 14:12:06 +00:00
bind ( context , ' c ' , MDFR_ALT , cmdid_open_color_tweaker ) ;
2016-06-07 16:26:11 +00:00
bind ( context , ' d ' , MDFR_ALT , cmdid_open_debug ) ;
2016-06-03 16:20:45 +00:00
2016-07-12 18:20:06 +00:00
bind ( context , ' . ' , MDFR_ALT , change_to_build_panel ) ;
bind ( context , ' , ' , MDFR_ALT , close_build_panel ) ;
2016-08-22 19:31:19 +00:00
bind ( context , ' n ' , MDFR_ALT , goto_next_error ) ;
bind ( context , ' N ' , MDFR_ALT , goto_prev_error ) ;
2016-07-12 18:20:06 +00:00
bind ( context , ' M ' , MDFR_ALT , goto_first_error ) ;
2016-09-01 19:40:25 +00:00
bind ( context , ' m ' , MDFR_ALT , build_in_build_panel ) ;
2016-07-12 19:16:48 +00:00
2016-03-15 14:12:06 +00:00
bind ( context , ' z ' , MDFR_ALT , execute_any_cli ) ;
2016-05-10 17:36:53 +00:00
bind ( context , ' Z ' , MDFR_ALT , execute_previous_cli ) ;
2016-06-03 16:20:45 +00:00
2016-07-12 19:16:48 +00:00
bind ( context , ' x ' , MDFR_ALT , execute_arbitrary_command ) ;
bind ( context , ' s ' , MDFR_ALT , show_scrollbar ) ;
bind ( context , ' w ' , MDFR_ALT , hide_scrollbar ) ;
2016-06-29 19:11:37 +00:00
bind ( context , key_f2 , MDFR_NONE , toggle_mouse ) ;
2016-09-01 03:06:46 +00:00
bind ( context , key_page_up , MDFR_CTRL , toggle_fullscreen ) ;
2016-09-10 15:22:25 +00:00
bind ( context , ' E ' , MDFR_ALT , exit_4coder ) ;
2016-11-02 03:27:51 +00:00
bind ( context , ' K ' , MDFR_ALT , weird_buffer_test ) ;
2016-06-29 19:11:37 +00:00
2016-03-15 14:12:06 +00:00
end_map ( context ) ;
2016-05-23 11:37:12 +00:00
2016-03-15 14:12:06 +00:00
begin_map ( context , my_code_map ) ;
2016-06-03 16:20:45 +00:00
2016-03-15 14:12:06 +00:00
// NOTE(allen|a3.1): Set this map (my_code_map == mapid_user_custom) to
// inherit from mapid_file. When searching if a key is bound
// in this map, if it is not found here it will then search mapid_file.
//
// If this is not set, it defaults to mapid_global.
inherit_map ( context , mapid_file ) ;
2016-06-03 16:20:45 +00:00
2016-03-15 14:12:06 +00:00
// NOTE(allen|a3.1): Children can override parent's bindings.
bind ( context , key_right , MDFR_CTRL , seek_alphanumeric_or_camel_right ) ;
bind ( context , key_left , MDFR_CTRL , seek_alphanumeric_or_camel_left ) ;
2016-06-03 16:20:45 +00:00
2016-03-15 14:12:06 +00:00
// NOTE(allen|a3.2): Specific keys can override vanilla keys,
// and write character writes whichever character corresponds
// to the key that triggered the command.
bind ( context , ' \n ' , MDFR_NONE , write_and_auto_tab ) ;
2016-07-12 18:20:06 +00:00
bind ( context , ' \n ' , MDFR_SHIFT , write_and_auto_tab ) ;
2016-03-15 14:12:06 +00:00
bind ( context , ' } ' , MDFR_NONE , write_and_auto_tab ) ;
bind ( context , ' ) ' , MDFR_NONE , write_and_auto_tab ) ;
bind ( context , ' ] ' , MDFR_NONE , write_and_auto_tab ) ;
bind ( context , ' ; ' , MDFR_NONE , write_and_auto_tab ) ;
bind ( context , ' # ' , MDFR_NONE , write_and_auto_tab ) ;
2016-06-03 16:20:45 +00:00
2016-07-11 16:15:37 +00:00
bind ( context , ' \t ' , MDFR_NONE , word_complete ) ;
2016-06-13 16:56:33 +00:00
bind ( context , ' \t ' , MDFR_CTRL , auto_tab_range ) ;
2016-03-15 14:12:06 +00:00
bind ( context , ' \t ' , MDFR_SHIFT , auto_tab_line_at_cursor ) ;
2016-06-03 16:20:45 +00:00
2016-03-15 14:12:06 +00:00
bind ( context , ' t ' , MDFR_ALT , write_allen_todo ) ;
2016-06-28 22:58:50 +00:00
bind ( context , ' y ' , MDFR_ALT , write_allen_note ) ;
2016-07-05 01:36:30 +00:00
bind ( context , ' r ' , MDFR_ALT , write_allen_doc ) ;
2016-03-15 14:12:06 +00:00
bind ( context , ' [ ' , MDFR_CTRL , open_long_braces ) ;
bind ( context , ' { ' , MDFR_CTRL , open_long_braces_semicolon ) ;
bind ( context , ' } ' , MDFR_CTRL , open_long_braces_break ) ;
bind ( context , ' i ' , MDFR_ALT , if0_off ) ;
bind ( context , ' 1 ' , MDFR_ALT , open_file_in_quotes ) ;
2016-05-19 01:22:35 +00:00
bind ( context , ' 0 ' , MDFR_CTRL , write_zero_struct ) ;
2016-06-03 16:20:45 +00:00
2016-03-15 14:12:06 +00:00
end_map ( context ) ;
2016-06-03 16:20:45 +00:00
2016-03-15 14:12:06 +00:00
begin_map ( context , mapid_file ) ;
2016-06-03 16:20:45 +00:00
2016-03-15 14:12:06 +00:00
// NOTE(allen|a3.4.4): Binding this essentially binds
// all key combos that would normally insert a character
// into a buffer. If the code for the key is not an enum
// value such as key_left or key_back then it is a vanilla key.
// It is possible to override this binding for individual keys.
2016-06-03 16:20:45 +00:00
bind_vanilla_keys ( context , write_character ) ;
2016-06-10 23:46:30 +00:00
// NOTE(allen|a4.0.7): You can now bind left and right clicks.
// They only trigger on mouse presses. Modifiers do work
// so control+click shift+click etc can now have special meanings.
bind ( context , key_mouse_left , MDFR_NONE , click_set_cursor ) ;
bind ( context , key_mouse_right , MDFR_NONE , click_set_mark ) ;
2016-09-09 17:14:38 +00:00
// NOTE(allen|a4.0.11): You can now bind left and right mouse
// button releases. Modifiers do work so control+click shift+click
// etc can now have special meanings.
bind ( context , key_mouse_left_release , MDFR_NONE , click_set_mark ) ;
2016-06-03 16:20:45 +00:00
bind ( context , key_left , MDFR_NONE , move_left ) ;
bind ( context , key_right , MDFR_NONE , move_right ) ;
bind ( context , key_del , MDFR_NONE , delete_char ) ;
bind ( context , key_back , MDFR_NONE , backspace_char ) ;
bind ( context , key_up , MDFR_NONE , move_up ) ;
bind ( context , key_down , MDFR_NONE , move_down ) ;
2016-06-06 18:41:17 +00:00
bind ( context , key_end , MDFR_NONE , seek_end_of_line ) ;
bind ( context , key_home , MDFR_NONE , seek_beginning_of_line ) ;
2016-07-04 20:40:57 +00:00
bind ( context , key_page_up , MDFR_NONE , page_up ) ;
bind ( context , key_page_down , MDFR_NONE , page_down ) ;
2016-06-03 16:20:45 +00:00
2016-03-15 14:12:06 +00:00
bind ( context , key_right , MDFR_CTRL , seek_whitespace_right ) ;
bind ( context , key_left , MDFR_CTRL , seek_whitespace_left ) ;
2016-06-28 19:48:12 +00:00
bind ( context , key_up , MDFR_CTRL , seek_whitespace_up_end_line ) ;
bind ( context , key_down , MDFR_CTRL , seek_whitespace_down_end_line ) ;
2016-06-03 16:20:45 +00:00
2016-03-15 14:12:06 +00:00
bind ( context , key_up , MDFR_ALT , move_up_10 ) ;
bind ( context , key_down , MDFR_ALT , move_down_10 ) ;
2016-06-03 16:20:45 +00:00
2016-03-15 14:12:06 +00:00
bind ( context , key_back , MDFR_CTRL , backspace_word ) ;
2016-06-10 15:19:29 +00:00
bind ( context , key_del , MDFR_CTRL , delete_word ) ;
2016-03-15 14:12:06 +00:00
bind ( context , key_back , MDFR_ALT , snipe_token_or_word ) ;
2016-06-03 16:20:45 +00:00
bind ( context , ' ' , MDFR_CTRL , set_mark ) ;
2016-05-12 02:15:54 +00:00
bind ( context , ' a ' , MDFR_CTRL , replace_in_range ) ;
2016-06-14 14:20:15 +00:00
bind ( context , ' c ' , MDFR_CTRL , copy ) ;
2016-06-03 16:20:45 +00:00
bind ( context , ' d ' , MDFR_CTRL , delete_range ) ;
2016-07-12 18:20:06 +00:00
bind ( context , ' e ' , MDFR_CTRL , center_view ) ;
bind ( context , ' E ' , MDFR_CTRL , left_adjust_view ) ;
2016-05-12 02:15:54 +00:00
bind ( context , ' f ' , MDFR_CTRL , search ) ;
2016-07-12 18:20:06 +00:00
bind ( context , ' F ' , MDFR_CTRL , list_all_locations ) ;
2016-07-18 18:36:53 +00:00
bind ( context , ' F ' , MDFR_ALT , list_all_substring_locations_case_insensitive ) ;
2016-05-12 02:15:54 +00:00
bind ( context , ' g ' , MDFR_CTRL , goto_line ) ;
2016-03-15 14:12:06 +00:00
bind ( context , ' h ' , MDFR_CTRL , cmdid_history_backward ) ;
bind ( context , ' H ' , MDFR_CTRL , cmdid_history_forward ) ;
2016-07-05 13:11:26 +00:00
bind ( context , ' j ' , MDFR_CTRL , to_lowercase ) ;
2016-05-12 02:15:54 +00:00
bind ( context , ' K ' , MDFR_CTRL , cmdid_kill_buffer ) ;
2016-07-04 20:40:57 +00:00
bind ( context , ' l ' , MDFR_CTRL , toggle_line_wrap ) ;
2016-06-06 18:41:17 +00:00
bind ( context , ' m ' , MDFR_CTRL , cursor_mark_swap ) ;
2016-05-12 02:15:54 +00:00
bind ( context , ' O ' , MDFR_CTRL , cmdid_reopen ) ;
bind ( context , ' q ' , MDFR_CTRL , query_replace ) ;
bind ( context , ' r ' , MDFR_CTRL , reverse_search ) ;
bind ( context , ' s ' , MDFR_CTRL , cmdid_save ) ;
2016-09-23 17:50:55 +00:00
bind ( context , ' T ' , MDFR_CTRL , list_all_locations_of_identifier ) ;
2016-07-05 13:11:26 +00:00
bind ( context , ' u ' , MDFR_CTRL , to_uppercase ) ;
2016-05-25 22:43:58 +00:00
bind ( context , ' U ' , MDFR_CTRL , rewrite_as_single_caps ) ;
2016-07-17 02:24:13 +00:00
bind ( context , ' v ' , MDFR_CTRL , paste_and_indent ) ;
2016-10-05 06:08:23 +00:00
bind ( context , ' v ' , MDFR_ALT , toggle_virtual_whitespace ) ;
2016-07-17 02:24:13 +00:00
bind ( context , ' V ' , MDFR_CTRL , paste_next_and_indent ) ;
2016-06-14 14:20:15 +00:00
bind ( context , ' x ' , MDFR_CTRL , cut ) ;
2016-05-12 02:15:54 +00:00
bind ( context , ' y ' , MDFR_CTRL , cmdid_redo ) ;
bind ( context , ' z ' , MDFR_CTRL , cmdid_undo ) ;
2016-07-04 20:40:57 +00:00
bind ( context , ' 1 ' , MDFR_CTRL , eol_dosify ) ;
bind ( context , ' ! ' , MDFR_CTRL , eol_nixify ) ;
2016-05-12 02:15:54 +00:00
2016-09-20 19:48:02 +00:00
bind ( context , ' 2 ' , MDFR_CTRL , decrease_line_wrap ) ;
bind ( context , ' 3 ' , MDFR_CTRL , increase_line_wrap ) ;
2016-07-04 20:40:57 +00:00
bind ( context , ' ? ' , MDFR_CTRL , toggle_show_whitespace ) ;
2016-07-09 04:39:14 +00:00
bind ( context , ' ~ ' , MDFR_CTRL , clean_all_lines ) ;
2016-07-12 18:20:06 +00:00
bind ( context , ' \n ' , MDFR_NONE , newline_or_goto_position ) ;
bind ( context , ' \n ' , MDFR_SHIFT , newline_or_goto_position ) ;
2016-06-03 16:20:45 +00:00
bind ( context , ' ' , MDFR_SHIFT , write_character ) ;
2016-05-12 02:15:54 +00:00
2016-10-25 02:45:34 +00:00
bind ( context , ' ; ' , MDFR_ALT , write_name_of_font ) ;
2016-05-12 02:15:54 +00:00
end_map ( context ) ;
}
2016-03-24 01:05:28 +00:00
2016-07-15 23:34:32 +00:00
2016-08-22 19:31:19 +00:00
# ifndef NO_BINDING
2016-07-15 23:34:32 +00:00
2016-08-29 02:14:02 +00:00
extern " C " int32_t
get_bindings ( void * data , int32_t size ) {
2016-05-12 02:15:54 +00:00
Bind_Helper context_ = begin_bind_helper ( data , size ) ;
Bind_Helper * context = & context_ ;
// NOTE(allen|a3.1): Hooks have no loyalties to maps. All hooks are global
// and once set they always apply, regardless of what map is active.
set_hook ( context , hook_start , my_start ) ;
2016-09-09 13:04:51 +00:00
set_hook ( context , hook_exit , my_exit ) ;
2016-06-03 16:20:45 +00:00
2016-06-23 23:11:09 +00:00
set_open_file_hook ( context , my_file_settings ) ;
2016-07-13 19:59:42 +00:00
set_command_caller ( context , default_command_caller ) ;
2016-06-29 19:11:37 +00:00
set_input_filter ( context , my_suppress_mouse_filter ) ;
2016-05-12 02:15:54 +00:00
set_scroll_rule ( context , smooth_scroll_rule ) ;
default_keys ( context ) ;
2016-05-07 17:25:45 +00:00
2016-08-29 02:14:02 +00:00
int32_t result = end_bind_helper ( context ) ;
2016-05-07 17:25:45 +00:00
return ( result ) ;
2016-03-15 14:12:06 +00:00
}
2016-03-21 22:27:27 +00:00
2016-06-28 22:58:50 +00:00
# endif //NO_BINDING
# endif //FCODER_DEFAULT_BINDINGS
2016-05-12 02:15:54 +00:00
2016-03-21 22:27:27 +00:00
// BOTTOM