Skip to content

Conversation

@s1yle
Copy link

@s1yle s1yle commented Jan 9, 2026

Hi Alexey, I saw the TODO regarding tab character support and decided to implement it as a learning exercise.
I understand your policy on new features, so feel free to close this if it's outside the current scope.
I had a lot of fun digging into the atlas and lexer logic!

This PR implements native support for the Tab character (\t) in ded, replacing the previous behavior of inserting 4 spaces.

Instead of hardcoding tab widths in the renderer or lexer, this implementation leverages the existing atlas->metrics system. By assigning a custom horizontal advance (ax) to the \t glyph index, all components (lexer, cursor positioning, and rendering) automatically respect the tab width without additional conditional logic.

  • src/free_glyph.c – Added initialization of the tab character’s glyph metrics in free_glyph_atlas_init. The tab’s advance width is set to 4× the space character’s advance (matching the existing width assumption in lexer_chop_char).

  • src/lexer.c – Restored the condition && l->content[l->cursor] != '\t' in lexer_trim_left, ensuring tabs are not consumed as whitespace and can be properly tokenized as TOKEN_TAB.

  • src/lexer.hTOKEN_TAB defined.

  • src/main.c – The Tab key handling (inserts a literal \t). The TODO comments about smarter indentation are left for future work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant