mirror of https://github.com/helix-editor/helix
Extract compositor & jobs into helix-view
parent
18381fcbc8
commit
11b8f068da
|
@ -827,6 +827,15 @@ dependencies = [
|
||||||
"which",
|
"which",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "helix-graphics"
|
||||||
|
version = "0.6.0"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"crossterm",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "helix-loader"
|
name = "helix-loader"
|
||||||
version = "0.6.0"
|
version = "0.6.0"
|
||||||
|
@ -906,7 +915,7 @@ dependencies = [
|
||||||
"cassowary",
|
"cassowary",
|
||||||
"crossterm",
|
"crossterm",
|
||||||
"helix-core",
|
"helix-core",
|
||||||
"helix-view",
|
"helix-graphics",
|
||||||
"serde",
|
"serde",
|
||||||
"unicode-segmentation",
|
"unicode-segmentation",
|
||||||
]
|
]
|
||||||
|
@ -937,7 +946,9 @@ dependencies = [
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"helix-core",
|
"helix-core",
|
||||||
"helix-dap",
|
"helix-dap",
|
||||||
|
"helix-graphics",
|
||||||
"helix-lsp",
|
"helix-lsp",
|
||||||
|
"helix-tui",
|
||||||
"log",
|
"log",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"serde",
|
"serde",
|
||||||
|
|
|
@ -4,6 +4,7 @@ members = [
|
||||||
"helix-view",
|
"helix-view",
|
||||||
"helix-term",
|
"helix-term",
|
||||||
"helix-tui",
|
"helix-tui",
|
||||||
|
"helix-graphics",
|
||||||
"helix-ui",
|
"helix-ui",
|
||||||
"helix-lsp",
|
"helix-lsp",
|
||||||
"helix-dap",
|
"helix-dap",
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
[package]
|
||||||
|
name = "helix-graphics"
|
||||||
|
version = "0.6.0"
|
||||||
|
authors = ["Blaž Hrastnik <blaz@mxxn.io>"]
|
||||||
|
edition = "2021"
|
||||||
|
license = "MPL-2.0"
|
||||||
|
repository = "https://github.com/helix-editor/helix"
|
||||||
|
homepage = "https://helix-editor.com"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/
|
||||||
|
|
||||||
|
[features]
|
||||||
|
term = ["crossterm"]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
bitflags = "1.3"
|
||||||
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
|
||||||
|
crossterm = { version = "0.23", optional = true }
|
||||||
|
|
||||||
|
# TODO: graphics.rs tests rely on this, but we should remove that
|
||||||
|
# [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
|
||||||
|
# helix-tui = { path = "../helix-tui" }
|
|
@ -15,13 +15,16 @@ use helix_view::{align_view, editor::ConfigEvent, graphics::Rect, theme, Align,
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
args::Args,
|
args::Args,
|
||||||
compositor::{Compositor, Event},
|
|
||||||
config::Config,
|
config::Config,
|
||||||
job::Jobs,
|
|
||||||
keymap::Keymaps,
|
keymap::Keymaps,
|
||||||
ui::{self, overlay::overlayed},
|
ui::{self, overlay::overlayed},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use helix_view::{
|
||||||
|
compositor::{Compositor, Event},
|
||||||
|
job::Jobs,
|
||||||
|
};
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
io::{stdin, stdout, Write},
|
io::{stdin, stdout, Write},
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
|
@ -233,7 +236,7 @@ impl Application {
|
||||||
|
|
||||||
// let area = *surface.area();
|
// let area = *surface.area();
|
||||||
|
|
||||||
let mut render_cx = crate::compositor::RenderContext {
|
let mut render_cx = helix_view::compositor::RenderContext {
|
||||||
editor: &self.editor,
|
editor: &self.editor,
|
||||||
surface,
|
surface,
|
||||||
scroll: None,
|
scroll: None,
|
||||||
|
@ -384,13 +387,13 @@ impl Application {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_idle_timeout(&mut self) {
|
pub fn handle_idle_timeout(&mut self) {
|
||||||
use crate::compositor::EventResult;
|
use helix_view::compositor::EventResult;
|
||||||
let editor_view = self
|
let editor_view = self
|
||||||
.compositor
|
.compositor
|
||||||
.find::<ui::EditorView>()
|
.find::<ui::EditorView>()
|
||||||
.expect("expected at least one EditorView");
|
.expect("expected at least one EditorView");
|
||||||
|
|
||||||
let mut cx = crate::compositor::Context {
|
let mut cx = helix_view::compositor::Context {
|
||||||
editor: &mut self.editor,
|
editor: &mut self.editor,
|
||||||
jobs: &mut self.jobs,
|
jobs: &mut self.jobs,
|
||||||
};
|
};
|
||||||
|
@ -403,7 +406,7 @@ impl Application {
|
||||||
&mut self,
|
&mut self,
|
||||||
event: Option<Result<CrosstermEvent, crossterm::ErrorKind>>,
|
event: Option<Result<CrosstermEvent, crossterm::ErrorKind>>,
|
||||||
) {
|
) {
|
||||||
let mut cx = crate::compositor::Context {
|
let mut cx = helix_view::compositor::Context {
|
||||||
editor: &mut self.editor,
|
editor: &mut self.editor,
|
||||||
jobs: &mut self.jobs,
|
jobs: &mut self.jobs,
|
||||||
};
|
};
|
||||||
|
|
|
@ -40,6 +40,11 @@ use helix_view::{
|
||||||
Document, DocumentId, Editor, ViewId,
|
Document, DocumentId, Editor, ViewId,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use helix_view::{
|
||||||
|
compositor::{self, Component, Compositor},
|
||||||
|
job::{self, Job, Jobs},
|
||||||
|
};
|
||||||
|
|
||||||
use anyhow::{anyhow, bail, ensure, Context as _};
|
use anyhow::{anyhow, bail, ensure, Context as _};
|
||||||
use fuzzy_matcher::FuzzyMatcher;
|
use fuzzy_matcher::FuzzyMatcher;
|
||||||
use insert::*;
|
use insert::*;
|
||||||
|
@ -47,11 +52,9 @@ use movement::Movement;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
args,
|
args,
|
||||||
compositor::{self, Component, Compositor},
|
|
||||||
ui::{self, overlay::overlayed, FilePicker, Picker, Popup, Prompt, PromptEvent},
|
ui::{self, overlay::overlayed, FilePicker, Picker, Popup, Prompt, PromptEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::job::{self, Job, Jobs};
|
|
||||||
use futures_util::{FutureExt, StreamExt};
|
use futures_util::{FutureExt, StreamExt};
|
||||||
use std::{collections::HashMap, fmt, future::Future};
|
use std::{collections::HashMap, fmt, future::Future};
|
||||||
use std::{collections::HashSet, num::NonZeroUsize};
|
use std::{collections::HashSet, num::NonZeroUsize};
|
||||||
|
@ -74,7 +77,7 @@ pub struct Context<'a> {
|
||||||
pub count: Option<NonZeroUsize>,
|
pub count: Option<NonZeroUsize>,
|
||||||
pub editor: &'a mut Editor,
|
pub editor: &'a mut Editor,
|
||||||
|
|
||||||
pub callback: Option<crate::compositor::Callback>,
|
pub callback: Option<helix_view::compositor::Callback>,
|
||||||
pub on_next_key_callback: Option<Box<dyn FnOnce(&mut Context, KeyEvent)>>,
|
pub on_next_key_callback: Option<Box<dyn FnOnce(&mut Context, KeyEvent)>>,
|
||||||
pub jobs: &'a mut Jobs,
|
pub jobs: &'a mut Jobs,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
use super::{Context, Editor};
|
use super::{Context, Editor};
|
||||||
use crate::{
|
use crate::ui::{self, overlay::overlayed, FilePicker, Picker, Popup, Prompt, PromptEvent, Text};
|
||||||
compositor::{self, Compositor},
|
|
||||||
job::{Callback, Jobs},
|
|
||||||
ui::{self, overlay::overlayed, FilePicker, Picker, Popup, Prompt, PromptEvent, Text},
|
|
||||||
};
|
|
||||||
use helix_core::syntax::{DebugArgumentValue, DebugConfigCompletion};
|
use helix_core::syntax::{DebugArgumentValue, DebugConfigCompletion};
|
||||||
use helix_dap::{self as dap, Client};
|
use helix_dap::{self as dap, Client};
|
||||||
use helix_lsp::block_on;
|
use helix_lsp::block_on;
|
||||||
use helix_view::editor::Breakpoint;
|
use helix_view::editor::Breakpoint;
|
||||||
|
use helix_view::{
|
||||||
|
compositor::{self, Compositor},
|
||||||
|
job::{Callback, Jobs},
|
||||||
|
};
|
||||||
|
|
||||||
use serde_json::{to_value, Value};
|
use serde_json::{to_value, Value};
|
||||||
use tokio_stream::wrappers::UnboundedReceiverStream;
|
use tokio_stream::wrappers::UnboundedReceiverStream;
|
||||||
|
|
|
@ -9,10 +9,8 @@ use super::{align_view, push_jump, Align, Context, Editor};
|
||||||
use helix_core::Selection;
|
use helix_core::Selection;
|
||||||
use helix_view::editor::Action;
|
use helix_view::editor::Action;
|
||||||
|
|
||||||
use crate::{
|
use crate::ui::{self, overlay::overlayed, FileLocation, FilePicker, Popup, PromptEvent};
|
||||||
compositor::{self, Compositor},
|
use helix_view::compositor::{self, Compositor};
|
||||||
ui::{self, overlay::overlayed, FileLocation, FilePicker, Popup, PromptEvent},
|
|
||||||
};
|
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,8 @@ extern crate helix_view;
|
||||||
pub mod application;
|
pub mod application;
|
||||||
pub mod args;
|
pub mod args;
|
||||||
pub mod commands;
|
pub mod commands;
|
||||||
pub mod compositor;
|
|
||||||
pub mod config;
|
pub mod config;
|
||||||
pub mod health;
|
pub mod health;
|
||||||
pub mod job;
|
|
||||||
pub mod keymap;
|
pub mod keymap;
|
||||||
pub mod ui;
|
pub mod ui;
|
||||||
pub use keymap::macros::*;
|
pub use keymap::macros::*;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::compositor::{Component, Context, Event, EventResult, RenderContext};
|
use helix_view::compositor::{Component, Context, Event, EventResult, RenderContext};
|
||||||
use helix_view::editor::CompleteAction;
|
use helix_view::editor::CompleteAction;
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
commands,
|
commands, key,
|
||||||
compositor::{Component, Context, Event, EventResult, RenderContext},
|
|
||||||
key,
|
|
||||||
keymap::{KeymapResult, Keymaps},
|
keymap::{KeymapResult, Keymaps},
|
||||||
ui::{Completion, ProgressSpinners},
|
ui::{Completion, ProgressSpinners},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use helix_view::compositor::{Component, Context, Event, EventResult, RenderContext};
|
||||||
|
|
||||||
use helix_core::{
|
use helix_core::{
|
||||||
coords_at_pos, encoding,
|
coords_at_pos, encoding,
|
||||||
graphemes::{
|
graphemes::{
|
||||||
|
@ -928,7 +928,7 @@ impl EditorView {
|
||||||
editor.clear_idle_timer(); // don't retrigger
|
editor.clear_idle_timer(); // don't retrigger
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_idle_timeout(&mut self, cx: &mut crate::compositor::Context) -> EventResult {
|
pub fn handle_idle_timeout(&mut self, cx: &mut helix_view::compositor::Context) -> EventResult {
|
||||||
if self.completion.is_some()
|
if self.completion.is_some()
|
||||||
|| !cx.editor.config().auto_completion
|
|| !cx.editor.config().auto_completion
|
||||||
|| doc!(cx.editor).mode != Mode::Insert
|
|| doc!(cx.editor).mode != Mode::Insert
|
||||||
|
@ -1163,7 +1163,7 @@ impl Component for EditorView {
|
||||||
fn handle_event(
|
fn handle_event(
|
||||||
&mut self,
|
&mut self,
|
||||||
event: Event,
|
event: Event,
|
||||||
context: &mut crate::compositor::Context,
|
context: &mut helix_view::compositor::Context,
|
||||||
) -> EventResult {
|
) -> EventResult {
|
||||||
let mut cx = commands::Context {
|
let mut cx = commands::Context {
|
||||||
editor: context.editor,
|
editor: context.editor,
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
use crate::compositor::{Component, RenderContext};
|
|
||||||
use helix_view::graphics::{Margin, Rect};
|
|
||||||
use helix_view::info::Info;
|
|
||||||
use tui::widgets::{Block, Borders, Paragraph, Widget};
|
|
||||||
|
|
||||||
impl Component for Info {
|
|
||||||
fn render(&mut self, viewport: Rect, cx: &mut RenderContext<'_>) {
|
|
||||||
let text_style = cx.editor.theme.get("ui.text.info");
|
|
||||||
let popup_style = cx.editor.theme.get("ui.popup.info");
|
|
||||||
|
|
||||||
// Calculate the area of the terminal to modify. Because we want to
|
|
||||||
// render at the bottom right, we use the viewport's width and height
|
|
||||||
// which evaluate to the most bottom right coordinate.
|
|
||||||
let width = self.width + 2 + 2; // +2 for border, +2 for margin
|
|
||||||
let height = self.height + 2; // +2 for border
|
|
||||||
let area = viewport.intersection(Rect::new(
|
|
||||||
viewport.width.saturating_sub(width),
|
|
||||||
viewport.height.saturating_sub(height + 2), // +2 for statusline
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
));
|
|
||||||
cx.surface.clear_with(area, popup_style);
|
|
||||||
|
|
||||||
let block = Block::default()
|
|
||||||
.title(self.title.as_str())
|
|
||||||
.borders(Borders::ALL)
|
|
||||||
.border_style(popup_style);
|
|
||||||
|
|
||||||
let margin = Margin {
|
|
||||||
vertical: 0,
|
|
||||||
horizontal: 1,
|
|
||||||
};
|
|
||||||
let inner = block.inner(area).inner(&margin);
|
|
||||||
block.render(area, cx.surface);
|
|
||||||
|
|
||||||
Paragraph::new(self.text.as_str())
|
|
||||||
.style(text_style)
|
|
||||||
.render(inner, cx.surface);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::compositor::{Component, RenderContext};
|
use helix_view::compositor::{Component, RenderContext};
|
||||||
use tui::text::{Span, Spans, Text};
|
use tui::text::{Span, Spans, Text};
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{
|
use crate::{ctrl, key, shift};
|
||||||
compositor::{Callback, Component, Compositor, Context, Event, EventResult, RenderContext},
|
use helix_view::compositor::{
|
||||||
ctrl, key, shift,
|
Callback, Component, Compositor, Context, Event, EventResult, RenderContext,
|
||||||
};
|
};
|
||||||
use tui::widgets::Table;
|
use tui::widgets::Table;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
mod completion;
|
mod completion;
|
||||||
pub(crate) mod editor;
|
pub(crate) mod editor;
|
||||||
mod info;
|
|
||||||
mod markdown;
|
mod markdown;
|
||||||
pub mod menu;
|
pub mod menu;
|
||||||
pub mod overlay;
|
pub mod overlay;
|
||||||
|
@ -31,7 +30,7 @@ pub fn prompt(
|
||||||
prompt: std::borrow::Cow<'static, str>,
|
prompt: std::borrow::Cow<'static, str>,
|
||||||
history_register: Option<char>,
|
history_register: Option<char>,
|
||||||
completion_fn: impl FnMut(&Editor, &str) -> Vec<prompt::Completion> + 'static,
|
completion_fn: impl FnMut(&Editor, &str) -> Vec<prompt::Completion> + 'static,
|
||||||
callback_fn: impl FnMut(&mut crate::compositor::Context, &str, PromptEvent) + 'static,
|
callback_fn: impl FnMut(&mut helix_view::compositor::Context, &str, PromptEvent) + 'static,
|
||||||
) {
|
) {
|
||||||
let mut prompt = Prompt::new(prompt, history_register, completion_fn, callback_fn);
|
let mut prompt = Prompt::new(prompt, history_register, completion_fn, callback_fn);
|
||||||
// Calculate initial completion
|
// Calculate initial completion
|
||||||
|
@ -56,7 +55,7 @@ pub fn regex_prompt(
|
||||||
prompt,
|
prompt,
|
||||||
history_register,
|
history_register,
|
||||||
completion_fn,
|
completion_fn,
|
||||||
move |cx: &mut crate::compositor::Context, input: &str, event: PromptEvent| {
|
move |cx: &mut helix_view::compositor::Context, input: &str, event: PromptEvent| {
|
||||||
match event {
|
match event {
|
||||||
PromptEvent::Abort => {
|
PromptEvent::Abort => {
|
||||||
let (view, doc) = current!(cx.editor);
|
let (view, doc) = current!(cx.editor);
|
||||||
|
|
|
@ -4,7 +4,7 @@ use helix_view::{
|
||||||
Editor,
|
Editor,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::compositor::{Component, Context, Event, EventResult, RenderContext};
|
use helix_view::compositor::{Component, Context, Event, EventResult, RenderContext};
|
||||||
|
|
||||||
/// Contains a component placed in the center of the parent component
|
/// Contains a component placed in the center of the parent component
|
||||||
pub struct Overlay<T> {
|
pub struct Overlay<T> {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
compositor::{Component, Compositor, Context, Event, EventResult, RenderContext},
|
|
||||||
ctrl, key, shift,
|
ctrl, key, shift,
|
||||||
ui::{self, EditorView},
|
ui::{self, EditorView},
|
||||||
};
|
};
|
||||||
|
use helix_view::compositor::{Component, Compositor, Context, Event, EventResult, RenderContext};
|
||||||
use tui::widgets::{Block, BorderType, Borders};
|
use tui::widgets::{Block, BorderType, Borders};
|
||||||
|
|
||||||
use fuzzy_matcher::skim::SkimMatcherV2 as Matcher;
|
use fuzzy_matcher::skim::SkimMatcherV2 as Matcher;
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
use crate::{
|
use crate::{ctrl, key};
|
||||||
compositor::{Callback, Component, Context, Event, EventResult, RenderContext},
|
use helix_view::compositor::{Callback, Component, Context, Event, EventResult, RenderContext};
|
||||||
ctrl, key,
|
|
||||||
};
|
|
||||||
|
|
||||||
use helix_core::Position;
|
use helix_core::Position;
|
||||||
use helix_view::{
|
use helix_view::{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::compositor::{Component, Compositor, Context, Event, EventResult, RenderContext};
|
use helix_view::compositor::{Component, Compositor, Context, Event, EventResult, RenderContext};
|
||||||
use crate::{alt, ctrl, key, shift, ui};
|
use crate::{alt, ctrl, key, shift, ui};
|
||||||
use helix_view::input::KeyEvent;
|
use helix_view::input::KeyEvent;
|
||||||
use helix_view::keyboard::KeyCode;
|
use helix_view::keyboard::KeyCode;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::compositor::{Component, RenderContext};
|
use helix_view::compositor::{Component, RenderContext};
|
||||||
|
|
||||||
use helix_view::graphics::Rect;
|
use helix_view::graphics::Rect;
|
||||||
|
|
||||||
|
|
|
@ -21,5 +21,5 @@ cassowary = "0.3"
|
||||||
unicode-segmentation = "1.9"
|
unicode-segmentation = "1.9"
|
||||||
crossterm = { version = "0.23", optional = true }
|
crossterm = { version = "0.23", optional = true }
|
||||||
serde = { version = "1", "optional" = true, features = ["derive"]}
|
serde = { version = "1", "optional" = true, features = ["derive"]}
|
||||||
helix-view = { version = "0.6", path = "../helix-view", features = ["term"] }
|
helix-graphics = { version = "0.6", path = "../helix-graphics", features = ["term"] }
|
||||||
helix-core = { version = "0.6", path = "../helix-core" }
|
helix-core = { version = "0.6", path = "../helix-core" }
|
||||||
|
|
|
@ -8,7 +8,7 @@ use crossterm::{
|
||||||
},
|
},
|
||||||
terminal::{self, Clear, ClearType},
|
terminal::{self, Clear, ClearType},
|
||||||
};
|
};
|
||||||
use helix_view::graphics::{Color, CursorKind, Modifier, Rect};
|
use helix_graphics::{Color, CursorKind, Modifier, Rect};
|
||||||
use std::io::{self, Write};
|
use std::io::{self, Write};
|
||||||
|
|
||||||
pub struct CrosstermBackend<W: Write> {
|
pub struct CrosstermBackend<W: Write> {
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::io;
|
||||||
|
|
||||||
use crate::buffer::Cell;
|
use crate::buffer::Cell;
|
||||||
|
|
||||||
use helix_view::graphics::{CursorKind, Rect};
|
use helix_graphics::{CursorKind, Rect};
|
||||||
|
|
||||||
#[cfg(feature = "crossterm")]
|
#[cfg(feature = "crossterm")]
|
||||||
mod crossterm;
|
mod crossterm;
|
||||||
|
|
|
@ -3,7 +3,7 @@ use crate::{
|
||||||
buffer::{Buffer, Cell},
|
buffer::{Buffer, Cell},
|
||||||
};
|
};
|
||||||
use helix_core::unicode::width::UnicodeWidthStr;
|
use helix_core::unicode::width::UnicodeWidthStr;
|
||||||
use helix_view::graphics::{CursorKind, Rect};
|
use helix_graphics::{CursorKind, Rect};
|
||||||
use std::{fmt::Write, io};
|
use std::{fmt::Write, io};
|
||||||
|
|
||||||
/// A backend used for the integration tests.
|
/// A backend used for the integration tests.
|
||||||
|
|
|
@ -3,7 +3,7 @@ use helix_core::unicode::width::UnicodeWidthStr;
|
||||||
use std::cmp::min;
|
use std::cmp::min;
|
||||||
use unicode_segmentation::UnicodeSegmentation;
|
use unicode_segmentation::UnicodeSegmentation;
|
||||||
|
|
||||||
use helix_view::graphics::{Color, Modifier, Rect, Style};
|
use helix_graphics::{Color, Modifier, Rect, Style};
|
||||||
|
|
||||||
/// A buffer cell
|
/// A buffer cell
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
@ -87,7 +87,7 @@ impl Default for Cell {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use helix_tui::buffer::{Buffer, Cell};
|
/// use helix_tui::buffer::{Buffer, Cell};
|
||||||
/// use helix_view::graphics::{Rect, Color, Style, Modifier};
|
/// use helix_graphics::{Rect, Color, Style, Modifier};
|
||||||
///
|
///
|
||||||
/// let mut buf = Buffer::empty(Rect{x: 0, y: 0, width: 10, height: 5});
|
/// let mut buf = Buffer::empty(Rect{x: 0, y: 0, width: 10, height: 5});
|
||||||
/// buf[(0, 2)].set_symbol("x");
|
/// buf[(0, 2)].set_symbol("x");
|
||||||
|
@ -179,7 +179,7 @@ impl Buffer {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use helix_tui::buffer::Buffer;
|
/// # use helix_tui::buffer::Buffer;
|
||||||
/// # use helix_view::graphics::Rect;
|
/// # use helix_graphics::Rect;
|
||||||
/// let rect = Rect::new(200, 100, 10, 10);
|
/// let rect = Rect::new(200, 100, 10, 10);
|
||||||
/// let buffer = Buffer::empty(rect);
|
/// let buffer = Buffer::empty(rect);
|
||||||
/// // Global coordinates inside the Buffer's area
|
/// // Global coordinates inside the Buffer's area
|
||||||
|
@ -204,7 +204,7 @@ impl Buffer {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use helix_tui::buffer::Buffer;
|
/// # use helix_tui::buffer::Buffer;
|
||||||
/// # use helix_view::graphics::Rect;
|
/// # use helix_graphics::Rect;
|
||||||
/// let rect = Rect::new(200, 100, 10, 10);
|
/// let rect = Rect::new(200, 100, 10, 10);
|
||||||
/// let buffer = Buffer::empty(rect);
|
/// let buffer = Buffer::empty(rect);
|
||||||
/// // Global coordinates to the top corner of this Buffer's area
|
/// // Global coordinates to the top corner of this Buffer's area
|
||||||
|
@ -243,7 +243,7 @@ impl Buffer {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use helix_tui::buffer::Buffer;
|
/// # use helix_tui::buffer::Buffer;
|
||||||
/// # use helix_view::graphics::Rect;
|
/// # use helix_graphics::Rect;
|
||||||
/// let rect = Rect::new(200, 100, 10, 10);
|
/// let rect = Rect::new(200, 100, 10, 10);
|
||||||
/// let buffer = Buffer::empty(rect);
|
/// let buffer = Buffer::empty(rect);
|
||||||
/// assert_eq!(buffer.pos_of(0), (200, 100));
|
/// assert_eq!(buffer.pos_of(0), (200, 100));
|
||||||
|
|
|
@ -5,7 +5,7 @@ use cassowary::strength::{REQUIRED, WEAK};
|
||||||
use cassowary::WeightedRelation::*;
|
use cassowary::WeightedRelation::*;
|
||||||
use cassowary::{Constraint as CassowaryConstraint, Expression, Solver, Variable};
|
use cassowary::{Constraint as CassowaryConstraint, Expression, Solver, Variable};
|
||||||
|
|
||||||
use helix_view::graphics::{Margin, Rect};
|
use helix_graphics::{Margin, Rect};
|
||||||
|
|
||||||
#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum Corner {
|
pub enum Corner {
|
||||||
|
@ -115,7 +115,7 @@ impl Layout {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
/// ```
|
/// ```
|
||||||
/// # use helix_tui::layout::{Constraint, Direction, Layout};
|
/// # use helix_tui::layout::{Constraint, Direction, Layout};
|
||||||
/// # use helix_view::graphics::Rect;
|
/// # use helix_graphics::Rect;
|
||||||
/// let chunks = Layout::default()
|
/// let chunks = Layout::default()
|
||||||
/// .direction(Direction::Vertical)
|
/// .direction(Direction::Vertical)
|
||||||
/// .constraints([Constraint::Length(5), Constraint::Min(0)].as_ref())
|
/// .constraints([Constraint::Length(5), Constraint::Min(0)].as_ref())
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::{backend::Backend, buffer::Buffer};
|
use crate::{backend::Backend, buffer::Buffer};
|
||||||
use helix_view::graphics::{CursorKind, Rect};
|
use helix_graphics::{CursorKind, Rect};
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! # use helix_tui::widgets::Block;
|
//! # use helix_tui::widgets::Block;
|
||||||
//! # use helix_tui::text::{Span, Spans};
|
//! # use helix_tui::text::{Span, Spans};
|
||||||
//! # use helix_view::graphics::{Color, Style};
|
//! # use helix_graphics::{Color, Style};
|
||||||
//! // A simple string with no styling.
|
//! // A simple string with no styling.
|
||||||
//! // Converted to Spans(vec![
|
//! // Converted to Spans(vec![
|
||||||
//! // Span { content: Cow::Borrowed("My title"), style: Style { .. } }
|
//! // Span { content: Cow::Borrowed("My title"), style: Style { .. } }
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
//! ```
|
//! ```
|
||||||
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_core::unicode::width::UnicodeWidthStr;
|
||||||
use helix_view::graphics::Style;
|
use helix_graphics::Style;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use unicode_segmentation::UnicodeSegmentation;
|
use unicode_segmentation::UnicodeSegmentation;
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ impl<'a> Span<'a> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use helix_tui::text::Span;
|
/// # use helix_tui::text::Span;
|
||||||
/// # use helix_view::graphics::{Color, Modifier, Style};
|
/// # use helix_graphics::{Color, Modifier, Style};
|
||||||
/// let style = Style::default().fg(Color::Yellow).add_modifier(Modifier::ITALIC);
|
/// let style = Style::default().fg(Color::Yellow).add_modifier(Modifier::ITALIC);
|
||||||
/// Span::styled("My text", style);
|
/// Span::styled("My text", style);
|
||||||
/// Span::styled(String::from("My text"), style);
|
/// Span::styled(String::from("My text"), style);
|
||||||
|
@ -121,7 +121,7 @@ impl<'a> Span<'a> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use helix_tui::text::{Span, StyledGrapheme};
|
/// # use helix_tui::text::{Span, StyledGrapheme};
|
||||||
/// # use helix_view::graphics::{Color, Modifier, Style};
|
/// # use helix_graphics::{Color, Modifier, Style};
|
||||||
/// # use std::iter::Iterator;
|
/// # use std::iter::Iterator;
|
||||||
/// let style = Style::default().fg(Color::Yellow);
|
/// let style = Style::default().fg(Color::Yellow);
|
||||||
/// let span = Span::styled("Text", style);
|
/// let span = Span::styled("Text", style);
|
||||||
|
@ -205,7 +205,7 @@ impl<'a> Spans<'a> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use helix_tui::text::{Span, Spans};
|
/// # use helix_tui::text::{Span, Spans};
|
||||||
/// # use helix_view::graphics::{Color, Style};
|
/// # use helix_graphics::{Color, Style};
|
||||||
/// let spans = Spans::from(vec![
|
/// let spans = Spans::from(vec![
|
||||||
/// Span::styled("My", Style::default().fg(Color::Yellow)),
|
/// Span::styled("My", Style::default().fg(Color::Yellow)),
|
||||||
/// Span::raw(" text"),
|
/// Span::raw(" text"),
|
||||||
|
@ -259,7 +259,7 @@ impl<'a> From<Spans<'a>> for String {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use helix_tui::text::Text;
|
/// # use helix_tui::text::Text;
|
||||||
/// # use helix_view::graphics::{Color, Modifier, Style};
|
/// # use helix_graphics::{Color, Modifier, Style};
|
||||||
/// let style = Style::default().fg(Color::Yellow).add_modifier(Modifier::ITALIC);
|
/// let style = Style::default().fg(Color::Yellow).add_modifier(Modifier::ITALIC);
|
||||||
///
|
///
|
||||||
/// // An initial two lines of `Text` built from a `&str`
|
/// // An initial two lines of `Text` built from a `&str`
|
||||||
|
@ -307,7 +307,7 @@ impl<'a> Text<'a> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use helix_tui::text::Text;
|
/// # use helix_tui::text::Text;
|
||||||
/// # use helix_view::graphics::{Color, Modifier, Style};
|
/// # use helix_graphics::{Color, Modifier, Style};
|
||||||
/// let style = Style::default().fg(Color::Yellow).add_modifier(Modifier::ITALIC);
|
/// let style = Style::default().fg(Color::Yellow).add_modifier(Modifier::ITALIC);
|
||||||
/// Text::styled("The first line\nThe second line", style);
|
/// Text::styled("The first line\nThe second line", style);
|
||||||
/// Text::styled(String::from("The first line\nThe second line"), style);
|
/// Text::styled(String::from("The first line\nThe second line"), style);
|
||||||
|
@ -357,7 +357,7 @@ impl<'a> Text<'a> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use helix_tui::text::Text;
|
/// # use helix_tui::text::Text;
|
||||||
/// # use helix_view::graphics::{Color, Modifier, Style};
|
/// # use helix_graphics::{Color, Modifier, Style};
|
||||||
/// let style = Style::default().fg(Color::Yellow).add_modifier(Modifier::ITALIC);
|
/// let style = Style::default().fg(Color::Yellow).add_modifier(Modifier::ITALIC);
|
||||||
/// let mut raw_text = Text::raw("The first line\nThe second line");
|
/// let mut raw_text = Text::raw("The first line\nThe second line");
|
||||||
/// let styled_text = Text::styled(String::from("The first line\nThe second line"), style);
|
/// let styled_text = Text::styled(String::from("The first line\nThe second line"), style);
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::{
|
||||||
text::{Span, Spans},
|
text::{Span, Spans},
|
||||||
widgets::{Borders, Widget},
|
widgets::{Borders, Widget},
|
||||||
};
|
};
|
||||||
use helix_view::graphics::{Rect, Style};
|
use helix_graphics::{Rect, Style};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub enum BorderType {
|
pub enum BorderType {
|
||||||
|
@ -32,7 +32,7 @@ impl BorderType {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use helix_tui::widgets::{Block, BorderType, Borders};
|
/// # use helix_tui::widgets::{Block, BorderType, Borders};
|
||||||
/// # use helix_view::graphics::{Style, Color};
|
/// # use helix_graphics::{Style, Color};
|
||||||
/// Block::default()
|
/// Block::default()
|
||||||
/// .title("Block")
|
/// .title("Block")
|
||||||
/// .borders(Borders::LEFT | Borders::RIGHT)
|
/// .borders(Borders::LEFT | Borders::RIGHT)
|
||||||
|
|
|
@ -23,7 +23,7 @@ pub use self::table::{Cell, Row, Table, TableState};
|
||||||
use crate::buffer::Buffer;
|
use crate::buffer::Buffer;
|
||||||
use bitflags::bitflags;
|
use bitflags::bitflags;
|
||||||
|
|
||||||
use helix_view::graphics::Rect;
|
use helix_graphics::Rect;
|
||||||
|
|
||||||
bitflags! {
|
bitflags! {
|
||||||
/// Bitflags that can be composed to set the visible borders essentially on the block widget.
|
/// Bitflags that can be composed to set the visible borders essentially on the block widget.
|
||||||
|
|
|
@ -8,7 +8,7 @@ use crate::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use helix_core::unicode::width::UnicodeWidthStr;
|
use helix_core::unicode::width::UnicodeWidthStr;
|
||||||
use helix_view::graphics::{Rect, Style};
|
use helix_graphics::{Rect, Style};
|
||||||
use std::iter;
|
use std::iter;
|
||||||
|
|
||||||
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 {
|
||||||
|
@ -27,7 +27,7 @@ fn get_line_offset(line_width: u16, text_area_width: u16, alignment: Alignment)
|
||||||
/// # use helix_tui::text::{Text, Spans, Span};
|
/// # use helix_tui::text::{Text, Spans, Span};
|
||||||
/// # use helix_tui::widgets::{Block, Borders, Paragraph, Wrap};
|
/// # use helix_tui::widgets::{Block, Borders, Paragraph, Wrap};
|
||||||
/// # use helix_tui::layout::{Alignment};
|
/// # use helix_tui::layout::{Alignment};
|
||||||
/// # use helix_view::graphics::{Style, Color, Modifier};
|
/// # use helix_graphics::{Style, Color, Modifier};
|
||||||
/// let text = vec![
|
/// let text = vec![
|
||||||
/// Spans::from(vec![
|
/// Spans::from(vec![
|
||||||
/// Span::raw("First"),
|
/// Span::raw("First"),
|
||||||
|
|
|
@ -10,7 +10,7 @@ use cassowary::{
|
||||||
{Expression, Solver},
|
{Expression, Solver},
|
||||||
};
|
};
|
||||||
use helix_core::unicode::width::UnicodeWidthStr;
|
use helix_core::unicode::width::UnicodeWidthStr;
|
||||||
use helix_view::graphics::{Rect, Style};
|
use helix_graphics::{Rect, Style};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
/// 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`].
|
||||||
|
@ -19,7 +19,7 @@ use std::collections::HashMap;
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use helix_tui::widgets::Cell;
|
/// # use helix_tui::widgets::Cell;
|
||||||
/// # use helix_tui::text::{Span, Spans, Text};
|
/// # use helix_tui::text::{Span, Spans, Text};
|
||||||
/// # use helix_view::graphics::{Style, Modifier};
|
/// # use helix_graphics::{Style, Modifier};
|
||||||
/// Cell::from("simple string");
|
/// Cell::from("simple string");
|
||||||
///
|
///
|
||||||
/// Cell::from(Span::from("span"));
|
/// Cell::from(Span::from("span"));
|
||||||
|
@ -71,7 +71,7 @@ where
|
||||||
/// But if you need a bit more control over individual cells, you can explicitly create [`Cell`]s:
|
/// But if you need a bit more control over individual cells, you can explicitly create [`Cell`]s:
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use helix_tui::widgets::{Row, Cell};
|
/// # use helix_tui::widgets::{Row, Cell};
|
||||||
/// # use helix_view::graphics::{Style, Color};
|
/// # use helix_graphics::{Style, Color};
|
||||||
/// Row::new(vec![
|
/// Row::new(vec![
|
||||||
/// Cell::from("Cell1"),
|
/// Cell::from("Cell1"),
|
||||||
/// Cell::from("Cell2").style(Style::default().fg(Color::Yellow)),
|
/// Cell::from("Cell2").style(Style::default().fg(Color::Yellow)),
|
||||||
|
@ -134,7 +134,7 @@ impl<'a> Row<'a> {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use helix_tui::widgets::{Block, Borders, Table, Row, Cell};
|
/// # use helix_tui::widgets::{Block, Borders, Table, Row, Cell};
|
||||||
/// # use helix_tui::layout::Constraint;
|
/// # use helix_tui::layout::Constraint;
|
||||||
/// # use helix_view::graphics::{Style, Color, Modifier};
|
/// # use helix_graphics::{Style, Color, Modifier};
|
||||||
/// # use helix_tui::text::{Text, Spans, Span};
|
/// # use helix_tui::text::{Text, Spans, Span};
|
||||||
/// Table::new(vec![
|
/// Table::new(vec![
|
||||||
/// // Row can be created from simple strings.
|
/// // Row can be created from simple strings.
|
||||||
|
|
|
@ -14,18 +14,20 @@ homepage = "https://helix-editor.com"
|
||||||
lsp = ["helix-lsp", "tokio-runtime"]
|
lsp = ["helix-lsp", "tokio-runtime"]
|
||||||
dap = ["helix-dap", "tokio-stream", "tokio-runtime"]
|
dap = ["helix-dap", "tokio-stream", "tokio-runtime"]
|
||||||
tokio-runtime = ["tokio"]
|
tokio-runtime = ["tokio"]
|
||||||
term = ["crossterm"]
|
term = ["crossterm", "tui"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "1.3"
|
bitflags = "1.3"
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
helix-core = { version = "0.6", path = "../helix-core" }
|
helix-core = { version = "0.6", path = "../helix-core" }
|
||||||
|
helix-graphics = { version = "0.6", path = "../helix-graphics" }
|
||||||
helix-lsp = { version = "0.6", path = "../helix-lsp", optional = true }
|
helix-lsp = { version = "0.6", path = "../helix-lsp", optional = true }
|
||||||
helix-dap = { version = "0.6", path = "../helix-dap", optional = true }
|
helix-dap = { version = "0.6", path = "../helix-dap", optional = true }
|
||||||
tokio-stream = { version = "0.1", optional = true }
|
tokio-stream = { version = "0.1", optional = true }
|
||||||
tokio = { version = "1", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot", "sync"], optional = true }
|
tokio = { version = "1", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot", "sync"], optional = true }
|
||||||
|
|
||||||
crossterm = { version = "0.23", optional = true }
|
crossterm = { version = "0.23", optional = true }
|
||||||
|
tui = { path = "../helix-tui", package = "helix-tui", default-features = false, features = ["crossterm"], optional = true }
|
||||||
|
|
||||||
# Conversion traits
|
# Conversion traits
|
||||||
once_cell = "1.10"
|
once_cell = "1.10"
|
||||||
|
@ -49,7 +51,3 @@ which = "4.2"
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
clipboard-win = { version = "4.4", features = ["std"] }
|
clipboard-win = { version = "4.4", features = ["std"] }
|
||||||
|
|
||||||
# TODO: graphics.rs tests rely on this, but we should remove that
|
|
||||||
# [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
|
|
||||||
# helix-tui = { path = "../helix-tui" }
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
// Each component declares it's own size constraints and gets fitted based on it's parent.
|
// Each component declares it's own size constraints and gets fitted based on it's parent.
|
||||||
// Q: how does this work with popups?
|
// Q: how does this work with popups?
|
||||||
// cursive does compositor.screen_mut().add_layer_at(pos::absolute(x, y), <component>)
|
// cursive does compositor.screen_mut().add_layer_at(pos::absolute(x, y), <component>)
|
||||||
|
use crate::graphics::{CursorKind, Rect};
|
||||||
use helix_core::Position;
|
use helix_core::Position;
|
||||||
use helix_view::graphics::{CursorKind, Rect};
|
|
||||||
|
|
||||||
pub type Callback = Box<dyn FnOnce(&mut Compositor, &mut Context)>;
|
pub type Callback = Box<dyn FnOnce(&mut Compositor, &mut Context)>;
|
||||||
|
|
||||||
|
@ -13,15 +13,16 @@ pub enum EventResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
use crate::job::Jobs;
|
use crate::job::Jobs;
|
||||||
use helix_view::Editor;
|
use crate::Editor;
|
||||||
|
|
||||||
pub use helix_view::input::Event;
|
pub use crate::input::Event;
|
||||||
|
|
||||||
pub struct Context<'a> {
|
pub struct Context<'a> {
|
||||||
pub editor: &'a mut Editor,
|
pub editor: &'a mut Editor,
|
||||||
pub jobs: &'a mut Jobs,
|
pub jobs: &'a mut Jobs,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "term")]
|
||||||
mod term {
|
mod term {
|
||||||
use super::*;
|
use super::*;
|
||||||
pub use tui::buffer::Buffer as Surface;
|
pub use tui::buffer::Buffer as Surface;
|
||||||
|
@ -33,6 +34,7 @@ mod term {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "term")]
|
||||||
pub use term::*;
|
pub use term::*;
|
||||||
|
|
||||||
pub trait Component: Any + AnyComponent {
|
pub trait Component: Any + AnyComponent {
|
||||||
|
@ -76,7 +78,8 @@ pub struct Compositor {
|
||||||
layers: Vec<Box<dyn Component>>,
|
layers: Vec<Box<dyn Component>>,
|
||||||
area: Rect,
|
area: Rect,
|
||||||
|
|
||||||
pub(crate) last_picker: Option<Box<dyn Component>>,
|
// TODO: remove pub
|
||||||
|
pub last_picker: Option<Box<dyn Component>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Compositor {
|
impl Compositor {
|
|
@ -73,3 +73,47 @@ impl Info {
|
||||||
infobox
|
infobox
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// term
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
compositor::{Component, RenderContext},
|
||||||
|
graphics::{Margin, Rect},
|
||||||
|
};
|
||||||
|
use tui::widgets::{Block, Borders, Paragraph, Widget};
|
||||||
|
|
||||||
|
impl Component for Info {
|
||||||
|
fn render(&mut self, viewport: Rect, cx: &mut RenderContext<'_>) {
|
||||||
|
let text_style = cx.editor.theme.get("ui.text.info");
|
||||||
|
let popup_style = cx.editor.theme.get("ui.popup.info");
|
||||||
|
|
||||||
|
// Calculate the area of the terminal to modify. Because we want to
|
||||||
|
// render at the bottom right, we use the viewport's width and height
|
||||||
|
// which evaluate to the most bottom right coordinate.
|
||||||
|
let width = self.width + 2 + 2; // +2 for border, +2 for margin
|
||||||
|
let height = self.height + 2; // +2 for border
|
||||||
|
let area = viewport.intersection(Rect::new(
|
||||||
|
viewport.width.saturating_sub(width),
|
||||||
|
viewport.height.saturating_sub(height + 2), // +2 for statusline
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
));
|
||||||
|
cx.surface.clear_with(area, popup_style);
|
||||||
|
|
||||||
|
let block = Block::default()
|
||||||
|
.title(self.title.as_str())
|
||||||
|
.borders(Borders::ALL)
|
||||||
|
.border_style(popup_style);
|
||||||
|
|
||||||
|
let margin = Margin {
|
||||||
|
vertical: 0,
|
||||||
|
horizontal: 1,
|
||||||
|
};
|
||||||
|
let inner = block.inner(area).inner(&margin);
|
||||||
|
block.render(area, cx.surface);
|
||||||
|
|
||||||
|
Paragraph::new(self.text.as_str())
|
||||||
|
.style(text_style)
|
||||||
|
.render(inner, cx.surface);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use helix_view::Editor;
|
|
||||||
|
|
||||||
use crate::compositor::Compositor;
|
use crate::compositor::Compositor;
|
||||||
|
use crate::Editor;
|
||||||
|
|
||||||
use futures_util::future::{self, BoxFuture, Future, FutureExt};
|
use futures_util::future::{self, BoxFuture, Future, FutureExt};
|
||||||
use futures_util::stream::{FuturesUnordered, StreamExt};
|
use futures_util::stream::{FuturesUnordered, StreamExt};
|
|
@ -6,10 +6,12 @@ pub mod backend {
|
||||||
pub mod term;
|
pub mod term;
|
||||||
}
|
}
|
||||||
pub mod clipboard;
|
pub mod clipboard;
|
||||||
|
pub mod compositor;
|
||||||
pub mod document;
|
pub mod document;
|
||||||
pub mod editor;
|
pub mod editor;
|
||||||
pub mod graphics;
|
pub use helix_graphics as graphics;
|
||||||
pub mod gutter;
|
pub mod gutter;
|
||||||
|
pub mod job;
|
||||||
pub mod handlers {
|
pub mod handlers {
|
||||||
#[cfg(feature = "dap")]
|
#[cfg(feature = "dap")]
|
||||||
pub mod dap;
|
pub mod dap;
|
||||||
|
|
Loading…
Reference in New Issue