Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new theme system #161

Merged
merged 20 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 118 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"app",
"config",
"core",
"plugin",
"shared",
]

Expand Down
1 change: 1 addition & 0 deletions app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"
adaptor = { path = "../adaptor" }
config = { path = "../config" }
core = { path = "../core" }
plugin = { path = "../plugin" }
shared = { path = "../shared" }

# External dependencies
Expand Down
14 changes: 8 additions & 6 deletions app/src/app.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use core::{emit, files::FilesOp, input::InputMode, Event};
use core::{emit, files::FilesOp, input::InputMode, Ctx, Event};
use std::ffi::OsString;

use anyhow::{Ok, Result};
Expand All @@ -7,7 +7,7 @@ use crossterm::event::KeyEvent;
use shared::{expand_url, Term};
use tokio::sync::oneshot;

use crate::{Ctx, Executor, Logs, Root, Signals};
use crate::{Executor, Logs, Root, Signals};

pub(super) struct App {
cx: Ctx,
Expand All @@ -21,7 +21,7 @@ impl App {
let term = Term::start()?;

let signals = Signals::start()?;
let mut app = Self { cx: Ctx::new(), term: Some(term), signals };
let mut app = Self { cx: Ctx::make(), term: Some(term), signals };

while let Some(event) = app.signals.recv().await {
match event {
Expand Down Expand Up @@ -76,7 +76,9 @@ impl App {
fn dispatch_render(&mut self) {
if let Some(term) = &mut self.term {
let _ = term.draw(|f| {
f.render_widget(Root::new(&self.cx), f.size());
plugin::scope(&self.cx, |_| {
f.render_widget(Root::new(&self.cx), f.size());
});

if let Some((x, y)) = self.cx.cursor() {
f.set_cursor(x, y);
Expand Down Expand Up @@ -209,8 +211,8 @@ impl App {
tasks.file_open(&targets);
}
}
Event::Progress(percent, left) => {
tasks.progress = (percent, left);
Event::Progress(progress) => {
tasks.progress = progress;
emit!(Render);
}

Expand Down
4 changes: 1 addition & 3 deletions app/src/executor.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use core::{emit, files::FilesSorter, input::InputMode, manager::FinderCase};
use core::{emit, files::FilesSorter, input::InputMode, manager::FinderCase, Ctx};

use config::{keymap::{Control, Exec, Key, KeymapLayer}, manager::SortBy, KEYMAP};
use shared::{optional_bool, Url};

use super::Ctx;

pub(super) struct Executor;

impl Executor {
Expand Down
33 changes: 0 additions & 33 deletions app/src/header/layout.rs

This file was deleted.

5 changes: 0 additions & 5 deletions app/src/header/mod.rs

This file was deleted.

63 changes: 0 additions & 63 deletions app/src/header/tabs.rs

This file was deleted.

4 changes: 2 additions & 2 deletions app/src/help/bindings.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use ratatui::{layout::{self, Constraint}, prelude::{Buffer, Direction, Rect}, style::{Color, Style, Stylize}, widgets::{List, ListItem, Widget}};
use core::Ctx;

use crate::context::Ctx;
use ratatui::{layout::{self, Constraint}, prelude::{Buffer, Direction, Rect}, style::{Color, Style, Stylize}, widgets::{List, ListItem, Widget}};

pub(super) struct Bindings<'a> {
cx: &'a Ctx,
Expand Down
5 changes: 3 additions & 2 deletions app/src/help/layout.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use core::Ctx;

use ratatui::{buffer::Buffer, layout::{self, Rect}, prelude::{Constraint, Direction}, style::{Color, Style}, widgets::{Clear, Paragraph, Widget}};

use super::Bindings;
use crate::Ctx;

pub(crate) struct Layout<'a> {
cx: &'a Ctx,
Expand All @@ -15,7 +16,7 @@ impl<'a> Widget for Layout<'a> {
fn render(self, area: Rect, buf: &mut Buffer) {
let chunks = layout::Layout::new()
.direction(Direction::Vertical)
.constraints([Constraint::Min(0), Constraint::Length(1)].as_ref())
.constraints([Constraint::Min(0), Constraint::Length(1)])
.split(area);

Clear.render(area, buf);
Expand Down
Loading