Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax highlighting and hinting #1101

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

pedrocarlo
Copy link
Contributor

@pedrocarlo pedrocarlo commented Mar 5, 2025

Start of syntax highlighting and hinting. Still need to figure out how to sublime-syntax works to produce good highlights.

Edit:
Personally, I believe there are more interesting syntax highlighting possibilities with reedline crate, but currently, we cannot use it as the our DB Connection would have to be Send. This PR is an introduction and quality of life changes for the users of the CLI and for us developers, as we now won't have to look at black and white text only. I want to have a config file to personalize the color pallets, that will be made in a following PR.

cli/app.rs Outdated
row.add_cell(
Cell::new(content)
.set_alignment(alignment)
.fg(COLORS[idx & COLORS.len()]),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you meant %, not &

Copy link
Contributor Author

@pedrocarlo pedrocarlo Mar 6, 2025

Choose a reason for hiding this comment

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

Lol yes thanks

Cell::new(name).add_attribute(Attribute::Bold)
Cell::new(name)
.add_attribute(Attribute::Bold)
.fg(Color::AnsiValue(49)) // Green color for headers
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think the headers need to be the brightest parts of the table view. They're already the first line you see. We can make them a bit dimmer with AnsiValue(9)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The AnsiValue(9) in this case would make the header red it would not dim it. To make it non bold you have to remove the Attribute::Bold. Regardless, I think this configuration could be the default and you can have a config file to change these little things to your preference.

@@ -196,6 +196,8 @@ macro_rules! query_internal {
}};
}

static COLORS: &[Color] = &[Color::DarkRed, Color::DarkGreen, Color::DarkBlue];
Copy link
Contributor

Choose a reason for hiding this comment

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

Can probably throw Color::DarkCyan, Color::DarkMagenta, Color::DarkYellow in there as well so it doesn't repeat immediately

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it could be a good default, I have to see how it would play out with a config file. I will get back to this after I have a configuration in mind

@pedrocarlo pedrocarlo marked this pull request as ready for review March 7, 2025 00:54
@pedrocarlo pedrocarlo requested a review from penberg as a code owner March 7, 2025 00:54
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.

2 participants