a3.2 & gap buffer finished

This commit is contained in:
Allen Webster 2015-10-29 20:48:30 -04:00
parent 7c2d26463e
commit 02d72d118d
9 changed files with 247 additions and 4194 deletions

View File

@ -127,7 +127,7 @@ CUSTOM_COMMAND_SIG(open_my_files){
my_file[i] = ("w:/4ed/data/test/basic.txt")[i];
}
// NOTE(allen|3.1): null terminators are not needed for strings.
// NOTE(allen|a3.1): null terminators are not needed for strings.
push_parameter(cmd_context, par_name, my_file, my_file_len);
exec_command(cmd_context, cmdid_interactive_open);
@ -181,7 +181,7 @@ extern "C" GET_BINDING_DATA(get_bindings){
bind(context, codes->right, MDFR_CTRL, cmdid_seek_alphanumeric_or_camel_right);
bind(context, codes->left, MDFR_CTRL, cmdid_seek_alphanumeric_or_camel_left);
// NOTE(allen|a3.1.1): Specific keys can override vanilla keys,
// 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_me(context, '\n', MDFR_NONE, write_and_auto_tab);
@ -244,7 +244,7 @@ extern "C" GET_BINDING_DATA(get_bindings){
bind(context, '?', MDFR_CTRL, cmdid_toggle_show_whitespace);
bind(context, '~', MDFR_CTRL, cmdid_clean_all_lines);
// NOTE(allen|a3.1.1): These now only set the mode of the file for writing to disk
// NOTE(allen|a3.2): These now only set the mode of the file for writing to disk
// they do no longer effect the internal representation.
bind(context, '1', MDFR_CTRL, cmdid_eol_dosify);
bind(context, '!', MDFR_CTRL, cmdid_eol_nixify);

1
4ed.h
View File

@ -246,7 +246,6 @@ struct Render_Target{
struct Application_Memory{
void *vars_memory;
i32 vars_memory_size;
void *target_memory;
i32 target_memory_size;
};

View File

@ -1746,7 +1746,6 @@ struct Edit_Spec{
Edit_Step step;
};
#if BUFFER_EXPERIMENT_SCALPEL
internal Edit_Step*
file_post_undo(General_Memory *general, Editing_File *file,
Edit_Step step, bool32 do_merge, bool32 can_merge){
@ -1950,7 +1949,6 @@ file_post_history(General_Memory *general, Editing_File *file,
return result;
}
#endif
inline Full_Cursor
view_compute_cursor_from_pos(File_View *view, i32 pos){
@ -2214,7 +2212,6 @@ enum History_Mode{
internal void
view_update_history_before_edit(Mem_Options *mem, Editing_File *file, Edit_Step step, u8 *str,
History_Mode history_mode){
#if BUFFER_EXPERIMENT_SCALPEL
General_Memory *general = &mem->general;
#if FRED_SLOW
@ -2379,7 +2376,6 @@ view_update_history_before_edit(Mem_Options *mem, Editing_File *file, Edit_Step
}
if (history_mode == hist_normal) file->undo.edit_history_cursor = file->undo.history.edit_count;
#endif
}
inline b32
@ -2450,7 +2446,6 @@ view_do_single_edit(Mem_Options *mem, File_View *view, Editing_File *file,
}
}
#if BUFFER_EXPERIMENT_SCALPEL
Temp_Memory cursor_temp = begin_temp_memory(&mem->part);
i32 cursor_max = layout->panel_max_count * 2;
Cursor_With_Index *cursors = push_array(&mem->part, Cursor_With_Index, cursor_max);
@ -2489,13 +2484,11 @@ view_do_single_edit(Mem_Options *mem, File_View *view, Editing_File *file,
}
end_temp_memory(cursor_temp);
#endif
}
internal void
view_do_white_batch_edit(Mem_Options *mem, File_View *view, Editing_File *file,
Editing_Layout *layout, Edit_Spec spec, History_Mode history_mode){
#if BUFFER_EXPERIMENT_SCALPEL
Assert(file);
ProfileMomentFunction();
@ -2587,7 +2580,6 @@ view_do_white_batch_edit(Mem_Options *mem, File_View *view, Editing_File *file,
}
end_temp_memory(cursor_temp);
}
#endif
}
inline void
@ -2853,7 +2845,6 @@ view_compute_whitespace_edit(Mem_Options *mem, Editing_File *file,
Buffer_Edit *edits, char *str_base, i32 str_size,
Buffer_Edit *inverse_array, char *inv_str, i32 inv_max,
i32 edit_count){
#if BUFFER_EXPERIMENT_SCALPEL
General_Memory *general = &mem->general;
i32 inv_str_pos = 0;
@ -2876,15 +2867,12 @@ view_compute_whitespace_edit(Mem_Options *mem, Editing_File *file,
spec.step.special_type = 1;
spec.step.child_count = edit_count;
spec.step.inverse_child_count = edit_count;
#else
Edit_Spec spec = {};
#endif
return spec;
}
internal void
view_clean_whitespace(Mem_Options *mem, File_View *view, Editing_Layout *layout){
#if BUFFER_EXPERIMENT_SCALPEL
Editing_File *file = view->file;
Assert(file && !file->is_dummy);
Partition *part = &mem->part;
@ -2938,7 +2926,6 @@ view_clean_whitespace(Mem_Options *mem, File_View *view, Editing_Layout *layout)
}
end_temp_memory(temp);
#endif
}
internal void
@ -2995,7 +2982,17 @@ view_auto_tab_tokens(Mem_Options *mem, File_View *view, Editing_Layout *layout,
if (result.in_whitespace) token_i += 1;
token = tokens.tokens + token_i;
if (token->start < start_pos){
while (token >= tokens.tokens &&
token->flags & CPP_TFLAG_PP_DIRECTIVE ||
token->flags & CPP_TFLAG_PP_BODY){
--token;
}
if (token < tokens.tokens){
++token;
current_indent = 0;
}
else if (token->start < start_pos){
line = buffer_get_line_index(&file->buffer, token->start);
i32 start = file->buffer.line_starts[line];
b32 all_whitespace = 0;
@ -3028,18 +3025,25 @@ view_auto_tab_tokens(Mem_Options *mem, File_View *view, Editing_Layout *layout,
else{
this_indent = current_indent;
if (token->start < next_line_start){
switch (token->type){
case CPP_TOKEN_BRACKET_CLOSE: this_indent -= 4; break;
case CPP_TOKEN_PARENTHESE_CLOSE: this_indent -= 4; break;
case CPP_TOKEN_BRACE_CLOSE: this_indent -= 4; break;
case CPP_TOKEN_BRACE_OPEN: break;
default:
if (current_indent > 0 && prev_token){
switch (prev_token->type){
case CPP_TOKEN_BRACKET_OPEN: case CPP_TOKEN_PARENTHESE_OPEN:
case CPP_TOKEN_BRACE_OPEN: case CPP_TOKEN_BRACE_CLOSE:
case CPP_TOKEN_SEMICOLON: case CPP_TOKEN_COLON: break;
default: this_indent += 4;
if (token->flags & CPP_TFLAG_PP_DIRECTIVE) this_indent = 0;
else{
switch (token->type){
case CPP_TOKEN_BRACKET_CLOSE: this_indent -= 4; break;
case CPP_TOKEN_PARENTHESE_CLOSE: this_indent -= 4; break;
case CPP_TOKEN_BRACE_CLOSE: this_indent -= 4; break;
case CPP_TOKEN_BRACE_OPEN: break;
default:
if (current_indent > 0 && prev_token){
if (!(prev_token->flags & CPP_TFLAG_PP_BODY ||
prev_token->flags & CPP_TFLAG_PP_DIRECTIVE)){
switch (prev_token->type){
case CPP_TOKEN_BRACKET_OPEN: case CPP_TOKEN_PARENTHESE_OPEN:
case CPP_TOKEN_BRACE_OPEN: case CPP_TOKEN_BRACE_CLOSE:
case CPP_TOKEN_SEMICOLON: case CPP_TOKEN_COLON: break;
case CPP_TOKEN_COMMA: case CPP_TOKEN_COMMENT: break;
default: this_indent += 4;
}
}
}
}
}
@ -3660,7 +3664,6 @@ draw_file_view(Thread_Context *thread, View *view_, i32_Rect rect, bool32 is_act
b32 tokens_use = file->tokens_complete && (file->token_stack.count > 0);
Cpp_Token_Stack token_stack = file->token_stack;
#if 1
Partition *part = &view_->mem->part;
Temp_Memory temp = begin_temp_memory(part);
@ -3718,12 +3721,10 @@ draw_file_view(Thread_Context *thread, View *view_, i32_Rect rect, bool32 is_act
}
}
#if BUFFER_EXPERIMENT_SCALPEL
if (current_token.type == CPP_TOKEN_JUNK &&
i >= current_token.start && i <= current_token.start + current_token.size){
highlight_color = style->main.highlight_junk_color;
}
#endif
}
u32 char_color = main_color;
@ -3732,17 +3733,31 @@ draw_file_view(Thread_Context *thread, View *view_, i32_Rect rect, bool32 is_act
else draw_rectangle_outline(target, f32R(item->x0, item->y0, item->x1, item->y1), cursor_color);
char_color = at_cursor_color;
}
u32 fade_color = 0xFFFF00FF;
f32 fade_amount = 0.f;
if (view->paste_effect.tick_down > 0 &&
view->paste_effect.start <= i && i < view->paste_effect.end){
fade_color = view->paste_effect.color;
fade_amount = (real32)(view->paste_effect.tick_down) / view->paste_effect.tick_max;
}
char_color = color_blend(char_color, fade_amount, fade_color);
if (ind == view->mark && prev_ind != ind){
draw_rectangle_outline(target, f32R(item->x0, item->y0, item->x1, item->y1), mark_color);
}
font_draw_glyph(target, font, (u16)item->glyphid,
item->x0, item->y0, char_color);
if (item->glyphid != 0){
font_draw_glyph(target, font, (u16)item->glyphid,
item->x0, item->y0, char_color);
}
prev_ind = ind;
}
end_temp_memory(temp);
#else
#if 0
i32 size = (i32)file->buffer.size;
u8 *data = (u8*)file->buffer.data;
@ -3874,7 +3889,7 @@ draw_file_view(Thread_Context *thread, View *view_, i32_Rect rect, bool32 is_act
special_char_color = char_color = style->main.at_highlight_color; break;
}
}
char_color = color_blend(char_color, fade_amount, fade_color);
special_char_color = color_blend(special_char_color, fade_amount, fade_color);

File diff suppressed because it is too large Load Diff

View File

@ -54,7 +54,7 @@ buffer_count_newlines(Buffer_Type *buffer, int start, int end){
assert_4tech(0 <= start);
assert_4tech(start <= end);
assert_4tech(end < buffer_size(buffer));
assert_4tech(end <= buffer_size(buffer));
count = 0;
@ -127,13 +127,13 @@ buffer_seek_whitespace_up(Buffer_Type *buffer, int pos){
int no_hard;
size = buffer_size(buffer);
loop = buffer_backify_loop(buffer, pos, 0, size);
loop = buffer_backify_loop(buffer, pos, 1, size);
for (;buffer_backify_good(&loop);
buffer_backify_next(&loop)){
end = loop.absolute_pos;
data = loop.data - loop.absolute_pos;
for (;pos >= end && pos > 0; --pos){
for (;pos >= end; --pos){
if (!is_whitespace(data[pos])) goto buffer_seek_whitespace_up_mid;
}
}
@ -144,7 +144,7 @@ buffer_seek_whitespace_up_mid:
buffer_backify_next(&loop)){
end = loop.absolute_pos;
data = loop.data - loop.absolute_pos;
for (; pos >= end && pos > 0; --pos){
for (; pos >= end; --pos){
if (data[pos] == '\n'){
if (no_hard) goto buffer_seek_whitespace_up_end;
else no_hard = 1;
@ -200,7 +200,7 @@ buffer_seek_whitespace_left(Buffer_Type *buffer, int pos){
--pos;
if (pos > 0){
size = buffer_size(buffer);
loop = buffer_backify_loop(buffer, pos, 0, size);
loop = buffer_backify_loop(buffer, pos, 1, size);
for (;buffer_backify_good(&loop);
buffer_backify_next(&loop)){
@ -266,7 +266,7 @@ buffer_seek_alphanumeric_left(Buffer_Type *buffer, int pos){
--pos;
if (pos >= 0){
size = buffer_size(buffer);
loop = buffer_backify_loop(buffer, pos, 0, size);
loop = buffer_backify_loop(buffer, pos, 1, size);
for (;buffer_backify_good(&loop);
buffer_backify_next(&loop)){
@ -301,8 +301,8 @@ buffer_seek_alphanumeric_or_camel_right(Buffer_Type *buffer, int pos, int an_pos
char ch, prev_ch;
size = buffer_size(buffer);
assert_4tech(pos < an_pos);
assert_4tech(an_pos < size);
assert_4tech(pos <= an_pos);
assert_4tech(an_pos <= size);
++pos;
if (pos < an_pos){
@ -339,10 +339,10 @@ buffer_seek_alphanumeric_or_camel_left(Buffer_Type *buffer, int pos, int an_pos)
char ch, prev_ch;
size = buffer_size(buffer);
assert_4tech(an_pos < pos);
assert_4tech(an_pos <= pos);
assert_4tech(0 <= an_pos);
loop = buffer_backify_loop(buffer, pos, an_pos, size);
loop = buffer_backify_loop(buffer, pos, an_pos+1, size);
if (buffer_backify_good(&loop)){
prev_ch = loop.data[0];
--pos;
@ -351,7 +351,7 @@ buffer_seek_alphanumeric_or_camel_left(Buffer_Type *buffer, int pos, int an_pos)
buffer_backify_next(&loop)){
end = loop.absolute_pos;
data = loop.data - loop.absolute_pos;
for (; pos >= end && pos > 0; --pos){
for (; pos >= end; --pos){
ch = data[pos];
if (is_upper(ch) && is_lower(prev_ch)) goto buffer_seek_alphanumeric_or_camel_left_end;
prev_ch = ch;
@ -363,6 +363,46 @@ buffer_seek_alphanumeric_or_camel_left_end:
return(pos);
}
internal_4tech int
buffer_find_hard_start(Buffer_Type *buffer, int line_start, int *all_whitespace, int *all_space,
int *preferred_indent, int tab_width){
Buffer_Stringify_Type loop;
char *data;
int size, end;
int result;
char c;
*all_space = 1;
*preferred_indent = 0;
size = buffer_size(buffer);
tab_width -= 1;
result = line_start;
for (loop = buffer_stringify_loop(buffer, line_start, size, size);
buffer_stringify_good(&loop);
buffer_stringify_next(&loop)){
end = loop.size + loop.absolute_pos;
data = loop.data - loop.absolute_pos;
for (; result < end; ++result){
c = data[result];
if (c == '\n' || c == 0){
*all_whitespace = 1;
goto buffer_find_hard_start_end;
}
if (c >= '!' && c <= '~') goto buffer_find_hard_start_end;
if (c == '\t') *preferred_indent += tab_width;
if (c != ' ') *all_space = 0;
*preferred_indent += 1;
}
}
buffer_find_hard_start_end:
return(result);
}
typedef struct{
int i;
int count;
@ -731,9 +771,9 @@ cursor_seek_step(Seek_State *state, Buffer_Seek seek, int xy_seek, float max_wid
cursor_seek_step_end:
state->cursor = cursor;
state->prev_cursor = prev_cursor;
return(result);
}
#endif
internal_4tech Full_Cursor
@ -820,6 +860,81 @@ buffer_cursor_from_wrapped_xy(Buffer_Type *buffer, float x, float y, int round_d
return(result);
}
internal_4tech void
buffer_invert_edit_shift(Buffer_Type *buffer, Buffer_Edit edit, Buffer_Edit *inverse, char *strings,
int *str_pos, int max, int shift_amount){
int pos;
int len;
pos = *str_pos;
len = edit.end - edit.start;
assert_4tech(pos + len <= max);
*str_pos = pos + len;
inverse->str_start = pos;
inverse->len = len;
inverse->start = edit.start + shift_amount;
inverse->end = edit.start + edit.len + shift_amount;
buffer_stringify(buffer, edit.start, edit.end, strings + pos);
}
inline_4tech void
buffer_invert_edit(Buffer_Type *buffer, Buffer_Edit edit, Buffer_Edit *inverse, char *strings,
int *str_pos, int max){
buffer_invert_edit_shift(buffer, edit, inverse, strings, str_pos, max, 0);
}
typedef struct{
int i;
int shift_amount;
int len;
} Buffer_Invert_Batch;
internal_4tech int
buffer_invert_batch(Buffer_Invert_Batch *state, Buffer_Type *buffer, Buffer_Edit *edits, int count,
Buffer_Edit *inverse, char *strings, int *str_pos, int max){
Buffer_Edit *edit, *inv_edit;
int shift_amount;
int result;
int i;
result = 0;
i = state->i;
shift_amount = state->shift_amount;
edit = edits + i;
inv_edit = inverse + i;
for (; i < count; ++i, ++edit, ++inv_edit){
if (*str_pos + edit->end - edit->start <= max){
buffer_invert_edit_shift(buffer, *edit, inv_edit, strings, str_pos, max, shift_amount);
shift_amount += (edit->len - (edit->end - edit->start));
}
else{
result = 1;
state->len = edit->end - edit->start;
}
}
state->i = i;
state->shift_amount = shift_amount;
return(result);
}
internal_4tech void
buffer_batch_edit(Buffer_Type *buffer, Buffer_Edit *sorted_edits, char *strings, int edit_count){
Buffer_Batch_State state;
debug_4tech(int result);
state.i = 0;
state.shift_total = 0;
debug_4tech(result =)
buffer_batch_edit_step(&state, buffer, sorted_edits, strings, edit_count);
assert_4tech(result == 0);
}
internal_4tech void
buffer_get_render_data(Buffer_Type *buffer, float *wraps, Buffer_Render_Item *items, int max, int *count,
float port_x, float port_y, float scroll_x, float scroll_y, int wrapped,
@ -929,6 +1044,16 @@ buffer_get_render_data(Buffer_Type *buffer, float *wraps, Buffer_Render_Item *it
}
buffer_get_render_data_end:
if (y <= height + shift_y || item == items){
ch = 0;
ch_width = measure_character(advance_data, stride, ' ');
write_render_item(item, size, ch, x, y, ch_width, font_height);
++item_i;
++item;
x += ch_width;
}
// TODO(allen): handle this with a control state
assert_4tech(item_i <= max);
*count = item_i;

View File

@ -300,5 +300,30 @@ buffer_replace_range(Gap_Buffer *buffer, int start, int end, char *str, int len,
return(result);
}
// NOTE(allen): This could should be optimized for Gap_Buffer
internal_4tech int
buffer_batch_edit_step(Buffer_Batch_State *state, Gap_Buffer *buffer, Buffer_Edit *sorted_edits, char *strings, int edit_count){
Buffer_Edit *edit;
int i, result;
int shift_total, shift_amount;
result = 0;
shift_total = state->shift_total;
i = state->i;
edit = sorted_edits + i;
for (; i < edit_count; ++i, ++edit){
result = buffer_replace_range(buffer, edit->start + shift_total, edit->end + shift_total,
strings + edit->str_start, edit->len, &shift_amount);
if (result) break;
shift_total += shift_amount;
}
state->shift_total = shift_total;
state->i = i;
return(result);
}
// BOTTOM

View File

@ -168,71 +168,6 @@ buffer_replace_range(Buffer *buffer, int start, int end, char *str, int len, int
return(result);
}
internal_4tech void
buffer_invert_edit_shift(Buffer *buffer, Buffer_Edit edit, Buffer_Edit *inverse, char *strings, int *str_pos, int max, int shift_amount){
int pos;
int len;
pos = *str_pos;
len = edit.end - edit.start;
assert_4tech(pos + len <= max);
*str_pos = pos + len;
inverse->str_start = pos;
inverse->len = len;
inverse->start = edit.start + shift_amount;
inverse->end = edit.start + edit.len + shift_amount;
memcpy_4tech(strings + pos, buffer->data + edit.start, len);
}
inline_4tech void
buffer_invert_edit(Buffer *buffer, Buffer_Edit edit, Buffer_Edit *inverse, char *strings, int *str_pos, int max){
buffer_invert_edit_shift(buffer, edit, inverse, strings, str_pos, max, 0);
}
typedef struct{
int i;
int shift_amount;
int len;
} Buffer_Invert_Batch;
internal_4tech int
buffer_invert_batch(Buffer_Invert_Batch *state, Buffer *buffer, Buffer_Edit *edits, int count,
Buffer_Edit *inverse, char *strings, int *str_pos, int max){
Buffer_Edit *edit, *inv_edit;
int shift_amount;
int result;
int i;
result = 0;
i = state->i;
shift_amount = state->shift_amount;
edit = edits + i;
inv_edit = inverse + i;
for (; i < count; ++i, ++edit, ++inv_edit){
if (*str_pos + edit->end - edit->start <= max){
buffer_invert_edit_shift(buffer, *edit, inv_edit, strings, str_pos, max, shift_amount);
shift_amount += (edit->len - (edit->end - edit->start));
}
else{
result = 1;
state->len = edit->end - edit->start;
}
}
state->i = i;
state->shift_amount = shift_amount;
return(result);
}
typedef struct{
int i;
int shift_total;
} Buffer_Batch_State;
internal_4tech int
buffer_batch_edit_step(Buffer_Batch_State *state, Buffer *buffer, Buffer_Edit *sorted_edits, char *strings, int edit_count){
Buffer_Edit *edit;
@ -257,19 +192,7 @@ buffer_batch_edit_step(Buffer_Batch_State *state, Buffer *buffer, Buffer_Edit *s
return(result);
}
internal_4tech void
buffer_batch_edit(Buffer *buffer, Buffer_Edit *sorted_edits, char *strings, int edit_count){
Buffer_Batch_State state;
debug_4tech(int result);
state.i = 0;
state.shift_total = 0;
debug_4tech(result =)
buffer_batch_edit_step(&state, buffer, sorted_edits, strings, edit_count);
assert_4tech(result == 0);
}
#if 0
internal_4tech int
buffer_find_hard_start(Buffer *buffer, int line_start, int *all_whitespace, int *all_space,
int *preferred_indent, int tab_width){
@ -300,6 +223,7 @@ buffer_find_hard_start(Buffer *buffer, int line_start, int *all_whitespace, int
return(result);
}
#endif
// BOTTOM

View File

@ -49,6 +49,11 @@ typedef struct{
int start, end;
} Buffer_Edit;
typedef struct{
int i;
int shift_total;
} Buffer_Batch_State;
typedef enum{
buffer_seek_pos,
buffer_seek_wrapped_xy,
@ -56,7 +61,6 @@ typedef enum{
buffer_seek_line_char
} Buffer_Seek_Type;
typedef struct{
Buffer_Seek_Type type;
union{

View File

@ -504,47 +504,24 @@ Win32Resize(i32 width, i32 height){
internal void
Win32KeyboardHandle(bool8 current_state, bool8 previous_state, WPARAM wParam){
switch (wParam){
case VK_LSHIFT:
case VK_RSHIFT:
case VK_SHIFT:
{
win32vars.input_data.control_keys[CONTROL_KEY_SHIFT] = current_state;
}break;
case VK_LCONTROL:
case VK_RCONTROL:
case VK_CONTROL:
{
win32vars.input_data.control_keys[CONTROL_KEY_CONTROL] = current_state;
}break;
case VK_LMENU:
case VK_RMENU:
case VK_MENU:
{
win32vars.input_data.control_keys[CONTROL_KEY_ALT] = current_state;
}break;
default:
{
u16 key = keycode_lookup((u8)wParam);
if (key != -1){
if (current_state & !previous_state){
i32 count = win32vars.input_data.press_count;
if (count < KEY_INPUT_BUFFER_SIZE){
win32vars.input_data.press[count].keycode = key;
win32vars.input_data.press[count].loose_keycode = loose_keycode_lookup((u8)wParam);
++win32vars.input_data.press_count;
}
}
else if (current_state){
i32 count = win32vars.input_data.hold_count;
if (count < KEY_INPUT_BUFFER_SIZE){
win32vars.input_data.hold[count].keycode = key;
win32vars.input_data.hold[count].loose_keycode = loose_keycode_lookup((u8)wParam);
++win32vars.input_data.hold_count;
}
u16 key = keycode_lookup((u8)wParam);
if (key != -1){
if (current_state & !previous_state){
i32 count = win32vars.input_data.press_count;
if (count < KEY_INPUT_BUFFER_SIZE){
win32vars.input_data.press[count].keycode = key;
win32vars.input_data.press[count].loose_keycode = loose_keycode_lookup((u8)wParam);
++win32vars.input_data.press_count;
}
}
else if (current_state){
i32 count = win32vars.input_data.hold_count;
if (count < KEY_INPUT_BUFFER_SIZE){
win32vars.input_data.hold[count].keycode = key;
win32vars.input_data.hold[count].loose_keycode = loose_keycode_lookup((u8)wParam);
++win32vars.input_data.hold_count;
}
}
}break;
}
}
@ -568,6 +545,7 @@ Win32Callback(HWND hwnd, UINT uMsg,
previous_state = ((lParam & Bit_30)?(1):(0));
current_state = ((lParam & Bit_31)?(0):(1));
Win32KeyboardHandle(current_state, previous_state, wParam);
result = DefWindowProc(hwnd, uMsg, wParam, lParam);
}break;
case WM_MOUSEMOVE:
@ -1148,6 +1126,7 @@ WinMain(HINSTANCE hInstance,
AllowLocal(thread);
bool32 first = 1;
i64 timer_start = system_time();
while (win32vars.keep_playing){
#if FRED_INTERNAL
i64 dbg_procing_start = system_time();
@ -1186,6 +1165,11 @@ WinMain(HINSTANCE hInstance,
win32vars.input_data.press_count = 0;
win32vars.input_data.hold_count = 0;
win32vars.input_data.caps_lock = GetKeyState(VK_CAPITAL) & 0x1;
win32vars.input_data.control_keys[CONTROL_KEY_SHIFT] = (GetKeyState(VK_SHIFT) & 0x0100) >> 8;
win32vars.input_data.control_keys[CONTROL_KEY_CONTROL] = (GetKeyState(VK_CONTROL) & 0x0100) >> 8;
win32vars.input_data.control_keys[CONTROL_KEY_ALT] = (GetKeyState(VK_MENU) & 0x0100) >> 8;
win32vars.mouse.left_button_prev = win32vars.mouse.left_button;
win32vars.mouse.right_button_prev = win32vars.mouse.right_button;
win32vars.mouse.wheel = 0;
@ -1218,8 +1202,8 @@ WinMain(HINSTANCE hInstance,
win32vars.mouse.out_of_window = 1;
}
bool32 shift = win32vars.input_data.control_keys[CONTROL_KEY_SHIFT];
bool32 caps_lock = win32vars.input_data.caps_lock;
b32 shift = win32vars.input_data.control_keys[CONTROL_KEY_SHIFT];
b32 caps_lock = win32vars.input_data.caps_lock;
for (i32 i = 0; i < win32vars.input_data.press_count; ++i){
i16 keycode = win32vars.input_data.press[i].keycode;
win32vars.input_data.press[i].character =