<commit_before>#![crate_name = "input"]
#![deny(missing_doc)]
#![feature(globs)]
#![feature(struct_variant)]

//! A flexible structure for user interactions
//! to be used in window frameworks and widgets libraries.

pub mod keyboard;
pub mod mouse;

/// Models different kinds of buttons.
#[deriving(Clone)]
pub enum Button {
    /// A keyboard button.
    Keyboard(keyboard::Key),
    /// A mouse button.
    Mouse(mouse::Button),
}

/// Models different kinds of motion.
#[deriving(Clone)]
pub enum Motion {
    /// x and y in window coordinates.
    MouseCursor(f64, f64),
    /// x and y in relative coordinates.
    MouseRelative(f64, f64),
    /// x and y in scroll ticks.
    MouseScroll(f64, f64),
}

/// Models input events.
#[deriving(Clone)]
pub enum InputEvent {
    /// Pressed a button.
    Press(Button),
    /// Released a button.
    Release(Button),
    /// Moved mouse cursor.
    Move(Motion),
    /// Text (usually from keyboard).
    Text(String),
}

<commit_msg>Derving Eq for Button<commit_after>#![crate_name = "input"]
#![deny(missing_doc)]
#![feature(globs)]
#![feature(struct_variant)]

//! A flexible structure for user interactions
//! to be used in window frameworks and widgets libraries.

pub mod keyboard;
pub mod mouse;

/// Models different kinds of buttons.
#[deriving(Clone, PartialEq, Eq)]
pub enum Button {
    /// A keyboard button.
    Keyboard(keyboard::Key),
    /// A mouse button.
    Mouse(mouse::Button),
}

/// Models different kinds of motion.
#[deriving(Clone)]
pub enum Motion {
    /// x and y in window coordinates.
    MouseCursor(f64, f64),
    /// x and y in relative coordinates.
    MouseRelative(f64, f64),
    /// x and y in scroll ticks.
    MouseScroll(f64, f64),
}

/// Models input events.
#[deriving(Clone)]
pub enum InputEvent {
    /// Pressed a button.
    Press(Button),
    /// Released a button.
    Release(Button),
    /// Moved mouse cursor.
    Move(Motion),
    /// Text (usually from keyboard).
    Text(String),
}

<|endoftext|>


<commit_before><commit_msg>version work<commit_after><|endoftext|>


<commit_before><commit_msg>Fixed entity allocation bug<commit_after><|endoftext|>


<commit_before><commit_msg>Rename Abs to Opaque<commit_after><|endoftext|>


<commit_before><commit_msg>Add doc examples for `Url::has_authority`.<commit_after><|endoftext|>


<commit_before><commit_msg>updated to use gclient<commit_after><|endoftext|>


<commit_before><commit_msg>Add test_heapsort<commit_after><|endoftext|>


<commit_before><commit_msg>cleanup: remove the I2CMaster trait<commit_after><|endoftext|>


<commit_before><commit_msg>add code to complete some of topics methods<commit_after><|endoftext|>


<commit_before>extern crate libc;

use std::ffi::{OsStr, OsString};
use std::fmt::Debug;
use std::fs::File;
use std::io;
use std::mem;
use std::os::unix::io::{FromRawFd, IntoRawFd, RawFd};
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio, Output};

pub trait Expression: Clone + Debug {
    fn exec(&self, context: IoContext) -> Result;

    fn run(&self) -> Result {
        let context = IoContext {
            stdin: CloneableStdio::Inherit,
            stdout: CloneableStdio::Inherit,
            stderr: CloneableStdio::Inherit,
        };
        self.exec(context)
    }
}

#[derive(Debug, Clone)]
pub struct ArgvCommand {
    argv: Vec<OsString>,
    stdout: Option<PathBuf>,
}

impl ArgvCommand {
    pub fn new<T: AsRef<OsStr>>(prog: T) -> ArgvCommand {
        ArgvCommand{
            argv: vec![prog.as_ref().to_owned()],
            stdout: None,
        }
    }

    pub fn arg<T: AsRef<OsStr>>(&mut self, arg: T) -> &mut Self {
        self.argv.push(arg.as_ref().to_owned());
        self
    }

    pub fn stdout<T: AsRef<Path>>(&mut self, path: T) -> &mut Self {
        self.stdout = Some(path.as_ref().to_owned());
        self
    }
}

impl Expression for ArgvCommand {
    fn exec(&self, context: IoContext) -> Result {
        let IoContext{stdin, stdout, stderr} = context;
        // Create a Command and add the args.
        let mut command = Command::new(&self.argv[0]);
        command.args(&self.argv[1..]);
        command.stdin(stdin.to_stdio());
        command.stdout(stdout.to_stdio());
        command.stderr(stderr.to_stdio());
        if let Some(ref path) = self.stdout {
            let file = try!(File::create(path));
            command.stdout(unsafe {
                FromRawFd::from_raw_fd(file.into_raw_fd())
            });
        }
        let exit_status = try!(command.status());
        Ok(Output{
            stdout: Vec::new(),
            stderr: Vec::new(),
            status: exit_status,
        })
    }
}

#[derive(Debug, Clone)]
pub struct Pipe {
    // TODO: Make this hold any Expression.
    left: ArgvCommand,
    right: ArgvCommand,
}

impl Pipe {
    pub fn new(left: &ArgvCommand, right: &ArgvCommand) -> Pipe {
        Pipe{left: left.clone(), right: right.clone()}
    }
}

impl Expression for Pipe {
    fn exec(&self, context: IoContext) -> Result {
        let IoContext{stdin, stdout, stderr} = context;
        let (read_pipe, write_pipe) = open_pipe();
        let left_context = IoContext{
            stdin: stdin,
            stdout: CloneableStdio::Fd(write_pipe),
            stderr: stderr.clone(),
        };
        let right_context = IoContext{
            stdin: CloneableStdio::Fd(read_pipe),
            stdout: stdout,
            stderr: stderr,
        };
        let left_clone = self.left.clone();
        let left_thread = std::thread::spawn(move || {
            left_clone.exec(left_context)
        });
        let right_result = self.right.exec(right_context);
        let left_result = left_thread.join().unwrap();  // TODO: handle errors here?
        match right_result {
            Err(_) => right_result,
            _ => left_result,
        }
    }
}

pub type Result = std::result::Result<Output, Error>;

#[derive(Debug)]
pub enum Error {
    Io(io::Error),
    Status(Output),
}

impl From<io::Error> for Error {
    fn from(err: io::Error) -> Error {
        Error::Io(err)
    }
}

#[derive(Clone, Debug)]
pub struct IoContext {
    stdin: CloneableStdio,
    stdout: CloneableStdio,
    stderr: CloneableStdio,
}

#[derive(Clone, Debug)]
enum CloneableStdio {
    Inherit,
    Fd(CloneableFd),
}

impl CloneableStdio {
    fn to_stdio(self) -> Stdio {
        match self {
            CloneableStdio::Inherit => Stdio::inherit(),
            CloneableStdio::Fd(fd) => unsafe {
                FromRawFd::from_raw_fd(fd.into_raw_fd())
            },
        }
    }
}

#[derive(Debug)]
struct CloneableFd {
    // The struct *owns* this file descriptor, and will close it in drop().
    fd: RawFd,
}

impl Clone for CloneableFd {
    fn clone(&self) -> Self {
        let new_fd = unsafe { libc::dup(self.fd) };
        assert!(new_fd >= 0);
        unsafe { FromRawFd::from_raw_fd(new_fd) }
    }
}

impl FromRawFd for CloneableFd {
    unsafe fn from_raw_fd(fd: RawFd) -> Self {
        CloneableFd{fd: fd}
    }
}

impl IntoRawFd for CloneableFd {
    fn into_raw_fd(self) -> RawFd {
        let fd = self.fd;
        mem::forget(self);  // prevent drop() from closing the fd
        fd
    }
}

impl Drop for CloneableFd {
    fn drop(&mut self) {
        let error = unsafe { libc::close(self.fd) };
        assert_eq!(error, 0);
    }
}

// (read, write)
// TODO: error handling
fn open_pipe() -> (CloneableFd, CloneableFd) {
    unsafe {
        let mut pipes = [0, 0];
        let error = libc::pipe(pipes.as_mut_ptr());
        assert_eq!(error, 0);
        // prevent child processes from inheriting these by default
        for fd in &pipes {
            let ret = libc::ioctl(*fd, libc::FIOCLEX);
            assert_eq!(ret, 0);
        }
        (FromRawFd::from_raw_fd(pipes[0]), FromRawFd::from_raw_fd(pipes[1]))
    }
}

#[cfg(test)]
mod test {
    use super::{ArgvCommand, Pipe, Expression};
    use std::fs::File;
    use std::io::prelude::*;
    use std::path::PathBuf;
    use std::process::Command;
    use std::str::from_utf8;

    fn mktemp() -> PathBuf {
        // TODO: use duct for this :)
        let output = Command::new("mktemp").output().unwrap();
        let path: PathBuf = from_utf8(&output.stdout).unwrap().trim().into();
        println!("here's the path we're using: {:?}", path);
        path
    }

    #[test]
    fn test_run() {
        let result = ArgvCommand::new("true").arg("foo").arg("bar").run();
        assert!(result.unwrap().status.success());
    }

    #[test]
    fn test_stdout() {
        let path = mktemp();
        let result = ArgvCommand::new("echo").arg("hi").stdout(&path).run();
        assert!(result.unwrap().status.success());
        let mut contents = String::new();
        File::open(&path).unwrap().read_to_string(&mut contents).unwrap();
        assert_eq!(contents, "hi\n");
    }

    #[test]
    fn test_pipe() {
        let mut left = ArgvCommand::new("echo");
        left.arg("hi");
        let mut right = ArgvCommand::new("sed");
        right.arg("s/i/o/");
        let path = mktemp();
        right.stdout(&path);
        let pipe = Pipe::new(&left, &right);
        let result = pipe.run();
        assert!(result.unwrap().status.success());
        let mut contents = String::new();
        File::open(&path).unwrap().read_to_string(&mut contents).unwrap();
        assert_eq!(contents, "ho\n");
    }
}
<commit_msg>define the .read() method to some approximation<commit_after>extern crate libc;

use std::ffi::{OsStr, OsString};
use std::fmt::Debug;
use std::fs::File;
use std::io;
use std::io::prelude::*;
use std::mem;
use std::os::unix::io::{FromRawFd, IntoRawFd, RawFd};
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio, Output, ExitStatus};
use std::thread::JoinHandle;

pub trait Expression: Clone + Debug {
    fn exec(&self, context: IoContext) -> io::Result<ExitStatus>;

    fn run(&self) -> Result<Output, Error> {
        let context = IoContext {
            stdin: CloneableStdio::Inherit,
            stdout: CloneableStdio::Inherit,
            stderr: CloneableStdio::Inherit,
        };
        let status = try!(self.exec(context));
        Ok(Output{
            status: status,
            stdout: Vec::new(),
            stderr: Vec::new(),
        })
    }

    fn read(&self) -> Result<String, Error> {
        let (stdout, stdout_reader) = pipe_with_reader_thread();
        let context = IoContext {
            stdin: CloneableStdio::Inherit,
            stdout: CloneableStdio::Fd(stdout),
            stderr: CloneableStdio::Inherit,
        };
        let status = try!(self.exec(context));
        let output = Output{
            status: status,
            stdout: try!(stdout_reader.join().unwrap()),
            stderr: Vec::new(),
        };
        if output.status.success() {
            // TODO: should only trim newlines
            Ok(try!(String::from_utf8(output.stdout)).trim_right().to_string())
        } else {
            Err(Error::Status(output))
        }
    }
}

#[derive(Debug, Clone)]
pub struct ArgvCommand {
    argv: Vec<OsString>,
    stdout: Option<PathBuf>,
}

impl ArgvCommand {
    pub fn new<T: AsRef<OsStr>>(prog: T) -> ArgvCommand {
        ArgvCommand{
            argv: vec![prog.as_ref().to_owned()],
            stdout: None,
        }
    }

    pub fn arg<T: AsRef<OsStr>>(&mut self, arg: T) -> &mut Self {
        self.argv.push(arg.as_ref().to_owned());
        self
    }

    pub fn stdout<T: AsRef<Path>>(&mut self, path: T) -> &mut Self {
        self.stdout = Some(path.as_ref().to_owned());
        self
    }
}

impl Expression for ArgvCommand {
    fn exec(&self, context: IoContext) -> io::Result<ExitStatus> {
        let IoContext{stdin, stdout, stderr} = context;
        // Create a Command and add the args.
        let mut command = Command::new(&self.argv[0]);
        command.args(&self.argv[1..]);
        command.stdin(stdin.to_stdio());
        command.stdout(stdout.to_stdio());
        command.stderr(stderr.to_stdio());
        if let Some(ref path) = self.stdout {
            let file = try!(File::create(path));
            command.stdout(unsafe {
                FromRawFd::from_raw_fd(file.into_raw_fd())
            });
        }
        Ok(try!(command.status()))
    }
}

#[derive(Debug, Clone)]
pub struct Pipe {
    // TODO: Make this hold any Expression.
    left: ArgvCommand,
    right: ArgvCommand,
}

impl Pipe {
    pub fn new(left: &ArgvCommand, right: &ArgvCommand) -> Pipe {
        Pipe{left: left.clone(), right: right.clone()}
    }
}

impl Expression for Pipe {
    fn exec(&self, context: IoContext) -> io::Result<ExitStatus> {
        let IoContext{stdin, stdout, stderr} = context;
        let (read_pipe, write_pipe) = open_pipe();
        let left_context = IoContext{
            stdin: stdin,
            stdout: CloneableStdio::Fd(write_pipe),
            stderr: stderr.clone(),
        };
        let right_context = IoContext{
            stdin: CloneableStdio::Fd(read_pipe),
            stdout: stdout,
            stderr: stderr,
        };
        let left_clone = self.left.clone();
        let left_thread = std::thread::spawn(move || {
            left_clone.exec(left_context)
        });
        let right_status = self.right.exec(right_context);
        let left_status = left_thread.join().unwrap();  // TODO: handle errors here?
        match right_status {
            Err(_) => right_status,
            _ => left_status,
        }
    }
}

#[derive(Debug)]
pub enum Error {
    Io(io::Error),
    Utf8(std::string::FromUtf8Error),
    Status(Output),
}

impl From<io::Error> for Error {
    fn from(err: io::Error) -> Error {
        Error::Io(err)
    }
}

impl From<std::string::FromUtf8Error> for Error {
    fn from(err: std::string::FromUtf8Error) -> Error {
        Error::Utf8(err)
    }
}

#[derive(Clone, Debug)]
pub struct IoContext {
    stdin: CloneableStdio,
    stdout: CloneableStdio,
    stderr: CloneableStdio,
}

#[derive(Clone, Debug)]
enum CloneableStdio {
    Inherit,
    Fd(CloneableFd),
}

impl CloneableStdio {
    fn to_stdio(self) -> Stdio {
        match self {
            CloneableStdio::Inherit => Stdio::inherit(),
            CloneableStdio::Fd(fd) => unsafe {
                FromRawFd::from_raw_fd(fd.into_raw_fd())
            },
        }
    }
}

#[derive(Debug)]
struct CloneableFd {
    // The struct *owns* this file descriptor, and will close it in drop().
    fd: RawFd,
}

impl Clone for CloneableFd {
    fn clone(&self) -> Self {
        let new_fd = unsafe { libc::dup(self.fd) };
        assert!(new_fd >= 0);
        unsafe { FromRawFd::from_raw_fd(new_fd) }
    }
}

impl FromRawFd for CloneableFd {
    unsafe fn from_raw_fd(fd: RawFd) -> Self {
        CloneableFd{fd: fd}
    }
}

impl IntoRawFd for CloneableFd {
    fn into_raw_fd(self) -> RawFd {
        let fd = self.fd;
        mem::forget(self);  // prevent drop() from closing the fd
        fd
    }
}

impl Drop for CloneableFd {
    fn drop(&mut self) {
        let error = unsafe { libc::close(self.fd) };
        assert_eq!(error, 0);
    }
}

// (read, write)
// TODO: error handling
fn open_pipe() -> (CloneableFd, CloneableFd) {
    unsafe {
        let mut pipes = [0, 0];
        let error = libc::pipe(pipes.as_mut_ptr());
        assert_eq!(error, 0);
        // prevent child processes from inheriting these by default
        for fd in &pipes {
            let ret = libc::ioctl(*fd, libc::FIOCLEX);
            assert_eq!(ret, 0);
        }
        (FromRawFd::from_raw_fd(pipes[0]), FromRawFd::from_raw_fd(pipes[1]))
    }
}

fn pipe_with_reader_thread() -> (CloneableFd, JoinHandle<io::Result<Vec<u8>>>) {
    let (read_pipe, write_pipe) = open_pipe();
    let thread = std::thread::spawn(move || {
        let mut read_file = unsafe { File::from_raw_fd(read_pipe.into_raw_fd()) };
        let mut output = Vec::new();
        try!(read_file.read_to_end(&mut output));
        Ok(output)
    });
    (write_pipe, thread)
}

#[cfg(test)]
mod test {
    use super::{ArgvCommand, Pipe, Expression};
    use std::fs::File;
    use std::io::prelude::*;
    use std::path::PathBuf;
    use std::process::Command;
    use std::str::from_utf8;

    fn mktemp() -> PathBuf {
        // TODO: use duct for this :)
        let output = Command::new("mktemp").output().unwrap();
        let path: PathBuf = from_utf8(&output.stdout).unwrap().trim().into();
        println!("here's the path we're using: {:?}", path);
        path
    }

    #[test]
    fn test_run() {
        let result = ArgvCommand::new("true").arg("foo").arg("bar").run();
        assert!(result.unwrap().status.success());
    }

    #[test]
    fn test_read() {
        let output = ArgvCommand::new("echo").arg("hi").read().unwrap();
        assert_eq!(output, "hi");
    }

    #[test]
    fn test_stdout() {
        let path = mktemp();
        let result = ArgvCommand::new("echo").arg("hi").stdout(&path).run();
        assert!(result.unwrap().status.success());
        let mut contents = String::new();
        File::open(&path).unwrap().read_to_string(&mut contents).unwrap();
        assert_eq!(contents, "hi\n");
    }

    #[test]
    fn test_pipe() {
        let mut left = ArgvCommand::new("echo");
        left.arg("hi");
        let mut right = ArgvCommand::new("sed");
        right.arg("s/i/o/");
        let pipe = Pipe::new(&left, &right);
        let output = pipe.read().unwrap();
        assert_eq!(output, "ho");
    }
}
<|endoftext|>


<commit_before><commit_msg>connect to rewarders on all children<commit_after><|endoftext|>


<commit_before><commit_msg>Accept closure (not reference to closure)<commit_after><|endoftext|>


<commit_before><commit_msg>event.rs in lib.rs<commit_after><|endoftext|>


<commit_before><commit_msg>Re-add accidentally deleted xcb.rs<commit_after>/*
Copyright (C) 2013 James Miller <james@aatch.net>

Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

*/

#[link(name="xcb",
       vers="0.3",
       uuid="ef466d26-0620-4f5f-a1d2-1bb9c628e101",
       url= "https://github.com/Aatch/rust-xcb")];

#[license = "MIT"];
#[crate_type="lib"];

pub mod ffi {
    pub mod xproto;
    pub mod base;

    pub mod bigreq;
    pub mod composite;
    pub mod damage;
    pub mod dpms;
    pub mod dri2;

    //pub mod ge; not sure about this one...

    pub mod glx;
    pub mod randr;
    pub mod record;
    pub mod render;
    pub mod screensaver;
    pub mod shape;
    pub mod shm;
    pub mod sync;
    pub mod xc_misc;
    pub mod xevie;
    pub mod xf86dri;
    //pub mod xf86vidmode; Same with this one...
    pub mod xfixes;
    pub mod xinerama;
    pub mod xinput;
    //pub mod xkb;
    pub mod xprint;

    #[cfg(enable_xselinux)]
    pub mod xselinux;
    pub mod xtest;
    pub mod xv;
    pub mod xvmc;
}

pub mod base;
pub mod macro;

pub mod xproto;

pub mod xinerama;

pub mod bigreq;
pub mod composite;
pub mod xfixes;
pub mod render;
pub mod shape;
/*
pub mod damage;
pub mod dpms;
pub mod dri2;

//pub mod ge; not sure about this one...

pub mod glx;
pub mod randr;
pub mod record;
pub mod screensaver;
pub mod shm;
pub mod sync;
pub mod xc_misc;
pub mod xevie;
pub mod xf86dri;
//pub mod xf86vidmode; Same with this one...
pub mod xinput;
//pub mod xkb;
pub mod xprint;

#[cfg(enable_xselinux)]
pub mod xselinux;
pub mod xtest;
pub mod xv;
pub mod xvmc;
*/
<|endoftext|>


<commit_before><commit_msg>04 - declare first<commit_after>fn main() {
    // Declare a variable
    let a_variable;

    {
        let x = 2i;

        // Initialize the variable
        a_variable = x * x;
    }

    println!("a variable: {}", a_variable);

    let another_variable;

    // Error! Use of uninitialized variable
    // println!("another variable: {}", another_variable);

    another_variable = 1i;

    println!("another variable: {}", another_variable);
}
<|endoftext|>


<commit_before><commit_msg>Add brainfuck interpreter<commit_after>use self::Command::*;

struct Tape {
	array: [isize; 30000],
	pos: usize
}

impl Tape {
	fn new() -> Tape {
		Tape {
			array: [0; 30000],
			pos: 0
		}
	}

	fn run(&mut self, commands: &[Command]) {
		for command in commands.iter() {
			match *command {
				IncrementPos => self.pos += 1,
				DecrementPos => self.pos -= 1,
				IncrementByte => self.array[self.pos] += 1,
				DecrementByte => self.array[self.pos] -= 1,
				OutputByte => print!("{}", self.array[self.pos] as u8 as char),
				InputByte => unimplemented!(),
				Loop(ref command_loop) => while self.array[self.pos] != 0 {
					self.run(&command_loop)
				}
			}
		}
	}
}

enum Command {
	IncrementPos,
	DecrementPos,
	IncrementByte,
	DecrementByte,
	OutputByte,
	InputByte,
	Loop(Vec<Command>)
}

trait ParseBrainfuck {
	fn parse(&self) -> Vec<Command>;
	fn _parse(&self) -> (Vec<Command>, u32);
}

impl<'a> ParseBrainfuck for &'a [u8] {
	fn parse(&self) -> Vec<Command> {
		let sanitized: Vec<u8> = (**self).iter().filter(|&c| b"><+-.,[]".contains(c)).map(|&c| c).collect();
		(&*sanitized)._parse().0
	}

	fn _parse(&self) -> (Vec<Command>, u32) {
		let mut commands = Vec::new();
		let len = self.len();
		let mut index = 0;

		while index < len {
			match self[index] {
				b'>' => commands.push(IncrementPos),
				b'<' => commands.push(DecrementPos),
				b'+' => commands.push(IncrementByte),
				b'-' => commands.push(DecrementByte),
				b'.' => commands.push(OutputByte),
				b',' => commands.push(InputByte),
				b'[' => {
					index += 1;
					let (parsed, count) = (&self[index..])._parse();
					commands.push(Loop(parsed));
					index += count as usize;
				},
				b']' => break,
				_ => unreachable!()
			}
			index += 1;
		}

		(commands, index as u32)
	}
}

fn main() {
	let mut tape = Tape::new();
//	let helloworld = b"++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.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>++++++>++++++++[-<++++<++++<++++>>>]++++++[-<+++<+++<+++>>>]>>-->---+[-<+]-<[+[->+]-<<->>>+>[-]++[-->++]-->+++[---++[--<++]---->>-<+>[++++[----<++++]--[>]++[-->++]--<]>++[--+[-<+]->>[-]+++++[---->++++]-->[->+<]>>[.>]++[-->++]]-->+++]---+[-<+]->>-[+>>>+[-<+]->>>++++++++++<<[->+>-[>+>>]>[+[-<+>]>+>>]<<<<<<]>>[-]>>>++++++++++<[->-[>+>>]>[+[-<+>]>+>>]<<<<<]>[-]>>[>++++++[-<++++++++>]<.<<+>+>[-]]<[<[->-<]++++++[->++++++++<]>.[-]]<<++++++[-<++++++++>]<.[-]<<[-<+>]+[-<+]->>]+[-]<<<.>>>+[-<+]-<<]";

	let program = fizzbuzz.as_ref().parse();

	tape.run(&program);
}<|endoftext|>


<commit_before>use redox::Box;
use redox::{self, cmp, env};
use redox::collections::BTreeMap;
use redox::fs::{self, File};
use redox::io::{Read, Seek, SeekFrom};
use redox::time::{self, Duration};
use redox::vec::Vec;
use redox::string::{String, ToString};

use orbital::{event, BmpFile, Color, EventOption, MouseEvent, Window};

struct FileType {
    description: &'static str,
    icon: BmpFile,
}

impl FileType {
    fn new(desc: &'static str, icon: &str) -> FileType {
        FileType { description: desc, icon: load_icon(icon) }
    }

}

struct FileTypesInfo {
    file_types: BTreeMap<&'static str, FileType>,
}

impl FileTypesInfo {
    pub fn new () -> FileTypesInfo {
        let mut file_types = BTreeMap::<&'static str, FileType>::new();
        file_types.insert("/",
                          FileType::new("Folder", "inode-directory"));
        file_types.insert("wav",
                          FileType::new("WAV audio", "audio-x-wav"));
        file_types.insert("bin",
                          FileType::new("Executable", "application-x-executable"));
        file_types.insert("bmp",
                          FileType::new("Bitmap Image", "image-x-generic"));
        file_types.insert("rs",
                          FileType::new("Rust source code", "text-x-makefile"));
        file_types.insert("crate",
                          FileType::new("Rust crate", "application-x-archive"));
        file_types.insert("rlib",
                          FileType::new("Static Rust library", "application-x-object"));
        file_types.insert("asm",
                          FileType::new("Assembly source", "text-x-makefile"));
        file_types.insert("list",
                          FileType::new("Disassembly source", "text-x-makefile"));
        file_types.insert("c",
                          FileType::new("C source code", "text-x-csrc"));
        file_types.insert("cpp",
                          FileType::new("C++ source code", "text-x-c++src"));
        file_types.insert("h",
                          FileType::new("C header", "text-x-chdr"));
        file_types.insert("sh",
                          FileType::new("Shell script", "text-x-script"));
        file_types.insert("lua",
                          FileType::new("Lua script", "text-x-script"));
        file_types.insert("txt",
                          FileType::new("Plain text document", "text-x-generic"));
        file_types.insert("md",
                          FileType::new("Markdown document", "text-x-generic"));
        file_types.insert("toml",
                          FileType::new("TOML document", "text-x-generic"));
        file_types.insert("json",
                          FileType::new("JSON document", "text-x-generic"));
        file_types.insert("REDOX",
                          FileType::new("Redox package", "text-x-generic"));
        file_types.insert("",
                          FileType::new("Unknown file", "unknown"));
        FileTypesInfo { file_types: file_types }
    }

    pub fn description_for(&self, file_name: &str) -> String {
        if file_name.ends_with('/') {
            self.file_types["/"].description.to_string()
        } else {
            let pos = file_name.rfind('.').unwrap_or(0) + 1;
            let ext = &file_name[pos..];
            if self.file_types.contains_key(ext) {
                self.file_types[ext].description.to_string()
            } else {
                self.file_types[""].description.to_string()
            }
        }
    }

    pub fn icon_for(&self, file_name: &str) -> &BmpFile {
        if file_name.ends_with('/') {
            &self.file_types["/"].icon
        } else {
            let pos = file_name.rfind('.').unwrap_or(0) + 1;
            let ext = &file_name[pos..];
            if self.file_types.contains_key(ext) {
                &self.file_types[ext].icon
            } else {
                &self.file_types[""].icon
            }
        }
    }
}

enum FileManagerCommand {
    ChangeDir(String),
    Execute(String),
    Redraw,
    Quit,
}

pub struct FileManager {
    file_types_info: FileTypesInfo,
    files: Vec<String>,
    file_sizes: Vec<String>,
    selected: isize,
    last_mouse_event: MouseEvent,
    click_time: Duration,
    window: Box<Window>,
}

fn load_icon(path: &str) -> BmpFile {
    let mut vec: Vec<u8> = Vec::new();
    if let Some(mut file) = File::open(&("file:///ui/mimetypes/".to_string() + path + ".bmp")) {
        file.read_to_end(&mut vec);
    }
    BmpFile::from_data(&vec)
}

impl FileManager {
    pub fn new() -> Self {
        FileManager {
            file_types_info: FileTypesInfo::new(),
            files: Vec::new(),
            file_sizes: Vec::new(),
            selected: -1,
            last_mouse_event: MouseEvent {
                x: 0,
                y: 0,
                left_button: false,
                middle_button: false,
                right_button: false,
            },
            click_time: Duration::new(0, 0),
            window: Window::new(-1,-1,0,0,"").unwrap(),
        }
    }

    fn draw_content(&mut self) {
        self.window.set(Color::WHITE);

        let mut i = 0;
        let mut row = 0;
        let column = {
            let mut tmp = [0, 0];
            for string in self.files.iter() {
                if tmp[0] < string.len() {
                    tmp[0] = string.len();
                }
            }

            tmp[0] += 1;

            for file_size in self.file_sizes.iter() {
                if tmp[1] < file_size.len() {
                    tmp[1] = file_size.len();
                }
            }

            tmp[1] += tmp[0] + 1;
            tmp
        };
        for (file_name, file_size) in self.files.iter().zip(self.file_sizes.iter()) {
            if i == self.selected {
                let width = self.window.width();
                self.window.rect(0, 32 * row as isize, width, 32, Color::rgba(224, 224, 224, 255));
            }

            let icon = self.file_types_info.icon_for(&file_name);
            self.window.image(0,
                              32 * row as isize,
                              icon.width(),
                              icon.height(),
                              icon.as_slice());

            let mut col = 0;
            for c in file_name.chars() {
                if c == '\n' {
                    col = 0;
                    row += 1;
                } else if c == '\t' {
                    col += 8 - col % 8;
                } else {
                    if col < self.window.width() / 8 && row < self.window.height() / 32 {
                        self.window.char(8 * col as isize + 40,
                                    32 * row as isize + 8,
                                    c,
                                    Color::BLACK);
                        col += 1;
                    }
                }
                if col >= self.window.width() / 8 {
                    col = 0;
                    row += 1;
                }
            }

            col = column[0];

            for c in file_size.chars() {
                if c == '\n' {
                    col = 0;
                    row += 1;
                } else if c == '\t' {
                    col += 8 - col % 8;
                } else {
                    if col < self.window.width() / 8 && row < self.window.height() / 32 {
                        self.window.char(8 * col as isize + 40,
                                    32 * row as isize + 8,
                                    c,
                                    Color::BLACK);
                        col += 1;
                    }
                }
                if col >= self.window.width() / 8 {
                    col = 0;
                    row += 1;
                }
            }

            col = column[1];

            let description = self.file_types_info.description_for(&file_name);
            for c in description.chars() {
                if c == '\n' {
                    col = 0;
                    row += 1;
                } else if c == '\t' {
                    col += 8 - col % 8;
                } else {
                    if col < self.window.width() / 8 && row < self.window.height() / 32 {
                        self.window.char(8 * col as isize + 40,
                                    32 * row as isize + 8,
                                    c,
                                    Color::BLACK);
                        col += 1;
                    }
                }
                if col >= self.window.width() / 8 {
                    col = 0;
                    row += 1;
                }
            }

            row += 1;
            i += 1;
        }

        self.window.sync();
    }

    fn set_path(&mut self, path: &str) {
        let mut width = [48, 48, 48];
        let mut height = 0;
        if let Some(readdir) = fs::read_dir(path) {
            self.files.clear();
            for entry in readdir {
                self.files.push(entry.path().to_string());
                self.file_sizes.push(
                    // When the entry is a folder
                    if entry.path().ends_with('/') {
                        let count = match fs::read_dir(&(path.to_string() + entry.path())) {
                            Some(entry_readdir) => entry_readdir.count(),
                            None => 0
                        };

                        if count == 1 {
                            "1 entry".to_string()
                        } else {
                            format!("{} entries", count)
                        }
                    } else {
                        match File::open(&(path.to_string() + entry.path())) {
                            Some(mut file) => match file.seek(SeekFrom::End(0)) {
                                Some(size) => {
                                    if size >= 1_000_000_000 {
                                        format!("{:.1} GB", (size as f64)/1_000_000_000.0)
                                    } else if size >= 1_000_000 {
                                        format!("{:.1} MB", (size as f64)/1_000_000.0)
                                    } else if size >= 1_000 {
                                        format!("{:.1} KB", (size as f64)/1_000.0)
                                    } else {
                                        format!("{:.1} bytes", size)
                                    }
                                }
                                None => "Failed to seek".to_string()
                            },
                            None => "Failed to open".to_string()
                        }
                    }
                );
                // Unwrapping the last file size will not panic since it has
                // been at least pushed once in the vector
                let description = self.file_types_info.description_for(entry.path());
                width[0] = cmp::max(width[0], 48 + (entry.path().len()) * 8);
                width[1] = cmp::max(width[1], 8 + (self.file_sizes.last().unwrap().len()) * 8);
                width[2] = cmp::max(width[2], 8 + (description.len()) * 8);
            }

            if height < self.files.len() * 32 {
                height = self.files.len() * 32;
            }
        }
        // TODO: HACK ALERT - should use resize whenver that gets added
        self.window = Window::new(self.window.x(),
                                  self.window.y(),
                                  width.iter().sum(),
                                  height,
                                  &path).unwrap();
        self.draw_content();
    }

    fn event_loop(&mut self) -> Option<FileManagerCommand> {
        let mut redraw = false;
        let mut command = None;
        if let Some(event) = self.window.poll() {
            match event.to_option() {
                EventOption::Key(key_event) => {
                    if key_event.pressed {
                        match key_event.scancode {
                            event::K_ESC => return Some(FileManagerCommand::Quit),
                            event::K_HOME => self.selected = 0,
                            event::K_UP => if self.selected > 0 {
                                self.selected -= 1;
                                redraw = true
                            },
                            event::K_END => self.selected = self.files.len() as isize - 1,
                            event::K_DOWN => if self.selected < self.files.len() as isize - 1 {
                                self.selected += 1;
                            },
                            _ => match key_event.character {
                                '\0' => (),
                                '\n' => {
                                    if self.selected >= 0 &&
                                       self.selected < self.files.len() as isize {
                                        match self.files.get(self.selected as usize) {
                                            Some(file) => {
                                                if file.ends_with('/') {
                                                    command = Some(FileManagerCommand::ChangeDir(file.clone()));
                                                } else {
                                                    command = Some(FileManagerCommand::Execute(file.clone()));
                                                }
                                            },
                                            None => (),
                                        }
                                    }
                                }
                                _ => {
                                    let mut i = 0;
                                    for file in self.files.iter() {
                                        if file.starts_with(key_event.character) {
                                            self.selected = i;
                                            break;
                                        }
                                        i += 1;
                                    }
                                }
                            },
                        }
                        if command.is_none() && redraw {
                            command = Some(FileManagerCommand::Redraw);
                        }
                    }
                }
                EventOption::Mouse(mouse_event) => {
                    let mut redraw = false;
                    let mut i = 0;
                    let mut row = 0;
                    for file in self.files.iter() {
                        let mut col = 0;
                        for c in file.chars() {
                            if mouse_event.y >= 32 * row as isize &&
                               mouse_event.y < 32 * row as isize + 32 {
                                self.selected = i;
                            }

                            if c == '\n' {
                                col = 0;
                                row += 1;
                            } else if c == '\t' {
                                col += 8 - col % 8;
                            } else {
                                if col < self.window.width() / 8 && row < self.window.height() / 32 {
                                    col += 1;
                                }
                            }
                            if col >= self.window.width() / 8 {
                                col = 0;
                                row += 1;
                            }
                        }
                        row += 1;
                        i += 1; }

                    //Check for double click
                    if mouse_event.left_button {
                        let click_time = Duration::realtime();

                        if click_time - self.click_time < Duration::new(0, 500 * time::NANOS_PER_MILLI)
                            && self.last_mouse_event.x == mouse_event.x
                            && self.last_mouse_event.y == mouse_event.y {
                            if self.selected >= 0 && self.selected < self.files.len() as isize {
                                if let Some(file) = self.files.get(self.selected as usize) {
                                    if file.ends_with('/') {
                                        command = Some(FileManagerCommand::ChangeDir(file.clone()));
                                    } else {
                                        command = Some(FileManagerCommand::Execute(file.clone()));
                                    }
                                }
                            }
                            self.click_time = Duration::new(0, 0);
                        } else {
                            self.click_time = click_time;
                        }
                    }
                    self.last_mouse_event = mouse_event;
                }
                EventOption::Quit(quit_event) => command = Some(FileManagerCommand::Quit),
                _ => (),
            }
        }
        command
    }

    fn main(&mut self, path: &str) {
        let mut current_path = path.to_string();
        self.set_path(path);
        while true {
            match self.event_loop() {
                Some(event) => {
                    match event {
                        FileManagerCommand::ChangeDir(dir) => {
                            current_path = current_path + &dir;
                            self.set_path(&current_path);
                        },
                        FileManagerCommand::Execute(cmd) => { File::exec(&(current_path.clone() + &cmd)); } ,
                        FileManagerCommand::Redraw => (),
                        FileManagerCommand::Quit => break,
                    };
                    self.draw_content();
                },
                None => (),
            };
        }

    }
}

pub fn main() {
    match env::args().get(1) {
        Some(arg) => FileManager::new().main(arg),
        None => FileManager::new().main("file:///"),
    }
}
<commit_msg>Fix file manager redraw<commit_after>use redox::Box;
use redox::{self, cmp, env};
use redox::collections::BTreeMap;
use redox::fs::{self, File};
use redox::io::{Read, Seek, SeekFrom};
use redox::time::{self, Duration};
use redox::vec::Vec;
use redox::string::{String, ToString};

use orbital::{event, BmpFile, Color, EventOption, MouseEvent, Window};

struct FileType {
    description: &'static str,
    icon: BmpFile,
}

impl FileType {
    fn new(desc: &'static str, icon: &str) -> FileType {
        FileType { description: desc, icon: load_icon(icon) }
    }

}

struct FileTypesInfo {
    file_types: BTreeMap<&'static str, FileType>,
}

impl FileTypesInfo {
    pub fn new () -> FileTypesInfo {
        let mut file_types = BTreeMap::<&'static str, FileType>::new();
        file_types.insert("/",
                          FileType::new("Folder", "inode-directory"));
        file_types.insert("wav",
                          FileType::new("WAV audio", "audio-x-wav"));
        file_types.insert("bin",
                          FileType::new("Executable", "application-x-executable"));
        file_types.insert("bmp",
                          FileType::new("Bitmap Image", "image-x-generic"));
        file_types.insert("rs",
                          FileType::new("Rust source code", "text-x-makefile"));
        file_types.insert("crate",
                          FileType::new("Rust crate", "application-x-archive"));
        file_types.insert("rlib",
                          FileType::new("Static Rust library", "application-x-object"));
        file_types.insert("asm",
                          FileType::new("Assembly source", "text-x-makefile"));
        file_types.insert("list",
                          FileType::new("Disassembly source", "text-x-makefile"));
        file_types.insert("c",
                          FileType::new("C source code", "text-x-csrc"));
        file_types.insert("cpp",
                          FileType::new("C++ source code", "text-x-c++src"));
        file_types.insert("h",
                          FileType::new("C header", "text-x-chdr"));
        file_types.insert("sh",
                          FileType::new("Shell script", "text-x-script"));
        file_types.insert("lua",
                          FileType::new("Lua script", "text-x-script"));
        file_types.insert("txt",
                          FileType::new("Plain text document", "text-x-generic"));
        file_types.insert("md",
                          FileType::new("Markdown document", "text-x-generic"));
        file_types.insert("toml",
                          FileType::new("TOML document", "text-x-generic"));
        file_types.insert("json",
                          FileType::new("JSON document", "text-x-generic"));
        file_types.insert("REDOX",
                          FileType::new("Redox package", "text-x-generic"));
        file_types.insert("",
                          FileType::new("Unknown file", "unknown"));
        FileTypesInfo { file_types: file_types }
    }

    pub fn description_for(&self, file_name: &str) -> String {
        if file_name.ends_with('/') {
            self.file_types["/"].description.to_string()
        } else {
            let pos = file_name.rfind('.').unwrap_or(0) + 1;
            let ext = &file_name[pos..];
            if self.file_types.contains_key(ext) {
                self.file_types[ext].description.to_string()
            } else {
                self.file_types[""].description.to_string()
            }
        }
    }

    pub fn icon_for(&self, file_name: &str) -> &BmpFile {
        if file_name.ends_with('/') {
            &self.file_types["/"].icon
        } else {
            let pos = file_name.rfind('.').unwrap_or(0) + 1;
            let ext = &file_name[pos..];
            if self.file_types.contains_key(ext) {
                &self.file_types[ext].icon
            } else {
                &self.file_types[""].icon
            }
        }
    }
}

enum FileManagerCommand {
    ChangeDir(String),
    Execute(String),
    Redraw,
    Quit,
}

pub struct FileManager {
    file_types_info: FileTypesInfo,
    files: Vec<String>,
    file_sizes: Vec<String>,
    selected: isize,
    last_mouse_event: MouseEvent,
    click_time: Duration,
    window: Box<Window>,
}

fn load_icon(path: &str) -> BmpFile {
    let mut vec: Vec<u8> = Vec::new();
    if let Some(mut file) = File::open(&("file:///ui/mimetypes/".to_string() + path + ".bmp")) {
        file.read_to_end(&mut vec);
    }
    BmpFile::from_data(&vec)
}

impl FileManager {
    pub fn new() -> Self {
        FileManager {
            file_types_info: FileTypesInfo::new(),
            files: Vec::new(),
            file_sizes: Vec::new(),
            selected: -1,
            last_mouse_event: MouseEvent {
                x: 0,
                y: 0,
                left_button: false,
                middle_button: false,
                right_button: false,
            },
            click_time: Duration::new(0, 0),
            window: Window::new(-1,-1,0,0,"").unwrap(),
        }
    }

    fn draw_content(&mut self) {
        self.window.set(Color::WHITE);

        let mut i = 0;
        let mut row = 0;
        let column = {
            let mut tmp = [0, 0];
            for string in self.files.iter() {
                if tmp[0] < string.len() {
                    tmp[0] = string.len();
                }
            }

            tmp[0] += 1;

            for file_size in self.file_sizes.iter() {
                if tmp[1] < file_size.len() {
                    tmp[1] = file_size.len();
                }
            }

            tmp[1] += tmp[0] + 1;
            tmp
        };
        for (file_name, file_size) in self.files.iter().zip(self.file_sizes.iter()) {
            if i == self.selected {
                let width = self.window.width();
                self.window.rect(0, 32 * row as isize, width, 32, Color::rgba(224, 224, 224, 255));
            }

            let icon = self.file_types_info.icon_for(&file_name);
            self.window.image(0,
                              32 * row as isize,
                              icon.width(),
                              icon.height(),
                              icon.as_slice());

            let mut col = 0;
            for c in file_name.chars() {
                if c == '\n' {
                    col = 0;
                    row += 1;
                } else if c == '\t' {
                    col += 8 - col % 8;
                } else {
                    if col < self.window.width() / 8 && row < self.window.height() / 32 {
                        self.window.char(8 * col as isize + 40,
                                    32 * row as isize + 8,
                                    c,
                                    Color::BLACK);
                        col += 1;
                    }
                }
                if col >= self.window.width() / 8 {
                    col = 0;
                    row += 1;
                }
            }

            col = column[0];

            for c in file_size.chars() {
                if c == '\n' {
                    col = 0;
                    row += 1;
                } else if c == '\t' {
                    col += 8 - col % 8;
                } else {
                    if col < self.window.width() / 8 && row < self.window.height() / 32 {
                        self.window.char(8 * col as isize + 40,
                                    32 * row as isize + 8,
                                    c,
                                    Color::BLACK);
                        col += 1;
                    }
                }
                if col >= self.window.width() / 8 {
                    col = 0;
                    row += 1;
                }
            }

            col = column[1];

            let description = self.file_types_info.description_for(&file_name);
            for c in description.chars() {
                if c == '\n' {
                    col = 0;
                    row += 1;
                } else if c == '\t' {
                    col += 8 - col % 8;
                } else {
                    if col < self.window.width() / 8 && row < self.window.height() / 32 {
                        self.window.char(8 * col as isize + 40,
                                    32 * row as isize + 8,
                                    c,
                                    Color::BLACK);
                        col += 1;
                    }
                }
                if col >= self.window.width() / 8 {
                    col = 0;
                    row += 1;
                }
            }

            row += 1;
            i += 1;
        }

        self.window.sync();
    }

    fn set_path(&mut self, path: &str) {
        let mut width = [48, 48, 48];
        let mut height = 0;
        if let Some(readdir) = fs::read_dir(path) {
            self.files.clear();
            for entry in readdir {
                self.files.push(entry.path().to_string());
                self.file_sizes.push(
                    // When the entry is a folder
                    if entry.path().ends_with('/') {
                        let count = match fs::read_dir(&(path.to_string() + entry.path())) {
                            Some(entry_readdir) => entry_readdir.count(),
                            None => 0
                        };

                        if count == 1 {
                            "1 entry".to_string()
                        } else {
                            format!("{} entries", count)
                        }
                    } else {
                        match File::open(&(path.to_string() + entry.path())) {
                            Some(mut file) => match file.seek(SeekFrom::End(0)) {
                                Some(size) => {
                                    if size >= 1_000_000_000 {
                                        format!("{:.1} GB", (size as f64)/1_000_000_000.0)
                                    } else if size >= 1_000_000 {
                                        format!("{:.1} MB", (size as f64)/1_000_000.0)
                                    } else if size >= 1_000 {
                                        format!("{:.1} KB", (size as f64)/1_000.0)
                                    } else {
                                        format!("{:.1} bytes", size)
                                    }
                                }
                                None => "Failed to seek".to_string()
                            },
                            None => "Failed to open".to_string()
                        }
                    }
                );
                // Unwrapping the last file size will not panic since it has
                // been at least pushed once in the vector
                let description = self.file_types_info.description_for(entry.path());
                width[0] = cmp::max(width[0], 48 + (entry.path().len()) * 8);
                width[1] = cmp::max(width[1], 8 + (self.file_sizes.last().unwrap().len()) * 8);
                width[2] = cmp::max(width[2], 8 + (description.len()) * 8);
            }

            if height < self.files.len() * 32 {
                height = self.files.len() * 32;
            }
        }
        // TODO: HACK ALERT - should use resize whenver that gets added
        self.window = Window::new(self.window.x(),
                                  self.window.y(),
                                  width.iter().sum(),
                                  height,
                                  &path).unwrap();
        self.draw_content();
    }

    fn event_loop(&mut self) -> Option<FileManagerCommand> {
        let mut redraw = false;
        let mut command = None;
        if let Some(event) = self.window.poll() {
            match event.to_option() {
                EventOption::Key(key_event) => {
                    if key_event.pressed {
                        match key_event.scancode {
                            event::K_ESC => return Some(FileManagerCommand::Quit),
                            event::K_HOME => self.selected = 0,
                            event::K_UP => if self.selected > 0 {
                                self.selected -= 1;
                                redraw = true;
                            },
                            event::K_END => self.selected = self.files.len() as isize - 1,
                            event::K_DOWN => if self.selected < self.files.len() as isize - 1 {
                                self.selected += 1;
                                redraw = true;
                            },
                            _ => match key_event.character {
                                '\0' => (),
                                '\n' => {
                                    if self.selected >= 0 &&
                                       self.selected < self.files.len() as isize {
                                        match self.files.get(self.selected as usize) {
                                            Some(file) => {
                                                if file.ends_with('/') {
                                                    command = Some(FileManagerCommand::ChangeDir(file.clone()));
                                                } else {
                                                    command = Some(FileManagerCommand::Execute(file.clone()));
                                                }
                                            },
                                            None => (),
                                        }
                                    }
                                }
                                _ => {
                                    let mut i = 0;
                                    for file in self.files.iter() {
                                        if file.starts_with(key_event.character) {
                                            self.selected = i;
                                            break;
                                        }
                                        i += 1;
                                    }
                                }
                            },
                        }
                        if command.is_none() && redraw {
                            command = Some(FileManagerCommand::Redraw);
                        }
                    }
                }
                EventOption::Mouse(mouse_event) => {
                    redraw = true;
                    let mut i = 0;
                    let mut row = 0;
                    for file in self.files.iter() {
                        let mut col = 0;
                        for c in file.chars() {
                            if mouse_event.y >= 32 * row as isize &&
                               mouse_event.y < 32 * row as isize + 32 {
                                self.selected = i;
                            }

                            if c == '\n' {
                                col = 0;
                                row += 1;
                            } else if c == '\t' {
                                col += 8 - col % 8;
                            } else {
                                if col < self.window.width() / 8 && row < self.window.height() / 32 {
                                    col += 1;
                                }
                            }
                            if col >= self.window.width() / 8 {
                                col = 0;
                                row += 1;
                            }
                        }
                        row += 1;
                        i += 1; }

                    //Check for double click
                    if mouse_event.left_button {
                        let click_time = Duration::realtime();

                        if click_time - self.click_time < Duration::new(0, 500 * time::NANOS_PER_MILLI)
                            && self.last_mouse_event.x == mouse_event.x
                            && self.last_mouse_event.y == mouse_event.y {
                            if self.selected >= 0 && self.selected < self.files.len() as isize {
                                if let Some(file) = self.files.get(self.selected as usize) {
                                    if file.ends_with('/') {
                                        command = Some(FileManagerCommand::ChangeDir(file.clone()));
                                    } else {
                                        command = Some(FileManagerCommand::Execute(file.clone()));
                                    }
                                }
                            }
                            self.click_time = Duration::new(0, 0);
                        } else {
                            self.click_time = click_time;
                        }
                    }
                    self.last_mouse_event = mouse_event;

                    if command.is_none() && redraw {
                        command = Some(FileManagerCommand::Redraw);
                    }
                }
                EventOption::Quit(quit_event) => command = Some(FileManagerCommand::Quit),
                _ => (),
            }
        }
        command
    }

    fn main(&mut self, path: &str) {
        let mut current_path = path.to_string();
        self.set_path(path);
        loop {
            if let Some(event) = self.event_loop() {
                match event {
                    FileManagerCommand::ChangeDir(dir) => {
                        current_path = current_path + &dir;
                        self.set_path(&current_path);
                    },
                    FileManagerCommand::Execute(cmd) => { File::exec(&(current_path.clone() + &cmd)); } ,
                    FileManagerCommand::Redraw => (),
                    FileManagerCommand::Quit => break,
                };
                self.draw_content();
            }
        }

    }
}

pub fn main() {
    match env::args().get(1) {
        Some(arg) => FileManager::new().main(arg),
        None => FileManager::new().main("file:/"),
    }
}
<|endoftext|>


<commit_before>use redox::*;
use redox::time::*;

pub struct FileManager {
    folder_icon: BMPFile,
    audio_icon: BMPFile,
    bin_icon: BMPFile,
    image_icon: BMPFile,
    source_icon: BMPFile,
    script_icon: BMPFile,
    text_icon: BMPFile,
    file_icon: BMPFile,
    files: Vec<String>,
    selected: isize,
    last_mouse_event: MouseEvent,
    click_time: Duration,
}

fn load_icon(path: &str) -> BMPFile {
    let mut resource = File::open(&("file:///ui/mimetypes/".to_string() + path + ".bmp"));

    let mut vec: Vec<u8> = Vec::new();
    resource.read_to_end(&mut vec);

    BMPFile::from_data(&vec)
}

impl FileManager {
    pub fn new() -> Self {
        FileManager {
            folder_icon: load_icon("inode-directory"),
            audio_icon: load_icon("audio-x-wav"),
            bin_icon: load_icon("application-x-executable"),
            image_icon: load_icon("image-x-generic"),
            source_icon: load_icon("text-x-makefile"),
            script_icon: load_icon("text-x-script"),
            text_icon: load_icon("text-x-generic"),
            file_icon: load_icon("unknown"),
            files: Vec::new(),
            selected: -1,
            last_mouse_event: MouseEvent {
                x: 0,
                y: 0,
                left_button: false,
                middle_button: false,
                right_button: false,
            }
            click_time: Duration::new(0, 0),
        }
    }

