/* * Copyright 2011 Chad Retz * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package org.gwtnode.core.node.tty; import org.gwtnode.core.JavaScriptUtils; import org.gwtnode.core.meta.GwtNodeFunction; import org.gwtnode.core.meta.GwtNodeModule; import org.gwtnode.core.node.Global; import org.gwtnode.core.node.NodeJsModule; import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JsArrayInteger; import com.google.gwt.core.client.JsArrayString; /** * The node.js * <a href="http://nodejs.org/docs/v0.5.6/api/tty.html">tty</a> * module. * * @author Chad Retz */ @GwtNodeModule public class Tty extends JavaScriptObject implements NodeJsModule { private static Tty instance; public static Tty get() { if (instance == null) { instance = Global.get().require("tty"); } return instance; } protected Tty() { } @GwtNodeFunction public final TtyProcess open(String path, String... args) { return open(path, JavaScriptUtils.toStringArray(args)); } @GwtNodeFunction public final native TtyProcess open(String path, JsArrayString args) /*-{ var ttyProc = this.open(path, args); return @org.gwtnode.core.node.tty.TtyProcess::new(ILorg/gwtnode/core/node/childprocess/ChildProcess;)( ttyProc[0], ttyProc[1]); }-*/; @GwtNodeFunction public final native boolean isatty(int fd) /*-{ return this.isatty(fd); }-*/; @GwtNodeFunction public final native void setRawMode(boolean mode) /*-{ this.setRawMode(mode); }-*/; @GwtNodeFunction public final native void setWindowSize(int fd, int row, int col) /*-{ this.setWindowSize(fd, row, col); }-*/; @GwtNodeFunction public final native JsArrayInteger getWindowSize(int fd) /*-{ return this.getWindowSize(fd); }-*/; }