Debian Codegraph @

debian/patches/0x20251202~0a8dabc.patch

raw symbols SCIP
1 Description: use crate nu-ansi-term (not deprecated ansi-term)
2 Author: Jeremy Bícha <[email protected]>
3 Origin: upstream, https://github.com/dandavison/delta/pull/2067
4 Bug: https://github.com/dandavison/delta/pull/2067
5 Bug-Debian: https://bugs.debian.org/1135356
6 Last-Update: 2026-08-13
7 ---
8 This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
9 --- a/Cargo.toml
10 +++ b/Cargo.toml
11 @@ -16,7 +16,7 @@
12
13 [dependencies]
14 ansi_colours = "1.2.1"
15 -ansi_term = "0.12.1"
16 +ansi_term = { package = "nu-ansi-term", version = "0.50"}
17 anstyle-parse = "0.2.3"
18 anyhow = "1.0.70"
19 bat = { version = "0.26.0", default-features = false, features = [
20 --- a/src/ansi/iterator.rs
21 +++ b/src/ansi/iterator.rs
22 @@ -270,7 +270,7 @@
23 let r = u8::try_from(params.next()?).ok()?;
24 let g = u8::try_from(params.next()?).ok()?;
25 let b = u8::try_from(params.next()?).ok()?;
26 - Some(ansi_term::Color::RGB(r, g, b))
27 + Some(ansi_term::Color::Rgb(r, g, b))
28 }
29 Some(5) => Some(ansi_term::Color::Fixed(u8::try_from(params.next()?).ok()?)),
30 _ => None,
31 --- a/src/color.rs
32 +++ b/src/color.rs
33 @@ -41,17 +41,28 @@
34
35 pub fn color_to_string(color: Color) -> String {
36 match color {
37 + Color::Default => todo!(),
38 Color::Fixed(n) if n < 16 => ansi_16_color_number_to_name(n).unwrap().to_string(),
39 Color::Fixed(n) => format!("{n}"),
40 - Color::RGB(r, g, b) => format!("\"#{r:02x?}{g:02x?}{b:02x?}\""),
41 + Color::Rgb(r, g, b) => format!("\"#{r:02x?}{g:02x?}{b:02x?}\""),
42 Color::Black => "black".to_string(),
43 + Color::DarkGray => "bright-black".to_string(),
44 Color::Red => "red".to_string(),
45 + Color::LightRed => "bright-red".to_string(),
46 Color::Green => "green".to_string(),
47 + Color::LightGreen => "bright-green".to_string(),
48 Color::Yellow => "yellow".to_string(),
49 + Color::LightYellow => "bright-yellow".to_string(),
50 Color::Blue => "blue".to_string(),
51 + Color::LightBlue => "bright-blue".to_string(),
52 Color::Purple => "purple".to_string(),
53 + Color::LightPurple => "bright-purple".to_string(),
54 + Color::Magenta => "magenta".to_string(),
55 + Color::LightMagenta => "bright-magenta".to_string(),
56 Color::Cyan => "cyan".to_string(),
57 + Color::LightCyan => "bright-cyan".to_string(),
58 Color::White => "white".to_string(),
59 + Color::LightGray => "bright-white".to_string(),
60 }
61 }
62
63 @@ -153,35 +164,35 @@
64 }
65 }
66
67 -const LIGHT_THEME_MINUS_COLOR: Color = Color::RGB(0xff, 0xe0, 0xe0);
68 +const LIGHT_THEME_MINUS_COLOR: Color = Color::Rgb(0xff, 0xe0, 0xe0);
69
70 const LIGHT_THEME_MINUS_COLOR_256: Color = Color::Fixed(224);
71
72 -const LIGHT_THEME_MINUS_EMPH_COLOR: Color = Color::RGB(0xff, 0xc0, 0xc0);
73 +const LIGHT_THEME_MINUS_EMPH_COLOR: Color = Color::Rgb(0xff, 0xc0, 0xc0);
74
75 const LIGHT_THEME_MINUS_EMPH_COLOR_256: Color = Color::Fixed(217);
76
77 -const LIGHT_THEME_PLUS_COLOR: Color = Color::RGB(0xd0, 0xff, 0xd0);
78 +const LIGHT_THEME_PLUS_COLOR: Color = Color::Rgb(0xd0, 0xff, 0xd0);
79
80 const LIGHT_THEME_PLUS_COLOR_256: Color = Color::Fixed(194);
81
82 -const LIGHT_THEME_PLUS_EMPH_COLOR: Color = Color::RGB(0xa0, 0xef, 0xa0);
83 +const LIGHT_THEME_PLUS_EMPH_COLOR: Color = Color::Rgb(0xa0, 0xef, 0xa0);
84
85 const LIGHT_THEME_PLUS_EMPH_COLOR_256: Color = Color::Fixed(157);
86
87 -const DARK_THEME_MINUS_COLOR: Color = Color::RGB(0x3f, 0x00, 0x01);
88 +const DARK_THEME_MINUS_COLOR: Color = Color::Rgb(0x3f, 0x00, 0x01);
89
90 const DARK_THEME_MINUS_COLOR_256: Color = Color::Fixed(52);
91
92 -const DARK_THEME_MINUS_EMPH_COLOR: Color = Color::RGB(0x90, 0x10, 0x11);
93 +const DARK_THEME_MINUS_EMPH_COLOR: Color = Color::Rgb(0x90, 0x10, 0x11);
94
95 const DARK_THEME_MINUS_EMPH_COLOR_256: Color = Color::Fixed(124);
96
97 -const DARK_THEME_PLUS_COLOR: Color = Color::RGB(0x00, 0x28, 0x00);
98 +const DARK_THEME_PLUS_COLOR: Color = Color::Rgb(0x00, 0x28, 0x00);
99
100 const DARK_THEME_PLUS_COLOR_256: Color = Color::Fixed(22);
101
102 -const DARK_THEME_PLUS_EMPH_COLOR: Color = Color::RGB(0x00, 0x60, 0x00);
103 +const DARK_THEME_PLUS_EMPH_COLOR: Color = Color::Rgb(0x00, 0x60, 0x00);
104
105 const DARK_THEME_PLUS_EMPH_COLOR_256: Color = Color::Fixed(28);
106
107 --- a/src/features/line_numbers.rs
108 +++ b/src/features/line_numbers.rs
109 @@ -103,7 +103,7 @@
110 ))
111 }
112
113 -/// Return a vec of `ansi_term::ANSIGenericString`s representing the left and right fields of the
114 +/// Return a vec of `ansi_term::AnsiGenericString`s representing the left and right fields of the
115 /// two-column line number display.
116 pub fn format_and_paint_line_numbers<'a>(
117 line_numbers_data: &'a LineNumbersData,
118 @@ -111,7 +111,7 @@
119 styles: MinusPlus<Style>,
120 line_numbers: MinusPlus<Option<usize>>,
121 config: &'a config::Config,
122 -) -> Vec<ansi_term::ANSIGenericString<'a, str>> {
123 +) -> Vec<ansi_term::AnsiGenericString<'a, str>> {
124 let mut formatted_numbers = Vec::new();
125
126 let (emit_left, emit_right) = match (config.side_by_side, side_by_side_panel) {
127 @@ -247,7 +247,7 @@
128 styles: &MinusPlus<Style>,
129 line_numbers: &MinusPlus<Option<usize>>,
130 config: &config::Config,
131 -) -> Vec<ansi_term::ANSIGenericString<'a, str>> {
132 +) -> Vec<ansi_term::AnsiGenericString<'a, str>> {
133 let min_field_width = line_numbers_data.hunk_max_line_number_width;
134
135 let format_data = &line_numbers_data.format_data[side];
136 --- a/src/features/side_by_side.rs
137 +++ b/src/features/side_by_side.rs
138 @@ -229,7 +229,7 @@
139 output_buffer: &mut String,
140 config: &Config,
141 line_numbers_data: &mut Option<&mut line_numbers::LineNumbersData>,
142 - painted_prefix: Option<ansi_term::ANSIString>,
143 + painted_prefix: Option<ansi_term::AnsiString>,
144 background_color_extends_to_terminal_width: BgShouldFill,
145 ) {
146 let states = vec![State::HunkZero(DiffType::Unified, None)];
147 --- a/src/handlers/grep.rs
148 +++ b/src/handlers/grep.rs
149 @@ -412,7 +412,7 @@
150 .iter()
151 .map(|(ansi_term_style, s)| {
152 if ansi_term_style.is_bold
153 - && ansi_term_style.foreground == Some(ansi_term::Colour::Red)
154 + && ansi_term_style.foreground == Some(ansi_term::Color::Red)
155 {
156 (match_style, *s)
157 } else {
158 --- a/src/paint.rs
159 +++ b/src/paint.rs
160 @@ -2,7 +2,7 @@
161 use std::collections::HashMap;
162 use std::io::Write;
163
164 -use ansi_term::ANSIString;
165 +use ansi_term::AnsiString;
166 use itertools::Itertools;
167 use syntect::easy::HighlightLines;
168 use syntect::highlighting::Style as SyntectStyle;
169 @@ -372,7 +372,7 @@
170 /// Emit line with ANSI sequences that extend the background color to the terminal width.
171 pub fn right_fill_background_color(line: &mut String, fill_style: Style) {
172 // HACK: How to properly incorporate the ANSI_CSI_CLEAR_TO_EOL into ansi_strings?
173 - line.push_str(&ansi_term::ANSIStrings(&[fill_style.paint("")]).to_string());
174 + line.push_str(&ansi_term::AnsiStrings(&[fill_style.paint("")]).to_string());
175 if line
176 .to_lowercase()
177 .ends_with(&ansi::ANSI_SGR_RESET.to_lowercase())
178 @@ -404,7 +404,7 @@
179 state: &State,
180 line_numbers_data: &mut Option<&mut line_numbers::LineNumbersData>,
181 side_by_side_panel: Option<PanelSide>,
182 - mut painted_prefix: Option<ansi_term::ANSIString>,
183 + mut painted_prefix: Option<ansi_term::AnsiString>,
184 config: &config::Config,
185 ) -> (String, bool) {
186 let mut ansi_strings = Vec::new();
187 @@ -454,7 +454,7 @@
188
189 // Only if syntax is empty (implies diff empty) can a line actually be empty.
190 let is_empty = syntax_sections.is_empty();
191 - (ansi_term::ANSIStrings(&ansi_strings).to_string(), is_empty)
192 + (ansi_term::AnsiStrings(&ansi_strings).to_string(), is_empty)
193 }
194
195 /// Write output buffer to output stream, and clear the buffer.
196 @@ -777,7 +777,7 @@
197 (diff_sections, line_alignment)
198 }
199
200 -fn painted_prefix(state: State, config: &config::Config) -> Option<ANSIString<'_>> {
201 +fn painted_prefix(state: State, config: &config::Config) -> Option<AnsiString<'_>> {
202 use DiffType::*;
203 use State::*;
204 match (state, config.keep_plus_minus_markers) {
205 @@ -850,13 +850,13 @@
206 if let Some(line_number) = line_number {
207 if let Some(line_number_style) = line_number_style {
208 if !file_with_line_number.is_empty() {
209 - file_with_line_number.push(ansi_term::ANSIString::from(separator));
210 + file_with_line_number.push(ansi_term::AnsiString::from(separator));
211 }
212 file_with_line_number.push(line_number_style.paint(format!("{line_number}")))
213 }
214 }
215 if terminate_with_separator {
216 - file_with_line_number.push(ansi_term::ANSIGenericString::from(separator));
217 + file_with_line_number.push(ansi_term::AnsiGenericString::from(separator));
218 }
219 if pad_line_number {
220 // If requested we pad line numbers to a width of at least
221 @@ -866,15 +866,15 @@
222 // discussion about aligning grep output.
223 match line_number {
224 Some(n) if n < 10 => {
225 - file_with_line_number.push(ansi_term::ANSIGenericString::from(" "))
226 + file_with_line_number.push(ansi_term::AnsiGenericString::from(" "))
227 }
228 Some(n) if n < 100 => {
229 - file_with_line_number.push(ansi_term::ANSIGenericString::from(" "))
230 + file_with_line_number.push(ansi_term::AnsiGenericString::from(" "))
231 }
232 _ => {}
233 }
234 }
235 - let file_with_line_number = ansi_term::ANSIStrings(&file_with_line_number).to_string();
236 + let file_with_line_number = ansi_term::AnsiStrings(&file_with_line_number).to_string();
237 match if config.hyperlinks && !file_with_line_number.is_empty() {
238 utils::path::absolute_path(file_path, config)
239 } else {
240 --- a/src/style.rs
241 +++ b/src/style.rs
242 @@ -97,7 +97,7 @@
243 pub fn paint<'a, I, S: 'a + ToOwned + ?Sized>(
244 self,
245 input: I,
246 - ) -> ansi_term::ANSIGenericString<'a, S>
247 + ) -> ansi_term::AnsiGenericString<'a, S>
248 where
249 I: Into<Cow<'a, S>>,
250 <S as ToOwned>::Owned: fmt::Debug,
251 @@ -130,7 +130,7 @@
252 None
253 }
254
255 - pub fn to_painted_string(self) -> ansi_term::ANSIGenericString<'static, str> {
256 + pub fn to_painted_string(self) -> ansi_term::AnsiGenericString<'static, str> {
257 self.paint(self.to_string())
258 }
259 }
260 @@ -140,7 +140,7 @@
261 color_string: &'a str,
262 true_color: bool,
263 git_config: Option<&GitConfig>,
264 -) -> ansi_term::ANSIGenericString<'a, str> {
265 +) -> ansi_term::AnsiGenericString<'a, str> {
266 if let Some(color) = color::parse_color(color_string, true_color, git_config) {
267 let style = ansi_term::Style {
268 background: Some(color),
269 @@ -148,7 +148,7 @@
270 };
271 style.paint(color_string)
272 } else {
273 - ansi_term::ANSIGenericString::from(color_string)
274 + ansi_term::AnsiGenericString::from(color_string)
275 }
276 }
277
278 @@ -219,7 +219,7 @@
279
280 // TODO: The equality methods were implemented first, and the equality_key
281 // methods later. The former should be re-implemented in terms of the latter.
282 -// But why did the former not address equality of ansi_term::Color::RGB values?
283 +// But why did the former not address equality of ansi_term::Color::Rgb values?
284 #[derive(Clone)]
285 pub struct AnsiTermStyleEqualityKey {
286 attrs_key: (bool, bool, bool, bool, bool, bool, bool, bool),
287 @@ -321,6 +321,14 @@
288 | (ansi_term::Color::Fixed(5), ansi_term::Color::Purple)
289 | (ansi_term::Color::Fixed(6), ansi_term::Color::Cyan)
290 | (ansi_term::Color::Fixed(7), ansi_term::Color::White)
291 + | (ansi_term::Color::Fixed(8), ansi_term::Color::DarkGray)
292 + | (ansi_term::Color::Fixed(9), ansi_term::Color::LightRed)
293 + | (ansi_term::Color::Fixed(10), ansi_term::Color::LightGreen)
294 + | (ansi_term::Color::Fixed(11), ansi_term::Color::LightYellow)
295 + | (ansi_term::Color::Fixed(12), ansi_term::Color::LightBlue)
296 + | (ansi_term::Color::Fixed(13), ansi_term::Color::LightPurple)
297 + | (ansi_term::Color::Fixed(14), ansi_term::Color::LightCyan)
298 + | (ansi_term::Color::Fixed(15), ansi_term::Color::LightGray)
299 )
300 }
301
302 @@ -336,11 +344,34 @@
303 ansi_term::Color::Fixed(2) | ansi_term::Color::Green => (2, default, default, default),
304 ansi_term::Color::Fixed(3) | ansi_term::Color::Yellow => (3, default, default, default),
305 ansi_term::Color::Fixed(4) | ansi_term::Color::Blue => (4, default, default, default),
306 - ansi_term::Color::Fixed(5) | ansi_term::Color::Purple => (5, default, default, default),
307 + ansi_term::Color::Fixed(5) | ansi_term::Color::Purple | ansi_term::Color::Magenta => {
308 + (5, default, default, default)
309 + }
310 ansi_term::Color::Fixed(6) | ansi_term::Color::Cyan => (6, default, default, default),
311 ansi_term::Color::Fixed(7) | ansi_term::Color::White => (7, default, default, default),
312 + ansi_term::Color::Fixed(8) | ansi_term::Color::DarkGray => (8, default, default, default),
313 + ansi_term::Color::Fixed(9) | ansi_term::Color::LightRed => (9, default, default, default),
314 + ansi_term::Color::Fixed(10) | ansi_term::Color::LightGreen => {
315 + (10, default, default, default)
316 + }
317 + ansi_term::Color::Fixed(11) | ansi_term::Color::LightYellow => {
318 + (11, default, default, default)
319 + }
320 + ansi_term::Color::Fixed(12) | ansi_term::Color::LightBlue => {
321 + (12, default, default, default)
322 + }
323 + ansi_term::Color::Fixed(13)
324 + | ansi_term::Color::LightPurple
325 + | ansi_term::Color::LightMagenta => (13, default, default, default),
326 + ansi_term::Color::Fixed(14) | ansi_term::Color::LightCyan => {
327 + (14, default, default, default)
328 + }
329 + ansi_term::Color::Fixed(15) | ansi_term::Color::LightGray => {
330 + (15, default, default, default)
331 + }
332 ansi_term::Color::Fixed(n) => (n, default, default, default),
333 - ansi_term::Color::RGB(r, g, b) => (r, g, b, 0),
334 + ansi_term::Color::Rgb(r, g, b) => (r, g, b, 0),
335 + ansi_term::Color::Default => todo!(),
336 }
337 }
338
339 --- a/src/utils/bat/assets.rs
340 +++ b/src/utils/bat/assets.rs
341 @@ -3,7 +3,7 @@
342
343 use std::io::{self, Write};
344
345 -use ansi_term::Colour::Green;
346 +use ansi_term::Color::Green;
347 use ansi_term::Style;
348 use bat;
349
350 --- a/src/utils/bat/terminal.rs
351 +++ b/src/utils/bat/terminal.rs
352 @@ -1,4 +1,4 @@
353 -use ansi_term::Color::{self, Fixed, RGB};
354 +use ansi_term::Color::{self, Fixed, Rgb};
355 use ansi_term::{self, Style};
356
357 use syntect::highlighting::{self, FontStyle};
358 @@ -38,7 +38,7 @@
359 // 01. The built-in theme ansi uses this.
360 None
361 } else if true_color {
362 - Some(RGB(color.r, color.g, color.b))
363 + Some(Rgb(color.r, color.g, color.b))
364 } else {
365 Some(Fixed(ansi_colours::ansi256_from_rgb((
366 color.r, color.g, color.b,
367 --- a/src/utils/syntect.rs
368 +++ b/src/utils/syntect.rs
369 @@ -76,10 +76,21 @@
370 ansi_term::Color::Yellow => syntect_color_from_ansi_number(3).unwrap(),
371 ansi_term::Color::Blue => syntect_color_from_ansi_number(4).unwrap(),
372 ansi_term::Color::Purple => syntect_color_from_ansi_number(5).unwrap(),
373 + ansi_term::Color::Magenta => syntect_color_from_ansi_number(5).unwrap(),
374 ansi_term::Color::Cyan => syntect_color_from_ansi_number(6).unwrap(),
375 ansi_term::Color::White => syntect_color_from_ansi_number(7).unwrap(),
376 + ansi_term::Color::DarkGray => syntect_color_from_ansi_number(8).unwrap(),
377 + ansi_term::Color::LightRed => syntect_color_from_ansi_number(9).unwrap(),
378 + ansi_term::Color::LightGreen => syntect_color_from_ansi_number(10).unwrap(),
379 + ansi_term::Color::LightYellow => syntect_color_from_ansi_number(11).unwrap(),
380 + ansi_term::Color::LightBlue => syntect_color_from_ansi_number(12).unwrap(),
381 + ansi_term::Color::LightMagenta => syntect_color_from_ansi_number(13).unwrap(),
382 + ansi_term::Color::LightPurple => syntect_color_from_ansi_number(13).unwrap(),
383 + ansi_term::Color::LightCyan => syntect_color_from_ansi_number(14).unwrap(),
384 + ansi_term::Color::LightGray => syntect_color_from_ansi_number(15).unwrap(),
385 ansi_term::Color::Fixed(n) => syntect_color_from_ansi_number(n).unwrap(),
386 - ansi_term::Color::RGB(r, g, b) => Self { r, g, b, a: 0xFF },
387 + ansi_term::Color::Rgb(r, g, b) => Self { r, g, b, a: 0xFF },
388 + ansi_term::Color::Default => todo!(),
389 }
390 }
391 }