Search in sources :

Example 6 with TermSession

use of jackpal.androidterm.emulatorview.TermSession in project Android-Terminal-Emulator by jackpal.

the class SessionList method remove.

@Override
public TermSession remove(int index) {
    TermSession object = super.remove(index);
    if (object != null) {
        object.setTitleChangedListener(null);
        notifyChange();
    }
    return object;
}
Also used : TermSession(jackpal.androidterm.emulatorview.TermSession)

Example 7 with TermSession

use of jackpal.androidterm.emulatorview.TermSession in project Android-Terminal-Emulator by jackpal.

the class TermActivity method createLocalTermSession.

/**
     * Create a TermSession connected to a local shell.
     */
private TermSession createLocalTermSession() {
    /* Instantiate the TermSession ... */
    TermSession session = new TermSession();
    /* ... create a process ... */
    /* TODO:Make local session work without execpty.
        String execPath = LaunchActivity.getDataDir(this) + "/bin/execpty";
        ProcessBuilder execBuild =
                new ProcessBuilder(execPath, "/system/bin/sh", "-");
        */
    ProcessBuilder execBuild = new ProcessBuilder("/system/bin/sh", "-");
    execBuild.redirectErrorStream(true);
    Process exec = null;
    try {
        exec = execBuild.start();
    } catch (Exception e) {
        Log.e(TAG, "Could not start terminal process.", e);
        return null;
    }
    /* ... and connect the process's I/O streams to the TermSession. */
    session.setTermIn(exec.getInputStream());
    session.setTermOut(exec.getOutputStream());
    /* You're done! */
    return session;
/**
         * NB: You can invoke a program without using execpty or a native code
         * method, but the results may not be what you expect, because the
         * process will be connected to a pipe, not a tty device.  tty devices
         * provide services such as flow control and input/output translation
         * which many programs expect.
         *
         * If you do connect a program directly to a TermSession without using
         * a tty, you should probably at a minimum translate '\r' (sent by the
         * Enter key) to '\n' (which most programs expect as their newline
         * input) in write(), and translate '\n' (sent by most programs to
         * indicate a newline) to '\r\n' (which the terminal emulator needs to
         * actually start a new line without overdrawing text or "staircase
         * effect") in processInput(), before sending it to the terminal
         * emulator.
         *
         * For an example of how to obtain and use a tty device in native code,
         * see assets-src/execpty.c.
         */
}
Also used : TermSession(jackpal.androidterm.emulatorview.TermSession) IOException(java.io.IOException)

Example 8 with TermSession

use of jackpal.androidterm.emulatorview.TermSession in project Android-Terminal-Emulator by jackpal.

the class TermActivity method createTelnetSession.

/* Create the TermSession which will handle the Telnet protocol and
       terminal emulation. */
private void createTelnetSession() {
    Socket socket = mSocket;
    // Get the socket's input and output streams
    InputStream termIn;
    OutputStream termOut;
    try {
        termIn = socket.getInputStream();
        termOut = socket.getOutputStream();
    } catch (IOException e) {
        // Handle exception here
        return;
    }
    /* Create the TermSession and attach it to the view.  See the
           TelnetSession class for details. */
    TermSession session = new TelnetSession(termIn, termOut);
    mEmulatorView.attachSession(session);
    mSession = session;
}
Also used : InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) IOException(java.io.IOException) TermSession(jackpal.androidterm.emulatorview.TermSession) Socket(java.net.Socket)

Example 9 with TermSession

use of jackpal.androidterm.emulatorview.TermSession in project Android-Terminal-Emulator by jackpal.

the class TermViewFlipper method showTitle.

private void showTitle() {
    if (getChildCount() == 0) {
        return;
    }
    EmulatorView view = (EmulatorView) getCurrentView();
    if (view == null) {
        return;
    }
    TermSession session = view.getTermSession();
    if (session == null) {
        return;
    }
    String title = context.getString(R.string.window_title, getDisplayedChild() + 1);
    if (session instanceof GenericTermSession) {
        title = ((GenericTermSession) session).getTitle(title);
    }
    if (mToast == null) {
        mToast = Toast.makeText(context, title, Toast.LENGTH_SHORT);
        mToast.setGravity(Gravity.CENTER, 0, 0);
    } else {
        mToast.setText(title);
    }
    mToast.show();
}
Also used : EmulatorView(jackpal.androidterm.emulatorview.EmulatorView) TermSession(jackpal.androidterm.emulatorview.TermSession)

Example 10 with TermSession

use of jackpal.androidterm.emulatorview.TermSession in project Android-Terminal-Emulator by jackpal.

the class WindowListAdapter method getView.

public View getView(int position, View convertView, ViewGroup parent) {
    Activity act = findActivityFromContext(parent.getContext());
    View child = act.getLayoutInflater().inflate(R.layout.window_list_item, parent, false);
    View close = child.findViewById(R.id.window_list_close);
    TextView label = (TextView) child.findViewById(R.id.window_list_label);
    String defaultTitle = act.getString(R.string.window_title, position + 1);
    label.setText(getSessionTitle(position, defaultTitle));
    final SessionList sessions = mSessions;
    final int closePosition = position;
    close.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            TermSession session = sessions.remove(closePosition);
            if (session != null) {
                session.finish();
                notifyDataSetChanged();
            }
        }
    });
    return child;
}
Also used : Activity(android.app.Activity) TextView(android.widget.TextView) SessionList(jackpal.androidterm.util.SessionList) TermSession(jackpal.androidterm.emulatorview.TermSession) TextView(android.widget.TextView) View(android.view.View)

Aggregations

TermSession (jackpal.androidterm.emulatorview.TermSession)18 EmulatorView (jackpal.androidterm.emulatorview.EmulatorView)5 IOException (java.io.IOException)5 Intent (android.content.Intent)3 View (android.view.View)3 TextView (android.widget.TextView)3 DisplayMetrics (android.util.DisplayMetrics)2 Activity (android.app.Activity)1 ActivityNotFoundException (android.content.ActivityNotFoundException)1 Editable (android.text.Editable)1 KeyEvent (android.view.KeyEvent)1 Window (android.view.Window)1 Button (android.widget.Button)1 SessionList (jackpal.androidterm.util.SessionList)1 TermSettings (jackpal.androidterm.util.TermSettings)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 Socket (java.net.Socket)1