    fn draw_content(&mut self, window: &mut Window) {
        window.set([255, 255, 255, 255]);

        let mut i = 0;
        let mut row = 0;
        for string in self.files.iter() {
            if i == self.selected {
                let width = window.width();
                window.rect(0, 32 * row as isize, width, 32, [224, 224, 224, 255]);
            }

            if string.ends_with('/') {
                window.image(0,
                             32 * row as isize,
                             self.folder_icon.width(),
                             self.folder_icon.height(),
                             self.folder_icon.as_slice());
            } else if string.ends_with(".wav") {
                window.image(0,
                             32 * row as isize,
                             self.audio_icon.width(),
                             self.audio_icon.height(),
                             self.audio_icon.as_slice());
            } else if string.ends_with(".bin") {
                window.image(0,
                             32 * row as isize,
                             self.bin_icon.width(),
                             self.bin_icon.height(),
                             self.bin_icon.as_slice());
            } else if string.ends_with(".bmp") {
                window.image(0,
                             32 * row as isize,
                             self.image_icon.width(),
                             self.image_icon.height(),
                             self.image_icon.as_slice());
            } else if string.ends_with(".rs") || string.ends_with(".asm") || string.ends_with(".list") {
                window.image(0,
                             32 * row as isize,
                             self.source_icon.width(),
                             self.source_icon.height(),
                             self.source_icon.as_slice());
            } else if string.ends_with(".sh") || string.ends_with(".lua") {
                window.image(0,
                             32 * row as isize,
                             self.script_icon.width(),
                             self.script_icon.height(),
                             self.script_icon.as_slice());
            } else if string.ends_with(".md") || string.ends_with(".txt") {
                window.image(0,
                             32 * row as isize,
                             self.text_icon.width(),
                             self.text_icon.height(),
                             self.text_icon.as_slice());
            } else {
                window.image(0,
                             32 * row as isize,
                             self.file_icon.width(),
                             self.file_icon.height(),
                             self.file_icon.as_slice());
            }

            let mut col = 0;
            for c in string.chars() {
                if c == '\n' {
                    col = 0;
                    row += 1;
                } else if c == '\t' {
                    col += 8 - col % 8;
                } else {
                    if col < window.width() / 8 && row < window.height() / 32 {
                        window.char(8 * col as isize + 40,
                                    32 * row as isize + 8,
                                    c,
                                    [0, 0, 0, 255]);
                        col += 1;
                    }
                }
                if col >= window.width() / 8 {
                    col = 0;
                    row += 1;
                }
            }
            row += 1;
            i += 1;
        }

        window.sync();
    }

    fn main(&mut self, path: &str) {
        let mut width = 160;
        let mut height = 0;
        {
            let mut resource = File::open(path);

            let mut vec: Vec<u8> = Vec::new();
            resource.read_to_end(&mut vec);

            for file in unsafe { String::from_utf8_unchecked(vec) }.split('\n') {
                if width < 40 + (file.len() + 1) * 8 {
                    width = 40 + (file.len() + 1) * 8;
                }
                self.files.push(file.to_string());
            }

            if height < self.files.len() * 32 {
                height = self.files.len() * 32;
            }
        }

        let mut window = Window::new((rand() % 400 + 50) as isize,
                                     (rand() % 300 + 50) as isize,
                                     width,
                                     height,
                                     &path);

        self.draw_content(&mut window);

        while let Option::Some(event) = window.poll() {
            match event.to_option() {
                EventOption::Key(key_event) => {
                    if key_event.pressed {
                        match key_event.scancode {
                            K_ESC => break,
                            K_HOME => self.selected = 0,
                            K_UP => if self.selected > 0 {
                                self.selected -= 1;
                            },
                            K_END => self.selected = self.files.len() as isize - 1,
                            K_DOWN => if self.selected < self.files.len() as isize - 1 {
                                self.selected += 1;
                            },
                            _ => match key_event.character {
                                '\0' => (),
                                '\n' => {
                                    if self.selected >= 0 &&
                                       self.selected < self.files.len() as isize {
                                        match self.files.get(self.selected as usize) {
                                            Option::Some(file) => OpenEvent {
                                                url_string: path.to_string() + &file,
                                            }.trigger(),
                                            Option::None => (),
                                        }
                                    }
                                }
                                _ => {
                                    let mut i = 0;
                                    for file in self.files.iter() {
                                        if file.starts_with(key_event.character) {
                                            self.selected = i;
                                            break;
                                        }
                                        i += 1;
                                    }
                                }
                            },
                        }

                        self.draw_content(&mut window);
                    }
                }
                EventOption::Mouse(mouse_event) => {
                    let mut redraw = false;
                    let mut i = 0;
                    let mut row = 0;
                    for file in self.files.iter() {
                        let mut col = 0;
                        for c in file.chars() {
                            if mouse_event.y >= 32 * row as isize &&
                               mouse_event.y < 32 * row as isize + 32 {
                                let click_time = Duration::realtime();
                                if self.selected == i {
                                    if click_time - self.click_time < Duration::new(0, 500 * NANOS_PER_MILLI) {
                                        match self.files.get(self.selected as usize) {
                                            Option::Some(file) => OpenEvent {
                                                url_string: path.to_string() + &file,
                                            }.trigger(),
                                            Option::None => (),
                                        }
                                        self.click_time = Duration::new(0, 0);
                                    }
                                } else {
                                    self.selected = i;
                                    self.click_time = click_time;
                                }
                                redraw = true;
                            }

                            if c == '\n' {
                                col = 0;
                                row += 1;
                            } else if c == '\t' {
                                col += 8 - col % 8;
                            } else {
                                if col < window.width() / 8 && row < window.height() / 32 {
                                    col += 1;
                                }
                            }
                            if col >= window.width() / 8 {
                                col = 0;
                                row += 1;
                            }
                        }
                        row += 1;
                        i += 1;
                    }

                    if redraw {
                        self.draw_content(&mut window);
                    }

                    self.last_mouse_event = mouse_event;
                }
                _ => (),
            }
        }
    }
}

pub fn main() {
    match args().get(1) {
        Option::Some(arg) => FileManager::new().main(arg),
        Option::None => FileManager::new().main("file:///"),
    }
}
<commit_msg>WIP double click<commit_after>use redox::*;
use redox::time::*;

pub struct FileManager {
    folder_icon: BMPFile,
    audio_icon: BMPFile,
    bin_icon: BMPFile,
    image_icon: BMPFile,
    source_icon: BMPFile,
    script_icon: BMPFile,
    text_icon: BMPFile,
    file_icon: BMPFile,
    files: Vec<String>,
    selected: isize,
    last_mouse_event: MouseEvent,
    click_time: Duration,
}

fn load_icon(path: &str) -> BMPFile {
    let mut resource = File::open(&("file:///ui/mimetypes/".to_string() + path + ".bmp"));

    let mut vec: Vec<u8> = Vec::new();
    resource.read_to_end(&mut vec);

    BMPFile::from_data(&vec)
}

impl FileManager {
    pub fn new() -> Self {
        FileManager {
            folder_icon: load_icon("inode-directory"),
            audio_icon: load_icon("audio-x-wav"),
            bin_icon: load_icon("application-x-executable"),
            image_icon: load_icon("image-x-generic"),
            source_icon: load_icon("text-x-makefile"),
            script_icon: load_icon("text-x-script"),
            text_icon: load_icon("text-x-generic"),
            file_icon: load_icon("unknown"),
            files: Vec::new(),
            selected: -1,
            last_mouse_event: MouseEvent {
                x: 0,
                y: 0,
                left_button: false,
                middle_button: false,
                right_button: false,
            }
            click_time: Duration::new(0, 0),
        }
    }

    fn draw_content(&mut self, window: &mut Window) {
        window.set([255, 255, 255, 255]);

        let mut i = 0;
        let mut row = 0;
        for string in self.files.iter() {
            if i == self.selected {
                let width = window.width();
                window.rect(0, 32 * row as isize, width, 32, [224, 224, 224, 255]);
            }

            if string.ends_with('/') {
                window.image(0,
                             32 * row as isize,
                             self.folder_icon.width(),
                             self.folder_icon.height(),
                             self.folder_icon.as_slice());
            } else if string.ends_with(".wav") {
                window.image(0,
                             32 * row as isize,
                             self.audio_icon.width(),
                             self.audio_icon.height(),
                             self.audio_icon.as_slice());
            } else if string.ends_with(".bin") {
                window.image(0,
                             32 * row as isize,
                             self.bin_icon.width(),
                             self.bin_icon.height(),
                             self.bin_icon.as_slice());
            } else if string.ends_with(".bmp") {
                window.image(0,
                             32 * row as isize,
                             self.image_icon.width(),
                             self.image_icon.height(),
                             self.image_icon.as_slice());
            } else if string.ends_with(".rs") || string.ends_with(".asm") || string.ends_with(".list") {
                window.image(0,
                             32 * row as isize,
                             self.source_icon.width(),
                             self.source_icon.height(),
                             self.source_icon.as_slice());
            } else if string.ends_with(".sh") || string.ends_with(".lua") {
                window.image(0,
                             32 * row as isize,
                             self.script_icon.width(),
                             self.script_icon.height(),
                             self.script_icon.as_slice());
            } else if string.ends_with(".md") || string.ends_with(".txt") {
                window.image(0,
                             32 * row as isize,
                             self.text_icon.width(),
                             self.text_icon.height(),
                             self.text_icon.as_slice());
            } else {
                window.image(0,
                             32 * row as isize,
                             self.file_icon.width(),
                             self.file_icon.height(),
                             self.file_icon.as_slice());
            }

            let mut col = 0;
            for c in string.chars() {
                if c == '\n' {
                    col = 0;
                    row += 1;
                } else if c == '\t' {
                    col += 8 - col % 8;
                } else {
                    if col < window.width() / 8 && row < window.height() / 32 {
                        window.char(8 * col as isize + 40,
                                    32 * row as isize + 8,
                                    c,
                                    [0, 0, 0, 255]);
                        col += 1;
                    }
                }
                if col >= window.width() / 8 {
                    col = 0;
                    row += 1;
                }
            }
            row += 1;
            i += 1;
        }

        window.sync();
    }

