aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorBlaž Hrastnik2020-09-04 09:18:40 +0000
committerBlaž Hrastnik2020-09-04 09:18:40 +0000
commit0d56ce9296ef6481b45cfdc90ea8b1d149ead242 (patch)
treefd08a114df4baee24c1994799541e8a2bfb2c449 /helix-term
parentbfa753307063034abd86de5d9f99f5fe925504ca (diff)
Bump deps, make it compile with latest smol.
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/Cargo.toml4
-rw-r--r--helix-term/src/editor.rs6
-rw-r--r--helix-term/src/main.rs11
3 files changed, 15 insertions, 6 deletions
diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml
index 1cb2c3bc..32e72825 100644
--- a/helix-term/Cargo.toml
+++ b/helix-term/Cargo.toml
@@ -19,9 +19,9 @@ argh = "0.1.3"
helix-core = { path = "../helix-core" }
crossterm = { version = "0.17.7", features = ["event-stream"] }
-smol = "0.3"
+smol = "0.4"
futures = { version = "0.3.5", default-features = false, features = ["std", "async-await"] }
+num_cpus = "1.13.0"
# futures-timer = "3.0.2"
-# async-channel = "1.4.0"
# tui = { version = "0.9.5", default-features = false }
diff --git a/helix-term/src/editor.rs b/helix-term/src/editor.rs
index a83db6fa..bddc2859 100644
--- a/helix-term/src/editor.rs
+++ b/helix-term/src/editor.rs
@@ -39,6 +39,8 @@ impl BufferComponent<'_> {
}
}
+static EX: smol::Executor = smol::Executor::new();
+
pub struct Editor {
state: Option<State>,
first_line: u16,
@@ -134,14 +136,14 @@ impl Editor {
}
}
- pub fn run(&mut self) -> Result<(), Error> {
+ pub async fn run(&mut self) -> Result<(), Error> {
enable_raw_mode()?;
let mut stdout = stdout();
execute!(stdout, terminal::EnterAlternateScreen)?;
- smol::run(self.print_events());
+ self.print_events().await;
execute!(stdout, terminal::LeaveAlternateScreen)?;
diff --git a/helix-term/src/main.rs b/helix-term/src/main.rs
index 6e5ec5ff..7a9289ee 100644
--- a/helix-term/src/main.rs
+++ b/helix-term/src/main.rs
@@ -18,12 +18,19 @@ pub struct Args {
files: Vec<PathBuf>,
}
+static EX: smol::Executor = smol::Executor::new();
+
fn main() -> Result<(), Error> {
let args: Args = argh::from_env();
println!("{:?}", args.files);
- let mut editor = editor::Editor::new(args)?;
- editor.run();
+ for _ in 0..num_cpus::get() {
+ std::thread::spawn(move || smol::block_on(EX.run(smol::future::pending::<()>())));
+ }
+
+ smol::block_on(EX.run(async {
+ editor::Editor::new(args).unwrap().run().await;
+ }));
Ok(())
}