unix errors fixed
This commit is contained in:
parent
6970dfadd8
commit
54bab51976
@ -30,7 +30,6 @@ fn main() {
|
|||||||
let mut cursor = term.cursor();
|
let mut cursor = term.cursor();
|
||||||
cursor.goto(10, 10);
|
cursor.goto(10, 10);
|
||||||
cursor.print("test");
|
cursor.print("test");
|
||||||
term.terminal().set_size(20,20);
|
|
||||||
let mut color = term.color();
|
let mut color = term.color();
|
||||||
color.set_fg(Color::Red);
|
color.set_fg(Color::Red);
|
||||||
}
|
}
|
||||||
|
@ -8,18 +8,12 @@ use std::io::Result;
|
|||||||
|
|
||||||
pub mod shared_commands;
|
pub mod shared_commands;
|
||||||
|
|
||||||
#[cfg(target_os = "unix")]
|
#[cfg(not(target_os = "windows"))]
|
||||||
pub mod unix_command;
|
pub mod unix_command;
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
pub mod win_commands;
|
pub mod win_commands;
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
pub use self::win_commands::*;
|
|
||||||
#[cfg(target_os = "unix")]
|
|
||||||
pub use self::unix_commands::*;
|
|
||||||
|
|
||||||
pub use self::shared_commands::*;
|
|
||||||
|
|
||||||
/// This command is used for complex commands whits change the terminal state.
|
/// This command is used for complex commands whits change the terminal state.
|
||||||
/// By passing an `Context` instance this command will register it self to notify the terminal state change.
|
/// By passing an `Context` instance this command will register it self to notify the terminal state change.
|
||||||
|
@ -10,20 +10,11 @@ use std::io::{Result,Error, ErrorKind};
|
|||||||
|
|
||||||
/// This command is used for switching to NoncanonicalMode.
|
/// This command is used for switching to NoncanonicalMode.
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct NoncanonicalModeCommand {
|
pub struct NoncanonicalModeCommand;
|
||||||
key: u16,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl NoncanonicalModeCommand {
|
impl NoncanonicalModeCommand {
|
||||||
pub fn new(state_manager: &Mutex<StateManager>) -> u16 {
|
pub fn new() -> NoncanonicalModeCommand {
|
||||||
let mut state = state_manager.lock().unwrap();
|
NoncanonicalModeCommand { }
|
||||||
{
|
|
||||||
let key = state.get_changes_count();
|
|
||||||
let command = NoncanonicalModeCommand { key: key };
|
|
||||||
|
|
||||||
state.register_change(Box::from(command), key);
|
|
||||||
key
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,8 @@
|
|||||||
//! With these modes you can easier design the terminal screen.
|
//! With these modes you can easier design the terminal screen.
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
use common::commands::EnableRawModeCommand;
|
use common::commands::unix_command::EnableRawModeCommand;
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use common::commands::EnableRawModeCommand;
|
use common::commands::EnableRawModeCommand;
|
||||||
|
|
||||||
|
@ -3,12 +3,18 @@
|
|||||||
use libc;
|
use libc;
|
||||||
pub use libc::termios;
|
pub use libc::termios;
|
||||||
use self::libc::{c_int, c_ushort, ioctl, STDOUT_FILENO, TIOCGWINSZ};
|
use self::libc::{c_int, c_ushort, ioctl, STDOUT_FILENO, TIOCGWINSZ};
|
||||||
use common::commands::{NoncanonicalModeCommand, EnableRawModeCommand};
|
use common::commands::unix_command::{NoncanonicalModeCommand, EnableRawModeCommand};
|
||||||
|
|
||||||
use std::io::Error;
|
use std::io::Error;
|
||||||
use std::os::unix::io::AsRawFd;
|
use std::os::unix::io::AsRawFd;
|
||||||
use std::{fs, io, mem};
|
use std::{fs, io, mem};
|
||||||
use termios::{cfmakeraw, tcsetattr, Termios, TCSADRAIN};
|
use termios::{cfmakeraw, tcsetattr, Termios, TCSADRAIN};
|
||||||
|
use std::io::ErrorKind;
|
||||||
|
use std::io::Read;
|
||||||
|
use std::time::{SystemTime, Duration};
|
||||||
|
|
||||||
|
|
||||||
|
use Crossterm;
|
||||||
|
|
||||||
/// A representation of the size of the current terminal.
|
/// A representation of the size of the current terminal.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
@ -41,14 +47,9 @@ pub fn terminal_size() -> (u16, u16) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
use std::time::{SystemTime, Duration};
|
|
||||||
use std::io::ErrorKind;
|
|
||||||
use Terminal;
|
|
||||||
use std::io::Read;
|
|
||||||
/// Get the current cursor position.
|
/// Get the current cursor position.
|
||||||
pub fn pos() -> (u16, u16) {
|
pub fn pos() -> (u16, u16) {
|
||||||
let crossterm = Terminal::new();
|
let crossterm = Crossterm::new();
|
||||||
let input = crossterm.input();
|
let input = crossterm.input();
|
||||||
|
|
||||||
let delimiter = b'R';
|
let delimiter = b'R';
|
||||||
|
@ -21,7 +21,7 @@ impl<'terminal> TerminalColor<'terminal> {
|
|||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
let color = AnsiColor::new() as Box<ITerminalColor>;
|
let color = Box::from(AnsiColor::new()) as Box<ITerminalColor>;
|
||||||
|
|
||||||
TerminalColor {
|
TerminalColor {
|
||||||
color,
|
color,
|
||||||
|
@ -5,7 +5,7 @@ use super::{ScreenManager, Color, StyledObject};
|
|||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use super::super::Attribute;
|
use super::Attribute;
|
||||||
|
|
||||||
/// Struct that contains the style properties that can be applied to an displayable object.
|
/// Struct that contains the style properties that can be applied to an displayable object.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -5,7 +5,7 @@ use std::fmt::{self, Display};
|
|||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use super::super::Attribute;
|
use super::Attribute;
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use super::super::super::manager::WinApiScreenManager;
|
use super::super::super::manager::WinApiScreenManager;
|
||||||
@ -89,55 +89,55 @@ impl<'terminal,D: Display> StyledObject<'terminal,D> {
|
|||||||
/// Increase the font intensity.
|
/// Increase the font intensity.
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn bold(self) -> StyledObject<D> {
|
pub fn bold(self) -> StyledObject<'terminal,D> {
|
||||||
self.attr(Attribute::Bold)
|
self.attr(Attribute::Bold)
|
||||||
}
|
}
|
||||||
/// Faint (decreased intensity) (Not widely supported).
|
/// Faint (decreased intensity) (Not widely supported).
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn dim(self) -> StyledObject<D> {
|
pub fn dim(self) -> StyledObject<'terminal,D> {
|
||||||
self.attr(Attribute::Dim)
|
self.attr(Attribute::Dim)
|
||||||
}
|
}
|
||||||
/// Make the font italic (Not widely supported; Sometimes treated as inverse).
|
/// Make the font italic (Not widely supported; Sometimes treated as inverse).
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn italic(self) -> StyledObject<D> {
|
pub fn italic(self) -> StyledObject<'terminal,D> {
|
||||||
self.attr(Attribute::Italic)
|
self.attr(Attribute::Italic)
|
||||||
}
|
}
|
||||||
/// Underline font.
|
/// Underline font.
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn underlined(self) -> StyledObject<D> {
|
pub fn underlined(self) -> StyledObject<'terminal,D> {
|
||||||
self.attr(Attribute::Underlined)
|
self.attr(Attribute::Underlined)
|
||||||
}
|
}
|
||||||
/// Slow Blink (less than 150 per minute; not widely supported).
|
/// Slow Blink (less than 150 per minute; not widely supported).
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn slow_blink(self) -> StyledObject<D> {
|
pub fn slow_blink(self) -> StyledObject<'terminal,D> {
|
||||||
self.attr(Attribute::SlowBlink)
|
self.attr(Attribute::SlowBlink)
|
||||||
}
|
}
|
||||||
/// Rapid Blink (MS-DOS ANSI.SYS; 150+ per minute; not widely supported).
|
/// Rapid Blink (MS-DOS ANSI.SYS; 150+ per minute; not widely supported).
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn rapid_blink(self) -> StyledObject<D> {
|
pub fn rapid_blink(self) -> StyledObject<'terminal,D> {
|
||||||
self.attr(Attribute::RapidBlink)
|
self.attr(Attribute::RapidBlink)
|
||||||
}
|
}
|
||||||
/// Swap foreground and background colors.
|
/// Swap foreground and background colors.
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn reverse(self) -> StyledObject<D> {
|
pub fn reverse(self) -> StyledObject<'terminal,D> {
|
||||||
self.attr(Attribute::Reverse)
|
self.attr(Attribute::Reverse)
|
||||||
}
|
}
|
||||||
/// Hide text (Not widely supported).
|
/// Hide text (Not widely supported).
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn hidden(self) -> StyledObject<D> {
|
pub fn hidden(self) -> StyledObject<'terminal,D> {
|
||||||
self.attr(Attribute::Hidden)
|
self.attr(Attribute::Hidden)
|
||||||
}
|
}
|
||||||
/// Characters legible, but marked for deletion. Not widely supported.
|
/// Characters legible, but marked for deletion. Not widely supported.
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn crossed_out(self) -> StyledObject<D> {
|
pub fn crossed_out(self) -> StyledObject<'terminal,D> {
|
||||||
self.attr(Attribute::CrossedOut)
|
self.attr(Attribute::CrossedOut)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ impl<'terminal> Terminal<'terminal> {
|
|||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
let terminal = AnsiTerminal::new() as Box<ITerminal>;
|
let terminal = Box::from(AnsiTerminal::new()) as Box<ITerminal>;
|
||||||
|
|
||||||
Terminal {
|
Terminal {
|
||||||
terminal,
|
terminal,
|
||||||
|
Loading…
Reference in New Issue
Block a user