diff --git a/data/src/config/scoutlink.rs b/data/src/config/scoutlink.rs index b83afc6..5380925 100644 --- a/data/src/config/scoutlink.rs +++ b/data/src/config/scoutlink.rs @@ -364,10 +364,10 @@ pub fn text(language: &str, key: &str) -> &'static str { ], "list_line" => ["linje", "linje", "rad", "line"], "list_syntax" => [ - "Ett ord eller uttrykk per linje: ord, ord*, *ord eller re:regex. Legg til # forklaring og !1-3 for alvorlighet. Linjer som starter med # er kommentarer.", - "Ét ord eller udtryk pr. linje: ord, ord*, *ord eller re:regex. Tilføj # forklaring og !1-3 for alvorlighed. Linjer der starter med # er kommentarer.", - "Ett ord eller uttryck per rad: ord, ord*, *ord eller re:regex. Lägg till # förklaring och !1-3 för allvarlighet. Rader som börjar med # är kommentarer.", - "One word or phrase per line: word, word*, *word or re:regex. Add # meaning and !1-3 for severity. Lines starting with # are comments.", + "Ett ord eller uttrykk per linje: ord, ord*, *ord eller re:regex. Legg til «# forklaring» og «!1-3» for alvorlighet. Linjer som starter med # er kommentarer.", + "Ét ord eller udtryk pr. linje: ord, ord*, *ord eller re:regex. Tilføj «# forklaring» og «!1-3» for alvorlighed. Linjer der starter med # er kommentarer.", + "Ett ord eller uttryck per rad: ord, ord*, *ord eller re:regex. Lägg till «# förklaring» och «!1-3» för allvarlighet. Rader som börjar med # är kommentarer.", + "One word or phrase per line: word, word*, *word or re:regex. Add \"# meaning\" and \"!1-3\" for severity. Lines starting with # are comments.", ], "list_plain" => [ "En oppføring per linje. Tomme linjer hoppes over.", diff --git a/src/buffer/config_editor.rs b/src/buffer/config_editor.rs index 40340dc..fb36983 100644 --- a/src/buffer/config_editor.rs +++ b/src/buffer/config_editor.rs @@ -745,6 +745,8 @@ enum Code { #[derive(Debug, Clone, Copy)] enum ListCode { + /// Text without a colour of its own. + Plain, Comment, Meaning, /// `word*` or `*word` @@ -755,6 +757,30 @@ enum ListCode { Invalid, } +/// Covers the whole line: what no part claims is plain text, so it is drawn +/// in the normal text colour. +fn fill_gaps( + line: &str, + mut parts: Vec<(Range, ListCode)>, +) -> Vec<(Range, ListCode)> { + parts.sort_by_key(|(range, _)| range.start); + + let mut out = Vec::new(); + let mut at = 0; + for (range, code) in parts { + if range.start > at { + out.push((at..range.start, ListCode::Plain)); + } + at = at.max(range.end); + out.push((range, code)); + } + if at < line.len() { + out.push((at..line.len(), ListCode::Plain)); + } + + out +} + /// The coloured parts of one line of a word list. fn list_line(line: &str) -> Vec<(Range, ListCode)> { let trimmed = line.trim_start(); @@ -832,6 +858,7 @@ impl ConfigParser { } else { Vec::new() }; + let parts = fill_gaps(line, parts); return Box::new( parts @@ -910,6 +937,7 @@ fn config_highlight(output: Code, theme: &Theme) -> Style { Code::List(code) => { let text = theme.styles().text; let color = match code { + ListCode::Plain => text.primary.color, ListCode::Comment | ListCode::Meaning => text.secondary.color, ListCode::Affix => { text.info.color.unwrap_or(text.primary.color) diff --git a/src/modal/flag_viewer.rs b/src/modal/flag_viewer.rs index 3168de8..04d4bc2 100644 --- a/src/modal/flag_viewer.rs +++ b/src/modal/flag_viewer.rs @@ -444,11 +444,6 @@ impl FlagViewer { row![ icon::config().width(13).height(13), text(self.t("fv_edit")).size(small), - container(text(self.t("fv_recommended")).size(small - 2.0)) - .padding([1, 7]) - .style(move |theme: &Theme| theme::container::chip( - theme, info - )), ] .spacing(7) .align_y(Alignment::Center), @@ -456,6 +451,12 @@ impl FlagViewer { .padding([5, 12]) .style(theme::button::action_primary) .on_press(act(Action::Edit(kind))); + let recommended = + container(text(self.t("fv_recommended")).size(small - 2.0)) + .padding([1, 7]) + .style(move |theme: &Theme| { + theme::container::chip(theme, info) + }); let mut top = row![ back, @@ -482,7 +483,7 @@ impl FlagViewer { theme, )); } - top = top.push(edit); + top = top.push(recommended).push(edit); let default = self.default_severity(); let shown = filter( diff --git a/src/modal/scoutlink/rows.rs b/src/modal/scoutlink/rows.rs index ac5320e..628185e 100644 --- a/src/modal/scoutlink/rows.rs +++ b/src/modal/scoutlink/rows.rs @@ -166,11 +166,6 @@ pub fn list_row<'a>( row![ icon::config().width(13).height(13), text(settings.t("fv_edit")), - container( - text(settings.t("fv_recommended")).size(theme::TEXT_SIZE - 3.0) - ) - .padding([1, 7]) - .style(move |theme: &Theme| theme::container::chip(theme, info)), ] .spacing(7) .align_y(Alignment::Center), @@ -178,6 +173,11 @@ pub fn list_row<'a>( .padding([5, 12]) .style(theme::button::action_primary) .on_press(Message::ScoutLink(Action::EditList(kind))); + let recommended = container( + text(settings.t("fv_recommended")).size(theme::TEXT_SIZE - 3.0), + ) + .padding([1, 7]) + .style(move |theme: &Theme| theme::container::chip(theme, info)); row![ iced::widget::column![ @@ -191,6 +191,7 @@ pub fn list_row<'a>( ] .spacing(2) .width(iced::Length::Fill), + recommended, edit, ] .spacing(10)