4coder/code/custom
Simon Anciaux 0e2b8d0df8 A user reported on the handmade network discord an issue where when you change the font size (e.g. ctrl + scroll up/down) 4coder was crashing. They were using the D3D11 renderer.
The crash is caused by dereferencing a invalid pointer to a texture. The D3D11 renderer as a arbitrary limit of 32 textures (there is normally no reason to have more than 2 or 3 textures in 4coder) because it needs to keep track of a few pointer in its state, while OpenGL doesn't (it just uses the id returned by `glGenTexture`). The code that recreate the texture atlas when changing the font size, never frees the previous texture, so both DirectX and OpenGL are leaking texture.

So this fix just frees the previous texture after 4coder successfully creates a new one. If for some reason the new texture can't be created, we continue using the last one. This is better than crashing as we can still use 4coder, but since we can't change font size anymore the editor might be stuck with a uncomfortable font size.

Unfortunately 4coder doesn't expose a way to delete texture outside the platform layer, and the font size code is not in the platform layer. So I had to expose a `free texture` function, which lead me to understand how 4coder generates API in the `generated` folder.

I updated the README to keep that information somewhere since it's not clear from the get go. The basic idea is that there are a few files that you can compile as a small standalone program and run to generate the files. For the graphics api, you need to compile `4ed_graphics_api.cpp`.

I took some time to also modify a little the generator so that the generated file contains the name of the file that generated them, and added a bit of indentation to make the file a bit more readable (even if we're not supposed to modify them).
2025-07-07 13:11:48 -07:00
..
bin Squashing macro-redefined error in clang 2025-07-06 12:37:41 -07:00
generated A user reported on the handmade network discord an issue where when you change the font size (e.g. ctrl + scroll up/down) 4coder was crashing. They were using the D3D11 renderer. 2025-07-07 13:11:48 -07:00
languages Implement new build system 2025-07-06 12:44:54 -07:00
lexer_generator Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_app_links_allocator.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_async_tasks.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_async_tasks.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_auto_indent.cpp Indent next line only on hitting enter 2024-02-10 20:12:36 -08:00
4coder_auto_indent.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_base_commands.cpp Implemented custom modal bindings 2024-02-10 15:38:37 -08:00
4coder_base_types.cpp string_find_first_of_set impl 2024-03-27 13:49:29 -07:00
4coder_base_types.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_buffer_seek_constructors.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_build_commands.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_build_commands.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_cli_command.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_clipboard.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_clipboard.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_code_index.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_code_index.h Increase Code_Index name_hash size 2025-07-07 12:32:45 -07:00
4coder_code_index_listers.cpp Implemented custom modal bindings 2024-02-10 15:38:37 -08:00
4coder_codepoint_map.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_combined_write_commands.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_combined_write_commands.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_command_map.cpp Reverting prior change to map_loose_match 2024-03-26 16:00:50 -07:00
4coder_command_map.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_config.cpp Project generation uses treat_as_code extensions to create project include patterns 2024-02-10 18:45:05 -08:00
4coder_config.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_config_grammar.txt Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_custom.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_default_bindings.cpp Bindings for replace identifier and replace selection 2025-04-30 12:38:07 -07:00
4coder_default_colors.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_default_colors.h Implemented custom modal bindings 2024-02-10 15:38:37 -08:00
4coder_default_framework.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_default_framework.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_default_framework_variables.cpp Implemented custom modal bindings 2024-02-10 15:38:37 -08:00
4coder_default_hooks.cpp Restructure default_render_buffer to only color visible tokens, and only look up tokens that are identifiers 2025-07-07 12:33:29 -07:00
4coder_default_include.cpp Added yeet sheet implementation 2024-05-13 19:29:16 -07:00
4coder_default_map.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_delta_rule.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_delta_rule.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_doc_commands.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_doc_content_types.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_doc_content_types.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_docs.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_draw.cpp Modal cursor recoloring 2024-02-10 15:43:16 -08:00
4coder_draw.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_dynamic_bindings.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_eol.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_events.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_events.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_examples.cpp Removed custom/audio 2024-02-10 14:25:13 -08:00
4coder_fancy.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_file.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_file.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_file_moving.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_font_helper.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_function_list.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_function_list.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_hash_functions.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_helper.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_helper.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_insertion.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_insertion.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_jump_lister.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_jump_lister.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_jump_sticky.cpp gs_parse_jump_location handles jai paths better 2024-03-27 13:49:52 -07:00
4coder_jump_sticky.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_jumping.cpp gs_parse_jump_location handles jai paths better 2024-03-27 13:49:52 -07:00
4coder_jumping.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_keyboard_macro.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_layout.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_layout_rule.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_layout_rule.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_lister_base.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_lister_base.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_lists.cpp Backspace in file search deletes whole word 2024-02-10 15:55:05 -08:00
4coder_log.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_log_parser.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_log_parser.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_mac_map.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_malloc_allocator.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_metadata_generator.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_miblo_numbers.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_modal.cpp Implemented custom modal bindings 2024-02-10 15:38:37 -08:00
4coder_modal.h Modal cursor recoloring 2024-02-10 15:43:16 -08:00
4coder_prj_v1.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_prj_v1.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_profile.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_profile.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_profile_inspect.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_profile_inspect.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_profile_static_disable.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_profile_static_enable.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_project_commands.cpp Project generation uses treat_as_code extensions to create project include patterns 2024-02-10 18:45:05 -08:00
4coder_project_commands.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_scope_commands.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_scope_commands.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_search.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_search.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_search_list.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_search_list.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_string_match.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_string_match.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_stringf.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_system_allocator.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_system_helpers.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_system_types.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_table.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_table.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_token.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_token.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_tutorial.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_tutorial.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_types.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_variables.cpp Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_variables.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_version.h Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00
4coder_yeet.cpp Added yeet sheet implementation 2024-05-13 19:29:16 -07:00
custom_4coder.so Bindings for replace identifier and replace selection 2025-04-30 12:38:07 -07:00
project.4coder Add 'code/' from commit '1459ef7cbce753b056ea148b29c9dc3f8a721261' 2022-11-18 13:37:07 +00:00