Apply suggestions from blaz for infobox

pull/412/head
Ivan Tham 3 years ago committed by Blaž Hrastnik
parent 4c190ec9d9
commit 9effe71b7d

2
Cargo.lock generated

@ -396,7 +396,6 @@ dependencies = [
"helix-view", "helix-view",
"serde", "serde",
"unicode-segmentation", "unicode-segmentation",
"unicode-width",
] ]
[[package]] [[package]]
@ -419,7 +418,6 @@ dependencies = [
"slotmap", "slotmap",
"tokio", "tokio",
"toml", "toml",
"unicode-width",
"url", "url",
"which", "which",
] ]

@ -11,11 +11,7 @@ impl Component for Info {
let (w, h) = (*width + 2, *height + 2); let (w, h) = (*width + 2, *height + 2);
// -2 to subtract command line + statusline. a bit of a hack, because of splits. // -2 to subtract command line + statusline. a bit of a hack, because of splits.
let area = Rect::new(viewport.width - w, viewport.height - h - 2, w, h); let area = Rect::new(viewport.width - w, viewport.height - h - 2, w, h);
let margin = Margin { let Rect { x, y, .. } = block.inner(area);
vertical: 1,
horizontal: 1,
};
let Rect { x, y, .. } = area.inner(&margin);
for (y, line) in (y..).zip(self.text.lines()) { for (y, line) in (y..).zip(self.text.lines()) {
surface.set_string(x, y, line, Style::default()); surface.set_string(x, y, line, Style::default());
} }

@ -19,7 +19,6 @@ default = ["crossterm"]
bitflags = "1.0" bitflags = "1.0"
cassowary = "0.3" cassowary = "0.3"
unicode-segmentation = "1.2" unicode-segmentation = "1.2"
unicode-width = "0.1"
crossterm = { version = "0.20", optional = true } crossterm = { version = "0.20", optional = true }
serde = { version = "1", "optional" = true, features = ["derive"]} serde = { version = "1", "optional" = true, features = ["derive"]}
helix-view = { version = "0.3", path = "../helix-view", features = ["term"] } helix-view = { version = "0.3", path = "../helix-view", features = ["term"] }

@ -2,9 +2,9 @@ use crate::{
backend::Backend, backend::Backend,
buffer::{Buffer, Cell}, buffer::{Buffer, Cell},
}; };
use helix_core::unicode::width::UnicodeWidthStr;
use helix_view::graphics::{CursorKind, Rect}; use helix_view::graphics::{CursorKind, Rect};
use std::{fmt::Write, io}; use std::{fmt::Write, io};
use unicode_width::UnicodeWidthStr;
/// A backend used for the integration tests. /// A backend used for the integration tests.
#[derive(Debug)] #[derive(Debug)]

@ -1,7 +1,7 @@
use crate::text::{Span, Spans}; use crate::text::{Span, Spans};
use helix_core::unicode::width::UnicodeWidthStr;
use std::cmp::min; use std::cmp::min;
use unicode_segmentation::UnicodeSegmentation; use unicode_segmentation::UnicodeSegmentation;
use unicode_width::UnicodeWidthStr;
use helix_view::graphics::{Color, Modifier, Rect, Style}; use helix_view::graphics::{Color, Modifier, Rect, Style};

@ -47,10 +47,10 @@
//! ]); //! ]);
//! ``` //! ```
use helix_core::line_ending::str_is_line_ending; use helix_core::line_ending::str_is_line_ending;
use helix_core::unicode::width::UnicodeWidthStr;
use helix_view::graphics::Style; use helix_view::graphics::Style;
use std::borrow::Cow; use std::borrow::Cow;
use unicode_segmentation::UnicodeSegmentation; use unicode_segmentation::UnicodeSegmentation;
use unicode_width::UnicodeWidthStr;
/// A grapheme associated to a style. /// A grapheme associated to a style.
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]

@ -7,9 +7,9 @@ use crate::{
Block, Widget, Block, Widget,
}, },
}; };
use helix_core::unicode::width::UnicodeWidthStr;
use helix_view::graphics::{Rect, Style}; use helix_view::graphics::{Rect, Style};
use std::iter; use std::iter;
use unicode_width::UnicodeWidthStr;
fn get_line_offset(line_width: u16, text_area_width: u16, alignment: Alignment) -> u16 { fn get_line_offset(line_width: u16, text_area_width: u16, alignment: Alignment) -> u16 {
match alignment { match alignment {

@ -1,7 +1,7 @@
use crate::text::StyledGrapheme; use crate::text::StyledGrapheme;
use helix_core::line_ending::str_is_line_ending; use helix_core::line_ending::str_is_line_ending;
use helix_core::unicode::width::UnicodeWidthStr;
use unicode_segmentation::UnicodeSegmentation; use unicode_segmentation::UnicodeSegmentation;
use unicode_width::UnicodeWidthStr;
const NBSP: &str = "\u{00a0}"; const NBSP: &str = "\u{00a0}";

@ -9,9 +9,9 @@ use cassowary::{
WeightedRelation::*, WeightedRelation::*,
{Expression, Solver}, {Expression, Solver},
}; };
use helix_core::unicode::width::UnicodeWidthStr;
use helix_view::graphics::{Rect, Style}; use helix_view::graphics::{Rect, Style};
use std::collections::HashMap; use std::collections::HashMap;
use unicode_width::UnicodeWidthStr;
/// A [`Cell`] contains the [`Text`] to be displayed in a [`Row`] of a [`Table`]. /// A [`Cell`] contains the [`Text`] to be displayed in a [`Row`] of a [`Table`].
/// ///

@ -31,7 +31,6 @@ slotmap = "1"
encoding_rs = "0.8" encoding_rs = "0.8"
chardetng = "0.1" chardetng = "0.1"
unicode-width = "0.1"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
toml = "0.5" toml = "0.5"

@ -1,6 +1,6 @@
use crate::input::KeyEvent; use crate::input::KeyEvent;
use helix_core::unicode::width::UnicodeWidthStr;
use std::fmt::Write; use std::fmt::Write;
use unicode_width::UnicodeWidthStr;
#[derive(Debug)] #[derive(Debug)]
/// Info box used in editor. Rendering logic will be in other crate. /// Info box used in editor. Rendering logic will be in other crate.

@ -1,5 +1,6 @@
//! Input event handling, currently backed by crossterm. //! Input event handling, currently backed by crossterm.
use anyhow::{anyhow, Error}; use anyhow::{anyhow, Error};
use helix_core::unicode::width::UnicodeWidthStr;
use serde::de::{self, Deserialize, Deserializer}; use serde::de::{self, Deserialize, Deserializer};
use std::fmt; use std::fmt;
@ -90,9 +91,9 @@ impl fmt::Display for KeyEvent {
} }
} }
impl unicode_width::UnicodeWidthStr for KeyEvent { impl UnicodeWidthStr for KeyEvent {
fn width(&self) -> usize { fn width(&self) -> usize {
use unicode_width::UnicodeWidthChar; use helix_core::unicode::width::UnicodeWidthChar;
let mut width = match self.code { let mut width = match self.code {
KeyCode::Backspace => keys::BACKSPACE.len(), KeyCode::Backspace => keys::BACKSPACE.len(),
KeyCode::Enter => keys::ENTER.len(), KeyCode::Enter => keys::ENTER.len(),

Loading…
Cancel
Save