|
|
@ -2,9 +2,8 @@ use clap::ArgMatches as Args;
|
|
|
|
|
|
|
|
|
|
|
|
use helix_view::{document::Mode, Document, Editor, Theme, View};
|
|
|
|
use helix_view::{document::Mode, Document, Editor, Theme, View};
|
|
|
|
|
|
|
|
|
|
|
|
use crate::compositor::{Component, Compositor, EventResult};
|
|
|
|
use crate::compositor::Compositor;
|
|
|
|
use crate::editor_view::EditorView;
|
|
|
|
use crate::ui;
|
|
|
|
use crate::prompt::Prompt;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use log::{debug, info};
|
|
|
|
use log::{debug, info};
|
|
|
|
|
|
|
|
|
|
|
@ -19,18 +18,11 @@ use smol::prelude::*;
|
|
|
|
use anyhow::Error;
|
|
|
|
use anyhow::Error;
|
|
|
|
|
|
|
|
|
|
|
|
use crossterm::{
|
|
|
|
use crossterm::{
|
|
|
|
cursor,
|
|
|
|
event::{Event, EventStream},
|
|
|
|
event::{read, Event, EventStream, KeyCode, KeyEvent},
|
|
|
|
execute, terminal,
|
|
|
|
execute, queue,
|
|
|
|
|
|
|
|
terminal::{self, disable_raw_mode, enable_raw_mode},
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
use tui::{
|
|
|
|
use tui::{backend::CrosstermBackend, layout::Rect};
|
|
|
|
backend::CrosstermBackend,
|
|
|
|
|
|
|
|
buffer::Buffer as Surface,
|
|
|
|
|
|
|
|
layout::Rect,
|
|
|
|
|
|
|
|
style::{Color, Modifier, Style},
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type Terminal = crate::terminal::Terminal<CrosstermBackend<std::io::Stdout>>;
|
|
|
|
type Terminal = crate::terminal::Terminal<CrosstermBackend<std::io::Stdout>>;
|
|
|
|
|
|
|
|
|
|
|
@ -43,12 +35,6 @@ pub struct Application {
|
|
|
|
language_server: helix_lsp::Client,
|
|
|
|
language_server: helix_lsp::Client,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: temp
|
|
|
|
|
|
|
|
#[inline(always)]
|
|
|
|
|
|
|
|
pub fn text_color() -> Style {
|
|
|
|
|
|
|
|
Style::default().fg(Color::Rgb(219, 191, 239)) // lilac
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl Application {
|
|
|
|
impl Application {
|
|
|
|
pub fn new(mut args: Args, executor: &'static smol::Executor<'static>) -> Result<Self, Error> {
|
|
|
|
pub fn new(mut args: Args, executor: &'static smol::Executor<'static>) -> Result<Self, Error> {
|
|
|
|
let backend = CrosstermBackend::new(stdout());
|
|
|
|
let backend = CrosstermBackend::new(stdout());
|
|
|
@ -61,14 +47,13 @@ impl Application {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let mut compositor = Compositor::new();
|
|
|
|
let mut compositor = Compositor::new();
|
|
|
|
compositor.push(Box::new(EditorView::new()));
|
|
|
|
compositor.push(Box::new(ui::EditorView::new()));
|
|
|
|
|
|
|
|
|
|
|
|
let language_server = helix_lsp::Client::start(&executor, "rust-analyzer", &[]);
|
|
|
|
let language_server = helix_lsp::Client::start(&executor, "rust-analyzer", &[]);
|
|
|
|
|
|
|
|
|
|
|
|
let mut app = Self {
|
|
|
|
let mut app = Self {
|
|
|
|
editor,
|
|
|
|
editor,
|
|
|
|
terminal,
|
|
|
|
terminal,
|
|
|
|
// TODO; move to state
|
|
|
|
|
|
|
|
compositor,
|
|
|
|
compositor,
|
|
|
|
|
|
|
|
|
|
|
|
executor,
|
|
|
|
executor,
|
|
|
@ -213,7 +198,7 @@ impl Application {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub async fn run(&mut self) -> Result<(), Error> {
|
|
|
|
pub async fn run(&mut self) -> Result<(), Error> {
|
|
|
|
enable_raw_mode()?;
|
|
|
|
terminal::enable_raw_mode()?;
|
|
|
|
|
|
|
|
|
|
|
|
let mut stdout = stdout();
|
|
|
|
let mut stdout = stdout();
|
|
|
|
|
|
|
|
|
|
|
@ -223,7 +208,7 @@ impl Application {
|
|
|
|
let hook = std::panic::take_hook();
|
|
|
|
let hook = std::panic::take_hook();
|
|
|
|
std::panic::set_hook(Box::new(move |info| {
|
|
|
|
std::panic::set_hook(Box::new(move |info| {
|
|
|
|
execute!(std::io::stdout(), terminal::LeaveAlternateScreen);
|
|
|
|
execute!(std::io::stdout(), terminal::LeaveAlternateScreen);
|
|
|
|
disable_raw_mode();
|
|
|
|
terminal::disable_raw_mode();
|
|
|
|
hook(info);
|
|
|
|
hook(info);
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
@ -234,7 +219,7 @@ impl Application {
|
|
|
|
|
|
|
|
|
|
|
|
execute!(stdout, terminal::LeaveAlternateScreen)?;
|
|
|
|
execute!(stdout, terminal::LeaveAlternateScreen)?;
|
|
|
|
|
|
|
|
|
|
|
|
disable_raw_mode()?;
|
|
|
|
terminal::disable_raw_mode()?;
|
|
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|