diff --git a/4coder_default_bindings.cpp b/4coder_default_bindings.cpp index 5fa3e8ab..bc060812 100644 --- a/4coder_default_bindings.cpp +++ b/4coder_default_bindings.cpp @@ -170,8 +170,6 @@ CUSTOM_COMMAND_SIG(write_name_of_font){ if (font_len != 0){ write_string(app, &view, &buffer, make_string(font_name, font_len)); } - - print_message(app, literal("TRIED WRITING FONT NAME")); } CUSTOM_COMMAND_SIG(newline_or_goto_position){ diff --git a/4ed_api_implementation.cpp b/4ed_api_implementation.cpp index 4458f5f0..28d452bb 100644 --- a/4ed_api_implementation.cpp +++ b/4ed_api_implementation.cpp @@ -2087,7 +2087,6 @@ API_EXPORT int32_t Buffer_Get_Font(Application_Links *app, Buffer_Summary *buffer, char *name_out, int32_t name_max) { Command_Data *cmd = (Command_Data*)app->cmd_context; - System_Functions *system = cmd->system; Models *models = cmd->models; Editing_File *file = imp_get_file(cmd, buffer); diff --git a/4ed_file_view.cpp b/4ed_file_view.cpp index 408b80c5..551b9290 100644 --- a/4ed_file_view.cpp +++ b/4ed_file_view.cpp @@ -282,10 +282,10 @@ view_file_display_width(View *view){ } inline f32 -view_file_minimum_base_width(View *view){ +view_file_minimum_base__width(View *view){ Editing_File *file = view->file_data.file; - f32 result = (f32)file->settings.display_width; - return(result); + f32 result = (f32)file->settings.display_width; + return(result); } inline f32 @@ -981,7 +981,7 @@ struct Code_Wrap_X{ i32 paren_safe_top; i32 paren_top; }; -globalvar Code_Wrap_X null_wrap_x = {0}; +globalvar Code_Wrap_X null_wrap_x = {0}; struct Code_Wrap_State{ Cpp_Token_Array token_array; @@ -1066,21 +1066,22 @@ wrap_state_consume_token(Code_Wrap_State *state, i32 fixed_end_point){ if (state->in_pp_body){ if (!(state->token_ptr->flags & CPP_TFLAG_PP_BODY)){ - state->in_pp_body = 0; - state->wrap_x = state->plane_wrap_x; - } + state->in_pp_body = 0; + state->wrap_x = state->plane_wrap_x; } - - if (!state->in_pp_body){ - if (state->token_ptr->flags & CPP_TFLAG_PP_DIRECTIVE){ - state->in_pp_body = 1; - state->plane_wrap_x = state->wrap_x; - state->wrap_x = null_wrap_x; - } + } + + if (!state->in_pp_body){ + if (state->token_ptr->flags & CPP_TFLAG_PP_DIRECTIVE){ + state->in_pp_body = 1; + state->plane_wrap_x = state->wrap_x; + state->wrap_x = null_wrap_x; } + } b32 skipping_whitespace = 0; if (i >= state->next_line_start){ + state->x = state->wrap_x.paren_nesting[state->wrap_x.paren_safe_top]; state->x = state->wrap_x.paren_nesting[state->wrap_x.paren_safe_top]; skipping_whitespace = 1; } @@ -1552,8 +1553,8 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file, f32 base_adjusted_width = wrap_state.wrap_x.base_x + minimum_base_width; if (minimum_base_width != 0 && current_width < base_adjusted_width){ - current_width = base_adjusted_width; - } + current_width = base_adjusted_width; + } if (stop.status == BLStatus_NeedLineShift){ real_count = 0; @@ -1667,7 +1668,7 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file, } b32 need_to_choose_a_wrap = 0; - if (step.final_x > current_width){ + if (step.final_x > current_width){ need_to_choose_a_wrap = 1; } @@ -1819,6 +1820,7 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file, if (line_shift < 0){ line_shift = 0; } + } else{ line_shift = 0.f; @@ -4329,8 +4331,7 @@ struct Single_Line_Mode{ }; internal Single_Line_Input_Step -app_single_line_input_core(System_Functions *system, Working_Set *working_set, - Key_Event_Data key, Single_Line_Mode mode){ +app_single_line_input_core(System_Functions *system, Working_Set *working_set, Key_Event_Data key, Single_Line_Mode mode){ Single_Line_Input_Step result = {0}; if (key.keycode == key_back){ @@ -4741,6 +4742,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su Assert(view->file_data.file); Font_Set *font_set = models->font_set; + Font_Info *info = 0; i16 i = 1, count = (i16)models->font_set->count + 1; @@ -4759,7 +4761,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su i16 new_font_id = font_id; for (i = 1; i < count; ++i){ - Font_Info *info = get_font_info(font_set, i); + info = get_font_info(font_set, i); id.id[0] = (u64)i; if (i != font_id){ if (gui_do_font_button(target, id, i, info->name)){ diff --git a/4ed_gui.cpp b/4ed_gui.cpp index dc1fab2a..4410e963 100644 --- a/4ed_gui.cpp +++ b/4ed_gui.cpp @@ -1256,8 +1256,9 @@ gui_do_jump(GUI_Target *target, GUI_View_Jump jump, GUI_Scroll_Vars vars){ } internal void -gui_standard_list(GUI_Target *target, GUI_id id, GUI_Scroll_Vars *vars, i32_Rect scroll_region, - Key_Summary *keys, i32 *list_i, GUI_Item_Update *update){ +gui_standard_list(GUI_Target *target, GUI_id id, GUI_Scroll_Vars *vars, i32_Rect scroll_region, + Key_Summary *keys, i32 *list_i, GUI_Item_Update *update, + i16 key_user_up = 0, i16 key_user_down = 0){ if (update->has_adjustment){ *list_i = update->adjustment_value; @@ -1274,18 +1275,15 @@ gui_standard_list(GUI_Target *target, GUI_id id, GUI_Scroll_Vars *vars, i32_Rect b32 indirectly_activate = 0; for (i32 j = 0; j < keys->count; ++j){ i16 key = keys->keys[j].keycode; - switch (key){ - case key_up: + + if (key == key_up || key == key_user_up){ --*list_i; - break; - - case key_down: + } + else if (key == key_down || key == key_user_down){ ++*list_i; - break; - - case '\n': case '\t': + } + else if (key == '\n' || key == '\t'){ indirectly_activate = 1; - break; } } diff --git a/TODO.txt b/TODO.txt index 77f233fd..2891744b 100644 --- a/TODO.txt +++ b/TODO.txt @@ -89,12 +89,12 @@ ; BEFORE I SHIP ; ; [X] query buffer font info +; [X] issues with drive letters ; [] ad hoc call for setting up/down keys for interactive screens -; [] miblo's various number editors -; [] API docs have duplicate ids? ; [] option to not open *messages* every startup -; [] issues with drive letters -; [] strong options for indentation rules for text & presentation +; [] API docs have duplicate ids? +; [] miblo's various number editors +; [] decent options for indentation rules for text & presentation ; ; TODOS @@ -165,9 +165,7 @@ ; [X] word level wrapping ; [X] ability to toggle virtual white space ; [X] home/end should go to the beginning/end of the visual line not the textual line -; [] command for setting wrap positions in views directly -; [] ability to see the wrap position as a number/line and adjust graphically -; [] code level wrapping +; [X] code level wrapping level 1 ; [X] handle basic scope indents ; [X] handle parentheses ; [X] handle preprocessor @@ -176,12 +174,15 @@ ; [X] smarter wrap rule ; [X] handle unclosed statements ; [X] wrapped line indication -; [X] additional width for nesting? ; [X] special indent rules in preprocessor body ; [X] handle comments -; [] solve the comment lead whitespace problem -; [] fix issues when relexing happens in parallel -; [] remeasure version of measure_wraps +; [X] additional width for nesting? +; [X] fix issues when relexing happens in parallel +; [] command for setting wrap positions in views directly +; [] ability to see the wrap position as a number/line and adjust graphically +; [] code level wrapping level 2 +; [] comment lead whitespace problem +; [] remeasure version of measure_wraps ; Buffer behavior cleanup ; [X] show all characters as \# if they can't be rendered diff --git a/win32_4ed.cpp b/win32_4ed.cpp index f6a9e19e..824d2cb6 100644 --- a/win32_4ed.cpp +++ b/win32_4ed.cpp @@ -162,11 +162,6 @@ enum CV_ID{ CV_COUNT }; -typedef struct Drive_Strings{ - char *prefix_[26]; - char **prefix; -} Drive_Strings; - typedef struct Win32_Vars{ System_Functions system; App_Functions app; @@ -214,8 +209,6 @@ typedef struct Win32_Vars{ b32 first; i32 running_cli; - Drive_Strings dstrings; - #if FRED_INTERNAL CRITICAL_SECTION DEBUG_sysmem_lock; Sys_Bubble internal_bubble; @@ -855,62 +848,17 @@ Sys_Set_File_List_Sig(system_set_file_list){ } } -internal void -set_volume_prefix(Drive_Strings *dstrings, char *vol){ - char c = vol[0]; - if (dstrings->prefix[c]){ - system_free_memory(dstrings->prefix[c]); - } - - HANDLE hdir = CreateFile( - vol, - GENERIC_READ, - FILE_SHARE_DELETE|FILE_SHARE_WRITE|FILE_SHARE_READ, - 0, - OPEN_EXISTING, - FILE_FLAG_BACKUP_SEMANTICS, - 0); - - if (hdir != INVALID_HANDLE_VALUE){ - char *s = 0; - DWORD len = GetFinalPathNameByHandle(hdir, 0, 0, 0); - len = len + 1; - s = (char*)system_get_memory(len); - len = GetFinalPathNameByHandle(hdir, s, len, 0); - s[len] = 0; - if (s[len-1] == '\\') s[len-1] = 0; - dstrings->prefix[c] = s + 4; - CloseHandle(hdir); - } - else{ - dstrings->prefix[c] = 0; - } -} - -internal void -win32_init_drive_strings(Drive_Strings *dstrings){ - dstrings->prefix = dstrings->prefix_ - 'A'; - - char vol[4] = "A:\\"; - for (char c = 'A'; c <= 'Z'; ++c){ - vol[0] = c; - set_volume_prefix(dstrings, vol); - } -} - // NOTE(allen): This does not chase down symbolic links because doing so // would require a lot of heavy duty OS calls. I've decided to give up // a little ground on always recognizing files as equivalent in exchange // for the ability to handle them very quickly when nothing strange is // going on. internal int32_t -win32_canonical_ascii_name(Drive_Strings *dstrings, char *src, i32 len, char *dst, i32 max){ +win32_canonical_ascii_name(char *src, i32 len, char *dst, i32 max){ char *wrt = dst; char *wrt_stop = dst + max; char *src_stop = src + len; char c = 0; - char **prefix_array = dstrings->prefix; - char *prefix = 0; if (len >= 2 && max > 0){ c = src[0]; @@ -919,19 +867,11 @@ win32_canonical_ascii_name(Drive_Strings *dstrings, char *src, i32 len, char *ds } if (c >= 'A' && c <= 'Z' && src[1] == ':'){ - prefix = prefix_array[c]; - if (prefix){ - for (;*prefix;){ - *(wrt++) = *(prefix++); - if (wrt == wrt_stop) goto fail; - } - } - else{ - *(wrt++) = c; - if (wrt == wrt_stop) goto fail; - *(wrt++) = ':'; - if (wrt == wrt_stop) goto fail; - } + *(wrt++) = c; + if (wrt == wrt_stop) goto fail; + *(wrt++) = ':'; + if (wrt == wrt_stop) goto fail; + src += 2; for (; src < src_stop; ++src){ @@ -978,7 +918,7 @@ win32_canonical_ascii_name(Drive_Strings *dstrings, char *src, i32 len, char *ds internal Sys_Get_Canonical_Sig(system_get_canonical){ - i32 result = win32_canonical_ascii_name(&win32vars.dstrings, filename, len, buffer, max); + i32 result = win32_canonical_ascii_name(filename, len, buffer, max); return(result); } @@ -1974,11 +1914,6 @@ WinMain(HINSTANCE hInstance, win32vars.coroutine_data[i].next = win32vars.coroutine_data + i + 1; } - // - // Volume Initialization - // - win32_init_drive_strings(&win32vars.dstrings); - // // Memory Initialization //