Commit Graph

2370 Commits

Author SHA1 Message Date
Peter Slattery 9ecf49d278 Add typescript support and document how to add a language 2025-07-13 14:37:25 -07:00
Peter Slattery a5f13529c3 Set a per-language flag for enabling virtual indentation 2025-07-13 14:02:32 -07:00
Peter Slattery 5ed8767819 Buffering code index updates when there are many modified buffers within a single frame 2025-07-13 13:46:55 -07:00
Peter Slattery 18428ec90d Pull tree_sitter_code_index_update_single_buffer out as it's own routine, and use it in tree_sitter_parse_asyn__inner to avoid setting the buffer_modified flag 2025-07-13 13:27:21 -07:00
Peter Slattery 5ccd6dd2ab Implemented tree_sitter_code_index_update_tick - populates Code_Index_Nests and Code_Index_Notes from each languages Tags query
Switched tree_sitter_list_all_query_results to list Code_Index_Note's matching a Code_Index_Note_Kind in each file
- remove old query types NESTS, FUNCTIONS, TYPES
2025-07-13 11:19:29 -07:00
Peter Slattery 58374ba625 Incorporating the nest query into the cpp tags query 2025-07-13 11:17:56 -07:00
Peter Slattery 67e0420eb1 Indenting 4coder_code_index.cpp 2025-07-13 11:15:48 -07:00
Peter Slattery 336a98f701 Switched to using the default highlight and tags queries for cpp, jai, bash. 2025-07-13 08:44:45 -07:00
Peter Slattery c5a462993d Pull language registration into individual per-language files 2025-07-12 12:21:31 -07:00
Peter Slattery 60e850b2ff Add bash support 2025-07-12 12:19:23 -07:00
Peter Slattery 877527e918 Cleaning up noisy build logs 2025-07-11 17:58:58 -07:00
Peter Slattery 324a78ae1e Implemented function and type queries.
Implemented tree_sitter_list_all_* commands
2025-07-11 17:18:11 -07:00
Peter Slattery 086ac34c4d Jai syntax highlighting 2025-07-10 12:10:17 -07:00
Peter Slattery 79695eca2c tree sitter logic handles edits to a parsed buffer
- async_task_cancel_nowait implementation
2025-07-10 09:14:35 -07:00
Peter Slattery 43fb4a757a Implement Tree_Sitter_Language_Definition, handle registering languages by extension, and looking up the appropriate language definition for a buffer.
custom_begin_buffer uses new functions to identify which files to treat as code
implement custom_render_buffer which uses tree sitter data to color tokens
2025-07-10 08:53:54 -07:00
Peter Slattery 7caaed736b Initial tree sitter usage:
- identify buffer language
- custom_begin_buffer sets up necessary tree sitter state, and kicks off a parse task
- custom_end_buffer cleans up tree sitter data and kills async parse tasks
- tree_sitter_parse_async/__inner uses tree sitter api to get a tree of the buffer's code and stores it on the buffers managed scope
- tree_sitter_write_tree prints tree to a special *tree* buffer
- use new build scripts in 4coder project
2025-07-10 07:08:27 -07:00
Peter Slattery 1a97b41257 Add tree sitter to compile command 2025-07-10 06:01:48 -07:00
Peter Slattery 8a918eef82 Checking for color support in build scripts 2025-07-10 06:01:34 -07:00
Peter Slattery d615358064 Updated build scripts to use common include flags 2025-07-08 10:05:45 -07:00
Peter Slattery 0b712c50e9 Added tree-sitter to project and got it building as a static library 2025-07-07 20:26:10 -07:00
Peter Slattery d8d99eefdd Removing tracking for generated files 2025-07-07 19:40:08 -07:00
Peter Slattery 73492010b3 render_buffer no longer overwrites the cpp token coloring for keywords 2025-07-07 19:39:30 -07:00
Peter Slattery 3dafcdd950 QOL underline all visible instances of the token the cursor is within 2025-07-07 15:16:07 -07:00
Peter Slattery 50c53649a2 QOL jump stack 2025-07-07 14:47:14 -07:00
Peter Slattery 322f690afc QOL column alignment 2025-07-07 14:31:41 -07:00
Peter Slattery ea389639b3 Search lister jumps 2025-07-07 14:08:40 -07:00
Peter Slattery 01a06a59c7 Cull lister render 2025-07-07 14:07:26 -07:00
Peter Slattery 051b5068e5 Fix redo off by one error 2025-07-07 14:06:38 -07:00
Peter Slattery 1c9fd3e16f goto_next_jump accounts for .cursor_at_end 2025-07-07 14:03:24 -07:00
flyingsolomon 0ee8e3904a Update code/platform_win32/4ed_dx11_render.cpp
Co-authored-by: Simon Anciaux <14198779+mrmixer@users.noreply.github.com>
2025-07-07 13:55:28 -07:00
fs 27b4626907 Added a check for badly defined scissor rectangles that caused a crash when resizing the window with dx11 backend 2025-07-07 13:55:14 -07:00
Peter Slattery 9e58435637 Fix font rendering on mac 2025-07-07 13:54:26 -07:00
Simon Anciaux 6469fe5a0f Removed test setup, and small clean up. 2025-07-07 13:25:15 -07:00
Ed Ye 0f5d46f5a4 remove old comment 2025-07-07 13:24:46 -07:00
Ed Ye 87d0eb9cf3 update opengl version to 3.2 on linux and update glsl version to 150 2025-07-07 13:24:06 -07:00
Edward Ye b834dbb451 change mac metal renderer to properly handle texture array 2025-07-07 13:23:11 -07:00
Simon Anciaux b2bdc515ec Mac version of the fix. Not working at the moment.
It needs an implementation for `free_texture` in 4ed_metal_render.mm (like `get_texture_of_dim`, and `fill_texture`).

We also need to make sure that the texture (`handle` parameter in get_texture_of_dim and fill_texture) is not zero as the original fix expect 0 to signify "invalid texture". More specifically in `4ed_font_provider_freetyp.cpp` there is `if (texture) { fill the texture }`
and in `4ed_font_set.cpp` there is `if ( slot->face->texture != 0 ) { graphics_free_texture(...);}`
2025-07-07 13:22:32 -07:00
Simon Anciaux 9b927bd410 Fixed slice index not being passed correctly. It was normalized instead of pass as an integer value.
This commit is setup for testing the texture array slices, it shouldn't be shipped to users.
2025-07-07 13:22:01 -07:00
Simon Anciaux bd7dac90ac Using 4coder string functions in code/4ed_api_parser_main.cpp instead of manually creating the strings.
Added "code/" in the string that point to the generator so it's easier to find the correct files.
Regenerated the 4 affected files (just to update the comment string).
2025-07-07 13:14:30 -07:00
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
BYP e040b1a29b undo can clear dirty state 2025-07-07 13:10:15 -07:00
Simon Anciaux c194053b83 4ed_generate_keycodes.cpp adds a comment at the top of the file it generate to specify which file generated it. Added proper indentation in the generated file. Note that this executable needs to be manually ran. The build system doesn't run it.
win32_keycode_init only initialize 30 KeyCode_Ex values (0 to 29) as the code generating the enum only generates that amount (explicitly loops from 0 to < 30).
2025-07-07 13:09:34 -07:00
Simon Anciaux e4a4910e6b Use the actual clip rectangle.
Use rect_overlap in draw_rectangle_outline.
Reorganized a bit to test earlier to avoid unnecessary work.
2025-07-07 13:09:10 -07:00
Simon Anciaux 33c3428796 Clipboard fix
Fixed duplicated entries in 4coder internal clipboard (Fix from VDK on the 4coder discord).
Removed the unnecessary loop that was there to try to fix the clipboard missing entries (which was fixed previously by removing the `next_clipboard_is_self` variable).
2025-07-07 13:07:35 -07:00
Simon Anciaux dfce9bf369 Fix wrong initialization of keycode lookup table
Up until now, several keys were assigned the same key value because the `keycode_lookup_table` array wasn't properly initialized. The values at the end of the array were all set to `KeyCode_Ex0 + 1` which is 112. This would cause several key to be treated as the same key.

In my case the key next to the left shift key ( `<` and `>` on AZERTY) was getting the same value as the `Right Windows key`. But I suppose that the left and right windows key would get the same value too (I can't check this as I have only 1 windows key on my keyboard).

This fix just properly initialize the array. I also fixed a typo in a function name: `keycode_physical_translaion_is_wrong` => `keycode_physical_translation_is_wrong`.
2025-07-07 13:06:29 -07:00
Simon Anciaux f3dc516704 Disable DXGI monitoring the message queue for Alt+Enter fullscreen switch. Switching that way instead of calling toggle_fullscreen, causes issue when trying to Alt+Tab. Also users might want to use Alt+Enter for other things.
Changed how DXGI factory is handled. I retrieve the one associated with the current DXGI device and adapter instead of creating a new one.
Fixed missing new line in the log at 1 location.
2025-07-07 13:05:28 -07:00
Simon Anciaux d926166630 Changed the fix a little to test only 4 vertex per characters (instead of 6).
Removed the "draw = true;" left from testing.
2025-07-07 13:05:18 -07:00
Simon Anciaux 52124edcd8 Avoid rendering rectangles (and characters) that are outside the window bounds.
While debugging an issue with the dx11 backend, I noticed that 4coder only clipped rectangles that are outside the screen vertically. Another potential issue (it might be the intended behavior) causes some things to not work with line wrapping, which means that we could have very long horizontal lines, causing a lot of vertices being sent through the render pipeline that will just be clipped after the vertex shader. This causes higher than necessary GPU memory usage, and low performance for things that aren't rendered in the end.

An example of problematic is:
```c
u8 data[ ] = {0,0,0,0,...,0}; // With a lot of zero, and no space between them.
```

This fix just checks that at least one vertex of each rectangle we try to draw is in the screen. It would be better to use the current clip rect, but it's not available at that point in the pipeline. If we want we can modify the API a little to pass it down, as a parameter to those functions.

Using RenderDoc, I saw the vertex count going from over 500K to 13K with this change, and the performance were from 57ms to 25ms. So perfs are not great (but still an improvement), but testing the bounds of 500K vertices is not free. Fixing the line wrapping issue would probably help getting back to reasonable frame rate.
2025-07-07 13:05:06 -07:00
Simon Anciaux dadb7dc49a Fixed crashing when 4coder tries to render more vertex than the vertex buffer reserved. We create a new buffer to accommodate the required size, and if that fails, we skip rendering the current vertex group. 2025-07-07 13:04:14 -07:00
Simon Anciaux 84da2da350 Changed `true` to `GL_TRUE` for `WGL_DOUBLE_BUFFER_ARB` to use OpenGL wording. 2025-07-07 13:03:52 -07:00