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;
}
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.
*/
}
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;
}
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();
}
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;
}
Aggregations