on master help sign in
Apply suggestions from blaz for infobox
9effe71Ivan Tham
Cargo.lock−2
@@ -396,7 +396,6 @@ dependencies = [
396 "helix-view",
396 "helix-view",
397 "serde",
397 "serde",
398 "unicode-segmentation",
398 "unicode-segmentation",
399− "unicode-width",
400]
399]
401
400
402[[package]]
401[[package]]
@@ -419,7 +418,6 @@ dependencies = [
419 "slotmap",
418 "slotmap",
420 "tokio",
419 "tokio",
421 "toml",
420 "toml",
422− "unicode-width",
423 "url",
421 "url",
424 "which",
422 "which",
425]
423]
helix-term/src/ui/info.rs+1−5
@@ -11,11 +11,7 @@ impl Component for Info {
11 let (w, h) = (*width + 2, *height + 2);
11 let (w, h) = (*width + 2, *height + 2);
12 // -2 to subtract command line + statusline. a bit of a hack, because of splits.
12 // -2 to subtract command line + statusline. a bit of a hack, because of splits.
13 let area = Rect::new(viewport.width - w, viewport.height - h - 2, w, h);
13 let area = Rect::new(viewport.width - w, viewport.height - h - 2, w, h);
14− let margin = Margin {
15− vertical: 1,
16− horizontal: 1,
17− };
18− let Rect { x, y, .. } = area.inner(&margin);
14+ let Rect { x, y, .. } = block.inner(area);
19 for (y, line) in (y..).zip(self.text.lines()) {
15 for (y, line) in (y..).zip(self.text.lines()) {
20 surface.set_string(x, y, line, Style::default());
16 surface.set_string(x, y, line, Style::default());
21 }
17 }
helix-tui/Cargo.toml−1
@@ -19,7 +19,6 @@ default = ["crossterm"]
19bitflags = "1.0"
19bitflags = "1.0"
20cassowary = "0.3"
20cassowary = "0.3"
21unicode-segmentation = "1.2"
21unicode-segmentation = "1.2"
22−unicode-width = "0.1"
23crossterm = { version = "0.20", optional = true }
22crossterm = { version = "0.20", optional = true }
24serde = { version = "1", "optional" = true, features = ["derive"]}
23serde = { version = "1", "optional" = true, features = ["derive"]}
25helix-view = { version = "0.3", path = "../helix-view", features = ["term"] }
24helix-view = { version = "0.3", path = "../helix-view", features = ["term"] }
helix-tui/src/backend/test.rs+1−1
@@ -2,9 +2,9 @@ use crate::{
2 backend::Backend,
2 backend::Backend,
3 buffer::{Buffer, Cell},
3 buffer::{Buffer, Cell},
4};
4};
5+use helix_core::unicode::width::UnicodeWidthStr;
5use helix_view::graphics::{CursorKind, Rect};
6use helix_view::graphics::{CursorKind, Rect};
6use std::{fmt::Write, io};
7use std::{fmt::Write, io};
7−use unicode_width::UnicodeWidthStr;
8
8
9/// A backend used for the integration tests.
9/// A backend used for the integration tests.
10#[derive(Debug)]
10#[derive(Debug)]
helix-tui/src/buffer.rs+1−1
@@ -1,7 +1,7 @@
1use crate::text::{Span, Spans};
1use crate::text::{Span, Spans};
2+use helix_core::unicode::width::UnicodeWidthStr;
2use std::cmp::min;
3use std::cmp::min;
3use unicode_segmentation::UnicodeSegmentation;
4use unicode_segmentation::UnicodeSegmentation;
4−use unicode_width::UnicodeWidthStr;
5
5
6use helix_view::graphics::{Color, Modifier, Rect, Style};
6use helix_view::graphics::{Color, Modifier, Rect, Style};
7
7
helix-tui/src/text.rs+1−1
@@ -47,10 +47,10 @@
47//! ]);
47//! ]);
48//! ```
48//! ```
49use helix_core::line_ending::str_is_line_ending;
49use helix_core::line_ending::str_is_line_ending;
50+use helix_core::unicode::width::UnicodeWidthStr;
50use helix_view::graphics::Style;
51use helix_view::graphics::Style;
51use std::borrow::Cow;
52use std::borrow::Cow;
52use unicode_segmentation::UnicodeSegmentation;
53use unicode_segmentation::UnicodeSegmentation;
53−use unicode_width::UnicodeWidthStr;
54
54
55/// A grapheme associated to a style.
55/// A grapheme associated to a style.
56#[derive(Debug, Clone, PartialEq)]
56#[derive(Debug, Clone, PartialEq)]
helix-tui/src/widgets/paragraph.rs+1−1
@@ -7,9 +7,9 @@ use crate::{
7 Block, Widget,
7 Block, Widget,
8 },
8 },
9};
9};
10+use helix_core::unicode::width::UnicodeWidthStr;
10use helix_view::graphics::{Rect, Style};
11use helix_view::graphics::{Rect, Style};
11use std::iter;
12use std::iter;
12−use unicode_width::UnicodeWidthStr;
13
13
14fn get_line_offset(line_width: u16, text_area_width: u16, alignment: Alignment) -> u16 {
14fn get_line_offset(line_width: u16, text_area_width: u16, alignment: Alignment) -> u16 {
15 match alignment {
15 match alignment {
helix-tui/src/widgets/reflow.rs+1−1
@@ -1,7 +1,7 @@
1use crate::text::StyledGrapheme;
1use crate::text::StyledGrapheme;
2use helix_core::line_ending::str_is_line_ending;
2use helix_core::line_ending::str_is_line_ending;
3+use helix_core::unicode::width::UnicodeWidthStr;
3use unicode_segmentation::UnicodeSegmentation;
4use unicode_segmentation::UnicodeSegmentation;
4−use unicode_width::UnicodeWidthStr;
5
5
6const NBSP: &str = "\u{00a0}";
6const NBSP: &str = "\u{00a0}";
7
7
helix-tui/src/widgets/table.rs+1−1
@@ -9,9 +9,9 @@ use cassowary::{
9 WeightedRelation::*,
9 WeightedRelation::*,
10 {Expression, Solver},
10 {Expression, Solver},
11};
11};
12+use helix_core::unicode::width::UnicodeWidthStr;
12use helix_view::graphics::{Rect, Style};
13use helix_view::graphics::{Rect, Style};
13use std::collections::HashMap;
14use std::collections::HashMap;
14−use unicode_width::UnicodeWidthStr;
15
15
16/// A [`Cell`] contains the [`Text`] to be displayed in a [`Row`] of a [`Table`].
16/// A [`Cell`] contains the [`Text`] to be displayed in a [`Row`] of a [`Table`].
17///
17///
helix-view/Cargo.toml−1
@@ -31,7 +31,6 @@ slotmap = "1"
31
31
32encoding_rs = "0.8"
32encoding_rs = "0.8"
33chardetng = "0.1"
33chardetng = "0.1"
34−unicode-width = "0.1"
35
34
36serde = { version = "1.0", features = ["derive"] }
35serde = { version = "1.0", features = ["derive"] }
37toml = "0.5"
36toml = "0.5"
helix-view/src/info.rs+1−1
@@ -1,6 +1,6 @@
1use crate::input::KeyEvent;
1use crate::input::KeyEvent;
2+use helix_core::unicode::width::UnicodeWidthStr;
2use std::fmt::Write;
3use std::fmt::Write;
3−use unicode_width::UnicodeWidthStr;
4
4
5#[derive(Debug)]
5#[derive(Debug)]
6/// Info box used in editor. Rendering logic will be in other crate.
6/// Info box used in editor. Rendering logic will be in other crate.
helix-view/src/input.rs+3−2
@@ -1,5 +1,6 @@
1//! Input event handling, currently backed by crossterm.
1//! Input event handling, currently backed by crossterm.
2use anyhow::{anyhow, Error};
2use anyhow::{anyhow, Error};
3+use helix_core::unicode::width::UnicodeWidthStr;
3use serde::de::{self, Deserialize, Deserializer};
4use serde::de::{self, Deserialize, Deserializer};
4use std::fmt;
5use std::fmt;
5
6
@@ -90,9 +91,9 @@ impl fmt::Display for KeyEvent {
90 }
91 }
91}
92}
92
93
93−impl unicode_width::UnicodeWidthStr for KeyEvent {
94+impl UnicodeWidthStr for KeyEvent {
94 fn width(&self) -> usize {
95 fn width(&self) -> usize {
95− use unicode_width::UnicodeWidthChar;
96+ use helix_core::unicode::width::UnicodeWidthChar;
96 let mut width = match self.code {
97 let mut width = match self.code {
97 KeyCode::Backspace => keys::BACKSPACE.len(),
98 KeyCode::Backspace => keys::BACKSPACE.len(),
98 KeyCode::Enter => keys::ENTER.len(),
99 KeyCode::Enter => keys::ENTER.len(),