Skip to content

New feature: highlight text selection at SqlEditor#418

Merged
arvanus merged 2 commits into
mariuz:masterfrom
arvanus:master
Apr 10, 2025
Merged

New feature: highlight text selection at SqlEditor#418
arvanus merged 2 commits into
mariuz:masterfrom
arvanus:master

Conversation

@arvanus

@arvanus arvanus commented Apr 9, 2025

Copy link
Copy Markdown
Collaborator

closes #401

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @arvanus, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request introduces a new feature to highlight text selections and the word under the cursor in the SqlEditor. This enhancement aims to improve the user experience by making it easier to identify and track specific words or selections within the SQL code. The changes include adding a new configuration setting to enable/disable the feature, implementing the highlighting logic within the SqlEditor class, and handling the UI updates to reflect the highlights.

Highlights

  • New Feature: Implements text selection and cursor highlights in the SqlEditor.
  • Configuration Setting: Adds a new checkbox setting 'highlightWordText' in the configuration to enable or disable the text highlighting feature.
  • Highlighting Logic: Introduces 'highlightText' and 'clearHighlights' methods in the SqlEditor class to manage the highlighting of text ranges.
  • UI Update: Binds the wxEVT_STC_UPDATEUI event to the OnTextSelected method in ExecuteSqlFrame to update highlights based on text selection or cursor position.

Changelog

Click here to see the changelog
  • conf-defs/fr_settings.confdef
    • Added a new setting 'highlightWordText' to enable or disable text selection/cursor highlights.
  • src/gui/ExecuteSqlFrame.cpp
    • Implemented 'highlightText' method in SqlEditor to highlight a given text range using indicators.
    • Implemented 'clearHighlights' method in SqlEditor to clear all highlights in the editor.
    • Added 'highlightWordText' member variable to ExecuteSqlFrame, read from config.
    • Bound wxEVT_STC_UPDATEUI event to 'OnTextSelected' method in ExecuteSqlFrame when 'highlightWordText' is enabled.
    • Implemented 'highlightOccurrences' method to find and highlight all occurrences of a given word.
    • Implemented 'OnTextSelected' method to handle text selection and cursor position changes, updating highlights accordingly.
  • src/gui/ExecuteSqlFrame.h
    • Added 'highlightText' and 'clearHighlights' method declarations to the SqlEditor class.
    • Added 'highlightWordText', 'highlightWordUnderCaret', and 'highlightWordTextMatchCase' member variables to the ExecuteSqlFrame class.
    • Added 'highlightOccurrences' and 'OnTextSelected' method declarations to the ExecuteSqlFrame class.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


In code's vast expanse,
A highlight's soft trance,
Words gleam, clear and bright,
Guiding through the night,
A feature to enhance.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new feature to highlight text selection in the SqlEditor, enhancing the user experience. The implementation involves adding a configuration setting, new methods for highlighting and clearing highlights in the SqlEditor, and event handling to trigger the highlighting. Overall, the changes seem well-structured and address the intended functionality. However, there are a few areas that could benefit from further refinement.

Summary of Findings

  • Global Style Configuration for Highlight Color: The highlight color is currently hardcoded as blue. It would be better to allow users to customize this color through the global style configuration to align with their preferences and the application's theme.
  • Case Sensitivity Configuration: The code includes a TODO to add a configuration option for case-sensitive search. Implementing this option would provide users with more control over the highlighting behavior.
  • Highlighting Logic Refinement: The logic for clearing highlights when moving the caret out of a word could be improved to ensure a smoother and more intuitive user experience.

Merge Readiness

The pull request introduces a valuable feature, but there are some improvements that should be considered before merging. Addressing the hardcoded highlight color and refining the highlighting logic would enhance the user experience. While I am unable to directly approve this pull request, I recommend that these points be addressed before merging. Ensure that others review and approve this code before merging.

Comment on lines +302 to +303
//TODO: If you don't like blue, please change to use global style configuration and send your patch
IndicatorSetForeground(0, wxColour(wxT("blue"))); //I liked how it looks like in blue

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The highlight color is currently hardcoded as blue. To improve flexibility and user customization, consider using a global style configuration to allow users to choose their preferred highlight color. This would also ensure consistency with the application's overall theme.

Consider using FRStyleManager to manage the color, so it can be configured via the style dialog.

Suggested change
//TODO: If you don't like blue, please change to use global style configuration and send your patch
IndicatorSetForeground(0, wxColour(wxT("blue"))); //I liked how it looks like in blue
IndicatorSetForeground(0, stylerManager().getGlobalStyle()->getfgColor()); //I liked how it looks like in blue


int start = 0;
int end = 0;
int flags = (highlightWordTextMatchCase ? wxSTC_FIND_MATCHCASE : 0); // No flags for case-insensitive search, use 0 instead TODO: add config to allow case (in)sensitive

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This comment mentions a TODO to add a configuration option for case-(in)sensitive search. Implementing this configuration would provide users with more control over the highlighting behavior. Consider adding a checkbox in the settings dialog to control this behavior.

Suggested change
int flags = (highlightWordTextMatchCase ? wxSTC_FIND_MATCHCASE : 0); // No flags for case-insensitive search, use 0 instead TODO: add config to allow case (in)sensitive
int flags = (highlightWordTextMatchCase ? wxSTC_FIND_MATCHCASE : 0); // No flags for case-insensitive search, use 0 instead TODO: add config to allow case (in)sensitive
int flags = (highlightWordTextMatchCase ? wxSTC_FIND_MATCHCASE : 0); // No flags for case-insensitive search, use 0 instead

@arvanus
arvanus merged commit 391fa2b into mariuz:master Apr 10, 2025
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.

Highlight same word selected in SQL editor

1 participant