mirror of
https://github.com/TECHNOFAB11/tmux-copyrat.git
synced 2025-12-13 00:20:08 +01:00
refactor: selection.rs -> ui/selection.rs
This commit is contained in:
parent
748da3ae72
commit
a5e3ed263c
6 changed files with 10 additions and 6 deletions
|
|
@ -3,7 +3,7 @@ use std::fs::OpenOptions;
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
use std::io::{self, Read};
|
use std::io::{self, Read};
|
||||||
|
|
||||||
use copyrat::{run, selection::Selection, CliOpt};
|
use copyrat::{run, ui::Selection, CliOpt};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let opt = CliOpt::parse();
|
let opt = CliOpt::parse();
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use clap::Clap;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use copyrat::{error, output_destination::OutputDestination, selection::Selection, tmux, CliOpt};
|
use copyrat::{error, output_destination::OutputDestination, tmux, ui::Selection, CliOpt};
|
||||||
|
|
||||||
/// Main configuration, parsed from command line.
|
/// Main configuration, parsed from command line.
|
||||||
#[derive(Clap, Debug)]
|
#[derive(Clap, Debug)]
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ pub mod error;
|
||||||
pub mod model;
|
pub mod model;
|
||||||
pub mod output_destination;
|
pub mod output_destination;
|
||||||
pub mod regexes;
|
pub mod regexes;
|
||||||
pub mod selection;
|
|
||||||
pub mod tmux;
|
pub mod tmux;
|
||||||
pub mod ui;
|
pub mod ui;
|
||||||
|
|
||||||
|
|
@ -17,7 +16,7 @@ pub mod ui;
|
||||||
/// # Note
|
/// # Note
|
||||||
///
|
///
|
||||||
/// Maybe the decision to take ownership of the buffer is a bit bold.
|
/// Maybe the decision to take ownership of the buffer is a bit bold.
|
||||||
pub fn run(buffer: String, opt: &CliOpt) -> Option<selection::Selection> {
|
pub fn run(buffer: String, opt: &CliOpt) -> Option<ui::Selection> {
|
||||||
let mut model = model::Model::new(
|
let mut model = model::Model::new(
|
||||||
&buffer,
|
&buffer,
|
||||||
&opt.alphabet,
|
&opt.alphabet,
|
||||||
|
|
@ -42,7 +41,7 @@ pub fn run(buffer: String, opt: &CliOpt) -> Option<selection::Selection> {
|
||||||
|
|
||||||
let default_output_destination = output_destination::OutputDestination::Tmux;
|
let default_output_destination = output_destination::OutputDestination::Tmux;
|
||||||
|
|
||||||
let selection: Option<selection::Selection> = {
|
let selection: Option<ui::Selection> = {
|
||||||
let mut ui = ui::ViewController::new(
|
let mut ui = ui::ViewController::new(
|
||||||
&mut model,
|
&mut model,
|
||||||
opt.unique_hint,
|
opt.unique_hint,
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,9 @@
|
||||||
//!
|
//!
|
||||||
|
|
||||||
pub mod colors;
|
pub mod colors;
|
||||||
|
mod selection;
|
||||||
mod vc;
|
mod vc;
|
||||||
|
|
||||||
|
pub use selection::Selection;
|
||||||
pub use vc::ViewController;
|
pub use vc::ViewController;
|
||||||
pub use vc::{HintAlignment, HintStyle};
|
pub use vc::{HintAlignment, HintStyle};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
use crate::output_destination::OutputDestination;
|
use crate::output_destination::OutputDestination;
|
||||||
|
|
||||||
|
/// Represents the text selected by the user, along with if it was uppercased
|
||||||
|
/// and the output destination (Tmux buffer or Clipboard).
|
||||||
pub struct Selection {
|
pub struct Selection {
|
||||||
pub text: String,
|
pub text: String,
|
||||||
pub uppercased: bool,
|
pub uppercased: bool,
|
||||||
|
|
@ -8,8 +8,9 @@ use sequence_trie::SequenceTrie;
|
||||||
use termion::{self, color, cursor, event, style};
|
use termion::{self, color, cursor, event, style};
|
||||||
|
|
||||||
use super::colors::UiColors;
|
use super::colors::UiColors;
|
||||||
|
use super::Selection;
|
||||||
use crate::error::ParseError;
|
use crate::error::ParseError;
|
||||||
use crate::{model, output_destination::OutputDestination, selection::Selection};
|
use crate::{model, output_destination::OutputDestination};
|
||||||
|
|
||||||
pub struct ViewController<'a> {
|
pub struct ViewController<'a> {
|
||||||
model: &'a mut model::Model<'a>,
|
model: &'a mut model::Model<'a>,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue