add window
This commit is contained in:
parent
934452beda
commit
f1882310c9
|
@ -113,7 +113,7 @@ impl Application {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let x = x + UnicodeWidthStr::width(suggestion.as_str()) as u16;
|
let x = x + UnicodeWidthStr::width(suggestion.as_str()) as u16;
|
||||||
let mut prompt = String::from(if x == 0 {""}else{" - "});
|
let mut prompt = String::from(if x == 0 { "" } else { " - " });
|
||||||
for c in self.cmdprocessor.get_prompt().chars() {
|
for c in self.cmdprocessor.get_prompt().chars() {
|
||||||
prompt.push(c);
|
prompt.push(c);
|
||||||
if UnicodeWidthStr::width(prompt.as_str()) as u16 >= self.size.0 - 1 - x {
|
if UnicodeWidthStr::width(prompt.as_str()) as u16 >= self.size.0 - 1 - x {
|
||||||
|
|
|
@ -55,6 +55,7 @@ impl CommandProcessor {
|
||||||
}
|
}
|
||||||
if self.command.is_empty() {
|
if self.command.is_empty() {
|
||||||
self.cmdbar_suggestion.clear();
|
self.cmdbar_suggestion.clear();
|
||||||
|
self.cmdbar_prompt.clear();
|
||||||
} else {
|
} else {
|
||||||
self.cmdbar_suggestion = s;
|
self.cmdbar_suggestion = s;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ pub mod colortheme;
|
||||||
pub mod command;
|
pub mod command;
|
||||||
pub mod innerpipe;
|
pub mod innerpipe;
|
||||||
pub mod window;
|
pub mod window;
|
||||||
|
pub mod windows;
|
||||||
|
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
use std::io;
|
use std::io::{self, Stdout};
|
||||||
|
|
||||||
pub trait Window {
|
pub trait Window {
|
||||||
fn get_pos(&self) -> (u16, u16);
|
fn get_pos(&self) -> (u16, u16);
|
||||||
fn get_size(&self) -> (u16, u16);
|
fn get_size(&self) -> (u16, u16);
|
||||||
|
fn get_name(&self) -> &str;
|
||||||
fn get_id(&self) -> usize;
|
fn get_id(&self) -> usize;
|
||||||
|
|
||||||
fn render(&mut self, screen_size: (u16, u16)) -> io::Result<()>;
|
fn render(&mut self, stdout: &mut Stdout, screen_size: (u16, u16)) -> io::Result<()>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
use std::{
|
||||||
|
hash::{DefaultHasher, Hash, Hasher},
|
||||||
|
io::{self, Stdout},
|
||||||
|
};
|
||||||
|
|
||||||
|
use crossterm::{cursor, queue};
|
||||||
|
|
||||||
|
use crate::window::Window;
|
||||||
|
|
||||||
|
pub struct Editor {
|
||||||
|
name: String,
|
||||||
|
pos: (u16, u16),
|
||||||
|
size: (u16, u16),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Window for Editor {
|
||||||
|
fn get_pos(&self) -> (u16, u16) {
|
||||||
|
self.pos
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_size(&self) -> (u16, u16) {
|
||||||
|
self.size
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_name(&self) -> &str {
|
||||||
|
&self.name
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_id(&self) -> usize {
|
||||||
|
let mut state = DefaultHasher::new();
|
||||||
|
self.name.hash(&mut state);
|
||||||
|
state.finish() as usize
|
||||||
|
}
|
||||||
|
|
||||||
|
fn render(&mut self, stdout: &mut Stdout, screen_size: (u16, u16)) -> io::Result<()> {
|
||||||
|
queue!(stdout, cursor::SavePosition, cursor::RestorePosition)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Hash for Editor {
|
||||||
|
fn hash<H>(&self, state: &mut H)
|
||||||
|
where
|
||||||
|
H: Hasher,
|
||||||
|
{
|
||||||
|
self.name.hash(state)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
use std::{
|
||||||
|
hash::{DefaultHasher, Hash, Hasher},
|
||||||
|
io::{self, Stdout},
|
||||||
|
};
|
||||||
|
|
||||||
|
use crossterm::{cursor, queue};
|
||||||
|
|
||||||
|
use crate::window::Window;
|
||||||
|
|
||||||
|
pub struct Editor {
|
||||||
|
name: String,
|
||||||
|
pos: (u16, u16),
|
||||||
|
size: (u16, u16),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Window for Editor {
|
||||||
|
fn get_pos(&self) -> (u16, u16) {
|
||||||
|
self.pos
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_size(&self) -> (u16, u16) {
|
||||||
|
self.size
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_name(&self) -> &str {
|
||||||
|
&self.name
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_id(&self) -> usize {
|
||||||
|
let mut state = DefaultHasher::new();
|
||||||
|
self.name.hash(&mut state);
|
||||||
|
state.finish() as usize
|
||||||
|
}
|
||||||
|
|
||||||
|
fn render(&mut self, stdout: &mut Stdout, screen_size: (u16, u16)) -> io::Result<()> {
|
||||||
|
queue!(stdout, cursor::SavePosition, cursor::StorePosition)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Hash for Editor {
|
||||||
|
fn hash<H>(&self, state: &mut H)
|
||||||
|
where
|
||||||
|
H: Hasher,
|
||||||
|
{
|
||||||
|
self.name.hash(state)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
pub mod editor;
|
Loading…
Reference in New Issue