Switch from usize to u16 in terminal_size

This commit is contained in:
ticki 2016-05-03 19:42:37 +02:00
parent 451cb95ee2
commit 119cbda718
2 changed files with 11 additions and 11 deletions

View File

@ -3,17 +3,17 @@ extern crate termion;
use termion::{TermWrite, Color, Style};
use std::io::{self, Write};
const LINE_NUM_BG: Color = Color::Grayscale(5);
const LINE_NUM_BG: Color = Color::Grayscale(3);
const LINE_NUM_FG: Color = Color::Grayscale(18);
const ERROR_FG: Color = Color::Grayscale(17);
const INFO_LINE: &'static str = " ";
const INFO_LINE: &'static str = "| ";
fn main() {
let stdout = io::stdout();
let mut stdout = stdout.lock();
stdout.color(Color::LightGreen).unwrap();
stdout.write("—— src/test/ui/borrow-errors.rs at 82:18 ——\n".as_bytes()).unwrap();
stdout.write("-- src/test/ui/borrow-errors.rs at 82:18 --\n".as_bytes()).unwrap();
stdout.reset().unwrap();
stdout.color(Color::Red).unwrap();
@ -42,7 +42,7 @@ fn main() {
stdout.write(INFO_LINE.as_bytes()).unwrap();
stdout.reset().unwrap();
stdout.color(Color::Red).unwrap();
stdout.write(" ━━━ ".as_bytes()).unwrap();
stdout.write(" ^^^ ".as_bytes()).unwrap();
stdout.reset().unwrap();
stdout.color(ERROR_FG).unwrap();
@ -61,7 +61,7 @@ fn main() {
stdout.write(INFO_LINE.as_bytes()).unwrap();
stdout.reset().unwrap();
stdout.color(Color::Red).unwrap();
stdout.write(" ━━━ ".as_bytes()).unwrap();
stdout.write(" ^^^ ".as_bytes()).unwrap();
stdout.reset().unwrap();
stdout.color(ERROR_FG).unwrap();
@ -85,7 +85,7 @@ fn main() {
stdout.write(INFO_LINE.as_bytes()).unwrap();
stdout.reset().unwrap();
stdout.color(Color::Red).unwrap();
stdout.write(" ━━━ ".as_bytes()).unwrap();
stdout.write(" ^^^ ".as_bytes()).unwrap();
stdout.reset().unwrap();
stdout.color(ERROR_FG).unwrap();
@ -104,7 +104,7 @@ fn main() {
stdout.write(INFO_LINE.as_bytes()).unwrap();
stdout.reset().unwrap();
stdout.color(Color::Red).unwrap();
stdout.write(" ━━━ ".as_bytes()).unwrap();
stdout.write(" ^^^ ".as_bytes()).unwrap();
stdout.reset().unwrap();
stdout.color(ERROR_FG).unwrap();
@ -128,7 +128,7 @@ fn main() {
stdout.write(INFO_LINE.as_bytes()).unwrap();
stdout.reset().unwrap();
stdout.color(Color::Red).unwrap();
stdout.write(" ".as_bytes()).unwrap();
stdout.write(" ^ ".as_bytes()).unwrap();
stdout.reset().unwrap();
stdout.color(ERROR_FG).unwrap();

View File

@ -29,7 +29,7 @@ fn tiocgwinsz() -> u32 {
/// Get the size of the terminal.
#[cfg(not(target_os = "redox"))]
pub fn terminal_size() -> io::Result<(usize, usize)> {
pub fn terminal_size() -> io::Result<(u16, u16)> {
use libc::ioctl;
use libc::STDOUT_FILENO;
@ -38,7 +38,7 @@ pub fn terminal_size() -> io::Result<(usize, usize)> {
let mut size: TermSize = mem::zeroed();
if ioctl(STDOUT_FILENO, tiocgwinsz(), &mut size as *mut _) == 0 {
Ok((size.col as usize, size.row as usize))
Ok((size.col as u16, size.row as u16))
} else {
Err(io::Error::new(io::ErrorKind::Other, "Unable to get the terminal size."))
}
@ -47,7 +47,7 @@ pub fn terminal_size() -> io::Result<(usize, usize)> {
/// Get the size of the terminal.
#[cfg(target_os = "redox")]
pub fn terminal_size() -> io::Result<(usize, usize)> {
pub fn terminal_size() -> io::Result<(u16, u16)> {
use std::env;
let width = try!(env::var("COLUMNS").map_err(|x| io::Error::new(io::ErrorKind::NotFound, x))).parse().unwrap_or(0);