From cf6c92fcbdfbca671afdae18d8b150b88c9bba4f Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Tue, 18 Jun 2019 19:31:59 -0700 Subject: [PATCH] Switching the API return method --- 4coder_API/4coder_types.h | 7 +- 4coder_api_transition_30_31.cpp | 183 +++---- 4coder_api_transition_30_31.h | 16 + 4coder_api_transition_30_31_helpers.cpp | 93 +++- 4coder_auto_indent.cpp | 46 +- 4coder_base_commands.cpp | 546 ++++++++------------- 4coder_base_types.cpp | 21 +- 4coder_build_commands.cpp | 24 +- 4coder_casey_classic.cpp | 22 +- 4coder_clipboard.cpp | 42 +- 4coder_combined_write_commands.cpp | 48 +- 4coder_default_framework.cpp | 56 +-- 4coder_default_hooks.cpp | 172 +++---- 4coder_experiments.cpp | 149 +++--- 4coder_function_list.cpp | 40 +- 4coder_generated/app_functions.h | 328 ++++++------- 4coder_generated/command_metadata.h | 454 ++++++++--------- 4coder_helper.cpp | 403 ++++++--------- 4coder_helper.h | 24 +- 4coder_insertion.cpp | 9 +- 4coder_jump_direct.cpp | 53 +- 4coder_jump_lister.cpp | 6 +- 4coder_jump_sticky.cpp | 87 ++-- 4coder_jumping.cpp | 20 +- 4coder_lists.cpp | 110 ++--- 4coder_miblo_numbers.cpp | 27 +- 4coder_project_commands.cpp | 15 +- 4coder_scope_commands.cpp | 128 ++--- 4coder_search.cpp | 58 +-- 4coder_seek.cpp | 27 +- 4coder_system_command.cpp | 3 +- 4coder_ui_helper.cpp | 111 ++--- 4ed_api_implementation.cpp | 621 +++++++++--------------- 4ed_cli.cpp | 14 + 4ed_file.cpp | 17 +- 4ed_view.cpp | 18 +- things_ive_broken.txt | 5 +- 37 files changed, 1674 insertions(+), 2329 deletions(-) diff --git a/4coder_API/4coder_types.h b/4coder_API/4coder_types.h index e2f5be45..0805b1dc 100644 --- a/4coder_API/4coder_types.h +++ b/4coder_API/4coder_types.h @@ -1070,8 +1070,8 @@ ENUM(u32, Clipboard_Change_Flag){ TYPEDEF_FUNC void Clipboard_Change_Hook_Function(struct Application_Links *app, String_Const_u8 contents, Clipboard_Change_Flag flags); #define CLIPBOARD_CHANGE_HOOK_SIG(name) void name(struct Application_Links *app, String_Const_u8 contents, Clipboard_Change_Flag flags) -TYPEDEF_FUNC Rect_i32 Get_View_Buffer_Region_Function(struct Application_Links *app, View_ID view_id, Rect_i32 sub_region); -#define GET_VIEW_BUFFER_REGION_SIG(name) Rect_i32 name(struct Application_Links *app, View_ID view_id, Rect_i32 sub_region) +TYPEDEF_FUNC Rect_f32 Get_View_Buffer_Region_Function(struct Application_Links *app, View_ID view_id, Rect_f32 sub_region); +#define GET_VIEW_BUFFER_REGION_SIG(name) Rect_f32 name(struct Application_Links *app, View_ID view_id, Rect_f32 sub_region) STRUCT Buffer_Name_Conflict_Entry{ Buffer_ID buffer_id; @@ -1160,7 +1160,8 @@ STRUCT String_Match_List{ i32 count; }; -STRUCT Process_State { +STRUCT Process_State{ + b32 valid; b32 is_updating; i64 return_code; }; diff --git a/4coder_api_transition_30_31.cpp b/4coder_api_transition_30_31.cpp index 09d3fd38..5c986e27 100644 --- a/4coder_api_transition_30_31.cpp +++ b/4coder_api_transition_30_31.cpp @@ -27,37 +27,34 @@ typedef b32 bool32; static b32 -get_buffer_summary(Application_Links *app, Buffer_ID buffer_id, Access_Flag access, Buffer_Summary *buffer){ +get_buffer_summary(Application_Links *app, Buffer_ID buffer, Access_Flag access, Buffer_Summary *summary){ b32 result = false; - if (buffer_exists(app, buffer_id)){ + if (buffer_exists(app, buffer)){ Scratch_Block scratch(app); - Access_Flag buffer_access_flags = 0; - buffer_get_access_flags(app, buffer_id, &buffer_access_flags); + Access_Flag buffer_access_flags = buffer_get_access_flags(app, buffer); if ((buffer_access_flags & ~access) == 0){ result = true; - buffer->exists = true; - buffer->ready = buffer_ready(app, buffer_id); - buffer->buffer_id = buffer_id; - buffer_get_size(app, buffer_id, &buffer->size); - buffer_get_line_count(app, buffer_id, &buffer->line_count); + summary->exists = true; + summary->ready = buffer_ready(app, buffer); + summary->buffer_id = buffer; + summary->size = (i32)buffer_get_size(app, buffer); + summary->line_count = (i32)buffer_get_line_count(app, buffer); - String_Const_u8 file_name_get = {}; - buffer_get_file_name(app, buffer_id, scratch, &file_name_get); - block_copy(buffer->file_name, file_name_get.str, file_name_get.size); - buffer->file_name_len = (i32)file_name_get.size; + String_Const_u8 file_name_get = push_buffer_file_name(app, scratch, buffer); + block_copy(summary->file_name, file_name_get.str, file_name_get.size); + summary->file_name_len = (i32)file_name_get.size; - String_Const_u8 buffer_name_get = {}; - buffer_get_unique_buffer_name(app, buffer_id, scratch, &buffer_name_get); - block_copy(buffer->buffer_name, buffer_name_get.str, buffer_name_get.size); - buffer->buffer_name_len = (i32)buffer_name_get.size; + String_Const_u8 buffer_name_get = push_buffer_unique_name(app, scratch, buffer); + block_copy(summary->buffer_name, buffer_name_get.str, buffer_name_get.size); + summary->buffer_name_len = (i32)buffer_name_get.size; - buffer_get_dirty_state(app, buffer_id, &buffer->dirty); - buffer_get_setting(app, buffer_id, BufferSetting_Lex, &buffer->is_lexed); - buffer->tokens_are_ready = buffer_tokens_are_ready(app, buffer_id); - buffer_get_setting(app, buffer_id, BufferSetting_MapID, &buffer->map_id); - buffer_get_setting(app, buffer_id, BufferSetting_WrapLine, &buffer->unwrapped_lines); - buffer->unwrapped_lines = !buffer->unwrapped_lines; - buffer->lock_flags = buffer_access_flags; + summary->dirty = buffer_get_dirty_state(app, buffer); + buffer_get_setting(app, buffer, BufferSetting_Lex, &summary->is_lexed); + summary->tokens_are_ready = buffer_tokens_are_ready(app, buffer); + buffer_get_setting(app, buffer, BufferSetting_MapID, &summary->map_id); + buffer_get_setting(app, buffer, BufferSetting_WrapLine, &summary->unwrapped_lines); + summary->unwrapped_lines = !summary->unwrapped_lines; + summary->lock_flags = buffer_access_flags; } } return(result); @@ -67,8 +64,8 @@ static b32 get_view_summary(Application_Links *app, View_ID view_id, Access_Flag access, View_Summary *view){ b32 result = false; if (view_exists(app, view_id)){ - Buffer_ID buffer = 0; - if (view_get_buffer(app, view_id, access, &buffer)){ + Buffer_ID buffer = view_get_buffer(app, view_id, access); + if (buffer != 0){ result = true; Face_ID face_id = 0; @@ -83,14 +80,12 @@ get_view_summary(Application_Links *app, View_ID view_id, Access_Flag access, Vi view->unwrapped_lines = !view->unwrapped_lines; view_get_setting(app, view_id, ViewSetting_ShowWhitespace, &view->show_whitespace); view->buffer_id = buffer; - i32 pos = 0; - view_get_mark_pos(app, view_id, &pos); + i32 pos = view_get_mark_pos(app, view_id); view_compute_cursor(app, view_id, seek_pos(pos), &view->mark); - view_get_cursor_pos(app, view_id, &pos); + pos = view_get_cursor_pos(app, view_id); view_compute_cursor(app, view_id, seek_pos(pos), &view->cursor); - view_get_preferred_x(app, view_id, &view->preferred_x); - Rect_f32 screen_rect = {}; - view_get_screen_rect(app, view_id, &screen_rect); + view->preferred_x = view_get_preferred_x(app, view_id); + Rect_f32 screen_rect = view_get_screen_rect(app, view_id); view->view_region = screen_rect; view->render_region = f32R(0.f, 0.f, rect_width(screen_rect), rect_height(screen_rect)); view_get_scroll_vars(app, view_id, &view->scroll_vars); @@ -104,27 +99,19 @@ clipboard_post(Application_Links *app, i32 clipboard_id, char *str, i32 len){ return(clipboard_post(app, clipboard_id, SCu8(str, len))); } -static i32 -clipboard_count(Application_Links *app, i32 clipboard_id){ - i32 count = 0; - clipboard_count(app, clipboard_id, &count); - return(count); -} - static i32 clipboard_index(Application_Links *app, i32 clipboard_id, i32 item_index, char *out, i32 len){ Scratch_Block scratch(app); - String_Const_u8 string = {}; - clipboard_index(app, clipboard_id, item_index, scratch, &string); + String_Const_u8 string = push_clipboard_index(app, scratch, clipboard_id, item_index); block_copy(out, string.str, clamp_top((i32)string.size, len)); return((i32)string.size); } static Buffer_Summary get_buffer_first(Application_Links *app, Access_Flag access){ - Buffer_ID buffer_id = 0; Buffer_Summary buffer = {}; - if (get_buffer_next(app, 0, access, &buffer_id)){ + Buffer_ID buffer_id = get_buffer_next(app, 0, access); + if (buffer_id != 0){ get_buffer_summary(app, buffer_id, access, &buffer); } return(buffer); @@ -133,12 +120,12 @@ get_buffer_first(Application_Links *app, Access_Flag access){ static void get_buffer_next(Application_Links *app, Buffer_Summary *buffer, Access_Flag access){ if (buffer != 0 && buffer->exists){ - Buffer_ID buffer_id = 0; - if (get_buffer_next(app, buffer->buffer_id, access, &buffer_id)){ + Buffer_ID buffer_id = get_buffer_next(app, buffer->buffer_id, access); + if (buffer_id != 0){ get_buffer_summary(app, buffer_id, access, buffer); } else{ - memset(buffer, 0, sizeof(*buffer)); + block_zero_struct(buffer); } } } @@ -152,9 +139,9 @@ get_buffer(Application_Links *app, Buffer_ID buffer_id, Access_Flag access){ static Buffer_Summary get_buffer_by_name(Application_Links *app, char *name, i32 len, Access_Flag access){ - Buffer_ID id = 0; Buffer_Summary buffer = {}; - if (get_buffer_by_name(app, SCu8(name, len), access, &id)){ + Buffer_ID id = get_buffer_by_name(app, SCu8(name, len), access); + if (id != 0){ get_buffer_summary(app, id, access, &buffer); } return(buffer); @@ -162,9 +149,9 @@ get_buffer_by_name(Application_Links *app, char *name, i32 len, Access_Flag acce static Buffer_Summary get_buffer_by_file_name(Application_Links *app, char *name, i32 len, Access_Flag access){ - Buffer_ID id = 0; Buffer_Summary buffer = {}; - if (get_buffer_by_file_name(app, SCu8(name, len), access, &id)){ + Buffer_ID id = get_buffer_by_file_name(app, SCu8(name, len), access); + if (id != 0){ get_buffer_summary(app, id, access, &buffer); } return(buffer); @@ -194,7 +181,8 @@ static b32 buffer_compute_cursor(Application_Links *app, Buffer_Summary *buffer, Buffer_Seek seek, Partial_Cursor *cursor_out){ b32 result = false; if (buffer != 0 && buffer->exists){ - result = buffer_compute_cursor(app, buffer->buffer_id, seek, cursor_out); + *cursor_out = buffer_compute_cursor(app, buffer->buffer_id, seek); + result = (cursor_out->line > 0); get_buffer_summary(app, buffer->buffer_id, AccessAll, buffer); } return(result); @@ -230,37 +218,48 @@ buffer_set_setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Settin return(result); } -static Managed_Scope -buffer_get_managed_scope(Application_Links *app, Buffer_ID buffer_id){ - Managed_Scope scope = 0; - buffer_get_managed_scope(app, buffer_id, &scope); - return(scope); -} - static i32 buffer_token_count(Application_Links *app, Buffer_Summary *buffer){ i32 count = 0; if (buffer != 0 && buffer->exists){ - buffer_token_count(app, buffer->buffer_id, &count); + count = buffer_get_token_array(app, buffer->buffer_id).count; } return(count); } static b32 -buffer_read_tokens(Application_Links *app, Buffer_Summary *buffer, i32 start_token, i32 end_token, Cpp_Token *tokens_out){ +buffer_read_tokens(Application_Links *app, Buffer_ID buffer, i32 start_token, i32 end_token, Cpp_Token *tokens_out){ b32 result = false; - if (buffer != 0 && buffer->exists){ - result = buffer_read_tokens(app, buffer->buffer_id, start_token, end_token, tokens_out); - get_buffer_summary(app, buffer->buffer_id, AccessAll, buffer); + if (buffer != 0){ + Cpp_Token_Array array = buffer_get_token_array(app, buffer); + if (0 <= start_token && start_token <= end_token && end_token < array.count){ + result = true; + block_copy_dynamic_array(tokens_out, array.tokens + start_token, end_token - start_token); + } } return(result); } +static b32 +buffer_read_tokens(Application_Links *app, Buffer_Summary *buffer, i32 start_token, i32 end_token, Cpp_Token *tokens_out){ + Buffer_ID buffer_id = (buffer==0?0:buffer->buffer_id); + b32 result = buffer_read_tokens(app, buffer_id, start_token, end_token, tokens_out); + get_buffer_summary(app, buffer_id, AccessAll, buffer); + return(result); +} + static b32 buffer_get_token_range(Application_Links *app, Buffer_Summary *buffer, Cpp_Token **first_token_out, Cpp_Token **one_past_last_token_out){ b32 result = false; if (buffer != 0 && buffer->exists){ - result = buffer_get_token_range(app, buffer->buffer_id, first_token_out, one_past_last_token_out); + Cpp_Token_Array array = buffer_get_token_array(app, buffer->buffer_id); + result = true; + if (first_token_out != 0){ + *first_token_out = array.tokens; + } + if (one_past_last_token_out != 0){ + *one_past_last_token_out = array.tokens + array.count; + } get_buffer_summary(app, buffer->buffer_id, AccessAll, buffer); } return(result); @@ -270,7 +269,9 @@ static b32 buffer_get_token_index(Application_Links *app, Buffer_Summary *buffer, i32 pos, Cpp_Get_Token_Result *get_result){ b32 result = false; if (buffer != 0 && buffer->exists){ - result = buffer_get_token_index(app, buffer->buffer_id, pos, get_result); + Cpp_Token_Array array = buffer_get_token_array(app, buffer->buffer_id); + result = true; + *get_result = cpp_get_token(array, pos); get_buffer_summary(app, buffer->buffer_id, AccessAll, buffer); } return(result); @@ -289,8 +290,8 @@ buffer_send_end_signal(Application_Links *app, Buffer_Summary *buffer){ static Buffer_Summary create_buffer(Application_Links *app, char *filename, i32 filename_len, Buffer_Create_Flag flags){ Buffer_Summary buffer = {}; - Buffer_ID buffer_id = 0; - if (create_buffer(app, SCu8(filename, filename_len), flags, &buffer_id)){ + Buffer_ID buffer_id = create_buffer(app, SCu8(filename, filename_len), flags); + if (buffer_id != 0){ get_buffer_summary(app, buffer_id, AccessAll, &buffer); } return(buffer); @@ -310,12 +311,12 @@ static Buffer_Kill_Result kill_buffer(Application_Links *app, Buffer_Identifier buffer, Buffer_Kill_Flag flags){ Buffer_Kill_Result result = 0; if (buffer.id != 0){ - buffer_kill(app, buffer.id, flags, &result); + result = buffer_kill(app, buffer.id, flags); } else if (buffer.name != 0){ - Buffer_ID id = 0; - if (get_buffer_by_name(app, SCu8(buffer.name, buffer.name_len), AccessAll, &id)){ - buffer_kill(app, id, flags, &result); + Buffer_ID id = get_buffer_by_name(app, SCu8(buffer.name, buffer.name_len), AccessAll); + if (id != 0){ + result = buffer_kill(app, id, flags); } } return(result); @@ -323,9 +324,9 @@ kill_buffer(Application_Links *app, Buffer_Identifier buffer, Buffer_Kill_Flag f static Buffer_Reopen_Result reopen_buffer(Application_Links *app, Buffer_Summary *buffer, Buffer_Reopen_Flag flags){ - Buffer_Kill_Result result = 0; + Buffer_Reopen_Result result = 0; if (buffer != 0 && buffer->exists){ - buffer_reopen(app, buffer->buffer_id, flags, &result); + result = buffer_reopen(app, buffer->buffer_id, flags); } return(result); } @@ -333,8 +334,8 @@ reopen_buffer(Application_Links *app, Buffer_Summary *buffer, Buffer_Reopen_Flag static View_Summary get_view_first(Application_Links *app, Access_Flag access){ View_Summary view = {}; - View_ID view_id = 0; - if (get_view_next(app, 0, access, &view_id)){ + View_ID view_id = get_view_next(app, 0, access); + if (view_id != 0){ get_view_summary(app, view_id, access, &view); } return(view); @@ -343,12 +344,12 @@ get_view_first(Application_Links *app, Access_Flag access){ static void get_view_next(Application_Links *app, View_Summary *view, Access_Flag access){ if (view != 0 && view->exists){ - View_ID view_id = 0; - if (get_view_next(app, view->view_id, access, &view_id)){ + View_ID view_id = get_view_next(app, view->view_id, access); + if (view_id != 0){ get_view_summary(app, view_id, access, view); } else{ - memset(view, 0, sizeof(*view)); + block_zero_struct(view); } } } @@ -361,10 +362,10 @@ get_view(Application_Links *app, View_ID view_id, Access_Flag access){ } static View_Summary -get_active_view(Application_Links *app, Access_Flag access){ +get_active_view_DEP(Application_Links *app, Access_Flag access){ View_Summary view = {}; - View_ID id = 0; - if (get_active_view(app, access, &id)){ + View_ID id = get_active_view(app, access); + if (id != 0){ get_view_summary(app, id, access, &view); } return(view); @@ -374,15 +375,15 @@ static View_Summary open_view(Application_Links *app, View_Summary *view_location, View_Split_Position position){ View_Summary view = {}; if (view_location != 0 && view_location->exists){ - Panel_ID panel_id = 0; - if (view_get_panel(app, view_location->view_id, &panel_id)){ + Panel_ID panel_id = view_get_panel(app, view_location->view_id); + if (panel_id != 0){ b32 vertical = (position == ViewSplit_Left || position == ViewSplit_Right); if (panel_split(app, panel_id, vertical?PanelSplit_LeftAndRight:PanelSplit_TopAndBottom)){ - Panel_ID new_panel_id = 0; Panel_Child child = (position == ViewSplit_Left || position == ViewSplit_Top)?PanelChild_Min:PanelChild_Max; - if (panel_get_child(app, panel_id, child, &new_panel_id)){ - View_ID new_view_id = 0; - if (panel_get_view(app, new_panel_id, &new_view_id)){ + Panel_ID new_panel_id = panel_get_child(app, panel_id, child); + if (new_panel_id != 0){ + View_ID new_view_id = panel_get_view(app, new_panel_id); + if (new_view_id != 0){ get_view_summary(app, new_view_id, AccessAll, &view); get_view_summary(app, view_location->view_id, AccessAll, view_location); } @@ -646,11 +647,11 @@ set_window_title(Application_Links *app, char *title){ } static Process_State -get_process_state(Application_Links *app, Buffer_ID buffer_id){ +get_process_state(Application_Links *app, Buffer_ID buffer){ Process_State state = {}; - Child_Process_ID child_process_id = 0; - if (buffer_get_attached_child_process(app, buffer_id, &child_process_id)){ - child_process_get_state(app, child_process_id, &state); + Child_Process_ID child_process = buffer_get_attached_child_process(app, buffer); + if (child_process != 0){ + state = child_process_get_state(app, child_process); } return(state); } diff --git a/4coder_api_transition_30_31.h b/4coder_api_transition_30_31.h index ab399a62..4e6b73fc 100644 --- a/4coder_api_transition_30_31.h +++ b/4coder_api_transition_30_31.h @@ -112,6 +112,22 @@ enum{ BoundaryCamelCase = 0x8 }; +// NOTE(allen|4.0.31): Stream_Tokens has been deprecated in favor of the Token_Iterator. +// For examples of usage: 4coder_function_list.cpp 4coder_scope_commands.cpp +// If you want to keep your code working easily uncomment the typedef for Stream_Tokens. +struct Stream_Tokens_DEP{ + Application_Links *app; + Buffer_ID buffer_id; + + Cpp_Token *base_tokens; + Cpp_Token *tokens; + i32 start; + i32 end; + i32 count; + i32 token_count; +}; +//typedef Stream_Tokens_DEP Stream_Tokens; + #endif // BOTTOM diff --git a/4coder_api_transition_30_31_helpers.cpp b/4coder_api_transition_30_31_helpers.cpp index bf76edd5..32e5b09e 100644 --- a/4coder_api_transition_30_31_helpers.cpp +++ b/4coder_api_transition_30_31_helpers.cpp @@ -145,7 +145,86 @@ init_stream_chunk(Stream_Chunk *chunk, Application_Links *app, Buffer_Summary *b static b32 init_stream_tokens(Stream_Tokens_DEP *stream, Application_Links *app, Buffer_Summary *buffer, i32 pos, Cpp_Token *data, i32 count){ - return(buffer==0?0:init_stream_tokens(stream, app, buffer->buffer_id, pos, data, count)); + b32 result = false; + + if (buffer != 0){ + i32 token_count = buffer_token_count(app, buffer); + if (buffer_tokens_are_ready(app, buffer->buffer_id) && + 0 <= pos && pos < token_count && count > 0){ + stream->app = app; + stream->buffer_id = buffer->buffer_id; + stream->base_tokens = data; + stream->count = count; + stream->start = round_down_i32(pos, count); + stream->end = round_up_i32(pos, count); + stream->token_count = token_count; + + stream->start = clamp_bot(0, stream->start); + stream->end = clamp_top(stream->end, stream->token_count); + + buffer_read_tokens(app, buffer, stream->start, stream->end, stream->base_tokens); + stream->tokens = stream->base_tokens - stream->start; + result = true; + } + } + + return(result); +} + +static Stream_Tokens_DEP +begin_temp_stream_token(Stream_Tokens_DEP *stream){ + return(*stream); +} + +static void +end_temp_stream_token(Stream_Tokens_DEP *stream, Stream_Tokens_DEP temp){ + if (stream->start != temp.start || stream->end != temp.end){ + Application_Links *app = stream->app; + buffer_read_tokens(app, temp.buffer_id, temp.start, temp.end, temp.base_tokens); + stream->tokens = stream->base_tokens - temp.start; + stream->start = temp.start; + stream->end = temp.end; + } +} + +static b32 +forward_stream_tokens(Stream_Tokens_DEP *stream){ + Application_Links *app = stream->app; + Buffer_ID buffer_id = stream->buffer_id; + b32 result = false; + if (stream->end < stream->token_count){ + stream->start = stream->end; + stream->end += stream->count; + if (stream->end > stream->token_count){ + stream->end = stream->token_count; + } + if (stream->start < stream->end){ + buffer_read_tokens(app, buffer_id, stream->start, stream->end, stream->base_tokens); + stream->tokens = stream->base_tokens - stream->start; + result = true; + } + } + return(result); +} + +static b32 +backward_stream_tokens(Stream_Tokens_DEP *stream){ + Application_Links *app = stream->app; + Buffer_ID buffer_id = stream->buffer_id; + b32 result = false; + if (stream->start > 0){ + stream->end = stream->start; + stream->start -= stream->count; + if (0 > stream->start){ + stream->start = 0; + } + if (stream->start < stream->end){ + buffer_read_tokens(app, buffer_id, stream->start, stream->end, stream->base_tokens); + stream->tokens = stream->base_tokens - stream->start; + result = true; + } + } + return(result); } static String @@ -254,7 +333,7 @@ buffer_get_all_tokens(Application_Links *app, Arena *arena, Buffer_ID buffer_id) b32 is_lexed = false; if (buffer_get_setting(app, buffer_id, BufferSetting_Lex, &is_lexed)){ if (is_lexed){ - buffer_token_count(app, buffer_id, &array.count); + array.count = buffer_get_token_array(app, buffer_id).count; array.max_count = array.count; array.tokens = push_array(arena, Cpp_Token, array.count); buffer_read_tokens(app, buffer_id, 0, array.count, array.tokens); @@ -683,7 +762,7 @@ post_buffer_range_to_clipboard(Application_Links *app, i32 clipboard_index, Buff static void view_set_vertical_focus(Application_Links *app, View_Summary *view, i32 y_top, i32 y_bot){ - view_set_vertical_focus(app, view==0?0:view->view_id, y_top, y_bot); + view_set_vertical_focus(app, view==0?0:view->view_id, (f32)y_top, (f32)y_bot); } static b32 @@ -738,8 +817,7 @@ isearch__update_highlight(Application_Links *app, View_Summary *view, Managed_Ob static void get_view_prev(Application_Links *app, View_Summary *view, Access_Flag access){ - View_ID new_id = 0; - get_view_prev(app, view->view_id, access, &new_id); + View_ID new_id = get_view_prev(app, view->view_id, access); get_view_summary(app, new_id, access, view); } @@ -1051,6 +1129,11 @@ current_view_boundary_seek_set_pos(Application_Links *app, Scan_Direction direct current_view_scan_move(app, direction, boundary_list_from_old_flags(scratch, flags)); } +static Buffer_Kill_Result +kill_buffer(Application_Links *app, Buffer_Identifier identifier, View_ID gui_view_id, Buffer_Kill_Flag flags){ + return(try_buffer_kill(app, buffer_identifier_to_id(app, identifier), gui_view_id, flags)); +} + #endif // BOTTOM diff --git a/4coder_auto_indent.cpp b/4coder_auto_indent.cpp index 86a2b80e..9f63f214 100644 --- a/4coder_auto_indent.cpp +++ b/4coder_auto_indent.cpp @@ -239,7 +239,7 @@ get_indentation_marks(Application_Links *app, Arena *arena, Buffer_ID buffer, } else{ token.type = CPP_TOKEN_EOF; - buffer_get_size(app, buffer, &token.start); + token.start = (i32)buffer_get_size(app, buffer); token.flags = 0; } @@ -475,8 +475,7 @@ get_indent_lines_whole_tokens(Application_Links *app, Buffer_ID buffer, Cpp_Toke } } - i32 line_count = 0; - buffer_get_line_count(app, buffer, &line_count); + i32 line_count = (i32)buffer_get_line_count(app, buffer); for (;line_end < line_count;){ i32 next_line_start_pos = get_line_start_pos(app, buffer, line_end + 1); @@ -505,16 +504,12 @@ buffer_auto_indent(Application_Links *app, Arena *scratch, Buffer_ID buffer, i32 Temp_Memory temp = begin_temp(scratch); // Stage 1: Read the tokens to be used for indentation. - Cpp_Token_Array tokens = {}; - buffer_token_count(app, buffer, &tokens.count); - tokens.max_count = tokens.count; - tokens.tokens = push_array(scratch, Cpp_Token, tokens.count); - buffer_read_tokens(app, buffer, 0, tokens.count, tokens.tokens); + Cpp_Token_Array tokens = buffer_get_token_array(app, buffer); // Stage 2: Decide where the first and last lines are. // The lines in the range [line_start,line_end) will be indented. i32 line_start = 0, line_end = 0; - if (flags & AutoIndent_FullTokens){ + if (HasFlag(flags, AutoIndent_FullTokens)){ get_indent_lines_whole_tokens(app, buffer, tokens, start, end, &line_start, &line_end); } else{ @@ -561,12 +556,9 @@ buffer_auto_indent(Application_Links *app, Buffer_ID buffer, i32 start, i32 end, CUSTOM_COMMAND_SIG(auto_tab_whole_file) CUSTOM_DOC("Audo-indents the entire current buffer.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); - i32 buffer_size = 0; - buffer_get_size(app, buffer, &buffer_size); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); + i32 buffer_size = (i32)buffer_get_size(app, buffer); Arena *scratch = context_get_arena(app); buffer_auto_indent(app, scratch, buffer, 0, buffer_size, DEF_TAB_WIDTH, DEFAULT_INDENT_FLAGS | AutoIndent_FullTokens); } @@ -574,12 +566,9 @@ CUSTOM_DOC("Audo-indents the entire current buffer.") CUSTOM_COMMAND_SIG(auto_tab_line_at_cursor) CUSTOM_DOC("Auto-indents the line on which the cursor sits.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); + i32 pos = view_get_cursor_pos(app, view); Arena *scratch = context_get_arena(app); buffer_auto_indent(app, scratch, buffer, pos, pos, DEF_TAB_WIDTH, DEFAULT_INDENT_FLAGS | AutoIndent_FullTokens); move_past_lead_whitespace(app, view, buffer); @@ -588,10 +577,8 @@ CUSTOM_DOC("Auto-indents the line on which the cursor sits.") CUSTOM_COMMAND_SIG(auto_tab_range) CUSTOM_DOC("Auto-indents the range between the cursor and the mark.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); Range range = get_view_range(app, view); Arena *scratch = context_get_arena(app); buffer_auto_indent(app, scratch, buffer, range.min, range.max, DEF_TAB_WIDTH, DEFAULT_INDENT_FLAGS | AutoIndent_FullTokens); @@ -602,17 +589,14 @@ CUSTOM_COMMAND_SIG(write_and_auto_tab) CUSTOM_DOC("Inserts a character and auto-indents the line on which the cursor sits.") { write_character(app); - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); u32 flags = DEFAULT_INDENT_FLAGS; User_Input in = get_command_input(app); if (in.key.character == '\n'){ flags |= AutoIndent_ExactAlignBlock; } - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + i32 pos = view_get_cursor_pos(app, view); Arena *scratch = context_get_arena(app); buffer_auto_indent(app, scratch, buffer, pos, pos, DEF_TAB_WIDTH, flags); move_past_lead_whitespace(app, view, buffer); diff --git a/4coder_base_commands.cpp b/4coder_base_commands.cpp index 867d3aa7..dd650864 100644 --- a/4coder_base_commands.cpp +++ b/4coder_base_commands.cpp @@ -8,14 +8,11 @@ moving the cursor, which work even without the default 4coder framework. static void write_character_parameter(Application_Links *app, u8 *character, u32 length){ if (length != 0){ - View_ID view = 0; - get_active_view(app, AccessOpen, &view); + View_ID view = get_active_view(app, AccessOpen); if_view_has_highlighted_range_delete_range(app, view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); + i32 pos = view_get_cursor_pos(app, view); Full_Cursor cursor = {}; view_compute_cursor(app, view, seek_pos(pos), &cursor); @@ -88,15 +85,11 @@ CUSTOM_DOC("Inserts an underscore.") CUSTOM_COMMAND_SIG(delete_char) CUSTOM_DOC("Deletes the character to the right of the cursor.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); + View_ID view = get_active_view(app, AccessOpen); if (!if_view_has_highlighted_range_delete_range(app, view)){ - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); - i32 start = 0; - view_get_cursor_pos(app, view, &start); - i32 buffer_size = 0; - buffer_get_size(app, buffer, &buffer_size); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); + i32 start = view_get_cursor_pos(app, view); + i32 buffer_size = (i32)buffer_get_size(app, buffer); if (0 <= start && start < buffer_size){ Full_Cursor cursor = {}; view_compute_cursor(app, view, seek_pos(start), &cursor); @@ -110,15 +103,11 @@ CUSTOM_DOC("Deletes the character to the right of the cursor.") CUSTOM_COMMAND_SIG(backspace_char) CUSTOM_DOC("Deletes the character to the left of the cursor.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); + View_ID view = get_active_view(app, AccessOpen); if (!if_view_has_highlighted_range_delete_range(app, view)){ - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); - i32 end = 0; - view_get_cursor_pos(app, view, &end); - i32 buffer_size = 0; - buffer_get_size(app, buffer, &buffer_size); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); + i32 end = view_get_cursor_pos(app, view); + i32 buffer_size = (i32)buffer_get_size(app, buffer); if (0 < end && end <= buffer_size){ Full_Cursor cursor = {}; view_compute_cursor(app, view, seek_pos(end), &cursor); @@ -134,10 +123,8 @@ CUSTOM_DOC("Deletes the character to the left of the cursor.") CUSTOM_COMMAND_SIG(set_mark) CUSTOM_DOC("Sets the mark to the current position of the cursor.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + View_ID view = get_active_view(app, AccessProtected); + i32 pos = view_get_cursor_pos(app, view); view_set_mark(app, view, seek_pos(pos)); view_set_cursor(app, view, seek_pos(pos), true); } @@ -145,12 +132,9 @@ CUSTOM_DOC("Sets the mark to the current position of the cursor.") CUSTOM_COMMAND_SIG(cursor_mark_swap) CUSTOM_DOC("Swaps the position of the cursor and the mark.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - i32 cursor = 0; - view_get_cursor_pos(app, view, &cursor); - i32 mark = 0; - view_get_mark_pos(app, view, &mark); + View_ID view = get_active_view(app, AccessProtected); + i32 cursor = view_get_cursor_pos(app, view); + i32 mark = view_get_mark_pos(app, view); view_set_cursor(app, view, seek_pos(mark), true); view_set_mark(app, view, seek_pos(cursor)); } @@ -158,22 +142,18 @@ CUSTOM_DOC("Swaps the position of the cursor and the mark.") CUSTOM_COMMAND_SIG(delete_range) CUSTOM_DOC("Deletes the text in the range between the cursor and the mark.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); Range range = get_view_range(app, view); buffer_replace_range(app, buffer, range, string_u8_litexpr("")); } static void current_view_boundary_delete(Application_Links *app, Scan_Direction direction, Boundary_Function_List funcs){ - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); Range range = {}; - view_get_cursor_pos(app, view, &range.first); + range.first = view_get_cursor_pos(app, view); range.one_past_last = scan(app, funcs, buffer, direction, range.first); range = rectify(range); buffer_replace_range(app, buffer, range, string_u8_litexpr("")); @@ -200,12 +180,9 @@ CUSTOM_DOC("Delete characters between the cursor position and the first alphanum static void current_view_snipe_delete(Application_Links *app, Scan_Direction direction, Boundary_Function_List funcs){ - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); + i32 pos = view_get_cursor_pos(app, view); Range range = get_snipe_range(app, funcs, buffer, pos, direction); buffer_replace_range(app, buffer, range, string_u8_litexpr("")); } @@ -234,11 +211,9 @@ CUSTOM_DOC("Delete a single, whole token on or to the right of the cursor and po CUSTOM_COMMAND_SIG(center_view) CUSTOM_DOC("Centers the view vertically on the line on which the cursor sits.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); + View_ID view = get_active_view(app, AccessProtected); - Rect_i32 region = {}; - view_get_buffer_region(app, view, ®ion); + Rect_f32 region = view_get_buffer_region(app, view); GUI_Scroll_Vars scroll = {}; view_get_scroll_vars(app, view, &scroll); @@ -252,8 +227,7 @@ CUSTOM_DOC("Centers the view vertically on the line on which the cursor sits.") CUSTOM_COMMAND_SIG(left_adjust_view) CUSTOM_DOC("Sets the left size of the view near the x position of the cursor.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); + View_ID view = get_active_view(app, AccessProtected); GUI_Scroll_Vars scroll = {}; view_get_scroll_vars(app, view, &scroll); f32 x = clamp_bot(0.f, get_view_x(app, view) - 30.f); @@ -262,10 +236,10 @@ CUSTOM_DOC("Sets the left size of the view near the x position of the cursor.") } static b32 -view_space_from_screen_space_checked(Vec2_i32 p, Rect_i32 file_region, Vec2 scroll_p, Vec2 *p_out){ +view_space_from_screen_space_checked(Vec2_f32 p, Rect_f32 file_region, Vec2 scroll_p, Vec2 *p_out){ b32 result = false; if (rect_contains_point(file_region, p)){ - *p_out = view_space_from_screen_space(V2(p), V2(file_region.p0), scroll_p); + *p_out = view_space_from_screen_space(p, file_region.p0, scroll_p); result = true; } else{ @@ -277,15 +251,13 @@ view_space_from_screen_space_checked(Vec2_i32 p, Rect_i32 file_region, Vec2 scro CUSTOM_COMMAND_SIG(click_set_cursor_and_mark) CUSTOM_DOC("Sets the cursor position and mark to the mouse position.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Rect_i32 region = {}; - view_get_buffer_region(app, view, ®ion); + View_ID view = get_active_view(app, AccessProtected); + Rect_f32 region = view_get_buffer_region(app, view); GUI_Scroll_Vars scroll_vars = {}; view_get_scroll_vars(app, view, &scroll_vars); Mouse_State mouse = get_mouse_state(app); Vec2 p = {}; - if (view_space_from_screen_space_checked(mouse.p, region, scroll_vars.scroll_p, &p)){ + if (view_space_from_screen_space_checked(V2(mouse.p), region, scroll_vars.scroll_p, &p)){ Full_Cursor cursor = {}; view_compute_cursor(app, view, seek_wrapped_xy(p.x, p.y, true), &cursor); view_set_cursor(app, view, seek_pos(cursor.pos), true); @@ -296,15 +268,13 @@ CUSTOM_DOC("Sets the cursor position and mark to the mouse position.") CUSTOM_COMMAND_SIG(click_set_cursor) CUSTOM_DOC("Sets the cursor position to the mouse position.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Rect_i32 region = {}; - view_get_buffer_region(app, view, ®ion); + View_ID view = get_active_view(app, AccessProtected); + Rect_f32 region = view_get_buffer_region(app, view); GUI_Scroll_Vars scroll_vars = {}; view_get_scroll_vars(app, view, &scroll_vars); Mouse_State mouse = get_mouse_state(app); Vec2 p = {}; - if (view_space_from_screen_space_checked(mouse.p, region, scroll_vars.scroll_p, &p)){ + if (view_space_from_screen_space_checked(V2(mouse.p), region, scroll_vars.scroll_p, &p)){ view_set_cursor(app, view, seek_wrapped_xy(p.x, p.y, true), true); } no_mark_snap_to_cursor(app, view); @@ -313,16 +283,14 @@ CUSTOM_DOC("Sets the cursor position to the mouse position.") CUSTOM_COMMAND_SIG(click_set_cursor_if_lbutton) CUSTOM_DOC("If the mouse left button is pressed, sets the cursor position to the mouse position.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); + View_ID view = get_active_view(app, AccessProtected); Mouse_State mouse = get_mouse_state(app); if (mouse.l){ - Rect_i32 region = {}; - view_get_buffer_region(app, view, ®ion); + Rect_f32 region = view_get_buffer_region(app, view); GUI_Scroll_Vars scroll_vars = {}; view_get_scroll_vars(app, view, &scroll_vars); Vec2 p = {}; - if (view_space_from_screen_space_checked(mouse.p, region, scroll_vars.scroll_p, &p)){ + if (view_space_from_screen_space_checked(V2(mouse.p), region, scroll_vars.scroll_p, &p)){ view_set_cursor(app, view, seek_wrapped_xy(p.x, p.y, true), true); } } @@ -332,15 +300,13 @@ CUSTOM_DOC("If the mouse left button is pressed, sets the cursor position to the CUSTOM_COMMAND_SIG(click_set_mark) CUSTOM_DOC("Sets the mark position to the mouse position.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Rect_i32 region = {}; - view_get_buffer_region(app, view, ®ion); + View_ID view = get_active_view(app, AccessProtected); + Rect_f32 region = view_get_buffer_region(app, view); GUI_Scroll_Vars scroll_vars = {}; view_get_scroll_vars(app, view, &scroll_vars); Mouse_State mouse = get_mouse_state(app); Vec2 p = {}; - if (view_space_from_screen_space_checked(mouse.p, region, scroll_vars.scroll_p, &p)){ + if (view_space_from_screen_space_checked(V2(mouse.p), region, scroll_vars.scroll_p, &p)){ view_set_mark(app, view, seek_wrapped_xy(p.x, p.y, true)); } no_mark_snap_to_cursor(app, view); @@ -349,8 +315,7 @@ CUSTOM_DOC("Sets the mark position to the mouse position.") CUSTOM_COMMAND_SIG(mouse_wheel_scroll) CUSTOM_DOC("Reads the scroll wheel value from the mouse state and scrolls accordingly.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); + View_ID view = get_active_view(app, AccessProtected); Mouse_State mouse = get_mouse_state(app); if (mouse.wheel != 0){ GUI_Scroll_Vars scroll = {}; @@ -364,11 +329,9 @@ CUSTOM_DOC("Reads the scroll wheel value from the mouse state and scrolls accord static void move_vertical(Application_Links *app, f32 line_multiplier){ - View_ID view = 0; - get_active_view(app, AccessProtected, &view); + View_ID view = get_active_view(app, AccessProtected); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessProtected, &buffer); + Buffer_ID buffer = view_get_buffer(app, view, AccessProtected); Face_ID face_id = 0; get_face_id(app, buffer, &face_id); Face_Metrics metrics = {}; @@ -376,24 +339,20 @@ move_vertical(Application_Links *app, f32 line_multiplier){ f32 delta_y = line_multiplier*metrics.line_height; f32 new_y = get_view_y(app, view) + delta_y; - f32 x = 0; - view_get_preferred_x(app, view, &x); + f32 x = view_get_preferred_x(app, view); view_set_cursor(app, view, seek_wrapped_xy(x, new_y, false), false); f32 actual_new_y = get_view_y(app, view); if (actual_new_y < new_y){ - Rect_i32 file_region = {}; - view_get_buffer_region(app, view, &file_region); - i32 height = rect_height(file_region); - i32 full_scroll_y = (i32)actual_new_y - height/2; + Rect_f32 file_region = view_get_buffer_region(app, view); + f32 height = rect_height(file_region); + f32 full_scroll_y = actual_new_y - height*0.5f; GUI_Scroll_Vars scroll_vars = {}; view_get_scroll_vars(app, view, &scroll_vars); if (scroll_vars.target_y < full_scroll_y){ GUI_Scroll_Vars new_scroll_vars = scroll_vars; new_scroll_vars.target_y += (i32)delta_y; - if (new_scroll_vars.target_y > full_scroll_y){ - new_scroll_vars.target_y = full_scroll_y; - } + new_scroll_vars.target_y = clamp_top(new_scroll_vars.target_y, (i32)full_scroll_y); view_set_scroll(app, view, new_scroll_vars); } } @@ -403,18 +362,16 @@ move_vertical(Application_Links *app, f32 line_multiplier){ static f32 get_page_jump(Application_Links *app, View_ID view){ - Rect_i32 region = {}; - view_get_buffer_region(app, view, ®ion); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessProtected, &buffer); + Rect_f32 region = view_get_buffer_region(app, view); + Buffer_ID buffer = view_get_buffer(app, view, AccessProtected); Face_ID face_id = 0; get_face_id(app, buffer, &face_id); Face_Metrics metrics = {}; get_face_metrics(app, face_id, &metrics); f32 page_jump = 1.f; if (metrics.line_height > 0.f){ - i32 height = rect_height(region); - f32 line_count = (f32)(height)/metrics.line_height; + f32 height = rect_height(region); + f32 line_count = height/metrics.line_height; i32 line_count_rounded = (i32)line_count; page_jump = (f32)line_count_rounded - 3.f; page_jump = clamp_bot(1.f, page_jump); @@ -449,22 +406,18 @@ CUSTOM_DOC("Moves the cursor down ten lines.") CUSTOM_COMMAND_SIG(move_down_textual) CUSTOM_DOC("Moves down to the next line of actual text, regardless of line wrapping.") { - View_ID view = 0; - if (get_active_view(app, AccessOpen, &view)){ - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); - Full_Cursor cursor = {}; - view_compute_cursor(app, view, seek_pos(pos), &cursor); - i32 next_line = cursor.line + 1; - view_set_cursor(app, view, seek_line_char(next_line, 1), true); - } + View_ID view = get_active_view(app, AccessOpen); + i32 pos = view_get_cursor_pos(app, view); + Full_Cursor cursor = {}; + view_compute_cursor(app, view, seek_pos(pos), &cursor); + i32 next_line = cursor.line + 1; + view_set_cursor(app, view, seek_line_char(next_line, 1), true); } CUSTOM_COMMAND_SIG(page_up) CUSTOM_DOC("Scrolls the view up one view height and moves the cursor up one view height.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); + View_ID view = get_active_view(app, AccessProtected); f32 page_jump = get_page_jump(app, view); move_vertical(app, -page_jump); } @@ -472,20 +425,16 @@ CUSTOM_DOC("Scrolls the view up one view height and moves the cursor up one view CUSTOM_COMMAND_SIG(page_down) CUSTOM_DOC("Scrolls the view down one view height and moves the cursor down one view height.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); + View_ID view = get_active_view(app, AccessProtected); f32 page_jump = get_page_jump(app, view); move_vertical(app, page_jump); } internal void seek_blank_line(Application_Links *app, Scan_Direction direction, Position_Within_Line position){ - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessProtected, &buffer); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer = view_get_buffer(app, view, AccessProtected); + i32 pos = view_get_cursor_pos(app, view); i32 new_pos = get_pos_of_blank_line_grouped(app, buffer, direction, pos); switch (position){ case PositionWithinLine_SkipLeadingWhitespace: @@ -546,10 +495,8 @@ CUSTOM_DOC("Seeks the cursor down to the next blank line and places it at the en CUSTOM_COMMAND_SIG(move_left) CUSTOM_DOC("Moves the cursor one character to the left.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + View_ID view = get_active_view(app, AccessProtected); + i32 pos = view_get_cursor_pos(app, view); Full_Cursor cursor = {}; view_compute_cursor(app, view, seek_pos(pos), &cursor); i32 new_pos = clamp_bot(0, cursor.character_pos - 1); @@ -560,10 +507,8 @@ CUSTOM_DOC("Moves the cursor one character to the left.") CUSTOM_COMMAND_SIG(move_right) CUSTOM_DOC("Moves the cursor one character to the right.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + View_ID view = get_active_view(app, AccessProtected); + i32 pos = view_get_cursor_pos(app, view); Full_Cursor cursor = {}; view_compute_cursor(app, view, seek_pos(pos), &cursor); i32 new_pos = cursor.character_pos + 1; @@ -573,12 +518,9 @@ CUSTOM_DOC("Moves the cursor one character to the right.") static void current_view_scan_move(Application_Links *app, Scan_Direction direction, Boundary_Function_List funcs){ - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessProtected, &buffer); - i32 cursor_pos = 0; - view_get_cursor_pos(app, view, &cursor_pos); + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer = view_get_buffer(app, view, AccessProtected); + i32 cursor_pos = view_get_cursor_pos(app, view); i32 pos = scan(app, funcs, buffer, direction, cursor_pos); view_set_cursor(app, view, seek_pos(pos), true); no_mark_snap_to_cursor_if_shift(app, view); @@ -680,12 +622,9 @@ CUSTOM_DOC("Seek left for boundary between alphanumeric characters or camel case CUSTOM_COMMAND_SIG(select_all) CUSTOM_DOC("Puts the cursor at the top of the file, and the mark at the bottom of the file.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessProtected, &buffer); - i32 buffer_size = 0; - buffer_get_size(app, buffer, &buffer_size); + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer = view_get_buffer(app, view, AccessProtected); + i32 buffer_size = (i32)buffer_get_size(app, buffer); view_set_cursor(app, view, seek_pos(0), true); view_set_mark(app, view, seek_pos(buffer_size)); no_mark_snap_to_cursor(app, view); @@ -696,10 +635,8 @@ CUSTOM_DOC("Puts the cursor at the top of the file, and the mark at the bottom o CUSTOM_COMMAND_SIG(to_uppercase) CUSTOM_DOC("Converts all ascii text in the range between the cursor and the mark to uppercase.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); Range range = get_view_range(app, view); Scratch_Block scratch(app); String_Const_u8 string = push_buffer_range(app, scratch, buffer, range); @@ -711,10 +648,8 @@ CUSTOM_DOC("Converts all ascii text in the range between the cursor and the mark CUSTOM_COMMAND_SIG(to_lowercase) CUSTOM_DOC("Converts all ascii text in the range between the cursor and the mark to lowercase.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); Range range = get_view_range(app, view); Scratch_Block scratch(app); String_Const_u8 string = push_buffer_range(app, scratch, buffer, range); @@ -726,13 +661,10 @@ CUSTOM_DOC("Converts all ascii text in the range between the cursor and the mark CUSTOM_COMMAND_SIG(clean_all_lines) CUSTOM_DOC("Removes trailing whitespace from all lines in the current buffer.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); - i32 line_count = 0; - buffer_get_line_count(app, buffer, &line_count); + i32 line_count = (i32)buffer_get_line_count(app, buffer); Scratch_Block scratch(app); Buffer_Edit *edits = push_array(scratch, Buffer_Edit, line_count); @@ -767,8 +699,7 @@ CUSTOM_DOC("Removes trailing whitespace from all lines in the current buffer.") CUSTOM_COMMAND_SIG(basic_change_active_panel) CUSTOM_DOC("Change the currently active panel, moving to the panel with the next highest view_id. Will not skipe the build panel if it is open.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); get_next_view_looped_all_panels(app, view, AccessAll); view_set_active(app, view); } @@ -776,8 +707,7 @@ CUSTOM_DOC("Change the currently active panel, moving to the panel with the next CUSTOM_COMMAND_SIG(close_panel) CUSTOM_DOC("Closes the currently active panel if it is not the only panel open.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); view_close(app, view); } @@ -786,41 +716,36 @@ CUSTOM_DOC("Closes the currently active panel if it is not the only panel open." CUSTOM_COMMAND_SIG(show_scrollbar) CUSTOM_DOC("Sets the current view to show it's scrollbar.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); view_set_setting(app, view, ViewSetting_ShowScrollbar, true); } CUSTOM_COMMAND_SIG(hide_scrollbar) CUSTOM_DOC("Sets the current view to hide it's scrollbar.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); view_set_setting(app, view, ViewSetting_ShowScrollbar, false); } CUSTOM_COMMAND_SIG(show_filebar) CUSTOM_DOC("Sets the current view to show it's filebar.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); view_set_setting(app, view, ViewSetting_ShowFileBar, true); } CUSTOM_COMMAND_SIG(hide_filebar) CUSTOM_DOC("Sets the current view to hide it's filebar.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); view_set_setting(app, view, ViewSetting_ShowFileBar, false); } CUSTOM_COMMAND_SIG(toggle_filebar) CUSTOM_DOC("Toggles the visibility status of the current view's filebar.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); - b32 value; + View_ID view = get_active_view(app, AccessAll); + b32 value = false; view_get_setting(app, view, ViewSetting_ShowFileBar, &value); view_set_setting(app, view, ViewSetting_ShowFileBar, !value); } @@ -828,10 +753,8 @@ CUSTOM_DOC("Toggles the visibility status of the current view's filebar.") CUSTOM_COMMAND_SIG(toggle_line_wrap) CUSTOM_DOC("Toggles the current buffer's line wrapping status.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessProtected, &buffer); + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer = view_get_buffer(app, view, AccessProtected); b32 wrapped; buffer_get_setting(app, buffer, BufferSetting_WrapLine, &wrapped); buffer_set_setting(app, buffer, BufferSetting_WrapLine, !wrapped); @@ -846,10 +769,8 @@ CUSTOM_DOC("Toggles the visibility of the FPS performance meter") CUSTOM_COMMAND_SIG(increase_line_wrap) CUSTOM_DOC("Increases the current buffer's width for line wrapping.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessProtected, &buffer); + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer = view_get_buffer(app, view, AccessProtected); i32 wrap = 0; buffer_get_setting(app, buffer, BufferSetting_WrapPosition, &wrap); buffer_set_setting(app, buffer, BufferSetting_WrapPosition, wrap + 10); @@ -858,10 +779,8 @@ CUSTOM_DOC("Increases the current buffer's width for line wrapping.") CUSTOM_COMMAND_SIG(decrease_line_wrap) CUSTOM_DOC("Decrases the current buffer's width for line wrapping.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessProtected, &buffer); + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer = view_get_buffer(app, view, AccessProtected); i32 wrap = 0; buffer_get_setting(app, buffer, BufferSetting_WrapPosition, &wrap); buffer_set_setting(app, buffer, BufferSetting_WrapPosition, wrap - 10); @@ -870,10 +789,8 @@ CUSTOM_DOC("Decrases the current buffer's width for line wrapping.") CUSTOM_COMMAND_SIG(increase_face_size) CUSTOM_DOC("Increase the size of the face used by the current buffer.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessAll, &buffer); + View_ID view = get_active_view(app, AccessAll); + Buffer_ID buffer = view_get_buffer(app, view, AccessAll); Face_ID face_id = 0; get_face_id(app, buffer, &face_id); Face_Description description = get_face_description(app, face_id); @@ -884,10 +801,8 @@ CUSTOM_DOC("Increase the size of the face used by the current buffer.") CUSTOM_COMMAND_SIG(decrease_face_size) CUSTOM_DOC("Decrease the size of the face used by the current buffer.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessAll, &buffer); + View_ID view = get_active_view(app, AccessAll); + Buffer_ID buffer = view_get_buffer(app, view, AccessAll); Face_ID face_id = 0; get_face_id(app, buffer, &face_id); Face_Description description = get_face_description(app, face_id); @@ -915,10 +830,8 @@ CUSTOM_DOC("Reads the state of the mouse wheel and uses it to either increase or CUSTOM_COMMAND_SIG(toggle_virtual_whitespace) CUSTOM_DOC("Toggles the current buffer's virtual whitespace status.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessProtected, &buffer); + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer = view_get_buffer(app, view, AccessProtected); i32 vwhite = 0; buffer_get_setting(app, buffer, BufferSetting_VirtualWhitespace, &vwhite); buffer_set_setting(app, buffer, BufferSetting_VirtualWhitespace, !vwhite); @@ -927,8 +840,7 @@ CUSTOM_DOC("Toggles the current buffer's virtual whitespace status.") CUSTOM_COMMAND_SIG(toggle_show_whitespace) CUSTOM_DOC("Toggles the current buffer's whitespace visibility status.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); + View_ID view = get_active_view(app, AccessProtected); b32 show_whitespace; view_get_setting(app, view, ViewSetting_ShowWhitespace, &show_whitespace); view_set_setting(app, view, ViewSetting_ShowWhitespace, !show_whitespace); @@ -943,20 +855,16 @@ CUSTOM_DOC("Toggles the left margin line numbers.") CUSTOM_COMMAND_SIG(eol_dosify) CUSTOM_DOC("Puts the buffer in DOS line ending mode.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); buffer_set_setting(app, buffer, BufferSetting_Eol, 1); } CUSTOM_COMMAND_SIG(eol_nixify) CUSTOM_DOC("Puts the buffer in NIX line ending mode.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); buffer_set_setting(app, buffer, BufferSetting_Eol, 0); } @@ -978,8 +886,7 @@ CUSTOM_DOC("Queries the user for a number, and jumps the cursor to the correspon bar.string_capacity = sizeof(string_space); if (query_user_number(app, &bar)){ i32 line_number = (i32)string_to_integer(bar.string, 10); - View_ID view = 0; - get_active_view(app, AccessProtected, &view); + View_ID view = get_active_view(app, AccessProtected); view_set_cursor(app, view, seek_line_char(line_number, 0), true); } } @@ -998,10 +905,8 @@ isearch__update_highlight(Application_Links *app, View_ID view, Managed_Object h static void isearch(Application_Links *app, b32 start_reversed, String_Const_u8 query_init, b32 on_the_query_init_string){ - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer_id = 0; - view_get_buffer(app, view, AccessProtected, &buffer_id); + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer_id = view_get_buffer(app, view, AccessProtected); if (!buffer_exists(app, buffer_id)){ return; } @@ -1012,8 +917,7 @@ isearch(Application_Links *app, b32 start_reversed, String_Const_u8 query_init, } b32 reverse = start_reversed; - i32 first_pos = 0; - view_get_cursor_pos(app, view, &first_pos); + i32 first_pos = view_get_cursor_pos(app, view); i32 pos = first_pos; if (query_init.size != 0){ @@ -1157,8 +1061,7 @@ isearch(Application_Links *app, b32 start_reversed, String_Const_u8 query_init, else{ i32 new_pos = 0; buffer_seek_string_insensitive_forward(app, buffer_id, start_pos + 1, 0, bar.string, &new_pos); - i32 buffer_size = 0; - buffer_get_size(app, buffer_id, &buffer_size); + i32 buffer_size = (i32)buffer_get_size(app, buffer_id); if (new_pos < buffer_size){ if (step_forward){ pos = new_pos; @@ -1211,12 +1114,9 @@ CUSTOM_DOC("Begins an incremental search up through the current buffer for a use CUSTOM_COMMAND_SIG(search_identifier) CUSTOM_DOC("Begins an incremental search down through the current buffer for the word or token under the cursor.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer_id = 0; - view_get_buffer(app, view, AccessProtected, &buffer_id); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer_id = view_get_buffer(app, view, AccessProtected); + i32 pos = view_get_cursor_pos(app, view); Scratch_Block scratch(app); String_Const_u8 query = push_enclose_range_at_pos(app, scratch, buffer_id, pos, enclose_alpha_numeric_underscore); @@ -1226,12 +1126,9 @@ CUSTOM_DOC("Begins an incremental search down through the current buffer for the CUSTOM_COMMAND_SIG(reverse_search_identifier) CUSTOM_DOC("Begins an incremental search up through the current buffer for the word or token under the cursor.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer_id = 0; - view_get_buffer(app, view, AccessProtected, &buffer_id); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer_id = view_get_buffer(app, view, AccessProtected); + i32 pos = view_get_cursor_pos(app, view); Scratch_Block scratch(app); String_Const_u8 query = push_enclose_range_at_pos(app, scratch, buffer_id, pos, enclose_alpha_numeric_underscore); @@ -1256,14 +1153,10 @@ CUSTOM_DOC("Queries the user for two strings, and replaces all occurences of the if (query_user_string(app, &replace) && replace.string.size != 0 && query_user_string(app, &with)){ String_Const_u8 r = replace.string; String_Const_u8 w = with.string; - - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer_id = 0; - view_get_buffer(app, view, AccessOpen, &buffer_id); - + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); Range range = get_view_range(app, view); - replace_in_range(app, buffer_id, range, r, w); + replace_in_range(app, buffer, range, r, w); } } @@ -1280,8 +1173,7 @@ query_replace_base(Application_Links *app, View_ID view, Buffer_ID buffer_id, i3 marker_visual_set_view_key(app, visual, view); cursor_is_hidden = true; - i32 buffer_size = 0; - buffer_get_size(app, buffer_id, &buffer_size); + i32 buffer_size = (i32)buffer_get_size(app, buffer_id); User_Input in = {}; for (;new_pos < buffer_size;){ @@ -1333,27 +1225,23 @@ query_replace_parameter(Application_Links *app, String_Const_u8 replace_str, i32 String_Const_u8 r = replace.string; String_Const_u8 w = with.string; - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer_id = 0; - view_get_buffer(app, view, AccessProtected, &buffer_id); + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer = view_get_buffer(app, view, AccessProtected); i32 pos = start_pos; Query_Bar bar = {}; bar.prompt = string_u8_litexpr("Replace? (y)es, (n)ext, (esc)\n"); start_query_bar(app, &bar, 0); - query_replace_base(app, view, buffer_id, pos, r, w); + query_replace_base(app, view, buffer, pos, r, w); } } CUSTOM_COMMAND_SIG(query_replace) CUSTOM_DOC("Queries the user for two strings, and incrementally replaces every occurence of the first string with the second string.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); if (buffer != 0){ Query_Bar replace = {}; u8 replace_space[1024]; @@ -1362,8 +1250,7 @@ CUSTOM_DOC("Queries the user for two strings, and incrementally replaces every o replace.string_capacity = sizeof(replace_space); if (query_user_string(app, &replace)){ if (replace.string.size > 0){ - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + i32 pos = view_get_cursor_pos(app, view); query_replace_parameter(app, replace.string, pos, false); } } @@ -1373,13 +1260,10 @@ CUSTOM_DOC("Queries the user for two strings, and incrementally replaces every o CUSTOM_COMMAND_SIG(query_replace_identifier) CUSTOM_DOC("Queries the user for a string, and incrementally replace every occurence of the word or token found at the cursor with the specified string.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); if (buffer != 0){ - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + i32 pos = view_get_cursor_pos(app, view); Scratch_Block scratch(app); Range range = enclose_alpha_numeric_underscore(app, buffer, make_range(pos)); String_Const_u8 replace = push_buffer_range(app, scratch, buffer, range); @@ -1392,10 +1276,8 @@ CUSTOM_DOC("Queries the user for a string, and incrementally replace every occur CUSTOM_COMMAND_SIG(query_replace_selection) CUSTOM_DOC("Queries the user for a string, and incrementally replace every occurence of the string found in the selected range with the specified string.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); if (buffer != 0){ Arena *scratch = context_get_arena(app); Temp_Memory temp = begin_temp(scratch); @@ -1416,12 +1298,10 @@ CUSTOM_DOC("Queries the user for a string, and incrementally replace every occur static void save_all_dirty_buffers_with_postfix(Application_Links *app, String_Const_u8 postfix){ Arena *scratch = context_get_arena(app); - Buffer_ID buffer = 0; - for (get_buffer_next(app, 0, AccessOpen, &buffer); + for (Buffer_ID buffer = get_buffer_next(app, 0, AccessOpen); buffer != 0; - get_buffer_next(app, buffer, AccessOpen, &buffer)){ - Dirty_State dirty = 0; - buffer_get_dirty_state(app, buffer, &dirty); + buffer = get_buffer_next(app, buffer, AccessOpen)){ + Dirty_State dirty = buffer_get_dirty_state(app, buffer); if (dirty == DirtyState_UnsavedChanges){ Temp_Memory temp = begin_temp(scratch); String_Const_u8 file_name = push_buffer_file_name(app, scratch, buffer); @@ -1455,16 +1335,14 @@ delete_file_base(Application_Links *app, String_Const_u8 file_name, Buffer_ID bu string_list_pushf(scratch, &list, "\"%.*s\"", string_expand(file_name)); String_Const_u8 cmd = string_list_flatten(scratch, list, StringFill_NullTerminate); exec_system_command(app, 0, buffer_identifier(0), path, cmd, 0); - kill_buffer(app, buffer_identifier(buffer_id), 0, BufferKill_AlwaysKill); + buffer_kill(app, buffer_id, BufferKill_AlwaysKill); } CUSTOM_COMMAND_SIG(delete_file_query) CUSTOM_DOC("Deletes the file of the current buffer if 4coder has the appropriate access rights. Will ask the user for confirmation first.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessAll, &buffer); + View_ID view = get_active_view(app, AccessAll); + Buffer_ID buffer = view_get_buffer(app, view, AccessAll); Scratch_Block scratch(app); String_Const_u8 file_name = push_buffer_file_name(app, scratch, buffer); if (file_name.size > 0){ @@ -1501,10 +1379,8 @@ CUSTOM_DOC("Deletes the file of the current buffer if 4coder has the appropriate CUSTOM_COMMAND_SIG(save_to_query) CUSTOM_DOC("Queries the user for a file name and saves the contents of the current buffer, altering the buffer's name too.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessAll, &buffer); + View_ID view = get_active_view(app, AccessAll); + Buffer_ID buffer = view_get_buffer(app, view, AccessAll); Arena *scratch = context_get_arena(app); Temp_Memory temp = begin_temp(scratch); @@ -1523,10 +1399,9 @@ CUSTOM_DOC("Queries the user for a file name and saves the contents of the curre string_list_push(scratch, &new_file_name_list, bar.string); String_Const_u8 new_file_name = string_list_flatten(scratch, new_file_name_list); if (buffer_save(app, buffer, new_file_name, BufferSave_IgnoreDirtyFlag)){ - Buffer_ID new_buffer = 0; - create_buffer(app, new_file_name, BufferCreate_NeverNew|BufferCreate_JustChangedFile, &new_buffer); + Buffer_ID new_buffer = create_buffer(app, new_file_name, BufferCreate_NeverNew|BufferCreate_JustChangedFile); if (new_buffer != 0 && new_buffer != buffer){ - kill_buffer(app, buffer_identifier(buffer), 0, BufferKill_AlwaysKill); + buffer_kill(app, buffer, BufferKill_AlwaysKill); view_set_buffer(app, view, new_buffer, 0); } } @@ -1539,10 +1414,8 @@ CUSTOM_DOC("Queries the user for a file name and saves the contents of the curre CUSTOM_COMMAND_SIG(rename_file_query) CUSTOM_DOC("Queries the user for a new name and renames the file of the current buffer, altering the buffer's name too.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessAll, &buffer); + View_ID view = get_active_view(app, AccessAll); + Buffer_ID buffer = view_get_buffer(app, view, AccessAll); Arena *scratch = context_get_arena(app); Temp_Memory temp = begin_temp(scratch); @@ -1564,8 +1437,7 @@ CUSTOM_DOC("Queries the user for a new name and renames the file of the current string_list_push(scratch, &new_file_name_list, bar.string); String_Const_u8 new_file_name = string_list_flatten(scratch, new_file_name_list, StringFill_NullTerminate); if (buffer_save(app, buffer, new_file_name, BufferSave_IgnoreDirtyFlag)){ - Buffer_ID new_buffer = 0; - create_buffer(app, new_file_name, BufferCreate_NeverNew|BufferCreate_JustChangedFile, &new_buffer); + Buffer_ID new_buffer = create_buffer(app, new_file_name, BufferCreate_NeverNew|BufferCreate_JustChangedFile); if (new_buffer != 0 && new_buffer != buffer){ delete_file_base(app, file_name, buffer); view_set_buffer(app, view, new_buffer, 0); @@ -1604,12 +1476,9 @@ CUSTOM_DOC("Queries the user for a name and creates a new directory with the giv internal void current_view_move_line(Application_Links *app, Scan_Direction direction){ - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); + i32 pos = view_get_cursor_pos(app, view); i32 line_number = get_line_number_from_pos(app, buffer, pos); pos = move_line(app, buffer, line_number, direction); view_set_cursor(app, view, seek_pos(pos), true); @@ -1630,12 +1499,9 @@ CUSTOM_DOC("Swaps the line under the cursor with the line below it, and moves th CUSTOM_COMMAND_SIG(duplicate_line) CUSTOM_DOC("Create a copy of the line on which the cursor sits.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); + i32 pos = view_get_cursor_pos(app, view); i32 line = get_line_number_from_pos(app, buffer, pos); Scratch_Block scratch(app); String_Const_u8 s = push_buffer_line(app, scratch, buffer, line); @@ -1647,17 +1513,13 @@ CUSTOM_DOC("Create a copy of the line on which the cursor sits.") CUSTOM_COMMAND_SIG(delete_line) CUSTOM_DOC("Delete the line the on which the cursor sits.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); + i32 pos = view_get_cursor_pos(app, view); i32 line = get_line_number_from_pos(app, buffer, pos); Range range = get_line_pos_range(app, buffer, line); range.end += 1; - i32 size = 0; - buffer_get_size(app, buffer, &size); + i32 size = (i32)buffer_get_size(app, buffer); range.end = clamp_top(range.end, size); if (range_size(range) == 0 || buffer_get_char(app, buffer, range.end - 1) != '\n'){ @@ -1716,15 +1578,12 @@ get_cpp_matching_file(Application_Links *app, Buffer_ID buffer, Buffer_ID *buffe CUSTOM_COMMAND_SIG(open_file_in_quotes) CUSTOM_DOC("Reads a filename from surrounding '\"' characters and attempts to open the corresponding file.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer_id = 0; - view_get_buffer(app, view, AccessProtected, &buffer_id); + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer_id = view_get_buffer(app, view, AccessProtected); if (buffer_exists(app, buffer_id)){ Scratch_Block scratch(app); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + i32 pos = view_get_cursor_pos(app, view); Range range = {}; buffer_seek_delimiter_forward(app, buffer_id, pos, '"', &range.end); @@ -1754,10 +1613,8 @@ CUSTOM_DOC("Reads a filename from surrounding '\"' characters and attempts to op CUSTOM_COMMAND_SIG(open_matching_file_cpp) CUSTOM_DOC("If the current file is a *.cpp or *.h, attempts to open the corresponding *.h or *.cpp file in the other view.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessAll, &buffer); + View_ID view = get_active_view(app, AccessAll); + Buffer_ID buffer = view_get_buffer(app, view, AccessAll); Buffer_ID new_buffer = 0; if (get_cpp_matching_file(app, buffer, &new_buffer)){ view = get_next_view_looped_primary_panels(app, view, AccessAll); @@ -1769,14 +1626,11 @@ CUSTOM_DOC("If the current file is a *.cpp or *.h, attempts to open the correspo CUSTOM_COMMAND_SIG(view_buffer_other_panel) CUSTOM_DOC("Set the other non-active panel to view the buffer that the active panel views, and switch to that panel.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessAll, &buffer); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + View_ID view = get_active_view(app, AccessAll); + Buffer_ID buffer = view_get_buffer(app, view, AccessAll); + i32 pos = view_get_cursor_pos(app, view); change_active_panel(app); - get_active_view(app, AccessAll, &view); + view = get_active_view(app, AccessAll); view_set_buffer(app, view, buffer, 0); view_set_cursor(app, view, seek_pos(pos), true); } @@ -1784,34 +1638,26 @@ CUSTOM_DOC("Set the other non-active panel to view the buffer that the active pa CUSTOM_COMMAND_SIG(swap_buffers_between_panels) CUSTOM_DOC("Set the other non-active panel to view the buffer that the active panel views, and switch to that panel.") { - View_ID view1 = 0; - get_active_view(app, AccessAll, &view1); + View_ID view1 = get_active_view(app, AccessAll); change_active_panel(app); - View_ID view2 = 0; - get_active_view(app, AccessAll, &view2); + View_ID view2 = get_active_view(app, AccessAll); if (view1 != view2){ - Buffer_ID buffer1 = 0; - Buffer_ID buffer2 = 0; - view_get_buffer(app, view1, AccessAll, &buffer1); - view_get_buffer(app, view2, AccessAll, &buffer2); + Buffer_ID buffer1 = view_get_buffer(app, view1, AccessAll); + Buffer_ID buffer2 = view_get_buffer(app, view2, AccessAll); if (buffer1 != buffer2){ view_set_buffer(app, view1, buffer2, 0); view_set_buffer(app, view2, buffer1, 0); } else{ - i32 p1 = 0; - i32 m1 = 0; - i32 p2 = 0; - i32 m2 = 0; GUI_Scroll_Vars sc1 = {}; GUI_Scroll_Vars sc2 = {}; - view_get_cursor_pos(app, view1, &p1); - view_get_mark_pos(app, view1, &m1); + i32 p1 = view_get_cursor_pos(app, view1); + i32 m1 = view_get_mark_pos(app, view1); view_get_scroll_vars(app, view1, &sc1); - view_get_cursor_pos(app, view2, &p2); - view_get_mark_pos(app, view2, &m2); + i32 p2 = view_get_cursor_pos(app, view2); + i32 m2 = view_get_mark_pos(app, view2); view_get_scroll_vars(app, view2, &sc2); view_set_cursor(app, view1, seek_pos(p2), true); @@ -1829,20 +1675,16 @@ CUSTOM_DOC("Set the other non-active panel to view the buffer that the active pa CUSTOM_COMMAND_SIG(kill_buffer) CUSTOM_DOC("Kills the current buffer.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessProtected, &buffer); - kill_buffer(app, buffer_identifier(buffer), view, 0); + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer = view_get_buffer(app, view, AccessProtected); + try_buffer_kill(app, buffer, view, 0); } CUSTOM_COMMAND_SIG(save) CUSTOM_DOC("Saves the current buffer.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessProtected, &buffer); + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer = view_get_buffer(app, view, AccessProtected); Arena *scratch = context_get_arena(app); Temp_Memory temp = begin_temp(scratch); String_Const_u8 file_name = push_buffer_file_name(app, scratch, buffer); @@ -1853,11 +1695,9 @@ CUSTOM_DOC("Saves the current buffer.") CUSTOM_COMMAND_SIG(reopen) CUSTOM_DOC("Reopen the current buffer from the hard drive.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessProtected, &buffer); - buffer_reopen(app, buffer, 0, 0); + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer = view_get_buffer(app, view, AccessProtected); + buffer_reopen(app, buffer, 0); } //////////////////////////////// @@ -1917,10 +1757,8 @@ record_get_new_cursor_position_redo(Application_Links *app, Buffer_ID buffer_id, CUSTOM_COMMAND_SIG(undo) CUSTOM_DOC("Advances backwards through the undo history of the current buffer.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); History_Record_Index current = 0; buffer_history_get_current_state_index(app, buffer, ¤t); if (current > 0){ @@ -1933,10 +1771,8 @@ CUSTOM_DOC("Advances backwards through the undo history of the current buffer.") CUSTOM_COMMAND_SIG(redo) CUSTOM_DOC("Advances forwards through the undo history of the current buffer.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); History_Record_Index current = 0; History_Record_Index max_index = 0; buffer_history_get_current_state_index(app, buffer, ¤t); @@ -1958,10 +1794,9 @@ CUSTOM_DOC("Advances backward through the undo history in the buffer containing i32 match_count = 0; { - Buffer_ID buffer = 0; - for (get_buffer_next(app, 0, AccessAll, &buffer); + for (Buffer_ID buffer = get_buffer_next(app, 0, AccessAll); buffer != 0; - get_buffer_next(app, buffer, AccessAll, &buffer)){ + buffer = get_buffer_next(app, buffer, AccessAll)){ History_Record_Index index = 0; buffer_history_get_current_state_index(app, buffer, &index); if (index > 0){ @@ -1989,7 +1824,7 @@ CUSTOM_DOC("Advances backward through the undo history in the buffer containing if (highest_edit_number != -1){ for (Buffer_ID buffer = first_buffer_match; buffer != 0; - get_buffer_next(app, buffer, AccessAll, &buffer)){ + buffer = get_buffer_next(app, buffer, AccessAll)){ b32 did_match = false; i32 new_edit_position = 0; for (;;){ @@ -2037,10 +1872,9 @@ CUSTOM_DOC("Advances forward through the undo history in the buffer containing t i32 match_count = 0; { - Buffer_ID buffer = 0; - for (get_buffer_next(app, 0, AccessAll, &buffer); + for (Buffer_ID buffer = get_buffer_next(app, 0, AccessAll); buffer != 0; - get_buffer_next(app, buffer, AccessAll, &buffer)){ + buffer = get_buffer_next(app, buffer, AccessAll)){ History_Record_Index max_index = 0; History_Record_Index index = 0; buffer_history_get_max_record_index(app, buffer, &max_index); @@ -2070,7 +1904,7 @@ CUSTOM_DOC("Advances forward through the undo history in the buffer containing t if (lowest_edit_number != -1){ for (Buffer_ID buffer = first_buffer_match; buffer != 0; - get_buffer_next(app, buffer, AccessAll, &buffer)){ + buffer = get_buffer_next(app, buffer, AccessAll)){ b32 did_match = false; i32 new_edit_position = 0; History_Record_Index max_index = 0; diff --git a/4coder_base_types.cpp b/4coder_base_types.cpp index 52737721..e17fa87f 100644 --- a/4coder_base_types.cpp +++ b/4coder_base_types.cpp @@ -1782,6 +1782,23 @@ range_is_valid(Interval_f32 a){ return(a.min <= a.max); } +internal i32 +range_side(Interval_i32 a, Side side){ + return(side == Side_Min?a.min:a.max); +} +internal i64 +range_side(Interval_i64 a, Side side){ + return(side == Side_Min?a.min:a.max); +} +internal u64 +range_side(Interval_u64 a, Side side){ + return(side == Side_Min?a.min:a.max); +} +internal f32 +range_side(Interval_f32 a, Side side){ + return(side == Side_Min?a.min:a.max); +} + //////////////////////////////// internal i32 @@ -1835,12 +1852,12 @@ Rf32(Vec2_f32 p0, Vec2_f32 p1){ internal Rect_i32 Ri32(Rect_f32 o){ - Rect_i32 rect = {(i32)(o.x0), (i32)(o.y0), (i32)(o.x0), (i32)(o.y1)}; + Rect_i32 rect = {(i32)(o.x0), (i32)(o.y0), (i32)(o.x1), (i32)(o.y1)}; return(rect); } internal Rect_f32 Rf32(Rect_i32 o){ - Rect_f32 rect = {(f32)(o.x0), (f32)(o.y0), (f32)(o.x0), (f32)(o.y1)}; + Rect_f32 rect = {(f32)(o.x0), (f32)(o.y0), (f32)(o.x1), (f32)(o.y1)}; return(rect); } diff --git a/4coder_build_commands.cpp b/4coder_build_commands.cpp index b7bf0035..9f699a3b 100644 --- a/4coder_build_commands.cpp +++ b/4coder_build_commands.cpp @@ -128,25 +128,22 @@ standard_search_and_build(Application_Links *app, View_ID view, Buffer_ID active CUSTOM_COMMAND_SIG(build_search) CUSTOM_DOC("Looks for a build.bat, build.sh, or makefile in the current and parent directories. Runs the first that it finds and prints the output to *compilation*.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessAll, &buffer); + View_ID view = get_active_view(app, AccessAll); + Buffer_ID buffer = view_get_buffer(app, view, AccessAll); standard_search_and_build(app, view, buffer); memset(&prev_location, 0, sizeof(prev_location)); lock_jump_buffer(string_u8_litexpr("*compilation*")); } -static b32 -get_comp_buffer(Application_Links *app, Buffer_ID *id_out){ - return(get_buffer_by_name(app, string_u8_litexpr("*compilation*"), AccessAll, id_out)); +static Buffer_ID +get_comp_buffer(Application_Links *app){ + return(get_buffer_by_name(app, string_u8_litexpr("*compilation*"), AccessAll)); } static View_ID get_or_open_build_panel(Application_Links *app){ View_ID view = 0; - Buffer_ID buffer = 0; - get_comp_buffer(app, &buffer); + Buffer_ID buffer = get_comp_buffer(app); if (buffer != 0){ view = get_first_view_with_buffer(app, buffer); } @@ -158,18 +155,15 @@ get_or_open_build_panel(Application_Links *app){ static void set_fancy_compilation_buffer_font(Application_Links *app){ - Buffer_ID buffer = 0; - get_comp_buffer(app, &buffer); + Buffer_ID buffer = get_comp_buffer(app); set_buffer_face_by_name(app, buffer, string_u8_litexpr("Inconsolata")); } CUSTOM_COMMAND_SIG(build_in_build_panel) CUSTOM_DOC("Looks for a build.bat, build.sh, or makefile in the current and parent directories. Runs the first that it finds and prints the output to *compilation*. Puts the *compilation* buffer in a panel at the footer of the current view.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessAll, &buffer); + View_ID view = get_active_view(app, AccessAll); + Buffer_ID buffer = view_get_buffer(app, view, AccessAll); View_ID build_view = get_or_open_build_panel(app); diff --git a/4coder_casey_classic.cpp b/4coder_casey_classic.cpp index 1609827d..2ae5aed6 100644 --- a/4coder_casey_classic.cpp +++ b/4coder_casey_classic.cpp @@ -457,7 +457,7 @@ internal void DeleteAfterMotion(struct Application_Links *app, Custom_Command_Function *motion) { unsigned int access = AccessOpen; - View_Summary view = get_active_view(app, access); + View_Summary view = get_active_view_DEP(app, access); int pos2 = view.cursor.pos; motion(app); @@ -501,7 +501,7 @@ CUSTOM_COMMAND_SIG(casey_delete_token_right) CUSTOM_COMMAND_SIG(casey_kill_to_end_of_line) { unsigned int access = AccessOpen; - View_Summary view = get_active_view(app, access); + View_Summary view = get_active_view_DEP(app, access); int pos2 = view.cursor.pos; exec_command(app, seek_end_of_line); @@ -567,7 +567,7 @@ SwitchToOrLoadFile(struct Application_Links *app, String FileName, bool CreateIf SanitizeSlashes(FileName); unsigned int access = AccessAll; - View_Summary view = get_active_view(app, access); + View_Summary view = get_active_view_DEP(app, access); Buffer_Summary buffer = get_buffer_by_name(app, FileName.str, FileName.size, access); Result.view = view; @@ -663,7 +663,7 @@ CUSTOM_COMMAND_SIG(casey_build_search) CUSTOM_COMMAND_SIG(casey_find_corresponding_file) { unsigned int access = AccessProtected; - View_Summary view = get_active_view(app, access); + View_Summary view = get_active_view_DEP(app, access); Buffer_Summary buffer = get_buffer(app, view.buffer_id, access); String extension = file_extension(make_string(buffer.file_name, buffer.file_name_len)); @@ -719,11 +719,11 @@ CUSTOM_COMMAND_SIG(casey_find_corresponding_file) CUSTOM_COMMAND_SIG(casey_find_corresponding_file_other_window) { unsigned int access = AccessProtected; - View_Summary old_view = get_active_view(app, access); + View_Summary old_view = get_active_view_DEP(app, access); Buffer_Summary buffer = get_buffer(app, old_view.buffer_id, access); exec_command(app, change_active_panel); - View_Summary new_view = get_active_view(app, AccessAll); + View_Summary new_view = get_active_view_DEP(app, AccessAll); view_set_buffer(app, &new_view, buffer.buffer_id, 0); // exec_command(app, casey_find_corresponding_file); @@ -771,7 +771,7 @@ CUSTOM_COMMAND_SIG(casey_save_and_make_without_asking) if(append(&command, "build.bat")) { unsigned int access = AccessAll; - View_Summary view = get_active_view(app, access); + View_Summary view = get_active_view_DEP(app, access); exec_system_command(app, &view, buffer_identifier(GlobalCompilationBufferName, (int)strlen(GlobalCompilationBufferName)), dir.str, dir.size, @@ -996,7 +996,7 @@ ParseCalc(tokenizer *Tokenizer) CUSTOM_COMMAND_SIG(casey_quick_calc) { unsigned int access = AccessOpen; - View_Summary view = get_active_view(app, access); + View_Summary view = get_active_view_DEP(app, access); Range range = get_view_range(&view); @@ -1130,7 +1130,7 @@ IsCodeLegal(int32_t Codepoint) CUSTOM_COMMAND_SIG(casey_force_codelegal_characters) { - View_Summary view = get_active_view(app, AccessOpen); + View_Summary view = get_active_view_DEP(app, AccessOpen); Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessOpen); int32_t line_count = buffer.line_count; @@ -1428,7 +1428,7 @@ casey_list_all_functions(Application_Links *app, Partition *part, Buffer_Summary buffer_replace_range(app, decls_buffer, size, size, str, part_size); - View_Summary view = get_active_view(app, AccessAll); + View_Summary view = get_active_view_DEP(app, AccessAll); view_set_buffer(app, &view, decls_buffer->buffer_id, 0); lock_jump_buffer(decls_buffer->buffer_name, decls_buffer->buffer_name_len); @@ -1455,7 +1455,7 @@ ClearDeclsBuffer(Application_Links *app, Buffer_Summary *decls_buffer) CUSTOM_COMMAND_SIG(casey_list_all_functions_current_buffer){ uint32_t access = AccessProtected; - View_Summary view = get_active_view(app, access); + View_Summary view = get_active_view_DEP(app, access); Buffer_Summary buffer = get_buffer(app, view.buffer_id, access); Buffer_Summary decls_buffer; diff --git a/4coder_clipboard.cpp b/4coder_clipboard.cpp index 353fb8ed..ea606537 100644 --- a/4coder_clipboard.cpp +++ b/4coder_clipboard.cpp @@ -7,8 +7,7 @@ static b32 post_buffer_range_to_clipboard(Application_Links *app, i32 clipboard_index, Buffer_ID buffer, i32 first, i32 one_past_last){ b32 success = false; - i32 buffer_size = 0; - buffer_get_size(app, buffer, &buffer_size); + i32 buffer_size = (i32)buffer_get_size(app, buffer); if (buffer != 0 && 0 <= first && first < one_past_last && one_past_last <= buffer_size){ Scratch_Block scratch(app); Range range = make_range(first, one_past_last); @@ -24,10 +23,8 @@ post_buffer_range_to_clipboard(Application_Links *app, i32 clipboard_index, Buff CUSTOM_COMMAND_SIG(copy) CUSTOM_DOC("Copy the text in the range from the cursor to the mark onto the clipboard.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessProtected, &buffer); + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer = view_get_buffer(app, view, AccessProtected); Range range = get_view_range(app, view); post_buffer_range_to_clipboard(app, 0, buffer, range.min, range.max); } @@ -35,10 +32,8 @@ CUSTOM_DOC("Copy the text in the range from the cursor to the mark onto the clip CUSTOM_COMMAND_SIG(cut) CUSTOM_DOC("Cut the text in the range from the cursor to the mark onto the clipboard.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); Range range = get_view_range(app, view); if (post_buffer_range_to_clipboard(app, 0, buffer, range.min, range.max)){ buffer_replace_range(app, buffer, range, string_u8_litexpr("")); @@ -48,11 +43,9 @@ CUSTOM_DOC("Cut the text in the range from the cursor to the mark onto the clipb CUSTOM_COMMAND_SIG(paste) CUSTOM_DOC("At the cursor, insert the text at the top of the clipboard.") { - i32 count = 0; - clipboard_count(app, 0, &count); + i32 count = clipboard_count(app, 0); if (count > 0){ - View_ID view = 0; - get_active_view(app, AccessOpen, &view); + View_ID view = get_active_view(app, AccessOpen); if_view_has_highlighted_range_delete_range(app, view); Managed_Scope scope = 0; @@ -63,14 +56,11 @@ CUSTOM_DOC("At the cursor, insert the text at the top of the clipboard.") Scratch_Block scratch(app); - String_Const_u8 string = {}; - clipboard_index(app, 0, paste_index, scratch, &string); + String_Const_u8 string = push_clipboard_index(app, scratch, 0, paste_index); if (string.size > 0){ - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + i32 pos = view_get_cursor_pos(app, view); buffer_replace_range(app, buffer, make_range(pos), string); view_set_mark(app, view, seek_pos(pos)); view_set_cursor(app, view, seek_pos(pos + (i32)string.size), true); @@ -89,11 +79,9 @@ CUSTOM_DOC("If the previous command was paste or paste_next, replaces the paste { Scratch_Block scratch(app); - i32 count = 0; - clipboard_count(app, 0, &count); + i32 count = clipboard_count(app, 0); if (count > 0){ - View_ID view = 0; - get_active_view(app, AccessOpen, &view); + View_ID view = get_active_view(app, AccessOpen); Managed_Scope scope = 0; view_get_managed_scope(app, view, &scope); no_mark_snap_to_cursor(app, scope); @@ -107,11 +95,9 @@ CUSTOM_DOC("If the previous command was paste or paste_next, replaces the paste i32 paste_index = (i32)prev_paste_index + 1; managed_variable_set(app, scope, view_paste_index_loc, paste_index); - String_Const_u8 string = {}; - clipboard_index(app, 0, paste_index, scratch, &string); + String_Const_u8 string = push_clipboard_index(app, scratch, 0, paste_index); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); Range range = get_view_range(app, view); i32 pos = range.min; diff --git a/4coder_combined_write_commands.cpp b/4coder_combined_write_commands.cpp index 4c73fd45..9b8ad349 100644 --- a/4coder_combined_write_commands.cpp +++ b/4coder_combined_write_commands.cpp @@ -6,18 +6,15 @@ static void write_string(Application_Links *app, View_ID view, Buffer_ID buffer, String_Const_u8 string){ - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + i32 pos = view_get_cursor_pos(app, view); buffer_replace_range(app, buffer, make_range(pos), string); view_set_cursor(app, view, seek_pos(pos + (i32)string.size), 1); } static void write_string(Application_Links *app, String_Const_u8 string){ - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); write_string(app, view, buffer, string); } @@ -37,12 +34,9 @@ write_named_comment_string(Application_Links *app, char *type_string){ static void long_braces(Application_Links *app, char *text, i32 size){ - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); + i32 pos = view_get_cursor_pos(app, view); buffer_replace_range(app, buffer, make_range(pos), SCu8(text, size)); view_set_cursor(app, view, seek_pos(pos + 2), true); buffer_auto_indent(app, buffer, pos, pos + size, DEF_TAB_WIDTH, DEFAULT_INDENT_FLAGS | AutoIndent_FullTokens); @@ -111,8 +105,7 @@ CUSTOM_DOC("At the cursor, insert a ' = {};'.") static i32 get_start_of_line_at_cursor(Application_Links *app, View_ID view, Buffer_ID buffer){ - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + i32 pos = view_get_cursor_pos(app, view); i32 line = get_line_number_from_pos(app, buffer, pos); pos = get_line_side_pos(app, buffer, line, Side_Min); return(pos); @@ -133,10 +126,8 @@ c_line_comment_starts_at_position(Application_Links *app, Buffer_ID buffer, i32 CUSTOM_COMMAND_SIG(comment_line) CUSTOM_DOC("Insert '//' at the beginning of the line after leading whitespace.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); i32 pos = get_start_of_line_at_cursor(app, view, buffer); b32 alread_has_comment = c_line_comment_starts_at_position(app, buffer, pos); if (!alread_has_comment){ @@ -147,10 +138,8 @@ CUSTOM_DOC("Insert '//' at the beginning of the line after leading whitespace.") CUSTOM_COMMAND_SIG(uncomment_line) CUSTOM_DOC("If present, delete '//' at the beginning of the line after leading whitespace.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); i32 pos = get_start_of_line_at_cursor(app, view, buffer); b32 alread_has_comment = c_line_comment_starts_at_position(app, buffer, pos); if (alread_has_comment){ @@ -161,10 +150,8 @@ CUSTOM_DOC("If present, delete '//' at the beginning of the line after leading w CUSTOM_COMMAND_SIG(comment_line_toggle) CUSTOM_DOC("Turns uncommented lines into commented lines and vice versa for comments starting with '//'.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); i32 pos = get_start_of_line_at_cursor(app, view, buffer); b32 alread_has_comment = c_line_comment_starts_at_position(app, buffer, pos); if (alread_has_comment){ @@ -214,10 +201,8 @@ activate_snippet(Application_Links *app, Heap *heap, View_ID view, struct Lister if (0 <= index && index < snippets.count){ Snippet snippet = snippets.snippets[index]; lister_default(app, heap, view, state, ListerActivation_Finished); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); + i32 pos = view_get_cursor_pos(app, view); buffer_replace_range(app, buffer, make_range(pos), SCu8(snippet.text)); view_set_cursor(app, view, seek_pos(pos + snippet.cursor_offset), true); view_set_mark(app, view, seek_pos(pos + snippet.mark_offset)); @@ -231,8 +216,7 @@ activate_snippet(Application_Links *app, Heap *heap, View_ID view, struct Lister static void snippet_lister__parameterized(Application_Links *app, Snippet_Array snippet_array){ - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); view_end_ui_mode(app, view); Arena *scratch = context_get_arena(app); Temp_Memory temp = begin_temp(scratch); diff --git a/4coder_default_framework.cpp b/4coder_default_framework.cpp index 4605d49b..ad23e53e 100644 --- a/4coder_default_framework.cpp +++ b/4coder_default_framework.cpp @@ -36,8 +36,7 @@ static View_ID get_view_for_locked_jump_buffer(Application_Links *app){ View_ID view = 0; if (locked_buffer.size > 0){ - Buffer_ID buffer = 0; - get_buffer_by_name(app, locked_buffer, AccessAll, &buffer); + Buffer_ID buffer = get_buffer_by_name(app, locked_buffer, AccessAll); if (buffer != 0){ view = get_first_view_with_buffer(app, buffer); } @@ -82,8 +81,7 @@ static View_ID open_footer_panel(Application_Links *app, View_ID view){ View_ID special_view = open_view(app, view, ViewSplit_Bottom); new_view_settings(app, special_view); - Buffer_ID buffer = 0; - view_get_buffer(app, special_view, AccessAll, &buffer); + Buffer_ID buffer = view_get_buffer(app, special_view, AccessAll); Face_ID face_id = 0; get_face_id(app, buffer, &face_id); Face_Metrics metrics = {}; @@ -104,8 +102,7 @@ close_build_footer_panel(Application_Links *app){ static View_ID open_build_footer_panel(Application_Links *app){ if (build_footer_panel_view_id == 0){ - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); build_footer_panel_view_id = open_footer_panel(app, view); view_set_active(app, view); } @@ -138,8 +135,7 @@ get_prev_view_looped_primary_panels(Application_Links *app, View_ID start_view_i static View_ID get_next_view_after_active(Application_Links *app, Access_Flag access){ - View_ID view = 0; - get_active_view(app, access, &view); + View_ID view = get_active_view(app, access); if (view != 0){ view = get_next_view_looped_primary_panels(app, view, access); } @@ -159,8 +155,7 @@ view_buffer_set(Application_Links *app, Buffer_ID *buffers, i32 *positions, i32 View_ID view_id; }; - View_ID active_view_id = 0; - get_active_view(app, AccessAll, &active_view_id); + View_ID active_view_id = get_active_view(app, AccessAll); View_ID first_view_id = active_view_id; if (view_get_is_passive(app, active_view_id)){ first_view_id = get_next_view_looped_primary_panels(app, active_view_id, AccessAll); @@ -206,8 +201,7 @@ view_buffer_set(Application_Links *app, Buffer_ID *buffers, i32 *positions, i32 CUSTOM_COMMAND_SIG(change_active_panel) CUSTOM_DOC("Change the currently active panel, moving to the panel with the next highest view_id.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); view = get_next_view_looped_primary_panels(app, view, AccessAll); if (view != 0){ view_set_active(app, view); @@ -217,8 +211,7 @@ CUSTOM_DOC("Change the currently active panel, moving to the panel with the next CUSTOM_COMMAND_SIG(change_active_panel_backwards) CUSTOM_DOC("Change the currently active panel, moving to the panel with the next lowest view_id.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); view = get_prev_view_looped_primary_panels(app, view, AccessAll); if (view != 0){ view_set_active(app, view); @@ -228,24 +221,20 @@ CUSTOM_DOC("Change the currently active panel, moving to the panel with the next CUSTOM_COMMAND_SIG(open_panel_vsplit) CUSTOM_DOC("Create a new panel by vertically splitting the active panel.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); View_ID new_view = open_view(app, view, ViewSplit_Right); new_view_settings(app, new_view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessAll, &buffer); + Buffer_ID buffer = view_get_buffer(app, view, AccessAll); view_set_buffer(app, new_view, buffer, 0); } CUSTOM_COMMAND_SIG(open_panel_hsplit) CUSTOM_DOC("Create a new panel by horizontally splitting the active panel.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); View_ID new_view = open_view(app, view, ViewSplit_Bottom); new_view_settings(app, new_view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessAll, &buffer); + Buffer_ID buffer = view_get_buffer(app, view, AccessAll); view_set_buffer(app, new_view, buffer, 0); } @@ -255,8 +244,7 @@ CUSTOM_DOC("Create a new panel by horizontally splitting the active panel.") static Buffer_ID create_or_switch_to_buffer_and_clear_by_name(Application_Links *app, String_Const_u8 name_string, View_ID default_target_view){ - Buffer_ID search_buffer = 0; - get_buffer_by_name(app, name_string, AccessAll, &search_buffer); + Buffer_ID search_buffer = get_buffer_by_name(app, name_string, AccessAll); if (search_buffer != 0){ buffer_set_setting(app, search_buffer, BufferSetting_ReadOnly, true); @@ -272,14 +260,13 @@ create_or_switch_to_buffer_and_clear_by_name(Application_Links *app, String_Cons } view_set_active(app, target_view); - i32 buffer_size = 0; - buffer_get_size(app, search_buffer, &buffer_size); + i32 buffer_size = (i32)buffer_get_size(app, search_buffer); buffer_send_end_signal(app, search_buffer); buffer_replace_range(app, search_buffer, make_range(0, buffer_size), string_u8_litexpr("")); } else{ - create_buffer(app, name_string, BufferCreate_AlwaysNew, &search_buffer); + search_buffer = create_buffer(app, name_string, BufferCreate_AlwaysNew); buffer_set_setting(app, search_buffer, BufferSetting_Unimportant, true); buffer_set_setting(app, search_buffer, BufferSetting_ReadOnly, true); buffer_set_setting(app, search_buffer, BufferSetting_WrapLine, false); @@ -412,9 +399,9 @@ default_4coder_initialize(Application_Links *app, char **command_line_files, i32 Temp_Memory temp2 = begin_temp(scratch); String_Const_u8 input_name = SCu8(command_line_files[i]); String_Const_u8 file_name = push_u8_stringf(scratch, "%.*s/%.*s", string_expand(hot_directory), string_expand(input_name)); - Buffer_ID ignore = 0; - if (!create_buffer(app, file_name, BufferCreate_NeverNew|BufferCreate_MustAttachToFile, &ignore)){ - create_buffer(app, input_name, 0, &ignore); + Buffer_ID new_buffer = create_buffer(app, file_name, BufferCreate_NeverNew|BufferCreate_MustAttachToFile); + if (new_buffer == 0){ + create_buffer(app, input_name, 0); } end_temp(temp2); } @@ -444,15 +431,13 @@ default_4coder_side_by_side_panels(Application_Links *app, Buffer_Identifier lef Buffer_ID right_id = buffer_identifier_to_id(app, right_buffer); // Left Panel - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); new_view_settings(app, view); view_set_buffer(app, view, left_id, 0); // Right Panel open_panel_vsplit(app); - View_ID right_view = 0; - get_active_view(app, AccessAll, &right_view); + View_ID right_view = get_active_view(app, AccessAll); view_set_buffer(app, right_view, right_id, 0); // Restore Active to Left @@ -485,8 +470,7 @@ default_4coder_side_by_side_panels(Application_Links *app){ static void default_4coder_one_panel(Application_Links *app, Buffer_Identifier buffer){ Buffer_ID id = buffer_identifier_to_id(app, buffer); - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); new_view_settings(app, view); view_set_buffer(app, view, id, 0); } diff --git a/4coder_default_hooks.cpp b/4coder_default_hooks.cpp index 0a657a4d..f3a32eff 100644 --- a/4coder_default_hooks.cpp +++ b/4coder_default_hooks.cpp @@ -29,14 +29,12 @@ START_HOOK_SIG(default_start){ #if 0 default_4coder_one_panel(app, files, file_count); - View_ID left_view = 0; - Panel_ID left = 0; Panel_ID right = 0; Panel_ID bottom = 0; Panel_ID header = 0; - get_active_view(app, AccessAll, &left_view); + View_ID left_view = get_active_view(app, AccessAll); view_get_panel(app, left_view, &left); @@ -80,16 +78,14 @@ START_HOOK_SIG(default_start){ // NOTE(allen|a4.0.10): As of this version the word_complete command // also relies on this particular command caller hook. COMMAND_CALLER_HOOK(default_command_caller){ - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); Managed_Scope scope = 0; view_get_managed_scope(app, view, &scope); managed_variable_set(app, scope, view_next_rewrite_loc, 0); if (fcoder_mode == FCoderMode_NotepadLike){ - View_ID view_it = 0; - for (get_view_next(app, 0, AccessAll, &view_it); + for (View_ID view_it = get_view_next(app, 0, AccessAll); view_it != 0; - get_view_next(app, view_it, AccessAll, &view_it)){ + view_it = get_view_next(app, view_it, AccessAll)){ Managed_Scope scope_it = 0; view_get_managed_scope(app, view_it, &scope_it); managed_variable_set(app, scope_it, view_snap_mark_to_cursor, true); @@ -102,17 +98,15 @@ COMMAND_CALLER_HOOK(default_command_caller){ managed_variable_get(app, scope, view_next_rewrite_loc, &next_rewrite); managed_variable_set(app, scope, view_rewrite_loc, next_rewrite); if (fcoder_mode == FCoderMode_NotepadLike){ - View_ID view_it = 0; - for (get_view_next(app, 0, AccessAll, &view_it); + for (View_ID view_it = get_view_next(app, 0, AccessAll); view_it != 0; - get_view_next(app, view_it, AccessAll, &view_it)){ + view_it = get_view_next(app, view_it, AccessAll)){ Managed_Scope scope_it = 0; view_get_managed_scope(app, view_it, &scope_it); u64 val = 0; if (managed_variable_get(app, scope_it, view_snap_mark_to_cursor, &val)){ if (val != 0){ - i32 pos = 0; - view_get_cursor_pos(app, view_it, &pos); + i32 pos = view_get_cursor_pos(app, view_it); view_set_mark(app, view_it, seek_pos(pos)); } } @@ -285,8 +279,7 @@ MODIFY_COLOR_TABLE_SIG(default_modify_color_table){ } GET_VIEW_BUFFER_REGION_SIG(default_view_buffer_region){ - Buffer_ID buffer = 0; - view_get_buffer(app, view_id, AccessAll, &buffer); + Buffer_ID buffer = view_get_buffer(app, view_id, AccessAll); Face_ID face_id = 0; get_face_id(app, buffer, &face_id); Face_Metrics metrics = {}; @@ -316,8 +309,7 @@ GET_VIEW_BUFFER_REGION_SIG(default_view_buffer_region){ // line number margins if (global_config.show_line_number_margins){ - i32 line_count = 0; - buffer_get_line_count(app, buffer, &line_count); + i32 line_count = (i32)buffer_get_line_count(app, buffer); i32 line_count_digit_count = (i32)digit_count_from_integer(line_count, 10); i32 margin_width = ceil32((f32)line_count_digit_count*metrics.typical_character_width); sub_region.x0 += margin_width + 2; @@ -349,23 +341,21 @@ abs_position_from_buffer_point(Application_Links *app, View_ID view_id, Buffer_P } static void -default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View_ID view_id, Rect_i32 view_inner_rect){ - Buffer_ID buffer_id = 0; - view_get_buffer(app, view_id, AccessAll, &buffer_id); +default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View_ID view_id, Rect_f32 view_inner_rect){ + Buffer_ID buffer = view_get_buffer(app, view_id, AccessAll); Face_ID face_id = 0; - get_face_id(app, buffer_id, &face_id); + get_face_id(app, buffer, &face_id); Face_Metrics face_metrics = {}; get_face_metrics(app, face_id, &face_metrics); f32 line_height = face_metrics.line_height; - Rect_i32 sub_region = i32R(0, 0, rect_width(view_inner_rect), rect_height(view_inner_rect)); + Rect_f32 sub_region = Rf32(V2(0, 0), rect_dim(view_inner_rect)); sub_region = default_view_buffer_region(app, view_id, sub_region); - Rect_f32 buffer_rect = {}; - buffer_rect.p0 = V2(view_inner_rect.p0 + sub_region.p0); - buffer_rect.p1 = V2(view_inner_rect.p0 + sub_region.p1); - buffer_rect = intersection_of(buffer_rect, f32R(view_inner_rect)); + Rect_f32 buffer_rect = Rf32(V2(view_inner_rect.p0 + sub_region.p0), + V2(view_inner_rect.p0 + sub_region.p1)); + buffer_rect = rect_intersect(buffer_rect, view_inner_rect); GUI_Scroll_Vars scroll = {}; view_get_scroll_vars(app, view_id, &scroll); @@ -373,14 +363,13 @@ default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View Buffer_Point buffer_point = buffer_position_from_scroll_position(app, view_id, scroll.scroll_p); Text_Layout_ID text_layout_id = 0; - compute_render_layout(app, view_id, buffer_id, buffer_rect.p0, rect_dim(buffer_rect), buffer_point, + compute_render_layout(app, view_id, buffer, buffer_rect.p0, rect_dim(buffer_rect), buffer_point, max_i32, &text_layout_id); Range on_screen_range = {}; text_layout_get_on_screen_range(app, text_layout_id, &on_screen_range); text_layout_free(app, text_layout_id); - View_ID active_view = 0; - get_active_view(app, AccessAll, &active_view); + View_ID active_view = get_active_view(app, AccessAll); b32 is_active_view = (active_view == view_id); Scratch_Block scratch(app); @@ -391,8 +380,7 @@ default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View } { - Rect_f32 r_cursor = {}; - view_get_screen_rect(app, view_id, &r_cursor); + Rect_f32 r_cursor = view_get_screen_rect(app, view_id); r_cursor.p1 -= r_cursor.p0; r_cursor.p0 = V2(0.f,0.f); @@ -412,18 +400,17 @@ default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View Temp_Memory temp = begin_temp(scratch); - i32 cursor_position = 0; - view_get_cursor_pos(app, view_id, &cursor_position); + i32 cursor_position = view_get_cursor_pos(app, view_id); Full_Cursor cursor = {}; view_compute_cursor(app, view_id, seek_pos(cursor_position), &cursor); Fancy_String_List list = {}; - String_Const_u8 unique_name = push_buffer_unique_name(app, scratch, buffer_id); + String_Const_u8 unique_name = push_buffer_unique_name(app, scratch, buffer); push_fancy_string(scratch, &list, base_color, unique_name); push_fancy_stringf(scratch, &list, base_color, " - Row: %3.d Col: %3.d -", cursor.line, cursor.character); b32 is_dos_mode = false; - if (buffer_get_setting(app, buffer_id, BufferSetting_Eol, &is_dos_mode)){ + if (buffer_get_setting(app, buffer, BufferSetting_Eol, &is_dos_mode)){ if (is_dos_mode){ push_fancy_string(scratch, &list, base_color, string_u8_litexpr(" dos")); } @@ -436,8 +423,7 @@ default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View } { - Dirty_State dirty = 0; - buffer_get_dirty_state(app, buffer_id, &dirty); + Dirty_State dirty = buffer_get_dirty_state(app, buffer); u8 space[3]; String_u8 str = Su8(space, 0, 3); if (dirty != 0){ @@ -492,8 +478,7 @@ default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View // NOTE(allen): Line Numbers if (global_config.show_line_number_margins){ - i32 line_count = 0; - buffer_get_line_count(app, buffer_id, &line_count); + i32 line_count = (i32)buffer_get_line_count(app, buffer); i32 line_count_digit_count = (i32)digit_count_from_integer(line_count, 10); // TODO(allen): I need a "digit width" f32 zero = get_string_advance(app, face_id, string_u8_litexpr("0")); @@ -534,7 +519,7 @@ default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View // NOTE(allen): Scan for TODOs and NOTEs { Temp_Memory temp = begin_temp(scratch); - String_Const_u8 tail = push_buffer_range(app, scratch, buffer_id, on_screen_range); + String_Const_u8 tail = push_buffer_range(app, scratch, buffer, on_screen_range); Highlight_Record *record_first = 0; Highlight_Record *record_last = 0; @@ -589,7 +574,7 @@ default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View b32 do_emit = (i == record_count || records[i].color != current_color); if (do_emit){ i32 marker_count = marker_index - marker_index_first; - Managed_Object o = alloc_buffer_markers_on_buffer(app, buffer_id, marker_count, &render_scope); + Managed_Object o = alloc_buffer_markers_on_buffer(app, buffer, marker_count, &render_scope); managed_object_store_data(app, o, 0, marker_count, markers + marker_index_first); Marker_Visual v = create_marker_visual(app, o); marker_visual_set_effect(app, v, VisualType_CharacterHighlightRanges, SymbolicColor_Default, current_color, 0); @@ -610,12 +595,10 @@ default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View } // NOTE(allen): Cursor and mark - i32 cursor_pos = 0; - i32 mark_pos = 0; - view_get_cursor_pos(app, view_id, &cursor_pos); - view_get_mark_pos(app, view_id, &mark_pos); + i32 cursor_pos = view_get_cursor_pos(app, view_id); + i32 mark_pos = view_get_mark_pos(app, view_id); - Managed_Object cursor_and_mark = alloc_buffer_markers_on_buffer(app, buffer_id, 2, &render_scope); + Managed_Object cursor_and_mark = alloc_buffer_markers_on_buffer(app, buffer, 2, &render_scope); Marker cm_markers[2] = {}; cm_markers[0].pos = cursor_pos; cm_markers[1].pos = mark_pos; @@ -695,9 +678,9 @@ default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View Temp_Memory temp = begin_temp(scratch); Boundary_Function_List funcs = push_boundary_list(scratch, boundary_token, boundary_non_whitespace); - Range snipe_range = get_snipe_range(app, funcs, buffer_id, cursor_pos, Scan_Backward); + Range snipe_range = get_snipe_range(app, funcs, buffer, cursor_pos, Scan_Backward); if (range_size(snipe_range) > 0){ - Managed_Object token_highlight = alloc_buffer_markers_on_buffer(app, buffer_id, 2, &render_scope); + Managed_Object token_highlight = alloc_buffer_markers_on_buffer(app, buffer, 2, &render_scope); Marker range_markers[2] = {}; range_markers[0].pos = snipe_range.min; range_markers[1].pos = snipe_range.max; @@ -715,15 +698,15 @@ default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View for (u16 i = 0; i < color_count; i += 1){ colors[i] = Stag_Back_Cycle_1 + i; } - mark_enclosures(app, render_scope, buffer_id, cursor_pos, FindScope_Brace, VisualType_LineHighlightRanges, colors, 0, color_count); + mark_enclosures(app, render_scope, buffer, cursor_pos, FindScope_Brace, VisualType_LineHighlightRanges, colors, 0, color_count); } if (do_matching_paren_highlight){ i32 pos = cursor_pos; - if (buffer_get_char(app, buffer_id, pos) == '('){ + if (buffer_get_char(app, buffer, pos) == '('){ pos += 1; } else if (pos > 0){ - if (buffer_get_char(app, buffer_id, pos - 1) == ')'){ + if (buffer_get_char(app, buffer, pos - 1) == ')'){ pos -= 1; } } @@ -731,7 +714,7 @@ default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View for (u16 i = 0; i < color_count; i += 1){ colors[i] = Stag_Text_Cycle_1 + i; } - mark_enclosures(app, render_scope, buffer_id, pos, FindScope_Paren, VisualType_CharacterBlocks, 0, colors, color_count); + mark_enclosures(app, render_scope, buffer, pos, FindScope_Paren, VisualType_CharacterBlocks, 0, colors, color_count); } draw_clip_push(app, buffer_rect); @@ -750,8 +733,7 @@ default_buffer_render_caller(Application_Links *app, Frame_Info frame_info, View history_animation_dt[wrapped_index] = frame_info.animation_dt; history_frame_index[wrapped_index] = frame_info.index; - Rect_f32 hud_rect = {}; - view_get_screen_rect(app, view_id, &hud_rect); + Rect_f32 hud_rect = view_get_screen_rect(app, view_id); hud_rect.p1 -= hud_rect.p0; hud_rect.p0 = V2(0.f, 0.f); hud_rect.y0 = hud_rect.y1 - line_height*(f32)(history_depth); @@ -871,83 +853,74 @@ default_ui_render_caller(Application_Links *app, View_ID view_id, Rect_f32 rect_ } static void default_ui_render_caller(Application_Links *app, View_ID view_id, Rect_f32 rect_f32){ - Buffer_ID buffer_id = 0; - view_get_buffer(app, view_id, AccessAll, &buffer_id); + Buffer_ID buffer = view_get_buffer(app, view_id, AccessAll); Face_ID face_id = 0; - get_face_id(app, buffer_id, &face_id); + get_face_id(app, buffer, &face_id); default_ui_render_caller(app, view_id, rect_f32, face_id); } static void default_ui_render_caller(Application_Links *app, View_ID view_id, Face_ID face_id){ - Rect_f32 rect = {}; - view_get_screen_rect(app, view_id, &rect); + Rect_f32 rect = view_get_screen_rect(app, view_id); rect.p1 -= rect.p0; rect.p0 = V2(0.f,0.f); default_ui_render_caller(app, view_id, rect, face_id); } static void -default_ui_render_caller(Application_Links *app, View_ID view_id){ - Rect_f32 rect = {}; - view_get_screen_rect(app, view_id, &rect); +default_ui_render_caller(Application_Links *app, View_ID view){ + Rect_f32 rect = view_get_screen_rect(app, view); rect.p1 -= rect.p0; rect.p0 = V2(0.f,0.f); - Buffer_ID buffer_id = 0; - view_get_buffer(app, view_id, AccessAll, &buffer_id); + Buffer_ID buffer = view_get_buffer(app, view, AccessAll); Face_ID face_id = 0; - get_face_id(app, buffer_id, &face_id); - default_ui_render_caller(app, view_id, rect, face_id); + get_face_id(app, buffer, &face_id); + default_ui_render_caller(app, view, rect, face_id); } static void -default_render_view(Application_Links *app, Frame_Info frame_info, View_ID view_id, b32 is_active){ - Rect_i32 view_rect = {}; - view_get_region(app, view_id, &view_rect); - Rect_i32 inner = rect_inner(view_rect, 3); - draw_rectangle(app, f32R(view_rect), get_margin_color(is_active?UIActivation_Active:UIActivation_None)); - draw_rectangle(app, f32R(inner), Stag_Back); - draw_clip_push(app, f32R(inner)); - draw_coordinate_center_push(app, V2(inner.p0)); - if (view_is_in_ui_mode(app, view_id)){ - default_ui_render_caller(app, view_id); +default_render_view(Application_Links *app, Frame_Info frame_info, View_ID view, b32 is_active){ + Rect_f32 view_rect = view_get_screen_rect(app, view); + Rect_f32 inner = rect_inner(view_rect, 3); + draw_rectangle(app, view_rect, get_margin_color(is_active?UIActivation_Active:UIActivation_None)); + draw_rectangle(app, inner, Stag_Back); + draw_clip_push(app, inner); + draw_coordinate_center_push(app, inner.p0); + if (view_is_in_ui_mode(app, view)){ + default_ui_render_caller(app, view); } else{ - default_buffer_render_caller(app, frame_info, view_id, inner); + default_buffer_render_caller(app, frame_info, view, inner); } draw_clip_pop(app); draw_coordinate_center_pop(app); } RENDER_CALLER_SIG(default_render_caller){ - View_ID active_view_id = 0; - get_active_view(app, AccessAll, &active_view_id); - View_ID view_id = 0; - for (get_view_next(app, 0, AccessAll, &view_id); + View_ID active_view_id = get_active_view(app, AccessAll); + for (View_ID view_id = get_view_next(app, 0, AccessAll); view_id != 0; - get_view_next(app, view_id, AccessAll, &view_id)){ + view_id = get_view_next(app, view_id, AccessAll)){ default_render_view(app, frame_info, view_id, (active_view_id == view_id)); } } HOOK_SIG(default_exit){ + // If this returns zero it cancels the exit. + i32 result = 1; - // If this returns zero it cancels the exit. if (!allow_immediate_close_without_checking_for_changes){ b32 has_unsaved_changes = false; - Buffer_ID buffer = 0; - for (get_buffer_next(app, 0, AccessAll, &buffer); + for (Buffer_ID buffer = get_buffer_next(app, 0, AccessAll); buffer != 0; - get_buffer_next(app, buffer, AccessAll, &buffer)){ - Dirty_State dirty = 0; - buffer_get_dirty_state(app, buffer, &dirty); + buffer = get_buffer_next(app, buffer, AccessAll)){ + Dirty_State dirty = buffer_get_dirty_state(app, buffer); if (HasFlag(dirty, DirtyState_UnsavedChanges)){ has_unsaved_changes = true; break; } } if (has_unsaved_changes){ - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); do_gui_sure_to_close_4coder(app, view); result = 0; } @@ -959,15 +932,12 @@ HOOK_SIG(default_exit){ // TODO(allen): how to deal with multiple sizes on a single view // TODO(allen): expected character advance. HOOK_SIG(default_view_adjust){ - View_ID view = 0; - for (get_view_next(app, 0, AccessAll, &view); + for (View_ID view = get_view_next(app, 0, AccessAll); view != 0; - get_view_next(app, view, AccessAll, &view)){ - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessAll, &buffer); + view = get_view_next(app, view, AccessAll)){ + Buffer_ID buffer = view_get_buffer(app, view, AccessAll); - Rect_f32 screen_rect = {}; - view_get_screen_rect(app, view, &screen_rect); + Rect_f32 screen_rect = view_get_screen_rect(app, view); f32 view_width = rect_width(screen_rect); Face_ID face_id = 0; @@ -1111,8 +1081,7 @@ OPEN_FILE_HOOK_SIG(default_file_settings){ Temp_Memory temp = begin_temp(scratch); String_Const_u8 file_name = push_buffer_file_name(app, scratch, buffer_id); - i32 buffer_size = 0; - buffer_get_size(app, buffer_id, &buffer_size); + i32 buffer_size = (i32)buffer_get_size(app, buffer_id); if (file_name.size > 0 && buffer_size < MB(32)){ String_Const_u8 ext = string_file_extension(file_name); @@ -1242,12 +1211,11 @@ OPEN_FILE_HOOK_SIG(default_new_file){ } OPEN_FILE_HOOK_SIG(default_file_save){ - i32 is_virtual = 0; + b32 is_virtual = false; if (global_config.automatically_indent_text_on_save && buffer_get_setting(app, buffer_id, BufferSetting_VirtualWhitespace, &is_virtual)){ if (is_virtual){ - i32 buffer_size = 0; - buffer_get_size(app, buffer_id, &buffer_size); + i32 buffer_size = (i32)buffer_get_size(app, buffer_id); buffer_auto_indent(app, buffer_id, 0, buffer_size, DEF_TAB_WIDTH, DEFAULT_INDENT_FLAGS | AutoIndent_FullTokens); } } diff --git a/4coder_experiments.cpp b/4coder_experiments.cpp index f9aa502e..f40c18fc 100644 --- a/4coder_experiments.cpp +++ b/4coder_experiments.cpp @@ -21,13 +21,10 @@ get_line_y(Application_Links *app, View_ID view, i32 line){ static Rect_i32 get_line_x_rect(Application_Links *app, View_ID view){ - i32 cursor_pos = 0; - view_get_cursor_pos(app, view, &cursor_pos); + i32 cursor_pos = view_get_cursor_pos(app, view); Full_Cursor cursor = {}; view_compute_cursor(app, view, seek_pos(cursor_pos), &cursor); - - i32 mark_pos = 0; - view_get_mark_pos(app, view, &mark_pos); + i32 mark_pos = view_get_mark_pos(app, view); Full_Cursor mark = {}; view_compute_cursor(app, view, seek_pos(mark_pos), &mark); @@ -50,10 +47,8 @@ get_line_x_rect(Application_Links *app, View_ID view){ CUSTOM_COMMAND_SIG(kill_rect) CUSTOM_DOC("Delete characters in a rectangular region. Range testing is done by unwrapped-xy coordinates.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); i32_Rect rect = get_line_x_rect(app, view); @@ -72,21 +67,16 @@ CUSTOM_DOC("Delete characters in a rectangular region. Range testing is done by static void pad_buffer_line(Application_Links *app, Buffer_ID buffer, i32 line, char padchar, i32 target){ - Partial_Cursor start = {}; - Partial_Cursor end = {}; - - if (buffer_compute_cursor(app, buffer, seek_line_char(line, 1), &start)){ - if (buffer_compute_cursor(app, buffer, seek_line_char(line, 65536), &end)){ - if (start.line == line){ - if (end.character-1 < target){ - Arena *scratch = context_get_arena(app); - Temp_Memory temp = begin_temp(scratch); - i32 size = target - (end.character - 1); - char *str = push_array(scratch, char, size); - block_fill_u8(str, size, ' '); - buffer_replace_range(app, buffer, make_range(end.pos), SCu8(str, size)); - end_temp(temp); - } + Partial_Cursor start = buffer_compute_cursor(app, buffer, seek_line_char(line, 1)); + if (start.line == line){ + Partial_Cursor end = buffer_compute_cursor(app, buffer, seek_line_char(line, 65536)); + if (end.line == line){ + if (end.character - 1 < target){ + Scratch_Block scratch(app); + i32 size = target - (end.character - 1); + char *str = push_array(scratch, char, size); + block_fill_u8(str, size, ' '); + buffer_replace_range(app, buffer, make_range(end.pos), SCu8(str, size)); } } } @@ -137,17 +127,13 @@ struct Buffer_Rect{ CUSTOM_COMMAND_SIG(multi_line_edit) CUSTOM_DOC("Begin multi-line mode. In multi-line mode characters are inserted at every line between the mark and cursor. All characters are inserted at the same character offset into the line. This mode uses line_char coordinates.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); - i32 cursor_pos = 0; - view_get_cursor_pos(app, view, &cursor_pos); + i32 cursor_pos = view_get_cursor_pos(app, view); Full_Cursor cursor = {}; view_compute_cursor(app, view, seek_pos(cursor_pos), &cursor); - i32 mark_pos = 0; - view_get_mark_pos(app, view, &mark_pos); + i32 mark_pos = view_get_mark_pos(app, view); Full_Cursor mark = {}; view_compute_cursor(app, view, seek_pos(mark_pos), &mark); Buffer_Rect rect = {}; @@ -178,18 +164,17 @@ CUSTOM_DOC("Begin multi-line mode. In multi-line mode characters are inserted a if (in.key.character && key_is_unmodified(&in.key)){ char str = (char)in.key.character; - Arena *scratch = context_get_arena(app); - Temp_Memory temp = begin_temp(scratch); - Buffer_Edit *edit = push_array(scratch, Buffer_Edit, line_count); - Buffer_Edit *edits = edit; + Scratch_Block scratch(app); + Buffer_Edit *edits = push_array(scratch, Buffer_Edit, line_count); + Buffer_Edit *edit = edits; for (i32 i = rect.line0; i <= rect.line1; ++i){ - Partial_Cursor partial_cursor = {}; - if (buffer_compute_cursor(app, buffer, seek_line_char(i, pos + 1), &partial_cursor)){ + Partial_Cursor partial_cursor = buffer_compute_cursor(app, buffer, seek_line_char(i, pos + 1)); + if (partial_cursor.line > 0){ edit->str_start = 0; edit->len = 1; - edit->start = cursor.pos; - edit->end = cursor.pos; + edit->start = partial_cursor.pos; + edit->end = partial_cursor.pos; ++edit; } } @@ -197,26 +182,23 @@ CUSTOM_DOC("Begin multi-line mode. In multi-line mode characters are inserted a i32 edit_count = (int)(edit - edits); buffer_batch_edit(app, buffer, &str, edits, edit_count); - end_temp(temp); - ++pos; view_set_cursor(app, view, seek_line_char(start_line, pos + 1), true); } else if (in.key.keycode == key_back){ if (pos > 0){ - Arena *scratch = context_get_arena(app); - Temp_Memory temp = begin_temp(scratch); - Buffer_Edit *edit = push_array(scratch, Buffer_Edit, line_count); - Buffer_Edit *edits = edit; + Scratch_Block scratch(app); + Buffer_Edit *edits = push_array(scratch, Buffer_Edit, line_count); + Buffer_Edit *edit = edits; for (i32 i = rect.line0; i <= rect.line1; ++i){ - Partial_Cursor partial_cursor = {}; - if (buffer_compute_cursor(app, buffer, seek_line_char(i, pos + 1), &partial_cursor)){ + Partial_Cursor partial_cursor = buffer_compute_cursor(app, buffer, seek_line_char(i, pos + 1)); + if (partial_cursor.line > 0){ edit->str_start = 0; edit->len = 0; - edit->start = cursor.pos-1; - edit->end = cursor.pos; + edit->start = partial_cursor.pos - 1; + edit->end = partial_cursor.pos; ++edit; } } @@ -224,8 +206,6 @@ CUSTOM_DOC("Begin multi-line mode. In multi-line mode characters are inserted a i32 edit_count = (int)(edit - edits); buffer_batch_edit(app, buffer, 0, edits, edit_count); - end_temp(temp); - --pos; } } @@ -240,11 +220,9 @@ CUSTOM_DOC("Begin multi-line mode. In multi-line mode characters are inserted a CUSTOM_COMMAND_SIG(multi_paste){ Scratch_Block scratch(app); - i32 count = 0; - clipboard_count(app, 0, &count); + i32 count = clipboard_count(app, 0); if (count > 0){ - View_ID view = 0; - get_active_view(app, AccessOpen, &view); + View_ID view = get_active_view(app, AccessOpen); Managed_Scope scope = 0; view_get_managed_scope(app, view, &scope); @@ -257,13 +235,11 @@ CUSTOM_COMMAND_SIG(multi_paste){ i32 paste_index = (i32)prev_paste_index + 1; managed_variable_set(app, scope, view_paste_index_loc, paste_index); - String_Const_u8 string = {}; - clipboard_index(app, 0, paste_index, scratch, &string); + String_Const_u8 string = push_clipboard_index(app, scratch, 0, paste_index); String_Const_u8 insert_string = push_u8_stringf(scratch, "\n%.*s", string_expand(string)); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); Range range = get_view_range(app, view); buffer_replace_range(app, buffer, make_range(range.max), insert_string); view_set_mark(app, view, seek_pos(range.max + 1)); @@ -287,8 +263,8 @@ multi_paste_range(Application_Links *app, View_ID view, Range range, i32 paste_c Range finish_range = range; if (paste_count >= 1){ - Buffer_ID buffer = 0; - if (view_get_buffer(app, view, AccessOpen, &buffer)){ + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); + if (buffer != 0){ i32 total_size = 0; for (i32 paste_index = 0; paste_index < paste_count; ++paste_index){ total_size += 1 + clipboard_index(app, 0, paste_index, 0, 0); @@ -311,8 +287,8 @@ multi_paste_range(Application_Links *app, View_ID view, Range range, i32 paste_c if (paste_index != first){ string_list_push(scratch, &list, SCu8("\n", 1)); } - String_Const_u8 string = {}; - if (clipboard_index(app, 0, paste_index, scratch, &string)){ + String_Const_u8 string = push_clipboard_index(app, scratch, 0, paste_index); + if (string.size > 0){ string_list_push(scratch, &list, string); } } @@ -339,10 +315,8 @@ multi_paste_range(Application_Links *app, View_ID view, Range range, i32 paste_c static void multi_paste_interactive_up_down(Application_Links *app, i32 paste_count, i32 clip_count){ - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + View_ID view = get_active_view(app, AccessOpen); + i32 pos = view_get_cursor_pos(app, view); Range range = make_range(pos);; @@ -386,23 +360,20 @@ multi_paste_interactive_up_down(Application_Links *app, i32 paste_count, i32 cli } if (in.abort){ - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); buffer_replace_range(app, buffer, range, SCu8("")); } } CUSTOM_COMMAND_SIG(multi_paste_interactive){ - i32 clip_count = 0; - clipboard_count(app, 0, &clip_count); + i32 clip_count = clipboard_count(app, 0); if (clip_count > 0){ multi_paste_interactive_up_down(app, 1, clip_count); } } CUSTOM_COMMAND_SIG(multi_paste_interactive_quick){ - i32 clip_count = 0; - clipboard_count(app, 0, &clip_count); + i32 clip_count = clipboard_count(app, 0); if (clip_count > 0){ u8 string_space[256]; Query_Bar bar = {}; @@ -424,19 +395,17 @@ CUSTOM_COMMAND_SIG(multi_paste_interactive_quick){ CUSTOM_COMMAND_SIG(rename_parameter) CUSTOM_DOC("If the cursor is found to be on the name of a function parameter in the signature of a function definition, all occurences within the scope of the function will be replaced with a new provided string.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); - i32 cursor_pos = 0; - view_get_cursor_pos(app, view, &cursor_pos); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); + i32 cursor_pos = view_get_cursor_pos(app, view); Arena *scratch = context_get_arena(app); Temp_Memory temp = begin_temp(scratch); - Cpp_Get_Token_Result result; - if (buffer_get_token_index(app, buffer, cursor_pos, &result)){ + Cpp_Get_Token_Result result = {}; + if (get_token_from_pos(app, buffer, cursor_pos, &result)){ if (!result.in_whitespace_after_token){ +#if 0 static const i32 stream_space_size = 512; Cpp_Token stream_space[stream_space_size]; Stream_Tokens_DEP stream = {}; @@ -557,6 +526,7 @@ CUSTOM_DOC("If the cursor is found to be on the name of a function parameter in } } } +#endif } } @@ -571,20 +541,18 @@ enum{ static void write_explicit_enum_values_parameters(Application_Links *app, Write_Explicit_Enum_Values_Mode mode){ - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + i32 pos = view_get_cursor_pos(app, view); Arena *scratch = context_get_arena(app); Temp_Memory temp = begin_temp(scratch); - Cpp_Get_Token_Result result; - if (buffer_get_token_index(app, buffer, pos, &result)){ + Cpp_Get_Token_Result result = {}; + if (get_token_from_pos(app, buffer, pos, &result)){ if (!result.in_whitespace_after_token){ +#if 0 Cpp_Token stream_space[32]; Stream_Tokens_DEP stream = {}; @@ -724,6 +692,7 @@ write_explicit_enum_values_parameters(Application_Links *app, Write_Explicit_Enu } } } +#endif } } diff --git a/4coder_function_list.cpp b/4coder_function_list.cpp index 56b8f9b6..8f405223 100644 --- a/4coder_function_list.cpp +++ b/4coder_function_list.cpp @@ -202,18 +202,16 @@ static void list_all_functions(Application_Links *app, Buffer_ID optional_target_buffer){ // TODO(allen): Use create or switch to buffer and clear here? String_Const_u8 decls_name = string_u8_litexpr("*decls*"); - Buffer_ID decls_buffer = 0; - get_buffer_by_name(app, decls_name, AccessAll, &decls_buffer); + Buffer_ID decls_buffer = get_buffer_by_name(app, decls_name, AccessAll); if (!buffer_exists(app, decls_buffer)){ - create_buffer(app, decls_name, BufferCreate_AlwaysNew, &decls_buffer); + decls_buffer = create_buffer(app, decls_name, BufferCreate_AlwaysNew); buffer_set_setting(app, decls_buffer, BufferSetting_Unimportant, true); buffer_set_setting(app, decls_buffer, BufferSetting_ReadOnly, true); buffer_set_setting(app, decls_buffer, BufferSetting_WrapLine, false); } else{ buffer_send_end_signal(app, decls_buffer); - i32 size = 0; - buffer_get_size(app, decls_buffer, &size); + i32 size = (i32)buffer_get_size(app, decls_buffer); buffer_replace_range(app, decls_buffer, make_range(0, size), string_u8_litexpr("")); } @@ -227,10 +225,9 @@ list_all_functions(Application_Links *app, Buffer_ID optional_target_buffer){ Cursor insertion_cursor = make_cursor(push_array(scratch, u8, KB(256)), KB(256)); Buffer_Insertion out = begin_buffer_insertion_at_buffered(app, decls_buffer, 0, &insertion_cursor); - Buffer_ID buffer_it = 0; - for (get_buffer_next(app, 0, AccessAll, &buffer_it); + for (Buffer_ID buffer_it = get_buffer_next(app, 0, AccessAll); buffer_it != 0; - get_buffer_next(app, buffer_it, AccessAll, &buffer_it)){ + buffer_it = get_buffer_next(app, buffer_it, AccessAll)){ Buffer_ID buffer = buffer_it; if (optional_target_buffer != 0){ buffer = optional_target_buffer; @@ -260,8 +257,7 @@ list_all_functions(Application_Links *app, Buffer_ID optional_target_buffer){ end_buffer_insertion(&out); - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); view_set_buffer(app, view, decls_buffer, 0); lock_jump_buffer(decls_name); @@ -273,11 +269,9 @@ list_all_functions(Application_Links *app, Buffer_ID optional_target_buffer){ CUSTOM_COMMAND_SIG(list_all_functions_current_buffer) CUSTOM_DOC("Creates a jump list of lines of the current buffer that appear to define or declare functions.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessProtected, &buffer); - if (buffer_exists(app, buffer)){ + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer = view_get_buffer(app, view, AccessProtected); + if (buffer != 0){ list_all_functions(app, buffer); } } @@ -285,13 +279,11 @@ CUSTOM_DOC("Creates a jump list of lines of the current buffer that appear to de CUSTOM_COMMAND_SIG(list_all_functions_current_buffer_lister) CUSTOM_DOC("Creates a lister of locations that look like function definitions and declarations in the buffer.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessProtected, &buffer); - if (buffer_exists(app, buffer)){ + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer = view_get_buffer(app, view, AccessProtected); + if (buffer != 0){ list_all_functions(app, buffer); - get_active_view(app, AccessAll, &view); + view = get_active_view(app, AccessAll); open_jump_lister(app, &global_heap, view, buffer, JumpListerActivation_OpenInUIView, 0); } } @@ -306,10 +298,8 @@ CUSTOM_COMMAND_SIG(list_all_functions_all_buffers_lister) CUSTOM_DOC("Creates a lister of locations that look like function definitions and declarations all buffers.") { list_all_functions(app, 0); - View_ID view = 0; - get_active_view(app, AccessAll, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessAll, &buffer); + View_ID view = get_active_view(app, AccessAll); + Buffer_ID buffer = view_get_buffer(app, view, AccessAll); open_jump_lister(app, &global_heap, view, buffer, JumpListerActivation_OpenInUIView, 0); } diff --git a/4coder_generated/app_functions.h b/4coder_generated/app_functions.h index 3fd2ee31..ed03b1fd 100644 --- a/4coder_generated/app_functions.h +++ b/4coder_generated/app_functions.h @@ -1,76 +1,72 @@ struct Application_Links; #define GLOBAL_SET_SETTING_SIG(n) b32 n(Application_Links *app, Global_Setting_ID setting, i32 value) #define GLOBAL_SET_MAPPING_SIG(n) b32 n(Application_Links *app, void *data, i32 size) -#define GLOBAL_GET_SCREEN_RECTANGLE_SIG(n) b32 n(Application_Links *app, Rect_f32 *rect_out) +#define GLOBAL_GET_SCREEN_RECTANGLE_SIG(n) Rect_f32 n(Application_Links *app) #define CONTEXT_GET_ARENA_SIG(n) Arena* n(Application_Links *app) #define CONTEXT_GET_BASE_ALLOCATOR_SIG(n) Base_Allocator* n(Application_Links *app) #define CREATE_CHILD_PROCESS_SIG(n) b32 n(Application_Links *app, String_Const_u8 path, String_Const_u8 command, Child_Process_ID *child_process_id_out) #define CHILD_PROCESS_SET_TARGET_BUFFER_SIG(n) b32 n(Application_Links *app, Child_Process_ID child_process_id, Buffer_ID buffer_id, Child_Process_Set_Target_Flags flags) -#define BUFFER_GET_ATTACHED_CHILD_PROCESS_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Child_Process_ID *child_process_id_out) -#define CHILD_PROCESS_GET_ATTACHED_BUFFER_SIG(n) b32 n(Application_Links *app, Child_Process_ID child_process_id, Buffer_ID *buffer_id_out) -#define CHILD_PROCESS_GET_STATE_SIG(n) b32 n(Application_Links *app, Child_Process_ID child_process_id, Process_State *process_state_out) +#define BUFFER_GET_ATTACHED_CHILD_PROCESS_SIG(n) Child_Process_ID n(Application_Links *app, Buffer_ID buffer_id) +#define CHILD_PROCESS_GET_ATTACHED_BUFFER_SIG(n) Buffer_ID n(Application_Links *app, Child_Process_ID child_process_id) +#define CHILD_PROCESS_GET_STATE_SIG(n) Process_State n(Application_Links *app, Child_Process_ID child_process_id) #define CLIPBOARD_POST_SIG(n) b32 n(Application_Links *app, i32 clipboard_id, String_Const_u8 string) -#define CLIPBOARD_COUNT_SIG(n) b32 n(Application_Links *app, i32 clipboard_id, i32 *count_out) -#define CLIPBOARD_INDEX_SIG(n) b32 n(Application_Links *app, i32 clipboard_id, i32 item_index, Arena *out, String_Const_u8 *string_out) +#define CLIPBOARD_COUNT_SIG(n) i32 n(Application_Links *app, i32 clipboard_id) +#define PUSH_CLIPBOARD_INDEX_SIG(n) String_Const_u8 n(Application_Links *app, Arena *arena, i32 clipboard_id, i32 item_index) #define CREATE_PARSE_CONTEXT_SIG(n) Parse_Context_ID n(Application_Links *app, Parser_String_And_Type *kw, u32 kw_count, Parser_String_And_Type *pp, u32 pp_count) #define GET_BUFFER_COUNT_SIG(n) i32 n(Application_Links *app) -#define GET_BUFFER_NEXT_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Access_Flag access, Buffer_ID *buffer_id_out) -#define GET_BUFFER_BY_NAME_SIG(n) b32 n(Application_Links *app, String_Const_u8 name, Access_Flag access, Buffer_ID *buffer_id_out) -#define GET_BUFFER_BY_FILE_NAME_SIG(n) b32 n(Application_Links *app, String_Const_u8 file_name, Access_Flag access, Buffer_ID *buffer_id_out) +#define GET_BUFFER_NEXT_SIG(n) Buffer_ID n(Application_Links *app, Buffer_ID buffer_id, Access_Flag access) +#define GET_BUFFER_BY_NAME_SIG(n) Buffer_ID n(Application_Links *app, String_Const_u8 name, Access_Flag access) +#define GET_BUFFER_BY_FILE_NAME_SIG(n) Buffer_ID n(Application_Links *app, String_Const_u8 file_name, Access_Flag access) #define BUFFER_READ_RANGE_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, i32 start, i32 one_past_last, char *out) #define BUFFER_REPLACE_RANGE_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Range range, String_Const_u8 string) #define BUFFER_BATCH_EDIT_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, char *str, Buffer_Edit *edits, i32 edit_count) -#define BUFFER_SEEK_STRING_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer, String_Const_u8 needle, Scan_Direction direction, i32 start_pos, i32 *pos_out, b32 *case_sensitive_out) +#define BUFFER_SEEK_STRING_SIG(n) String_Match n(Application_Links *app, Buffer_ID buffer, String_Const_u8 needle, Scan_Direction direction, i32 start_pos) #define BUFFER_SEEK_CHARACTER_CLASS_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Character_Predicate *predicate, Scan_Direction direction, i32 start_pos, i32 *pos_out) -#define BUFFER_COMPUTE_CURSOR_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Buffer_Seek seek, Partial_Cursor *cursor_out) +#define BUFFER_COMPUTE_CURSOR_SIG(n) Partial_Cursor n(Application_Links *app, Buffer_ID buffer_id, Buffer_Seek seek) #define BUFFER_EXISTS_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id) #define BUFFER_READY_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id) -#define BUFFER_GET_ACCESS_FLAGS_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Access_Flag *access_flags_out) -#define BUFFER_GET_SIZE_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, i32 *size_out) -#define BUFFER_GET_LINE_COUNT_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, i32 *line_count_out) -#define BUFFER_GET_BASE_BUFFER_NAME_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Arena *out, String_Const_u8 *name_out) -#define BUFFER_GET_UNIQUE_BUFFER_NAME_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Arena *out, String_Const_u8 *name_out) -#define BUFFER_GET_FILE_NAME_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Arena *out, String_Const_u8 *name_out) -#define BUFFER_GET_DIRTY_STATE_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Dirty_State *dirty_state_out) -#define BUFFER_DIRECTLY_SET_DIRTY_STATE_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Dirty_State dirty_state) +#define BUFFER_GET_ACCESS_FLAGS_SIG(n) Access_Flag n(Application_Links *app, Buffer_ID buffer_id) +#define BUFFER_GET_SIZE_SIG(n) u64 n(Application_Links *app, Buffer_ID buffer_id) +#define BUFFER_GET_LINE_COUNT_SIG(n) u64 n(Application_Links *app, Buffer_ID buffer_id) +#define PUSH_BUFFER_BASE_NAME_SIG(n) String_Const_u8 n(Application_Links *app, Arena *arena, Buffer_ID buffer_id) +#define PUSH_BUFFER_UNIQUE_NAME_SIG(n) String_Const_u8 n(Application_Links *app, Arena *out, Buffer_ID buffer_id) +#define PUSH_BUFFER_FILE_NAME_SIG(n) String_Const_u8 n(Application_Links *app, Arena *arena, Buffer_ID buffer_id) +#define BUFFER_GET_DIRTY_STATE_SIG(n) Dirty_State n(Application_Links *app, Buffer_ID buffer_id) +#define BUFFER_SET_DIRTY_STATE_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Dirty_State dirty_state) #define BUFFER_TOKENS_ARE_READY_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id) #define BUFFER_GET_SETTING_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Buffer_Setting_ID setting, i32 *value_out) #define BUFFER_SET_SETTING_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Buffer_Setting_ID setting, i32 value) -#define BUFFER_GET_MANAGED_SCOPE_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Managed_Scope *scope_out) -#define BUFFER_TOKEN_COUNT_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, i32 *count_out) -#define BUFFER_READ_TOKENS_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, i32 start_token, i32 end_token, Cpp_Token *tokens_out) -#define BUFFER_GET_TOKEN_RANGE_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Cpp_Token **first_token_out, Cpp_Token **one_past_last_token_out) -#define BUFFER_GET_TOKEN_INDEX_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, i32 pos, Cpp_Get_Token_Result *get_result) +#define BUFFER_GET_MANAGED_SCOPE_SIG(n) Managed_Scope n(Application_Links *app, Buffer_ID buffer_id) +#define BUFFER_GET_TOKEN_ARRAY_SIG(n) Cpp_Token_Array n(Application_Links *app, Buffer_ID buffer_id) #define BUFFER_SEND_END_SIGNAL_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id) -#define CREATE_BUFFER_SIG(n) b32 n(Application_Links *app, String_Const_u8 file_name, Buffer_Create_Flag flags, Buffer_ID *new_buffer_id_out) -#define BUFFER_SAVE_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, String_Const_u8 file_name, u32 flags) -#define BUFFER_KILL_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Buffer_Kill_Flag flags, Buffer_Kill_Result *result_out) -#define BUFFER_REOPEN_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, Buffer_Reopen_Flag flags, Buffer_Reopen_Result *result_out) -#define BUFFER_GET_FILE_ATTRIBUTES_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, File_Attributes *attributes_out) -#define GET_VIEW_NEXT_SIG(n) b32 n(Application_Links *app, View_ID view_id, Access_Flag access, View_ID *view_id_out) -#define GET_VIEW_PREV_SIG(n) b32 n(Application_Links *app, View_ID view_id, Access_Flag access, View_ID *view_id_out) -#define GET_ACTIVE_VIEW_SIG(n) b32 n(Application_Links *app, Access_Flag access, View_ID *view_id_out) -#define GET_ACTIVE_PANEL_SIG(n) b32 n(Application_Links *app, Panel_ID *panel_id_out) +#define CREATE_BUFFER_SIG(n) Buffer_ID n(Application_Links *app, String_Const_u8 file_name, Buffer_Create_Flag flags) +#define BUFFER_SAVE_SIG(n) b32 n(Application_Links *app, Buffer_ID buffer_id, String_Const_u8 file_name, Buffer_Save_Flag flags) +#define BUFFER_KILL_SIG(n) Buffer_Kill_Result n(Application_Links *app, Buffer_ID buffer_id, Buffer_Kill_Flag flags) +#define BUFFER_REOPEN_SIG(n) Buffer_Reopen_Result n(Application_Links *app, Buffer_ID buffer_id, Buffer_Reopen_Flag flags) +#define BUFFER_GET_FILE_ATTRIBUTES_SIG(n) File_Attributes n(Application_Links *app, Buffer_ID buffer_id) +#define GET_VIEW_NEXT_SIG(n) View_ID n(Application_Links *app, View_ID view_id, Access_Flag access) +#define GET_VIEW_PREV_SIG(n) View_ID n(Application_Links *app, View_ID view_id, Access_Flag access) +#define GET_ACTIVE_VIEW_SIG(n) View_ID n(Application_Links *app, Access_Flag access) +#define GET_ACTIVE_PANEL_SIG(n) Panel_ID n(Application_Links *app) #define VIEW_EXISTS_SIG(n) b32 n(Application_Links *app, View_ID view_id) -#define VIEW_GET_BUFFER_SIG(n) b32 n(Application_Links *app, View_ID view_id, Access_Flag access, Buffer_ID *buffer_id_out) -#define VIEW_GET_CURSOR_POS_SIG(n) b32 n(Application_Links *app, View_ID view_id, i32 *pos_out) -#define VIEW_GET_MARK_POS_SIG(n) b32 n(Application_Links *app, View_ID view_id, i32 *pos_out) -#define VIEW_GET_PREFERRED_X_SIG(n) b32 n(Application_Links *app, View_ID view_id, f32 *preferred_x_out) -#define VIEW_GET_SCREEN_RECT_SIG(n) b32 n(Application_Links *app, View_ID view_id, Rect_f32 *rect_out) -#define VIEW_GET_PANEL_SIG(n) b32 n(Application_Links *app, View_ID view_id, Panel_ID *panel_id_out) -#define PANEL_GET_VIEW_SIG(n) b32 n(Application_Links *app, Panel_ID panel_id, View_ID *view_id_out) +#define VIEW_GET_BUFFER_SIG(n) Buffer_ID n(Application_Links *app, View_ID view_id, Access_Flag access) +#define VIEW_GET_CURSOR_POS_SIG(n) i32 n(Application_Links *app, View_ID view_id) +#define VIEW_GET_MARK_POS_SIG(n) i32 n(Application_Links *app, View_ID view_id) +#define VIEW_GET_PREFERRED_X_SIG(n) f32 n(Application_Links *app, View_ID view_id) +#define VIEW_GET_SCREEN_RECT_SIG(n) Rect_f32 n(Application_Links *app, View_ID view_id) +#define VIEW_GET_PANEL_SIG(n) Panel_ID n(Application_Links *app, View_ID view_id) +#define PANEL_GET_VIEW_SIG(n) View_ID n(Application_Links *app, Panel_ID panel_id) #define PANEL_IS_SPLIT_SIG(n) b32 n(Application_Links *app, Panel_ID panel_id) #define PANEL_IS_LEAF_SIG(n) b32 n(Application_Links *app, Panel_ID panel_id) #define PANEL_SPLIT_SIG(n) b32 n(Application_Links *app, Panel_ID panel_id, Panel_Split_Orientation orientation) #define PANEL_SET_SPLIT_SIG(n) b32 n(Application_Links *app, Panel_ID panel_id, Panel_Split_Kind kind, float t) #define PANEL_SWAP_CHILDREN_SIG(n) b32 n(Application_Links *app, Panel_ID panel_id, Panel_Split_Kind kind, float t) -#define PANEL_GET_PARENT_SIG(n) b32 n(Application_Links *app, Panel_ID panel_id, Panel_ID *panel_id_out) -#define PANEL_GET_CHILD_SIG(n) b32 n(Application_Links *app, Panel_ID panel_id, Panel_Child which_child, Panel_ID *panel_id_out) -#define PANEL_GET_MAX_SIG(n) b32 n(Application_Links *app, Panel_ID panel_id, Panel_ID *panel_id_out) -#define PANEL_GET_MARGIN_SIG(n) b32 n(Application_Links *app, Panel_ID panel_id, i32_Rect *margins_out) +#define PANEL_GET_PARENT_SIG(n) Panel_ID n(Application_Links *app, Panel_ID panel_id) +#define PANEL_GET_CHILD_SIG(n) Panel_ID n(Application_Links *app, Panel_ID panel_id, Panel_Child which_child) +#define PANEL_GET_MAX_SIG(n) Panel_ID n(Application_Links *app, Panel_ID panel_id) +#define PANEL_GET_MARGIN_SIG(n) Rect_i32 n(Application_Links *app, Panel_ID panel_id) #define VIEW_CLOSE_SIG(n) b32 n(Application_Links *app, View_ID view_id) -#define VIEW_GET_REGION_SIG(n) b32 n(Application_Links *app, View_ID view_id, Rect_i32 *region_out) -#define VIEW_GET_BUFFER_REGION_SIG(n) b32 n(Application_Links *app, View_ID view_id, Rect_i32 *region_out) +#define VIEW_GET_BUFFER_REGION_SIG(n) Rect_f32 n(Application_Links *app, View_ID view_id) #define VIEW_GET_SCROLL_VARS_SIG(n) b32 n(Application_Links *app, View_ID view_id, GUI_Scroll_Vars *scroll_vars_out) #define VIEW_SET_ACTIVE_SIG(n) b32 n(Application_Links *app, View_ID view_id) #define VIEW_GET_SETTING_SIG(n) b32 n(Application_Links *app, View_ID view_id, View_Setting_ID setting, i32 *value_out) @@ -196,7 +192,7 @@ typedef CHILD_PROCESS_GET_ATTACHED_BUFFER_SIG(Child_Process_Get_Attached_Buffer_ typedef CHILD_PROCESS_GET_STATE_SIG(Child_Process_Get_State_Function); typedef CLIPBOARD_POST_SIG(Clipboard_Post_Function); typedef CLIPBOARD_COUNT_SIG(Clipboard_Count_Function); -typedef CLIPBOARD_INDEX_SIG(Clipboard_Index_Function); +typedef PUSH_CLIPBOARD_INDEX_SIG(Push_Clipboard_Index_Function); typedef CREATE_PARSE_CONTEXT_SIG(Create_Parse_Context_Function); typedef GET_BUFFER_COUNT_SIG(Get_Buffer_Count_Function); typedef GET_BUFFER_NEXT_SIG(Get_Buffer_Next_Function); @@ -213,19 +209,16 @@ typedef BUFFER_READY_SIG(Buffer_Ready_Function); typedef BUFFER_GET_ACCESS_FLAGS_SIG(Buffer_Get_Access_Flags_Function); typedef BUFFER_GET_SIZE_SIG(Buffer_Get_Size_Function); typedef BUFFER_GET_LINE_COUNT_SIG(Buffer_Get_Line_Count_Function); -typedef BUFFER_GET_BASE_BUFFER_NAME_SIG(Buffer_Get_Base_Buffer_Name_Function); -typedef BUFFER_GET_UNIQUE_BUFFER_NAME_SIG(Buffer_Get_Unique_Buffer_Name_Function); -typedef BUFFER_GET_FILE_NAME_SIG(Buffer_Get_File_Name_Function); +typedef PUSH_BUFFER_BASE_NAME_SIG(Push_Buffer_Base_Name_Function); +typedef PUSH_BUFFER_UNIQUE_NAME_SIG(Push_Buffer_Unique_Name_Function); +typedef PUSH_BUFFER_FILE_NAME_SIG(Push_Buffer_File_Name_Function); typedef BUFFER_GET_DIRTY_STATE_SIG(Buffer_Get_Dirty_State_Function); -typedef BUFFER_DIRECTLY_SET_DIRTY_STATE_SIG(Buffer_Directly_Set_Dirty_State_Function); +typedef BUFFER_SET_DIRTY_STATE_SIG(Buffer_Set_Dirty_State_Function); typedef BUFFER_TOKENS_ARE_READY_SIG(Buffer_Tokens_Are_Ready_Function); typedef BUFFER_GET_SETTING_SIG(Buffer_Get_Setting_Function); typedef BUFFER_SET_SETTING_SIG(Buffer_Set_Setting_Function); typedef BUFFER_GET_MANAGED_SCOPE_SIG(Buffer_Get_Managed_Scope_Function); -typedef BUFFER_TOKEN_COUNT_SIG(Buffer_Token_Count_Function); -typedef BUFFER_READ_TOKENS_SIG(Buffer_Read_Tokens_Function); -typedef BUFFER_GET_TOKEN_RANGE_SIG(Buffer_Get_Token_Range_Function); -typedef BUFFER_GET_TOKEN_INDEX_SIG(Buffer_Get_Token_Index_Function); +typedef BUFFER_GET_TOKEN_ARRAY_SIG(Buffer_Get_Token_Array_Function); typedef BUFFER_SEND_END_SIGNAL_SIG(Buffer_Send_End_Signal_Function); typedef CREATE_BUFFER_SIG(Create_Buffer_Function); typedef BUFFER_SAVE_SIG(Buffer_Save_Function); @@ -254,7 +247,6 @@ typedef PANEL_GET_CHILD_SIG(Panel_Get_Child_Function); typedef PANEL_GET_MAX_SIG(Panel_Get_Max_Function); typedef PANEL_GET_MARGIN_SIG(Panel_Get_Margin_Function); typedef VIEW_CLOSE_SIG(View_Close_Function); -typedef VIEW_GET_REGION_SIG(View_Get_Region_Function); typedef VIEW_GET_BUFFER_REGION_SIG(View_Get_Buffer_Region_Function); typedef VIEW_GET_SCROLL_VARS_SIG(View_Get_Scroll_Vars_Function); typedef VIEW_SET_ACTIVE_SIG(View_Set_Active_Function); @@ -383,7 +375,7 @@ Child_Process_Get_Attached_Buffer_Function *child_process_get_attached_buffer; Child_Process_Get_State_Function *child_process_get_state; Clipboard_Post_Function *clipboard_post; Clipboard_Count_Function *clipboard_count; -Clipboard_Index_Function *clipboard_index; +Push_Clipboard_Index_Function *push_clipboard_index; Create_Parse_Context_Function *create_parse_context; Get_Buffer_Count_Function *get_buffer_count; Get_Buffer_Next_Function *get_buffer_next; @@ -400,19 +392,16 @@ Buffer_Ready_Function *buffer_ready; Buffer_Get_Access_Flags_Function *buffer_get_access_flags; Buffer_Get_Size_Function *buffer_get_size; Buffer_Get_Line_Count_Function *buffer_get_line_count; -Buffer_Get_Base_Buffer_Name_Function *buffer_get_base_buffer_name; -Buffer_Get_Unique_Buffer_Name_Function *buffer_get_unique_buffer_name; -Buffer_Get_File_Name_Function *buffer_get_file_name; +Push_Buffer_Base_Name_Function *push_buffer_base_name; +Push_Buffer_Unique_Name_Function *push_buffer_unique_name; +Push_Buffer_File_Name_Function *push_buffer_file_name; Buffer_Get_Dirty_State_Function *buffer_get_dirty_state; -Buffer_Directly_Set_Dirty_State_Function *buffer_directly_set_dirty_state; +Buffer_Set_Dirty_State_Function *buffer_set_dirty_state; Buffer_Tokens_Are_Ready_Function *buffer_tokens_are_ready; Buffer_Get_Setting_Function *buffer_get_setting; Buffer_Set_Setting_Function *buffer_set_setting; Buffer_Get_Managed_Scope_Function *buffer_get_managed_scope; -Buffer_Token_Count_Function *buffer_token_count; -Buffer_Read_Tokens_Function *buffer_read_tokens; -Buffer_Get_Token_Range_Function *buffer_get_token_range; -Buffer_Get_Token_Index_Function *buffer_get_token_index; +Buffer_Get_Token_Array_Function *buffer_get_token_array; Buffer_Send_End_Signal_Function *buffer_send_end_signal; Create_Buffer_Function *create_buffer; Buffer_Save_Function *buffer_save; @@ -441,7 +430,6 @@ Panel_Get_Child_Function *panel_get_child; Panel_Get_Max_Function *panel_get_max; Panel_Get_Margin_Function *panel_get_margin; View_Close_Function *view_close; -View_Get_Region_Function *view_get_region; View_Get_Buffer_Region_Function *view_get_buffer_region; View_Get_Scroll_Vars_Function *view_get_scroll_vars; View_Set_Active_Function *view_set_active; @@ -569,7 +557,7 @@ Child_Process_Get_Attached_Buffer_Function *child_process_get_attached_buffer_; Child_Process_Get_State_Function *child_process_get_state_; Clipboard_Post_Function *clipboard_post_; Clipboard_Count_Function *clipboard_count_; -Clipboard_Index_Function *clipboard_index_; +Push_Clipboard_Index_Function *push_clipboard_index_; Create_Parse_Context_Function *create_parse_context_; Get_Buffer_Count_Function *get_buffer_count_; Get_Buffer_Next_Function *get_buffer_next_; @@ -586,19 +574,16 @@ Buffer_Ready_Function *buffer_ready_; Buffer_Get_Access_Flags_Function *buffer_get_access_flags_; Buffer_Get_Size_Function *buffer_get_size_; Buffer_Get_Line_Count_Function *buffer_get_line_count_; -Buffer_Get_Base_Buffer_Name_Function *buffer_get_base_buffer_name_; -Buffer_Get_Unique_Buffer_Name_Function *buffer_get_unique_buffer_name_; -Buffer_Get_File_Name_Function *buffer_get_file_name_; +Push_Buffer_Base_Name_Function *push_buffer_base_name_; +Push_Buffer_Unique_Name_Function *push_buffer_unique_name_; +Push_Buffer_File_Name_Function *push_buffer_file_name_; Buffer_Get_Dirty_State_Function *buffer_get_dirty_state_; -Buffer_Directly_Set_Dirty_State_Function *buffer_directly_set_dirty_state_; +Buffer_Set_Dirty_State_Function *buffer_set_dirty_state_; Buffer_Tokens_Are_Ready_Function *buffer_tokens_are_ready_; Buffer_Get_Setting_Function *buffer_get_setting_; Buffer_Set_Setting_Function *buffer_set_setting_; Buffer_Get_Managed_Scope_Function *buffer_get_managed_scope_; -Buffer_Token_Count_Function *buffer_token_count_; -Buffer_Read_Tokens_Function *buffer_read_tokens_; -Buffer_Get_Token_Range_Function *buffer_get_token_range_; -Buffer_Get_Token_Index_Function *buffer_get_token_index_; +Buffer_Get_Token_Array_Function *buffer_get_token_array_; Buffer_Send_End_Signal_Function *buffer_send_end_signal_; Create_Buffer_Function *create_buffer_; Buffer_Save_Function *buffer_save_; @@ -627,7 +612,6 @@ Panel_Get_Child_Function *panel_get_child_; Panel_Get_Max_Function *panel_get_max_; Panel_Get_Margin_Function *panel_get_margin_; View_Close_Function *view_close_; -View_Get_Region_Function *view_get_region_; View_Get_Buffer_Region_Function *view_get_buffer_region_; View_Get_Scroll_Vars_Function *view_get_scroll_vars_; View_Set_Active_Function *view_set_active_; @@ -763,7 +747,7 @@ app_links->child_process_get_attached_buffer_ = Child_Process_Get_Attached_Buffe app_links->child_process_get_state_ = Child_Process_Get_State;\ app_links->clipboard_post_ = Clipboard_Post;\ app_links->clipboard_count_ = Clipboard_Count;\ -app_links->clipboard_index_ = Clipboard_Index;\ +app_links->push_clipboard_index_ = Push_Clipboard_Index;\ app_links->create_parse_context_ = Create_Parse_Context;\ app_links->get_buffer_count_ = Get_Buffer_Count;\ app_links->get_buffer_next_ = Get_Buffer_Next;\ @@ -780,19 +764,16 @@ app_links->buffer_ready_ = Buffer_Ready;\ app_links->buffer_get_access_flags_ = Buffer_Get_Access_Flags;\ app_links->buffer_get_size_ = Buffer_Get_Size;\ app_links->buffer_get_line_count_ = Buffer_Get_Line_Count;\ -app_links->buffer_get_base_buffer_name_ = Buffer_Get_Base_Buffer_Name;\ -app_links->buffer_get_unique_buffer_name_ = Buffer_Get_Unique_Buffer_Name;\ -app_links->buffer_get_file_name_ = Buffer_Get_File_Name;\ +app_links->push_buffer_base_name_ = Push_Buffer_Base_Name;\ +app_links->push_buffer_unique_name_ = Push_Buffer_Unique_Name;\ +app_links->push_buffer_file_name_ = Push_Buffer_File_Name;\ app_links->buffer_get_dirty_state_ = Buffer_Get_Dirty_State;\ -app_links->buffer_directly_set_dirty_state_ = Buffer_Directly_Set_Dirty_State;\ +app_links->buffer_set_dirty_state_ = Buffer_Set_Dirty_State;\ app_links->buffer_tokens_are_ready_ = Buffer_Tokens_Are_Ready;\ app_links->buffer_get_setting_ = Buffer_Get_Setting;\ app_links->buffer_set_setting_ = Buffer_Set_Setting;\ app_links->buffer_get_managed_scope_ = Buffer_Get_Managed_Scope;\ -app_links->buffer_token_count_ = Buffer_Token_Count;\ -app_links->buffer_read_tokens_ = Buffer_Read_Tokens;\ -app_links->buffer_get_token_range_ = Buffer_Get_Token_Range;\ -app_links->buffer_get_token_index_ = Buffer_Get_Token_Index;\ +app_links->buffer_get_token_array_ = Buffer_Get_Token_Array;\ app_links->buffer_send_end_signal_ = Buffer_Send_End_Signal;\ app_links->create_buffer_ = Create_Buffer;\ app_links->buffer_save_ = Buffer_Save;\ @@ -821,7 +802,6 @@ app_links->panel_get_child_ = Panel_Get_Child;\ app_links->panel_get_max_ = Panel_Get_Max;\ app_links->panel_get_margin_ = Panel_Get_Margin;\ app_links->view_close_ = View_Close;\ -app_links->view_get_region_ = View_Get_Region;\ app_links->view_get_buffer_region_ = View_Get_Buffer_Region;\ app_links->view_get_scroll_vars_ = View_Get_Scroll_Vars;\ app_links->view_set_active_ = View_Set_Active;\ @@ -939,76 +919,72 @@ app_links->get_view_visible_range_ = Get_View_Visible_Range;} while(false) #if defined(ALLOW_DEP_4CODER) static b32 global_set_setting(Application_Links *app, Global_Setting_ID setting, i32 value){return(app->global_set_setting(app, setting, value));} static b32 global_set_mapping(Application_Links *app, void *data, i32 size){return(app->global_set_mapping(app, data, size));} -static b32 global_get_screen_rectangle(Application_Links *app, Rect_f32 *rect_out){return(app->global_get_screen_rectangle(app, rect_out));} +static Rect_f32 global_get_screen_rectangle(Application_Links *app){return(app->global_get_screen_rectangle(app));} static Arena* context_get_arena(Application_Links *app){return(app->context_get_arena(app));} static Base_Allocator* context_get_base_allocator(Application_Links *app){return(app->context_get_base_allocator(app));} static b32 create_child_process(Application_Links *app, String_Const_u8 path, String_Const_u8 command, Child_Process_ID *child_process_id_out){return(app->create_child_process(app, path, command, child_process_id_out));} static b32 child_process_set_target_buffer(Application_Links *app, Child_Process_ID child_process_id, Buffer_ID buffer_id, Child_Process_Set_Target_Flags flags){return(app->child_process_set_target_buffer(app, child_process_id, buffer_id, flags));} -static b32 buffer_get_attached_child_process(Application_Links *app, Buffer_ID buffer_id, Child_Process_ID *child_process_id_out){return(app->buffer_get_attached_child_process(app, buffer_id, child_process_id_out));} -static b32 child_process_get_attached_buffer(Application_Links *app, Child_Process_ID child_process_id, Buffer_ID *buffer_id_out){return(app->child_process_get_attached_buffer(app, child_process_id, buffer_id_out));} -static b32 child_process_get_state(Application_Links *app, Child_Process_ID child_process_id, Process_State *process_state_out){return(app->child_process_get_state(app, child_process_id, process_state_out));} +static Child_Process_ID buffer_get_attached_child_process(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_get_attached_child_process(app, buffer_id));} +static Buffer_ID child_process_get_attached_buffer(Application_Links *app, Child_Process_ID child_process_id){return(app->child_process_get_attached_buffer(app, child_process_id));} +static Process_State child_process_get_state(Application_Links *app, Child_Process_ID child_process_id){return(app->child_process_get_state(app, child_process_id));} static b32 clipboard_post(Application_Links *app, i32 clipboard_id, String_Const_u8 string){return(app->clipboard_post(app, clipboard_id, string));} -static b32 clipboard_count(Application_Links *app, i32 clipboard_id, i32 *count_out){return(app->clipboard_count(app, clipboard_id, count_out));} -static b32 clipboard_index(Application_Links *app, i32 clipboard_id, i32 item_index, Arena *out, String_Const_u8 *string_out){return(app->clipboard_index(app, clipboard_id, item_index, out, string_out));} +static i32 clipboard_count(Application_Links *app, i32 clipboard_id){return(app->clipboard_count(app, clipboard_id));} +static String_Const_u8 push_clipboard_index(Application_Links *app, Arena *arena, i32 clipboard_id, i32 item_index){return(app->push_clipboard_index(app, arena, clipboard_id, item_index));} static Parse_Context_ID create_parse_context(Application_Links *app, Parser_String_And_Type *kw, u32 kw_count, Parser_String_And_Type *pp, u32 pp_count){return(app->create_parse_context(app, kw, kw_count, pp, pp_count));} static i32 get_buffer_count(Application_Links *app){return(app->get_buffer_count(app));} -static b32 get_buffer_next(Application_Links *app, Buffer_ID buffer_id, Access_Flag access, Buffer_ID *buffer_id_out){return(app->get_buffer_next(app, buffer_id, access, buffer_id_out));} -static b32 get_buffer_by_name(Application_Links *app, String_Const_u8 name, Access_Flag access, Buffer_ID *buffer_id_out){return(app->get_buffer_by_name(app, name, access, buffer_id_out));} -static b32 get_buffer_by_file_name(Application_Links *app, String_Const_u8 file_name, Access_Flag access, Buffer_ID *buffer_id_out){return(app->get_buffer_by_file_name(app, file_name, access, buffer_id_out));} +static Buffer_ID get_buffer_next(Application_Links *app, Buffer_ID buffer_id, Access_Flag access){return(app->get_buffer_next(app, buffer_id, access));} +static Buffer_ID get_buffer_by_name(Application_Links *app, String_Const_u8 name, Access_Flag access){return(app->get_buffer_by_name(app, name, access));} +static Buffer_ID get_buffer_by_file_name(Application_Links *app, String_Const_u8 file_name, Access_Flag access){return(app->get_buffer_by_file_name(app, file_name, access));} static b32 buffer_read_range(Application_Links *app, Buffer_ID buffer_id, i32 start, i32 one_past_last, char *out){return(app->buffer_read_range(app, buffer_id, start, one_past_last, out));} static b32 buffer_replace_range(Application_Links *app, Buffer_ID buffer_id, Range range, String_Const_u8 string){return(app->buffer_replace_range(app, buffer_id, range, string));} static b32 buffer_batch_edit(Application_Links *app, Buffer_ID buffer_id, char *str, Buffer_Edit *edits, i32 edit_count){return(app->buffer_batch_edit(app, buffer_id, str, edits, edit_count));} -static b32 buffer_seek_string(Application_Links *app, Buffer_ID buffer, String_Const_u8 needle, Scan_Direction direction, i32 start_pos, i32 *pos_out, b32 *case_sensitive_out){return(app->buffer_seek_string(app, buffer, needle, direction, start_pos, pos_out, case_sensitive_out));} +static String_Match buffer_seek_string(Application_Links *app, Buffer_ID buffer, String_Const_u8 needle, Scan_Direction direction, i32 start_pos){return(app->buffer_seek_string(app, buffer, needle, direction, start_pos));} static b32 buffer_seek_character_class(Application_Links *app, Buffer_ID buffer_id, Character_Predicate *predicate, Scan_Direction direction, i32 start_pos, i32 *pos_out){return(app->buffer_seek_character_class(app, buffer_id, predicate, direction, start_pos, pos_out));} -static b32 buffer_compute_cursor(Application_Links *app, Buffer_ID buffer_id, Buffer_Seek seek, Partial_Cursor *cursor_out){return(app->buffer_compute_cursor(app, buffer_id, seek, cursor_out));} +static Partial_Cursor buffer_compute_cursor(Application_Links *app, Buffer_ID buffer_id, Buffer_Seek seek){return(app->buffer_compute_cursor(app, buffer_id, seek));} static b32 buffer_exists(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_exists(app, buffer_id));} static b32 buffer_ready(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_ready(app, buffer_id));} -static b32 buffer_get_access_flags(Application_Links *app, Buffer_ID buffer_id, Access_Flag *access_flags_out){return(app->buffer_get_access_flags(app, buffer_id, access_flags_out));} -static b32 buffer_get_size(Application_Links *app, Buffer_ID buffer_id, i32 *size_out){return(app->buffer_get_size(app, buffer_id, size_out));} -static b32 buffer_get_line_count(Application_Links *app, Buffer_ID buffer_id, i32 *line_count_out){return(app->buffer_get_line_count(app, buffer_id, line_count_out));} -static b32 buffer_get_base_buffer_name(Application_Links *app, Buffer_ID buffer_id, Arena *out, String_Const_u8 *name_out){return(app->buffer_get_base_buffer_name(app, buffer_id, out, name_out));} -static b32 buffer_get_unique_buffer_name(Application_Links *app, Buffer_ID buffer_id, Arena *out, String_Const_u8 *name_out){return(app->buffer_get_unique_buffer_name(app, buffer_id, out, name_out));} -static b32 buffer_get_file_name(Application_Links *app, Buffer_ID buffer_id, Arena *out, String_Const_u8 *name_out){return(app->buffer_get_file_name(app, buffer_id, out, name_out));} -static b32 buffer_get_dirty_state(Application_Links *app, Buffer_ID buffer_id, Dirty_State *dirty_state_out){return(app->buffer_get_dirty_state(app, buffer_id, dirty_state_out));} -static b32 buffer_directly_set_dirty_state(Application_Links *app, Buffer_ID buffer_id, Dirty_State dirty_state){return(app->buffer_directly_set_dirty_state(app, buffer_id, dirty_state));} +static Access_Flag buffer_get_access_flags(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_get_access_flags(app, buffer_id));} +static u64 buffer_get_size(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_get_size(app, buffer_id));} +static u64 buffer_get_line_count(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_get_line_count(app, buffer_id));} +static String_Const_u8 push_buffer_base_name(Application_Links *app, Arena *arena, Buffer_ID buffer_id){return(app->push_buffer_base_name(app, arena, buffer_id));} +static String_Const_u8 push_buffer_unique_name(Application_Links *app, Arena *out, Buffer_ID buffer_id){return(app->push_buffer_unique_name(app, out, buffer_id));} +static String_Const_u8 push_buffer_file_name(Application_Links *app, Arena *arena, Buffer_ID buffer_id){return(app->push_buffer_file_name(app, arena, buffer_id));} +static Dirty_State buffer_get_dirty_state(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_get_dirty_state(app, buffer_id));} +static b32 buffer_set_dirty_state(Application_Links *app, Buffer_ID buffer_id, Dirty_State dirty_state){return(app->buffer_set_dirty_state(app, buffer_id, dirty_state));} static b32 buffer_tokens_are_ready(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_tokens_are_ready(app, buffer_id));} static b32 buffer_get_setting(Application_Links *app, Buffer_ID buffer_id, Buffer_Setting_ID setting, i32 *value_out){return(app->buffer_get_setting(app, buffer_id, setting, value_out));} static b32 buffer_set_setting(Application_Links *app, Buffer_ID buffer_id, Buffer_Setting_ID setting, i32 value){return(app->buffer_set_setting(app, buffer_id, setting, value));} -static b32 buffer_get_managed_scope(Application_Links *app, Buffer_ID buffer_id, Managed_Scope *scope_out){return(app->buffer_get_managed_scope(app, buffer_id, scope_out));} -static b32 buffer_token_count(Application_Links *app, Buffer_ID buffer_id, i32 *count_out){return(app->buffer_token_count(app, buffer_id, count_out));} -static b32 buffer_read_tokens(Application_Links *app, Buffer_ID buffer_id, i32 start_token, i32 end_token, Cpp_Token *tokens_out){return(app->buffer_read_tokens(app, buffer_id, start_token, end_token, tokens_out));} -static b32 buffer_get_token_range(Application_Links *app, Buffer_ID buffer_id, Cpp_Token **first_token_out, Cpp_Token **one_past_last_token_out){return(app->buffer_get_token_range(app, buffer_id, first_token_out, one_past_last_token_out));} -static b32 buffer_get_token_index(Application_Links *app, Buffer_ID buffer_id, i32 pos, Cpp_Get_Token_Result *get_result){return(app->buffer_get_token_index(app, buffer_id, pos, get_result));} +static Managed_Scope buffer_get_managed_scope(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_get_managed_scope(app, buffer_id));} +static Cpp_Token_Array buffer_get_token_array(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_get_token_array(app, buffer_id));} static b32 buffer_send_end_signal(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_send_end_signal(app, buffer_id));} -static b32 create_buffer(Application_Links *app, String_Const_u8 file_name, Buffer_Create_Flag flags, Buffer_ID *new_buffer_id_out){return(app->create_buffer(app, file_name, flags, new_buffer_id_out));} -static b32 buffer_save(Application_Links *app, Buffer_ID buffer_id, String_Const_u8 file_name, u32 flags){return(app->buffer_save(app, buffer_id, file_name, flags));} -static b32 buffer_kill(Application_Links *app, Buffer_ID buffer_id, Buffer_Kill_Flag flags, Buffer_Kill_Result *result_out){return(app->buffer_kill(app, buffer_id, flags, result_out));} -static b32 buffer_reopen(Application_Links *app, Buffer_ID buffer_id, Buffer_Reopen_Flag flags, Buffer_Reopen_Result *result_out){return(app->buffer_reopen(app, buffer_id, flags, result_out));} -static b32 buffer_get_file_attributes(Application_Links *app, Buffer_ID buffer_id, File_Attributes *attributes_out){return(app->buffer_get_file_attributes(app, buffer_id, attributes_out));} -static b32 get_view_next(Application_Links *app, View_ID view_id, Access_Flag access, View_ID *view_id_out){return(app->get_view_next(app, view_id, access, view_id_out));} -static b32 get_view_prev(Application_Links *app, View_ID view_id, Access_Flag access, View_ID *view_id_out){return(app->get_view_prev(app, view_id, access, view_id_out));} -static b32 get_active_view(Application_Links *app, Access_Flag access, View_ID *view_id_out){return(app->get_active_view(app, access, view_id_out));} -static b32 get_active_panel(Application_Links *app, Panel_ID *panel_id_out){return(app->get_active_panel(app, panel_id_out));} +static Buffer_ID create_buffer(Application_Links *app, String_Const_u8 file_name, Buffer_Create_Flag flags){return(app->create_buffer(app, file_name, flags));} +static b32 buffer_save(Application_Links *app, Buffer_ID buffer_id, String_Const_u8 file_name, Buffer_Save_Flag flags){return(app->buffer_save(app, buffer_id, file_name, flags));} +static Buffer_Kill_Result buffer_kill(Application_Links *app, Buffer_ID buffer_id, Buffer_Kill_Flag flags){return(app->buffer_kill(app, buffer_id, flags));} +static Buffer_Reopen_Result buffer_reopen(Application_Links *app, Buffer_ID buffer_id, Buffer_Reopen_Flag flags){return(app->buffer_reopen(app, buffer_id, flags));} +static File_Attributes buffer_get_file_attributes(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_get_file_attributes(app, buffer_id));} +static View_ID get_view_next(Application_Links *app, View_ID view_id, Access_Flag access){return(app->get_view_next(app, view_id, access));} +static View_ID get_view_prev(Application_Links *app, View_ID view_id, Access_Flag access){return(app->get_view_prev(app, view_id, access));} +static View_ID get_active_view(Application_Links *app, Access_Flag access){return(app->get_active_view(app, access));} +static Panel_ID get_active_panel(Application_Links *app){return(app->get_active_panel(app));} static b32 view_exists(Application_Links *app, View_ID view_id){return(app->view_exists(app, view_id));} -static b32 view_get_buffer(Application_Links *app, View_ID view_id, Access_Flag access, Buffer_ID *buffer_id_out){return(app->view_get_buffer(app, view_id, access, buffer_id_out));} -static b32 view_get_cursor_pos(Application_Links *app, View_ID view_id, i32 *pos_out){return(app->view_get_cursor_pos(app, view_id, pos_out));} -static b32 view_get_mark_pos(Application_Links *app, View_ID view_id, i32 *pos_out){return(app->view_get_mark_pos(app, view_id, pos_out));} -static b32 view_get_preferred_x(Application_Links *app, View_ID view_id, f32 *preferred_x_out){return(app->view_get_preferred_x(app, view_id, preferred_x_out));} -static b32 view_get_screen_rect(Application_Links *app, View_ID view_id, Rect_f32 *rect_out){return(app->view_get_screen_rect(app, view_id, rect_out));} -static b32 view_get_panel(Application_Links *app, View_ID view_id, Panel_ID *panel_id_out){return(app->view_get_panel(app, view_id, panel_id_out));} -static b32 panel_get_view(Application_Links *app, Panel_ID panel_id, View_ID *view_id_out){return(app->panel_get_view(app, panel_id, view_id_out));} +static Buffer_ID view_get_buffer(Application_Links *app, View_ID view_id, Access_Flag access){return(app->view_get_buffer(app, view_id, access));} +static i32 view_get_cursor_pos(Application_Links *app, View_ID view_id){return(app->view_get_cursor_pos(app, view_id));} +static i32 view_get_mark_pos(Application_Links *app, View_ID view_id){return(app->view_get_mark_pos(app, view_id));} +static f32 view_get_preferred_x(Application_Links *app, View_ID view_id){return(app->view_get_preferred_x(app, view_id));} +static Rect_f32 view_get_screen_rect(Application_Links *app, View_ID view_id){return(app->view_get_screen_rect(app, view_id));} +static Panel_ID view_get_panel(Application_Links *app, View_ID view_id){return(app->view_get_panel(app, view_id));} +static View_ID panel_get_view(Application_Links *app, Panel_ID panel_id){return(app->panel_get_view(app, panel_id));} static b32 panel_is_split(Application_Links *app, Panel_ID panel_id){return(app->panel_is_split(app, panel_id));} static b32 panel_is_leaf(Application_Links *app, Panel_ID panel_id){return(app->panel_is_leaf(app, panel_id));} static b32 panel_split(Application_Links *app, Panel_ID panel_id, Panel_Split_Orientation orientation){return(app->panel_split(app, panel_id, orientation));} static b32 panel_set_split(Application_Links *app, Panel_ID panel_id, Panel_Split_Kind kind, float t){return(app->panel_set_split(app, panel_id, kind, t));} static b32 panel_swap_children(Application_Links *app, Panel_ID panel_id, Panel_Split_Kind kind, float t){return(app->panel_swap_children(app, panel_id, kind, t));} -static b32 panel_get_parent(Application_Links *app, Panel_ID panel_id, Panel_ID *panel_id_out){return(app->panel_get_parent(app, panel_id, panel_id_out));} -static b32 panel_get_child(Application_Links *app, Panel_ID panel_id, Panel_Child which_child, Panel_ID *panel_id_out){return(app->panel_get_child(app, panel_id, which_child, panel_id_out));} -static b32 panel_get_max(Application_Links *app, Panel_ID panel_id, Panel_ID *panel_id_out){return(app->panel_get_max(app, panel_id, panel_id_out));} -static b32 panel_get_margin(Application_Links *app, Panel_ID panel_id, i32_Rect *margins_out){return(app->panel_get_margin(app, panel_id, margins_out));} +static Panel_ID panel_get_parent(Application_Links *app, Panel_ID panel_id){return(app->panel_get_parent(app, panel_id));} +static Panel_ID panel_get_child(Application_Links *app, Panel_ID panel_id, Panel_Child which_child){return(app->panel_get_child(app, panel_id, which_child));} +static Panel_ID panel_get_max(Application_Links *app, Panel_ID panel_id){return(app->panel_get_max(app, panel_id));} +static Rect_i32 panel_get_margin(Application_Links *app, Panel_ID panel_id){return(app->panel_get_margin(app, panel_id));} static b32 view_close(Application_Links *app, View_ID view_id){return(app->view_close(app, view_id));} -static b32 view_get_region(Application_Links *app, View_ID view_id, Rect_i32 *region_out){return(app->view_get_region(app, view_id, region_out));} -static b32 view_get_buffer_region(Application_Links *app, View_ID view_id, Rect_i32 *region_out){return(app->view_get_buffer_region(app, view_id, region_out));} +static Rect_f32 view_get_buffer_region(Application_Links *app, View_ID view_id){return(app->view_get_buffer_region(app, view_id));} static b32 view_get_scroll_vars(Application_Links *app, View_ID view_id, GUI_Scroll_Vars *scroll_vars_out){return(app->view_get_scroll_vars(app, view_id, scroll_vars_out));} static b32 view_set_active(Application_Links *app, View_ID view_id){return(app->view_set_active(app, view_id));} static b32 view_get_setting(Application_Links *app, View_ID view_id, View_Setting_ID setting, i32 *value_out){return(app->view_get_setting(app, view_id, setting, value_out));} @@ -1125,76 +1101,72 @@ static Range get_view_visible_range(Application_Links *app, View_ID view_id){ret #else static b32 global_set_setting(Application_Links *app, Global_Setting_ID setting, i32 value){return(app->global_set_setting_(app, setting, value));} static b32 global_set_mapping(Application_Links *app, void *data, i32 size){return(app->global_set_mapping_(app, data, size));} -static b32 global_get_screen_rectangle(Application_Links *app, Rect_f32 *rect_out){return(app->global_get_screen_rectangle_(app, rect_out));} +static Rect_f32 global_get_screen_rectangle(Application_Links *app){return(app->global_get_screen_rectangle_(app));} static Arena* context_get_arena(Application_Links *app){return(app->context_get_arena_(app));} static Base_Allocator* context_get_base_allocator(Application_Links *app){return(app->context_get_base_allocator_(app));} static b32 create_child_process(Application_Links *app, String_Const_u8 path, String_Const_u8 command, Child_Process_ID *child_process_id_out){return(app->create_child_process_(app, path, command, child_process_id_out));} static b32 child_process_set_target_buffer(Application_Links *app, Child_Process_ID child_process_id, Buffer_ID buffer_id, Child_Process_Set_Target_Flags flags){return(app->child_process_set_target_buffer_(app, child_process_id, buffer_id, flags));} -static b32 buffer_get_attached_child_process(Application_Links *app, Buffer_ID buffer_id, Child_Process_ID *child_process_id_out){return(app->buffer_get_attached_child_process_(app, buffer_id, child_process_id_out));} -static b32 child_process_get_attached_buffer(Application_Links *app, Child_Process_ID child_process_id, Buffer_ID *buffer_id_out){return(app->child_process_get_attached_buffer_(app, child_process_id, buffer_id_out));} -static b32 child_process_get_state(Application_Links *app, Child_Process_ID child_process_id, Process_State *process_state_out){return(app->child_process_get_state_(app, child_process_id, process_state_out));} +static Child_Process_ID buffer_get_attached_child_process(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_get_attached_child_process_(app, buffer_id));} +static Buffer_ID child_process_get_attached_buffer(Application_Links *app, Child_Process_ID child_process_id){return(app->child_process_get_attached_buffer_(app, child_process_id));} +static Process_State child_process_get_state(Application_Links *app, Child_Process_ID child_process_id){return(app->child_process_get_state_(app, child_process_id));} static b32 clipboard_post(Application_Links *app, i32 clipboard_id, String_Const_u8 string){return(app->clipboard_post_(app, clipboard_id, string));} -static b32 clipboard_count(Application_Links *app, i32 clipboard_id, i32 *count_out){return(app->clipboard_count_(app, clipboard_id, count_out));} -static b32 clipboard_index(Application_Links *app, i32 clipboard_id, i32 item_index, Arena *out, String_Const_u8 *string_out){return(app->clipboard_index_(app, clipboard_id, item_index, out, string_out));} +static i32 clipboard_count(Application_Links *app, i32 clipboard_id){return(app->clipboard_count_(app, clipboard_id));} +static String_Const_u8 push_clipboard_index(Application_Links *app, Arena *arena, i32 clipboard_id, i32 item_index){return(app->push_clipboard_index_(app, arena, clipboard_id, item_index));} static Parse_Context_ID create_parse_context(Application_Links *app, Parser_String_And_Type *kw, u32 kw_count, Parser_String_And_Type *pp, u32 pp_count){return(app->create_parse_context_(app, kw, kw_count, pp, pp_count));} static i32 get_buffer_count(Application_Links *app){return(app->get_buffer_count_(app));} -static b32 get_buffer_next(Application_Links *app, Buffer_ID buffer_id, Access_Flag access, Buffer_ID *buffer_id_out){return(app->get_buffer_next_(app, buffer_id, access, buffer_id_out));} -static b32 get_buffer_by_name(Application_Links *app, String_Const_u8 name, Access_Flag access, Buffer_ID *buffer_id_out){return(app->get_buffer_by_name_(app, name, access, buffer_id_out));} -static b32 get_buffer_by_file_name(Application_Links *app, String_Const_u8 file_name, Access_Flag access, Buffer_ID *buffer_id_out){return(app->get_buffer_by_file_name_(app, file_name, access, buffer_id_out));} +static Buffer_ID get_buffer_next(Application_Links *app, Buffer_ID buffer_id, Access_Flag access){return(app->get_buffer_next_(app, buffer_id, access));} +static Buffer_ID get_buffer_by_name(Application_Links *app, String_Const_u8 name, Access_Flag access){return(app->get_buffer_by_name_(app, name, access));} +static Buffer_ID get_buffer_by_file_name(Application_Links *app, String_Const_u8 file_name, Access_Flag access){return(app->get_buffer_by_file_name_(app, file_name, access));} static b32 buffer_read_range(Application_Links *app, Buffer_ID buffer_id, i32 start, i32 one_past_last, char *out){return(app->buffer_read_range_(app, buffer_id, start, one_past_last, out));} static b32 buffer_replace_range(Application_Links *app, Buffer_ID buffer_id, Range range, String_Const_u8 string){return(app->buffer_replace_range_(app, buffer_id, range, string));} static b32 buffer_batch_edit(Application_Links *app, Buffer_ID buffer_id, char *str, Buffer_Edit *edits, i32 edit_count){return(app->buffer_batch_edit_(app, buffer_id, str, edits, edit_count));} -static b32 buffer_seek_string(Application_Links *app, Buffer_ID buffer, String_Const_u8 needle, Scan_Direction direction, i32 start_pos, i32 *pos_out, b32 *case_sensitive_out){return(app->buffer_seek_string_(app, buffer, needle, direction, start_pos, pos_out, case_sensitive_out));} +static String_Match buffer_seek_string(Application_Links *app, Buffer_ID buffer, String_Const_u8 needle, Scan_Direction direction, i32 start_pos){return(app->buffer_seek_string_(app, buffer, needle, direction, start_pos));} static b32 buffer_seek_character_class(Application_Links *app, Buffer_ID buffer_id, Character_Predicate *predicate, Scan_Direction direction, i32 start_pos, i32 *pos_out){return(app->buffer_seek_character_class_(app, buffer_id, predicate, direction, start_pos, pos_out));} -static b32 buffer_compute_cursor(Application_Links *app, Buffer_ID buffer_id, Buffer_Seek seek, Partial_Cursor *cursor_out){return(app->buffer_compute_cursor_(app, buffer_id, seek, cursor_out));} +static Partial_Cursor buffer_compute_cursor(Application_Links *app, Buffer_ID buffer_id, Buffer_Seek seek){return(app->buffer_compute_cursor_(app, buffer_id, seek));} static b32 buffer_exists(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_exists_(app, buffer_id));} static b32 buffer_ready(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_ready_(app, buffer_id));} -static b32 buffer_get_access_flags(Application_Links *app, Buffer_ID buffer_id, Access_Flag *access_flags_out){return(app->buffer_get_access_flags_(app, buffer_id, access_flags_out));} -static b32 buffer_get_size(Application_Links *app, Buffer_ID buffer_id, i32 *size_out){return(app->buffer_get_size_(app, buffer_id, size_out));} -static b32 buffer_get_line_count(Application_Links *app, Buffer_ID buffer_id, i32 *line_count_out){return(app->buffer_get_line_count_(app, buffer_id, line_count_out));} -static b32 buffer_get_base_buffer_name(Application_Links *app, Buffer_ID buffer_id, Arena *out, String_Const_u8 *name_out){return(app->buffer_get_base_buffer_name_(app, buffer_id, out, name_out));} -static b32 buffer_get_unique_buffer_name(Application_Links *app, Buffer_ID buffer_id, Arena *out, String_Const_u8 *name_out){return(app->buffer_get_unique_buffer_name_(app, buffer_id, out, name_out));} -static b32 buffer_get_file_name(Application_Links *app, Buffer_ID buffer_id, Arena *out, String_Const_u8 *name_out){return(app->buffer_get_file_name_(app, buffer_id, out, name_out));} -static b32 buffer_get_dirty_state(Application_Links *app, Buffer_ID buffer_id, Dirty_State *dirty_state_out){return(app->buffer_get_dirty_state_(app, buffer_id, dirty_state_out));} -static b32 buffer_directly_set_dirty_state(Application_Links *app, Buffer_ID buffer_id, Dirty_State dirty_state){return(app->buffer_directly_set_dirty_state_(app, buffer_id, dirty_state));} +static Access_Flag buffer_get_access_flags(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_get_access_flags_(app, buffer_id));} +static u64 buffer_get_size(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_get_size_(app, buffer_id));} +static u64 buffer_get_line_count(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_get_line_count_(app, buffer_id));} +static String_Const_u8 push_buffer_base_name(Application_Links *app, Arena *arena, Buffer_ID buffer_id){return(app->push_buffer_base_name_(app, arena, buffer_id));} +static String_Const_u8 push_buffer_unique_name(Application_Links *app, Arena *out, Buffer_ID buffer_id){return(app->push_buffer_unique_name_(app, out, buffer_id));} +static String_Const_u8 push_buffer_file_name(Application_Links *app, Arena *arena, Buffer_ID buffer_id){return(app->push_buffer_file_name_(app, arena, buffer_id));} +static Dirty_State buffer_get_dirty_state(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_get_dirty_state_(app, buffer_id));} +static b32 buffer_set_dirty_state(Application_Links *app, Buffer_ID buffer_id, Dirty_State dirty_state){return(app->buffer_set_dirty_state_(app, buffer_id, dirty_state));} static b32 buffer_tokens_are_ready(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_tokens_are_ready_(app, buffer_id));} static b32 buffer_get_setting(Application_Links *app, Buffer_ID buffer_id, Buffer_Setting_ID setting, i32 *value_out){return(app->buffer_get_setting_(app, buffer_id, setting, value_out));} static b32 buffer_set_setting(Application_Links *app, Buffer_ID buffer_id, Buffer_Setting_ID setting, i32 value){return(app->buffer_set_setting_(app, buffer_id, setting, value));} -static b32 buffer_get_managed_scope(Application_Links *app, Buffer_ID buffer_id, Managed_Scope *scope_out){return(app->buffer_get_managed_scope_(app, buffer_id, scope_out));} -static b32 buffer_token_count(Application_Links *app, Buffer_ID buffer_id, i32 *count_out){return(app->buffer_token_count_(app, buffer_id, count_out));} -static b32 buffer_read_tokens(Application_Links *app, Buffer_ID buffer_id, i32 start_token, i32 end_token, Cpp_Token *tokens_out){return(app->buffer_read_tokens_(app, buffer_id, start_token, end_token, tokens_out));} -static b32 buffer_get_token_range(Application_Links *app, Buffer_ID buffer_id, Cpp_Token **first_token_out, Cpp_Token **one_past_last_token_out){return(app->buffer_get_token_range_(app, buffer_id, first_token_out, one_past_last_token_out));} -static b32 buffer_get_token_index(Application_Links *app, Buffer_ID buffer_id, i32 pos, Cpp_Get_Token_Result *get_result){return(app->buffer_get_token_index_(app, buffer_id, pos, get_result));} +static Managed_Scope buffer_get_managed_scope(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_get_managed_scope_(app, buffer_id));} +static Cpp_Token_Array buffer_get_token_array(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_get_token_array_(app, buffer_id));} static b32 buffer_send_end_signal(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_send_end_signal_(app, buffer_id));} -static b32 create_buffer(Application_Links *app, String_Const_u8 file_name, Buffer_Create_Flag flags, Buffer_ID *new_buffer_id_out){return(app->create_buffer_(app, file_name, flags, new_buffer_id_out));} -static b32 buffer_save(Application_Links *app, Buffer_ID buffer_id, String_Const_u8 file_name, u32 flags){return(app->buffer_save_(app, buffer_id, file_name, flags));} -static b32 buffer_kill(Application_Links *app, Buffer_ID buffer_id, Buffer_Kill_Flag flags, Buffer_Kill_Result *result_out){return(app->buffer_kill_(app, buffer_id, flags, result_out));} -static b32 buffer_reopen(Application_Links *app, Buffer_ID buffer_id, Buffer_Reopen_Flag flags, Buffer_Reopen_Result *result_out){return(app->buffer_reopen_(app, buffer_id, flags, result_out));} -static b32 buffer_get_file_attributes(Application_Links *app, Buffer_ID buffer_id, File_Attributes *attributes_out){return(app->buffer_get_file_attributes_(app, buffer_id, attributes_out));} -static b32 get_view_next(Application_Links *app, View_ID view_id, Access_Flag access, View_ID *view_id_out){return(app->get_view_next_(app, view_id, access, view_id_out));} -static b32 get_view_prev(Application_Links *app, View_ID view_id, Access_Flag access, View_ID *view_id_out){return(app->get_view_prev_(app, view_id, access, view_id_out));} -static b32 get_active_view(Application_Links *app, Access_Flag access, View_ID *view_id_out){return(app->get_active_view_(app, access, view_id_out));} -static b32 get_active_panel(Application_Links *app, Panel_ID *panel_id_out){return(app->get_active_panel_(app, panel_id_out));} +static Buffer_ID create_buffer(Application_Links *app, String_Const_u8 file_name, Buffer_Create_Flag flags){return(app->create_buffer_(app, file_name, flags));} +static b32 buffer_save(Application_Links *app, Buffer_ID buffer_id, String_Const_u8 file_name, Buffer_Save_Flag flags){return(app->buffer_save_(app, buffer_id, file_name, flags));} +static Buffer_Kill_Result buffer_kill(Application_Links *app, Buffer_ID buffer_id, Buffer_Kill_Flag flags){return(app->buffer_kill_(app, buffer_id, flags));} +static Buffer_Reopen_Result buffer_reopen(Application_Links *app, Buffer_ID buffer_id, Buffer_Reopen_Flag flags){return(app->buffer_reopen_(app, buffer_id, flags));} +static File_Attributes buffer_get_file_attributes(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_get_file_attributes_(app, buffer_id));} +static View_ID get_view_next(Application_Links *app, View_ID view_id, Access_Flag access){return(app->get_view_next_(app, view_id, access));} +static View_ID get_view_prev(Application_Links *app, View_ID view_id, Access_Flag access){return(app->get_view_prev_(app, view_id, access));} +static View_ID get_active_view(Application_Links *app, Access_Flag access){return(app->get_active_view_(app, access));} +static Panel_ID get_active_panel(Application_Links *app){return(app->get_active_panel_(app));} static b32 view_exists(Application_Links *app, View_ID view_id){return(app->view_exists_(app, view_id));} -static b32 view_get_buffer(Application_Links *app, View_ID view_id, Access_Flag access, Buffer_ID *buffer_id_out){return(app->view_get_buffer_(app, view_id, access, buffer_id_out));} -static b32 view_get_cursor_pos(Application_Links *app, View_ID view_id, i32 *pos_out){return(app->view_get_cursor_pos_(app, view_id, pos_out));} -static b32 view_get_mark_pos(Application_Links *app, View_ID view_id, i32 *pos_out){return(app->view_get_mark_pos_(app, view_id, pos_out));} -static b32 view_get_preferred_x(Application_Links *app, View_ID view_id, f32 *preferred_x_out){return(app->view_get_preferred_x_(app, view_id, preferred_x_out));} -static b32 view_get_screen_rect(Application_Links *app, View_ID view_id, Rect_f32 *rect_out){return(app->view_get_screen_rect_(app, view_id, rect_out));} -static b32 view_get_panel(Application_Links *app, View_ID view_id, Panel_ID *panel_id_out){return(app->view_get_panel_(app, view_id, panel_id_out));} -static b32 panel_get_view(Application_Links *app, Panel_ID panel_id, View_ID *view_id_out){return(app->panel_get_view_(app, panel_id, view_id_out));} +static Buffer_ID view_get_buffer(Application_Links *app, View_ID view_id, Access_Flag access){return(app->view_get_buffer_(app, view_id, access));} +static i32 view_get_cursor_pos(Application_Links *app, View_ID view_id){return(app->view_get_cursor_pos_(app, view_id));} +static i32 view_get_mark_pos(Application_Links *app, View_ID view_id){return(app->view_get_mark_pos_(app, view_id));} +static f32 view_get_preferred_x(Application_Links *app, View_ID view_id){return(app->view_get_preferred_x_(app, view_id));} +static Rect_f32 view_get_screen_rect(Application_Links *app, View_ID view_id){return(app->view_get_screen_rect_(app, view_id));} +static Panel_ID view_get_panel(Application_Links *app, View_ID view_id){return(app->view_get_panel_(app, view_id));} +static View_ID panel_get_view(Application_Links *app, Panel_ID panel_id){return(app->panel_get_view_(app, panel_id));} static b32 panel_is_split(Application_Links *app, Panel_ID panel_id){return(app->panel_is_split_(app, panel_id));} static b32 panel_is_leaf(Application_Links *app, Panel_ID panel_id){return(app->panel_is_leaf_(app, panel_id));} static b32 panel_split(Application_Links *app, Panel_ID panel_id, Panel_Split_Orientation orientation){return(app->panel_split_(app, panel_id, orientation));} static b32 panel_set_split(Application_Links *app, Panel_ID panel_id, Panel_Split_Kind kind, float t){return(app->panel_set_split_(app, panel_id, kind, t));} static b32 panel_swap_children(Application_Links *app, Panel_ID panel_id, Panel_Split_Kind kind, float t){return(app->panel_swap_children_(app, panel_id, kind, t));} -static b32 panel_get_parent(Application_Links *app, Panel_ID panel_id, Panel_ID *panel_id_out){return(app->panel_get_parent_(app, panel_id, panel_id_out));} -static b32 panel_get_child(Application_Links *app, Panel_ID panel_id, Panel_Child which_child, Panel_ID *panel_id_out){return(app->panel_get_child_(app, panel_id, which_child, panel_id_out));} -static b32 panel_get_max(Application_Links *app, Panel_ID panel_id, Panel_ID *panel_id_out){return(app->panel_get_max_(app, panel_id, panel_id_out));} -static b32 panel_get_margin(Application_Links *app, Panel_ID panel_id, i32_Rect *margins_out){return(app->panel_get_margin_(app, panel_id, margins_out));} +static Panel_ID panel_get_parent(Application_Links *app, Panel_ID panel_id){return(app->panel_get_parent_(app, panel_id));} +static Panel_ID panel_get_child(Application_Links *app, Panel_ID panel_id, Panel_Child which_child){return(app->panel_get_child_(app, panel_id, which_child));} +static Panel_ID panel_get_max(Application_Links *app, Panel_ID panel_id){return(app->panel_get_max_(app, panel_id));} +static Rect_i32 panel_get_margin(Application_Links *app, Panel_ID panel_id){return(app->panel_get_margin_(app, panel_id));} static b32 view_close(Application_Links *app, View_ID view_id){return(app->view_close_(app, view_id));} -static b32 view_get_region(Application_Links *app, View_ID view_id, Rect_i32 *region_out){return(app->view_get_region_(app, view_id, region_out));} -static b32 view_get_buffer_region(Application_Links *app, View_ID view_id, Rect_i32 *region_out){return(app->view_get_buffer_region_(app, view_id, region_out));} +static Rect_f32 view_get_buffer_region(Application_Links *app, View_ID view_id){return(app->view_get_buffer_region_(app, view_id));} static b32 view_get_scroll_vars(Application_Links *app, View_ID view_id, GUI_Scroll_Vars *scroll_vars_out){return(app->view_get_scroll_vars_(app, view_id, scroll_vars_out));} static b32 view_set_active(Application_Links *app, View_ID view_id){return(app->view_set_active_(app, view_id));} static b32 view_get_setting(Application_Links *app, View_ID view_id, View_Setting_ID setting, i32 *value_out){return(app->view_get_setting_(app, view_id, setting, value_out));} diff --git a/4coder_generated/command_metadata.h b/4coder_generated/command_metadata.h index 258db328..c42a3920 100644 --- a/4coder_generated/command_metadata.h +++ b/4coder_generated/command_metadata.h @@ -257,242 +257,242 @@ int32_t source_name_len; int32_t line_number; }; static Command_Metadata fcoder_metacmd_table[236] = { -{ PROC_LINKS(replace_all_occurrences, 0), "replace_all_occurrences", 23, "Queries the user for two strings, and replaces all occurrences of the first string with the second string in all open buffers.", 126, "w:\\4ed\\code\\4coder_experiments.cpp", 34, 806 }, -{ PROC_LINKS(seek_beginning_of_textual_line, 0), "seek_beginning_of_textual_line", 30, "Seeks the cursor to the beginning of the line across all text.", 62, "w:\\4ed\\code\\4coder_seek.cpp", 27, 34 }, -{ PROC_LINKS(seek_end_of_textual_line, 0), "seek_end_of_textual_line", 24, "Seeks the cursor to the end of the line across all text.", 56, "w:\\4ed\\code\\4coder_seek.cpp", 27, 40 }, -{ PROC_LINKS(seek_beginning_of_line, 0), "seek_beginning_of_line", 22, "Seeks the cursor to the beginning of the visual line.", 53, "w:\\4ed\\code\\4coder_seek.cpp", 27, 46 }, -{ PROC_LINKS(seek_end_of_line, 0), "seek_end_of_line", 16, "Seeks the cursor to the end of the visual line.", 47, "w:\\4ed\\code\\4coder_seek.cpp", 27, 52 }, -{ PROC_LINKS(goto_beginning_of_file, 0), "goto_beginning_of_file", 22, "Sets the cursor to the beginning of the file.", 45, "w:\\4ed\\code\\4coder_seek.cpp", 27, 58 }, -{ PROC_LINKS(goto_end_of_file, 0), "goto_end_of_file", 16, "Sets the cursor to the end of the file.", 39, "w:\\4ed\\code\\4coder_seek.cpp", 27, 67 }, -{ PROC_LINKS(change_active_panel, 0), "change_active_panel", 19, "Change the currently active panel, moving to the panel with the next highest view_id.", 85, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 206 }, -{ PROC_LINKS(change_active_panel_backwards, 0), "change_active_panel_backwards", 29, "Change the currently active panel, moving to the panel with the next lowest view_id.", 84, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 217 }, -{ PROC_LINKS(open_panel_vsplit, 0), "open_panel_vsplit", 17, "Create a new panel by vertically splitting the active panel.", 60, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 228 }, -{ PROC_LINKS(open_panel_hsplit, 0), "open_panel_hsplit", 17, "Create a new panel by horizontally splitting the active panel.", 62, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 240 }, -{ PROC_LINKS(suppress_mouse, 0), "suppress_mouse", 14, "Hides the mouse and causes all mosue input (clicks, position, wheel) to be ignored.", 83, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 307 }, -{ PROC_LINKS(allow_mouse, 0), "allow_mouse", 11, "Shows the mouse and causes all mouse input to be processed normally.", 68, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 313 }, -{ PROC_LINKS(toggle_mouse, 0), "toggle_mouse", 12, "Toggles the mouse suppression mode, see suppress_mouse and allow_mouse.", 71, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 319 }, -{ PROC_LINKS(set_mode_to_original, 0), "set_mode_to_original", 20, "Sets the edit mode to 4coder original.", 38, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 325 }, -{ PROC_LINKS(set_mode_to_notepad_like, 0), "set_mode_to_notepad_like", 24, "Sets the edit mode to Notepad like.", 35, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 331 }, -{ PROC_LINKS(toggle_highlight_line_at_cursor, 0), "toggle_highlight_line_at_cursor", 31, "Toggles the line highlight at the cursor.", 41, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 337 }, -{ PROC_LINKS(toggle_highlight_enclosing_scopes, 0), "toggle_highlight_enclosing_scopes", 33, "In code files scopes surrounding the cursor are highlighted with distinguishing colors.", 87, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 343 }, -{ PROC_LINKS(toggle_paren_matching_helper, 0), "toggle_paren_matching_helper", 28, "In code files matching parentheses pairs are colored with distinguishing colors.", 80, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 349 }, -{ PROC_LINKS(toggle_fullscreen, 0), "toggle_fullscreen", 17, "Toggle fullscreen mode on or off. The change(s) do not take effect until the next frame.", 89, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 355 }, -{ PROC_LINKS(remap_interactive, 0), "remap_interactive", 17, "Switch to a named key binding map.", 34, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 363 }, -{ PROC_LINKS(write_character, 0), "write_character", 15, "Inserts whatever character was used to trigger this command.", 60, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 72 }, -{ PROC_LINKS(write_underscore, 0), "write_underscore", 16, "Inserts an underscore.", 22, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 81 }, -{ PROC_LINKS(delete_char, 0), "delete_char", 11, "Deletes the character to the right of the cursor.", 49, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 88 }, -{ PROC_LINKS(backspace_char, 0), "backspace_char", 14, "Deletes the character to the left of the cursor.", 48, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 110 }, -{ PROC_LINKS(set_mark, 0), "set_mark", 8, "Sets the mark to the current position of the cursor.", 52, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 134 }, -{ PROC_LINKS(cursor_mark_swap, 0), "cursor_mark_swap", 16, "Swaps the position of the cursor and the mark.", 46, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 145 }, -{ PROC_LINKS(delete_range, 0), "delete_range", 12, "Deletes the text in the range between the cursor and the mark.", 62, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 158 }, -{ PROC_LINKS(backspace_alpha_numeric_boundary, 0), "backspace_alpha_numeric_boundary", 32, "Delete characters between the cursor position and the first alphanumeric boundary to the left.", 94, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 182 }, -{ PROC_LINKS(delete_alpha_numeric_boundary, 0), "delete_alpha_numeric_boundary", 29, "Delete characters between the cursor position and the first alphanumeric boundary to the right.", 95, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 190 }, -{ PROC_LINKS(snipe_backward_whitespace_or_token_boundary, 0), "snipe_backward_whitespace_or_token_boundary", 43, "Delete a single, whole token on or to the left of the cursor and post it to the clipboard.", 90, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 213 }, -{ PROC_LINKS(snipe_forward_whitespace_or_token_boundary, 0), "snipe_forward_whitespace_or_token_boundary", 42, "Delete a single, whole token on or to the right of the cursor and post it to the clipboard.", 91, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 221 }, -{ PROC_LINKS(center_view, 0), "center_view", 11, "Centers the view vertically on the line on which the cursor sits.", 65, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 234 }, -{ PROC_LINKS(left_adjust_view, 0), "left_adjust_view", 16, "Sets the left size of the view near the x position of the cursor.", 65, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 252 }, -{ PROC_LINKS(click_set_cursor_and_mark, 0), "click_set_cursor_and_mark", 25, "Sets the cursor position and mark to the mouse position.", 56, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 277 }, -{ PROC_LINKS(click_set_cursor, 0), "click_set_cursor", 16, "Sets the cursor position to the mouse position.", 47, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 296 }, -{ PROC_LINKS(click_set_cursor_if_lbutton, 0), "click_set_cursor_if_lbutton", 27, "If the mouse left button is pressed, sets the cursor position to the mouse position.", 84, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 313 }, -{ PROC_LINKS(click_set_mark, 0), "click_set_mark", 14, "Sets the mark position to the mouse position.", 45, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 332 }, -{ PROC_LINKS(mouse_wheel_scroll, 0), "mouse_wheel_scroll", 18, "Reads the scroll wheel value from the mouse state and scrolls accordingly.", 74, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 349 }, -{ PROC_LINKS(move_up, 0), "move_up", 7, "Moves the cursor up one line.", 29, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 425 }, -{ PROC_LINKS(move_down, 0), "move_down", 9, "Moves the cursor down one line.", 31, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 431 }, -{ PROC_LINKS(move_up_10, 0), "move_up_10", 10, "Moves the cursor up ten lines.", 30, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 437 }, -{ PROC_LINKS(move_down_10, 0), "move_down_10", 12, "Moves the cursor down ten lines.", 32, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 443 }, -{ PROC_LINKS(move_down_textual, 0), "move_down_textual", 17, "Moves down to the next line of actual text, regardless of line wrapping.", 72, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 449 }, -{ PROC_LINKS(page_up, 0), "page_up", 7, "Scrolls the view up one view height and moves the cursor up one view height.", 76, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 463 }, -{ PROC_LINKS(page_down, 0), "page_down", 9, "Scrolls the view down one view height and moves the cursor down one view height.", 80, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 472 }, -{ PROC_LINKS(move_up_to_blank_line, 0), "move_up_to_blank_line", 21, "Seeks the cursor up to the next blank line.", 43, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 505 }, -{ PROC_LINKS(move_down_to_blank_line, 0), "move_down_to_blank_line", 23, "Seeks the cursor down to the next blank line.", 45, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 511 }, -{ PROC_LINKS(move_up_to_blank_line_skip_whitespace, 0), "move_up_to_blank_line_skip_whitespace", 37, "Seeks the cursor up to the next blank line and places it at the end of the line.", 80, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 517 }, -{ PROC_LINKS(move_down_to_blank_line_skip_whitespace, 0), "move_down_to_blank_line_skip_whitespace", 39, "Seeks the cursor down to the next blank line and places it at the end of the line.", 82, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 523 }, -{ PROC_LINKS(move_up_to_blank_line_end, 0), "move_up_to_blank_line_end", 25, "Seeks the cursor up to the next blank line and places it at the end of the line.", 80, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 529 }, -{ PROC_LINKS(move_down_to_blank_line_end, 0), "move_down_to_blank_line_end", 27, "Seeks the cursor down to the next blank line and places it at the end of the line.", 82, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 535 }, -{ PROC_LINKS(move_left, 0), "move_left", 9, "Moves the cursor one character to the left.", 43, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 546 }, -{ PROC_LINKS(move_right, 0), "move_right", 10, "Moves the cursor one character to the right.", 44, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 560 }, -{ PROC_LINKS(move_right_whitespace_boundary, 0), "move_right_whitespace_boundary", 30, "Seek right for the next boundary between whitespace and non-whitespace.", 71, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 587 }, -{ PROC_LINKS(move_left_whitespace_boundary, 0), "move_left_whitespace_boundary", 29, "Seek left for the next boundary between whitespace and non-whitespace.", 70, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 595 }, -{ PROC_LINKS(move_right_token_boundary, 0), "move_right_token_boundary", 25, "Seek right for the next end of a token.", 39, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 603 }, -{ PROC_LINKS(move_left_token_boundary, 0), "move_left_token_boundary", 24, "Seek left for the next beginning of a token.", 44, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 611 }, -{ PROC_LINKS(move_right_whitespace_or_token_boundary, 0), "move_right_whitespace_or_token_boundary", 39, "Seek right for the next end of a token or boundary between whitespace and non-whitespace.", 89, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 619 }, -{ PROC_LINKS(move_left_whitespace_or_token_boundary, 0), "move_left_whitespace_or_token_boundary", 38, "Seek left for the next end of a token or boundary between whitespace and non-whitespace.", 88, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 627 }, -{ PROC_LINKS(move_right_alpha_numeric_boundary, 0), "move_right_alpha_numeric_boundary", 33, "Seek right for boundary between alphanumeric characters and non-alphanumeric characters.", 88, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 635 }, -{ PROC_LINKS(move_left_alpha_numeric_boundary, 0), "move_left_alpha_numeric_boundary", 32, "Seek left for boundary between alphanumeric characters and non-alphanumeric characters.", 87, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 643 }, -{ PROC_LINKS(move_right_alpha_numeric_or_camel_boundary, 0), "move_right_alpha_numeric_or_camel_boundary", 42, "Seek right for boundary between alphanumeric characters or camel case word and non-alphanumeric characters.", 107, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 651 }, -{ PROC_LINKS(move_left_alpha_numeric_or_camel_boundary, 0), "move_left_alpha_numeric_or_camel_boundary", 41, "Seek left for boundary between alphanumeric characters or camel case word and non-alphanumeric characters.", 106, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 659 }, -{ PROC_LINKS(select_all, 0), "select_all", 10, "Puts the cursor at the top of the file, and the mark at the bottom of the file.", 79, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 680 }, -{ PROC_LINKS(to_uppercase, 0), "to_uppercase", 12, "Converts all ascii text in the range between the cursor and the mark to uppercase.", 82, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 696 }, -{ PROC_LINKS(to_lowercase, 0), "to_lowercase", 12, "Converts all ascii text in the range between the cursor and the mark to lowercase.", 82, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 711 }, -{ PROC_LINKS(clean_all_lines, 0), "clean_all_lines", 15, "Removes trailing whitespace from all lines in the current buffer.", 65, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 726 }, -{ PROC_LINKS(basic_change_active_panel, 0), "basic_change_active_panel", 25, "Change the currently active panel, moving to the panel with the next highest view_id. Will not skipe the build panel if it is open.", 132, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 767 }, -{ PROC_LINKS(close_panel, 0), "close_panel", 11, "Closes the currently active panel if it is not the only panel open.", 67, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 776 }, -{ PROC_LINKS(show_scrollbar, 0), "show_scrollbar", 14, "Sets the current view to show it's scrollbar.", 45, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 786 }, -{ PROC_LINKS(hide_scrollbar, 0), "hide_scrollbar", 14, "Sets the current view to hide it's scrollbar.", 45, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 794 }, -{ PROC_LINKS(show_filebar, 0), "show_filebar", 12, "Sets the current view to show it's filebar.", 43, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 802 }, -{ PROC_LINKS(hide_filebar, 0), "hide_filebar", 12, "Sets the current view to hide it's filebar.", 43, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 810 }, -{ PROC_LINKS(toggle_filebar, 0), "toggle_filebar", 14, "Toggles the visibility status of the current view's filebar.", 60, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 818 }, -{ PROC_LINKS(toggle_line_wrap, 0), "toggle_line_wrap", 16, "Toggles the current buffer's line wrapping status.", 50, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 828 }, -{ PROC_LINKS(toggle_fps_meter, 0), "toggle_fps_meter", 16, "Toggles the visibility of the FPS performance meter", 51, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 840 }, -{ PROC_LINKS(increase_line_wrap, 0), "increase_line_wrap", 18, "Increases the current buffer's width for line wrapping.", 55, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 846 }, -{ PROC_LINKS(decrease_line_wrap, 0), "decrease_line_wrap", 18, "Decrases the current buffer's width for line wrapping.", 54, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 858 }, -{ PROC_LINKS(increase_face_size, 0), "increase_face_size", 18, "Increase the size of the face used by the current buffer.", 57, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 870 }, -{ PROC_LINKS(decrease_face_size, 0), "decrease_face_size", 18, "Decrease the size of the face used by the current buffer.", 57, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 884 }, -{ PROC_LINKS(mouse_wheel_change_face_size, 0), "mouse_wheel_change_face_size", 28, "Reads the state of the mouse wheel and uses it to either increase or decrease the face size.", 92, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 898 }, -{ PROC_LINKS(toggle_virtual_whitespace, 0), "toggle_virtual_whitespace", 25, "Toggles the current buffer's virtual whitespace status.", 55, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 915 }, -{ PROC_LINKS(toggle_show_whitespace, 0), "toggle_show_whitespace", 22, "Toggles the current buffer's whitespace visibility status.", 58, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 927 }, -{ PROC_LINKS(toggle_line_numbers, 0), "toggle_line_numbers", 19, "Toggles the left margin line numbers.", 37, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 937 }, -{ PROC_LINKS(eol_dosify, 0), "eol_dosify", 10, "Puts the buffer in DOS line ending mode.", 40, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 943 }, -{ PROC_LINKS(eol_nixify, 0), "eol_nixify", 10, "Puts the buffer in NIX line ending mode.", 40, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 953 }, -{ PROC_LINKS(exit_4coder, 0), "exit_4coder", 11, "Attempts to close 4coder.", 25, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 963 }, -{ PROC_LINKS(goto_line, 0), "goto_line", 9, "Queries the user for a number, and jumps the cursor to the corresponding line.", 78, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 971 }, -{ PROC_LINKS(search, 0), "search", 6, "Begins an incremental search down through the current buffer for a user specified string.", 89, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1199 }, -{ PROC_LINKS(reverse_search, 0), "reverse_search", 14, "Begins an incremental search up through the current buffer for a user specified string.", 87, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1205 }, -{ PROC_LINKS(search_identifier, 0), "search_identifier", 17, "Begins an incremental search down through the current buffer for the word or token under the cursor.", 100, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1211 }, -{ PROC_LINKS(reverse_search_identifier, 0), "reverse_search_identifier", 25, "Begins an incremental search up through the current buffer for the word or token under the cursor.", 98, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1226 }, -{ PROC_LINKS(replace_in_range, 0), "replace_in_range", 16, "Queries the user for two strings, and replaces all occurences of the first string in the range between the cursor and the mark with the second string.", 150, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1241 }, -{ PROC_LINKS(query_replace, 0), "query_replace", 13, "Queries the user for two strings, and incrementally replaces every occurence of the first string with the second string.", 120, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1350 }, -{ PROC_LINKS(query_replace_identifier, 0), "query_replace_identifier", 24, "Queries the user for a string, and incrementally replace every occurence of the word or token found at the cursor with the specified string.", 140, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1373 }, -{ PROC_LINKS(query_replace_selection, 0), "query_replace_selection", 23, "Queries the user for a string, and incrementally replace every occurence of the string found in the selected range with the specified string.", 141, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1392 }, -{ PROC_LINKS(save_all_dirty_buffers, 0), "save_all_dirty_buffers", 22, "Saves all buffers marked dirty (showing the '*' indicator).", 59, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1436 }, -{ PROC_LINKS(delete_file_query, 0), "delete_file_query", 17, "Deletes the file of the current buffer if 4coder has the appropriate access rights. Will ask the user for confirmation first.", 125, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1461 }, -{ PROC_LINKS(save_to_query, 0), "save_to_query", 13, "Queries the user for a file name and saves the contents of the current buffer, altering the buffer's name too.", 110, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1501 }, -{ PROC_LINKS(rename_file_query, 0), "rename_file_query", 17, "Queries the user for a new name and renames the file of the current buffer, altering the buffer's name too.", 107, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1539 }, -{ PROC_LINKS(make_directory_query, 0), "make_directory_query", 20, "Queries the user for a name and creates a new directory with the given name.", 76, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1582 }, -{ PROC_LINKS(move_line_up, 0), "move_line_up", 12, "Swaps the line under the cursor with the line above it, and moves the cursor up with it.", 88, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1618 }, -{ PROC_LINKS(move_line_down, 0), "move_line_down", 14, "Swaps the line under the cursor with the line below it, and moves the cursor down with it.", 90, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1624 }, -{ PROC_LINKS(duplicate_line, 0), "duplicate_line", 14, "Create a copy of the line on which the cursor sits.", 51, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1630 }, -{ PROC_LINKS(delete_line, 0), "delete_line", 11, "Delete the line the on which the cursor sits.", 45, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1647 }, -{ PROC_LINKS(open_file_in_quotes, 0), "open_file_in_quotes", 19, "Reads a filename from surrounding '\"' characters and attempts to open the corresponding file.", 94, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1716 }, -{ PROC_LINKS(open_matching_file_cpp, 0), "open_matching_file_cpp", 22, "If the current file is a *.cpp or *.h, attempts to open the corresponding *.h or *.cpp file in the other view.", 110, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1754 }, -{ PROC_LINKS(view_buffer_other_panel, 0), "view_buffer_other_panel", 23, "Set the other non-active panel to view the buffer that the active panel views, and switch to that panel.", 104, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1769 }, -{ PROC_LINKS(swap_buffers_between_panels, 0), "swap_buffers_between_panels", 27, "Set the other non-active panel to view the buffer that the active panel views, and switch to that panel.", 104, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1784 }, -{ PROC_LINKS(kill_buffer, 0), "kill_buffer", 11, "Kills the current buffer.", 25, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1829 }, -{ PROC_LINKS(save, 0), "save", 4, "Saves the current buffer.", 25, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1839 }, -{ PROC_LINKS(reopen, 0), "reopen", 6, "Reopen the current buffer from the hard drive.", 46, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1853 }, -{ PROC_LINKS(undo, 0), "undo", 4, "Advances backwards through the undo history of the current buffer.", 66, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1917 }, -{ PROC_LINKS(redo, 0), "redo", 4, "Advances forwards through the undo history of the current buffer.", 65, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1933 }, -{ PROC_LINKS(undo_all_buffers, 0), "undo_all_buffers", 16, "Advances backward through the undo history in the buffer containing the most recent regular edit.", 97, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1951 }, -{ PROC_LINKS(redo_all_buffers, 0), "redo_all_buffers", 16, "Advances forward through the undo history in the buffer containing the most recent regular edit.", 96, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 2030 }, -{ PROC_LINKS(open_in_other, 0), "open_in_other", 13, "Interactively opens a file in the other panel.", 46, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 2140 }, +{ PROC_LINKS(replace_all_occurrences, 0), "replace_all_occurrences", 23, "Queries the user for two strings, and replaces all occurrences of the first string with the second string in all open buffers.", 126, "w:\\4ed\\code\\4coder_experiments.cpp", 34, 775 }, +{ PROC_LINKS(seek_beginning_of_textual_line, 0), "seek_beginning_of_textual_line", 30, "Seeks the cursor to the beginning of the line across all text.", 62, "w:\\4ed\\code\\4coder_seek.cpp", 27, 29 }, +{ PROC_LINKS(seek_end_of_textual_line, 0), "seek_end_of_textual_line", 24, "Seeks the cursor to the end of the line across all text.", 56, "w:\\4ed\\code\\4coder_seek.cpp", 27, 35 }, +{ PROC_LINKS(seek_beginning_of_line, 0), "seek_beginning_of_line", 22, "Seeks the cursor to the beginning of the visual line.", 53, "w:\\4ed\\code\\4coder_seek.cpp", 27, 41 }, +{ PROC_LINKS(seek_end_of_line, 0), "seek_end_of_line", 16, "Seeks the cursor to the end of the visual line.", 47, "w:\\4ed\\code\\4coder_seek.cpp", 27, 47 }, +{ PROC_LINKS(goto_beginning_of_file, 0), "goto_beginning_of_file", 22, "Sets the cursor to the beginning of the file.", 45, "w:\\4ed\\code\\4coder_seek.cpp", 27, 53 }, +{ PROC_LINKS(goto_end_of_file, 0), "goto_end_of_file", 16, "Sets the cursor to the end of the file.", 39, "w:\\4ed\\code\\4coder_seek.cpp", 27, 61 }, +{ PROC_LINKS(change_active_panel, 0), "change_active_panel", 19, "Change the currently active panel, moving to the panel with the next highest view_id.", 85, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 201 }, +{ PROC_LINKS(change_active_panel_backwards, 0), "change_active_panel_backwards", 29, "Change the currently active panel, moving to the panel with the next lowest view_id.", 84, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 211 }, +{ PROC_LINKS(open_panel_vsplit, 0), "open_panel_vsplit", 17, "Create a new panel by vertically splitting the active panel.", 60, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 221 }, +{ PROC_LINKS(open_panel_hsplit, 0), "open_panel_hsplit", 17, "Create a new panel by horizontally splitting the active panel.", 62, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 231 }, +{ PROC_LINKS(suppress_mouse, 0), "suppress_mouse", 14, "Hides the mouse and causes all mosue input (clicks, position, wheel) to be ignored.", 83, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 294 }, +{ PROC_LINKS(allow_mouse, 0), "allow_mouse", 11, "Shows the mouse and causes all mouse input to be processed normally.", 68, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 300 }, +{ PROC_LINKS(toggle_mouse, 0), "toggle_mouse", 12, "Toggles the mouse suppression mode, see suppress_mouse and allow_mouse.", 71, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 306 }, +{ PROC_LINKS(set_mode_to_original, 0), "set_mode_to_original", 20, "Sets the edit mode to 4coder original.", 38, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 312 }, +{ PROC_LINKS(set_mode_to_notepad_like, 0), "set_mode_to_notepad_like", 24, "Sets the edit mode to Notepad like.", 35, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 318 }, +{ PROC_LINKS(toggle_highlight_line_at_cursor, 0), "toggle_highlight_line_at_cursor", 31, "Toggles the line highlight at the cursor.", 41, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 324 }, +{ PROC_LINKS(toggle_highlight_enclosing_scopes, 0), "toggle_highlight_enclosing_scopes", 33, "In code files scopes surrounding the cursor are highlighted with distinguishing colors.", 87, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 330 }, +{ PROC_LINKS(toggle_paren_matching_helper, 0), "toggle_paren_matching_helper", 28, "In code files matching parentheses pairs are colored with distinguishing colors.", 80, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 336 }, +{ PROC_LINKS(toggle_fullscreen, 0), "toggle_fullscreen", 17, "Toggle fullscreen mode on or off. The change(s) do not take effect until the next frame.", 89, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 342 }, +{ PROC_LINKS(remap_interactive, 0), "remap_interactive", 17, "Switch to a named key binding map.", 34, "w:\\4ed\\code\\4coder_default_framework.cpp", 40, 350 }, +{ PROC_LINKS(write_character, 0), "write_character", 15, "Inserts whatever character was used to trigger this command.", 60, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 69 }, +{ PROC_LINKS(write_underscore, 0), "write_underscore", 16, "Inserts an underscore.", 22, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 78 }, +{ PROC_LINKS(delete_char, 0), "delete_char", 11, "Deletes the character to the right of the cursor.", 49, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 85 }, +{ PROC_LINKS(backspace_char, 0), "backspace_char", 14, "Deletes the character to the left of the cursor.", 48, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 103 }, +{ PROC_LINKS(set_mark, 0), "set_mark", 8, "Sets the mark to the current position of the cursor.", 52, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 123 }, +{ PROC_LINKS(cursor_mark_swap, 0), "cursor_mark_swap", 16, "Swaps the position of the cursor and the mark.", 46, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 132 }, +{ PROC_LINKS(delete_range, 0), "delete_range", 12, "Deletes the text in the range between the cursor and the mark.", 62, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 142 }, +{ PROC_LINKS(backspace_alpha_numeric_boundary, 0), "backspace_alpha_numeric_boundary", 32, "Delete characters between the cursor position and the first alphanumeric boundary to the left.", 94, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 162 }, +{ PROC_LINKS(delete_alpha_numeric_boundary, 0), "delete_alpha_numeric_boundary", 29, "Delete characters between the cursor position and the first alphanumeric boundary to the right.", 95, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 170 }, +{ PROC_LINKS(snipe_backward_whitespace_or_token_boundary, 0), "snipe_backward_whitespace_or_token_boundary", 43, "Delete a single, whole token on or to the left of the cursor and post it to the clipboard.", 90, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 190 }, +{ PROC_LINKS(snipe_forward_whitespace_or_token_boundary, 0), "snipe_forward_whitespace_or_token_boundary", 42, "Delete a single, whole token on or to the right of the cursor and post it to the clipboard.", 91, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 198 }, +{ PROC_LINKS(center_view, 0), "center_view", 11, "Centers the view vertically on the line on which the cursor sits.", 65, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 211 }, +{ PROC_LINKS(left_adjust_view, 0), "left_adjust_view", 16, "Sets the left size of the view near the x position of the cursor.", 65, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 227 }, +{ PROC_LINKS(click_set_cursor_and_mark, 0), "click_set_cursor_and_mark", 25, "Sets the cursor position and mark to the mouse position.", 56, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 251 }, +{ PROC_LINKS(click_set_cursor, 0), "click_set_cursor", 16, "Sets the cursor position to the mouse position.", 47, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 268 }, +{ PROC_LINKS(click_set_cursor_if_lbutton, 0), "click_set_cursor_if_lbutton", 27, "If the mouse left button is pressed, sets the cursor position to the mouse position.", 84, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 283 }, +{ PROC_LINKS(click_set_mark, 0), "click_set_mark", 14, "Sets the mark position to the mouse position.", 45, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 300 }, +{ PROC_LINKS(mouse_wheel_scroll, 0), "mouse_wheel_scroll", 18, "Reads the scroll wheel value from the mouse state and scrolls accordingly.", 74, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 315 }, +{ PROC_LINKS(move_up, 0), "move_up", 7, "Moves the cursor up one line.", 29, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 382 }, +{ PROC_LINKS(move_down, 0), "move_down", 9, "Moves the cursor down one line.", 31, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 388 }, +{ PROC_LINKS(move_up_10, 0), "move_up_10", 10, "Moves the cursor up ten lines.", 30, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 394 }, +{ PROC_LINKS(move_down_10, 0), "move_down_10", 12, "Moves the cursor down ten lines.", 32, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 400 }, +{ PROC_LINKS(move_down_textual, 0), "move_down_textual", 17, "Moves down to the next line of actual text, regardless of line wrapping.", 72, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 406 }, +{ PROC_LINKS(page_up, 0), "page_up", 7, "Scrolls the view up one view height and moves the cursor up one view height.", 76, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 417 }, +{ PROC_LINKS(page_down, 0), "page_down", 9, "Scrolls the view down one view height and moves the cursor down one view height.", 80, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 425 }, +{ PROC_LINKS(move_up_to_blank_line, 0), "move_up_to_blank_line", 21, "Seeks the cursor up to the next blank line.", 43, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 454 }, +{ PROC_LINKS(move_down_to_blank_line, 0), "move_down_to_blank_line", 23, "Seeks the cursor down to the next blank line.", 45, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 460 }, +{ PROC_LINKS(move_up_to_blank_line_skip_whitespace, 0), "move_up_to_blank_line_skip_whitespace", 37, "Seeks the cursor up to the next blank line and places it at the end of the line.", 80, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 466 }, +{ PROC_LINKS(move_down_to_blank_line_skip_whitespace, 0), "move_down_to_blank_line_skip_whitespace", 39, "Seeks the cursor down to the next blank line and places it at the end of the line.", 82, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 472 }, +{ PROC_LINKS(move_up_to_blank_line_end, 0), "move_up_to_blank_line_end", 25, "Seeks the cursor up to the next blank line and places it at the end of the line.", 80, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 478 }, +{ PROC_LINKS(move_down_to_blank_line_end, 0), "move_down_to_blank_line_end", 27, "Seeks the cursor down to the next blank line and places it at the end of the line.", 82, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 484 }, +{ PROC_LINKS(move_left, 0), "move_left", 9, "Moves the cursor one character to the left.", 43, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 495 }, +{ PROC_LINKS(move_right, 0), "move_right", 10, "Moves the cursor one character to the right.", 44, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 507 }, +{ PROC_LINKS(move_right_whitespace_boundary, 0), "move_right_whitespace_boundary", 30, "Seek right for the next boundary between whitespace and non-whitespace.", 71, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 529 }, +{ PROC_LINKS(move_left_whitespace_boundary, 0), "move_left_whitespace_boundary", 29, "Seek left for the next boundary between whitespace and non-whitespace.", 70, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 537 }, +{ PROC_LINKS(move_right_token_boundary, 0), "move_right_token_boundary", 25, "Seek right for the next end of a token.", 39, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 545 }, +{ PROC_LINKS(move_left_token_boundary, 0), "move_left_token_boundary", 24, "Seek left for the next beginning of a token.", 44, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 553 }, +{ PROC_LINKS(move_right_whitespace_or_token_boundary, 0), "move_right_whitespace_or_token_boundary", 39, "Seek right for the next end of a token or boundary between whitespace and non-whitespace.", 89, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 561 }, +{ PROC_LINKS(move_left_whitespace_or_token_boundary, 0), "move_left_whitespace_or_token_boundary", 38, "Seek left for the next end of a token or boundary between whitespace and non-whitespace.", 88, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 569 }, +{ PROC_LINKS(move_right_alpha_numeric_boundary, 0), "move_right_alpha_numeric_boundary", 33, "Seek right for boundary between alphanumeric characters and non-alphanumeric characters.", 88, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 577 }, +{ PROC_LINKS(move_left_alpha_numeric_boundary, 0), "move_left_alpha_numeric_boundary", 32, "Seek left for boundary between alphanumeric characters and non-alphanumeric characters.", 87, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 585 }, +{ PROC_LINKS(move_right_alpha_numeric_or_camel_boundary, 0), "move_right_alpha_numeric_or_camel_boundary", 42, "Seek right for boundary between alphanumeric characters or camel case word and non-alphanumeric characters.", 107, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 593 }, +{ PROC_LINKS(move_left_alpha_numeric_or_camel_boundary, 0), "move_left_alpha_numeric_or_camel_boundary", 41, "Seek left for boundary between alphanumeric characters or camel case word and non-alphanumeric characters.", 106, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 601 }, +{ PROC_LINKS(select_all, 0), "select_all", 10, "Puts the cursor at the top of the file, and the mark at the bottom of the file.", 79, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 622 }, +{ PROC_LINKS(to_uppercase, 0), "to_uppercase", 12, "Converts all ascii text in the range between the cursor and the mark to uppercase.", 82, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 635 }, +{ PROC_LINKS(to_lowercase, 0), "to_lowercase", 12, "Converts all ascii text in the range between the cursor and the mark to lowercase.", 82, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 648 }, +{ PROC_LINKS(clean_all_lines, 0), "clean_all_lines", 15, "Removes trailing whitespace from all lines in the current buffer.", 65, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 661 }, +{ PROC_LINKS(basic_change_active_panel, 0), "basic_change_active_panel", 25, "Change the currently active panel, moving to the panel with the next highest view_id. Will not skipe the build panel if it is open.", 132, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 699 }, +{ PROC_LINKS(close_panel, 0), "close_panel", 11, "Closes the currently active panel if it is not the only panel open.", 67, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 707 }, +{ PROC_LINKS(show_scrollbar, 0), "show_scrollbar", 14, "Sets the current view to show it's scrollbar.", 45, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 716 }, +{ PROC_LINKS(hide_scrollbar, 0), "hide_scrollbar", 14, "Sets the current view to hide it's scrollbar.", 45, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 723 }, +{ PROC_LINKS(show_filebar, 0), "show_filebar", 12, "Sets the current view to show it's filebar.", 43, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 730 }, +{ PROC_LINKS(hide_filebar, 0), "hide_filebar", 12, "Sets the current view to hide it's filebar.", 43, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 737 }, +{ PROC_LINKS(toggle_filebar, 0), "toggle_filebar", 14, "Toggles the visibility status of the current view's filebar.", 60, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 744 }, +{ PROC_LINKS(toggle_line_wrap, 0), "toggle_line_wrap", 16, "Toggles the current buffer's line wrapping status.", 50, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 753 }, +{ PROC_LINKS(toggle_fps_meter, 0), "toggle_fps_meter", 16, "Toggles the visibility of the FPS performance meter", 51, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 763 }, +{ PROC_LINKS(increase_line_wrap, 0), "increase_line_wrap", 18, "Increases the current buffer's width for line wrapping.", 55, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 769 }, +{ PROC_LINKS(decrease_line_wrap, 0), "decrease_line_wrap", 18, "Decrases the current buffer's width for line wrapping.", 54, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 779 }, +{ PROC_LINKS(increase_face_size, 0), "increase_face_size", 18, "Increase the size of the face used by the current buffer.", 57, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 789 }, +{ PROC_LINKS(decrease_face_size, 0), "decrease_face_size", 18, "Decrease the size of the face used by the current buffer.", 57, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 801 }, +{ PROC_LINKS(mouse_wheel_change_face_size, 0), "mouse_wheel_change_face_size", 28, "Reads the state of the mouse wheel and uses it to either increase or decrease the face size.", 92, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 813 }, +{ PROC_LINKS(toggle_virtual_whitespace, 0), "toggle_virtual_whitespace", 25, "Toggles the current buffer's virtual whitespace status.", 55, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 830 }, +{ PROC_LINKS(toggle_show_whitespace, 0), "toggle_show_whitespace", 22, "Toggles the current buffer's whitespace visibility status.", 58, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 840 }, +{ PROC_LINKS(toggle_line_numbers, 0), "toggle_line_numbers", 19, "Toggles the left margin line numbers.", 37, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 849 }, +{ PROC_LINKS(eol_dosify, 0), "eol_dosify", 10, "Puts the buffer in DOS line ending mode.", 40, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 855 }, +{ PROC_LINKS(eol_nixify, 0), "eol_nixify", 10, "Puts the buffer in NIX line ending mode.", 40, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 863 }, +{ PROC_LINKS(exit_4coder, 0), "exit_4coder", 11, "Attempts to close 4coder.", 25, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 871 }, +{ PROC_LINKS(goto_line, 0), "goto_line", 9, "Queries the user for a number, and jumps the cursor to the corresponding line.", 78, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 879 }, +{ PROC_LINKS(search, 0), "search", 6, "Begins an incremental search down through the current buffer for a user specified string.", 89, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1102 }, +{ PROC_LINKS(reverse_search, 0), "reverse_search", 14, "Begins an incremental search up through the current buffer for a user specified string.", 87, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1108 }, +{ PROC_LINKS(search_identifier, 0), "search_identifier", 17, "Begins an incremental search down through the current buffer for the word or token under the cursor.", 100, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1114 }, +{ PROC_LINKS(reverse_search_identifier, 0), "reverse_search_identifier", 25, "Begins an incremental search up through the current buffer for the word or token under the cursor.", 98, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1126 }, +{ PROC_LINKS(replace_in_range, 0), "replace_in_range", 16, "Queries the user for two strings, and replaces all occurences of the first string in the range between the cursor and the mark with the second string.", 150, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1138 }, +{ PROC_LINKS(query_replace, 0), "query_replace", 13, "Queries the user for two strings, and incrementally replaces every occurence of the first string with the second string.", 120, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1240 }, +{ PROC_LINKS(query_replace_identifier, 0), "query_replace_identifier", 24, "Queries the user for a string, and incrementally replace every occurence of the word or token found at the cursor with the specified string.", 140, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1260 }, +{ PROC_LINKS(query_replace_selection, 0), "query_replace_selection", 23, "Queries the user for a string, and incrementally replace every occurence of the string found in the selected range with the specified string.", 141, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1276 }, +{ PROC_LINKS(save_all_dirty_buffers, 0), "save_all_dirty_buffers", 22, "Saves all buffers marked dirty (showing the '*' indicator).", 59, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1316 }, +{ PROC_LINKS(delete_file_query, 0), "delete_file_query", 17, "Deletes the file of the current buffer if 4coder has the appropriate access rights. Will ask the user for confirmation first.", 125, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1341 }, +{ PROC_LINKS(save_to_query, 0), "save_to_query", 13, "Queries the user for a file name and saves the contents of the current buffer, altering the buffer's name too.", 110, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1379 }, +{ PROC_LINKS(rename_file_query, 0), "rename_file_query", 17, "Queries the user for a new name and renames the file of the current buffer, altering the buffer's name too.", 107, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1414 }, +{ PROC_LINKS(make_directory_query, 0), "make_directory_query", 20, "Queries the user for a name and creates a new directory with the given name.", 76, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1454 }, +{ PROC_LINKS(move_line_up, 0), "move_line_up", 12, "Swaps the line under the cursor with the line above it, and moves the cursor up with it.", 88, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1487 }, +{ PROC_LINKS(move_line_down, 0), "move_line_down", 14, "Swaps the line under the cursor with the line below it, and moves the cursor down with it.", 90, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1493 }, +{ PROC_LINKS(duplicate_line, 0), "duplicate_line", 14, "Create a copy of the line on which the cursor sits.", 51, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1499 }, +{ PROC_LINKS(delete_line, 0), "delete_line", 11, "Delete the line the on which the cursor sits.", 45, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1513 }, +{ PROC_LINKS(open_file_in_quotes, 0), "open_file_in_quotes", 19, "Reads a filename from surrounding '\"' characters and attempts to open the corresponding file.", 94, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1578 }, +{ PROC_LINKS(open_matching_file_cpp, 0), "open_matching_file_cpp", 22, "If the current file is a *.cpp or *.h, attempts to open the corresponding *.h or *.cpp file in the other view.", 110, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1613 }, +{ PROC_LINKS(view_buffer_other_panel, 0), "view_buffer_other_panel", 23, "Set the other non-active panel to view the buffer that the active panel views, and switch to that panel.", 104, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1626 }, +{ PROC_LINKS(swap_buffers_between_panels, 0), "swap_buffers_between_panels", 27, "Set the other non-active panel to view the buffer that the active panel views, and switch to that panel.", 104, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1638 }, +{ PROC_LINKS(kill_buffer, 0), "kill_buffer", 11, "Kills the current buffer.", 25, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1675 }, +{ PROC_LINKS(save, 0), "save", 4, "Saves the current buffer.", 25, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1683 }, +{ PROC_LINKS(reopen, 0), "reopen", 6, "Reopen the current buffer from the hard drive.", 46, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1695 }, +{ PROC_LINKS(undo, 0), "undo", 4, "Advances backwards through the undo history of the current buffer.", 66, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1757 }, +{ PROC_LINKS(redo, 0), "redo", 4, "Advances forwards through the undo history of the current buffer.", 65, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1771 }, +{ PROC_LINKS(undo_all_buffers, 0), "undo_all_buffers", 16, "Advances backward through the undo history in the buffer containing the most recent regular edit.", 97, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1787 }, +{ PROC_LINKS(redo_all_buffers, 0), "redo_all_buffers", 16, "Advances forward through the undo history in the buffer containing the most recent regular edit.", 96, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1865 }, +{ PROC_LINKS(open_in_other, 0), "open_in_other", 13, "Interactively opens a file in the other panel.", 46, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1974 }, { PROC_LINKS(lister__quit, 0), "lister__quit", 12, "A lister mode command that quits the list without executing any actions.", 72, "w:\\4ed\\code\\4coder_lists.cpp", 28, 8 }, -{ PROC_LINKS(lister__activate, 0), "lister__activate", 16, "A lister mode command that activates the list's action on the highlighted item.", 79, "w:\\4ed\\code\\4coder_lists.cpp", 28, 16 }, -{ PROC_LINKS(lister__write_character, 0), "lister__write_character", 23, "A lister mode command that dispatches to the lister's write character handler.", 78, "w:\\4ed\\code\\4coder_lists.cpp", 28, 32 }, -{ PROC_LINKS(lister__backspace_text_field, 0), "lister__backspace_text_field", 28, "A lister mode command that dispatches to the lister's backspace text field handler.", 83, "w:\\4ed\\code\\4coder_lists.cpp", 28, 43 }, -{ PROC_LINKS(lister__move_up, 0), "lister__move_up", 15, "A lister mode command that dispatches to the lister's navigate up handler.", 74, "w:\\4ed\\code\\4coder_lists.cpp", 28, 54 }, -{ PROC_LINKS(lister__move_down, 0), "lister__move_down", 17, "A lister mode command that dispatches to the lister's navigate down handler.", 76, "w:\\4ed\\code\\4coder_lists.cpp", 28, 65 }, -{ PROC_LINKS(lister__wheel_scroll, 0), "lister__wheel_scroll", 20, "A lister mode command that scrolls the list in response to the mouse wheel.", 75, "w:\\4ed\\code\\4coder_lists.cpp", 28, 76 }, -{ PROC_LINKS(lister__mouse_press, 0), "lister__mouse_press", 19, "A lister mode command that beings a click interaction with a list item under the mouse.", 87, "w:\\4ed\\code\\4coder_lists.cpp", 28, 92 }, -{ PROC_LINKS(lister__mouse_release, 0), "lister__mouse_release", 21, "A lister mode command that ends a click interaction with a list item under the mouse, possibly activating it.", 109, "w:\\4ed\\code\\4coder_lists.cpp", 28, 104 }, -{ PROC_LINKS(lister__repaint, 0), "lister__repaint", 15, "A lister mode command that updates the lists UI data.", 53, "w:\\4ed\\code\\4coder_lists.cpp", 28, 120 }, -{ PROC_LINKS(lister__write_character__default, 0), "lister__write_character__default", 32, "A lister mode command that inserts a new character to the text field.", 69, "w:\\4ed\\code\\4coder_lists.cpp", 28, 131 }, -{ PROC_LINKS(lister__backspace_text_field__default, 0), "lister__backspace_text_field__default", 37, "A lister mode command that backspaces one character from the text field.", 72, "w:\\4ed\\code\\4coder_lists.cpp", 28, 151 }, -{ PROC_LINKS(lister__move_up__default, 0), "lister__move_up__default", 24, "A lister mode command that moves the highlighted item one up in the list.", 73, "w:\\4ed\\code\\4coder_lists.cpp", 28, 166 }, -{ PROC_LINKS(lister__move_down__default, 0), "lister__move_down__default", 26, "A lister mode command that moves the highlighted item one down in the list.", 75, "w:\\4ed\\code\\4coder_lists.cpp", 28, 182 }, -{ PROC_LINKS(lister__write_character__file_path, 0), "lister__write_character__file_path", 34, "A lister mode command that inserts a character into the text field of a file system list.", 89, "w:\\4ed\\code\\4coder_lists.cpp", 28, 198 }, -{ PROC_LINKS(lister__backspace_text_field__file_path, 0), "lister__backspace_text_field__file_path", 39, "A lister mode command that backspaces one character from the text field of a file system list.", 94, "w:\\4ed\\code\\4coder_lists.cpp", 28, 224 }, -{ PROC_LINKS(lister__write_character__fixed_list, 0), "lister__write_character__fixed_list", 35, "A lister mode command that handles input for the fixed sure to kill list.", 73, "w:\\4ed\\code\\4coder_lists.cpp", 28, 266 }, -{ PROC_LINKS(interactive_switch_buffer, 0), "interactive_switch_buffer", 25, "Interactively switch to an open buffer.", 39, "w:\\4ed\\code\\4coder_lists.cpp", 28, 750 }, -{ PROC_LINKS(interactive_kill_buffer, 0), "interactive_kill_buffer", 23, "Interactively kill an open buffer.", 34, "w:\\4ed\\code\\4coder_lists.cpp", 28, 770 }, -{ PROC_LINKS(interactive_open_or_new, 0), "interactive_open_or_new", 23, "Interactively open a file out of the file system.", 49, "w:\\4ed\\code\\4coder_lists.cpp", 28, 845 }, -{ PROC_LINKS(interactive_new, 0), "interactive_new", 15, "Interactively creates a new file.", 33, "w:\\4ed\\code\\4coder_lists.cpp", 28, 885 }, -{ PROC_LINKS(interactive_open, 0), "interactive_open", 16, "Interactively opens a file.", 27, "w:\\4ed\\code\\4coder_lists.cpp", 28, 919 }, -{ PROC_LINKS(command_lister, 0), "command_lister", 14, "Opens an interactive list of all registered commands.", 53, "w:\\4ed\\code\\4coder_lists.cpp", 28, 1004 }, -{ PROC_LINKS(auto_tab_whole_file, 0), "auto_tab_whole_file", 19, "Audo-indents the entire current buffer.", 39, "w:\\4ed\\code\\4coder_auto_indent.cpp", 34, 561 }, -{ PROC_LINKS(auto_tab_line_at_cursor, 0), "auto_tab_line_at_cursor", 23, "Auto-indents the line on which the cursor sits.", 47, "w:\\4ed\\code\\4coder_auto_indent.cpp", 34, 574 }, -{ PROC_LINKS(auto_tab_range, 0), "auto_tab_range", 14, "Auto-indents the range between the cursor and the mark.", 55, "w:\\4ed\\code\\4coder_auto_indent.cpp", 34, 588 }, -{ PROC_LINKS(write_and_auto_tab, 0), "write_and_auto_tab", 18, "Inserts a character and auto-indents the line on which the cursor sits.", 71, "w:\\4ed\\code\\4coder_auto_indent.cpp", 34, 601 }, -{ PROC_LINKS(list_all_locations, 0), "list_all_locations", 18, "Queries the user for a string and lists all exact case-sensitive matches found in all open buffers.", 99, "w:\\4ed\\code\\4coder_search.cpp", 29, 705 }, -{ PROC_LINKS(list_all_substring_locations, 0), "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "w:\\4ed\\code\\4coder_search.cpp", 29, 712 }, -{ PROC_LINKS(list_all_locations_case_insensitive, 0), "list_all_locations_case_insensitive", 35, "Queries the user for a string and lists all exact case-insensitive matches found in all open buffers.", 101, "w:\\4ed\\code\\4coder_search.cpp", 29, 719 }, -{ PROC_LINKS(list_all_substring_locations_case_insensitive, 0), "list_all_substring_locations_case_insensitive", 45, "Queries the user for a string and lists all case-insensitive substring matches found in all open buffers.", 105, "w:\\4ed\\code\\4coder_search.cpp", 29, 726 }, -{ PROC_LINKS(list_all_locations_of_identifier, 0), "list_all_locations_of_identifier", 32, "Reads a token or word under the cursor and lists all exact case-sensitive mathces in all open buffers.", 102, "w:\\4ed\\code\\4coder_search.cpp", 29, 733 }, -{ PROC_LINKS(list_all_locations_of_identifier_case_insensitive, 0), "list_all_locations_of_identifier_case_insensitive", 49, "Reads a token or word under the cursor and lists all exact case-insensitive mathces in all open buffers.", 104, "w:\\4ed\\code\\4coder_search.cpp", 29, 740 }, -{ PROC_LINKS(list_all_locations_of_selection, 0), "list_all_locations_of_selection", 31, "Reads the string in the selected range and lists all exact case-sensitive mathces in all open buffers.", 102, "w:\\4ed\\code\\4coder_search.cpp", 29, 747 }, -{ PROC_LINKS(list_all_locations_of_selection_case_insensitive, 0), "list_all_locations_of_selection_case_insensitive", 48, "Reads the string in the selected range and lists all exact case-insensitive mathces in all open buffers.", 104, "w:\\4ed\\code\\4coder_search.cpp", 29, 754 }, -{ PROC_LINKS(list_all_locations_of_type_definition, 0), "list_all_locations_of_type_definition", 37, "Queries user for string, lists all locations of strings that appear to define a type whose name matches the input string.", 121, "w:\\4ed\\code\\4coder_search.cpp", 29, 761 }, -{ PROC_LINKS(list_all_locations_of_type_definition_of_identifier, 0), "list_all_locations_of_type_definition_of_identifier", 51, "Reads a token or word under the cursor and lists all locations of strings that appear to define a type whose name matches it.", 125, "w:\\4ed\\code\\4coder_search.cpp", 29, 772 }, -{ PROC_LINKS(word_complete, 0), "word_complete", 13, "Iteratively tries completing the word to the left of the cursor with other words in open buffers that have the same prefix string.", 130, "w:\\4ed\\code\\4coder_search.cpp", 29, 796 }, +{ PROC_LINKS(lister__activate, 0), "lister__activate", 16, "A lister mode command that activates the list's action on the highlighted item.", 79, "w:\\4ed\\code\\4coder_lists.cpp", 28, 15 }, +{ PROC_LINKS(lister__write_character, 0), "lister__write_character", 23, "A lister mode command that dispatches to the lister's write character handler.", 78, "w:\\4ed\\code\\4coder_lists.cpp", 28, 30 }, +{ PROC_LINKS(lister__backspace_text_field, 0), "lister__backspace_text_field", 28, "A lister mode command that dispatches to the lister's backspace text field handler.", 83, "w:\\4ed\\code\\4coder_lists.cpp", 28, 40 }, +{ PROC_LINKS(lister__move_up, 0), "lister__move_up", 15, "A lister mode command that dispatches to the lister's navigate up handler.", 74, "w:\\4ed\\code\\4coder_lists.cpp", 28, 50 }, +{ PROC_LINKS(lister__move_down, 0), "lister__move_down", 17, "A lister mode command that dispatches to the lister's navigate down handler.", 76, "w:\\4ed\\code\\4coder_lists.cpp", 28, 60 }, +{ PROC_LINKS(lister__wheel_scroll, 0), "lister__wheel_scroll", 20, "A lister mode command that scrolls the list in response to the mouse wheel.", 75, "w:\\4ed\\code\\4coder_lists.cpp", 28, 70 }, +{ PROC_LINKS(lister__mouse_press, 0), "lister__mouse_press", 19, "A lister mode command that beings a click interaction with a list item under the mouse.", 87, "w:\\4ed\\code\\4coder_lists.cpp", 28, 85 }, +{ PROC_LINKS(lister__mouse_release, 0), "lister__mouse_release", 21, "A lister mode command that ends a click interaction with a list item under the mouse, possibly activating it.", 109, "w:\\4ed\\code\\4coder_lists.cpp", 28, 96 }, +{ PROC_LINKS(lister__repaint, 0), "lister__repaint", 15, "A lister mode command that updates the lists UI data.", 53, "w:\\4ed\\code\\4coder_lists.cpp", 28, 111 }, +{ PROC_LINKS(lister__write_character__default, 0), "lister__write_character__default", 32, "A lister mode command that inserts a new character to the text field.", 69, "w:\\4ed\\code\\4coder_lists.cpp", 28, 121 }, +{ PROC_LINKS(lister__backspace_text_field__default, 0), "lister__backspace_text_field__default", 37, "A lister mode command that backspaces one character from the text field.", 72, "w:\\4ed\\code\\4coder_lists.cpp", 28, 140 }, +{ PROC_LINKS(lister__move_up__default, 0), "lister__move_up__default", 24, "A lister mode command that moves the highlighted item one up in the list.", 73, "w:\\4ed\\code\\4coder_lists.cpp", 28, 154 }, +{ PROC_LINKS(lister__move_down__default, 0), "lister__move_down__default", 26, "A lister mode command that moves the highlighted item one down in the list.", 75, "w:\\4ed\\code\\4coder_lists.cpp", 28, 169 }, +{ PROC_LINKS(lister__write_character__file_path, 0), "lister__write_character__file_path", 34, "A lister mode command that inserts a character into the text field of a file system list.", 89, "w:\\4ed\\code\\4coder_lists.cpp", 28, 184 }, +{ PROC_LINKS(lister__backspace_text_field__file_path, 0), "lister__backspace_text_field__file_path", 39, "A lister mode command that backspaces one character from the text field of a file system list.", 94, "w:\\4ed\\code\\4coder_lists.cpp", 28, 209 }, +{ PROC_LINKS(lister__write_character__fixed_list, 0), "lister__write_character__fixed_list", 35, "A lister mode command that handles input for the fixed sure to kill list.", 73, "w:\\4ed\\code\\4coder_lists.cpp", 28, 250 }, +{ PROC_LINKS(interactive_switch_buffer, 0), "interactive_switch_buffer", 25, "Interactively switch to an open buffer.", 39, "w:\\4ed\\code\\4coder_lists.cpp", 28, 726 }, +{ PROC_LINKS(interactive_kill_buffer, 0), "interactive_kill_buffer", 23, "Interactively kill an open buffer.", 34, "w:\\4ed\\code\\4coder_lists.cpp", 28, 745 }, +{ PROC_LINKS(interactive_open_or_new, 0), "interactive_open_or_new", 23, "Interactively open a file out of the file system.", 49, "w:\\4ed\\code\\4coder_lists.cpp", 28, 818 }, +{ PROC_LINKS(interactive_new, 0), "interactive_new", 15, "Interactively creates a new file.", 33, "w:\\4ed\\code\\4coder_lists.cpp", 28, 857 }, +{ PROC_LINKS(interactive_open, 0), "interactive_open", 16, "Interactively opens a file.", 27, "w:\\4ed\\code\\4coder_lists.cpp", 28, 890 }, +{ PROC_LINKS(command_lister, 0), "command_lister", 14, "Opens an interactive list of all registered commands.", 53, "w:\\4ed\\code\\4coder_lists.cpp", 28, 972 }, +{ PROC_LINKS(auto_tab_whole_file, 0), "auto_tab_whole_file", 19, "Audo-indents the entire current buffer.", 39, "w:\\4ed\\code\\4coder_auto_indent.cpp", 34, 556 }, +{ PROC_LINKS(auto_tab_line_at_cursor, 0), "auto_tab_line_at_cursor", 23, "Auto-indents the line on which the cursor sits.", 47, "w:\\4ed\\code\\4coder_auto_indent.cpp", 34, 566 }, +{ PROC_LINKS(auto_tab_range, 0), "auto_tab_range", 14, "Auto-indents the range between the cursor and the mark.", 55, "w:\\4ed\\code\\4coder_auto_indent.cpp", 34, 577 }, +{ PROC_LINKS(write_and_auto_tab, 0), "write_and_auto_tab", 18, "Inserts a character and auto-indents the line on which the cursor sits.", 71, "w:\\4ed\\code\\4coder_auto_indent.cpp", 34, 588 }, +{ PROC_LINKS(list_all_locations, 0), "list_all_locations", 18, "Queries the user for a string and lists all exact case-sensitive matches found in all open buffers.", 99, "w:\\4ed\\code\\4coder_search.cpp", 29, 698 }, +{ PROC_LINKS(list_all_substring_locations, 0), "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "w:\\4ed\\code\\4coder_search.cpp", 29, 705 }, +{ PROC_LINKS(list_all_locations_case_insensitive, 0), "list_all_locations_case_insensitive", 35, "Queries the user for a string and lists all exact case-insensitive matches found in all open buffers.", 101, "w:\\4ed\\code\\4coder_search.cpp", 29, 712 }, +{ PROC_LINKS(list_all_substring_locations_case_insensitive, 0), "list_all_substring_locations_case_insensitive", 45, "Queries the user for a string and lists all case-insensitive substring matches found in all open buffers.", 105, "w:\\4ed\\code\\4coder_search.cpp", 29, 719 }, +{ PROC_LINKS(list_all_locations_of_identifier, 0), "list_all_locations_of_identifier", 32, "Reads a token or word under the cursor and lists all exact case-sensitive mathces in all open buffers.", 102, "w:\\4ed\\code\\4coder_search.cpp", 29, 726 }, +{ PROC_LINKS(list_all_locations_of_identifier_case_insensitive, 0), "list_all_locations_of_identifier_case_insensitive", 49, "Reads a token or word under the cursor and lists all exact case-insensitive mathces in all open buffers.", 104, "w:\\4ed\\code\\4coder_search.cpp", 29, 733 }, +{ PROC_LINKS(list_all_locations_of_selection, 0), "list_all_locations_of_selection", 31, "Reads the string in the selected range and lists all exact case-sensitive mathces in all open buffers.", 102, "w:\\4ed\\code\\4coder_search.cpp", 29, 740 }, +{ PROC_LINKS(list_all_locations_of_selection_case_insensitive, 0), "list_all_locations_of_selection_case_insensitive", 48, "Reads the string in the selected range and lists all exact case-insensitive mathces in all open buffers.", 104, "w:\\4ed\\code\\4coder_search.cpp", 29, 747 }, +{ PROC_LINKS(list_all_locations_of_type_definition, 0), "list_all_locations_of_type_definition", 37, "Queries user for string, lists all locations of strings that appear to define a type whose name matches the input string.", 121, "w:\\4ed\\code\\4coder_search.cpp", 29, 754 }, +{ PROC_LINKS(list_all_locations_of_type_definition_of_identifier, 0), "list_all_locations_of_type_definition_of_identifier", 51, "Reads a token or word under the cursor and lists all locations of strings that appear to define a type whose name matches it.", 125, "w:\\4ed\\code\\4coder_search.cpp", 29, 765 }, +{ PROC_LINKS(word_complete, 0), "word_complete", 13, "Iteratively tries completing the word to the left of the cursor with other words in open buffers that have the same prefix string.", 130, "w:\\4ed\\code\\4coder_search.cpp", 29, 786 }, { PROC_LINKS(goto_jump_at_cursor_direct, 0), "goto_jump_at_cursor_direct", 26, "If the cursor is found to be on a jump location, parses the jump location and brings up the file and position in another view and changes the active panel to the view containing the jump.", 187, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 8 }, -{ PROC_LINKS(goto_jump_at_cursor_same_panel_direct, 0), "goto_jump_at_cursor_same_panel_direct", 37, "If the cursor is found to be on a jump location, parses the jump location and brings up the file and position in this view, losing the compilation output or jump list..", 168, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 36 }, -{ PROC_LINKS(goto_next_jump_direct, 0), "goto_next_jump_direct", 21, "If a buffer containing jump locations has been locked in, goes to the next jump in the buffer, skipping sub jump locations.", 123, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 61 }, -{ PROC_LINKS(goto_prev_jump_direct, 0), "goto_prev_jump_direct", 21, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, skipping sub jump locations.", 127, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 70 }, -{ PROC_LINKS(goto_next_jump_no_skips_direct, 0), "goto_next_jump_no_skips_direct", 30, "If a buffer containing jump locations has been locked in, goes to the next jump in the buffer, and does not skip sub jump locations.", 132, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 79 }, -{ PROC_LINKS(goto_prev_jump_no_skips_direct, 0), "goto_prev_jump_no_skips_direct", 30, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, and does not skip sub jump locations.", 136, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 88 }, -{ PROC_LINKS(goto_first_jump_direct, 0), "goto_first_jump_direct", 22, "If a buffer containing jump locations has been locked in, goes to the first jump in the buffer.", 95, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 97 }, -{ PROC_LINKS(newline_or_goto_position_direct, 0), "newline_or_goto_position_direct", 31, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor.", 106, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 112 }, -{ PROC_LINKS(newline_or_goto_position_same_panel_direct, 0), "newline_or_goto_position_same_panel_direct", 42, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor_same_panel.", 117, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 127 }, -{ PROC_LINKS(goto_jump_at_cursor_sticky, 0), "goto_jump_at_cursor_sticky", 26, "If the cursor is found to be on a jump location, parses the jump location and brings up the file and position in another view and changes the active panel to the view containing the jump.", 187, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 366 }, -{ PROC_LINKS(goto_jump_at_cursor_same_panel_sticky, 0), "goto_jump_at_cursor_same_panel_sticky", 37, "If the cursor is found to be on a jump location, parses the jump location and brings up the file and position in this view, losing the compilation output or jump list.", 167, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 398 }, -{ PROC_LINKS(goto_next_jump_sticky, 0), "goto_next_jump_sticky", 21, "If a buffer containing jump locations has been locked in, goes to the next jump in the buffer, skipping sub jump locations.", 123, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 505 }, -{ PROC_LINKS(goto_prev_jump_sticky, 0), "goto_prev_jump_sticky", 21, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, skipping sub jump locations.", 127, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 524 }, -{ PROC_LINKS(goto_next_jump_no_skips_sticky, 0), "goto_next_jump_no_skips_sticky", 30, "If a buffer containing jump locations has been locked in, goes to the next jump in the buffer, and does not skip sub jump locations.", 132, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 537 }, -{ PROC_LINKS(goto_prev_jump_no_skips_sticky, 0), "goto_prev_jump_no_skips_sticky", 30, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, and does not skip sub jump locations.", 136, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 556 }, -{ PROC_LINKS(goto_first_jump_sticky, 0), "goto_first_jump_sticky", 22, "If a buffer containing jump locations has been locked in, goes to the first jump in the buffer.", 95, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 570 }, -{ PROC_LINKS(goto_first_jump_same_panel_sticky, 0), "goto_first_jump_same_panel_sticky", 33, "If a buffer containing jump locations has been locked in, goes to the first jump in the buffer and views the buffer in the panel where the jump list was.", 153, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 587 }, -{ PROC_LINKS(newline_or_goto_position_sticky, 0), "newline_or_goto_position_sticky", 31, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor.", 106, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 609 }, -{ PROC_LINKS(newline_or_goto_position_same_panel_sticky, 0), "newline_or_goto_position_same_panel_sticky", 42, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor_same_panel.", 117, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 624 }, +{ PROC_LINKS(goto_jump_at_cursor_same_panel_direct, 0), "goto_jump_at_cursor_same_panel_direct", 37, "If the cursor is found to be on a jump location, parses the jump location and brings up the file and position in this view, losing the compilation output or jump list..", 168, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 32 }, +{ PROC_LINKS(goto_next_jump_direct, 0), "goto_next_jump_direct", 21, "If a buffer containing jump locations has been locked in, goes to the next jump in the buffer, skipping sub jump locations.", 123, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 54 }, +{ PROC_LINKS(goto_prev_jump_direct, 0), "goto_prev_jump_direct", 21, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, skipping sub jump locations.", 127, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 63 }, +{ PROC_LINKS(goto_next_jump_no_skips_direct, 0), "goto_next_jump_no_skips_direct", 30, "If a buffer containing jump locations has been locked in, goes to the next jump in the buffer, and does not skip sub jump locations.", 132, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 72 }, +{ PROC_LINKS(goto_prev_jump_no_skips_direct, 0), "goto_prev_jump_no_skips_direct", 30, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, and does not skip sub jump locations.", 136, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 81 }, +{ PROC_LINKS(goto_first_jump_direct, 0), "goto_first_jump_direct", 22, "If a buffer containing jump locations has been locked in, goes to the first jump in the buffer.", 95, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 90 }, +{ PROC_LINKS(newline_or_goto_position_direct, 0), "newline_or_goto_position_direct", 31, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor.", 106, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 105 }, +{ PROC_LINKS(newline_or_goto_position_same_panel_direct, 0), "newline_or_goto_position_same_panel_direct", 42, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor_same_panel.", 117, "w:\\4ed\\code\\4coder_jump_direct.cpp", 34, 122 }, +{ PROC_LINKS(goto_jump_at_cursor_sticky, 0), "goto_jump_at_cursor_sticky", 26, "If the cursor is found to be on a jump location, parses the jump location and brings up the file and position in another view and changes the active panel to the view containing the jump.", 187, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 365 }, +{ PROC_LINKS(goto_jump_at_cursor_same_panel_sticky, 0), "goto_jump_at_cursor_same_panel_sticky", 37, "If the cursor is found to be on a jump location, parses the jump location and brings up the file and position in this view, losing the compilation output or jump list.", 167, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 393 }, +{ PROC_LINKS(goto_next_jump_sticky, 0), "goto_next_jump_sticky", 21, "If a buffer containing jump locations has been locked in, goes to the next jump in the buffer, skipping sub jump locations.", 123, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 494 }, +{ PROC_LINKS(goto_prev_jump_sticky, 0), "goto_prev_jump_sticky", 21, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, skipping sub jump locations.", 127, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 512 }, +{ PROC_LINKS(goto_next_jump_no_skips_sticky, 0), "goto_next_jump_no_skips_sticky", 30, "If a buffer containing jump locations has been locked in, goes to the next jump in the buffer, and does not skip sub jump locations.", 132, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 525 }, +{ PROC_LINKS(goto_prev_jump_no_skips_sticky, 0), "goto_prev_jump_no_skips_sticky", 30, "If a buffer containing jump locations has been locked in, goes to the previous jump in the buffer, and does not skip sub jump locations.", 136, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 543 }, +{ PROC_LINKS(goto_first_jump_sticky, 0), "goto_first_jump_sticky", 22, "If a buffer containing jump locations has been locked in, goes to the first jump in the buffer.", 95, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 557 }, +{ PROC_LINKS(goto_first_jump_same_panel_sticky, 0), "goto_first_jump_same_panel_sticky", 33, "If a buffer containing jump locations has been locked in, goes to the first jump in the buffer and views the buffer in the panel where the jump list was.", 153, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 574 }, +{ PROC_LINKS(newline_or_goto_position_sticky, 0), "newline_or_goto_position_sticky", 31, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor.", 106, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 596 }, +{ PROC_LINKS(newline_or_goto_position_same_panel_sticky, 0), "newline_or_goto_position_same_panel_sticky", 42, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor_same_panel.", 117, "w:\\4ed\\code\\4coder_jump_sticky.cpp", 34, 613 }, { PROC_LINKS(view_jump_list_with_lister, 0), "view_jump_list_with_lister", 26, "When executed on a buffer with jumps, creates a persistent lister for all the jumps", 83, "w:\\4ed\\code\\4coder_jump_lister.cpp", 34, 104 }, -{ PROC_LINKS(copy, 0), "copy", 4, "Copy the text in the range from the cursor to the mark onto the clipboard.", 74, "w:\\4ed\\code\\4coder_clipboard.cpp", 32, 24 }, -{ PROC_LINKS(cut, 0), "cut", 3, "Cut the text in the range from the cursor to the mark onto the clipboard.", 73, "w:\\4ed\\code\\4coder_clipboard.cpp", 32, 35 }, -{ PROC_LINKS(paste, 0), "paste", 5, "At the cursor, insert the text at the top of the clipboard.", 59, "w:\\4ed\\code\\4coder_clipboard.cpp", 32, 48 }, -{ PROC_LINKS(paste_next, 0), "paste_next", 10, "If the previous command was paste or paste_next, replaces the paste range with the next text down on the clipboard, otherwise operates as the paste command.", 156, "w:\\4ed\\code\\4coder_clipboard.cpp", 32, 87 }, -{ PROC_LINKS(paste_and_indent, 0), "paste_and_indent", 16, "Paste from the top of clipboard and run auto-indent on the newly pasted text.", 77, "w:\\4ed\\code\\4coder_clipboard.cpp", 32, 135 }, -{ PROC_LINKS(paste_next_and_indent, 0), "paste_next_and_indent", 21, "Paste the next item on the clipboard and run auto-indent on the newly pasted text.", 82, "w:\\4ed\\code\\4coder_clipboard.cpp", 32, 142 }, +{ PROC_LINKS(copy, 0), "copy", 4, "Copy the text in the range from the cursor to the mark onto the clipboard.", 74, "w:\\4ed\\code\\4coder_clipboard.cpp", 32, 23 }, +{ PROC_LINKS(cut, 0), "cut", 3, "Cut the text in the range from the cursor to the mark onto the clipboard.", 73, "w:\\4ed\\code\\4coder_clipboard.cpp", 32, 32 }, +{ PROC_LINKS(paste, 0), "paste", 5, "At the cursor, insert the text at the top of the clipboard.", 59, "w:\\4ed\\code\\4coder_clipboard.cpp", 32, 43 }, +{ PROC_LINKS(paste_next, 0), "paste_next", 10, "If the previous command was paste or paste_next, replaces the paste range with the next text down on the clipboard, otherwise operates as the paste command.", 156, "w:\\4ed\\code\\4coder_clipboard.cpp", 32, 77 }, +{ PROC_LINKS(paste_and_indent, 0), "paste_and_indent", 16, "Paste from the top of clipboard and run auto-indent on the newly pasted text.", 77, "w:\\4ed\\code\\4coder_clipboard.cpp", 32, 121 }, +{ PROC_LINKS(paste_next_and_indent, 0), "paste_next_and_indent", 21, "Paste the next item on the clipboard and run auto-indent on the newly pasted text.", 82, "w:\\4ed\\code\\4coder_clipboard.cpp", 32, 128 }, { PROC_LINKS(execute_previous_cli, 0), "execute_previous_cli", 20, "If the command execute_any_cli has already been used, this will execute a CLI reusing the most recent buffer name and command.", 126, "w:\\4ed\\code\\4coder_system_command.cpp", 37, 7 }, -{ PROC_LINKS(execute_any_cli, 0), "execute_any_cli", 15, "Queries for an output buffer name and system command, runs the system command as a CLI and prints the output to the specified buffer.", 133, "w:\\4ed\\code\\4coder_system_command.cpp", 37, 23 }, +{ PROC_LINKS(execute_any_cli, 0), "execute_any_cli", 15, "Queries for an output buffer name and system command, runs the system command as a CLI and prints the output to the specified buffer.", 133, "w:\\4ed\\code\\4coder_system_command.cpp", 37, 22 }, { PROC_LINKS(build_search, 0), "build_search", 12, "Looks for a build.bat, build.sh, or makefile in the current and parent directories. Runs the first that it finds and prints the output to *compilation*.", 153, "w:\\4ed\\code\\4coder_build_commands.cpp", 37, 128 }, -{ PROC_LINKS(build_in_build_panel, 0), "build_in_build_panel", 20, "Looks for a build.bat, build.sh, or makefile in the current and parent directories. Runs the first that it finds and prints the output to *compilation*. Puts the *compilation* buffer in a panel at the footer of the current view.", 230, "w:\\4ed\\code\\4coder_build_commands.cpp", 37, 166 }, -{ PROC_LINKS(close_build_panel, 0), "close_build_panel", 17, "If the special build panel is open, closes it.", 46, "w:\\4ed\\code\\4coder_build_commands.cpp", 37, 183 }, -{ PROC_LINKS(change_to_build_panel, 0), "change_to_build_panel", 21, "If the special build panel is open, makes the build panel the active panel.", 75, "w:\\4ed\\code\\4coder_build_commands.cpp", 37, 189 }, -{ PROC_LINKS(close_all_code, 0), "close_all_code", 14, "Closes any buffer with a filename ending with an extension configured to be recognized as a code file type.", 107, "w:\\4ed\\code\\4coder_project_commands.cpp", 39, 931 }, -{ PROC_LINKS(open_all_code, 0), "open_all_code", 13, "Open all code in the current directory. File types are determined by extensions. An extension is considered code based on the extensions specified in 4coder.config.", 164, "w:\\4ed\\code\\4coder_project_commands.cpp", 39, 937 }, -{ PROC_LINKS(open_all_code_recursive, 0), "open_all_code_recursive", 23, "Works as open_all_code but also runs in all subdirectories.", 59, "w:\\4ed\\code\\4coder_project_commands.cpp", 39, 943 }, -{ PROC_LINKS(load_project, 0), "load_project", 12, "Looks for a project.4coder file in the current directory and tries to load it. Looks in parent directories until a project file is found or there are no more parents.", 167, "w:\\4ed\\code\\4coder_project_commands.cpp", 39, 951 }, -{ PROC_LINKS(project_fkey_command, 0), "project_fkey_command", 20, "Run an 'fkey command' configured in a project.4coder file. Determines the index of the 'fkey command' by which function key or numeric key was pressed to trigger the command.", 175, "w:\\4ed\\code\\4coder_project_commands.cpp", 39, 958 }, -{ PROC_LINKS(project_go_to_root_directory, 0), "project_go_to_root_directory", 28, "Changes 4coder's hot directory to the root directory of the currently loaded project. With no loaded project nothing hapepns.", 125, "w:\\4ed\\code\\4coder_project_commands.cpp", 39, 981 }, -{ PROC_LINKS(setup_new_project, 0), "setup_new_project", 17, "Queries the user for several configuration options and initializes a new 4coder project with build scripts for every OS.", 120, "w:\\4ed\\code\\4coder_project_commands.cpp", 39, 1316 }, -{ PROC_LINKS(setup_build_bat, 0), "setup_build_bat", 15, "Queries the user for several configuration options and initializes a new build batch script.", 92, "w:\\4ed\\code\\4coder_project_commands.cpp", 39, 1323 }, -{ PROC_LINKS(setup_build_sh, 0), "setup_build_sh", 14, "Queries the user for several configuration options and initializes a new build shell script.", 92, "w:\\4ed\\code\\4coder_project_commands.cpp", 39, 1329 }, -{ PROC_LINKS(setup_build_bat_and_sh, 0), "setup_build_bat_and_sh", 22, "Queries the user for several configuration options and initializes a new build batch script.", 92, "w:\\4ed\\code\\4coder_project_commands.cpp", 39, 1335 }, -{ PROC_LINKS(project_command_lister, 0), "project_command_lister", 22, "Open a lister of all commands in the currently loaded project.", 62, "w:\\4ed\\code\\4coder_project_commands.cpp", 39, 1350 }, -{ PROC_LINKS(list_all_functions_current_buffer, 0), "list_all_functions_current_buffer", 33, "Creates a jump list of lines of the current buffer that appear to define or declare functions.", 94, "w:\\4ed\\code\\4coder_function_list.cpp", 36, 273 }, -{ PROC_LINKS(list_all_functions_current_buffer_lister, 0), "list_all_functions_current_buffer_lister", 40, "Creates a lister of locations that look like function definitions and declarations in the buffer.", 97, "w:\\4ed\\code\\4coder_function_list.cpp", 36, 285 }, -{ PROC_LINKS(list_all_functions_all_buffers, 0), "list_all_functions_all_buffers", 30, "Creates a jump list of lines from all buffers that appear to define or declare functions.", 89, "w:\\4ed\\code\\4coder_function_list.cpp", 36, 299 }, -{ PROC_LINKS(list_all_functions_all_buffers_lister, 0), "list_all_functions_all_buffers_lister", 37, "Creates a lister of locations that look like function definitions and declarations all buffers.", 95, "w:\\4ed\\code\\4coder_function_list.cpp", 36, 305 }, -{ PROC_LINKS(select_surrounding_scope, 0), "select_surrounding_scope", 24, "Finds the scope enclosed by '{' '}' surrounding the cursor and puts the cursor and mark on the '{' and '}'.", 107, "w:\\4ed\\code\\4coder_scope_commands.cpp", 37, 339 }, -{ PROC_LINKS(select_next_scope_absolute, 0), "select_next_scope_absolute", 26, "Finds the first scope started by '{' after the cursor and puts the cursor and mark on the '{' and '}'.", 102, "w:\\4ed\\code\\4coder_scope_commands.cpp", 37, 357 }, -{ PROC_LINKS(select_prev_scope_absolute, 0), "select_prev_scope_absolute", 26, "Finds the first scope started by '{' before the cursor and puts the cursor and mark on the '{' and '}'.", 103, "w:\\4ed\\code\\4coder_scope_commands.cpp", 37, 379 }, -{ PROC_LINKS(place_in_scope, 0), "place_in_scope", 14, "Wraps the code contained in the range between cursor and mark with a new curly brace scope.", 91, "w:\\4ed\\code\\4coder_scope_commands.cpp", 37, 475 }, -{ PROC_LINKS(delete_current_scope, 0), "delete_current_scope", 20, "Deletes the braces surrounding the currently selected scope. Leaves the contents within the scope.", 99, "w:\\4ed\\code\\4coder_scope_commands.cpp", 37, 481 }, -{ PROC_LINKS(scope_absorb_down, 0), "scope_absorb_down", 17, "If a scope is currently selected, and a statement or block statement is present below the current scope, the statement is moved into the scope.", 143, "w:\\4ed\\code\\4coder_scope_commands.cpp", 37, 715 }, -{ PROC_LINKS(open_long_braces, 0), "open_long_braces", 16, "At the cursor, insert a '{' and '}' separated by a blank line.", 62, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 52 }, -{ PROC_LINKS(open_long_braces_semicolon, 0), "open_long_braces_semicolon", 26, "At the cursor, insert a '{' and '};' separated by a blank line.", 63, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 60 }, -{ PROC_LINKS(open_long_braces_break, 0), "open_long_braces_break", 22, "At the cursor, insert a '{' and '}break;' separated by a blank line.", 68, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 68 }, -{ PROC_LINKS(if0_off, 0), "if0_off", 7, "Surround the range between the cursor and mark with an '#if 0' and an '#endif'", 78, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 76 }, -{ PROC_LINKS(write_todo, 0), "write_todo", 10, "At the cursor, insert a '// TODO' comment, includes user name if it was specified in config.4coder.", 99, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 82 }, -{ PROC_LINKS(write_hack, 0), "write_hack", 10, "At the cursor, insert a '// HACK' comment, includes user name if it was specified in config.4coder.", 99, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 88 }, -{ PROC_LINKS(write_note, 0), "write_note", 10, "At the cursor, insert a '// NOTE' comment, includes user name if it was specified in config.4coder.", 99, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 94 }, -{ PROC_LINKS(write_block, 0), "write_block", 11, "At the cursor, insert a block comment.", 38, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 100 }, -{ PROC_LINKS(write_zero_struct, 0), "write_zero_struct", 17, "At the cursor, insert a ' = {};'.", 33, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 106 }, -{ PROC_LINKS(comment_line, 0), "comment_line", 12, "Insert '//' at the beginning of the line after leading whitespace.", 66, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 133 }, -{ PROC_LINKS(uncomment_line, 0), "uncomment_line", 14, "If present, delete '//' at the beginning of the line after leading whitespace.", 78, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 147 }, -{ PROC_LINKS(comment_line_toggle, 0), "comment_line_toggle", 19, "Turns uncommented lines into commented lines and vice versa for comments starting with '//'.", 92, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 161 }, -{ PROC_LINKS(snippet_lister, 0), "snippet_lister", 14, "Opens a snippet lister for inserting whole pre-written snippets of text.", 72, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 250 }, +{ PROC_LINKS(build_in_build_panel, 0), "build_in_build_panel", 20, "Looks for a build.bat, build.sh, or makefile in the current and parent directories. Runs the first that it finds and prints the output to *compilation*. Puts the *compilation* buffer in a panel at the footer of the current view.", 230, "w:\\4ed\\code\\4coder_build_commands.cpp", 37, 162 }, +{ PROC_LINKS(close_build_panel, 0), "close_build_panel", 17, "If the special build panel is open, closes it.", 46, "w:\\4ed\\code\\4coder_build_commands.cpp", 37, 177 }, +{ PROC_LINKS(change_to_build_panel, 0), "change_to_build_panel", 21, "If the special build panel is open, makes the build panel the active panel.", 75, "w:\\4ed\\code\\4coder_build_commands.cpp", 37, 183 }, +{ PROC_LINKS(close_all_code, 0), "close_all_code", 14, "Closes any buffer with a filename ending with an extension configured to be recognized as a code file type.", 107, "w:\\4ed\\code\\4coder_project_commands.cpp", 39, 929 }, +{ PROC_LINKS(open_all_code, 0), "open_all_code", 13, "Open all code in the current directory. File types are determined by extensions. An extension is considered code based on the extensions specified in 4coder.config.", 164, "w:\\4ed\\code\\4coder_project_commands.cpp", 39, 935 }, +{ PROC_LINKS(open_all_code_recursive, 0), "open_all_code_recursive", 23, "Works as open_all_code but also runs in all subdirectories.", 59, "w:\\4ed\\code\\4coder_project_commands.cpp", 39, 941 }, +{ PROC_LINKS(load_project, 0), "load_project", 12, "Looks for a project.4coder file in the current directory and tries to load it. Looks in parent directories until a project file is found or there are no more parents.", 167, "w:\\4ed\\code\\4coder_project_commands.cpp", 39, 949 }, +{ PROC_LINKS(project_fkey_command, 0), "project_fkey_command", 20, "Run an 'fkey command' configured in a project.4coder file. Determines the index of the 'fkey command' by which function key or numeric key was pressed to trigger the command.", 175, "w:\\4ed\\code\\4coder_project_commands.cpp", 39, 956 }, +{ PROC_LINKS(project_go_to_root_directory, 0), "project_go_to_root_directory", 28, "Changes 4coder's hot directory to the root directory of the currently loaded project. With no loaded project nothing hapepns.", 125, "w:\\4ed\\code\\4coder_project_commands.cpp", 39, 979 }, +{ PROC_LINKS(setup_new_project, 0), "setup_new_project", 17, "Queries the user for several configuration options and initializes a new 4coder project with build scripts for every OS.", 120, "w:\\4ed\\code\\4coder_project_commands.cpp", 39, 1314 }, +{ PROC_LINKS(setup_build_bat, 0), "setup_build_bat", 15, "Queries the user for several configuration options and initializes a new build batch script.", 92, "w:\\4ed\\code\\4coder_project_commands.cpp", 39, 1321 }, +{ PROC_LINKS(setup_build_sh, 0), "setup_build_sh", 14, "Queries the user for several configuration options and initializes a new build shell script.", 92, "w:\\4ed\\code\\4coder_project_commands.cpp", 39, 1327 }, +{ PROC_LINKS(setup_build_bat_and_sh, 0), "setup_build_bat_and_sh", 22, "Queries the user for several configuration options and initializes a new build batch script.", 92, "w:\\4ed\\code\\4coder_project_commands.cpp", 39, 1333 }, +{ PROC_LINKS(project_command_lister, 0), "project_command_lister", 22, "Open a lister of all commands in the currently loaded project.", 62, "w:\\4ed\\code\\4coder_project_commands.cpp", 39, 1348 }, +{ PROC_LINKS(list_all_functions_current_buffer, 0), "list_all_functions_current_buffer", 33, "Creates a jump list of lines of the current buffer that appear to define or declare functions.", 94, "w:\\4ed\\code\\4coder_function_list.cpp", 36, 269 }, +{ PROC_LINKS(list_all_functions_current_buffer_lister, 0), "list_all_functions_current_buffer_lister", 40, "Creates a lister of locations that look like function definitions and declarations in the buffer.", 97, "w:\\4ed\\code\\4coder_function_list.cpp", 36, 279 }, +{ PROC_LINKS(list_all_functions_all_buffers, 0), "list_all_functions_all_buffers", 30, "Creates a jump list of lines from all buffers that appear to define or declare functions.", 89, "w:\\4ed\\code\\4coder_function_list.cpp", 36, 291 }, +{ PROC_LINKS(list_all_functions_all_buffers_lister, 0), "list_all_functions_all_buffers_lister", 37, "Creates a lister of locations that look like function definitions and declarations all buffers.", 95, "w:\\4ed\\code\\4coder_function_list.cpp", 36, 297 }, +{ PROC_LINKS(select_surrounding_scope, 0), "select_surrounding_scope", 24, "Finds the scope enclosed by '{' '}' surrounding the cursor and puts the cursor and mark on the '{' and '}'.", 107, "w:\\4ed\\code\\4coder_scope_commands.cpp", 37, 338 }, +{ PROC_LINKS(select_next_scope_absolute, 0), "select_next_scope_absolute", 26, "Finds the first scope started by '{' after the cursor and puts the cursor and mark on the '{' and '}'.", 102, "w:\\4ed\\code\\4coder_scope_commands.cpp", 37, 353 }, +{ PROC_LINKS(select_prev_scope_absolute, 0), "select_prev_scope_absolute", 26, "Finds the first scope started by '{' before the cursor and puts the cursor and mark on the '{' and '}'.", 103, "w:\\4ed\\code\\4coder_scope_commands.cpp", 37, 372 }, +{ PROC_LINKS(place_in_scope, 0), "place_in_scope", 14, "Wraps the code contained in the range between cursor and mark with a new curly brace scope.", 91, "w:\\4ed\\code\\4coder_scope_commands.cpp", 37, 462 }, +{ PROC_LINKS(delete_current_scope, 0), "delete_current_scope", 20, "Deletes the braces surrounding the currently selected scope. Leaves the contents within the scope.", 99, "w:\\4ed\\code\\4coder_scope_commands.cpp", 37, 468 }, +{ PROC_LINKS(scope_absorb_down, 0), "scope_absorb_down", 17, "If a scope is currently selected, and a statement or block statement is present below the current scope, the statement is moved into the scope.", 143, "w:\\4ed\\code\\4coder_scope_commands.cpp", 37, 691 }, +{ PROC_LINKS(open_long_braces, 0), "open_long_braces", 16, "At the cursor, insert a '{' and '}' separated by a blank line.", 62, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 46 }, +{ PROC_LINKS(open_long_braces_semicolon, 0), "open_long_braces_semicolon", 26, "At the cursor, insert a '{' and '};' separated by a blank line.", 63, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 54 }, +{ PROC_LINKS(open_long_braces_break, 0), "open_long_braces_break", 22, "At the cursor, insert a '{' and '}break;' separated by a blank line.", 68, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 62 }, +{ PROC_LINKS(if0_off, 0), "if0_off", 7, "Surround the range between the cursor and mark with an '#if 0' and an '#endif'", 78, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 70 }, +{ PROC_LINKS(write_todo, 0), "write_todo", 10, "At the cursor, insert a '// TODO' comment, includes user name if it was specified in config.4coder.", 99, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 76 }, +{ PROC_LINKS(write_hack, 0), "write_hack", 10, "At the cursor, insert a '// HACK' comment, includes user name if it was specified in config.4coder.", 99, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 82 }, +{ PROC_LINKS(write_note, 0), "write_note", 10, "At the cursor, insert a '// NOTE' comment, includes user name if it was specified in config.4coder.", 99, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 88 }, +{ PROC_LINKS(write_block, 0), "write_block", 11, "At the cursor, insert a block comment.", 38, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 94 }, +{ PROC_LINKS(write_zero_struct, 0), "write_zero_struct", 17, "At the cursor, insert a ' = {};'.", 33, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 100 }, +{ PROC_LINKS(comment_line, 0), "comment_line", 12, "Insert '//' at the beginning of the line after leading whitespace.", 66, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 126 }, +{ PROC_LINKS(uncomment_line, 0), "uncomment_line", 14, "If present, delete '//' at the beginning of the line after leading whitespace.", 78, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 138 }, +{ PROC_LINKS(comment_line_toggle, 0), "comment_line_toggle", 19, "Turns uncommented lines into commented lines and vice versa for comments starting with '//'.", 92, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 150 }, +{ PROC_LINKS(snippet_lister, 0), "snippet_lister", 14, "Opens a snippet lister for inserting whole pre-written snippets of text.", 72, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 234 }, { PROC_LINKS(set_bindings_choose, 0), "set_bindings_choose", 19, "Remap keybindings using the 'choose' mapping rule.", 50, "w:\\4ed\\code\\4coder_remapping_commands.cpp", 41, 39 }, { PROC_LINKS(set_bindings_default, 0), "set_bindings_default", 20, "Remap keybindings using the 'default' mapping rule.", 51, "w:\\4ed\\code\\4coder_remapping_commands.cpp", 41, 49 }, { PROC_LINKS(set_bindings_mac_default, 0), "set_bindings_mac_default", 24, "Remap keybindings using the 'mac-default' mapping rule.", 55, "w:\\4ed\\code\\4coder_remapping_commands.cpp", 41, 64 }, { PROC_LINKS(miblo_increment_basic, 0), "miblo_increment_basic", 21, "Increment an integer under the cursor by one.", 45, "w:\\4ed\\code\\4coder_miblo_numbers.cpp", 36, 95 }, -{ PROC_LINKS(miblo_decrement_basic, 0), "miblo_decrement_basic", 21, "Decrement an integer under the cursor by one.", 45, "w:\\4ed\\code\\4coder_miblo_numbers.cpp", 36, 113 }, -{ PROC_LINKS(miblo_increment_time_stamp, 0), "miblo_increment_time_stamp", 26, "Increment a time stamp under the cursor by one second. (format [m]m:ss or h:mm:ss", 81, "w:\\4ed\\code\\4coder_miblo_numbers.cpp", 36, 383 }, -{ PROC_LINKS(miblo_decrement_time_stamp, 0), "miblo_decrement_time_stamp", 26, "Decrement a time stamp under the cursor by one second. (format [m]m:ss or h:mm:ss", 81, "w:\\4ed\\code\\4coder_miblo_numbers.cpp", 36, 389 }, -{ PROC_LINKS(miblo_increment_time_stamp_minute, 0), "miblo_increment_time_stamp_minute", 33, "Increment a time stamp under the cursor by one minute. (format [m]m:ss or h:mm:ss", 81, "w:\\4ed\\code\\4coder_miblo_numbers.cpp", 36, 395 }, -{ PROC_LINKS(miblo_decrement_time_stamp_minute, 0), "miblo_decrement_time_stamp_minute", 33, "Decrement a time stamp under the cursor by one minute. (format [m]m:ss or h:mm:ss", 81, "w:\\4ed\\code\\4coder_miblo_numbers.cpp", 36, 401 }, -{ PROC_LINKS(kill_rect, 0), "kill_rect", 9, "Delete characters in a rectangular region. Range testing is done by unwrapped-xy coordinates.", 93, "w:\\4ed\\code\\4coder_experiments.cpp", 34, 50 }, -{ PROC_LINKS(multi_line_edit, 0), "multi_line_edit", 15, "Begin multi-line mode. In multi-line mode characters are inserted at every line between the mark and cursor. All characters are inserted at the same character offset into the line. This mode uses line_char coordinates.", 221, "w:\\4ed\\code\\4coder_experiments.cpp", 34, 137 }, -{ PROC_LINKS(rename_parameter, 0), "rename_parameter", 16, "If the cursor is found to be on the name of a function parameter in the signature of a function definition, all occurences within the scope of the function will be replaced with a new provided string.", 200, "w:\\4ed\\code\\4coder_experiments.cpp", 34, 424 }, -{ PROC_LINKS(write_explicit_enum_values, 0), "write_explicit_enum_values", 26, "If the cursor is found to be on the '{' of an enum definition, the values of the enum will be filled in sequentially starting from zero. Existing values are overwritten.", 170, "w:\\4ed\\code\\4coder_experiments.cpp", 34, 733 }, -{ PROC_LINKS(write_explicit_enum_flags, 0), "write_explicit_enum_flags", 25, "If the cursor is found to be on the '{' of an enum definition, the values of the enum will be filled in to give each a unique power of 2 value, starting from 1. Existing values are overwritten.", 194, "w:\\4ed\\code\\4coder_experiments.cpp", 34, 739 }, +{ PROC_LINKS(miblo_decrement_basic, 0), "miblo_decrement_basic", 21, "Decrement an integer under the cursor by one.", 45, "w:\\4ed\\code\\4coder_miblo_numbers.cpp", 36, 110 }, +{ PROC_LINKS(miblo_increment_time_stamp, 0), "miblo_increment_time_stamp", 26, "Increment a time stamp under the cursor by one second. (format [m]m:ss or h:mm:ss", 81, "w:\\4ed\\code\\4coder_miblo_numbers.cpp", 36, 374 }, +{ PROC_LINKS(miblo_decrement_time_stamp, 0), "miblo_decrement_time_stamp", 26, "Decrement a time stamp under the cursor by one second. (format [m]m:ss or h:mm:ss", 81, "w:\\4ed\\code\\4coder_miblo_numbers.cpp", 36, 380 }, +{ PROC_LINKS(miblo_increment_time_stamp_minute, 0), "miblo_increment_time_stamp_minute", 33, "Increment a time stamp under the cursor by one minute. (format [m]m:ss or h:mm:ss", 81, "w:\\4ed\\code\\4coder_miblo_numbers.cpp", 36, 386 }, +{ PROC_LINKS(miblo_decrement_time_stamp_minute, 0), "miblo_decrement_time_stamp_minute", 33, "Decrement a time stamp under the cursor by one minute. (format [m]m:ss or h:mm:ss", 81, "w:\\4ed\\code\\4coder_miblo_numbers.cpp", 36, 392 }, +{ PROC_LINKS(kill_rect, 0), "kill_rect", 9, "Delete characters in a rectangular region. Range testing is done by unwrapped-xy coordinates.", 93, "w:\\4ed\\code\\4coder_experiments.cpp", 34, 47 }, +{ PROC_LINKS(multi_line_edit, 0), "multi_line_edit", 15, "Begin multi-line mode. In multi-line mode characters are inserted at every line between the mark and cursor. All characters are inserted at the same character offset into the line. This mode uses line_char coordinates.", 221, "w:\\4ed\\code\\4coder_experiments.cpp", 34, 127 }, +{ PROC_LINKS(rename_parameter, 0), "rename_parameter", 16, "If the cursor is found to be on the name of a function parameter in the signature of a function definition, all occurences within the scope of the function will be replaced with a new provided string.", 200, "w:\\4ed\\code\\4coder_experiments.cpp", 34, 395 }, +{ PROC_LINKS(write_explicit_enum_values, 0), "write_explicit_enum_values", 26, "If the cursor is found to be on the '{' of an enum definition, the values of the enum will be filled in sequentially starting from zero. Existing values are overwritten.", 170, "w:\\4ed\\code\\4coder_experiments.cpp", 34, 702 }, +{ PROC_LINKS(write_explicit_enum_flags, 0), "write_explicit_enum_flags", 25, "If the cursor is found to be on the '{' of an enum definition, the values of the enum will be filled in to give each a unique power of 2 value, starting from 1. Existing values are overwritten.", 194, "w:\\4ed\\code\\4coder_experiments.cpp", 34, 708 }, }; static int32_t fcoder_metacmd_ID_replace_all_occurrences = 0; static int32_t fcoder_metacmd_ID_seek_beginning_of_textual_line = 1; diff --git a/4coder_helper.cpp b/4coder_helper.cpp index 4eae5d04..2e96b95c 100644 --- a/4coder_helper.cpp +++ b/4coder_helper.cpp @@ -279,6 +279,28 @@ get_key_code(char *buffer){ //////////////////////////////// +static Buffer_Seek +seek_location(ID_Line_Column_Jump_Location location){ + return(seek_line_char(location.line, location.column)); +} + +static Buffer_Seek +seek_location(ID_Pos_Jump_Location location){ + return(seek_pos(location.pos)); +} + +static Buffer_Seek +seek_location(Name_Line_Column_Location location){ + return(seek_line_char(location.line, location.column)); +} + +static Buffer_Seek +seek_jump(Parsed_Jump jump){ + return(seek_location(jump.location)); +} + +//////////////////////////////// + internal Character_Predicate character_predicate_from_function(Character_Predicate_Function *func){ Character_Predicate predicate = {}; @@ -393,41 +415,28 @@ push_4ed_path(Application_Links *app, Arena *arena){ return(result); } -static String_Const_u8 -push_buffer_base_name(Application_Links *app, Arena *arena, Buffer_ID buffer){ - String_Const_u8 result = {}; - buffer_get_base_buffer_name(app, buffer, arena, &result); - return(result); -} - -static String_Const_u8 -push_buffer_unique_name(Application_Links *app, Arena *arena, Buffer_ID buffer){ - String_Const_u8 result = {}; - buffer_get_unique_buffer_name(app, buffer, arena, &result); - return(result); -} - -static String_Const_u8 -push_buffer_file_name(Application_Links *app, Arena *arena, Buffer_ID buffer){ - String_Const_u8 result = {}; - buffer_get_file_name(app, buffer, arena, &result); - return(result); -} - //////////////////////////////// +static Range_u64 +buffer_range(Application_Links *app, Buffer_ID buffer){ + Range_u64 range = {}; + range.end = buffer_get_size(app, buffer); + return(range); +} + +static u64 +buffer_side(Application_Links *app, Buffer_ID buffer, Side side){ + return(range_side(buffer_range(app, buffer), side)); +} + static Range get_view_range(Application_Links *app, View_ID view){ - Range range = {}; - view_get_cursor_pos(app, view, &range.first); - view_get_mark_pos(app, view, &range.one_past_last); - return(rectify(range)); + return(make_range(view_get_cursor_pos(app, view), view_get_mark_pos(app, view))); } static f32 get_view_y(Application_Links *app, View_ID view){ - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + i32 pos = view_get_cursor_pos(app, view); Full_Cursor cursor = {}; view_compute_cursor(app, view, seek_pos(pos), &cursor); return(cursor.wrapped_y); @@ -435,8 +444,7 @@ get_view_y(Application_Links *app, View_ID view){ static f32 get_view_x(Application_Links *app, View_ID view){ - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + i32 pos = view_get_cursor_pos(app, view); Full_Cursor cursor = {}; view_compute_cursor(app, view, seek_pos(pos), &cursor); return(cursor.wrapped_x); @@ -444,22 +452,19 @@ get_view_x(Application_Links *app, View_ID view){ static b32 is_valid_line(Application_Links *app, Buffer_ID buffer_id, i32 line){ - i32 max_line = 0; - buffer_get_line_count(app, buffer_id, &max_line); + i32 max_line = (i32)buffer_get_line_count(app, buffer_id); return(1 <= line && line <= max_line); } static b32 is_valid_line_range(Application_Links *app, Buffer_ID buffer_id, Range range){ - i32 max_line = 0; - buffer_get_line_count(app, buffer_id, &max_line); + i32 max_line = (i32)buffer_get_line_count(app, buffer_id); return(1 <= range.first && range.first <= range.end && range.end <= max_line); } static i32 get_line_number_from_pos(Application_Links *app, Buffer_ID buffer, i32 pos){ - Partial_Cursor partial_cursor = {}; - buffer_compute_cursor(app, buffer, seek_pos(pos), &partial_cursor); + Partial_Cursor partial_cursor = buffer_compute_cursor(app, buffer, seek_pos(pos)); return(partial_cursor.line); } @@ -475,22 +480,14 @@ character_pos_to_pos_view(Application_Links *app, View_ID view, i32 character_po static i32 character_pos_to_pos_buffer(Application_Links *app, Buffer_ID buffer, i32 character_pos){ - i32 result = 0; - Partial_Cursor cursor = {}; - if (buffer_compute_cursor(app, buffer, seek_character_pos(character_pos), &cursor)){ - result = cursor.pos; - } - return(result); + Partial_Cursor cursor = buffer_compute_cursor(app, buffer, seek_character_pos(character_pos)); + return(cursor.pos); } static Partial_Cursor get_line_side(Application_Links *app, Buffer_ID buffer, i32 line_number, Side side){ - Partial_Cursor result = {}; i32 character_index = (side == Side_Min)?(1):(-1); - if (!buffer_compute_cursor(app, buffer, seek_line_char(line_number, character_index), &result)){ - block_zero_struct(&result); - } - return(result); + return(buffer_compute_cursor(app, buffer, seek_line_char(line_number, character_index))); } static i32 get_line_side_pos(Application_Links *app, Buffer_ID buffer, i32 line_number, Side side){ @@ -626,8 +623,7 @@ static i32 scan(Application_Links *app, Boundary_Function_List funcs, Buffer_ID buffer, Scan_Direction direction, i32 start_pos){ i32 result = 0; if (direction == Scan_Forward){ - i32 size = 0; - buffer_get_size(app, buffer, &size); + i32 size = (i32)buffer_get_size(app, buffer); result = size + 1; for (Boundary_Function_Node *node = funcs.first; node != 0; @@ -746,15 +742,11 @@ boundary_token(Application_Links *app, Buffer_ID buffer, Side side, Scan_Directi result = boundary_non_whitespace(app, buffer, side, direction, pos); } else{ - Cpp_Token *first_token = 0; - Cpp_Token *last_token = 0; - buffer_get_token_range(app, buffer, &first_token, &last_token); - Cpp_Token_Array tokens = {first_token, (i32)(last_token - first_token)}; + Cpp_Token_Array tokens = buffer_get_token_array(app, buffer); switch (direction){ case Scan_Forward: { - i32 buffer_size = 0; - buffer_get_size(app, buffer, &buffer_size); + i32 buffer_size = (i32)buffer_get_size(app, buffer); if (tokens.count > 0){ Cpp_Token *token = get_first_token_from_pos(tokens, pos); if (token != 0){ @@ -853,7 +845,7 @@ boundary_line(Application_Links *app, Buffer_ID buffer, Side side, Scan_Directio else if (direction == Scan_Forward && new_pos <= pos){ new_pos = get_line_side_pos(app, buffer, line_number + 1, side); if (new_pos <= pos){ - buffer_get_size(app, buffer, &new_pos); + new_pos = (i32)buffer_get_size(app, buffer); } } return(new_pos); @@ -873,35 +865,38 @@ buffer_seek_delimiter_backward(Application_Links *app, Buffer_ID buffer, i32 pos buffer_seek_character_class(app, buffer, &predicate, Scan_Backward, pos, result); } +// TODO(allen): these need a little more rewrite static void buffer_seek_string_forward(Application_Links *app, Buffer_ID buffer, i32 pos, i32 end, String_Const_u8 needle, i32 *result){ if (end == 0){ - buffer_get_size(app, buffer, &end); + end = (i32)buffer_get_size(app, buffer); } - b32 case_sensitive = false; - b32 finding_matches = false; - do{ - finding_matches = - buffer_seek_string(app, buffer, needle, Scan_Forward, pos, &pos, &case_sensitive); - } while(!case_sensitive && pos < end && finding_matches); - if (pos < end && finding_matches){ - *result = pos; + String_Match match = {}; + match.range.first = pos; + for (;;){ + match = buffer_seek_string(app, buffer, needle, Scan_Forward, (i32)match.range.first); + if (HasFlag(match.flags, StringMatch_CaseSensitive) || + match.buffer != buffer || match.range.first >= end) break; + } + if (match.range.first < end && match.buffer == buffer){ + *result = (i32)match.range.first; } else{ - buffer_get_size(app, buffer, result); + *result = (i32)buffer_get_size(app, buffer); } } static void buffer_seek_string_backward(Application_Links *app, Buffer_ID buffer, i32 pos, i32 min, String_Const_u8 needle, i32 *result){ - b32 case_sensitive = false; - b32 finding_matches = false; - do{ - finding_matches = - buffer_seek_string(app, buffer, needle, Scan_Backward, pos, &pos, &case_sensitive); - } while(!case_sensitive && pos >= min && finding_matches); - if (pos >= min && finding_matches){ - *result = pos; + String_Match match = {}; + match.range.first = pos; + for (;;){ + match = buffer_seek_string(app, buffer, needle, Scan_Backward, (i32)match.range.first); + if (HasFlag(match.flags, StringMatch_CaseSensitive) || + match.buffer != buffer || match.range.first < min) break; + } + if (match.range.first >= min && match.buffer != buffer){ + *result = (i32)match.range.first; } else{ *result = -1; @@ -911,28 +906,22 @@ buffer_seek_string_backward(Application_Links *app, Buffer_ID buffer, i32 pos, i static void buffer_seek_string_insensitive_forward(Application_Links *app, Buffer_ID buffer, i32 pos, i32 end, String_Const_u8 needle, i32 *result){ if (end == 0){ - buffer_get_size(app, buffer, &end); + end = (i32)buffer_get_size(app, buffer); } - b32 finding_matches = false; - b32 case_sensitive = false; - finding_matches = - buffer_seek_string(app, buffer, needle, Scan_Forward, pos, &pos, &case_sensitive); - if (pos < end && finding_matches){ - *result = pos; + String_Match match = buffer_seek_string(app, buffer, needle, Scan_Forward, pos); + if (match.range.first < end && match.buffer == buffer){ + *result = (i32)match.range.first; } else{ - buffer_get_size(app, buffer, result); + *result = (i32)buffer_get_size(app, buffer); } } static void buffer_seek_string_insensitive_backward(Application_Links *app, Buffer_ID buffer, i32 pos, i32 min, String_Const_u8 needle, i32 *result){ - b32 finding_matches = false; - b32 case_sensitive = false; - finding_matches = - buffer_seek_string(app, buffer, needle, Scan_Backward, pos, &pos, &case_sensitive); - if (pos >= min && finding_matches){ - *result = pos; + String_Match match = buffer_seek_string(app, buffer, needle, Scan_Backward, pos); + if (match.range.first >= min && match.buffer != buffer){ + *result = (i32)match.range.first; } else{ *result = -1; @@ -1046,8 +1035,7 @@ pos_range_enclose_whole_lines(Application_Links *app, Buffer_ID buffer, Range ra static Range get_snipe_range(Application_Links *app, Boundary_Function_List funcs, Buffer_ID buffer, i32 pos, Scan_Direction direction){ Range result = {}; - i32 buffer_size = 0; - buffer_get_size(app, buffer, &buffer_size); + i32 buffer_size = (i32)buffer_get_size(app, buffer); i32 pos0 = pos; i32 pos1 = scan(app, funcs, buffer, direction, pos0); if (0 <= pos1 && pos1 <= buffer_size){ @@ -1074,7 +1062,7 @@ get_snipe_range(Application_Links *app, Boundary_Function *func, Buffer_ID buffe //////////////////////////////// static String_Const_u8 -push_buffer_range(Application_Links *app, Arena *arena, Buffer_ID buffer, umem first, umem one_past_last){ +push_buffer_range(Application_Links *app, Arena *arena, Buffer_ID buffer, u64 first, u64 one_past_last){ String_Const_u8 result = {}; if (first <= one_past_last){ umem length = one_past_last - first; @@ -1112,15 +1100,12 @@ push_buffer_line(Application_Links *app, Arena *arena, Buffer_ID buffer, i32 lin static String_Const_u8 push_whole_buffer(Application_Links *app, Arena *arena, Buffer_ID buffer){ - i32 size = 0; - buffer_get_size(app, buffer, &size); - return(push_buffer_range(app, arena, buffer, 0, size)); + return(push_buffer_range(app, arena, buffer, buffer_range(app, buffer))); } static String_Const_u8 push_string_in_view_range(Application_Links *app, Arena *arena, View_ID view){ - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessProtected, &buffer); + Buffer_ID buffer = view_get_buffer(app, view, AccessProtected); return(push_buffer_range(app, arena, buffer, get_view_range(app, view))); } @@ -1141,8 +1126,7 @@ buffer_has_name_with_star(Application_Links *app, Buffer_ID buffer){ static char buffer_get_char(Application_Links *app, Buffer_ID buffer_id, i32 pos){ - i32 buffer_size = 0; - buffer_get_size(app, buffer_id, &buffer_size); + i32 buffer_size = (i32)buffer_get_size(app, buffer_id); char result = ' '; if (0 <= pos && pos < buffer_size){ buffer_read_range(app, buffer_id, pos, pos + 1, &result); @@ -1194,16 +1178,14 @@ get_pos_past_lead_whitespace(Application_Links *app, Buffer_ID buffer, i32 pos){ static void move_past_lead_whitespace(Application_Links *app, View_ID view, Buffer_ID buffer){ - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + i32 pos = view_get_cursor_pos(app, view); i32 new_pos = get_pos_past_lead_whitespace(app, buffer, pos); view_set_cursor(app, view, seek_pos(new_pos), true); } static void move_past_lead_whitespace(Application_Links *app, View_ID view){ - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessProtected, &buffer); + Buffer_ID buffer = view_get_buffer(app, view, AccessProtected); move_past_lead_whitespace(app, view, buffer); } @@ -1223,8 +1205,7 @@ line_is_blank(Application_Links *app, Buffer_ID buffer, i32 line_number){ static i32 get_line_number_of__whitespace_status_line(Application_Links *app, Buffer_ID buffer, Scan_Direction direction, i32 line_number_start, b32 get_blank_line){ - i32 line_count = 0; - buffer_get_line_count(app, buffer, &line_count); + i32 line_count = (i32)buffer_get_line_count(app, buffer); i32 line_number = line_number_start + direction; for (;1 <= line_number && line_number <= line_count; line_number += direction){ b32 is_blank = line_is_blank(app, buffer, line_number); @@ -1352,8 +1333,7 @@ replace_in_range(Application_Links *app, Buffer_ID buffer, Range range, String_C internal Range swap_lines(Application_Links *app, Buffer_ID buffer, i32 line_1, i32 line_2){ Range result = {}; - i32 line_count = 0; - buffer_get_line_count(app, buffer, &line_count); + i32 line_count = (i32)buffer_get_line_count(app, buffer); if (1 <= line_1 && line_2 <= line_count){ Range range_1 = get_line_pos_range(app, buffer, line_1); Range range_2 = get_line_pos_range(app, buffer, line_2); @@ -1561,9 +1541,9 @@ buffer_identifier_to_id(Application_Links *app, Buffer_Identifier identifier){ } else{ String_Const_u8 name = SCu8(identifier.name, identifier.name_len); - get_buffer_by_name(app, name, AccessAll, &id); + id = get_buffer_by_name(app, name, AccessAll); if (id == 0){ - get_buffer_by_file_name(app, name, AccessAll, &id); + id = get_buffer_by_file_name(app, name, AccessAll); } } return(id); @@ -1574,12 +1554,13 @@ buffer_identifier_to_id_create_out_buffer(Application_Links *app, Buffer_Identif Buffer_ID result = 0; if (buffer_id.name != 0 && buffer_id.name_len > 0){ String_Const_u8 buffer_name = SCu8(buffer_id.name, buffer_id.name_len); - Buffer_ID buffer_attach_id = 0; - if (get_buffer_by_name(app, buffer_name, AccessAll, &buffer_attach_id)){ + Buffer_ID buffer_attach_id = get_buffer_by_name(app, buffer_name, AccessAll); + if (buffer_attach_id != 0){ result = buffer_attach_id; } else{ - if (create_buffer(app, buffer_name, BufferCreate_AlwaysNew|BufferCreate_NeverAttachToFile, &buffer_attach_id)){ + buffer_attach_id = create_buffer(app, buffer_name, BufferCreate_AlwaysNew|BufferCreate_NeverAttachToFile); + if (buffer_attach_id != 0){ buffer_set_setting(app, buffer_attach_id, BufferSetting_ReadOnly, true); buffer_set_setting(app, buffer_attach_id, BufferSetting_Unimportant, true); result = buffer_attach_id; @@ -1596,10 +1577,9 @@ buffer_identifier_to_id_create_out_buffer(Application_Links *app, Buffer_Identif static void adjust_all_buffer_wrap_widths(Application_Links *app, i32 wrap_width, i32 min_base_width){ - Buffer_ID buffer = 0; - for (get_buffer_next(app, 0, AccessAll, &buffer); + for (Buffer_ID buffer = get_buffer_next(app, 0, AccessAll); buffer != 0; - get_buffer_next(app, buffer, AccessAll, &buffer)){ + buffer = get_buffer_next(app, buffer, AccessAll)){ buffer_set_setting(app, buffer, BufferSetting_WrapPosition, wrap_width); buffer_set_setting(app, buffer, BufferSetting_MinimumBaseWrapPosition, min_base_width); } @@ -1609,15 +1589,15 @@ static View_ID open_view(Application_Links *app, View_ID view_location, View_Split_Position position){ View_ID result = 0; if (view_location != 0 && view_exists(app, view_location)){ - Panel_ID panel_id = 0; - if (view_get_panel(app, view_location, &panel_id)){ + Panel_ID panel_id = view_get_panel(app, view_location); + if (panel_id != 0){ b32 vertical = (position == ViewSplit_Left || position == ViewSplit_Right); if (panel_split(app, panel_id, vertical?PanelSplit_LeftAndRight:PanelSplit_TopAndBottom)){ - Panel_ID new_panel_id = 0; Panel_Child child = (position == ViewSplit_Left || position == ViewSplit_Top)?PanelChild_Min:PanelChild_Max; - if (panel_get_child(app, panel_id, child, &new_panel_id)){ - View_ID new_view_id = 0; - if (panel_get_view(app, new_panel_id, &new_view_id)){ + Panel_ID new_panel_id = panel_get_child(app, panel_id, child); + if (new_panel_id != 0){ + View_ID new_view_id = panel_get_view(app, new_panel_id); + if (new_view_id != 0){ result = new_view_id; } } @@ -1630,13 +1610,11 @@ open_view(Application_Links *app, View_ID view_location, View_Split_Position pos static View_ID get_first_view_with_buffer(Application_Links *app, Buffer_ID buffer_id){ View_ID result = {}; - View_ID test = {}; if (buffer_id != 0){ - for (get_view_next(app, 0, AccessAll, &test); + for (View_ID test = get_view_next(app, 0, AccessAll); test != 0; - get_view_next(app, test, AccessAll, &test)){ - Buffer_ID test_buffer = 0; - view_get_buffer(app, test, AccessAll, &test_buffer); + test = get_view_next(app, test, AccessAll)){ + Buffer_ID test_buffer = view_get_buffer(app, test, AccessAll); if (test_buffer == buffer_id){ result = test; break; @@ -1649,8 +1627,7 @@ get_first_view_with_buffer(Application_Links *app, Buffer_ID buffer_id){ static b32 open_file(Application_Links *app, Buffer_ID *buffer_out, String_Const_u8 file_name, b32 background, b32 never_new){ b32 result = false; - Buffer_ID buffer = 0; - get_buffer_by_name(app, file_name, AccessProtected, &buffer); + Buffer_ID buffer = get_buffer_by_name(app, file_name, AccessProtected); b32 exists = buffer_exists(app, buffer); if (!exists){ Buffer_Create_Flag flags = 0; @@ -1660,7 +1637,7 @@ open_file(Application_Links *app, Buffer_ID *buffer_out, String_Const_u8 file_na if (never_new){ flags |= BufferCreate_NeverNew; } - create_buffer(app, file_name, flags, &buffer); + buffer = create_buffer(app, file_name, flags); exists = buffer_exists(app, buffer); } if (exists){ @@ -1689,20 +1666,18 @@ view_open_file(Application_Links *app, View_ID view, String_Const_u8 file_name, static View_ID get_next_view_looped_all_panels(Application_Links *app, View_ID view_id, Access_Flag access){ - if (!get_view_next(app, view_id, access, &view_id)){ - if (!get_view_next(app, 0, access, &view_id)){ - view_id = 0; - } + view_id = get_view_next(app, view_id, access); + if (view_id == 0){ + view_id = get_view_next(app, 0, access); } return(view_id); } static View_ID get_prev_view_looped_all_panels(Application_Links *app, View_ID view_id, Access_Flag access){ - if (!get_view_prev(app, view_id, access, &view_id)){ - if (!get_view_prev(app, 0, access, &view_id)){ - view_id = 0; - } + view_id = get_view_prev(app, view_id, access); + if (view_id == 0){ + view_id = get_view_prev(app, 0, access); } return(view_id); } @@ -1710,10 +1685,8 @@ get_prev_view_looped_all_panels(Application_Links *app, View_ID view_id, Access_ //////////////////////////////// static Buffer_Kill_Result -kill_buffer(Application_Links *app, Buffer_Identifier identifier, View_ID gui_view_id, Buffer_Kill_Flag flags){ - Buffer_ID buffer = buffer_identifier_to_id(app, identifier); - Buffer_Kill_Result result = 0; - buffer_kill(app, buffer, flags, &result); +try_buffer_kill(Application_Links *app, Buffer_ID buffer, View_ID gui_view_id, Buffer_Kill_Flag flags){ + Buffer_Kill_Result result = buffer_kill(app, buffer, flags); if (result == BufferKillResult_Dirty){ do_gui_sure_to_kill(app, buffer, gui_view_id); } @@ -1724,8 +1697,7 @@ kill_buffer(Application_Links *app, Buffer_Identifier identifier, View_ID gui_vi static void clear_buffer(Application_Links *app, Buffer_ID buffer_id){ - i32 buffer_size = 0; - buffer_get_size(app, buffer_id, &buffer_size); + i32 buffer_size = (i32)buffer_get_size(app, buffer_id); buffer_replace_range(app, buffer_id, make_range(0, buffer_size), string_u8_litexpr("")); } @@ -1736,8 +1708,7 @@ init_stream_chunk(Stream_Chunk *chunk, Application_Links *app, Buffer_ID buffer_ i32 pos, char *data, u32 size){ b32 result = false; - i32 buffer_size = 0; - buffer_get_size(app, buffer_id, &buffer_size); + i32 buffer_size = (i32)buffer_get_size(app, buffer_id); if (0 <= pos && pos < buffer_size && size > 0){ chunk->app = app; chunk->buffer_id = buffer_id; @@ -1773,8 +1744,7 @@ forward_stream_chunk(Stream_Chunk *chunk){ Buffer_ID buffer_id = chunk->buffer_id; b32 result = 0; - i32 buffer_size = 0; - buffer_get_size(app, buffer_id, &buffer_size); + i32 buffer_size = (i32)buffer_get_size(app, buffer_id); if (chunk->end < buffer_size){ chunk->start = chunk->end; chunk->end += chunk->data_size; @@ -1841,94 +1811,12 @@ backward_stream_chunk(Stream_Chunk *chunk){ //////////////////////////////// -static b32 -init_stream_tokens(Stream_Tokens_DEP *stream, Application_Links *app, Buffer_ID buffer_id, i32 pos, Cpp_Token *data, i32 count){ - b32 result = false; - - i32 token_count = 0; - buffer_token_count(app, buffer_id, &token_count); - if (buffer_tokens_are_ready(app, buffer_id) && pos >= 0 && pos < token_count && count > 0){ - stream->app = app; - stream->buffer_id = buffer_id; - stream->base_tokens = data; - stream->count = count; - stream->start = round_down_i32(pos, count); - stream->end = round_up_i32(pos, count); - stream->token_count = token_count; - - stream->start = clamp_bot(0, stream->start); - stream->end = clamp_top(stream->end, stream->token_count); - - buffer_read_tokens(app, buffer_id, stream->start, stream->end, stream->base_tokens); - stream->tokens = stream->base_tokens - stream->start; - result = true; - } - - return(result); -} - -static Stream_Tokens_DEP -begin_temp_stream_token(Stream_Tokens_DEP *stream){ - return(*stream); -} - -static void -end_temp_stream_token(Stream_Tokens_DEP *stream, Stream_Tokens_DEP temp){ - if (stream->start != temp.start || stream->end != temp.end){ - Application_Links *app = stream->app; - buffer_read_tokens(app, temp.buffer_id, temp.start, temp.end, temp.base_tokens); - stream->tokens = stream->base_tokens - temp.start; - stream->start = temp.start; - stream->end = temp.end; - } -} - -static b32 -forward_stream_tokens(Stream_Tokens_DEP *stream){ - Application_Links *app = stream->app; - Buffer_ID buffer_id = stream->buffer_id; - b32 result = false; - if (stream->end < stream->token_count){ - stream->start = stream->end; - stream->end += stream->count; - if (stream->end > stream->token_count){ - stream->end = stream->token_count; - } - if (stream->start < stream->end){ - buffer_read_tokens(app, buffer_id, stream->start, stream->end, stream->base_tokens); - stream->tokens = stream->base_tokens - stream->start; - result = true; - } - } - return(result); -} - -static b32 -backward_stream_tokens(Stream_Tokens_DEP *stream){ - Application_Links *app = stream->app; - Buffer_ID buffer_id = stream->buffer_id; - b32 result = false; - if (stream->start > 0){ - stream->end = stream->start; - stream->start -= stream->count; - if (0 > stream->start){ - stream->start = 0; - } - if (stream->start < stream->end){ - buffer_read_tokens(app, buffer_id, stream->start, stream->end, stream->base_tokens); - stream->tokens = stream->base_tokens - stream->start; - result = true; - } - } - return(result); -} - -//////////////////////////////// - static Token_Range buffer_get_token_range(Application_Links *app, Buffer_ID buffer){ + Cpp_Token_Array array = buffer_get_token_array(app, buffer); Token_Range range = {}; - buffer_get_token_range(app, buffer, &range.first, &range.one_past_last); + range.first = array.tokens; + range.one_past_last = array.tokens + array.count; return(range); } @@ -2037,11 +1925,22 @@ get_query_string(Application_Links *app, char *query_str, char *string_space, i3 return(bar.string); } +static b32 +get_token_from_pos(Application_Links *app, Buffer_ID buffer, u64 pos, Cpp_Get_Token_Result *result){ + b32 success = false; + Cpp_Token_Array array = buffer_get_token_array(app, buffer); + if (array.count > 0){ + success = true; + *result = cpp_get_token(array, (i32)pos); + } + return(success); +} + static String_Const_u8 -get_token_or_word_under_pos(Application_Links *app, Arena *arena, Buffer_ID buffer, umem pos){ +get_token_or_word_under_pos(Application_Links *app, Arena *arena, Buffer_ID buffer, u64 pos){ String_Const_u8 result = {}; Cpp_Get_Token_Result get_result = {}; - b32 success = buffer_get_token_index(app, buffer, (i32)pos, &get_result); + b32 success = get_token_from_pos(app, buffer, (i32)pos, &get_result); if (success && !get_result.in_whitespace_after_token){ umem size = get_result.token_one_past_last - get_result.token_start; if (0 < size){ @@ -2256,13 +2155,11 @@ no_mark_snap_to_cursor_if_shift(Application_Links *app, View_ID view_id){ } static b32 -view_has_highlighted_range(Application_Links *app, View_ID view_id){ +view_has_highlighted_range(Application_Links *app, View_ID view){ b32 result = false; if (fcoder_mode == FCoderMode_NotepadLike){ - i32 pos = 0; - i32 mark = 0; - view_get_cursor_pos(app, view_id, &pos); - view_get_mark_pos(app, view_id, &mark); + i32 pos = view_get_cursor_pos(app, view); + i32 mark = view_get_mark_pos(app, view); result = (pos != mark); } return(result); @@ -2273,8 +2170,7 @@ if_view_has_highlighted_range_delete_range(Application_Links *app, View_ID view_ b32 result = false; if (view_has_highlighted_range(app, view_id)){ Range range = get_view_range(app, view_id); - Buffer_ID buffer = 0; - view_get_buffer(app, view_id, AccessOpen, &buffer); + Buffer_ID buffer = view_get_buffer(app, view_id, AccessOpen); buffer_replace_range(app, buffer, range, string_u8_litexpr("")); result = true; } @@ -2284,34 +2180,26 @@ if_view_has_highlighted_range_delete_range(Application_Links *app, View_ID view_ static void begin_notepad_mode(Application_Links *app){ fcoder_mode = FCoderMode_NotepadLike; - View_ID view = 0; - for (get_view_next(app, 0, AccessAll, &view); + for (View_ID view = get_view_next(app, 0, AccessAll); view != 0; - get_view_next(app, view, AccessAll, &view)){ - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + view = get_view_next(app, view, AccessAll)){ + i32 pos = view_get_cursor_pos(app, view); view_set_mark(app, view, seek_pos(pos)); } } //////////////////////////////// -typedef i32 View_Split_Kind; -enum{ - ViewSplitKind_Ratio, - ViewSplitKind_FixedPixels, -}; - static b32 view_set_split(Application_Links *app, View_ID view, View_Split_Kind kind, f32 t){ b32 result = false; if (view != 0){ - Panel_ID panel_id = 0; - if (view_get_panel(app, view, &panel_id)){ - Panel_ID parent_panel_id = 0; - if (panel_get_parent(app, panel_id, &parent_panel_id)){ - Panel_ID min_child_id = 0; - if (panel_get_child(app, parent_panel_id, PanelChild_Min, &min_child_id)){ + Panel_ID panel_id = view_get_panel(app, view); + if (panel_id != 0){ + Panel_ID parent_panel_id = panel_get_parent(app, panel_id); + if (parent_panel_id != 0){ + Panel_ID min_child_id = panel_get_child(app, parent_panel_id, PanelChild_Min); + if (min_child_id != 0){ b32 panel_is_min = (min_child_id == panel_id); Panel_Split_Kind panel_kind = ((kind == ViewSplitKind_Ratio)? (panel_is_min?PanelSplitKind_Ratio_Min:PanelSplitKind_Ratio_Max): @@ -2425,8 +2313,7 @@ set_buffer_system_command(Application_Links *app, Child_Process_ID process, Buff b32 result = false; Child_Process_Set_Target_Flags set_buffer_flags = flags_system_command(flags); if (child_process_set_target_buffer(app, process, buffer, set_buffer_flags)){ - i32 buffer_size = 0; - buffer_get_size(app, buffer, &buffer_size); + i32 buffer_size = (i32)buffer_get_size(app, buffer); buffer_replace_range(app, buffer, make_range(0, buffer_size), string_u8_litexpr("")); if (HasFlag(flags, CLI_SendEndSignal)){ buffer_send_end_signal(app, buffer); diff --git a/4coder_helper.h b/4coder_helper.h index 0dd30426..279be60a 100644 --- a/4coder_helper.h +++ b/4coder_helper.h @@ -159,22 +159,6 @@ struct Stream_Chunk{ char *data; }; -// NOTE(allen|4.0.31): Stream_Tokens has been deprecated in favor of the Token_Iterator below. -// For examples of usage: 4coder_function_list.cpp 4coder_scope_commands.cpp -// If you want to keep your code working easily uncomment the typedef for Stream_Tokens. -struct Stream_Tokens_DEP{ - Application_Links *app; - Buffer_ID buffer_id; - - Cpp_Token *base_tokens; - Cpp_Token *tokens; - i32 start; - i32 end; - i32 count; - i32 token_count; -}; -//typedef Stream_Tokens_DEP Stream_Tokens; - struct Token_Range{ Cpp_Token *first; Cpp_Token *one_past_last; @@ -201,6 +185,14 @@ struct History_Group{ History_Record_Index first; }; +//////////////////////////////// + +typedef i32 View_Split_Kind; +enum{ + ViewSplitKind_Ratio, + ViewSplitKind_FixedPixels, +}; + #endif // BOTTOM diff --git a/4coder_insertion.cpp b/4coder_insertion.cpp index af7a8059..adcd3637 100644 --- a/4coder_insertion.cpp +++ b/4coder_insertion.cpp @@ -24,12 +24,9 @@ begin_buffer_insertion_at_buffered(Application_Links *app, Buffer_ID buffer_id, static Buffer_Insertion begin_buffer_insertion(Application_Links *app){ - View_ID view = 0; - get_active_view(app, AccessAll, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessAll, &buffer); - i32 cursor_pos = 0; - view_get_cursor_pos(app, view, &cursor_pos); + View_ID view = get_active_view(app, AccessAll); + Buffer_ID buffer = view_get_buffer(app, view, AccessAll); + i32 cursor_pos = view_get_cursor_pos(app, view); Buffer_Insertion result = begin_buffer_insertion_at(app, buffer, cursor_pos); return(result); } diff --git a/4coder_jump_direct.cpp b/4coder_jump_direct.cpp index 78fc4647..92ee30e5 100644 --- a/4coder_jump_direct.cpp +++ b/4coder_jump_direct.cpp @@ -10,20 +10,16 @@ CUSTOM_DOC("If the cursor is found to be on a jump location, parses the jump loc { Arena *scratch = context_get_arena(app); Temp_Memory temp = begin_temp(scratch); - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessProtected, &buffer); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer = view_get_buffer(app, view, AccessProtected); + i32 pos = view_get_cursor_pos(app, view); Full_Cursor cursor = {}; view_compute_cursor(app, view, seek_pos(pos), &cursor); Parsed_Jump jump = parse_jump_from_buffer_line(app, scratch, buffer, cursor.line, false); if (jump.success){ change_active_panel(app); - View_ID target_view = 0; - get_active_view(app, AccessAll, &target_view); + View_ID target_view = get_active_view(app, AccessAll); if (get_jump_buffer(app, &buffer, &jump.location)){ switch_to_existing_view(app, target_view, buffer); jump_to_location(app, target_view, buffer, jump.location); @@ -38,12 +34,9 @@ CUSTOM_DOC("If the cursor is found to be on a jump location, parses the jump loc { Arena *scratch = context_get_arena(app); Temp_Memory temp = begin_temp(scratch); - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessProtected, &buffer); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer = view_get_buffer(app, view, AccessProtected); + i32 pos = view_get_cursor_pos(app, view); Full_Cursor cursor = {}; view_compute_cursor(app, view, seek_pos(pos), &cursor); @@ -112,30 +105,34 @@ CUSTOM_DOC("If a buffer containing jump locations has been locked in, goes to th CUSTOM_COMMAND_SIG(newline_or_goto_position_direct) CUSTOM_DOC("If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer = 0; - if (view_get_buffer(app, view, AccessOpen, &buffer)){ + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); + if (buffer != 0){ write_character(app); } - else if (view_get_buffer(app, view, AccessProtected, &buffer)){ - goto_jump_at_cursor_direct(app); - lock_jump_buffer(app, buffer); + else{ + buffer = view_get_buffer(app, view, AccessProtected); + if (buffer != 0){ + goto_jump_at_cursor_direct(app); + lock_jump_buffer(app, buffer); + } } } CUSTOM_COMMAND_SIG(newline_or_goto_position_same_panel_direct) CUSTOM_DOC("If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor_same_panel.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer = 0; - if (view_get_buffer(app, view, AccessOpen, &buffer)){ + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); + if (buffer != 0){ write_character(app); } - else if (view_get_buffer(app, view, AccessProtected, &buffer)){ - goto_jump_at_cursor_same_panel_direct(app); - lock_jump_buffer(app, buffer); + else{ + buffer = view_get_buffer(app, view, AccessProtected); + if (buffer != 0){ + goto_jump_at_cursor_same_panel_direct(app); + lock_jump_buffer(app, buffer); + } } } diff --git a/4coder_jump_lister.cpp b/4coder_jump_lister.cpp index d23a3a4a..3e2e87cb 100644 --- a/4coder_jump_lister.cpp +++ b/4coder_jump_lister.cpp @@ -104,10 +104,8 @@ open_jump_lister(Application_Links *app, Heap *heap, View_ID ui_view, Buffer_ID CUSTOM_COMMAND_SIG(view_jump_list_with_lister) CUSTOM_DOC("When executed on a buffer with jumps, creates a persistent lister for all the jumps") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessAll, &buffer); + View_ID view = get_active_view(app, AccessAll); + Buffer_ID buffer = view_get_buffer(app, view, AccessAll); open_jump_lister(app, &global_heap, view, buffer, JumpListerActivation_OpenInNextViewKeepUI, 0); } diff --git a/4coder_jump_sticky.cpp b/4coder_jump_sticky.cpp index b1b1cce4..691afab5 100644 --- a/4coder_jump_sticky.cpp +++ b/4coder_jump_sticky.cpp @@ -60,8 +60,8 @@ parse_buffer_to_jump_array(Application_Links *app, Arena *arena, Buffer_ID buffe Buffer_ID jump_buffer = {}; if (open_file(app, &jump_buffer, parsed_jump.location.file, false, true)){ if (buffer_exists(app, jump_buffer)){ - Partial_Cursor cursor = {}; - if (buffer_compute_cursor(app, jump_buffer, seek_line_char(parsed_jump.location.line, parsed_jump.location.column), &cursor)){ + Partial_Cursor cursor = buffer_compute_cursor(app, jump_buffer, seek_jump(parsed_jump)); + if (cursor.line > 0){ out_buffer_id = jump_buffer; out_pos = cursor.pos; output_jump = true; @@ -128,7 +128,7 @@ init_marker_list(Application_Links *app, Heap *heap, Buffer_ID buffer, Marker_Li Sticky_Jump_Stored *stored = push_array(scratch, Sticky_Jump_Stored, jumps.count); Managed_Scope scope_array[2] = {}; - buffer_get_managed_scope(app, buffer, &scope_array[0]); + scope_array[0] = buffer_get_managed_scope(app, buffer); for (i32 i = 0; i < scoped_buffer_ranges.count; i += 1){ Range buffer_range_indices = scoped_buffer_ranges.ranges[i]; @@ -166,7 +166,7 @@ init_marker_list(Application_Links *app, Heap *heap, Buffer_ID buffer, Marker_Li } } - buffer_get_managed_scope(app, target_buffer_id, &scope_array[1]); + scope_array[1] = buffer_get_managed_scope(app, target_buffer_id); Managed_Scope scope = get_managed_scope_with_multiple_dependencies(app, scope_array, ArrayCount(scope_array)); Managed_Object marker_handle = alloc_buffer_markers_on_buffer(app, target_buffer_id, total_jump_count, &scope); managed_object_store_data(app, marker_handle, 0, total_jump_count, markers); @@ -191,7 +191,7 @@ init_marker_list(Application_Links *app, Heap *heap, Buffer_ID buffer, Marker_Li list->jump_array = stored_jump_array; list->jump_count = jumps.count; - buffer_get_size(app, buffer, &list->previous_size); + list->previous_size = (i32)buffer_get_size(app, buffer); list->buffer_id = buffer; end_temp(temp); @@ -233,8 +233,7 @@ static Marker_List* get_or_make_list_for_buffer(Application_Links *app, Heap *heap, Buffer_ID buffer_id){ Marker_List *result = get_marker_list_for_buffer(buffer_id); if (result != 0){ - i32 buffer_size = 0; - buffer_get_size(app, buffer_id, &buffer_size); + i32 buffer_size = (i32)buffer_get_size(app, buffer_id); // TODO(allen): // TODO(allen): // TODO(allen): // TODO(allen): // TODO(allen): When buffers get an "edit sequence number" use that instead. if (result->previous_size != buffer_size){ delete_marker_list(result); @@ -289,8 +288,8 @@ get_jump_from_list(Application_Links *app, Marker_List *list, i32 index, ID_Pos_ Buffer_ID target_buffer_id = stored.jump_buffer_id; Managed_Scope scope_array[2] = {}; - buffer_get_managed_scope(app, list->buffer_id, &scope_array[0]); - buffer_get_managed_scope(app, target_buffer_id, &scope_array[1]); + scope_array[0] = buffer_get_managed_scope(app, list->buffer_id); + scope_array[1] = buffer_get_managed_scope(app, target_buffer_id); Managed_Scope scope = get_managed_scope_with_multiple_dependencies(app, scope_array, ArrayCount(scope_array)); sticky_jump_marker_handle_loc = managed_variable_create_or_get_id(app, sticky_jump_marker_handle_var, 0); @@ -368,14 +367,11 @@ CUSTOM_DOC("If the cursor is found to be on a jump location, parses the jump loc { Heap *heap = &global_heap; - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessProtected, &buffer); + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer = view_get_buffer(app, view, AccessProtected); Marker_List *list = get_or_make_list_for_buffer(app, heap, buffer); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + i32 pos = view_get_cursor_pos(app, view); Full_Cursor cursor = {}; view_compute_cursor(app, view, seek_pos(pos), &cursor); @@ -386,8 +382,7 @@ CUSTOM_DOC("If the cursor is found to be on a jump location, parses the jump loc if (get_jump_from_list(app, list, list_index, &location)){ if (get_jump_buffer(app, &buffer, &location)){ change_active_panel(app); - View_ID target_view = 0; - get_active_view(app, AccessAll, &target_view); + View_ID target_view = get_active_view(app, AccessAll); switch_to_existing_view(app, target_view, buffer); jump_to_location(app, target_view, buffer, location); } @@ -400,15 +395,12 @@ CUSTOM_DOC("If the cursor is found to be on a jump location, parses the jump loc { Heap *heap = &global_heap; - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessProtected, &buffer); + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer = view_get_buffer(app, view, AccessProtected); Marker_List *list = get_or_make_list_for_buffer(app, heap, buffer); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + i32 pos = view_get_cursor_pos(app, view); Full_Cursor cursor = {}; view_compute_cursor(app, view, seek_pos(pos), &cursor); @@ -428,11 +420,10 @@ static void goto_jump_in_order(Application_Links *app, Marker_List *list, View_ID jump_view, ID_Pos_Jump_Location location){ Buffer_ID buffer = {}; if (get_jump_buffer(app, &buffer, &location)){ - View_ID target_view = 0; - get_active_view(app, AccessAll, &target_view); + View_ID target_view = get_active_view(app, AccessAll); if (target_view == jump_view){ change_active_panel(app); - get_active_view(app, AccessAll, &target_view); + target_view = get_active_view(app, AccessAll); } switch_to_existing_view(app, target_view, buffer); jump_to_location(app, target_view, buffer, location); @@ -489,12 +480,10 @@ get_locked_jump_state(Application_Links *app, Heap *heap){ Locked_Jump_State result = {}; result.view = get_view_for_locked_jump_buffer(app); if (result.view != 0){ - Buffer_ID buffer = 0; - view_get_buffer(app, result.view, AccessAll, &buffer); + Buffer_ID buffer = view_get_buffer(app, result.view, AccessAll); result.list = get_or_make_list_for_buffer(app, heap, buffer); - i32 cursor_position = 0; - view_get_cursor_pos(app, result.view, &cursor_position); + i32 cursor_position = view_get_cursor_pos(app, result.view); Full_Cursor cursor = {}; view_compute_cursor(app, result.view, seek_pos(cursor_position), &cursor); result.list_index = get_index_nearest_from_list(app, result.list, cursor.line); @@ -509,8 +498,7 @@ CUSTOM_DOC("If a buffer containing jump locations has been locked in, goes to th Locked_Jump_State jump_state = get_locked_jump_state(app, heap); if (jump_state.view != 0){ - i32 cursor_position = 0; - view_get_cursor_pos(app, jump_state.view, &cursor_position); + i32 cursor_position = view_get_cursor_pos(app, jump_state.view); Full_Cursor cursor = {}; view_compute_cursor(app, jump_state.view, seek_pos(cursor_position), &cursor); i32 line = get_line_from_list(app, jump_state.list, jump_state.list_index); @@ -541,8 +529,7 @@ CUSTOM_DOC("If a buffer containing jump locations has been locked in, goes to th Locked_Jump_State jump_state = get_locked_jump_state(app, heap); if (jump_state.view != 0){ - i32 cursor_position = 0; - view_get_cursor_pos(app, jump_state.view, &cursor_position); + i32 cursor_position = view_get_cursor_pos(app, jump_state.view); Full_Cursor cursor = {}; view_compute_cursor(app, jump_state.view, seek_pos(cursor_position), &cursor); i32 line = get_line_from_list(app, jump_state.list, jump_state.list_index); @@ -609,30 +596,34 @@ CUSTOM_DOC("If a buffer containing jump locations has been locked in, goes to th CUSTOM_COMMAND_SIG(newline_or_goto_position_sticky) CUSTOM_DOC("If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer = 0; - if (view_get_buffer(app, view, AccessOpen, &buffer)){ + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); + if (buffer != 0){ write_character(app); } - else if (view_get_buffer(app, view, AccessProtected, &buffer)){ - goto_jump_at_cursor_sticky(app); - lock_jump_buffer(app, buffer); + else{ + buffer = view_get_buffer(app, view, AccessProtected); + if (buffer != 0){ + goto_jump_at_cursor_sticky(app); + lock_jump_buffer(app, buffer); + } } } CUSTOM_COMMAND_SIG(newline_or_goto_position_same_panel_sticky) CUSTOM_DOC("If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor_same_panel.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer = 0; - if (view_get_buffer(app, view, AccessOpen, &buffer)){ + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); + if (buffer != 0){ write_character(app); } - else if (view_get_buffer(app, view, AccessProtected, &buffer)){ - goto_jump_at_cursor_same_panel_sticky(app); - lock_jump_buffer(app, buffer); + else{ + buffer = view_get_buffer(app, view, AccessProtected); + if (buffer != 0){ + goto_jump_at_cursor_same_panel_sticky(app); + lock_jump_buffer(app, buffer); + } } } diff --git a/4coder_jumping.cpp b/4coder_jumping.cpp index 2144477a..86532e35 100644 --- a/4coder_jumping.cpp +++ b/4coder_jumping.cpp @@ -224,8 +224,7 @@ get_jump_buffer(Application_Links *app, Buffer_ID *buffer, ID_Pos_Jump_Location static View_ID switch_to_existing_view(Application_Links *app, View_ID view, Buffer_ID buffer){ - Buffer_ID current_buffer = 0; - view_get_buffer(app, view, AccessAll, ¤t_buffer); + Buffer_ID current_buffer = view_get_buffer(app, view, AccessAll); if (view != 0 || current_buffer != buffer){ View_ID existing_view = get_first_view_with_buffer(app, buffer); if (existing_view != 0){ @@ -237,8 +236,7 @@ switch_to_existing_view(Application_Links *app, View_ID view, Buffer_ID buffer){ static void set_view_to_location(Application_Links *app, View_ID view, Buffer_ID buffer, Buffer_Seek seek){ - Buffer_ID current_buffer = 0; - view_get_buffer(app, view, AccessAll, ¤t_buffer); + Buffer_ID current_buffer = view_get_buffer(app, view, AccessAll); if (current_buffer != buffer){ view_set_buffer(app, view, buffer, 0); } @@ -294,8 +292,7 @@ seek_next_jump_in_buffer(Application_Links *app, Arena *arena, static ID_Line_Column_Jump_Location convert_name_based_to_id_based(Application_Links *app, Name_Line_Column_Location loc){ ID_Line_Column_Jump_Location result = {}; - Buffer_ID buffer = 0; - get_buffer_by_name(app, loc.file, AccessAll, &buffer); + Buffer_ID buffer = get_buffer_by_name(app, loc.file, AccessAll); if (buffer != 0){ result.buffer_id = buffer; result.line = loc.line; @@ -306,13 +303,11 @@ convert_name_based_to_id_based(Application_Links *app, Name_Line_Column_Location static Parsed_Jump seek_next_jump_in_view(Application_Links *app, Arena *arena, View_ID view, i32 skip_sub_errors, i32 direction, i32 *line_out){ - i32 cursor_position = 0; - view_get_cursor_pos(app, view, &cursor_position); + i32 cursor_position = view_get_cursor_pos(app, view); Full_Cursor cursor = {}; view_compute_cursor(app, view, seek_pos(cursor_position), &cursor); i32 line = cursor.line; - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessAll, &buffer); + Buffer_ID buffer = view_get_buffer(app, view, AccessAll); Parsed_Jump jump = seek_next_jump_in_buffer(app, arena, buffer, line + direction, skip_sub_errors, direction, &line); if (jump.success){ *line_out = line; @@ -374,11 +369,10 @@ seek_jump(Application_Links *app, b32 skip_repeats, b32 skip_sub_errors, i32 dir if (advance_cursor_in_jump_view(app, view, skip_repeats, skip_sub_errors, direction, &location)){ Buffer_ID buffer = {}; if (get_jump_buffer(app, &buffer, &location)){ - View_ID target_view = 0; - get_active_view(app, AccessAll, &target_view); + View_ID target_view = get_active_view(app, AccessAll); if (target_view == view){ change_active_panel(app); - get_active_view(app, AccessAll, &target_view); + target_view = get_active_view(app, AccessAll); } switch_to_existing_view(app, target_view, buffer); jump_to_location(app, target_view, buffer, location); diff --git a/4coder_lists.cpp b/4coder_lists.cpp index d1a235fb..da164995 100644 --- a/4coder_lists.cpp +++ b/4coder_lists.cpp @@ -8,8 +8,7 @@ such as open file, switch buffer, or kill buffer. CUSTOM_COMMAND_SIG(lister__quit) CUSTOM_DOC("A lister mode command that quits the list without executing any actions.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); view_end_ui_mode(app, view); } @@ -17,8 +16,7 @@ CUSTOM_COMMAND_SIG(lister__activate) CUSTOM_DOC("A lister mode command that activates the list's action on the highlighted item.") { Heap *heap = &global_heap; - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); Lister_State *state = view_get_lister_state(view); if (state->initialized){ void *user_data = 0; @@ -32,8 +30,7 @@ CUSTOM_DOC("A lister mode command that activates the list's action on the highli CUSTOM_COMMAND_SIG(lister__write_character) CUSTOM_DOC("A lister mode command that dispatches to the lister's write character handler.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); Lister_State *state = view_get_lister_state(view); if (state->lister.data.handlers.write_character != 0){ state->lister.data.handlers.write_character(app); @@ -43,8 +40,7 @@ CUSTOM_DOC("A lister mode command that dispatches to the lister's write characte CUSTOM_COMMAND_SIG(lister__backspace_text_field) CUSTOM_DOC("A lister mode command that dispatches to the lister's backspace text field handler.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); Lister_State *state = view_get_lister_state(view); if (state->lister.data.handlers.backspace != 0){ state->lister.data.handlers.backspace(app); @@ -54,8 +50,7 @@ CUSTOM_DOC("A lister mode command that dispatches to the lister's backspace text CUSTOM_COMMAND_SIG(lister__move_up) CUSTOM_DOC("A lister mode command that dispatches to the lister's navigate up handler.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); Lister_State *state = view_get_lister_state(view); if (state->lister.data.handlers.navigate_up != 0){ state->lister.data.handlers.navigate_up(app); @@ -65,8 +60,7 @@ CUSTOM_DOC("A lister mode command that dispatches to the lister's navigate up ha CUSTOM_COMMAND_SIG(lister__move_down) CUSTOM_DOC("A lister mode command that dispatches to the lister's navigate down handler.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); Lister_State *state = view_get_lister_state(view); if (state->lister.data.handlers.navigate_down != 0){ state->lister.data.handlers.navigate_down(app); @@ -76,8 +70,7 @@ CUSTOM_DOC("A lister mode command that dispatches to the lister's navigate down CUSTOM_COMMAND_SIG(lister__wheel_scroll) CUSTOM_DOC("A lister mode command that scrolls the list in response to the mouse wheel.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); GUI_Scroll_Vars scroll = {}; view_get_scroll_vars(app, view, &scroll); Mouse_State mouse = get_mouse_state(app); @@ -92,8 +85,7 @@ CUSTOM_DOC("A lister mode command that scrolls the list in response to the mouse CUSTOM_COMMAND_SIG(lister__mouse_press) CUSTOM_DOC("A lister mode command that beings a click interaction with a list item under the mouse.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); Lister_State *state = view_get_lister_state(view); if (state->initialized){ UI_Item clicked = lister_get_clicked_item(app, view); @@ -105,8 +97,7 @@ CUSTOM_COMMAND_SIG(lister__mouse_release) CUSTOM_DOC("A lister mode command that ends a click interaction with a list item under the mouse, possibly activating it.") { Heap *heap = &global_heap; - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); Lister_State *state = view_get_lister_state(view); if (state->initialized && state->hot_user_data != 0){ UI_Item clicked = lister_get_clicked_item(app, view); @@ -120,8 +111,7 @@ CUSTOM_DOC("A lister mode command that ends a click interaction with a list item CUSTOM_COMMAND_SIG(lister__repaint) CUSTOM_DOC("A lister mode command that updates the lists UI data.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); Lister_State *state = view_get_lister_state(view); if (state->initialized){ lister_update_ui(app, view, state); @@ -131,8 +121,7 @@ CUSTOM_DOC("A lister mode command that updates the lists UI data.") CUSTOM_COMMAND_SIG(lister__write_character__default) CUSTOM_DOC("A lister mode command that inserts a new character to the text field.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); Lister_State *state = view_get_lister_state(view); if (state->initialized){ User_Input in = get_command_input(app); @@ -151,8 +140,7 @@ CUSTOM_DOC("A lister mode command that inserts a new character to the text field CUSTOM_COMMAND_SIG(lister__backspace_text_field__default) CUSTOM_DOC("A lister mode command that backspaces one character from the text field.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); Lister_State *state = view_get_lister_state(view); if (state->initialized){ state->lister.data.text_field.string = backspace_utf8(state->lister.data.text_field.string); @@ -166,8 +154,7 @@ CUSTOM_DOC("A lister mode command that backspaces one character from the text fi CUSTOM_COMMAND_SIG(lister__move_up__default) CUSTOM_DOC("A lister mode command that moves the highlighted item one up in the list.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); Lister_State *state = view_get_lister_state(view); if (state->initialized){ state->item_index = state->item_index - 1; @@ -182,8 +169,7 @@ CUSTOM_DOC("A lister mode command that moves the highlighted item one up in the CUSTOM_COMMAND_SIG(lister__move_down__default) CUSTOM_DOC("A lister mode command that moves the highlighted item one down in the list.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); Lister_State *state = view_get_lister_state(view); if (state->initialized){ state->item_index = state->item_index + 1; @@ -198,8 +184,7 @@ CUSTOM_DOC("A lister mode command that moves the highlighted item one down in th CUSTOM_COMMAND_SIG(lister__write_character__file_path) CUSTOM_DOC("A lister mode command that inserts a character into the text field of a file system list.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); Lister_State *state = view_get_lister_state(view); if (state->initialized){ User_Input in = get_command_input(app); @@ -224,8 +209,7 @@ CUSTOM_DOC("A lister mode command that inserts a character into the text field o CUSTOM_COMMAND_SIG(lister__backspace_text_field__file_path) CUSTOM_DOC("A lister mode command that backspaces one character from the text field of a file system list.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); Lister_State *state = view_get_lister_state(view); if (state->initialized){ if (state->lister.data.text_field.size > 0){ @@ -267,8 +251,7 @@ CUSTOM_COMMAND_SIG(lister__write_character__fixed_list) CUSTOM_DOC("A lister mode command that handles input for the fixed sure to kill list.") { Heap *heap = &global_heap; - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); Lister_State *state = view_get_lister_state(view); if (state->initialized){ User_Input in = get_command_input(app); @@ -467,8 +450,7 @@ begin_integrated_lister__theme_list(Application_Links *app, char *query_string, static void generate_all_buffers_list__output_buffer(Application_Links *app, Lister *lister, Buffer_ID buffer){ - Dirty_State dirty = 0; - buffer_get_dirty_state(app, buffer, &dirty); + Dirty_State dirty = buffer_get_dirty_state(app, buffer); String_Const_u8 status = {}; switch (dirty){ case DirtyState_UnsavedChanges: status = string_u8_litexpr("*"); break; @@ -491,12 +473,10 @@ generate_all_buffers_list(Application_Links *app, Lister *lister){ // List currently viewed buffers { - View_ID view = 0; - for (get_view_next(app, 0, AccessAll, &view); + for (View_ID view = get_view_next(app, 0, AccessAll); view != 0; - get_view_next(app, view, AccessAll, &view)){ - Buffer_ID new_buffer_id = 0; - view_get_buffer(app, view, AccessAll, &new_buffer_id); + view = get_view_next(app, view, AccessAll)){ + Buffer_ID new_buffer_id = view_get_buffer(app, view, AccessAll); for (i32 i = 0; i < currently_viewed_buffer_count; i += 1){ if (new_buffer_id == buffers_currently_being_viewed[i]){ goto skip0; @@ -509,10 +489,9 @@ generate_all_buffers_list(Application_Links *app, Lister *lister){ // Regular Buffers { - Buffer_ID buffer = 0; - for (get_buffer_next(app, 0, AccessAll, &buffer); + for (Buffer_ID buffer = get_buffer_next(app, 0, AccessAll); buffer != 0; - get_buffer_next(app, buffer, AccessAll, &buffer)){ + buffer = get_buffer_next(app, buffer, AccessAll)){ for (i32 i = 0; i < currently_viewed_buffer_count; i += 1){ if (buffer == buffers_currently_being_viewed[i]){ goto skip1; @@ -526,10 +505,9 @@ generate_all_buffers_list(Application_Links *app, Lister *lister){ } // Buffers Starting with * { - Buffer_ID buffer = 0; - for (get_buffer_next(app, 0, AccessAll, &buffer); + for (Buffer_ID buffer = get_buffer_next(app, 0, AccessAll); buffer != 0; - get_buffer_next(app, buffer, AccessAll, &buffer)){ + buffer = get_buffer_next(app, buffer, AccessAll)){ for (i32 i = 0; i < currently_viewed_buffer_count; i += 1){ if (buffer == buffers_currently_being_viewed[i]){ goto skip2; @@ -596,14 +574,13 @@ generate_hot_directory_file_list(Application_Links *app, Lister *lister){ string_list_push_overlap(&lister->arena, &list, '/', SCu8(info->filename, info->filename_len)); String_Const_u8 full_file_path = string_list_flatten(&lister->arena, list); - get_buffer_by_file_name(app, full_file_path, AccessAll, &buffer); + buffer = get_buffer_by_file_name(app, full_file_path, AccessAll); end_temp(path_temp); } if (buffer != 0){ is_loaded = "LOADED"; - Dirty_State dirty = 0; - buffer_get_dirty_state(app, buffer, &dirty); + Dirty_State dirty = buffer_get_dirty_state(app, buffer); switch (dirty){ case DirtyState_UnsavedChanges: status_flag = " *"; break; case DirtyState_UnloadedChanges: status_flag = " !"; break; @@ -657,8 +634,7 @@ activate_confirm_kill(Application_Links *app, Heap *heap, View_ID view, Lister_S case SureToKill_Yes: { - Buffer_Kill_Result ignore = 0; - buffer_kill(app, buffer_id, BufferKill_AlwaysKill, &ignore); + buffer_kill(app, buffer_id, BufferKill_AlwaysKill); }break; case SureToKill_Save: @@ -667,7 +643,7 @@ activate_confirm_kill(Application_Links *app, Heap *heap, View_ID view, Lister_S Temp_Memory temp = begin_temp(scratch); String_Const_u8 file_name = push_buffer_file_name(app, scratch, buffer_id); if (buffer_save(app, buffer_id, file_name, BufferSave_IgnoreDirtyFlag)){ - buffer_kill(app, buffer_id, BufferKill_AlwaysKill, 0); + buffer_kill(app, buffer_id, BufferKill_AlwaysKill); } else{ String_Const_u8 str = push_u8_stringf(scratch, "Did not close '%.*s' because it did not successfully save.", @@ -750,8 +726,7 @@ activate_switch_buffer(Application_Links *app, Heap *heap, CUSTOM_COMMAND_SIG(interactive_switch_buffer) CUSTOM_DOC("Interactively switch to an open buffer.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); view_end_ui_mode(app, view); begin_integrated_lister__buffer_list(app, "Switch:", activate_switch_buffer, 0, 0, view); } @@ -762,16 +737,15 @@ activate_kill_buffer(Application_Links *app, Heap *heap, String_Const_u8 text_field, void *user_data, b32 activated_by_mouse){ lister_default(app, heap, view, state, ListerActivation_Finished); if (user_data != 0){ - Buffer_ID buffer_id = (Buffer_ID)(PtrAsInt(user_data)); - kill_buffer(app, buffer_identifier(buffer_id), view, 0); + Buffer_ID buffer = (Buffer_ID)(PtrAsInt(user_data)); + try_buffer_kill(app, buffer, view, 0); } } CUSTOM_COMMAND_SIG(interactive_kill_buffer) CUSTOM_DOC("Interactively kill an open buffer.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); view_end_ui_mode(app, view); begin_integrated_lister__buffer_list(app, "Kill:", activate_kill_buffer, 0, 0, view); } @@ -801,8 +775,7 @@ activate_open_or_new__generic(Application_Links *app, View_ID view, result = ListerActivation_ContinueAndRefresh; } else{ - Buffer_ID buffer = 0; - create_buffer(app, full_file_name, flags, &buffer); + Buffer_ID buffer = create_buffer(app, full_file_name, flags); if (buffer != 0){ view_set_buffer(app, view, buffer, SetBuffer_KeepOriginalGUI); } @@ -845,8 +818,7 @@ activate_open_or_new(Application_Links *app, Heap *heap, CUSTOM_COMMAND_SIG(interactive_open_or_new) CUSTOM_DOC("Interactively open a file out of the file system.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); view_end_ui_mode(app, view); begin_integrated_lister__file_system_list(app, "Open:", activate_open_or_new, 0, 0, view); } @@ -885,8 +857,7 @@ activate_new(Application_Links *app, Heap *heap, CUSTOM_COMMAND_SIG(interactive_new) CUSTOM_DOC("Interactively creates a new file.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); view_end_ui_mode(app, view); begin_integrated_lister__file_system_list(app, "New:", activate_new, 0, 0, view); } @@ -919,8 +890,7 @@ activate_open(Application_Links *app, Heap *heap, CUSTOM_COMMAND_SIG(interactive_open) CUSTOM_DOC("Interactively opens a file.") { - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); view_end_ui_mode(app, view); begin_integrated_lister__file_system_list(app, "Open:", activate_open, 0, 0, view); } @@ -940,8 +910,7 @@ CUSTOM_DOC("Opens the 4coder theme selector list.") Partition *scratch = &global_part; Temp_Memory temp = begin_temp_memory(scratch); - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); view_end_ui_mode(app, view); i32 theme_count = get_theme_count(app); Lister_UI_Option *options = push_array(scratch, Lister_UI_Option, theme_count); @@ -982,8 +951,7 @@ launch_custom_command_lister(Application_Links *app, i32 *command_ids, i32 comma } Arena *scratch = context_get_arena(app); - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); view_end_ui_mode(app, view); Temp_Memory temp = begin_temp(scratch); Lister_Option *options = push_array(scratch, Lister_Option, command_id_count); diff --git a/4coder_miblo_numbers.cpp b/4coder_miblo_numbers.cpp index 5b76ca05..661a135b 100644 --- a/4coder_miblo_numbers.cpp +++ b/4coder_miblo_numbers.cpp @@ -95,12 +95,9 @@ get_numeric_at_cursor(Application_Links *app, Buffer_ID buffer, i32 pos, Miblo_N CUSTOM_COMMAND_SIG(miblo_increment_basic) CUSTOM_DOC("Increment an integer under the cursor by one.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); + i32 pos = view_get_cursor_pos(app, view); Miblo_Number_Info number = {}; if (get_numeric_at_cursor(app, buffer, pos, &number)){ Scratch_Block scratch(app); @@ -113,12 +110,9 @@ CUSTOM_DOC("Increment an integer under the cursor by one.") CUSTOM_COMMAND_SIG(miblo_decrement_basic) CUSTOM_DOC("Decrement an integer under the cursor by one.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); + i32 pos = view_get_cursor_pos(app, view); Miblo_Number_Info number = {}; if (get_numeric_at_cursor(app, buffer, pos, &number)){ Scratch_Block scratch(app); @@ -363,12 +357,9 @@ get_timestamp_at_cursor(Application_Links *app, Buffer_ID buffer, i32 pos, Miblo static void miblo_time_stamp_alter(Application_Links *app, i32 unit_type, i32 amt){ - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); + i32 pos = view_get_cursor_pos(app, view); Miblo_Timestamp_Info timestamp = {}; if (get_timestamp_at_cursor(app, buffer, pos, ×tamp)){ diff --git a/4coder_project_commands.cpp b/4coder_project_commands.cpp index a23bec13..415b5243 100644 --- a/4coder_project_commands.cpp +++ b/4coder_project_commands.cpp @@ -35,10 +35,9 @@ close_all_files_with_extension(Application_Links *app, String_Const_u8_Array ext i32 buffers_to_close_count = 0; do_repeat = false; - Buffer_ID buffer = 0; - for (buffer = get_buffer_next(app, 0, AccessAll, &buffer); + for (Buffer_ID buffer = get_buffer_next(app, 0, AccessAll); buffer != 0; - get_buffer_next(app, buffer, AccessAll, &buffer)){ + buffer = get_buffer_next(app, buffer, AccessAll)){ b32 is_match = true; if (extension_array.count > 0){ @@ -67,7 +66,7 @@ close_all_files_with_extension(Application_Links *app, String_Const_u8_Array ext } for (i32 i = 0; i < buffers_to_close_count; ++i){ - kill_buffer(app, buffer_identifier(buffers_to_close[i]), true, 0); + buffer_kill(app, buffers_to_close[i], BufferKill_AlwaysKill); } }while(do_repeat); } @@ -124,8 +123,7 @@ open_all_files_in_directory_pattern_match__recursive(Application_Links *app, String_Const_u8 full_path = push_u8_stringf(scratch, "%.*s%.*s", string_expand(path), string_expand(file_name)); - Buffer_ID ignore = 0; - create_buffer(app, full_path, 0, &ignore); + create_buffer(app, full_path, 0); } } @@ -861,7 +859,7 @@ exec_project_command(Application_Links *app, Project_Command *command){ Buffer_ID buffer = buffer_identifier_to_id(app, buffer_id); view = get_first_view_with_buffer(app, buffer); if (view == 0){ - get_active_view(app, AccessAll, &view); + view = get_active_view(app, AccessAll); } } @@ -1353,8 +1351,7 @@ CUSTOM_DOC("Open a lister of all commands in the currently loaded project.") if (current_project.loaded){ Arena *scratch = context_get_arena(app); - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); view_end_ui_mode(app, view); Temp_Memory temp = begin_temp(scratch); i32 option_count = current_project.command_array.count; diff --git a/4coder_scope_commands.cpp b/4coder_scope_commands.cpp index 0dbd8fc5..06250cd7 100644 --- a/4coder_scope_commands.cpp +++ b/4coder_scope_commands.cpp @@ -44,9 +44,9 @@ find_scope_top(Application_Links *app, Buffer_ID buffer, i32 start_pos, u32 flag Cpp_Get_Token_Result get_result = {}; b32 success = false; i32 position = 0; - if (buffer_get_token_index(app, buffer, start_pos, &get_result)){ + if (get_token_from_pos(app, buffer, start_pos, &get_result)){ i32 token_index = get_result.token_index; - if (flags & FindScope_Parent){ + if (HasFlag(flags, FindScope_Parent)){ --token_index; if (get_result.in_whitespace_after_token){ ++token_index; @@ -95,9 +95,9 @@ find_scope_bottom(Application_Links *app, Buffer_ID buffer, i32 start_pos, u32 f Cpp_Get_Token_Result get_result = {}; b32 success = false; i32 position = 0; - if (buffer_get_token_index(app, buffer, start_pos, &get_result)){ + if (get_token_from_pos(app, buffer, start_pos, &get_result)){ i32 token_index = get_result.token_index + 1; - if (flags & FindScope_Parent){ + if (HasFlag(flags, FindScope_Parent)){ --token_index; if (get_result.in_whitespace_after_token){ ++token_index; @@ -146,13 +146,13 @@ find_next_scope(Application_Links *app, Buffer_ID buffer, i32 start_pos, u32 fla Cpp_Get_Token_Result get_result = {}; b32 success = 0; i32 position = 0; - if (buffer_get_token_index(app, buffer, start_pos, &get_result)){ + if (get_token_from_pos(app, buffer, start_pos, &get_result)){ i32 token_index = get_result.token_index + 1; if (token_index >= 0){ Token_Range token_range = buffer_get_token_range(app, buffer); if (token_range.first != 0){ Token_Iterator token_it = make_token_iterator(token_range, token_index); - if ((flags & FindScope_NextSibling) != 0){ + if (HasFlag(flags, FindScope_NextSibling)){ i32 nest_level = 1; for (Cpp_Token *token = token_iterator_current(&token_it); token != 0; @@ -212,8 +212,8 @@ find_prev_scope(Application_Links *app, Buffer_ID buffer, i32 start_pos, u32 fla Cpp_Get_Token_Result get_result = {}; b32 success = false; i32 position = 0; - if (buffer_get_token_index(app, buffer, start_pos, &get_result)){ - i32 token_index = get_result.token_index-1; + if (get_token_from_pos(app, buffer, start_pos, &get_result)){ + i32 token_index = get_result.token_index - 1; if (token_index >= 0){ Token_Range token_range = buffer_get_token_range(app, buffer); if (token_range.first != 0){ @@ -301,8 +301,7 @@ view_set_to_region(Application_Links *app, View_ID view, i32 major_pos, i32 mino f32 top_y = top.wrapped_y; f32 bottom_y = bottom.wrapped_y; - Rect_i32 region = {}; - view_get_buffer_region(app, view, ®ion); + Rect_f32 region = view_get_buffer_region(app, view); GUI_Scroll_Vars scroll = {}; view_get_scroll_vars(app, view, &scroll); @@ -339,12 +338,9 @@ view_set_to_region(Application_Links *app, View_ID view, i32 major_pos, i32 mino CUSTOM_COMMAND_SIG(select_surrounding_scope) CUSTOM_DOC("Finds the scope enclosed by '{' '}' surrounding the cursor and puts the cursor and mark on the '{' and '}'.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessProtected, &buffer); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer = view_get_buffer(app, view, AccessProtected); + i32 pos = view_get_cursor_pos(app, view); Range range = {}; if (find_scope_range(app, buffer, pos, &range, FindScope_Brace)){ view_set_cursor(app, view, seek_pos(range.first), true); @@ -357,12 +353,9 @@ CUSTOM_DOC("Finds the scope enclosed by '{' '}' surrounding the cursor and puts CUSTOM_COMMAND_SIG(select_next_scope_absolute) CUSTOM_DOC("Finds the first scope started by '{' after the cursor and puts the cursor and mark on the '{' and '}'.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessProtected, &buffer); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer = view_get_buffer(app, view, AccessProtected); + i32 pos = view_get_cursor_pos(app, view); i32 start_pos = pos; i32 top = 0; i32 bottom = 0; @@ -379,12 +372,9 @@ CUSTOM_DOC("Finds the first scope started by '{' after the cursor and puts the c CUSTOM_COMMAND_SIG(select_prev_scope_absolute) CUSTOM_DOC("Finds the first scope started by '{' before the cursor and puts the cursor and mark on the '{' and '}'.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessProtected, &buffer); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer = view_get_buffer(app, view, AccessProtected); + i32 pos = view_get_cursor_pos(app, view); i32 start_pos = pos; i32 top = 0; i32 bottom = 0; @@ -400,10 +390,8 @@ CUSTOM_DOC("Finds the first scope started by '{' before the cursor and puts the static void place_begin_and_end_on_own_lines(Application_Links *app, char *begin, char *end){ - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); Range lines = {}; Range range = get_view_range(app, view); @@ -442,9 +430,8 @@ place_begin_and_end_on_own_lines(Application_Links *app, char *begin, char *end) max_adjustment += begin_str.size; Range new_pos = make_range(range.min + (i32)min_adjustment, range.max + (i32)max_adjustment); - i32 cursor_pos = 0; + i32 cursor_pos = view_get_cursor_pos(app, view); i32 mark_pos = 0; - view_get_cursor_pos(app, view, &cursor_pos); if (cursor_pos == range.min){ cursor_pos = new_pos.min; @@ -481,45 +468,35 @@ CUSTOM_DOC("Wraps the code contained in the range between cursor and mark with a CUSTOM_COMMAND_SIG(delete_current_scope) CUSTOM_DOC("Deletes the braces surrounding the currently selected scope. Leaves the contents within the scope.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); - i32 view_cursor_pos = 0; - view_get_cursor_pos(app, view, &view_cursor_pos); - i32 view_mark_pos = 0; - view_get_mark_pos(app, view, &view_mark_pos); + i32 view_cursor_pos = view_get_cursor_pos(app, view); + i32 view_mark_pos = view_get_mark_pos(app, view); - i32 top = view_cursor_pos; - i32 bottom = view_mark_pos; + Range range = make_range(view_cursor_pos, view_mark_pos); - if (top > bottom){ - i32 x = top; - top = bottom; - bottom = x; - } - - if (buffer_get_char(app, buffer, top) == '{' && buffer_get_char(app, buffer, bottom - 1) == '}'){ + if (buffer_get_char(app, buffer, range.min) == '{' && + buffer_get_char(app, buffer, range.max - 1) == '}'){ i32 top_len = 1; - i32 bottom_len = 1; - if (buffer_get_char(app, buffer, top - 1) == '\n'){ + i32 bot_len = 1; + if (buffer_get_char(app, buffer, range.min - 1) == '\n'){ top_len = 2; } - if (buffer_get_char(app, buffer, bottom + 1) == '\n'){ - bottom_len = 2; + if (buffer_get_char(app, buffer, range.max + 1) == '\n'){ + bot_len = 2; } Buffer_Edit edits[2]; edits[0].str_start = 0; edits[0].len = 0; - edits[0].start = top + 1 - top_len; - edits[0].end = top + 1; + edits[0].start = range.min + 1 - top_len; + edits[0].end = range.min + 1; edits[1].str_start = 0; edits[1].len = 0; - edits[1].start = bottom - 1; - edits[1].end = bottom - 1 + bottom_len; + edits[1].start = range.max - 1; + edits[1].end = range.max - 1 + bot_len; buffer_batch_edit(app, buffer, 0, edits, 2); } @@ -691,8 +668,7 @@ find_whole_statement_down(Application_Links *app, Buffer_ID buffer, i32 pos, i32 i32 end = start; Cpp_Get_Token_Result get_result = {}; - - if (buffer_get_token_index(app, buffer, pos, &get_result)){ + if (get_token_from_pos(app, buffer, pos, &get_result)){ Statement_Parser parser = make_statement_parser(app, buffer, get_result.token_index); if (parser.buffer != 0){ if (get_result.in_whitespace_after_token){ @@ -715,29 +691,19 @@ find_whole_statement_down(Application_Links *app, Buffer_ID buffer, i32 pos, i32 CUSTOM_COMMAND_SIG(scope_absorb_down) CUSTOM_DOC("If a scope is currently selected, and a statement or block statement is present below the current scope, the statement is moved into the scope.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessOpen, &buffer); + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); - i32 view_cursor_pos = 0; - view_get_cursor_pos(app, view, &view_cursor_pos); - i32 view_mark_pos = 0; - view_get_mark_pos(app, view, &view_mark_pos); + i32 view_cursor_pos = view_get_cursor_pos(app, view); + i32 view_mark_pos = view_get_mark_pos(app, view); - i32 top = view_cursor_pos; - i32 bottom = view_mark_pos; + Range range = make_range(view_cursor_pos, view_mark_pos); - if (top > bottom){ - i32 x = top; - top = bottom; - bottom = x; - } - - if (buffer_get_char(app, buffer, top) == '{' && buffer_get_char(app, buffer, bottom - 1) == '}'){ + if (buffer_get_char(app, buffer, range.min) == '{' && + buffer_get_char(app, buffer, range.max - 1) == '}'){ Scratch_Block scratch(app); Range range = {}; - if (find_whole_statement_down(app, buffer, bottom, &range.start, &range.end)){ + if (find_whole_statement_down(app, buffer, range.max, &range.start, &range.end)){ String_Const_u8 base_string = push_buffer_range(app, scratch, buffer, range); String_Const_u8 string = string_skip_chop_whitespace(base_string); @@ -764,8 +730,8 @@ CUSTOM_DOC("If a scope is currently selected, and a statement or block statement Buffer_Edit edits[2]; edits[0].str_start = 0; edits[0].len = (i32)edit_str.size; - edits[0].start = bottom - 1; - edits[0].end = bottom - 1; + edits[0].start = range.max - 1; + edits[0].end = range.max - 1; edits[1].str_start = 0; edits[1].len = 0; edits[1].start = range.start; diff --git a/4coder_search.cpp b/4coder_search.cpp index c3935c09..9598b148 100644 --- a/4coder_search.cpp +++ b/4coder_search.cpp @@ -495,10 +495,8 @@ initialize_generic_search_all_buffers(Application_Links *app, Heap *heap, String Search_Range *ranges = set->ranges; - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessProtected, &buffer); + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer = view_get_buffer(app, view, AccessProtected); i32 j = 0; if (buffer_exists(app, buffer)){ @@ -515,15 +513,14 @@ initialize_generic_search_all_buffers(Application_Links *app, Heap *heap, String ranges[j].flags = match_flags; ranges[j].buffer = buffer; ranges[j].start = 0; - buffer_get_size(app, buffer, &ranges[j].size); + ranges[j].size = (i32)buffer_get_size(app, buffer); ++j; } } - Buffer_ID buffer_it = 0; - for (get_buffer_next(app, 0, AccessAll, &buffer_it); + for (Buffer_ID buffer_it = get_buffer_next(app, 0, AccessAll); buffer_exists(app, buffer_it); - get_buffer_next(app, buffer_it, AccessAll, &buffer_it)){ + buffer_it = get_buffer_next(app, buffer_it, AccessAll)){ if (buffer_it == buffer){ continue; } @@ -542,7 +539,7 @@ initialize_generic_search_all_buffers(Application_Links *app, Heap *heap, String ranges[j].flags = match_flags; ranges[j].buffer = buffer_it; ranges[j].start = 0; - buffer_get_size(app, buffer_it, &ranges[j].size); + ranges[j].size = (i32)buffer_get_size(app, buffer_it); ++j; } } @@ -583,8 +580,8 @@ list__parameters_buffer(Application_Links *app, Heap *heap, for (Search_Match match = search_next_match(app, &set, &iter); match.found_match; match = search_next_match(app, &set, &iter)){ - Partial_Cursor word_pos = {}; - if (buffer_compute_cursor(app, match.buffer, seek_pos(match.start), &word_pos)){ + Partial_Cursor word_pos = buffer_compute_cursor(app, match.buffer, seek_pos(match.start)); + if (word_pos.line > 0){ if (prev_match_id != match.buffer){ if (prev_match_id != 0){ insertc(&out, '\n'); @@ -650,13 +647,10 @@ list_query__parameters(Application_Links *app, Heap *heap, b32 substrings, b32 c static void list_identifier__parameters(Application_Links *app, Heap *heap, b32 substrings, b32 case_insensitive, View_ID default_target_view){ - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessProtected, &buffer); + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer = view_get_buffer(app, view, AccessProtected); if (buffer != 0){ - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + i32 pos = view_get_cursor_pos(app, view); Scratch_Block scratch(app); String_Const_u8 str = get_token_or_word_under_pos(app, scratch, buffer, pos); if (str.size > 0){ @@ -667,8 +661,7 @@ list_identifier__parameters(Application_Links *app, Heap *heap, b32 substrings, static void list_selected_range__parameters(Application_Links *app, Heap *heap, b32 substrings, b32 case_insensitive, View_ID default_target_view){ - View_ID view = 0; - get_active_view(app, AccessProtected, &view); + View_ID view = get_active_view(app, AccessProtected); Arena *scratch = context_get_arena(app); Temp_Memory temp = begin_temp(scratch); String_Const_u8 str = push_string_in_view_range(app, scratch, view); @@ -772,12 +765,9 @@ CUSTOM_DOC("Queries user for string, lists all locations of strings that appear CUSTOM_COMMAND_SIG(list_all_locations_of_type_definition_of_identifier) CUSTOM_DOC("Reads a token or word under the cursor and lists all locations of strings that appear to define a type whose name matches it.") { - View_ID target_view = 0; - get_active_view(app, AccessProtected, &target_view); - Buffer_ID buffer = 0; - view_get_buffer(app, target_view, AccessProtected, &buffer); - i32 pos = 0; - view_get_cursor_pos(app, target_view, &pos); + View_ID target_view = get_active_view(app, AccessProtected); + Buffer_ID buffer = view_get_buffer(app, target_view, AccessProtected); + i32 pos = view_get_cursor_pos(app, target_view); Scratch_Block scratch(app); String_Const_u8 str = get_token_or_word_under_pos(app, scratch, buffer, pos); if (str.size > 0){ @@ -796,10 +786,9 @@ static Word_Complete_State complete_state = {}; CUSTOM_COMMAND_SIG(word_complete) CUSTOM_DOC("Iteratively tries completing the word to the left of the cursor with other words in open buffers that have the same prefix string.") { - View_ID view = 0; - get_active_view(app, AccessOpen, &view); - Buffer_ID buffer = 0; - if (view_get_buffer(app, view, AccessOpen, &buffer)){ + View_ID view = get_active_view(app, AccessOpen); + Buffer_ID buffer = view_get_buffer(app, view, AccessOpen); + if (buffer != 0){ i32 do_init = false; Managed_Scope scope = 0; @@ -823,8 +812,7 @@ CUSTOM_DOC("Iteratively tries completing the word to the left of the cursor with if (do_init){ // NOTE(allen): Get the range where the // partial word is written. - word_end = 0; - view_get_cursor_pos(app, view, &word_end); + word_end = view_get_cursor_pos(app, view); word_start = word_end; cursor_pos = word_end - 1; @@ -872,22 +860,22 @@ CUSTOM_DOC("Iteratively tries completing the word to the left of the cursor with ranges[0].flags = SearchFlag_MatchWordPrefix; ranges[0].buffer = buffer; ranges[0].start = 0; - buffer_get_size(app, buffer, &ranges[0].size); + ranges[0].size = (i32)buffer_get_size(app, buffer); ranges[0].mid_start = word_start; ranges[0].mid_size = (i32)size; Buffer_ID buffer_it = 0; i32 j = 1; - for (get_buffer_next(app, 0, AccessAll, &buffer_it); + for (buffer_it = get_buffer_next(app, 0, AccessAll); buffer_it != 0; - get_buffer_next(app, buffer_it, AccessAll, &buffer_it)){ + buffer_it = get_buffer_next(app, buffer_it, AccessAll)){ if (buffer != buffer_it){ ranges[j].type = SearchRange_FrontToBack; ranges[j].flags = SearchFlag_MatchWordPrefix; ranges[j].buffer = buffer_it; ranges[j].start = 0; - buffer_get_size(app, buffer_it, &ranges[j].size); + ranges[j].size = (i32)buffer_get_size(app, buffer_it); ++j; } } diff --git a/4coder_seek.cpp b/4coder_seek.cpp index e59e110d..14bdc41f 100644 --- a/4coder_seek.cpp +++ b/4coder_seek.cpp @@ -6,12 +6,9 @@ internal void seek_pos_of_textual_line(Application_Links *app, Side side){ - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer_id = 0; - view_get_buffer(app, view, AccessProtected, &buffer_id); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer_id = view_get_buffer(app, view, AccessProtected); + i32 pos = view_get_cursor_pos(app, view); i32 new_pos = get_line_side_pos_from_pos(app, buffer_id, pos, side); view_set_cursor(app, view, seek_pos(new_pos), true); no_mark_snap_to_cursor_if_shift(app, view); @@ -19,10 +16,8 @@ seek_pos_of_textual_line(Application_Links *app, Side side){ internal void seek_pos_of_visual_line(Application_Links *app, Side side){ - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - i32 pos = 0; - view_get_cursor_pos(app, view, &pos); + View_ID view = get_active_view(app, AccessProtected); + i32 pos = view_get_cursor_pos(app, view); Full_Cursor cursor = {}; view_compute_cursor(app, view, seek_pos(pos), &cursor); f32 y = cursor.wrapped_y; @@ -58,8 +53,7 @@ CUSTOM_DOC("Seeks the cursor to the end of the visual line.") CUSTOM_COMMAND_SIG(goto_beginning_of_file) CUSTOM_DOC("Sets the cursor to the beginning of the file.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); + View_ID view = get_active_view(app, AccessProtected); view_set_cursor(app, view, seek_pos(0), true); no_mark_snap_to_cursor_if_shift(app, view); } @@ -67,12 +61,9 @@ CUSTOM_DOC("Sets the cursor to the beginning of the file.") CUSTOM_COMMAND_SIG(goto_end_of_file) CUSTOM_DOC("Sets the cursor to the end of the file.") { - View_ID view = 0; - get_active_view(app, AccessProtected, &view); - Buffer_ID buffer_id = 0; - view_get_buffer(app, view, AccessProtected, &buffer_id); - i32 size = 0; - buffer_get_size(app, buffer_id, &size); + View_ID view = get_active_view(app, AccessProtected); + Buffer_ID buffer_id = view_get_buffer(app, view, AccessProtected); + i32 size = (i32)buffer_get_size(app, buffer_id); view_set_cursor(app, view, seek_pos(size), true); no_mark_snap_to_cursor_if_shift(app, view); } diff --git a/4coder_system_command.cpp b/4coder_system_command.cpp index 9766bcba..60fb9383 100644 --- a/4coder_system_command.cpp +++ b/4coder_system_command.cpp @@ -12,8 +12,7 @@ CUSTOM_DOC("If the command execute_any_cli has already been used, this will exec String_Const_u8 hot_directory = SCu8(hot_directory_space); if (out_buffer.size > 0 && cmd.size > 0 && hot_directory.size > 0){ - View_ID view = 0; - get_active_view(app, AccessAll, &view); + View_ID view = get_active_view(app, AccessAll); Buffer_Identifier id = buffer_identifier(out_buffer); exec_system_command(app, view, id, hot_directory, cmd, CLI_OverlapWithConflict|CLI_CursorAtEnd|CLI_SendEndSignal); lock_jump_buffer(out_buffer); diff --git a/4coder_ui_helper.cpp b/4coder_ui_helper.cpp index 0fa9bf69..081b0ce8 100644 --- a/4coder_ui_helper.cpp +++ b/4coder_ui_helper.cpp @@ -138,10 +138,10 @@ ui_control_set_bottom(UI_Data *data, i32 bottom_y){ } static UI_Item* -ui_control_get_mouse_hit(UI_Data *data, Vec2_i32 view_p, Vec2_i32 panel_p){ +ui_control_get_mouse_hit(UI_Data *data, Vec2_f32 view_p, Vec2_f32 panel_p){ UI_Item *result = 0; for (UI_Item *item = data->list.first; item != 0 && result == 0; item = item->next){ - i32_Rect r = item->rect_outer; + Rect_f32 r = Rf32(item->rect_outer); switch (item->coordinates){ case UICoordinates_ViewSpace: { @@ -160,10 +160,12 @@ ui_control_get_mouse_hit(UI_Data *data, Vec2_i32 view_p, Vec2_i32 panel_p){ return(result); } +#if 0 static UI_Item* ui_control_get_mouse_hit(UI_Data *data, i32 mx_scrolled, i32 my_scrolled, i32 mx_unscrolled, i32 my_unscrolled){ return(ui_control_get_mouse_hit(data, V2i32(mx_scrolled, my_scrolled), V2i32(mx_unscrolled, my_unscrolled))); } +#endif //////////////////////////////// @@ -174,86 +176,74 @@ view_zero_scroll(Application_Links *app, View_ID view){ } static void -view_set_vertical_focus(Application_Links *app, View_ID view, i32 y_top, i32 y_bot){ - Rect_i32 buffer_region = {}; - view_get_buffer_region(app, view, &buffer_region); +view_set_vertical_focus(Application_Links *app, View_ID view, f32 y_top, f32 y_bot){ + Rect_f32 buffer_region = view_get_buffer_region(app, view); GUI_Scroll_Vars scroll = {}; view_get_scroll_vars(app, view, &scroll); - i32 view_y_top = scroll.target_y; - i32 view_y_dim = rect_height(buffer_region); - i32 view_y_bot = view_y_top + view_y_dim; + f32 view_y_top = (f32)scroll.target_y; + f32 view_y_dim = rect_height(buffer_region); + f32 view_y_bot = view_y_top + view_y_dim; - Buffer_ID buffer = 0; - view_get_buffer(app, view, AccessAll, &buffer); + Buffer_ID buffer = view_get_buffer(app, view, AccessAll); Face_ID face_id = 0; get_face_id(app, buffer, &face_id); Face_Metrics metrics = {}; get_face_metrics(app, face_id, &metrics); - i32 line_dim = (i32)metrics.line_height; - i32 hot_y_top = view_y_top + line_dim*3; - i32 hot_y_bot = view_y_bot - line_dim*3; + f32 line_dim = metrics.line_height; + f32 hot_y_top = view_y_top + line_dim*3; + f32 hot_y_bot = view_y_bot - line_dim*3; if (hot_y_bot - hot_y_top < line_dim*6){ - i32 quarter_view_y_dim = view_y_dim/4; + f32 quarter_view_y_dim = view_y_dim*.25f; hot_y_top = view_y_top + quarter_view_y_dim; hot_y_bot = view_y_bot - quarter_view_y_dim; } - i32 hot_y_dim = hot_y_bot - hot_y_top; - i32 skirt_dim = hot_y_top - view_y_top; - i32 y_dim = y_bot - y_top; + f32 hot_y_dim = hot_y_bot - hot_y_top; + f32 skirt_dim = hot_y_top - view_y_top; + f32 y_dim = y_bot - y_top; if (y_dim > hot_y_dim){ - scroll.target_y = y_top - skirt_dim; + scroll.target_y = (i32)(y_top - skirt_dim); view_set_scroll(app, view, scroll); } else{ if (y_top < hot_y_top){ - scroll.target_y = y_top - skirt_dim; + scroll.target_y = (i32)(y_top - skirt_dim); view_set_scroll(app, view, scroll); } else if (y_bot > hot_y_bot){ - scroll.target_y = y_bot + skirt_dim - view_y_dim; + scroll.target_y = (i32)(y_bot + skirt_dim - view_y_dim); view_set_scroll(app, view, scroll); } } } -static Vec2 -view_space_from_screen_space(Vec2 p, Vec2 file_region_p0, Vec2 scroll_p){ +static Vec2_f32 +view_space_from_screen_space(Vec2_f32 p, Vec2_f32 file_region_p0, Vec2_f32 scroll_p){ return(p - file_region_p0 + scroll_p); } -static Vec2_i32 -view_space_from_screen_space(Vec2_i32 p, Vec2_i32 file_region_p0, Vec2_i32 scroll_p){ - return(p - file_region_p0 + scroll_p); +static Vec2_f32 +get_mouse_position_in_view_space(Mouse_State mouse, Vec2_f32 file_region_p0, Vec2_f32 scroll_p){ + return(view_space_from_screen_space(V2f32(mouse.p), file_region_p0, scroll_p)); } -static Vec2_i32 -get_mouse_position_in_view_space(Mouse_State mouse, Vec2_i32 file_region_p0, Vec2_i32 scroll_p){ - return(view_space_from_screen_space(mouse.p, file_region_p0, scroll_p)); -} - -static Vec2_i32 -get_mouse_position_in_view_space(Application_Links *app, Vec2_i32 file_region_p0, Vec2_i32 scroll_p){ +static Vec2_f32 +get_mouse_position_in_view_space(Application_Links *app, Vec2_f32 file_region_p0, Vec2_f32 scroll_p){ return(get_mouse_position_in_view_space(get_mouse_state(app), file_region_p0, scroll_p)); } -static Vec2 -panel_space_from_screen_space(Vec2 p, Vec2 file_region_p0){ +static Vec2_f32 +panel_space_from_screen_space(Vec2_f32 p, Vec2_f32 file_region_p0){ return(p - file_region_p0); } -static Vec2_i32 -panel_space_from_screen_space(Vec2_i32 p, Vec2_i32 file_region_p0){ - return(p - file_region_p0); +static Vec2_f32 +get_mouse_position_in_panel_space(Mouse_State mouse, Vec2_f32 file_region_p0){ + return(panel_space_from_screen_space(V2f32(mouse.p), file_region_p0)); } -static Vec2_i32 -get_mouse_position_in_panel_space(Mouse_State mouse, Vec2_i32 file_region_p0){ - return(panel_space_from_screen_space(mouse.p, file_region_p0)); -} - -static Vec2_i32 -get_mouse_position_in_panel_space(Application_Links *app, Vec2_i32 file_region_p0){ +static Vec2_f32 +get_mouse_position_in_panel_space(Application_Links *app, Vec2_f32 file_region_p0){ return(get_mouse_position_in_panel_space(get_mouse_state(app), file_region_p0)); } @@ -314,11 +304,10 @@ lister_get_clicked_item(Application_Links *app, View_ID view_id){ GUI_Scroll_Vars scroll_vars = {}; view_get_scroll_vars(app, view_id, &scroll_vars); Mouse_State mouse = get_mouse_state(app); - Rect_i32 buffer_region = {}; - view_get_buffer_region(app, view_id, &buffer_region); - Vec2_i32 region_p0 = buffer_region.p0; - Vec2_i32 m_view_space = get_mouse_position_in_view_space(mouse, region_p0, V2i32(scroll_vars.scroll_p)); - Vec2_i32 m_panel_space = get_mouse_position_in_panel_space(mouse, region_p0); + Rect_f32 buffer_region = view_get_buffer_region(app, view_id); + Vec2_f32 region_p0 = buffer_region.p0; + Vec2_f32 m_view_space = get_mouse_position_in_view_space(mouse, region_p0, scroll_vars.scroll_p); + Vec2_f32 m_panel_space = get_mouse_position_in_panel_space(mouse, region_p0); UI_Item *clicked = ui_control_get_mouse_hit(ui_data, m_view_space, m_panel_space); if (clicked != 0){ result = *clicked; @@ -348,8 +337,7 @@ static void lister_update_ui(Application_Links *app, View_ID view, Lister_State *state){ b32 is_theme_list = state->lister.data.theme_list; - Rect_f32 screen_rect = {}; - view_get_screen_rect(app, view, &screen_rect); + Rect_f32 screen_rect = view_get_screen_rect(app, view); Face_ID face_id = 0; get_face_id(app, 0, &face_id); @@ -369,9 +357,8 @@ lister_update_ui(Application_Links *app, View_ID view, Lister_State *state){ Temp_Memory full_temp = begin_temp(scratch); // TODO(allen): switch to float - Rect_i32 buffer_region = {}; - view_get_buffer_region(app, view, &buffer_region); - Vec2_i32 view_m = get_mouse_position_in_view_space(app, buffer_region.p0, V2i32(scroll_vars.scroll_p)); + Rect_f32 buffer_region = view_get_buffer_region(app, view); + Vec2_f32 view_m = get_mouse_position_in_view_space(app, buffer_region.p0, scroll_vars.scroll_p); f32 y_pos = text_field_height; @@ -434,18 +421,13 @@ lister_update_ui(Application_Links *app, View_ID view, Lister_State *state){ for (i32 node_index = 0; node_index < node_ptr_array.count; node_index += 1){ Lister_Node *node = node_ptr_array.node_ptrs[node_index]; - // TODO(allen): switch to float - i32_Rect item_rect = {}; - item_rect.x0 = (i32)x0; - item_rect.y0 = (i32)y_pos; - item_rect.x1 = (i32)x1; - item_rect.y1 = (i32)y_pos + (i32)block_height; - y_pos = (f32)item_rect.y1; + Rect_f32 item_rect = Rf32(x0, y_pos, x1, y_pos + block_height); + y_pos = item_rect.y1; UI_Item item = {}; item.activation_level = UIActivation_None; item.coordinates = UICoordinates_ViewSpace; - item.rect_outer = item_rect; + item.rect_outer = Ri32(item_rect); item.inner_margin = 3; if (!is_theme_list){ @@ -477,7 +459,6 @@ lister_update_ui(Application_Links *app, View_ID view, Lister_State *state){ item.user_data = node->user_data; - UI_Item *item_ptr = ui_list_add_item(ui_arena, &ui_data->list, item); if (rect_contains_point(item_rect, view_m)){ hovered_item = item_ptr; @@ -511,7 +492,9 @@ lister_update_ui(Application_Links *app, View_ID view, Lister_State *state){ if (state->set_view_vertical_focus_to_item){ if (highlighted_item != 0){ - view_set_vertical_focus(app, view, highlighted_item->rect_outer.y0, highlighted_item->rect_outer.y1); + view_set_vertical_focus(app, view, + (f32)highlighted_item->rect_outer.y0, + (f32)highlighted_item->rect_outer.y1); } state->set_view_vertical_focus_to_item = false; } diff --git a/4ed_api_implementation.cpp b/4ed_api_implementation.cpp index dafcfe02..ab93d367 100644 --- a/4ed_api_implementation.cpp +++ b/4ed_api_implementation.cpp @@ -83,12 +83,10 @@ DOC(Dumps away the previous mappings and instantiates the mappings described in return(result); } -API_EXPORT b32 -Global_Get_Screen_Rectangle(Application_Links *app, Rect_f32 *rect_out){ +API_EXPORT Rect_f32 +Global_Get_Screen_Rectangle(Application_Links *app){ Models *models = (Models*)app->cmd_context; - rect_out->p0 = V2(0, 0); - rect_out->p1 = V2(layout_get_root_size(&models->layout)); - return(true); + return(Rf32(V2(0, 0), V2(layout_get_root_size(&models->layout)))); } API_EXPORT Arena* @@ -122,48 +120,32 @@ Child_Process_Set_Target_Buffer(Application_Links *app, Child_Process_ID child_p return(result); } -API_EXPORT b32 -Buffer_Get_Attached_Child_Process(Application_Links *app, Buffer_ID buffer_id, Child_Process_ID *child_process_id_out){ +API_EXPORT Child_Process_ID +Buffer_Get_Attached_Child_Process(Application_Links *app, Buffer_ID buffer_id){ Models *models = (Models*)app->cmd_context; Editing_File *file = imp_get_file(models, buffer_id); - b32 result = false; + Child_Process_ID result = 0; if (api_check_buffer(file)){ - *child_process_id_out = file->state.attached_child_process; - result = true; + result = file->state.attached_child_process; } return(result); } -API_EXPORT b32 -Child_Process_Get_Attached_Buffer(Application_Links *app, Child_Process_ID child_process_id, Buffer_ID *buffer_id_out){ +API_EXPORT Buffer_ID +Child_Process_Get_Attached_Buffer(Application_Links *app, Child_Process_ID child_process_id){ Models *models = (Models*)app->cmd_context; Child_Process *child_process = child_process_from_id(&models->child_processes, child_process_id); - b32 result = false; - if (child_process != 0){ - Editing_File *out_file = child_process->out_file; - *buffer_id_out = out_file->id.id; - result = true; + Buffer_ID result = 0; + if (child_process != 0 && child_process->out_file != 0){ + result = child_process->out_file->id.id; } return(result); } -API_EXPORT b32 -Child_Process_Get_State(Application_Links *app, Child_Process_ID child_process_id, Process_State *process_state_out){ +API_EXPORT Process_State +Child_Process_Get_State(Application_Links *app, Child_Process_ID child_process_id){ Models *models = (Models*)app->cmd_context; - Child_Process *child_process = child_process_from_id(&models->child_processes, child_process_id); - b32 result = false; - if (child_process != 0){ - process_state_out->is_updating = true; - process_state_out->return_code = 0; - result = true; - } - else{ - if (child_process_lookup_return_code(&models->child_processes, child_process_id, &process_state_out->return_code)){ - process_state_out->is_updating = false; - result = true; - } - } - return(result); + return(child_process_get_state(&models->child_processes, child_process_id)); } // TODO(allen): redocument @@ -184,22 +166,20 @@ DOC_SEE(The_4coder_Clipboard) } // TODO(casey): Allen, why does this return a bool? Like, shouldn't it just return the count? If there's nothing in that clipboard, it'd just be 0? -API_EXPORT b32 -Clipboard_Count(Application_Links *app, i32 clipboard_id, i32 *count_out) +API_EXPORT i32 +Clipboard_Count(Application_Links *app, i32 clipboard_id) /* DOC_PARAM(clipboard_id, This parameter is set up to prepare for future features, it should always be 0 for now.) DOC(This call returns the number of items in the clipboard.) DOC_SEE(The_4coder_Clipboard) */{ Models *models = (Models*)app->cmd_context; - Working_Set *working = &models->working_set; - *count_out = working->clipboard_size; - return(true); + return(models->working_set.clipboard_size); } // TODO(allen): redocument -API_EXPORT b32 -Clipboard_Index(Application_Links *app, i32 clipboard_id, i32 item_index, Arena *out, String_Const_u8 *string_out) +API_EXPORT String_Const_u8 +Push_Clipboard_Index(Application_Links *app, Arena *arena, i32 clipboard_id, i32 item_index) /* DOC_PARAM(clipboard_id, This parameter is set up to prepare for future features, it should always be 0 for now.) DOC_PARAM(item_index, This parameter specifies which item to read, 0 is the most recent copy, 1 is the second most recent copy, etc.) @@ -214,10 +194,9 @@ DOC_SEE(The_4coder_Clipboard) */{ Models *models = (Models*)app->cmd_context; String_Const_u8 *str = working_set_clipboard_index(&models->working_set, item_index); - b32 result = false; + String_Const_u8 result = {}; if (str != 0){ - *string_out = string_copy(out, *str); - result = true; + result = string_copy(arena, *str); } return(result); } @@ -248,8 +227,8 @@ DOC(Gives the total number of buffers in the application.) } // TODO(allen): redocument -API_EXPORT b32 -Get_Buffer_Next(Application_Links *app, Buffer_ID buffer_id, Access_Flag access, Buffer_ID *buffer_id_out) +API_EXPORT Buffer_ID +Get_Buffer_Next(Application_Links *app, Buffer_ID buffer_id, Access_Flag access) /* DOC_PARAM(buffer, The pointed to by buffer is iterated to the next buffer or to a null summary if this is the last buffer.) DOC_PARAM(access, The access parameter determines what levels of protection this call can access. The buffer outputted will be the next buffer that is accessible.) @@ -270,20 +249,16 @@ DOC_SEE(get_buffer_first) for (;file != 0 && !access_test(file_get_access_flags(file), access);){ file = file_get_next(working_set, file); } - b32 result = false; + Buffer_ID result = 0; if (file != 0){ - *buffer_id_out = file->id.id; - result = true; - } - else{ - *buffer_id_out = 0; + result = file->id.id; } return(result); } // TODO(allen): redocument -API_EXPORT b32 -Get_Buffer_By_Name(Application_Links *app, String_Const_u8 name, Access_Flag access, Buffer_ID *buffer_id_out) +API_EXPORT Buffer_ID +Get_Buffer_By_Name(Application_Links *app, String_Const_u8 name, Access_Flag access) /* DOC_PARAM(name, The name parameter specifies the buffer name to try to get. The string need not be null terminated.) DOC_PARAM(len, The len parameter specifies the length of the name string.) @@ -298,17 +273,16 @@ DOC_SEE(Access_Flag) Models *models = (Models*)app->cmd_context; Working_Set *working_set = &models->working_set; Editing_File *file = working_set_contains_name(working_set, name); - b32 result = false; + Buffer_ID result = 0; if (api_check_buffer(file, access)){ - *buffer_id_out = file->id.id; - result = true; + result = file->id.id; } return(result); } // TODO(allen): redocument -API_EXPORT b32 -Get_Buffer_By_File_Name(Application_Links *app, String_Const_u8 file_name, Access_Flag access, Buffer_ID *buffer_id_out) +API_EXPORT Buffer_ID +Get_Buffer_By_File_Name(Application_Links *app, String_Const_u8 file_name, Access_Flag access) /* DOC_PARAM(name, The name parameter specifies the buffer name to try to get. The string need not be null terminated.) DOC_PARAM(len, The len parameter specifies the length of the name string.) @@ -323,14 +297,13 @@ DOC_SEE(Access_Flag) { Models *models = (Models*)app->cmd_context; System_Functions *system = models->system; - Working_Set *working_set = &models->working_set; Editing_File_Name canon = {}; - b32 result = false; + Buffer_ID result = false; if (get_canon_name(system, file_name, &canon)){ + Working_Set *working_set = &models->working_set; Editing_File *file = working_set_contains_canon(working_set, string_from_file_name(&canon)); if (api_check_buffer(file, access)){ - *buffer_id_out = file->id.id; - result = true; + result = file->id.id; } } return(result); @@ -420,48 +393,15 @@ DOC_SEE(Buffer_Batch_Edit_Type) return(result); } -internal b32 -chunked_match(String_Const_u8_Array chunks, String_Const_u8 needle, - i32 chunk_index, i32 chunk_pos, b32 *case_sensitive_out){ - b32 result = false; - if (chunk_pos + (imem)(needle.size) <= (imem)(chunks.vals[chunk_index].size)){ - String_Const_u8 s = SCu8(chunks.vals[chunk_index].str + chunk_pos, needle.size); - if (string_match(needle, s)){ - *case_sensitive_out = true; - result = true; - } - else if (string_match_insensitive(needle, s)){ - *case_sensitive_out = false; - result = true; - } - } - else{ - String_Const_u8 c = chunks.vals[chunk_index]; - u8 *str = c.str; - String_Const_u8 s = SCu8(str + chunk_pos, str + c.size); - String_Const_u8 p = string_prefix(needle, s.size); - if (string_match(p, s)){ - result = chunked_match(chunks, string_skip(needle, s.size), - chunk_index + 1, 0, case_sensitive_out); - } - else if (string_match_insensitive(p, s)){ - result = chunked_match(chunks, string_skip(needle, s.size), - chunk_index + 1, 0, case_sensitive_out); - *case_sensitive_out = false; - } - } - return(result); -} - -API_EXPORT b32 -Buffer_Seek_String(Application_Links *app, Buffer_ID buffer, String_Const_u8 needle, Scan_Direction direction, i32 start_pos, i32 *pos_out, b32 *case_sensitive_out){ +API_EXPORT String_Match +Buffer_Seek_String(Application_Links *app, Buffer_ID buffer, String_Const_u8 needle, Scan_Direction direction, i32 start_pos){ Models *models = (Models*)app->cmd_context; Editing_File *file = imp_get_file(models, buffer); - b32 result = false; + String_Match result = {}; if (api_check_buffer(file)){ if (needle.size == 0){ - *pos_out = start_pos; - *case_sensitive_out = true; + result.flags = StringMatch_CaseSensitive; + result.range = make_range_u64(start_pos); } else{ Scratch_Block scratch(app); @@ -489,13 +429,11 @@ Buffer_Seek_String(Application_Links *app, Buffer_ID buffer, String_Const_u8 nee chunks, needle, jump_table, &dummy, direction, range.min, 0, 0); if (list.count == 1){ - result = true; - *pos_out = (i32)list.first->range.first; - *case_sensitive_out = (HasFlag(list.first->flags, StringMatch_CaseSensitive)); + result = *list.first; } } else{ - *pos_out = start_pos; + result.range = make_range_u64(start_pos); } } } @@ -544,8 +482,8 @@ Buffer_Seek_Character_Class(Application_Links *app, Buffer_ID buffer_id, Charact } // TODO(allen): redocument -API_EXPORT b32 -Buffer_Compute_Cursor(Application_Links *app, Buffer_ID buffer_id, Buffer_Seek seek, Partial_Cursor *cursor_out) +API_EXPORT Partial_Cursor +Buffer_Compute_Cursor(Application_Links *app, Buffer_ID buffer_id, Buffer_Seek seek) /* DOC_PARAM(buffer, The buffer parameter specifies the buffer on which to run the cursor computation.) DOC_PARAM(seek, The seek parameter specifies the target position for the seek.) @@ -561,14 +499,9 @@ DOC_SEE(Partial_Cursor) */{ Models *models = (Models*)app->cmd_context; Editing_File *file = imp_get_file(models, buffer_id); - b32 result = false; + Partial_Cursor result = {}; if (api_check_buffer(file)){ - if (file->settings.unwrapped_lines && seek.type == buffer_seek_wrapped_xy){ - seek.type = buffer_seek_unwrapped_xy; - } - if (file_compute_partial_cursor(file, seek, cursor_out)){ - result = true; - } + result = file_compute_partial_cursor(file, seek); } return(result); } @@ -591,92 +524,85 @@ Buffer_Ready(Application_Links *app, Buffer_ID buffer_id){ return(result); } -API_EXPORT b32 -Buffer_Get_Access_Flags(Application_Links *app, Buffer_ID buffer_id, Access_Flag *access_flags_out){ +API_EXPORT Access_Flag +Buffer_Get_Access_Flags(Application_Links *app, Buffer_ID buffer_id){ Models *models = (Models*)app->cmd_context; Editing_File *file = imp_get_file(models, buffer_id); - b32 result = false; + Access_Flag result = 0; if (api_check_buffer(file)){ - *access_flags_out = file_get_access_flags(file); - result = true; + result = file_get_access_flags(file); + } + return(result); +} + +API_EXPORT u64 +Buffer_Get_Size(Application_Links *app, Buffer_ID buffer_id){ + Models *models = (Models*)app->cmd_context; + Editing_File *file = imp_get_file(models, buffer_id); + u64 result = 0; + if (api_check_buffer(file)){ + result = buffer_size(&file->state.buffer); + } + return(result); +} + +API_EXPORT u64 +Buffer_Get_Line_Count(Application_Links *app, Buffer_ID buffer_id){ + Models *models = (Models*)app->cmd_context; + Editing_File *file = imp_get_file(models, buffer_id); + u64 result = 0; + if (api_check_buffer(file)){ + result = file->state.buffer.line_count; + } + return(result); +} + +API_EXPORT String_Const_u8 +Push_Buffer_Base_Name(Application_Links *app, Arena *arena, Buffer_ID buffer_id){ + Models *models = (Models*)app->cmd_context; + Editing_File *file = imp_get_file(models, buffer_id); + String_Const_u8 result = {}; + if (api_check_buffer(file)){ + result = string_copy(arena, string_from_file_name(&file->base_name)); + } + return(result); +} + +API_EXPORT String_Const_u8 +Push_Buffer_Unique_Name(Application_Links *app, Arena *out, Buffer_ID buffer_id){ + Models *models = (Models*)app->cmd_context; + Editing_File *file = imp_get_file(models, buffer_id); + String_Const_u8 result = {}; + if (api_check_buffer(file)){ + result = string_copy(out, string_from_file_name(&file->unique_name)); + } + return(result); +} + +API_EXPORT String_Const_u8 +Push_Buffer_File_Name(Application_Links *app, Arena *arena, Buffer_ID buffer_id){ + Models *models = (Models*)app->cmd_context; + Editing_File *file = imp_get_file(models, buffer_id); + String_Const_u8 result = {}; + if (api_check_buffer(file)){ + result = string_copy(arena, string_from_file_name(&file->canon)); + } + return(result); +} + +API_EXPORT Dirty_State +Buffer_Get_Dirty_State(Application_Links *app, Buffer_ID buffer_id){ + Models *models = (Models*)app->cmd_context; + Editing_File *file = imp_get_file(models, buffer_id); + Dirty_State result = {}; + if (api_check_buffer(file)){ + result = file->state.dirty; } return(result); } API_EXPORT b32 -Buffer_Get_Size(Application_Links *app, Buffer_ID buffer_id, i32 *size_out){ - Models *models = (Models*)app->cmd_context; - Editing_File *file = imp_get_file(models, buffer_id); - b32 result = false; - if (api_check_buffer(file)){ - *size_out = buffer_size(&file->state.buffer); - result = true; - } - return(result); -} - -API_EXPORT b32 -Buffer_Get_Line_Count(Application_Links *app, Buffer_ID buffer_id, i32 *line_count_out){ - Models *models = (Models*)app->cmd_context; - Editing_File *file = imp_get_file(models, buffer_id); - b32 result = false; - if (api_check_buffer(file)){ - *line_count_out = file->state.buffer.line_count; - result = true; - } - return(result); -} - -API_EXPORT b32 -Buffer_Get_Base_Buffer_Name(Application_Links *app, Buffer_ID buffer_id, Arena *out, String_Const_u8 *name_out){ - Models *models = (Models*)app->cmd_context; - Editing_File *file = imp_get_file(models, buffer_id); - b32 result = false; - if (api_check_buffer(file)){ - *name_out = string_copy(out, string_from_file_name(&file->base_name)); - result = true; - } - return(result); -} - -API_EXPORT b32 -Buffer_Get_Unique_Buffer_Name(Application_Links *app, Buffer_ID buffer_id, Arena *out, String_Const_u8 *name_out){ - Models *models = (Models*)app->cmd_context; - Editing_File *file = imp_get_file(models, buffer_id); - b32 result = false; - if (api_check_buffer(file)){ - *name_out = string_copy(out, string_from_file_name(&file->unique_name)); - result = true; - } - return(result); -} - -API_EXPORT b32 -Buffer_Get_File_Name(Application_Links *app, Buffer_ID buffer_id, Arena *out, String_Const_u8 *name_out){ - Models *models = (Models*)app->cmd_context; - Editing_File *file = imp_get_file(models, buffer_id); - b32 result = false; - if (api_check_buffer(file)){ - *name_out = string_copy(out, string_from_file_name(&file->canon)); - result = true; - } - return(result); -} - -API_EXPORT b32 -Buffer_Get_Dirty_State(Application_Links *app, Buffer_ID buffer_id, Dirty_State *dirty_state_out){ - Models *models = (Models*)app->cmd_context; - Editing_File *file = imp_get_file(models, buffer_id); - b32 result = false; - if (api_check_buffer(file)){ - *dirty_state_out = file->state.dirty; - result = true; - } - return(result); -} - -API_EXPORT b32 -Buffer_Directly_Set_Dirty_State(Application_Links *app, Buffer_ID buffer_id, Dirty_State dirty_state){ +Buffer_Set_Dirty_State(Application_Links *app, Buffer_ID buffer_id, Dirty_State dirty_state){ Models *models = (Models*)app->cmd_context; Editing_File *file = imp_get_file(models, buffer_id); b32 result = false; @@ -775,7 +701,7 @@ DOC_RETURN(returns non-zero on success) default: { - result = 0; + result = false; }break; } } @@ -795,7 +721,6 @@ DOC_SEE(Buffer_Setting_ID) System_Functions *system = models->system; Editing_File *file = imp_get_file(models, buffer_id); b32 result = false; - if (api_check_buffer(file)){ result = true; switch (setting){ @@ -981,8 +906,8 @@ DOC_SEE(Buffer_Setting_ID) } // TODO(allen): redocument -API_EXPORT b32 -Buffer_Get_Managed_Scope(Application_Links *app, Buffer_ID buffer_id, Managed_Scope *scope_out) +API_EXPORT Managed_Scope +Buffer_Get_Managed_Scope(Application_Links *app, Buffer_ID buffer_id) /* DOC_PARAM(buffer_id, The id of the buffer from which to get a managed scope.) DOC_RETURN(If the buffer_id specifies a valid buffer, the scope returned is the scope tied to the @@ -992,97 +917,23 @@ If the buffer_id does not specify a valid buffer, the returned scope is null.) { Models *models = (Models*)app->cmd_context; Editing_File *file = imp_get_file(models, buffer_id); - b32 result = false; + Managed_Scope result = 0; if (api_check_buffer(file)){ - *scope_out = file_get_managed_scope(file); - result = true; - } - return(result); -} - -// TODO(allen): redocument -API_EXPORT b32 -Buffer_Token_Count(Application_Links *app, Buffer_ID buffer_id, i32 *count_out) -/* -DOC_PARAM(buffer, Specifies the buffer from which to read the token count.) -DOC_RETURN(If tokens are available for the buffer, the number of tokens on the buffer is returned. -If the buffer does not exist or if it is not a lexed buffer, the return is zero.) -*/{ - Models *models = (Models*)app->cmd_context; - Editing_File *file = imp_get_file(models, buffer_id); - b32 result = false; - if (api_check_buffer_and_tokens(file)){ - *count_out = file->state.token_array.count; - result = true; - } - return(result); -} - -// TODO(allen): redocument -API_EXPORT b32 -Buffer_Read_Tokens(Application_Links *app, Buffer_ID buffer_id, i32 start_token, i32 end_token, Cpp_Token *tokens_out) -/* -DOC_PARAM(buffer, Specifies the buffer from which to read tokens.) -DOC_PARAM(first_token, Specifies the index of the first token to read.) -DOC_PARAM(end_token, Specifies the token to stop reading at.) -DOC_PARAM(tokens_out, The memory that will store the tokens read from the buffer.) -DOC_RETURN(Returns non-zero on success. This call can fail if the buffer doesn't -exist or doesn't have tokens ready, or if either the first or last index is out of bounds.) -DOC(Puts the data for the tokens with the indices [first_token,last_token) into the tokens_out array. -The number of output tokens will be end_token - start_token.) -*/{ - Models *models = (Models*)app->cmd_context; - Editing_File *file = imp_get_file(models, buffer_id); - b32 result = false; - if (api_check_buffer_and_tokens(file)){ - Cpp_Token_Array token_array = file->state.token_array; - if (0 <= start_token && start_token <= end_token && end_token <= token_array.count){ - block_copy(tokens_out, token_array.tokens + start_token, sizeof(Cpp_Token)*(end_token - start_token)); - result = true; - } + result = file_get_managed_scope(file); } return(result); } // TODO(allen): redocument // TODO(allen): Include warning note about pointers and editing buffers. -API_EXPORT b32 -Buffer_Get_Token_Range(Application_Links *app, Buffer_ID buffer_id, Cpp_Token **first_token_out, Cpp_Token **one_past_last_token_out) +API_EXPORT Cpp_Token_Array +Buffer_Get_Token_Array(Application_Links *app, Buffer_ID buffer_id) { Models *models = (Models*)app->cmd_context; Editing_File *file = imp_get_file(models, buffer_id); - b32 result = false; + Cpp_Token_Array result = {}; if (api_check_buffer_and_tokens(file)){ - Cpp_Token_Array token_array = file->state.token_array; - if (first_token_out != 0){ - *first_token_out = token_array.tokens; - } - if (one_past_last_token_out != 0){ - *one_past_last_token_out = token_array.tokens + token_array.count; - } - result = true; - } - return(result); -} - -// TODO(allen): redocument -API_EXPORT b32 -Buffer_Get_Token_Index(Application_Links *app, Buffer_ID buffer_id, i32 pos, Cpp_Get_Token_Result *get_result) -/* -DOC_PARAM(buffer, The buffer from which to get a token.) -DOC_PARAM(pos, The position in the buffer in absolute coordinates.) -DOC_PARAM(get_result, The output struct specifying which token contains pos.) -DOC_RETURN(Returns non-zero on success. This call can fail if the buffer doesn't exist, or if the buffer doesn't have tokens ready.) -DOC(This call finds the token that contains a particular position, or if the position is in between tokens it finds the index of the token to the left of the position. The returned index can be -1 if the position is before the first token.) -DOC_SEE(Cpp_Get_Token_Result) -DOC_SEE(cpp_get_token) -*/{ - Models *models = (Models*)app->cmd_context; - Editing_File *file = imp_get_file(models, buffer_id); - b32 result = false; - if (api_check_buffer_and_tokens(file)){ - *get_result = cpp_get_token(file->state.token_array, pos); - result = true; + result = file->state.token_array; } return(result); } @@ -1107,8 +958,8 @@ This is useful in cases such as clearing a buffer and refilling it with new cont } // TODO(allen): redocument -API_EXPORT b32 -Create_Buffer(Application_Links *app, String_Const_u8 file_name, Buffer_Create_Flag flags, Buffer_ID *new_buffer_id_out) +API_EXPORT Buffer_ID +Create_Buffer(Application_Links *app, String_Const_u8 file_name, Buffer_Create_Flag flags) /* DOC_PARAM(filename, The name of the file to associate to the new buffer.) DOC_PARAM(filename_len, The length of the filename string.) @@ -1124,15 +975,16 @@ DOC_SEE(Buffer_Create_Flag) */{ Models *models = (Models*)app->cmd_context; Editing_File *new_file = create_file(models, file_name, flags); - if (new_file != 0 && new_buffer_id_out != 0){ - *new_buffer_id_out = new_file->id.id; + Buffer_ID result = 0; + if (new_file != 0){ + result = new_file->id.id; } - return(new_file != 0); + return(result); } // TODO(allen): redocument API_EXPORT b32 -Buffer_Save(Application_Links *app, Buffer_ID buffer_id, String_Const_u8 file_name, u32 flags) +Buffer_Save(Application_Links *app, Buffer_ID buffer_id, String_Const_u8 file_name, Buffer_Save_Flag flags) /* DOC_PARAM(buffer, The buffer parameter specifies the buffer to save to a file.) DOC_PARAM(file_name, The file_name parameter specifies the name of the file to write with the contents of the buffer; it need not be null terminated.) @@ -1169,8 +1021,8 @@ DOC_SEE(Buffer_Save_Flag) } // TODO(allen): redocument -API_EXPORT b32 -Buffer_Kill(Application_Links *app, Buffer_ID buffer_id, Buffer_Kill_Flag flags, Buffer_Kill_Result *result_out) +API_EXPORT Buffer_Kill_Result +Buffer_Kill(Application_Links *app, Buffer_ID buffer_id, Buffer_Kill_Flag flags) /* DOC_PARAM(buffer, The buffer parameter specifies the buffer to try to kill.) DOC_PARAM(flags, The flags parameter specifies behaviors for the buffer kill.) @@ -1237,14 +1089,11 @@ DOC_SEE(Buffer_Identifier) result = BufferKillResult_Unkillable; } } - if (result_out != 0){ - *result_out = result; - } - return(result == BufferKillResult_Killed); + return(result); } -API_EXPORT b32 -Buffer_Reopen(Application_Links *app, Buffer_ID buffer_id, Buffer_Reopen_Flag flags, Buffer_Reopen_Result *result_out) +API_EXPORT Buffer_Reopen_Result +Buffer_Reopen(Application_Links *app, Buffer_ID buffer_id, Buffer_Reopen_Flag flags) { Models *models = (Models*)app->cmd_context; System_Functions *system = models->system; @@ -1314,21 +1163,17 @@ Buffer_Reopen(Application_Links *app, Buffer_ID buffer_id, Buffer_Reopen_Flag fl } } } - if (result_out != 0){ - *result_out = result; - } - return(result == BufferReopenResult_Reopened); + return(result); } -API_EXPORT b32 -Buffer_Get_File_Attributes(Application_Links *app, Buffer_ID buffer_id, File_Attributes *attributes_out) +API_EXPORT File_Attributes +Buffer_Get_File_Attributes(Application_Links *app, Buffer_ID buffer_id) { Models *models = (Models*)app->cmd_context; Editing_File *file = imp_get_file(models, buffer_id); - b32 result = false; + File_Attributes result = {}; if (api_check_buffer(file)){ - block_copy(attributes_out, &file->attributes, sizeof(*attributes_out)); - result = true; + block_copy_struct(&result, &file->attributes); } return(result); } @@ -1372,8 +1217,8 @@ get_view_prev__inner(Layout *layout, View *view){ } // TODO(allen): redocument -API_EXPORT b32 -Get_View_Next(Application_Links *app, View_ID view_id, Access_Flag access, View_ID *view_id_out) +API_EXPORT View_ID +Get_View_Next(Application_Links *app, View_ID view_id, Access_Flag access) /* DOC_PARAM(view, The pointed to by view is iterated to the next view or to a null summary if this is the last view.) DOC_PARAM(access, The access parameter determines what levels of protection this call can access. The view outputted will be the next view that is accessible.) @@ -1394,19 +1239,15 @@ DOC_SEE(get_view_first) for (;view != 0 && !access_test(view_get_access_flags(view), access);){ view = get_view_next__inner(layout, view); } - b32 result = false; + View_ID result = 0; if (view != 0){ - *view_id_out = view_get_id(&models->live_set, view); - result = true; - } - else{ - *view_id_out = 0; + result = view_get_id(&models->live_set, view); } return(result); } -API_EXPORT b32 -Get_View_Prev(Application_Links *app, View_ID view_id, Access_Flag access, View_ID *view_id_out) +API_EXPORT View_ID +Get_View_Prev(Application_Links *app, View_ID view_id, Access_Flag access) { Models *models = (Models*)app->cmd_context; Layout *layout = &models->layout; @@ -1415,17 +1256,16 @@ Get_View_Prev(Application_Links *app, View_ID view_id, Access_Flag access, View_ for (;view != 0 && !access_test(view_get_access_flags(view), access);){ view = get_view_prev__inner(layout, view); } - b32 result = false; + View_ID result = 0; if (view != 0){ - *view_id_out = view_get_id(&models->live_set, view); - result = true; + result = view_get_id(&models->live_set, view); } return(result); } // TODO(allen): redocument -API_EXPORT b32 -Get_Active_View(Application_Links *app, Access_Flag access, View_ID *view_id_out) +API_EXPORT View_ID +Get_Active_View(Application_Links *app, Access_Flag access) /* DOC_PARAM(access, The access parameter determines what levels of protection this call can access.) DOC_RETURN(This call returns a summary that describes the active view.) @@ -1437,26 +1277,21 @@ DOC_SEE(Access_Flag) Assert(panel != 0); View *view = panel->view; Assert(view != 0); - b32 result = false; + View_ID result = 0; if (api_check_view(view, access)){ - *view_id_out = view_get_id(&models->live_set, view); - result = true; + result = view_get_id(&models->live_set, view); } return(result); } -API_EXPORT b32 -Get_Active_Panel(Application_Links *app, Panel_ID *panel_id_out){ +API_EXPORT Panel_ID +Get_Active_Panel(Application_Links *app){ Models *models = (Models*)app->cmd_context; Panel *panel = layout_get_active_panel(&models->layout); Assert(panel != 0); - b32 result = false; + Panel_ID result = 0; if (api_check_panel(panel)){ - *panel_id_out = panel_get_id(&models->layout, panel); - result = true; - } - else{ - *panel_id_out = 0; + result = panel_get_id(&models->layout, panel); } return(result); } @@ -1472,95 +1307,88 @@ View_Exists(Application_Links *app, View_ID view_id){ return(result); } -API_EXPORT b32 -View_Get_Buffer(Application_Links *app, View_ID view_id, Access_Flag access, Buffer_ID *buffer_id_out){ +API_EXPORT Buffer_ID +View_Get_Buffer(Application_Links *app, View_ID view_id, Access_Flag access){ Models *models = (Models*)app->cmd_context; View *view = imp_get_view(models, view_id); - b32 result = false; + Buffer_ID result = 0; if (api_check_view(view)){ Editing_File *file = view->file; if (api_check_buffer(file, access)){ - *buffer_id_out = file->id.id; - result = true; + result = file->id.id; } } return(result); } -API_EXPORT b32 -View_Get_Cursor_Pos(Application_Links *app, View_ID view_id, i32 *pos_out){ +API_EXPORT i32 +View_Get_Cursor_Pos(Application_Links *app, View_ID view_id){ Models *models = (Models*)app->cmd_context; View *view = imp_get_view(models, view_id); - b32 result = false; + i32 result = 0; if (api_check_view(view)){ File_Edit_Positions edit_pos = view_get_edit_pos(view); - *pos_out = edit_pos.cursor_pos; - result = true; + result = edit_pos.cursor_pos; } return(result); } -API_EXPORT b32 -View_Get_Mark_Pos(Application_Links *app, View_ID view_id, i32 *pos_out){ +API_EXPORT i32 +View_Get_Mark_Pos(Application_Links *app, View_ID view_id){ Models *models = (Models*)app->cmd_context; View *view = imp_get_view(models, view_id); - b32 result = false; + i32 result = 0;; if (api_check_view(view)){ - *pos_out = view->mark; - result = true; + result = view->mark; } return(result); } -API_EXPORT b32 -View_Get_Preferred_X(Application_Links *app, View_ID view_id, f32 *preferred_x_out){ +API_EXPORT f32 +View_Get_Preferred_X(Application_Links *app, View_ID view_id){ Models *models = (Models*)app->cmd_context; View *view = imp_get_view(models, view_id); - b32 result = false; + f32 result = 0.f;; if (api_check_view(view)){ - *preferred_x_out = view->preferred_x; - result = true; + result = view->preferred_x; } return(result); } -API_EXPORT b32 -View_Get_Screen_Rect(Application_Links *app, View_ID view_id, Rect_f32 *rect_out){ +API_EXPORT Rect_f32 +View_Get_Screen_Rect(Application_Links *app, View_ID view_id){ Models *models = (Models*)app->cmd_context; - b32 result = false; + Rect_f32 result = {}; View *view = imp_get_view(models, view_id); if (api_check_view(view)){ - *rect_out = f32R(view->panel->rect_full); - result = true; + result = f32R(view->panel->rect_full); } return(result); } -API_EXPORT b32 -View_Get_Panel(Application_Links *app, View_ID view_id, Panel_ID *panel_id_out){ +API_EXPORT Panel_ID +View_Get_Panel(Application_Links *app, View_ID view_id){ Models *models = (Models*)app->cmd_context; Layout *layout = &models->layout; - b32 result = false; View *view = imp_get_view(models, view_id); + Panel_ID result = 0; if (api_check_view(view)){ Panel *panel = view->panel; - *panel_id_out = panel_get_id(layout, panel); - result = true; + result = panel_get_id(layout, panel); } return(result); } -API_EXPORT b32 -Panel_Get_View(Application_Links *app, Panel_ID panel_id, View_ID *view_id_out){ +API_EXPORT View_ID +Panel_Get_View(Application_Links *app, Panel_ID panel_id){ Models *models = (Models*)app->cmd_context; - b32 result = false; Panel *panel = imp_get_panel(models, panel_id); + View_ID result = 0; if (api_check_panel(panel)){ if (panel->kind == PanelKind_Final){ View *view = panel->view; Assert(view != 0); - *view_id_out = view_get_id(&models->live_set, view); - result = true; + result = view_get_id(&models->live_set, view); } } return(result); @@ -1659,27 +1487,24 @@ Panel_Swap_Children(Application_Links *app, Panel_ID panel_id, Panel_Split_Kind return(result); } -API_EXPORT b32 -Panel_Get_Parent(Application_Links *app, Panel_ID panel_id, Panel_ID *panel_id_out){ +API_EXPORT Panel_ID +Panel_Get_Parent(Application_Links *app, Panel_ID panel_id){ Models *models = (Models*)app->cmd_context; Layout *layout = &models->layout; - b32 result = false; Panel *panel = imp_get_panel(models, panel_id); - *panel_id_out = 0; + Panel_ID result = false; if (api_check_panel(panel)){ - *panel_id_out = panel_get_id(layout, panel->parent); - result = true; + result = panel_get_id(layout, panel->parent); } return(result); } -API_EXPORT b32 -Panel_Get_Child(Application_Links *app, Panel_ID panel_id, Panel_Child which_child, Panel_ID *panel_id_out){ +API_EXPORT Panel_ID +Panel_Get_Child(Application_Links *app, Panel_ID panel_id, Panel_Child which_child){ Models *models = (Models*)app->cmd_context; Layout *layout = &models->layout; - b32 result = false; Panel *panel = imp_get_panel(models, panel_id); - *panel_id_out = 0; + Panel_ID result = 0; if (api_check_panel(panel)){ if (panel->kind == PanelKind_Intermediate){ Panel *child = 0; @@ -1694,44 +1519,41 @@ Panel_Get_Child(Application_Links *app, Panel_ID panel_id, Panel_Child which_chi }break; } if (child != 0){ - *panel_id_out = panel_get_id(layout, child); - result = true; + result = panel_get_id(layout, child); } } } return(result); } -API_EXPORT b32 -Panel_Get_Max(Application_Links *app, Panel_ID panel_id, Panel_ID *panel_id_out){ +API_EXPORT Panel_ID +Panel_Get_Max(Application_Links *app, Panel_ID panel_id){ Models *models = (Models*)app->cmd_context; Layout *layout = &models->layout; - b32 result = false; Panel *panel = imp_get_panel(models, panel_id); + Panel_ID result = 0; if (api_check_panel(panel)){ if (panel->kind == PanelKind_Intermediate){ Panel *child = panel->br_panel; - *panel_id_out = panel_get_id(layout, child); - result = true; + result = panel_get_id(layout, child); } } return(result); } -API_EXPORT b32 -Panel_Get_Margin(Application_Links *app, Panel_ID panel_id, i32_Rect *margins_out){ +API_EXPORT Rect_i32 +Panel_Get_Margin(Application_Links *app, Panel_ID panel_id){ Models *models = (Models*)app->cmd_context; Layout *layout = &models->layout; - b32 result = false; Panel *panel = imp_get_panel(models, panel_id); + Rect_i32 result = {}; if (api_check_panel(panel)){ if (panel->kind == PanelKind_Final){ i32 margin = layout->margin; - margins_out->x0 = margin; - margins_out->x1 = margin; - margins_out->y0 = margin; - margins_out->y1 = margin; - result = true; + result.x0 = margin; + result.x1 = margin; + result.y0 = margin; + result.y1 = margin; } } return(result); @@ -1763,26 +1585,13 @@ in the system, the call will fail.) return(result); } -API_EXPORT b32 -View_Get_Region(Application_Links *app, View_ID view_id, Rect_i32 *region_out){ +API_EXPORT Rect_f32 +View_Get_Buffer_Region(Application_Links *app, View_ID view_id){ Models *models = (Models*)app->cmd_context; View *view = imp_get_view(models, view_id); - b32 result = false; + Rect_f32 result = {}; if (api_check_view(view)){ - *region_out = view->panel->rect_full; - result = true; - } - return(result); -} - -API_EXPORT b32 -View_Get_Buffer_Region(Application_Links *app, View_ID view_id, Rect_i32 *region_out){ - Models *models = (Models*)app->cmd_context; - View *view = imp_get_view(models, view_id); - b32 result = false; - if (api_check_view(view)){ - *region_out = view_get_buffer_rect(models, view); - result = true; + result = view_get_buffer_rect(models, view); } return(result); } @@ -4132,6 +3941,7 @@ Compute_Render_Layout(Application_Links *app, View_ID view_id, Buffer_ID buffer_ f32 smallest_char_width = 6.f; f32 smallest_char_height = 8.f; i32 max = (i32)(layout_dim.x*layout_dim.y/(smallest_char_width*smallest_char_height))*2; + max = clamp_bot(0, max); if (view->layout_arena.base_allocator == 0){ view->layout_arena = make_arena_app_links(app); } @@ -4235,9 +4045,12 @@ Compute_Render_Layout(Application_Links *app, View_ID view_id, Buffer_ID buffer_ view->render.item_count = item_count; if (text_layout_id_out != 0){ - Buffer_Render_Item *render_item_first = items; - Buffer_Render_Item *render_item_last = items + item_count - 1; - f32 height = render_item_last->y1 - render_item_first->y0; + f32 height = 0.f; + if (item_count > 0){ + Buffer_Render_Item *render_item_first = items; + Buffer_Render_Item *render_item_last = items + item_count - 1; + height = render_item_last->y1 - render_item_first->y0; + } *text_layout_id_out = text_layout_new(&models->mem.heap, &models->text_layouts, buffer_id, buffer_point, range, height); } } diff --git a/4ed_cli.cpp b/4ed_cli.cpp index bf7bbaa5..316cffc6 100644 --- a/4ed_cli.cpp +++ b/4ed_cli.cpp @@ -133,5 +133,19 @@ child_process_set_target_buffer(Models *models, Child_Process *child_process, Ed return(result); } +internal Process_State +child_process_get_state(Child_Process_Container *child_processes, Child_Process_ID child_process_id){ + Child_Process *child_process = child_process_from_id(child_processes, child_process_id); + Process_State result = {}; + if (child_processes != 0){ + result.valid = true; + result.is_updating = true; + } + else if (child_process_lookup_return_code(child_processes, child_process_id, &result.return_code)){ + result.valid = true; + } + return(result); +} + // BOTTOM diff --git a/4ed_file.cpp b/4ed_file.cpp index 4f79f9a0..a44a8dc8 100644 --- a/4ed_file.cpp +++ b/4ed_file.cpp @@ -219,26 +219,19 @@ save_file(System_Functions *system, Models *models, Editing_File *file){ //////////////////////////////// -internal b32 -file_compute_partial_cursor(Editing_File *file, Buffer_Seek seek, Partial_Cursor *cursor){ - b32 result = true; +internal Partial_Cursor +file_compute_partial_cursor(Editing_File *file, Buffer_Seek seek){ + Partial_Cursor result = {}; switch (seek.type){ case buffer_seek_pos: { - *cursor = buffer_partial_from_pos(&file->state.buffer, seek.pos); + result = buffer_partial_from_pos(&file->state.buffer, seek.pos); }break; - case buffer_seek_line_char: { - *cursor = buffer_partial_from_line_character(&file->state.buffer, seek.line, seek.character); + result = buffer_partial_from_line_character(&file->state.buffer, seek.line, seek.character); }break; - // TODO(allen): do(support buffer_seek_character_pos and character_pos coordiantes in partial cursor system) - - default: - { - result = false; - }break; } return(result); } diff --git a/4ed_view.cpp b/4ed_view.cpp index 8be6ed91..958ccbb2 100644 --- a/4ed_view.cpp +++ b/4ed_view.cpp @@ -86,12 +86,12 @@ view_set_edit_pos(View *view, File_Edit_Positions edit_pos){ //////////////////////////////// -internal Rect_i32 +internal Rect_f32 view_get_buffer_rect(Models *models, View *view){ - Rect_i32 region = {}; + Rect_f32 region = {}; if (models->get_view_buffer_region != 0){ - Rect_i32 rect = view->panel->rect_inner; - Rect_i32 sub_region = i32R(0, 0, rect_width(rect), rect_height(rect)); + Rect_f32 rect = Rf32(view->panel->rect_inner); + Rect_f32 sub_region = Rf32(V2(0, 0), rect_dim(rect)); sub_region = models->get_view_buffer_region(&models->app_links, view_get_id(&models->live_set, view), sub_region); region.p0 = rect.p0 + sub_region.p0; region.p1 = rect.p0 + sub_region.p1; @@ -101,17 +101,17 @@ view_get_buffer_rect(Models *models, View *view){ region.y0 = clamp_top(region.y0, region.y1); } else{ - region = view->panel->rect_inner; + region = Rf32(view->panel->rect_inner); } return(region); } -internal i32 +internal f32 view_width(Models *models, View *view){ return(rect_width(view_get_buffer_rect(models, view))); } -internal i32 +internal f32 view_height(Models *models, View *view){ return(rect_height(view_get_buffer_rect(models, view))); } @@ -133,7 +133,7 @@ view_get_cursor_xy(System_Functions *system, View *view){ internal Cursor_Limits view_cursor_limits(Models *models, View *view){ i32 line_height = view->line_height; - i32 visible_height = view_height(models, view); + i32 visible_height = (i32)view_height(models, view); Cursor_Limits limits = {}; limits.max = visible_height - line_height*3; limits.min = line_height*2; @@ -177,7 +177,7 @@ view_compute_max_target_y(Models *models, View *view){ internal b32 view_move_view_to_cursor(System_Functions *system, Models *models, View *view, GUI_Scroll_Vars *scroll){ b32 result = false; - i32 max_x = view_width(models, view); + i32 max_x = (i32)view_width(models, view); i32 max_y = view_compute_max_target_y(models, view); Vec2_i32 cursor = view_get_cursor_xy(system, view); diff --git a/things_ive_broken.txt b/things_ive_broken.txt index ee1bc7f8..db4ccebd 100644 --- a/things_ive_broken.txt +++ b/things_ive_broken.txt @@ -29,4 +29,7 @@ view_buffer_boundary_range view_buffer_snipe_range Hard_Start_Result -> Line_Indent_Info -buffer_find_hard_start -> get_line_indent_info \ No newline at end of file +buffer_find_hard_start -> get_line_indent_info + + +get_active_view -> get_active_view_DEP