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

move ui and commands to helix-view #5581

Closed

Conversation

pascalkuthe
Copy link
Member

Closes #5555

This PR is super simple. All it does is:

  • Move relevant files to helix-view
  • replace helix_term:: with crate::
  • replace helix_view:: with crate:: (unfortunate that rust doesn't allow this)
  • replace tui:: with helix_tui:: (seems more consistent, but the main reason is that RA for some reason is unable to resolve these imports evenotugh rustc can which leads to terrible dev experience)
  • move a few additional small functions from helix-term that are used by commands

The primary focus of this PR is to avoid git conflicts. Git should handle most of these changes fine if a PR is rebased
altough there can be some conflicts in the use statements. However, compared to other PRs the changes here are not
that large and should be easy to resolve.

These changes will not only allow experimentation with GUIs (#39) but also unblocks other efforts (see #5555).
However, this PR implements not abstraction over the actual terminal functionality yet.
I think the best approach would be a cfg based approach opposed to traits as used by @archser in the gui branch.
Such an approach avoids many breaking changes (and making every function/struct generic).
This abstraction can be added in the future with smaller less disruptive PRs.

@pascalkuthe pascalkuthe marked this pull request as ready for review January 18, 2023 18:52
@pascalkuthe pascalkuthe added A-helix-term Area: Helix term improvements E-medium Call for participation: Experience needed to fix: Medium / intermediate A-gui Area: Helix gui improvements S-waiting-on-review Status: Awaiting review from a maintainer. labels Jan 18, 2023
@pascalkuthe pascalkuthe force-pushed the refactor_commands branch 2 times, most recently from 7c80092 to e8d440e Compare January 18, 2023 22:01
@pascalkuthe
Copy link
Member Author

pascalkuthe commented Jan 22, 2023

@archseer I kept this PR minimal on purpose so right now it doesn't hide terminal specific code behind cfg attributes. I wasn't 100% sure what the best way to do that would be and wanted to leave that design space for when we actually implement guis. This PR already unblocks the non-gui related work.

Are you okay with that or do you want me to add the cfg attributes in this PR?

Copy link
Member

@dead10ck dead10ck left a comment

Choose a reason for hiding this comment

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

This seems fine to me, thanks!

Copy link
Member

@gabydd gabydd left a comment

Choose a reason for hiding this comment

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

just a couple really small nits otherwise looks good, though I assume this would need a rebase so no worries if this review isn't that helpful

Comment on lines -50 to -52
/// Render the component onto the provided surface.
fn render(&mut self, area: Rect, frame: &mut Surface, ctx: &mut Context);

Copy link
Member

Choose a reason for hiding this comment

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

is this reorder necessary

@@ -264,14 +264,14 @@ impl Markdown {
CodeBlockKind::Fenced(language) => language,
CodeBlockKind::Indented => "",
};
let tui_text = highlighted_code_block(
let helix_tui_text = highlighted_code_block(
Copy link
Member

Choose a reason for hiding this comment

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

this and the one below don't need to be changed

Suggested change
let helix_tui_text = highlighted_code_block(
let tui_text = highlighted_code_block(

text.to_string(),
language,
theme,
Arc::clone(&self.config_loader),
None,
);
lines.extend(tui_text.lines.into_iter());
lines.extend(helix_tui_text.lines.into_iter());
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
lines.extend(helix_tui_text.lines.into_iter());
lines.extend(tui_text.lines.into_iter());


# TODO: graphics.rs tests rely on this, but we should remove that
# [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
# helix-tui = { path = "../helix-tui" }
Copy link
Member

Choose a reason for hiding this comment

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

I think all our cargo.tomls have newlines at the end

Suggested change
# helix-tui = { path = "../helix-tui" }
# helix-tui = { path = "../helix-tui" }

@@ -28,7 +28,7 @@ path = "src/main.rs"

[dependencies]
helix-core = { version = "0.6", path = "../helix-core" }
helix-view = { version = "0.6", path = "../helix-view" }
helix-view = { version = "0.6", path = "../helix-view", features = ["term"]}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
helix-view = { version = "0.6", path = "../helix-view", features = ["term"]}
helix-view = { version = "0.6", path = "../helix-view", features = ["term"] }

Copy link
Member

@gabydd gabydd left a comment

Choose a reason for hiding this comment

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

just a couple really small nits otherwise looks good, though I assume this would need a rebase so no worries if this review isn't that helpful

@pascalkuthe
Copy link
Member Author

I think I want to go with a slightly different approach here, this branch also has an insane amount of conflicts so I need to start over anyway. I will close this

@pascalkuthe pascalkuthe closed this Apr 8, 2024
@pascalkuthe pascalkuthe deleted the refactor_commands branch April 8, 2024 01:28
@pascalkuthe pascalkuthe restored the refactor_commands branch April 8, 2024 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-gui Area: Helix gui improvements A-helix-term Area: Helix term improvements E-medium Call for participation: Experience needed to fix: Medium / intermediate S-waiting-on-review Status: Awaiting review from a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move commands into the helix-view crate
4 participants