GitXplorerGitXplorer
h

pty-shell

public
31 stars
8 forks
4 issues

Commits

List of commits on branch master.
Unverified
e03d4fef48a51c411e8292cdad376474cb4522ff

Merge pull request #6 from adjivas/master

hhibariya committed 8 years ago
Unverified
d198c23dbea69c77436f6dccba7071687b96a2dc

support 0.2

aadjivas committed 8 years ago
Unverified
dd166965db6ee22bfe1c5b0946e143eb16cc6c9f

hard tab = false

aadjivas committed 8 years ago
Unverified
34b42d4896fafec44170cdf7274f1a3a10fd4d36

fix hard tab

aadjivas committed 8 years ago
Unverified
5b5189da7dac0b0959d3199af3d60dfccd66531f

rename father to parent

aadjivas committed 8 years ago
Unverified
4d2c3c8140d758e70bd421f7f3e6b15e2c0b5bfa

move main to example

aadjivas committed 8 years ago

README

The README file for this repository.

pty-shell

An extension of pty crate.

https://speakerdeck.com/hibariya/control-a-shell-with-pty-shell

Usage

Add this to your Cargo.toml:

[dependencies]
pty-shell = '0.2.0'

For example, add src/main.rs as following:

extern crate pty_shell;

use pty_shell::{winsize, PtyShell, PtyHandler};

struct Shell;
impl PtyHandler for Shell {
    fn input(&mut self, input: &[u8]) {
      /* do something with input */
    }

    fn output(&mut self, output: &[u8]) {
      /* do something with output */
    }

    fn resize(&mut self, winsize: &winsize::Winsize) {
      /* do something with winsize */
    }

    fn shutdown(&mut self) {
      /* prepare for shutdown */
    }
}

fn main() {
    let child = pty::fork().unwrap();

    child.exec("bash");
    child.proxy(Shell);
    child.wait();
}

Callback Style

Use pty_shell::PtyCallback.

child.proxy(
    PtyCallback::new()
        .input(|input| { /* do something with input */ })
        .output(|output| { /* do something with output */ })
        .build()
    )
);

Event types

  • input
  • output
  • resize
  • shutdown

Contributing

  1. Fork it ( https://github.com/hibariya/pty-shell/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

License

Copyright (c) 2015 Hika Hibariya

Distributed under the MIT License.