Jump to content

GSoC/2025/StatusReports/simplelives

From KDE Community Wiki

Intergrate KTextEditor into Cantor

Cantor is a powerful mathematical and statistical computingfront-end within the KDE ecosystem.Currently, Cantor's worksheet cells use a custom implementationthat, while meeting basic needs, has certain limitations interms of functionality expansion and maintenance. To enhancetheediting experience and simplify the codebase, this project plansto integrate the KTextEditor component into Cantor, replacingthe existing cell implementation. This improvement will bringnumerous powerful new features to Cantor, including:

  • Vi Mode: Provides Vi-style text editing, improving efficiency and catering to users accustomed to Vim.
  • Improved Syntax Highlighting: Supports more comprehensivecode coloring rules, making mathematical and programmingexpressions clearer and easier to read.
  • Auto-indent: Enhances code formatting capabilities, makingit more convenient to write structured code.
  • Code Completion: Intelligently suggests variables, functions,and keywords, increasing input speed and reducing syntaxerrors.
  • Spell Check: Ensures the accuracy of text and comments,making it useful for documentation and formula explanations.

Mentor

Alexander Semke

Israel Galadima

Work report

Week 1:

  • Read and understand the cell working logic based on QTextDocument. Check the KTextEditor documentation and think about how to integrate it correctly.
  • View the current frame and use QGraphicsProxyWidget to embed KTextEditor into QWidget
  • Based on the original class (WorksheetTextItem), preliminarily define the KTextEditor integrated KTextItem.[1]

Week 2:

  • First migrate commandEntry, modify the relevant function implementation, and call KTextEditor to implement.[2]
  • Modify the implementation of related functions to ensure that they can be compiled correctly after migration.[3]

Week 3:

  • Discussed renaming KTextItem to WorksheetTextEditorItem because the new class has richer functionality.[4]
  • Implementing the empty function of Worksheet TextEditor Item step by step.

Week 4:

  • Based on the existing editing performance, summarize the functions that need to be adapted.
  • The implementation of keyboard related events, but found that the movement between characters cannot be handled correctly

Week 5:

  • Discuss the correctness of QGraphicsProxyWidget's event delivery
  • Implement code syntax highlighting.[5]

Week 6:

  • Fixed the problem of running the same item twice and the layout being messed up after running.[6]
  • Research on the implementation of search and replace based on KTextEditor::View

Week 7:

  • Learned and became familiar with the usage of KTextEditor::CodeCompletionModel and related interfaces, and mastered its basic principles and calling methods.
  • KTextEditor::CodeCompletionModel is preliminarily encapsulated in WorksheetTextEditorItem to establish the basic framework of the code completion function.[7]
  • Restored expected Tab key behavior, ensuring that the completion list no longer appears inappropriately. This refinement aligns Cantor’s editor interactions with user expectations and improves usability.

Week 8:

  • Implemented the initial version of code completion based on KTextEditor::CodeCompletionModel. This marks the first working integration of completion into Cantor’s worksheet editor.
  • At this stage, the completion list was maintained manually inside WorksheetTextEditorItem, providing a controllable but foundational approach for further development.

Week 9:

  • Extended the completion system to support user-defined keywords. These keywords are now both highlighted and available as completion suggestions, making Cantor’s editor more adaptable to user workflows.
  • The custom logic that previously handled syntax highlighting and

partial completion has been removed. Now, using KTextEditor as a unified backend, the codebase has become cleaner and easier to maintain.[8]

Week 10:

  • Enhanced compatibility between the new completion framework and search-and-replace functionality across different worksheet items. This ensures that users can rely on Cantor’s editing tools consistently, regardless of which item they are working on.
  • Validated functionality by testing with example items, confirming that completion, highlighting, and search/replace operations all behave reliably in real use cases.

Week 11:

  • Conducted comprehensive functional testing, systematically covering different backends and interaction scenarios to ensure stability and correctness.
  • Fixed CI issues introduced by recent changes, ensuring smooth integration with Cantor’s continuous integration pipeline and guaranteeing that the project remains buildable and testable across environments.[9]

Week 12:

  • Discussed with mentors the implementation details of the planned theming support, focusing on how to unify worksheet appearance through KTextEditor/KSyntaxHighlighting themes.
  • Performed a simple prototype to validate feasibility, ensuring that switching themes can be propagated correctly to worksheet entries and results.

Future Plans

Theming support (planned) For now, Cantor will keep the Default theme, which uses the desktop palette. This preserves the familiar look and behavior.

Next, we plan to introduce a Worksheet Theme setting. Users will be able to:

- Stay with Default (desktop palette, as before), or

- Choose a theme from KTextEditor/KSyntaxHighlighting, just like in Kate.

The selected theme will apply consistently across the worksheet—including command entries and results—for a unified appearance. Instead of relying on hardcoded colors or the system palette, Cantor will use the color roles provided by KTextEditor and KSyntaxHighlighting.

This approach avoids performance overhead from repeatedly reading theme files, ensures instant updates when switching themes, and lays the foundation for richer customization in the future—such as clearer distinctions between prompts, results, and errors, all within a consistent global style.

Links to Blogs and other writing

Integrate KTextEditor into Cantor

Integrate KTextEditor into Cantor(2)

Contact

[email protected]

@fu4ure:mozilla.org