aboutsummaryrefslogtreecommitdiff
path: root/vendor/clap_builder/src/output/textwrap/wrap_algorithms.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
committerValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
commita990de90fe41456a23e58bd087d2f107d321f3a1 (patch)
tree15afc392522a9e85dc3332235e311b7d39352ea9 /vendor/clap_builder/src/output/textwrap/wrap_algorithms.rs
parent3d48cd3f81164bbfc1a755dc1d4a9a02f98c8ddd (diff)
downloadfparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.tar.xz
fparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.zip
Deleted vendor folder
Diffstat (limited to 'vendor/clap_builder/src/output/textwrap/wrap_algorithms.rs')
-rw-r--r--vendor/clap_builder/src/output/textwrap/wrap_algorithms.rs63
1 files changed, 0 insertions, 63 deletions
diff --git a/vendor/clap_builder/src/output/textwrap/wrap_algorithms.rs b/vendor/clap_builder/src/output/textwrap/wrap_algorithms.rs
deleted file mode 100644
index 34b4fd2..0000000
--- a/vendor/clap_builder/src/output/textwrap/wrap_algorithms.rs
+++ /dev/null
@@ -1,63 +0,0 @@
-use super::core::display_width;
-
-#[derive(Debug)]
-pub(crate) struct LineWrapper<'w> {
- hard_width: usize,
- line_width: usize,
- carryover: Option<&'w str>,
-}
-
-impl<'w> LineWrapper<'w> {
- pub(crate) fn new(hard_width: usize) -> Self {
- Self {
- hard_width,
- line_width: 0,
- carryover: None,
- }
- }
-
- pub(crate) fn reset(&mut self) {
- self.line_width = 0;
- self.carryover = None;
- }
-
- pub(crate) fn wrap(&mut self, mut words: Vec<&'w str>) -> Vec<&'w str> {
- if self.carryover.is_none() {
- if let Some(word) = words.first() {
- if word.trim().is_empty() {
- self.carryover = Some(*word);
- } else {
- self.carryover = Some("");
- }
- }
- }
-
- let mut i = 0;
- while i < words.len() {
- let word = &words[i];
- let trimmed = word.trim_end();
- let word_width = display_width(trimmed);
- let trimmed_delta = word.len() - trimmed.len();
- if i != 0 && self.hard_width < self.line_width + word_width {
- if 0 < i {
- let last = i - 1;
- let trimmed = words[last].trim_end();
- words[last] = trimmed;
- }
-
- self.line_width = 0;
- words.insert(i, "\n");
- i += 1;
- if let Some(carryover) = self.carryover {
- words.insert(i, carryover);
- self.line_width += carryover.len();
- i += 1;
- }
- }
- self.line_width += word_width + trimmed_delta;
-
- i += 1;
- }
- words
- }
-}