replaced Key_Codes with generated enum
This commit is contained in:
parent
9c6fdde85d
commit
ceb9b6d217
|
@ -418,8 +418,8 @@ extern "C" GET_BINDING_DATA(get_bindings){
|
||||||
inherit_map(context, mapid_file);
|
inherit_map(context, mapid_file);
|
||||||
|
|
||||||
// NOTE(allen|a3.1): Children can override parent's bindings.
|
// NOTE(allen|a3.1): Children can override parent's bindings.
|
||||||
bind(context, codes->right, MDFR_CTRL, cmdid_seek_alphanumeric_or_camel_right);
|
bind(context, key_right, MDFR_CTRL, cmdid_seek_alphanumeric_or_camel_right);
|
||||||
bind(context, codes->left, MDFR_CTRL, cmdid_seek_alphanumeric_or_camel_left);
|
bind(context, key_left, MDFR_CTRL, cmdid_seek_alphanumeric_or_camel_left);
|
||||||
|
|
||||||
// NOTE(allen|a3.2): Specific keys can override vanilla keys,
|
// NOTE(allen|a3.2): Specific keys can override vanilla keys,
|
||||||
// and write character writes whichever character corresponds
|
// and write character writes whichever character corresponds
|
||||||
|
@ -456,26 +456,26 @@ extern "C" GET_BINDING_DATA(get_bindings){
|
||||||
// It is possible to override this binding for individual keys.
|
// It is possible to override this binding for individual keys.
|
||||||
bind_vanilla_keys(context, cmdid_write_character);
|
bind_vanilla_keys(context, cmdid_write_character);
|
||||||
|
|
||||||
bind(context, codes->left, MDFR_NONE, cmdid_move_left);
|
bind(context, key_left, MDFR_NONE, cmdid_move_left);
|
||||||
bind(context, codes->right, MDFR_NONE, cmdid_move_right);
|
bind(context, key_right, MDFR_NONE, cmdid_move_right);
|
||||||
bind(context, codes->del, MDFR_NONE, cmdid_delete);
|
bind(context, key_del, MDFR_NONE, cmdid_delete);
|
||||||
bind(context, codes->back, MDFR_NONE, cmdid_backspace);
|
bind(context, key_back, MDFR_NONE, cmdid_backspace);
|
||||||
bind(context, codes->up, MDFR_NONE, cmdid_move_up);
|
bind(context, key_up, MDFR_NONE, cmdid_move_up);
|
||||||
bind(context, codes->down, MDFR_NONE, cmdid_move_down);
|
bind(context, key_down, MDFR_NONE, cmdid_move_down);
|
||||||
bind(context, codes->end, MDFR_NONE, cmdid_seek_end_of_line);
|
bind(context, key_end, MDFR_NONE, cmdid_seek_end_of_line);
|
||||||
bind(context, codes->home, MDFR_NONE, cmdid_seek_beginning_of_line);
|
bind(context, key_home, MDFR_NONE, cmdid_seek_beginning_of_line);
|
||||||
bind(context, codes->page_up, MDFR_NONE, cmdid_page_up);
|
bind(context, key_page_up, MDFR_NONE, cmdid_page_up);
|
||||||
bind(context, codes->page_down, MDFR_NONE, cmdid_page_down);
|
bind(context, key_page_down, MDFR_NONE, cmdid_page_down);
|
||||||
|
|
||||||
bind(context, codes->right, MDFR_CTRL, cmdid_seek_whitespace_right);
|
bind(context, key_right, MDFR_CTRL, cmdid_seek_whitespace_right);
|
||||||
bind(context, codes->left, MDFR_CTRL, cmdid_seek_whitespace_left);
|
bind(context, key_left, MDFR_CTRL, cmdid_seek_whitespace_left);
|
||||||
bind(context, codes->up, MDFR_CTRL, cmdid_seek_whitespace_up);
|
bind(context, key_up, MDFR_CTRL, cmdid_seek_whitespace_up);
|
||||||
bind(context, codes->down, MDFR_CTRL, cmdid_seek_whitespace_down);
|
bind(context, key_down, MDFR_CTRL, cmdid_seek_whitespace_down);
|
||||||
|
|
||||||
bind(context, codes->up, MDFR_ALT, move_up_10);
|
bind(context, key_up, MDFR_ALT, move_up_10);
|
||||||
bind(context, codes->down, MDFR_ALT, move_down_10);
|
bind(context, key_down, MDFR_ALT, move_down_10);
|
||||||
|
|
||||||
bind(context, codes->back, MDFR_CTRL, backspace_word);
|
bind(context, key_back, MDFR_CTRL, backspace_word);
|
||||||
|
|
||||||
bind(context, ' ', MDFR_CTRL, cmdid_set_mark);
|
bind(context, ' ', MDFR_CTRL, cmdid_set_mark);
|
||||||
bind(context, 'm', MDFR_CTRL, cmdid_cursor_mark_swap);
|
bind(context, 'm', MDFR_CTRL, cmdid_cursor_mark_swap);
|
||||||
|
@ -486,9 +486,9 @@ extern "C" GET_BINDING_DATA(get_bindings){
|
||||||
bind(context, 'Z', MDFR_CTRL, cmdid_timeline_scrub);
|
bind(context, 'Z', MDFR_CTRL, cmdid_timeline_scrub);
|
||||||
bind(context, 'z', MDFR_CTRL, cmdid_undo);
|
bind(context, 'z', MDFR_CTRL, cmdid_undo);
|
||||||
bind(context, 'y', MDFR_CTRL, cmdid_redo);
|
bind(context, 'y', MDFR_CTRL, cmdid_redo);
|
||||||
bind(context, codes->left, MDFR_ALT, cmdid_increase_rewind_speed);
|
bind(context, key_left, MDFR_ALT, cmdid_increase_rewind_speed);
|
||||||
bind(context, codes->right, MDFR_ALT, cmdid_increase_fastforward_speed);
|
bind(context, key_right, MDFR_ALT, cmdid_increase_fastforward_speed);
|
||||||
bind(context, codes->down, MDFR_ALT, cmdid_stop_rewind_fastforward);
|
bind(context, key_down, MDFR_ALT, cmdid_stop_rewind_fastforward);
|
||||||
bind(context, 'h', MDFR_CTRL, cmdid_history_backward);
|
bind(context, 'h', MDFR_CTRL, cmdid_history_backward);
|
||||||
bind(context, 'H', MDFR_CTRL, cmdid_history_forward);
|
bind(context, 'H', MDFR_CTRL, cmdid_history_forward);
|
||||||
bind(context, 'd', MDFR_CTRL, cmdid_delete_range);
|
bind(context, 'd', MDFR_CTRL, cmdid_delete_range);
|
||||||
|
|
|
@ -1,54 +1,14 @@
|
||||||
|
|
||||||
|
#include "4coder_keycodes.h"
|
||||||
#include "4coder_buffer_types.h"
|
#include "4coder_buffer_types.h"
|
||||||
|
|
||||||
#define MDFR_NONE 0
|
#define MDFR_NONE 0
|
||||||
#define MDFR_CTRL 1
|
#define MDFR_CTRL 1
|
||||||
#define MDFR_ALT 2
|
#define MDFR_ALT 2
|
||||||
#define MDFR_SHIFT 4
|
#define MDFR_SHIFT 4
|
||||||
#define MDFR_NUMPAD 8
|
|
||||||
|
|
||||||
typedef unsigned char Code;
|
typedef unsigned char Code;
|
||||||
|
|
||||||
struct Key_Codes{
|
|
||||||
Code back;
|
|
||||||
Code up;
|
|
||||||
Code down;
|
|
||||||
Code left;
|
|
||||||
Code right;
|
|
||||||
Code del;
|
|
||||||
Code insert;
|
|
||||||
Code home;
|
|
||||||
Code end;
|
|
||||||
Code page_up;
|
|
||||||
Code page_down;
|
|
||||||
Code esc;
|
|
||||||
|
|
||||||
#if 0 // TODO(allen): Get these working sometime
|
|
||||||
union{
|
|
||||||
struct{
|
|
||||||
Code f1;
|
|
||||||
Code f2;
|
|
||||||
Code f3;
|
|
||||||
Code f4;
|
|
||||||
Code f5;
|
|
||||||
Code f6;
|
|
||||||
Code f7;
|
|
||||||
Code f8;
|
|
||||||
|
|
||||||
Code f9;
|
|
||||||
Code f10;
|
|
||||||
Code f11;
|
|
||||||
Code f12;
|
|
||||||
Code f13;
|
|
||||||
Code f14;
|
|
||||||
Code f15;
|
|
||||||
Code f16;
|
|
||||||
};
|
|
||||||
Code f[16];
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
enum Command_ID{
|
enum Command_ID{
|
||||||
cmdid_null,
|
cmdid_null,
|
||||||
cmdid_write_character,
|
cmdid_write_character,
|
||||||
|
@ -261,7 +221,7 @@ struct String{
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define GET_BINDING_DATA(name) int name(void *data, int size, Key_Codes *codes)
|
#define GET_BINDING_DATA(name) int name(void *data, int size)
|
||||||
#define SET_EXTRA_FONT_SIG(name) void name(Extra_Font *font_out)
|
#define SET_EXTRA_FONT_SIG(name) void name(Extra_Font *font_out)
|
||||||
#define CUSTOM_COMMAND_SIG(name) void name(void *cmd_context, struct Application_Links *app)
|
#define CUSTOM_COMMAND_SIG(name) void name(void *cmd_context, struct Application_Links *app)
|
||||||
#define HOOK_SIG(name) void name(void *cmd_context, struct Application_Links *app)
|
#define HOOK_SIG(name) void name(void *cmd_context, struct Application_Links *app)
|
||||||
|
|
|
@ -226,7 +226,6 @@ get_range(File_View_Summary *view){
|
||||||
range.max = view->cursor.pos;
|
range.max = view->cursor.pos;
|
||||||
range.min = view->mark.pos;
|
range.min = view->mark.pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(range);
|
return(range);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
enum Key_Code{
|
||||||
|
key_back = 1,
|
||||||
|
key_up = 2,
|
||||||
|
key_down = 3,
|
||||||
|
key_left = 4,
|
||||||
|
key_right = 5,
|
||||||
|
key_del = 6,
|
||||||
|
key_insert = 7,
|
||||||
|
key_home = 8,
|
||||||
|
key_end = 11,
|
||||||
|
key_page_up = 12,
|
||||||
|
key_page_down = 13,
|
||||||
|
key_esc = 14,
|
||||||
|
key_f1 = 127,
|
||||||
|
key_f2 = 128,
|
||||||
|
key_f3 = 129,
|
||||||
|
key_f4 = 130,
|
||||||
|
key_f5 = 131,
|
||||||
|
key_f6 = 132,
|
||||||
|
key_f7 = 133,
|
||||||
|
key_f8 = 134,
|
||||||
|
key_f9 = 135,
|
||||||
|
key_f10 = 136,
|
||||||
|
key_f11 = 137,
|
||||||
|
key_f12 = 138,
|
||||||
|
key_f13 = 139,
|
||||||
|
key_f14 = 140,
|
||||||
|
key_f15 = 141,
|
||||||
|
key_f16 = 142,
|
||||||
|
};
|
34
4ed.cpp
34
4ed.cpp
|
@ -2495,7 +2495,7 @@ app_links_init(System_Functions *system){
|
||||||
|
|
||||||
#if FRED_INTERNAL
|
#if FRED_INTERNAL
|
||||||
internal void
|
internal void
|
||||||
setup_debug_commands(Command_Map *commands, Partition *part, Key_Codes *codes, Command_Map *parent){
|
setup_debug_commands(Command_Map *commands, Partition *part, Command_Map *parent){
|
||||||
map_init(commands, part, 6, parent);
|
map_init(commands, part, 6, parent);
|
||||||
|
|
||||||
map_add(commands, 'm', MDFR_NONE, command_debug_memory);
|
map_add(commands, 'm', MDFR_NONE, command_debug_memory);
|
||||||
|
@ -2504,7 +2504,7 @@ setup_debug_commands(Command_Map *commands, Partition *part, Key_Codes *codes, C
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
setup_ui_commands(Command_Map *commands, Partition *part, Key_Codes *codes, Command_Map *parent){
|
setup_ui_commands(Command_Map *commands, Partition *part, Command_Map *parent){
|
||||||
map_init(commands, part, 32, parent);
|
map_init(commands, part, 32, parent);
|
||||||
|
|
||||||
commands->vanilla_keyboard_default.function = command_null;
|
commands->vanilla_keyboard_default.function = command_null;
|
||||||
|
@ -2515,22 +2515,22 @@ setup_ui_commands(Command_Map *commands, Partition *part, Key_Codes *codes, Comm
|
||||||
u8 mdfr_array[] = {MDFR_NONE, MDFR_SHIFT, MDFR_CTRL, MDFR_SHIFT | MDFR_CTRL};
|
u8 mdfr_array[] = {MDFR_NONE, MDFR_SHIFT, MDFR_CTRL, MDFR_SHIFT | MDFR_CTRL};
|
||||||
for (i32 i = 0; i < 4; ++i){
|
for (i32 i = 0; i < 4; ++i){
|
||||||
mdfr = mdfr_array[i];
|
mdfr = mdfr_array[i];
|
||||||
map_add(commands, codes->left, mdfr, command_null);
|
map_add(commands, key_left, mdfr, command_null);
|
||||||
map_add(commands, codes->right, mdfr, command_null);
|
map_add(commands, key_right, mdfr, command_null);
|
||||||
map_add(commands, codes->up, mdfr, command_null);
|
map_add(commands, key_up, mdfr, command_null);
|
||||||
map_add(commands, codes->down, mdfr, command_null);
|
map_add(commands, key_down, mdfr, command_null);
|
||||||
map_add(commands, codes->back, mdfr, command_null);
|
map_add(commands, key_back, mdfr, command_null);
|
||||||
map_add(commands, codes->esc, mdfr, command_close_minor_view);
|
map_add(commands, key_esc, mdfr, command_close_minor_view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
setup_file_commands(Command_Map *commands, Partition *part, Key_Codes *codes, Command_Map *parent){
|
setup_file_commands(Command_Map *commands, Partition *part, Command_Map *parent){
|
||||||
map_init(commands, part, 10, parent);
|
map_init(commands, part, 10, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
setup_top_commands(Command_Map *commands, Partition *part, Key_Codes *codes, Command_Map *parent){
|
setup_top_commands(Command_Map *commands, Partition *part, Command_Map *parent){
|
||||||
map_init(commands, part, 5, parent);
|
map_init(commands, part, 5, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3107,7 +3107,7 @@ App_Init_Sig(app_init){
|
||||||
// TODO(allen): Use a giant bubble of general memory for this.
|
// TODO(allen): Use a giant bubble of general memory for this.
|
||||||
// So that it doesn't interfere with the command maps as they allocate
|
// So that it doesn't interfere with the command maps as they allocate
|
||||||
// their own memory.
|
// their own memory.
|
||||||
i32 wanted_size = vars->config_api.get_bindings(data, size, codes);
|
i32 wanted_size = vars->config_api.get_bindings(data, size);
|
||||||
|
|
||||||
b32 did_top = 0;
|
b32 did_top = 0;
|
||||||
b32 did_file = 0;
|
b32 did_file = 0;
|
||||||
|
@ -3212,16 +3212,16 @@ App_Init_Sig(app_init){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!did_top) setup_top_commands(&vars->map_top, &vars->mem.part, codes, global);
|
if (!did_top) setup_top_commands(&vars->map_top, &vars->mem.part, global);
|
||||||
if (!did_file) setup_file_commands(&vars->map_file, &vars->mem.part, codes, global);
|
if (!did_file) setup_file_commands(&vars->map_file, &vars->mem.part, global);
|
||||||
|
|
||||||
#if !defined(FRED_SUPER)
|
#if !defined(FRED_SUPER)
|
||||||
vars->hooks[hook_start] = 0;
|
vars->hooks[hook_start] = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
setup_ui_commands(&vars->map_ui, &vars->mem.part, codes, global);
|
setup_ui_commands(&vars->map_ui, &vars->mem.part, global);
|
||||||
#if FRED_INTERNAL
|
#if FRED_INTERNAL
|
||||||
setup_debug_commands(&vars->map_debug, &vars->mem.part, codes, global);
|
setup_debug_commands(&vars->map_debug, &vars->mem.part, global);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (vars->hooks[hook_open_file] == 0){
|
if (vars->hooks[hook_open_file] == 0){
|
||||||
|
@ -3785,7 +3785,7 @@ App_Step_Sig(app_step){
|
||||||
Handle_Command_Function *handle_command = 0;
|
Handle_Command_Function *handle_command = 0;
|
||||||
if (view) handle_command = view->handle_command;
|
if (view) handle_command = view->handle_command;
|
||||||
if (handle_command){
|
if (handle_command){
|
||||||
handle_command(system, view, &command_data, cmd, key, codes);
|
handle_command(system, view, &command_data, cmd, key);
|
||||||
app_result.redraw = 1;
|
app_result.redraw = 1;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -3815,13 +3815,11 @@ App_Step_Sig(app_step){
|
||||||
Input_Summary dead_input = {};
|
Input_Summary dead_input = {};
|
||||||
dead_input.mouse.mx = mouse_data.mx;
|
dead_input.mouse.mx = mouse_data.mx;
|
||||||
dead_input.mouse.my = mouse_data.my;
|
dead_input.mouse.my = mouse_data.my;
|
||||||
dead_input.codes = codes;
|
|
||||||
|
|
||||||
Input_Summary active_input = {};
|
Input_Summary active_input = {};
|
||||||
dead_input.mouse.mx = mouse_data.mx;
|
dead_input.mouse.mx = mouse_data.mx;
|
||||||
dead_input.mouse.my = mouse_data.my;
|
dead_input.mouse.my = mouse_data.my;
|
||||||
active_input.keys = key_data;
|
active_input.keys = key_data;
|
||||||
active_input.codes = codes;
|
|
||||||
|
|
||||||
// NOTE(allen): pass raw input to the panels
|
// NOTE(allen): pass raw input to the panels
|
||||||
{
|
{
|
||||||
|
|
3
4ed.h
3
4ed.h
|
@ -81,7 +81,6 @@ struct Mouse_Summary{
|
||||||
struct Input_Summary{
|
struct Input_Summary{
|
||||||
Mouse_Summary mouse;
|
Mouse_Summary mouse;
|
||||||
Key_Summary keys;
|
Key_Summary keys;
|
||||||
Key_Codes *codes;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Command_Line_Parameters{
|
struct Command_Line_Parameters{
|
||||||
|
@ -115,7 +114,6 @@ name(System_Functions *system, \
|
||||||
Render_Target *target, \
|
Render_Target *target, \
|
||||||
Application_Memory *memory, \
|
Application_Memory *memory, \
|
||||||
Exchange *exchange, \
|
Exchange *exchange, \
|
||||||
Key_Codes *codes, \
|
|
||||||
String clipboard, \
|
String clipboard, \
|
||||||
String current_directory, \
|
String current_directory, \
|
||||||
Custom_API api)
|
Custom_API api)
|
||||||
|
@ -140,7 +138,6 @@ struct Application_Step_Result{
|
||||||
|
|
||||||
#define App_Step_Sig(name) void \
|
#define App_Step_Sig(name) void \
|
||||||
name(System_Functions *system, \
|
name(System_Functions *system, \
|
||||||
Key_Codes *codes, \
|
|
||||||
Key_Input_Data *input, \
|
Key_Input_Data *input, \
|
||||||
Mouse_State *mouse, \
|
Mouse_State *mouse, \
|
||||||
Render_Target *target, \
|
Render_Target *target, \
|
||||||
|
|
|
@ -452,21 +452,20 @@ do_channel_field(i32 sub_id, Color_UI *ui, u8 *channel, Channel_Field_Type ftype
|
||||||
i32 indx = ui->state.selected.sub_id2;
|
i32 indx = ui->state.selected.sub_id2;
|
||||||
if (ui->state.input_stage){
|
if (ui->state.input_stage){
|
||||||
Key_Summary *keys = ui->state.keys;
|
Key_Summary *keys = ui->state.keys;
|
||||||
Key_Codes *codes = ui->state.codes;
|
|
||||||
for (i32 key_i = 0; key_i < keys->count; ++key_i){
|
for (i32 key_i = 0; key_i < keys->count; ++key_i){
|
||||||
Key_Event_Data key = get_single_key(keys, key_i);
|
Key_Event_Data key = get_single_key(keys, key_i);
|
||||||
|
|
||||||
if (key.keycode == codes->right){
|
if (key.keycode == key_right){
|
||||||
++indx;
|
++indx;
|
||||||
if (indx > digit_count-1) indx = 0;
|
if (indx > digit_count-1) indx = 0;
|
||||||
}
|
}
|
||||||
if (key.keycode == codes->left){
|
if (key.keycode == key_left){
|
||||||
--indx;
|
--indx;
|
||||||
if (indx < 0) indx = digit_count-1;
|
if (indx < 0) indx = digit_count-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
i32 new_value = *channel;
|
i32 new_value = *channel;
|
||||||
if (key.keycode == codes->up || key.keycode == codes->down){
|
if (key.keycode == key_up || key.keycode == key_down){
|
||||||
i32 place = digit_count-1-indx;
|
i32 place = digit_count-1-indx;
|
||||||
i32 base = (ftype == CF_DEC)?10:0x10;
|
i32 base = (ftype == CF_DEC)?10:0x10;
|
||||||
i32 step_amount = 1;
|
i32 step_amount = 1;
|
||||||
|
@ -474,7 +473,7 @@ do_channel_field(i32 sub_id, Color_UI *ui, u8 *channel, Channel_Field_Type ftype
|
||||||
step_amount *= base;
|
step_amount *= base;
|
||||||
--place;
|
--place;
|
||||||
}
|
}
|
||||||
if (key.keycode == codes->down){
|
if (key.keycode == key_down){
|
||||||
step_amount = 0 - step_amount;
|
step_amount = 0 - step_amount;
|
||||||
}
|
}
|
||||||
new_value += step_amount;
|
new_value += step_amount;
|
||||||
|
|
|
@ -3406,7 +3406,7 @@ HANDLE_COMMAND_SIG(handle_command_file_view){
|
||||||
if (binding.function) binding.function(system, command, binding);
|
if (binding.function) binding.function(system, command, binding);
|
||||||
file_view->mode = file_view->next_mode;
|
file_view->mode = file_view->next_mode;
|
||||||
|
|
||||||
if (key.keycode == codes->esc)
|
if (key.keycode == key_esc)
|
||||||
view_set_widget(file_view, FWIDG_NONE);
|
view_set_widget(file_view, FWIDG_NONE);
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
|
@ -3415,7 +3415,7 @@ HANDLE_COMMAND_SIG(handle_command_file_view){
|
||||||
#if BUFFER_EXPERIMENT_SCALPEL <= 3
|
#if BUFFER_EXPERIMENT_SCALPEL <= 3
|
||||||
String *string = &file_view->isearch.str;
|
String *string = &file_view->isearch.str;
|
||||||
Single_Line_Input_Step result =
|
Single_Line_Input_Step result =
|
||||||
app_single_line_input_step(system, codes, key, string);
|
app_single_line_input_step(system, key, string);
|
||||||
|
|
||||||
if (result.made_a_change ||
|
if (result.made_a_change ||
|
||||||
binding.function == command_search ||
|
binding.function == command_search ||
|
||||||
|
@ -3500,7 +3500,7 @@ HANDLE_COMMAND_SIG(handle_command_file_view){
|
||||||
{
|
{
|
||||||
String *string = &file_view->gotoline.str;
|
String *string = &file_view->gotoline.str;
|
||||||
Single_Line_Input_Step result =
|
Single_Line_Input_Step result =
|
||||||
app_single_number_input_step(system, codes, key, string);
|
app_single_number_input_step(system, key, string);
|
||||||
|
|
||||||
if (result.hit_newline || result.hit_ctrl_newline){
|
if (result.hit_newline || result.hit_ctrl_newline){
|
||||||
i32 line_number = str_to_int(*string);
|
i32 line_number = str_to_int(*string);
|
||||||
|
|
30
4ed_gui.cpp
30
4ed_gui.cpp
|
@ -149,12 +149,11 @@ struct Single_Line_Mode{
|
||||||
};
|
};
|
||||||
|
|
||||||
internal Single_Line_Input_Step
|
internal Single_Line_Input_Step
|
||||||
app_single_line_input_core(System_Functions *system,
|
app_single_line_input_core(System_Functions *system, Working_Set *working_set,
|
||||||
Key_Codes *codes, Working_Set *working_set,
|
|
||||||
Key_Event_Data key, Single_Line_Mode mode){
|
Key_Event_Data key, Single_Line_Mode mode){
|
||||||
Single_Line_Input_Step result = {};
|
Single_Line_Input_Step result = {};
|
||||||
|
|
||||||
if (key.keycode == codes->back){
|
if (key.keycode == key_back){
|
||||||
result.hit_backspace = 1;
|
result.hit_backspace = 1;
|
||||||
if (mode.string->size > 0){
|
if (mode.string->size > 0){
|
||||||
result.made_a_change = 1;
|
result.made_a_change = 1;
|
||||||
|
@ -221,7 +220,7 @@ app_single_line_input_core(System_Functions *system,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (key.keycode == codes->esc){
|
else if (key.keycode == key_esc){
|
||||||
result.hit_esc = 1;
|
result.hit_esc = 1;
|
||||||
result.made_a_change = 1;
|
result.made_a_change = 1;
|
||||||
}
|
}
|
||||||
|
@ -251,16 +250,15 @@ app_single_line_input_core(System_Functions *system,
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Single_Line_Input_Step
|
inline Single_Line_Input_Step
|
||||||
app_single_line_input_step(System_Functions *system,
|
app_single_line_input_step(System_Functions *system, Key_Event_Data key, String *string){
|
||||||
Key_Codes *codes, Key_Event_Data key, String *string){
|
|
||||||
Single_Line_Mode mode = {};
|
Single_Line_Mode mode = {};
|
||||||
mode.type = SINGLE_LINE_STRING;
|
mode.type = SINGLE_LINE_STRING;
|
||||||
mode.string = string;
|
mode.string = string;
|
||||||
return app_single_line_input_core(system, codes, 0, key, mode);
|
return app_single_line_input_core(system, 0, key, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Single_Line_Input_Step
|
inline Single_Line_Input_Step
|
||||||
app_single_file_input_step(System_Functions *system, Key_Codes *codes,
|
app_single_file_input_step(System_Functions *system,
|
||||||
Working_Set *working_set, Key_Event_Data key,
|
Working_Set *working_set, Key_Event_Data key,
|
||||||
String *string, Hot_Directory *hot_directory,
|
String *string, Hot_Directory *hot_directory,
|
||||||
b32 fast_folder_select, b32 try_to_match, b32 case_sensitive){
|
b32 fast_folder_select, b32 try_to_match, b32 case_sensitive){
|
||||||
|
@ -271,12 +269,11 @@ app_single_file_input_step(System_Functions *system, Key_Codes *codes,
|
||||||
mode.fast_folder_select = fast_folder_select;
|
mode.fast_folder_select = fast_folder_select;
|
||||||
mode.try_to_match = try_to_match;
|
mode.try_to_match = try_to_match;
|
||||||
mode.case_sensitive = case_sensitive;
|
mode.case_sensitive = case_sensitive;
|
||||||
return app_single_line_input_core(system, codes, working_set, key, mode);
|
return app_single_line_input_core(system, working_set, key, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Single_Line_Input_Step
|
inline Single_Line_Input_Step
|
||||||
app_single_number_input_step(System_Functions *system, Key_Codes *codes,
|
app_single_number_input_step(System_Functions *system, Key_Event_Data key, String *string){
|
||||||
Key_Event_Data key, String *string){
|
|
||||||
Single_Line_Input_Step result = {};
|
Single_Line_Input_Step result = {};
|
||||||
Single_Line_Mode mode = {};
|
Single_Line_Mode mode = {};
|
||||||
mode.type = SINGLE_LINE_STRING;
|
mode.type = SINGLE_LINE_STRING;
|
||||||
|
@ -284,7 +281,7 @@ app_single_number_input_step(System_Functions *system, Key_Codes *codes,
|
||||||
|
|
||||||
char c = (char)key.character;
|
char c = (char)key.character;
|
||||||
if (c == 0 || c == '\n' || char_is_numeric(c))
|
if (c == 0 || c == '\n' || char_is_numeric(c))
|
||||||
result = app_single_line_input_core(system, codes, 0, key, mode);
|
result = app_single_line_input_core(system, 0, key, mode);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,7 +304,6 @@ struct UI_State{
|
||||||
Font_Set *font_set;
|
Font_Set *font_set;
|
||||||
Mouse_Summary *mouse;
|
Mouse_Summary *mouse;
|
||||||
Key_Summary *keys;
|
Key_Summary *keys;
|
||||||
Key_Codes *codes;
|
|
||||||
Working_Set *working_set;
|
Working_Set *working_set;
|
||||||
i16 font_id;
|
i16 font_id;
|
||||||
|
|
||||||
|
@ -509,7 +505,6 @@ ui_state_init(UI_State *state_in, Render_Target *target, Input_Summary *user_inp
|
||||||
if (user_input){
|
if (user_input){
|
||||||
state.mouse = &user_input->mouse;
|
state.mouse = &user_input->mouse;
|
||||||
state.keys = &user_input->keys;
|
state.keys = &user_input->keys;
|
||||||
state.codes = user_input->codes;
|
|
||||||
}
|
}
|
||||||
state.selected = state_in->selected;
|
state.selected = state_in->selected;
|
||||||
state.hot = state_in->hot;
|
state.hot = state_in->hot;
|
||||||
|
@ -678,7 +673,7 @@ ui_do_text_field_input(UI_State *state, String *str){
|
||||||
else if (c == '\n'){
|
else if (c == '\n'){
|
||||||
result = 1;
|
result = 1;
|
||||||
}
|
}
|
||||||
else if (key.keycode == state->codes->back && str->size > 0){
|
else if (key.keycode == key_back && str->size > 0){
|
||||||
str->str[--str->size] = 0;
|
str->str[--str->size] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -700,8 +695,7 @@ ui_do_file_field_input(System_Functions *system, UI_State *state,
|
||||||
for (key_i = 0; key_i < keys->count; ++key_i){
|
for (key_i = 0; key_i < keys->count; ++key_i){
|
||||||
key = get_single_key(keys, key_i);
|
key = get_single_key(keys, key_i);
|
||||||
step =
|
step =
|
||||||
app_single_file_input_step(system, state->codes,
|
app_single_file_input_step(system, state->working_set, key, str,
|
||||||
state->working_set, key, str,
|
|
||||||
hot_dir, 1, try_to_match, case_sensitive);
|
hot_dir, 1, try_to_match, case_sensitive);
|
||||||
if ((step.hit_newline || step.hit_ctrl_newline) && !step.no_file_match) result = 1;
|
if ((step.hit_newline || step.hit_ctrl_newline) && !step.no_file_match) result = 1;
|
||||||
}
|
}
|
||||||
|
@ -717,7 +711,7 @@ ui_do_line_field_input(System_Functions *system,
|
||||||
Key_Event_Data key = get_single_key(keys, key_i);
|
Key_Event_Data key = get_single_key(keys, key_i);
|
||||||
terminate_with_null(string);
|
terminate_with_null(string);
|
||||||
Single_Line_Input_Step step =
|
Single_Line_Input_Step step =
|
||||||
app_single_line_input_step(system, state->codes, key, string);
|
app_single_line_input_step(system, key, string);
|
||||||
if (step.hit_newline || step.hit_ctrl_newline) result = 1;
|
if (step.hit_newline || step.hit_ctrl_newline) result = 1;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -170,7 +170,7 @@ step_draw_int_view(System_Functions *system, Interactive_View *view,
|
||||||
case 'n': case 'N': action = 1; break;
|
case 'n': case 'N': action = 1; break;
|
||||||
case 's': case 'S': action = 2; break;
|
case 's': case 'S': action = 2; break;
|
||||||
}
|
}
|
||||||
if (action == -1 && key.keycode == state.codes->esc) action = 1;
|
if (action == -1 && key.keycode == key_esc) action = 1;
|
||||||
if (action != -1) break;
|
if (action != -1) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,21 +11,6 @@
|
||||||
|
|
||||||
globalvar u8 keycode_lookup_table[255];
|
globalvar u8 keycode_lookup_table[255];
|
||||||
|
|
||||||
internal void
|
|
||||||
set_dynamic_key_names(Key_Codes *codes){
|
|
||||||
u8 code = 1;
|
|
||||||
u8 *codes_array = (u8*)codes;
|
|
||||||
for (i32 i = 0; i < sizeof(*codes)/sizeof(codes->up);){
|
|
||||||
switch (code){
|
|
||||||
case '\n': code++; break;
|
|
||||||
case '\t': code++; break;
|
|
||||||
case 0x20: code = 0x7F; break;
|
|
||||||
default:
|
|
||||||
codes_array[i++] = code++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline u8
|
inline u8
|
||||||
keycode_lookup(u8 system_code){
|
keycode_lookup(u8 system_code){
|
||||||
return keycode_lookup_table[system_code];
|
return keycode_lookup_table[system_code];
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
enum Key_Code{
|
||||||
|
key_back = 1,
|
||||||
|
key_up = 2,
|
||||||
|
key_down = 3,
|
||||||
|
key_left = 4,
|
||||||
|
key_right = 5,
|
||||||
|
key_del = 6,
|
||||||
|
key_insert = 7,
|
||||||
|
key_home = 8,
|
||||||
|
key_end = 11,
|
||||||
|
key_page_up = 12,
|
||||||
|
key_page_down = 13,
|
||||||
|
key_esc = 14,
|
||||||
|
key_f1 = 127,
|
||||||
|
key_f2 = 128,
|
||||||
|
key_f3 = 129,
|
||||||
|
key_f4 = 130,
|
||||||
|
key_f5 = 131,
|
||||||
|
key_f6 = 132,
|
||||||
|
key_f7 = 133,
|
||||||
|
key_f8 = 134,
|
||||||
|
key_f9 = 135,
|
||||||
|
key_f10 = 136,
|
||||||
|
key_f11 = 137,
|
||||||
|
key_f12 = 138,
|
||||||
|
key_f13 = 139,
|
||||||
|
key_f14 = 140,
|
||||||
|
key_f15 = 141,
|
||||||
|
key_f15 = 142,
|
||||||
|
}
|
|
@ -8,10 +8,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// TOP
|
// TOP
|
||||||
// TODO(allen):
|
|
||||||
//
|
|
||||||
// BUGS
|
|
||||||
//
|
|
||||||
|
|
||||||
struct Interactive_Style{
|
struct Interactive_Style{
|
||||||
u32 bar_color;
|
u32 bar_color;
|
||||||
|
@ -49,7 +45,7 @@ typedef Do_View_Sig(Do_View_Function);
|
||||||
#define HANDLE_COMMAND_SIG(name) \
|
#define HANDLE_COMMAND_SIG(name) \
|
||||||
void (name)(System_Functions *system, View *view, \
|
void (name)(System_Functions *system, View *view, \
|
||||||
Command_Data *command, Command_Binding binding, \
|
Command_Data *command, Command_Binding binding, \
|
||||||
Key_Event_Data key, Key_Codes *codes)
|
Key_Event_Data key)
|
||||||
|
|
||||||
typedef HANDLE_COMMAND_SIG(Handle_Command_Function);
|
typedef HANDLE_COMMAND_SIG(Handle_Command_Function);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
/*
|
||||||
|
* Mr. 4th Dimention - Allen Webster
|
||||||
|
*
|
||||||
|
* 25.02.2016
|
||||||
|
*
|
||||||
|
* File editing view for 4coder
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TOP
|
||||||
|
|
||||||
|
#define ArrayCount(a) (sizeof(a)/sizeof(*a))
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
char *keys_that_need_codes[] = {
|
||||||
|
"back",
|
||||||
|
"up",
|
||||||
|
"down",
|
||||||
|
"left",
|
||||||
|
"right",
|
||||||
|
"del",
|
||||||
|
"insert",
|
||||||
|
"home",
|
||||||
|
"end",
|
||||||
|
"page_up",
|
||||||
|
"page_down",
|
||||||
|
"esc",
|
||||||
|
|
||||||
|
"f1",
|
||||||
|
"f2",
|
||||||
|
"f3",
|
||||||
|
"f4",
|
||||||
|
"f5",
|
||||||
|
"f6",
|
||||||
|
"f7",
|
||||||
|
"f8",
|
||||||
|
|
||||||
|
"f9",
|
||||||
|
"f10",
|
||||||
|
"f11",
|
||||||
|
"f12",
|
||||||
|
"f13",
|
||||||
|
"f14",
|
||||||
|
"f15",
|
||||||
|
"f16",
|
||||||
|
};
|
||||||
|
|
||||||
|
void generate_keycode_enum(){
|
||||||
|
FILE *file;
|
||||||
|
char filename[] = "4coder_keycodes.h";
|
||||||
|
int i, count;
|
||||||
|
unsigned char code = 1;
|
||||||
|
|
||||||
|
file = fopen(filename, "wb");
|
||||||
|
fprintf(file, "enum Key_Code{\n");
|
||||||
|
count = ArrayCount(keys_that_need_codes);
|
||||||
|
for (i = 0; i < count;){
|
||||||
|
if (strcmp(keys_that_need_codes[i], "f1") == 0 && code < 0x7F){
|
||||||
|
code = 0x7F;
|
||||||
|
}
|
||||||
|
switch (code){
|
||||||
|
case '\n': code++; break;
|
||||||
|
case '\t': code++; break;
|
||||||
|
case 0x20: code = 0x7F; break;
|
||||||
|
default:
|
||||||
|
fprintf(file, "key_%s = %d,\n", keys_that_need_codes[i++], code++);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fprintf(file, "};\n");
|
||||||
|
fclose(file);
|
||||||
|
printf("gen success: %s\n", filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
generate_keycode_enum();
|
||||||
|
}
|
||||||
|
|
||||||
|
// BOTTOM
|
||||||
|
|
|
@ -12,21 +12,19 @@
|
||||||
#include "4ed_keyboard.cpp"
|
#include "4ed_keyboard.cpp"
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
keycode_init(Key_Codes *codes){
|
keycode_init(){
|
||||||
set_dynamic_key_names(codes);
|
keycode_lookup_table[VK_BACK] = key_back;
|
||||||
|
keycode_lookup_table[VK_DELETE] = key_del;
|
||||||
keycode_lookup_table[VK_BACK] = codes->back;
|
keycode_lookup_table[VK_UP] = key_up;
|
||||||
keycode_lookup_table[VK_DELETE] = codes->del;
|
keycode_lookup_table[VK_DOWN] = key_down;
|
||||||
keycode_lookup_table[VK_UP] = codes->up;
|
keycode_lookup_table[VK_LEFT] = key_left;
|
||||||
keycode_lookup_table[VK_DOWN] = codes->down;
|
keycode_lookup_table[VK_RIGHT] = key_right;
|
||||||
keycode_lookup_table[VK_LEFT] = codes->left;
|
keycode_lookup_table[VK_INSERT] = key_insert;
|
||||||
keycode_lookup_table[VK_RIGHT] = codes->right;
|
keycode_lookup_table[VK_HOME] = key_home;
|
||||||
keycode_lookup_table[VK_INSERT] = codes->insert;
|
keycode_lookup_table[VK_END] = key_end;
|
||||||
keycode_lookup_table[VK_HOME] = codes->home;
|
keycode_lookup_table[VK_PRIOR] = key_page_up;
|
||||||
keycode_lookup_table[VK_END] = codes->end;
|
keycode_lookup_table[VK_NEXT] = key_page_down;
|
||||||
keycode_lookup_table[VK_PRIOR] = codes->page_up;
|
keycode_lookup_table[VK_ESCAPE] = key_esc;
|
||||||
keycode_lookup_table[VK_NEXT] = codes->page_down;
|
|
||||||
keycode_lookup_table[VK_ESCAPE] = codes->esc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// BOTTOM
|
// BOTTOM
|
||||||
|
|
|
@ -107,7 +107,6 @@ struct Win32_Vars{
|
||||||
HANDLE update_loop_thread;
|
HANDLE update_loop_thread;
|
||||||
DWORD update_loop_thread_id;
|
DWORD update_loop_thread_id;
|
||||||
|
|
||||||
Key_Codes key_codes;
|
|
||||||
Win32_Input_Chunk input_chunk;
|
Win32_Input_Chunk input_chunk;
|
||||||
b32 lctrl_lalt_is_altgr;
|
b32 lctrl_lalt_is_altgr;
|
||||||
|
|
||||||
|
@ -1385,7 +1384,6 @@ UpdateLoop(LPVOID param){
|
||||||
result.lctrl_lalt_is_altgr = win32vars.lctrl_lalt_is_altgr;
|
result.lctrl_lalt_is_altgr = win32vars.lctrl_lalt_is_altgr;
|
||||||
|
|
||||||
win32vars.app.step(win32vars.system,
|
win32vars.app.step(win32vars.system,
|
||||||
&win32vars.key_codes,
|
|
||||||
&input_data,
|
&input_data,
|
||||||
&mouse,
|
&mouse,
|
||||||
&win32vars.target,
|
&win32vars.target,
|
||||||
|
@ -1586,8 +1584,6 @@ main(int argc, char **argv){
|
||||||
win32vars.start_time = ((u64)filetime.dwHighDateTime << 32) | (filetime.dwLowDateTime);
|
win32vars.start_time = ((u64)filetime.dwHighDateTime << 32) | (filetime.dwLowDateTime);
|
||||||
win32vars.start_time /= 10;
|
win32vars.start_time /= 10;
|
||||||
|
|
||||||
keycode_init(&win32vars.key_codes);
|
|
||||||
|
|
||||||
#ifdef FRED_SUPER
|
#ifdef FRED_SUPER
|
||||||
char *custom_file_default = "4coder_custom.dll";
|
char *custom_file_default = "4coder_custom.dll";
|
||||||
char *custom_file;
|
char *custom_file;
|
||||||
|
@ -1789,7 +1785,7 @@ main(int argc, char **argv){
|
||||||
sysshared_init_font_params(&win32vars.fnt, params, ArrayCount(params));
|
sysshared_init_font_params(&win32vars.fnt, params, ArrayCount(params));
|
||||||
|
|
||||||
win32vars.app.init(win32vars.system, &win32vars.target,
|
win32vars.app.init(win32vars.system, &win32vars.target,
|
||||||
&memory_vars, &exchange_vars, &win32vars.key_codes,
|
&memory_vars, &exchange_vars,
|
||||||
win32vars.clipboard_contents, current_directory,
|
win32vars.clipboard_contents, current_directory,
|
||||||
win32vars.custom_api);
|
win32vars.custom_api);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue