mirror of
https://codeberg.org/unspeaker/perch.git
synced 2025-12-06 09:36:42 +01:00
chore: struct Taggart -> Perch
This commit is contained in:
parent
44315dcc72
commit
332869c5cb
12 changed files with 15 additions and 15 deletions
|
|
@ -25,7 +25,7 @@ mod save;
|
||||||
mod quit;
|
mod quit;
|
||||||
mod help;
|
mod help;
|
||||||
|
|
||||||
impl Handle<TuiIn> for Taggart {
|
impl Handle<TuiIn> for Perch {
|
||||||
fn handle (&mut self, input: &TuiIn) -> Perhaps<bool> {
|
fn handle (&mut self, input: &TuiIn) -> Perhaps<bool> {
|
||||||
let min = self.offset;
|
let min = self.offset;
|
||||||
let max = self.offset + self.display.h().saturating_sub(1);
|
let max = self.offset + self.display.h().saturating_sub(1);
|
||||||
|
|
@ -60,7 +60,7 @@ impl Handle<TuiIn> for Taggart {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Taggart {
|
impl Perch {
|
||||||
fn open_in_player (&self) -> Usually<()> {
|
fn open_in_player (&self) -> Usually<()> {
|
||||||
open(self.entries[self.cursor].path.as_ref())?;
|
open(self.entries[self.cursor].path.as_ref())?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
impl Taggart {
|
impl Perch {
|
||||||
pub fn handle_edit (&mut self, event: &Event) {
|
pub fn handle_edit (&mut self, event: &Event) {
|
||||||
match event {
|
match event {
|
||||||
press!(Char(c)) => self.edit_insert(*c),
|
press!(Char(c)) => self.edit_insert(*c),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
impl Taggart {
|
impl Perch {
|
||||||
pub fn handle_help (&mut self, event: &Event, _page: u8) {
|
pub fn handle_help (&mut self, event: &Event, _page: u8) {
|
||||||
match event {
|
match event {
|
||||||
press!(Esc) => { self.mode = None },
|
press!(Esc) => { self.mode = None },
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
impl Taggart {
|
impl Perch {
|
||||||
pub fn handle_quit (&mut self, input: &TuiIn, choice: u8) {
|
pub fn handle_quit (&mut self, input: &TuiIn, choice: u8) {
|
||||||
match &*input.event() {
|
match &*input.event() {
|
||||||
press!(Esc) => { self.mode = None },
|
press!(Esc) => { self.mode = None },
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
impl Taggart {
|
impl Perch {
|
||||||
pub fn handle_save (&mut self, event: &Event, choice: u8) {
|
pub fn handle_save (&mut self, event: &Event, choice: u8) {
|
||||||
match event {
|
match event {
|
||||||
press!(Esc) => { self.mode = None }
|
press!(Esc) => { self.mode = None }
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ fn main () -> Usually<()> {
|
||||||
if let Ok(results) = Arc::try_unwrap(results) {
|
if let Ok(results) = Arc::try_unwrap(results) {
|
||||||
let mut results = results.into_inner()?;
|
let mut results = results.into_inner()?;
|
||||||
results.sort();
|
results.sort();
|
||||||
let state = Arc::new(RwLock::new(Taggart::new(&path, results)?));
|
let state = Arc::new(RwLock::new(Perch::new(&path, results)?));
|
||||||
if let Some(true) = args.get_one::<bool>("check") {
|
if let Some(true) = args.get_one::<bool>("check") {
|
||||||
return Ok(())
|
return Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ mod column; pub use self::column::*;
|
||||||
mod entry; pub use self::entry::*;
|
mod entry; pub use self::entry::*;
|
||||||
|
|
||||||
/// The application state.
|
/// The application state.
|
||||||
pub struct Taggart {
|
pub struct Perch {
|
||||||
pub _root: PathBuf,
|
pub _root: PathBuf,
|
||||||
pub entries: Vec<Entry>,
|
pub entries: Vec<Entry>,
|
||||||
pub cursor: usize,
|
pub cursor: usize,
|
||||||
|
|
@ -32,7 +32,7 @@ pub enum Mode {
|
||||||
Quit { choice: u8, },
|
Quit { choice: u8, },
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Taggart {
|
impl Perch {
|
||||||
pub fn new (root: &impl AsRef<Path>, entries: Vec<Entry>) -> Usually<Self> {
|
pub fn new (root: &impl AsRef<Path>, entries: Vec<Entry>) -> Usually<Self> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
_root: root.as_ref().into(),
|
_root: root.as_ref().into(),
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ pub struct Columns<G, S, U>(pub Vec<Column<G, S, U>>);
|
||||||
|
|
||||||
macro_rules! setter {
|
macro_rules! setter {
|
||||||
($set:ident) => {{
|
($set:ident) => {{
|
||||||
fn $set (state: &mut Taggart, index: usize, value: Option<&str>) {
|
fn $set (state: &mut Perch, index: usize, value: Option<&str>) {
|
||||||
if let Some(entries) = entries_under(&mut state.entries, index) {
|
if let Some(entries) = entries_under(&mut state.entries, index) {
|
||||||
for (_path, entry) in entries.into_iter() {
|
for (_path, entry) in entries.into_iter() {
|
||||||
if entry.write().unwrap().$set(value) {
|
if entry.write().unwrap().$set(value) {
|
||||||
|
|
@ -82,7 +82,7 @@ macro_rules! setter {
|
||||||
|
|
||||||
impl Default for Columns<
|
impl Default for Columns<
|
||||||
fn(&Entry)->Option<Arc<str>>,
|
fn(&Entry)->Option<Arc<str>>,
|
||||||
fn(&mut Taggart, usize, Option<&str>),
|
fn(&mut Perch, usize, Option<&str>),
|
||||||
fn(&Entry)->Option<Style>,
|
fn(&Entry)->Option<Style>,
|
||||||
> {
|
> {
|
||||||
fn default () -> Self {
|
fn default () -> Self {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ mod table; pub use self::table::*;
|
||||||
mod dialog;
|
mod dialog;
|
||||||
mod status;
|
mod status;
|
||||||
|
|
||||||
impl Content<TuiOut> for Taggart {
|
impl Content<TuiOut> for Perch {
|
||||||
fn content (&self) -> impl Render<TuiOut> {
|
fn content (&self) -> impl Render<TuiOut> {
|
||||||
let w = self.display.w();
|
let w = self.display.w();
|
||||||
let h = self.display.h();
|
let h = self.display.h();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
impl Taggart {
|
impl Perch {
|
||||||
fn dialog (content: impl Content<TuiOut>) -> impl Content<TuiOut> {
|
fn dialog (content: impl Content<TuiOut>) -> impl Content<TuiOut> {
|
||||||
let pos = |x|Fill::xy( Align::c(x));
|
let pos = |x|Fill::xy( Align::c(x));
|
||||||
let style = |x|Tui::modify(false, Modifier::DIM, Tui::fg_bg(FG_MODAL, BG_MODAL, x));
|
let style = |x|Tui::modify(false, Modifier::DIM, Tui::fg_bg(FG_MODAL, BG_MODAL, x));
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
impl Taggart {
|
impl Perch {
|
||||||
pub(crate) fn title_bar (&self) -> impl Content<TuiOut> {
|
pub(crate) fn title_bar (&self) -> impl Content<TuiOut> {
|
||||||
status_bar(
|
status_bar(
|
||||||
Color::Rgb(0, 0, 0),
|
Color::Rgb(0, 0, 0),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
pub struct TreeTable<'a>(pub(crate) &'a Taggart);
|
pub struct TreeTable<'a>(pub(crate) &'a Perch);
|
||||||
|
|
||||||
impl<'a> Content<TuiOut> for TreeTable<'a> {
|
impl<'a> Content<TuiOut> for TreeTable<'a> {
|
||||||
fn render (&self, to: &mut TuiOut) {
|
fn render (&self, to: &mut TuiOut) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue