aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorKeith Simmons2021-06-25 03:58:15 +0000
committerGitHub2021-06-25 03:58:15 +0000
commit4418e17547562e211952b9e8585916e04b858b3b (patch)
tree8427958809392969b035967c1c69e9507207d00e /helix-term
parent74cc4b4a49e05462b2b543737ad4dc32e2265794 (diff)
reverse the dependency between helix-tui and helix-view (#366)
* reverse the dependency between helix-tui and helix-view by moving a fiew types to view * fix tests * clippy and format fixes Co-authored-by: Keith Simmons <keithsim@microsoft.com>
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/Cargo.toml4
-rw-r--r--helix-term/src/application.rs4
-rw-r--r--helix-term/src/commands.rs3
-rw-r--r--helix-term/src/compositor.rs3
-rw-r--r--helix-term/src/config.rs7
-rw-r--r--helix-term/src/keymap.rs7
-rw-r--r--helix-term/src/ui/completion.rs11
-rw-r--r--helix-term/src/ui/editor.rs17
-rw-r--r--helix-term/src/ui/markdown.rs12
-rw-r--r--helix-term/src/ui/menu.rs12
-rw-r--r--helix-term/src/ui/mod.rs8
-rw-r--r--helix-term/src/ui/picker.rs10
-rw-r--r--helix-term/src/ui/popup.rs11
-rw-r--r--helix-term/src/ui/prompt.rs16
-rw-r--r--helix-term/src/ui/text.rs11
15 files changed, 65 insertions, 71 deletions
diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml
index 385af64c..2334c34a 100644
--- a/helix-term/Cargo.toml
+++ b/helix-term/Cargo.toml
@@ -23,8 +23,8 @@ path = "src/main.rs"
[dependencies]
helix-core = { version = "0.2", path = "../helix-core" }
-helix-view = { version = "0.2", path = "../helix-view", features = ["term"]}
-helix-lsp = { version = "0.2", path = "../helix-lsp"}
+helix-view = { version = "0.2", path = "../helix-view" }
+helix-lsp = { version = "0.2", path = "../helix-lsp" }
anyhow = "1"
once_cell = "1.8"
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs
index f9c6c9c1..f33a5831 100644
--- a/helix-term/src/application.rs
+++ b/helix-term/src/application.rs
@@ -1,6 +1,6 @@
use helix_core::syntax;
use helix_lsp::{lsp, LspProgressMap};
-use helix_view::{document::Mode, theme, Document, Editor, Theme, View};
+use helix_view::{document::Mode, graphics::Rect, theme, Document, Editor, Theme, View};
use crate::{
args::Args,
@@ -29,8 +29,6 @@ use crossterm::{
execute, terminal,
};
-use tui::layout::Rect;
-
use futures_util::{future, stream::FuturesUnordered};
type BoxFuture<T> = Pin<Box<dyn Future<Output = T> + Send>>;
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index d99c840f..d98bda74 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -15,7 +15,8 @@ use helix_core::{
use helix_view::{
document::{IndentStyle, Mode},
- input::{KeyCode, KeyEvent},
+ input::KeyEvent,
+ keyboard::KeyCode,
view::{View, PADDING},
Document, DocumentId, Editor, ViewId,
};
diff --git a/helix-term/src/compositor.rs b/helix-term/src/compositor.rs
index b04d4588..cd0a12b5 100644
--- a/helix-term/src/compositor.rs
+++ b/helix-term/src/compositor.rs
@@ -3,9 +3,10 @@
// cursive does compositor.screen_mut().add_layer_at(pos::absolute(x, y), <component>)
use helix_core::Position;
use helix_lsp::LspProgressMap;
+use helix_view::graphics::{CursorKind, Rect};
use crossterm::event::Event;
-use tui::{buffer::Buffer as Surface, layout::Rect, terminal::CursorKind};
+use tui::buffer::Buffer as Surface;
pub type Callback = Box<dyn FnOnce(&mut Compositor)>;
diff --git a/helix-term/src/config.rs b/helix-term/src/config.rs
index 87d9e365..3c05144a 100644
--- a/helix-term/src/config.rs
+++ b/helix-term/src/config.rs
@@ -23,8 +23,11 @@ pub struct LspConfig {
#[test]
fn parsing_keymaps_config_file() {
use helix_core::hashmap;
- use helix_view::document::Mode;
- use helix_view::input::{KeyCode, KeyEvent, KeyModifiers};
+ use helix_view::{
+ document::Mode,
+ input::KeyEvent,
+ keyboard::{KeyCode, KeyModifiers},
+ };
let sample_keymaps = r#"
[keys.insert]
diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs
index b4c2055f..05869610 100644
--- a/helix-term/src/keymap.rs
+++ b/helix-term/src/keymap.rs
@@ -3,8 +3,11 @@ pub use crate::commands::Command;
use crate::config::Config;
use anyhow::{anyhow, Error, Result};
use helix_core::hashmap;
-use helix_view::document::Mode;
-use helix_view::input::{KeyCode, KeyEvent, KeyModifiers};
+use helix_view::{
+ document::Mode,
+ input::KeyEvent,
+ keyboard::{KeyCode, KeyModifiers},
+};
use serde::Deserialize;
use std::{
collections::HashMap,
diff --git a/helix-term/src/ui/completion.rs b/helix-term/src/ui/completion.rs
index 85543610..74a82dab 100644
--- a/helix-term/src/ui/completion.rs
+++ b/helix-term/src/ui/completion.rs
@@ -1,15 +1,14 @@
use crate::compositor::{Component, Compositor, Context, EventResult};
use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers};
-use tui::{
- buffer::Buffer as Surface,
- layout::Rect,
- style::{Color, Style},
-};
+use tui::buffer::Buffer as Surface;
use std::borrow::Cow;
use helix_core::{Position, Transaction};
-use helix_view::Editor;
+use helix_view::{
+ graphics::{Color, Rect, Style},
+ Editor,
+};
use crate::commands;
use crate::ui::{menu, Markdown, Menu, Popup, PromptEvent};
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 1c443bc7..93f000e7 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -12,21 +12,20 @@ use helix_core::{
LineEnding, Position, Range,
};
use helix_lsp::LspProgressMap;
-use helix_view::input::{KeyCode, KeyEvent, KeyModifiers};
-use helix_view::{document::Mode, Document, Editor, Theme, View};
+use helix_view::{
+ document::Mode,
+ graphics::{Color, CursorKind, Modifier, Rect, Style},
+ input::KeyEvent,
+ keyboard::{KeyCode, KeyModifiers},
+ Document, Editor, Theme, View,
+};
use std::borrow::Cow;
use crossterm::{
cursor,
event::{read, Event, EventStream},
};
-use tui::{
- backend::CrosstermBackend,
- buffer::Buffer as Surface,
- layout::Rect,
- style::{Color, Modifier, Style},
- terminal::CursorKind,
-};
+use tui::{backend::CrosstermBackend, buffer::Buffer as Surface};
pub struct EditorView {
keymaps: Keymaps,
diff --git a/helix-term/src/ui/markdown.rs b/helix-term/src/ui/markdown.rs
index 72a3e4ff..36d570cd 100644
--- a/helix-term/src/ui/markdown.rs
+++ b/helix-term/src/ui/markdown.rs
@@ -1,16 +1,14 @@
use crate::compositor::{Component, Compositor, Context, EventResult};
use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers};
-use tui::{
- buffer::Buffer as Surface,
- layout::Rect,
- style::{Color, Style},
- text::Text,
-};
+use tui::{buffer::Buffer as Surface, text::Text};
use std::{borrow::Cow, sync::Arc};
use helix_core::{syntax, Position};
-use helix_view::{Editor, Theme};
+use helix_view::{
+ graphics::{Color, Rect, Style},
+ Editor, Theme,
+};
pub struct Markdown {
contents: String,
diff --git a/helix-term/src/ui/menu.rs b/helix-term/src/ui/menu.rs
index 0a264f7c..f32ce01c 100644
--- a/helix-term/src/ui/menu.rs
+++ b/helix-term/src/ui/menu.rs
@@ -1,11 +1,6 @@
use crate::compositor::{Component, Compositor, Context, EventResult};
use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers};
-use tui::{
- buffer::Buffer as Surface,
- layout::Rect,
- style::{Color, Style},
- widgets::Table,
-};
+use tui::{buffer::Buffer as Surface, widgets::Table};
pub use tui::widgets::{Cell, Row};
@@ -15,7 +10,10 @@ use fuzzy_matcher::skim::SkimMatcherV2 as Matcher;
use fuzzy_matcher::FuzzyMatcher;
use helix_core::Position;
-use helix_view::Editor;
+use helix_view::{
+ graphics::{Color, Rect, Style},
+ Editor,
+};
pub trait Item {
// TODO: sort_text
diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs
index 29d555ac..14dc9169 100644
--- a/helix-term/src/ui/mod.rs
+++ b/helix-term/src/ui/mod.rs
@@ -18,12 +18,12 @@ pub use prompt::{Prompt, PromptEvent};
pub use spinner::{ProgressSpinners, Spinner};
pub use text::Text;
-pub use tui::layout::Rect;
-pub use tui::style::{Color, Modifier, Style};
-
use helix_core::regex::Regex;
use helix_core::register::Registers;
-use helix_view::{Document, Editor, View};
+use helix_view::{
+ graphics::{Color, Modifier, Rect, Style},
+ Document, Editor, View,
+};
use std::path::{Path, PathBuf};
diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs
index d1152659..15e6b062 100644
--- a/helix-term/src/ui/picker.rs
+++ b/helix-term/src/ui/picker.rs
@@ -2,8 +2,6 @@ use crate::compositor::{Component, Compositor, Context, EventResult};
use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers};
use tui::{
buffer::Buffer as Surface,
- layout::Rect,
- style::{Color, Style},
widgets::{Block, BorderType, Borders},
};
@@ -14,9 +12,11 @@ use std::borrow::Cow;
use crate::ui::{Prompt, PromptEvent};
use helix_core::Position;
-use helix_view::editor::Action;
-use helix_view::Editor;
-use tui::terminal::CursorKind;
+use helix_view::{
+ editor::Action,
+ graphics::{Color, CursorKind, Rect, Style},
+ Editor,
+};
pub struct Picker<T> {
options: Vec<T>,
diff --git a/helix-term/src/ui/popup.rs b/helix-term/src/ui/popup.rs
index 8488d1c6..af72735c 100644
--- a/helix-term/src/ui/popup.rs
+++ b/helix-term/src/ui/popup.rs
@@ -1,15 +1,14 @@
use crate::compositor::{Component, Compositor, Context, EventResult};
use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers};
-use tui::{
- buffer::Buffer as Surface,
- layout::Rect,
- style::{Color, Style},
-};
+use tui::buffer::Buffer as Surface;
use std::borrow::Cow;
use helix_core::Position;
-use helix_view::Editor;
+use helix_view::{
+ graphics::{Color, Rect, Style},
+ Editor,
+};
// TODO: share logic with Menu, it's essentially Popup(render_fn), but render fn needs to return
// a width/height hint. maybe Popup(Box<Component>)
diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs
index 63078c39..6bb1b006 100644
--- a/helix-term/src/ui/prompt.rs
+++ b/helix-term/src/ui/prompt.rs
@@ -1,14 +1,17 @@
use crate::compositor::{Component, Compositor, Context, EventResult};
use crate::ui;
use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers};
-use helix_core::Position;
-use helix_view::{Editor, Theme};
use std::{borrow::Cow, ops::RangeFrom};
-use tui::terminal::CursorKind;
+use tui::buffer::Buffer as Surface;
use helix_core::{
unicode::segmentation::{GraphemeCursor, GraphemeIncomplete},
unicode::width::UnicodeWidthStr,
+ Position,
+};
+use helix_view::{
+ graphics::{Color, CursorKind, Margin, Modifier, Rect, Style},
+ Editor, Theme,
};
pub type Completion = (RangeFrom<usize>, Cow<'static, str>);
@@ -251,12 +254,6 @@ impl Prompt {
}
}
-use tui::{
- buffer::Buffer as Surface,
- layout::Rect,
- style::{Color, Modifier, Style},
-};
-
const BASE_WIDTH: u16 = 30;
impl Prompt {
@@ -343,7 +340,6 @@ impl Prompt {
let background = theme.get("ui.help");
surface.clear_with(area, background);
- use tui::layout::Margin;
text.render(
area.inner(&Margin {
vertical: 1,
diff --git a/helix-term/src/ui/text.rs b/helix-term/src/ui/text.rs
index 6225e769..7c491841 100644
--- a/helix-term/src/ui/text.rs
+++ b/helix-term/src/ui/text.rs
@@ -1,15 +1,14 @@
use crate::compositor::{Component, Compositor, Context, EventResult};
use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers};
-use tui::{
- buffer::Buffer as Surface,
- layout::Rect,
- style::{Color, Style},
-};
+use tui::buffer::Buffer as Surface;
use std::borrow::Cow;
use helix_core::Position;
-use helix_view::Editor;
+use helix_view::{
+ graphics::{Color, Rect, Style},
+ Editor,
+};
pub struct Text {
contents: String,