| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/max().; |
| 2 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#; |
| 3 | |
| 4 | use craterust-analyzer cargo git-delta 0.19.2 crate/::ansirust-analyzer cargo git-delta 0.19.2 ansi/; |
| 5 | use craterust-analyzer cargo git-delta 0.19.2 crate/::clirust-analyzer cargo git-delta 0.19.2 cli/::Widthrust-analyzer cargo git-delta 0.19.2 cli/Width#; |
| 6 | use craterust-analyzer cargo git-delta 0.19.2 crate/::stylerust-analyzer cargo git-delta 0.19.2 style/::{DecorationStylerust-analyzer cargo git-delta 0.19.2 style/DecorationStyle#, Stylerust-analyzer cargo git-delta 0.19.2 style/Style#}; |
| 7 | |
| 8 | fn paint_textrust-analyzer cargo git-delta 0.19.2 handlers/draw/paint_text().(text_style: Stylerust-analyzer cargo git-delta 0.19.2 style/Style#, text: &str, addendum: &str) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 9 | if addendum.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() { |
| 10 | text_style.paintrust-analyzer cargo git-delta 0.19.2 style/impl#[Style]paint().(text).to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() |
| 11 | } else { |
| 12 | text_style |
| 13 | .paintrust-analyzer cargo git-delta 0.19.2 style/impl#[Style]paint().(text.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add().+rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add()." (" rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add().+rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add().addendum rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add().+rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add().")") |
| 14 | .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | pub type DrawFunctionrust-analyzer cargo git-delta 0.19.2 handlers/draw/DrawFunction# = dyn FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#( |
| 19 | &mut dyn Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, |
| 20 | &str, |
| 21 | &str, |
| 22 | &str, |
| 23 | &Widthrust-analyzer cargo git-delta 0.19.2 cli/Width#, |
| 24 | Stylerust-analyzer cargo git-delta 0.19.2 style/Style#, |
| 25 | ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::Stylerust-analyzer cargo nu-ansi-term 0.50.3 style/Style#, |
| 26 | ) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()>; |
| 27 | |
| 28 | pub fn get_draw_functionrust-analyzer cargo git-delta 0.19.2 handlers/draw/get_draw_function().( |
| 29 | decoration_style: DecorationStylerust-analyzer cargo git-delta 0.19.2 style/DecorationStyle#, |
| 30 | ) -> (Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<DrawFunctionrust-analyzer cargo git-delta 0.19.2 handlers/draw/DrawFunction#>, bool, ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::Stylerust-analyzer cargo nu-ansi-term 0.50.3 style/Style#) { |
| 31 | match decoration_style { |
| 32 | DecorationStylerust-analyzer cargo git-delta 0.19.2 style/DecorationStyle#::Boxrust-analyzer cargo git-delta 0.19.2 style/DecorationStyle#Box#(style) => (Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(write_boxedrust-analyzer cargo git-delta 0.19.2 handlers/draw/write_boxed().), true, style), |
| 33 | DecorationStylerust-analyzer cargo git-delta 0.19.2 style/DecorationStyle#::BoxWithUnderlinerust-analyzer cargo git-delta 0.19.2 style/DecorationStyle#BoxWithUnderline#(style) => { |
| 34 | (Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(write_boxed_with_underlinerust-analyzer cargo git-delta 0.19.2 handlers/draw/write_boxed_with_underline().), true, style) |
| 35 | } |
| 36 | DecorationStylerust-analyzer cargo git-delta 0.19.2 style/DecorationStyle#::BoxWithOverlinerust-analyzer cargo git-delta 0.19.2 style/DecorationStyle#BoxWithOverline#(style) => { |
| 37 | // TODO: not implemented |
| 38 | (Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(write_boxedrust-analyzer cargo git-delta 0.19.2 handlers/draw/write_boxed().), true, style) |
| 39 | } |
| 40 | DecorationStylerust-analyzer cargo git-delta 0.19.2 style/DecorationStyle#::BoxWithUnderOverlinerust-analyzer cargo git-delta 0.19.2 style/DecorationStyle#BoxWithUnderOverline#(style) => { |
| 41 | // TODO: not implemented |
| 42 | (Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(write_boxedrust-analyzer cargo git-delta 0.19.2 handlers/draw/write_boxed().), true, style) |
| 43 | } |
| 44 | DecorationStylerust-analyzer cargo git-delta 0.19.2 style/DecorationStyle#::Underlinerust-analyzer cargo git-delta 0.19.2 style/DecorationStyle#Underline#(style) => (Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(write_underlinedrust-analyzer cargo git-delta 0.19.2 handlers/draw/write_underlined().), false, style), |
| 45 | DecorationStylerust-analyzer cargo git-delta 0.19.2 style/DecorationStyle#::Overlinerust-analyzer cargo git-delta 0.19.2 style/DecorationStyle#Overline#(style) => (Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(write_overlinedrust-analyzer cargo git-delta 0.19.2 handlers/draw/write_overlined().), false, style), |
| 46 | DecorationStylerust-analyzer cargo git-delta 0.19.2 style/DecorationStyle#::UnderOverlinerust-analyzer cargo git-delta 0.19.2 style/DecorationStyle#UnderOverline#(style) => (Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(write_underoverlinedrust-analyzer cargo git-delta 0.19.2 handlers/draw/write_underoverlined().), false, style), |
| 47 | DecorationStylerust-analyzer cargo git-delta 0.19.2 style/DecorationStyle#::NoDecorationrust-analyzer cargo git-delta 0.19.2 style/DecorationStyle#NoDecoration# => ( |
| 48 | Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(write_no_decorationrust-analyzer cargo git-delta 0.19.2 handlers/draw/write_no_decoration().), |
| 49 | false, |
| 50 | ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::Stylerust-analyzer cargo nu-ansi-term 0.50.3 style/Style#::newrust-analyzer cargo nu-ansi-term 0.50.3 style/impl#[Style]new().(), |
| 51 | ), |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | fn write_no_decorationrust-analyzer cargo git-delta 0.19.2 handlers/draw/write_no_decoration().( |
| 56 | writer: &mut dyn Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, |
| 57 | text: &str, |
| 58 | raw_text: &str, |
| 59 | addendum: &str, |
| 60 | _line_width: &Widthrust-analyzer cargo git-delta 0.19.2 cli/Width#, // ignored |
| 61 | text_style: Stylerust-analyzer cargo git-delta 0.19.2 style/Style#, |
| 62 | _decoration_style: ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::Stylerust-analyzer cargo nu-ansi-term 0.50.3 style/Style#, |
| 63 | ) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> { |
| 64 | if text_style.is_rawrust-analyzer cargo git-delta 0.19.2 style/Style#is_raw. { |
| 65 | writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(writer, "{raw_text}")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 66 | } else { |
| 67 | writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(writer, "{}", paint_textrust-analyzer cargo git-delta 0.19.2 handlers/draw/paint_text().(text_style, text, addendum))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 68 | } |
| 69 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 70 | } |
| 71 | |
| 72 | /// Write text to stream, surrounded by a box, leaving the cursor just |
| 73 | /// beyond the bottom right corner. |
| 74 | pub fn write_boxedrust-analyzer cargo git-delta 0.19.2 handlers/draw/write_boxed().( |
| 75 | writer: &mut dyn Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, |
| 76 | text: &str, |
| 77 | raw_text: &str, |
| 78 | addendum: &str, |
| 79 | _line_width: &Widthrust-analyzer cargo git-delta 0.19.2 cli/Width#, // ignored |
| 80 | text_style: Stylerust-analyzer cargo git-delta 0.19.2 style/Style#, |
| 81 | decoration_style: ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::Stylerust-analyzer cargo nu-ansi-term 0.50.3 style/Style#, |
| 82 | ) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> { |
| 83 | let up_left = if decoration_style.is_boldrust-analyzer cargo nu-ansi-term 0.50.3 style/Style#is_bold. { |
| 84 | box_drawingrust-analyzer cargo box_drawing 0.1.2 crate/::heavyrust-analyzer cargo box_drawing 0.1.2 heavy/::UP_LEFTrust-analyzer cargo box_drawing 0.1.2 heavy/UP_LEFT. |
| 85 | } else { |
| 86 | box_drawingrust-analyzer cargo box_drawing 0.1.2 crate/::lightrust-analyzer cargo box_drawing 0.1.2 light/::UP_LEFTrust-analyzer cargo box_drawing 0.1.2 light/UP_LEFT. |
| 87 | }; |
| 88 | let box_width = ansirust-analyzer cargo git-delta 0.19.2 ansi/::measure_text_widthrust-analyzer cargo git-delta 0.19.2 ansi/measure_text_width().(text); |
| 89 | write_boxed_partialrust-analyzer cargo git-delta 0.19.2 handlers/draw/write_boxed_partial().( |
| 90 | writer, |
| 91 | text, |
| 92 | raw_text, |
| 93 | addendum, |
| 94 | box_width, |
| 95 | text_style, |
| 96 | decoration_style, |
| 97 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 98 | writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(writer, "{}", decoration_style.paintrust-analyzer cargo nu-ansi-term 0.50.3 display/impl#[Style]paint().(up_left))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 99 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 100 | } |
| 101 | |
| 102 | /// Write text to stream, surrounded by a box, and extend a line from |
| 103 | /// the bottom right corner. |
| 104 | fn write_boxed_with_underlinerust-analyzer cargo git-delta 0.19.2 handlers/draw/write_boxed_with_underline().( |
| 105 | writer: &mut dyn Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, |
| 106 | text: &str, |
| 107 | raw_text: &str, |
| 108 | addendum: &str, |
| 109 | line_width: &Widthrust-analyzer cargo git-delta 0.19.2 cli/Width#, |
| 110 | text_style: Stylerust-analyzer cargo git-delta 0.19.2 style/Style#, |
| 111 | decoration_style: ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::Stylerust-analyzer cargo nu-ansi-term 0.50.3 style/Style#, |
| 112 | ) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> { |
| 113 | let box_width = ansirust-analyzer cargo git-delta 0.19.2 ansi/::measure_text_widthrust-analyzer cargo git-delta 0.19.2 ansi/measure_text_width().(text); |
| 114 | write_boxed_with_horizontal_whiskerrust-analyzer cargo git-delta 0.19.2 handlers/draw/write_boxed_with_horizontal_whisker().( |
| 115 | writer, |
| 116 | text, |
| 117 | raw_text, |
| 118 | addendum, |
| 119 | box_width, |
| 120 | text_style, |
| 121 | decoration_style, |
| 122 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 123 | let line_width = match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().line_width { |
| 124 | Widthrust-analyzer cargo git-delta 0.19.2 cli/Width#::Fixedrust-analyzer cargo git-delta 0.19.2 cli/Width#Fixed#(n) => n, |
| 125 | Widthrust-analyzer cargo git-delta 0.19.2 cli/Width#::Variablerust-analyzer cargo git-delta 0.19.2 cli/Width#Variable# => box_width, |
| 126 | }; |
| 127 | write_horizontal_linerust-analyzer cargo git-delta 0.19.2 handlers/draw/write_horizontal_line().( |
| 128 | writer, |
| 129 | if line_width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().box_width { |
| 130 | line_width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().box_width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1 |
| 131 | } else { |
| 132 | 0 |
| 133 | }, |
| 134 | text_style, |
| 135 | decoration_style, |
| 136 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 137 | writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(writer)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 138 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 139 | } |
| 140 | |
| 141 | enum UnderOverlinerust-analyzer cargo git-delta 0.19.2 handlers/draw/UnderOverline# { |
| 142 | Underrust-analyzer cargo git-delta 0.19.2 handlers/draw/UnderOverline#Under#, |
| 143 | Overrust-analyzer cargo git-delta 0.19.2 handlers/draw/UnderOverline#Over#, |
| 144 | Underoverrust-analyzer cargo git-delta 0.19.2 handlers/draw/UnderOverline#Underover#, |
| 145 | } |
| 146 | |
| 147 | fn write_underlinedrust-analyzer cargo git-delta 0.19.2 handlers/draw/write_underlined().( |
| 148 | writer: &mut dyn Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, |
| 149 | text: &str, |
| 150 | raw_text: &str, |
| 151 | addendum: &str, |
| 152 | line_width: &Widthrust-analyzer cargo git-delta 0.19.2 cli/Width#, |
| 153 | text_style: Stylerust-analyzer cargo git-delta 0.19.2 style/Style#, |
| 154 | decoration_style: ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::Stylerust-analyzer cargo nu-ansi-term 0.50.3 style/Style#, |
| 155 | ) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> { |
| 156 | _write_under_or_over_linedrust-analyzer cargo git-delta 0.19.2 handlers/draw/_write_under_or_over_lined().( |
| 157 | UnderOverlinerust-analyzer cargo git-delta 0.19.2 handlers/draw/UnderOverline#::Underrust-analyzer cargo git-delta 0.19.2 handlers/draw/UnderOverline#Under#, |
| 158 | writer, |
| 159 | text, |
| 160 | raw_text, |
| 161 | addendum, |
| 162 | line_width, |
| 163 | text_style, |
| 164 | decoration_style, |
| 165 | ) |
| 166 | } |
| 167 | |
| 168 | fn write_overlinedrust-analyzer cargo git-delta 0.19.2 handlers/draw/write_overlined().( |
| 169 | writer: &mut dyn Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, |
| 170 | text: &str, |
| 171 | raw_text: &str, |
| 172 | addendum: &str, |
| 173 | line_width: &Widthrust-analyzer cargo git-delta 0.19.2 cli/Width#, |
| 174 | text_style: Stylerust-analyzer cargo git-delta 0.19.2 style/Style#, |
| 175 | decoration_style: ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::Stylerust-analyzer cargo nu-ansi-term 0.50.3 style/Style#, |
| 176 | ) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> { |
| 177 | _write_under_or_over_linedrust-analyzer cargo git-delta 0.19.2 handlers/draw/_write_under_or_over_lined().( |
| 178 | UnderOverlinerust-analyzer cargo git-delta 0.19.2 handlers/draw/UnderOverline#::Overrust-analyzer cargo git-delta 0.19.2 handlers/draw/UnderOverline#Over#, |
| 179 | writer, |
| 180 | text, |
| 181 | raw_text, |
| 182 | addendum, |
| 183 | line_width, |
| 184 | text_style, |
| 185 | decoration_style, |
| 186 | ) |
| 187 | } |
| 188 | |
| 189 | fn write_underoverlinedrust-analyzer cargo git-delta 0.19.2 handlers/draw/write_underoverlined().( |
| 190 | writer: &mut dyn Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, |
| 191 | text: &str, |
| 192 | raw_text: &str, |
| 193 | addendum: &str, |
| 194 | line_width: &Widthrust-analyzer cargo git-delta 0.19.2 cli/Width#, |
| 195 | text_style: Stylerust-analyzer cargo git-delta 0.19.2 style/Style#, |
| 196 | decoration_style: ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::Stylerust-analyzer cargo nu-ansi-term 0.50.3 style/Style#, |
| 197 | ) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> { |
| 198 | _write_under_or_over_linedrust-analyzer cargo git-delta 0.19.2 handlers/draw/_write_under_or_over_lined().( |
| 199 | UnderOverlinerust-analyzer cargo git-delta 0.19.2 handlers/draw/UnderOverline#::Underoverrust-analyzer cargo git-delta 0.19.2 handlers/draw/UnderOverline#Underover#, |
| 200 | writer, |
| 201 | text, |
| 202 | raw_text, |
| 203 | addendum, |
| 204 | line_width, |
| 205 | text_style, |
| 206 | decoration_style, |
| 207 | ) |
| 208 | } |
| 209 | |
| 210 | #[allow(clippy::too_many_arguments)] |
| 211 | fn _write_under_or_over_linedrust-analyzer cargo git-delta 0.19.2 handlers/draw/_write_under_or_over_lined().( |
| 212 | underoverline: UnderOverlinerust-analyzer cargo git-delta 0.19.2 handlers/draw/UnderOverline#, |
| 213 | writer: &mut dyn Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, |
| 214 | text: &str, |
| 215 | raw_text: &str, |
| 216 | addendum: &str, |
| 217 | line_width: &Widthrust-analyzer cargo git-delta 0.19.2 cli/Width#, |
| 218 | text_style: Stylerust-analyzer cargo git-delta 0.19.2 style/Style#, |
| 219 | decoration_style: ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::Stylerust-analyzer cargo nu-ansi-term 0.50.3 style/Style#, |
| 220 | ) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> { |
| 221 | let text_width = ansirust-analyzer cargo git-delta 0.19.2 ansi/::measure_text_widthrust-analyzer cargo git-delta 0.19.2 ansi/measure_text_width().(text); |
| 222 | let line_width = match *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().line_width { |
| 223 | Widthrust-analyzer cargo git-delta 0.19.2 cli/Width#::Fixedrust-analyzer cargo git-delta 0.19.2 cli/Width#Fixed#(n) => maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/max().(n, text_width), |
| 224 | Widthrust-analyzer cargo git-delta 0.19.2 cli/Width#::Variablerust-analyzer cargo git-delta 0.19.2 cli/Width#Variable# => text_width, |
| 225 | }; |
| 226 | let write_line = |writer: &mut dyn Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#| -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> { |
| 227 | write_horizontal_linerust-analyzer cargo git-delta 0.19.2 handlers/draw/write_horizontal_line().(writer, line_width, text_style, decoration_style)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 228 | writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(writer)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 229 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 230 | }; |
| 231 | match underoverline { |
| 232 | UnderOverlinerust-analyzer cargo git-delta 0.19.2 handlers/draw/UnderOverline#::Underrust-analyzer cargo git-delta 0.19.2 handlers/draw/UnderOverline#Under# => {} |
| 233 | _ => write_line(writer)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 234 | } |
| 235 | if text_style.is_rawrust-analyzer cargo git-delta 0.19.2 style/Style#is_raw. { |
| 236 | writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(writer, "{raw_text}")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 237 | } else { |
| 238 | writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(writer, "{}", paint_textrust-analyzer cargo git-delta 0.19.2 handlers/draw/paint_text().(text_style, text, addendum))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 239 | } |
| 240 | match underoverline { |
| 241 | UnderOverlinerust-analyzer cargo git-delta 0.19.2 handlers/draw/UnderOverline#::Overrust-analyzer cargo git-delta 0.19.2 handlers/draw/UnderOverline#Over# => {} |
| 242 | _ => write_line(writer)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 243 | } |
| 244 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 245 | } |
| 246 | |
| 247 | fn write_horizontal_linerust-analyzer cargo git-delta 0.19.2 handlers/draw/write_horizontal_line().( |
| 248 | writer: &mut dyn Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, |
| 249 | width: usize, |
| 250 | _text_style: Stylerust-analyzer cargo git-delta 0.19.2 style/Style#, |
| 251 | decoration_style: ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::Stylerust-analyzer cargo nu-ansi-term 0.50.3 style/Style#, |
| 252 | ) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> { |
| 253 | let horizontal = if decoration_style.is_boldrust-analyzer cargo nu-ansi-term 0.50.3 style/Style#is_bold. { |
| 254 | box_drawingrust-analyzer cargo box_drawing 0.1.2 crate/::heavyrust-analyzer cargo box_drawing 0.1.2 heavy/::HORIZONTALrust-analyzer cargo box_drawing 0.1.2 heavy/HORIZONTAL. |
| 255 | } else { |
| 256 | box_drawingrust-analyzer cargo box_drawing 0.1.2 crate/::lightrust-analyzer cargo box_drawing 0.1.2 light/::HORIZONTALrust-analyzer cargo box_drawing 0.1.2 light/HORIZONTAL. |
| 257 | }; |
| 258 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!( |
| 259 | writer, |
| 260 | "{}", |
| 261 | decoration_style.paintrust-analyzer cargo nu-ansi-term 0.50.3 display/impl#[Style]paint().(horizontal.repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(width)) |
| 262 | ) |
| 263 | } |
| 264 | |
| 265 | fn write_boxed_with_horizontal_whiskerrust-analyzer cargo git-delta 0.19.2 handlers/draw/write_boxed_with_horizontal_whisker().( |
| 266 | writer: &mut dyn Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, |
| 267 | text: &str, |
| 268 | raw_text: &str, |
| 269 | addendum: &str, |
| 270 | box_width: usize, |
| 271 | text_style: Stylerust-analyzer cargo git-delta 0.19.2 style/Style#, |
| 272 | decoration_style: ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::Stylerust-analyzer cargo nu-ansi-term 0.50.3 style/Style#, |
| 273 | ) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> { |
| 274 | let up_horizontal = if decoration_style.is_boldrust-analyzer cargo nu-ansi-term 0.50.3 style/Style#is_bold. { |
| 275 | box_drawingrust-analyzer cargo box_drawing 0.1.2 crate/::heavyrust-analyzer cargo box_drawing 0.1.2 heavy/::UP_HORIZONTALrust-analyzer cargo box_drawing 0.1.2 heavy/UP_HORIZONTAL. |
| 276 | } else { |
| 277 | box_drawingrust-analyzer cargo box_drawing 0.1.2 crate/::lightrust-analyzer cargo box_drawing 0.1.2 light/::UP_HORIZONTALrust-analyzer cargo box_drawing 0.1.2 light/UP_HORIZONTAL. |
| 278 | }; |
| 279 | write_boxed_partialrust-analyzer cargo git-delta 0.19.2 handlers/draw/write_boxed_partial().( |
| 280 | writer, |
| 281 | text, |
| 282 | raw_text, |
| 283 | addendum, |
| 284 | box_width, |
| 285 | text_style, |
| 286 | decoration_style, |
| 287 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 288 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(writer, "{}", decoration_style.paintrust-analyzer cargo nu-ansi-term 0.50.3 display/impl#[Style]paint().(up_horizontal))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 289 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 290 | } |
| 291 | |
| 292 | fn write_boxed_partialrust-analyzer cargo git-delta 0.19.2 handlers/draw/write_boxed_partial().( |
| 293 | writer: &mut dyn Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, |
| 294 | text: &str, |
| 295 | raw_text: &str, |
| 296 | addendum: &str, |
| 297 | box_width: usize, |
| 298 | text_style: Stylerust-analyzer cargo git-delta 0.19.2 style/Style#, |
| 299 | decoration_style: ansi_termrust-analyzer cargo nu-ansi-term 0.50.3 crate/::Stylerust-analyzer cargo nu-ansi-term 0.50.3 style/Style#, |
| 300 | ) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> { |
| 301 | let (horizontal, down_left, vertical) = if decoration_style.is_boldrust-analyzer cargo nu-ansi-term 0.50.3 style/Style#is_bold. { |
| 302 | ( |
| 303 | box_drawingrust-analyzer cargo box_drawing 0.1.2 crate/::heavyrust-analyzer cargo box_drawing 0.1.2 heavy/::HORIZONTALrust-analyzer cargo box_drawing 0.1.2 heavy/HORIZONTAL., |
| 304 | box_drawingrust-analyzer cargo box_drawing 0.1.2 crate/::heavyrust-analyzer cargo box_drawing 0.1.2 heavy/::DOWN_LEFTrust-analyzer cargo box_drawing 0.1.2 heavy/DOWN_LEFT., |
| 305 | box_drawingrust-analyzer cargo box_drawing 0.1.2 crate/::heavyrust-analyzer cargo box_drawing 0.1.2 heavy/::VERTICALrust-analyzer cargo box_drawing 0.1.2 heavy/VERTICAL., |
| 306 | ) |
| 307 | } else { |
| 308 | ( |
| 309 | box_drawingrust-analyzer cargo box_drawing 0.1.2 crate/::lightrust-analyzer cargo box_drawing 0.1.2 light/::HORIZONTALrust-analyzer cargo box_drawing 0.1.2 light/HORIZONTAL., |
| 310 | box_drawingrust-analyzer cargo box_drawing 0.1.2 crate/::lightrust-analyzer cargo box_drawing 0.1.2 light/::DOWN_LEFTrust-analyzer cargo box_drawing 0.1.2 light/DOWN_LEFT., |
| 311 | box_drawingrust-analyzer cargo box_drawing 0.1.2 crate/::lightrust-analyzer cargo box_drawing 0.1.2 light/::VERTICALrust-analyzer cargo box_drawing 0.1.2 light/VERTICAL., |
| 312 | ) |
| 313 | }; |
| 314 | let horizontal_edge = horizontal.repeatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]repeat().(box_width); |
| 315 | writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!( |
| 316 | writer, |
| 317 | "{}{}", |
| 318 | decoration_style.paintrust-analyzer cargo nu-ansi-term 0.50.3 display/impl#[Style]paint().(&horizontal_edge), |
| 319 | decoration_style.paintrust-analyzer cargo nu-ansi-term 0.50.3 display/impl#[Style]paint().(down_left), |
| 320 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 321 | if text_style.is_rawrust-analyzer cargo git-delta 0.19.2 style/Style#is_raw. { |
| 322 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(writer, "{raw_text}")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 323 | } else { |
| 324 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(writer, "{}", paint_textrust-analyzer cargo git-delta 0.19.2 handlers/draw/paint_text().(text_style, text, addendum))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 325 | } |
| 326 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!( |
| 327 | writer, |
| 328 | "{}\n{}", |
| 329 | decoration_style.paintrust-analyzer cargo nu-ansi-term 0.50.3 display/impl#[Style]paint().(vertical), |
| 330 | decoration_style.paintrust-analyzer cargo nu-ansi-term 0.50.3 display/impl#[Style]paint().(&horizontal_edge), |
| 331 | ) |
| 332 | } |