mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-22 09:26:19 +04:00
Apply suggestions from blaz for infobox
This commit is contained in:
parent
4c190ec9d9
commit
9effe71b7d
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -396,7 +396,6 @@ dependencies = [
|
||||
"helix-view",
|
||||
"serde",
|
||||
"unicode-segmentation",
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -419,7 +418,6 @@ dependencies = [
|
||||
"slotmap",
|
||||
"tokio",
|
||||
"toml",
|
||||
"unicode-width",
|
||||
"url",
|
||||
"which",
|
||||
]
|
||||
|
@ -11,11 +11,7 @@ fn render(&self, viewport: Rect, surface: &mut Surface, cx: &mut Context) {
|
||||
let (w, h) = (*width + 2, *height + 2);
|
||||
// -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 margin = Margin {
|
||||
vertical: 1,
|
||||
horizontal: 1,
|
||||
};
|
||||
let Rect { x, y, .. } = area.inner(&margin);
|
||||
let Rect { x, y, .. } = block.inner(area);
|
||||
for (y, line) in (y..).zip(self.text.lines()) {
|
||||
surface.set_string(x, y, line, Style::default());
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ default = ["crossterm"]
|
||||
bitflags = "1.0"
|
||||
cassowary = "0.3"
|
||||
unicode-segmentation = "1.2"
|
||||
unicode-width = "0.1"
|
||||
crossterm = { version = "0.20", optional = true }
|
||||
serde = { version = "1", "optional" = true, features = ["derive"]}
|
||||
helix-view = { version = "0.3", path = "../helix-view", features = ["term"] }
|
||||
|
@ -2,9 +2,9 @@
|
||||
backend::Backend,
|
||||
buffer::{Buffer, Cell},
|
||||
};
|
||||
use helix_core::unicode::width::UnicodeWidthStr;
|
||||
use helix_view::graphics::{CursorKind, Rect};
|
||||
use std::{fmt::Write, io};
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
/// A backend used for the integration tests.
|
||||
#[derive(Debug)]
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::text::{Span, Spans};
|
||||
use helix_core::unicode::width::UnicodeWidthStr;
|
||||
use std::cmp::min;
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
use helix_view::graphics::{Color, Modifier, Rect, Style};
|
||||
|
||||
|
@ -47,10 +47,10 @@
|
||||
//! ]);
|
||||
//! ```
|
||||
use helix_core::line_ending::str_is_line_ending;
|
||||
use helix_core::unicode::width::UnicodeWidthStr;
|
||||
use helix_view::graphics::Style;
|
||||
use std::borrow::Cow;
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
/// A grapheme associated to a style.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
|
@ -7,9 +7,9 @@
|
||||
Block, Widget,
|
||||
},
|
||||
};
|
||||
use helix_core::unicode::width::UnicodeWidthStr;
|
||||
use helix_view::graphics::{Rect, Style};
|
||||
use std::iter;
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
fn get_line_offset(line_width: u16, text_area_width: u16, alignment: Alignment) -> u16 {
|
||||
match alignment {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::text::StyledGrapheme;
|
||||
use helix_core::line_ending::str_is_line_ending;
|
||||
use helix_core::unicode::width::UnicodeWidthStr;
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
const NBSP: &str = "\u{00a0}";
|
||||
|
||||
|
@ -9,9 +9,9 @@
|
||||
WeightedRelation::*,
|
||||
{Expression, Solver},
|
||||
};
|
||||
use helix_core::unicode::width::UnicodeWidthStr;
|
||||
use helix_view::graphics::{Rect, Style};
|
||||
use std::collections::HashMap;
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
/// A [`Cell`] contains the [`Text`] to be displayed in a [`Row`] of a [`Table`].
|
||||
///
|
||||
|
@ -31,7 +31,6 @@ slotmap = "1"
|
||||
|
||||
encoding_rs = "0.8"
|
||||
chardetng = "0.1"
|
||||
unicode-width = "0.1"
|
||||
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
toml = "0.5"
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::input::KeyEvent;
|
||||
use helix_core::unicode::width::UnicodeWidthStr;
|
||||
use std::fmt::Write;
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
#[derive(Debug)]
|
||||
/// Info box used in editor. Rendering logic will be in other crate.
|
||||
|
@ -1,5 +1,6 @@
|
||||
//! Input event handling, currently backed by crossterm.
|
||||
use anyhow::{anyhow, Error};
|
||||
use helix_core::unicode::width::UnicodeWidthStr;
|
||||
use serde::de::{self, Deserialize, Deserializer};
|
||||
use std::fmt;
|
||||
|
||||
@ -90,9 +91,9 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
}
|
||||
}
|
||||
|
||||
impl unicode_width::UnicodeWidthStr for KeyEvent {
|
||||
impl UnicodeWidthStr for KeyEvent {
|
||||
fn width(&self) -> usize {
|
||||
use unicode_width::UnicodeWidthChar;
|
||||
use helix_core::unicode::width::UnicodeWidthChar;
|
||||
let mut width = match self.code {
|
||||
KeyCode::Backspace => keys::BACKSPACE.len(),
|
||||
KeyCode::Enter => keys::ENTER.len(),
|
||||
|
Loading…
Reference in New Issue
Block a user