Skip to content

Conversation

@mkh-user
Copy link
Member

@mkh-user mkh-user commented Oct 3, 2025

Type of Change

  • New feature

Description

Adds code colors to themes, along with a function to quickly retrieve them. Fixes #111 but reloads current mode after settings change to handle theme changing.

Testing

Works fine.

Impact

Nothing special.

Additional Information

Nothing

Checklist

  • My code adheres to the coding and style guidelines of the project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings
  • Changes were added to CHANGELOG

Summary by CodeRabbit

  • New Features
    • Theme-based syntax highlighting with expanded color categories for richer, more readable editor coloring.
  • Style
    • Refined Dark theme visuals: expanded syntax palette and improved tab, editor, and tree styles for clearer focus and selection states.
  • Bug Fixes
    • Fixed caret position popup layout to prevent misplacement and overflow.
  • Chores
    • Changelog updated with the new syntax highlighting entry.

@mkh-user mkh-user self-assigned this Oct 3, 2025
@mkh-user mkh-user added this to the Text Forge 0.2 milestone Oct 3, 2025
@mkh-user mkh-user moved this from Needs Review to In Progress in Release: Text Forge 1.0 Oct 3, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 3, 2025

Walkthrough

Adds theme-based syntax color support (enum, mapping, getter), extends the dark theme with SyntaxColors and related UI style entries, adjusts settings flow to unload/reload current mode during theme application, tweaks a popup MarginContainer layout, and updates the changelog entry.

Changes

Cohort / File(s) Summary
Changelog update
CHANGELOG.md
Adds “Syntax highlighting colors by themes” entry under Unreleased -> Added.
Syntax color API
core/autoload/utils.gd
Adds enum SyntaxColors, const SYNTAX_COLORS_MAP and func get_syntax_color(token_name: SyntaxColors) -> Color to expose theme-driven code colors.
Settings/control-flow tweak
core/main.gd
_handle_settings now unloads the current mode, awaits a frame/timer, then switches back to the previous mode around theme application.
Scene layout tweak
core/main.tscn
Adjusts CaretPos popup MarginContainer offsets: offset_right 198.0 → -2.0 and offset_bottom 80.0 → -2.0.
Theme additions (colors & styles)
data/themes/dark.tres
Inserts SyntaxColors/colors entries (default, builtin, comment, keyword1–3, number, string, etc.) and additional UI style mappings (TabContainer, TextEdit, Tree). Block appears in two insertion points.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Settings as Settings UI
  participant Main as core/main.gd
  participant Mode as CurrentMode
  participant Theme as Theme Engine
  participant Utils as core/autoload/utils.gd

  User->>Settings: change theme/preferences
  Settings->>Main: _handle_settings()
  Main->>Theme: apply_theme()  %% includes SyntaxColors data
  Theme->>Utils: expose SyntaxColors (SYNTAX_COLORS_MAP)
  Utils-->>Main: get_syntax_color(...) returns Color

  alt current mode exists
    Main->>Mode: unload()
    Note over Main,Mode: await frame/timer
    Main->>Main: switch_to(previous_mode)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

Little paws tint code tonight,
Keywords glow in moonlit light,
I hop, unload, then hop anew—
Theme colors stitched in every queue.
Burrowed bytes now shine in view. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Linked Issues Check ⚠️ Warning The PR adds syntax color definitions to themes, a utility function to retrieve them, and reloads modes on theme change, fulfilling theme extension and retrieval requirements, but it does not update any mode or highlighter code to actually use the new theme-provided colors, so modes remain unchanged. Ensure that existing mode or highlighter code is updated to call get_syntax_color for token coloring so that modes use the new theme-provided syntax colors as specified in issue #111.
Out of Scope Changes Check ⚠️ Warning The PR includes unrelated UI layout adjustments in core/main.tscn and adds non-syntax style entries in dark.tres for TabContainer, TextEdit, and Tree components that do not pertain to the “Code” section or syntax color support defined in issue #111. Remove or isolate the UI layout offset changes and unrelated theme style additions into a separate PR so this changeset only covers the syntax color support scoped to the Code theme section.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title “Syntax colors support” succinctly and accurately summarizes the primary feature added by the changeset, namely the introduction of syntax color definitions and retrieval support for themes. It directly reflects the main enhancement without extraneous detail.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch syntax-colors-support

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 59e8556 and 90bb795.

📒 Files selected for processing (1)
  • CHANGELOG.md (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]

This comment was marked as resolved.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@mkh-user mkh-user merged commit 7e1c27f into Main Oct 3, 2025
2 checks passed
@mkh-user mkh-user deleted the syntax-colors-support branch October 3, 2025 13:04
@github-project-automation github-project-automation bot moved this from In Progress to Completed in Release: Text Forge 1.0 Oct 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Completed

Development

Successfully merging this pull request may close these issues.

Add syntax colors to themes

2 participants