    fn main(&mut self, path: &str) {
        let mut width = 160;
        let mut height = 0;
        {
            let mut resource = File::open(path);

            let mut vec: Vec<u8> = Vec::new();
            resource.read_to_end(&mut vec);

            for file in unsafe { String::from_utf8_unchecked(vec) }.split('\n') {
                if width < 40 + (file.len() + 1) * 8 {
                    width = 40 + (file.len() + 1) * 8;
                }
                self.files.push(file.to_string());
            }

            if height < self.files.len() * 32 {
                height = self.files.len() * 32;
            }
        }

        let mut window = Window::new((rand() % 400 + 50) as isize,
                                     (rand() % 300 + 50) as isize,
                                     width,
                                     height,
                                     &path);

        self.draw_content(&mut window);

        while let Option::Some(event) = window.poll() {
            match event.to_option() {
                EventOption::Key(key_event) => {
                    if key_event.pressed {
                        match key_event.scancode {
                            K_ESC => break,
                            K_HOME => self.selected = 0,
                            K_UP => if self.selected > 0 {
                                self.selected -= 1;
                            },
                            K_END => self.selected = self.files.len() as isize - 1,
                            K_DOWN => if self.selected < self.files.len() as isize - 1 {
                                self.selected += 1;
                            },
                            _ => match key_event.character {
                                '\0' => (),
                                '\n' => {
                                    if self.selected >= 0 &&
                                       self.selected < self.files.len() as isize {
                                        match self.files.get(self.selected as usize) {
                                            Option::Some(file) => OpenEvent {
                                                url_string: path.to_string() + &file,
                                            }.trigger(),
                                            Option::None => (),
                                        }
                                    }
                                }
                                _ => {
                                    let mut i = 0;
                                    for file in self.files.iter() {
                                        if file.starts_with(key_event.character) {
                                            self.selected = i;
                                            break;
                                        }
                                        i += 1;
                                    }
                                }
                            },
                        }

                        self.draw_content(&mut window);
                    }
                }
                EventOption::Mouse(mouse_event) => {
                    let mut redraw = false;
                    let mut i = 0;
                    let mut row = 0;
                    for file in self.files.iter() {
                        let mut col = 0;
                        for c in file.chars() {
                            if mouse_event.y >= 32 * row as isize &&
                               mouse_event.y < 32 * row as isize + 32 {
                                let click_time = Duration::realtime();
                                if self.selected == i {
                                    if click_time - self.click_time < Duration::new(0, 500 * NANOS_PER_MILLI) {
                                        match self.files.get(self.selected as usize) {
                                            Option::Some(file) => OpenEvent {
                                                url_string: path.to_string() + &file,
                                            }.trigger(),
                                            Option::None => (),
                                        }
                                        self.click_time = Duration::new(0, 0);
                                    }
                                } else {
                                    self.selected = i;
                                    self.click_time = click_time;
                                }
                                redraw = true;
                            }

                            if c == '\n' {
                                col = 0;
                                row += 1;
                            } else if c == '\t' {
                                col += 8 - col % 8;
                            } else {
                                if col < window.width() / 8 && row < window.height() / 32 {
                                    col += 1;
                                }
                            }
                            if col >= window.width() / 8 {
                                col = 0;
                                row += 1;
                            }
                        }
                        row += 1;
                        i += 1;
                    }

                    if redraw {
                        self.draw_content(&mut window);
                    }

                    if mouse_event.left_button
                    self.last_mouse_event = mouse_event;
                }
                _ => (),
            }
        }
    }
}

pub fn main() {
    match args().get(1) {
        Option::Some(arg) => FileManager::new().main(arg),
        Option::None => FileManager::new().main("file:///"),
    }
}
<|endoftext|>


<commit_before><commit_msg>Add another unwind test<commit_after>// error-pattern:fail

fn a() { }

fn b() { fail; }

fn main() {
    let x = [0];
    a();
    let y = [0];
    b();
}<|endoftext|>


<commit_before><commit_msg>style(Whitespace): Remove some whitespace<commit_after><|endoftext|>


<commit_before><commit_msg>added nbertagnolli's solution to the collatz 2-tag problem<commit_after>/// This File takes a string of 'a' characters and performs a 2-tag
/// collatz reduction on it

// Import necessary libraries
use std::io;
use std::collections::HashMap;

fn main() {
    println!("Enter a string of n a's where n is the number you want to start from");

    // Create a holder for the raw input
    let mut raw_input = String::new();

    // Read from standard in
    io::stdin()
        .read_line(&mut raw_input)
        .expect("Failed to read line");

    // Print out the input that was entered
    // string.len() returns the number of bytes in the string
    // subtract 1 for the newline character at the end.
    raw_input.pop();
    let str_len = raw_input.chars().count();

    println!("Your string is of size {}", str_len);
    // TODO:: Check for only a's

    // apply the tag system
    collatz(raw_input);
}

/// Reduces a string of a's to a single a by using a 2-tag system and the collatz conjecture
///
/// # Args
/// s: String of n a's to be reduce
///
/// # Returns
/// Void:  No return but it will print out each tag reduction as it reduces
fn collatz(s: String) -> () {
    // Create a map for the two tag system
    // Unfortunately Rust does not have a map literal syntax you would need to create
    // a macro for this, see stackoverflow.com/questions/27582739/how-do-i-create-a-hashmap-lieteral
    let mut tag_map: HashMap<char, String> = HashMap::new();
    tag_map.insert('a', "bc".to_string());
    tag_map.insert('b', "a".to_string());
    tag_map.insert('c', "aaa".to_string());

    // Calculate the initial string length subtract 1 for newline character
    let mut str_len = s.chars().count() - 1;

    // Create a mutable version of the string to work with
    let mut tag_str: String  = s.chars().collect();
    println!("{}", tag_str);

    // While the string is greater than 1 use the tag system rules to update and print the string
    while str_len > 1 {
        // Extract the first character
        let first: Option<char> = tag_str.chars().nth(0);

        // Remove the first two characters
        tag_str = tag_str.chars().skip(2).take(str_len).collect();

        // Append the new tag at the end of the string
        let add_str: &str  = tag_map.get(&first.unwrap()).unwrap();
        // let poop = [tag_str, &*add_str].concat();
        //println!("pattern is: {}", add_str);
        tag_str.push_str(add_str);

        // Print the new string
        println!("{}", tag_str);

        // Recalculate string length
        str_len = tag_str.chars().count();
    }

}
<|endoftext|>


<commit_before><commit_msg>Added tests for loading the 2.0 sample models<commit_after>
extern crate gltf;

use gltf::Generic::V2;

#[test]
fn import_v2() {
    let assets = [
        // These are currently the only available 2.0 compliant sample assets
        "glTF-Sample-Models/2.0/Corset/glTF/Corset.gltf",
        "glTF-Sample-Models/2.0/BoomBox/glTF/BoomBox.gltf",
        "glTF-Sample-Models/2.0/Lantern/glTF/Lantern.gltf",
    ];
    for asset in &assets {
        match gltf::import(asset) {
            Ok(V2(_)) => {},
            Ok(_) => { println!("import() detected wrong version"); panic!() },
            Err(err) => { println!("{:?}", err); panic!() },
        }
    }
}

<|endoftext|>


<commit_before><commit_msg>Add test for all.html<commit_after>// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![crate_name = "foo"]

// @has foo/all.html '//a[@href="struct.Struct.html"]' 'Struct'
// @has foo/all.html '//a[@href="enum.Enum.html"]' 'Enum'
// @has foo/all.html '//a[@href="union.Union.html"]' 'Union'
// @has foo/all.html '//a[@href="constant.CONST.html"]' 'CONST'
// @has foo/all.html '//a[@href="static.STATIC.html"]' 'STATIC'
// @has foo/all.html '//a[@href="fn.function.html"]' 'function'

pub struct Struct;
pub enum Enum {
    X,
    Y,
}
pub union Union {
    x: u32,
}
pub const CONST: u32 = 0;
pub static STATIC: &str = "baguette";
pub fn function() {}
<|endoftext|>


<commit_before><commit_msg>command work for windows<commit_after><|endoftext|>


<commit_before><commit_msg>Some refactoring in parser::shell_expand<commit_after><|endoftext|>


<commit_before><commit_msg>Fix autobackup_interval<commit_after><|endoftext|>


<commit_before><commit_msg>Add test for issue-60390<commit_after>// check-pass
// compile-flags: --emit=mir,link
// Regression test for #60390, this ICE requires `--emit=mir` flag.

fn main() {
    enum Inner { Member(u32) };
    Inner::Member(0);
}
<|endoftext|>


<commit_before><commit_msg>cfail test for std::env::args()<commit_after>//error-pattern: no mir for `std

fn main() {
    let x = std::env::args();
    assert_eq!(x.count(), 1);
}
<|endoftext|>