0

I'm writing a text editor in Rust using egui. I am trying to implement syntax highlighting, so I followed the example in the demo. It works there, so I thought it might be useful. But I am getting an error that syntax_highlighting is not found in the crate root. I have syntect and egui both installed at their latest versions and have them as dependencies.

let mut theme = crate::syntax_highlighting::CodeTheme::from_memory(ui.ctx());
ui.collapsing("Theme", |ui| {
    ui.group(|ui| {
        theme.ui(ui);
        theme.clone().store_in_memory(ui.ctx());
    });
});


let mut layouter = |ui: &egui::Ui, string: &str, wrap_width: f32| {
    let mut layout_job = 
        crate::syntax_highlighting::highlight(ui.ctx(), &theme, string, self.language);
    layout_job.wrap.max_width = wrap_width;
    ui.fonts().layout_job(layout_job)
};

In particular, it is these lines that raise the error that syntax_highlighting is not found in the crate root. In case it's useful, here is all my code: https://pastebin.com/mHDhLhSR

I want to implement syntax highlighting to my egui application, but I get the error that syntax_highlighting is not found in the crate root, which the only example I found used.

cascading-jox
  • 982
  • 1
  • 7
  • 21
VideoCarp
  • 35
  • 1
  • 2
  • 7

1 Answers1

2

The crate:: means syntax_highlighting is a member of the egui_demo_lib crate itself. In this case, you'll find it right here.

mrkishi
  • 5,602
  • 1
  • 20
  • 18