xmlterm changes only;

Initial terminal size is now explicitly passed through parameters, providing
better control. Session aborts now produce an error message on the screen.
This commit is contained in:
svn%xmlterm.org 2000-04-04 04:42:27 +00:00
parent 78bd430e0d
commit 67b2f8314a
17 changed files with 267 additions and 97 deletions

View File

@ -134,6 +134,10 @@ int lterm_new();
* If it is set to LTERM_DETERMINE_PROCESS, the process type is determined
* from the path name.
*
* ROWS, COLS contain the initial no. of rows/columns.
* X_PIXELS, Y_PIXELS contain the initial screen size in pixels
* (may be set to zero if screen size is unknown).
*
* CALLBACK_FUNC is a pointer to a GTK-style callback function,
* or NULL for no callback.
* The function is called whenever there is data available for
@ -160,6 +164,7 @@ int lterm_new();
int lterm_open(int lterm, char *const argv[],
const char* cookie, const char* init_command,
const UNICHAR* prompt_regexp, int options, int process_type,
int rows, int cols, int x_pixels, int y_pixels,
lterm_callback_func_t callback_func, void *callback_data);

View File

@ -235,6 +235,7 @@ int lterm_new()
int lterm_open(int lterm, char *const argv[],
const char* cookie, const char* init_command,
const UNICHAR* prompt_regexp, int options, int process_type,
int rows, int cols, int x_pixels, int y_pixels,
lterm_callback_func_t callback_func, void *callback_data)
{
int nostderr, noPTY, j;
@ -316,9 +317,11 @@ int lterm_open(int lterm, char *const argv[],
lto->decodedChars = 0;
lto->incompleteEscapeSequence = 0;
/* Set default screen size (VT100) */
lts->nRows = 24;
lts->nCols = 80;
/* Set initial screen size */
lts->nRows = rows;
lts->nCols = cols;
lts->xPixels = y_pixels;
lts->yPixels = x_pixels;
/* Clear screen buffer */
lto->screenChar = NULL;
@ -433,14 +436,12 @@ int lterm_open(int lterm, char *const argv[],
("errfd=%d, noecho=%d, noblock=%d, noexport=%d, debugPTY=%d\n",
errfd, lts->noTTYEcho, noblock, noexport, debugPTY));
#ifndef NO_PTY
if (pty_create(&ptyStruc, cargv, errfd,
noblock, lts->noTTYEcho, noexport, debugPTY) == -1) {
if (pty_create(&ptyStruc, cargv,
lts->nRows, lts->nCols, lts->xPixels, lts->yPixels,
errfd, noblock, lts->noTTYEcho, noexport, debugPTY) == -1) {
LTERM_OPEN_ERROR_RETURN(lterm,lts,
"lterm_open: Error - PTY creation failed\n")
}
/* Resize TTY (fails on BSD?) */
pty_resize(&ptyStruc, lts->nRows, lts->nCols, 0, 0);
#endif /* !NO_PTY */
/* Copy PTY structure */

View File

@ -499,6 +499,8 @@ struct lterms {
int nRows; /* Number of rows */
int nCols; /* Number of columns */
int xPixels; /* Number of X pixels in screen */
int yPixels; /* Number of Y pixels in screen */
UNICHAR promptRegexp[MAXPROMPT]; /* prompt regular expression
JUST A LIST OF DELIMITERS AT PRESENT */

View File

@ -71,6 +71,10 @@ class mozILineTermAux : public mozILineTerm {
* @param options LineTerm option bits (usually 0; see lineterm.h)
* @param processType command shell type; if set to -1, type is determined
* from the command name
* @param nRows no. of screen rows
* @param nCols no. of screen columns
* @param xPixels screen width in pixels (or 0 if unknown)
* @param yPixels screen height in pixels (or 0 if unknown)
* @param domDoc DOM document object associated with the LineTerm
* (document.cookie will be defined for this document on return)
* @param aCookie (output) cookie associated with LineTerm
@ -79,6 +83,8 @@ class mozILineTermAux : public mozILineTerm {
const PRUnichar *initInput,
const PRUnichar *promptRegexp,
PRInt32 options, PRInt32 processType,
PRInt32 nRows, PRInt32 nCols,
PRInt32 xPixels, PRInt32 yPixels,
nsIDOMDocument *domDoc,
nsIObserver* anObserver,
nsString& aCookie) = 0;

View File

@ -149,6 +149,15 @@ public:
/** Shows the caret and make it editable.
*/
NS_IMETHOD ShowCaret(void) = 0;
/** Returns current screen size in rows/cols and in pixels
* @param (output) rows
* @param (output) cols
* @param (output) xPixels
* @param (output) yPixels
*/
NS_IMETHOD ScreenSize(PRInt32& rows, PRInt32& cols,
PRInt32& xPixels, PRInt32& yPixels) = 0;
};
#define MOZXMLTERMINAL_CID \

View File

@ -297,8 +297,9 @@ NS_IMETHODIMP mozLineTerm::Open(const PRUnichar *command,
nsAutoString aCookie;
return OpenAux(command, initInput, promptRegexp,
options, processType, domDoc,
nsnull, aCookie);
options, processType,
24, 80, 0, 0,
domDoc, nsnull, aCookie);
}
@ -308,6 +309,8 @@ NS_IMETHODIMP mozLineTerm::OpenAux(const PRUnichar *command,
const PRUnichar *initInput,
const PRUnichar *promptRegexp,
PRInt32 options, PRInt32 processType,
PRInt32 nRows, PRInt32 nCols,
PRInt32 xPixels, PRInt32 yPixels,
nsIDOMDocument *domDoc,
nsIObserver* anObserver,
nsString& aCookie)
@ -389,12 +392,14 @@ NS_IMETHODIMP mozLineTerm::OpenAux(const PRUnichar *command,
if (anObserver != nsnull) {
result = lterm_open(mLTerm, NULL, cookieCStr, initCStr.GetBuffer(),
prompt_regexp, options,
processType, mozLineTerm::Callback, (void *) this);
prompt_regexp, options, processType,
nRows, nCols, xPixels, yPixels,
mozLineTerm::Callback, (void *) this);
} else {
result = lterm_open(mLTerm, NULL, cookieCStr, initCStr.GetBuffer(),
prompt_regexp, options,
processType, NULL, NULL);
prompt_regexp, options, processType,
nRows, nCols, xPixels, yPixels,
NULL, NULL);
}
// Free cookie CString

View File

@ -67,6 +67,8 @@ public:
const PRUnichar *initInput,
const PRUnichar *promptRegexp,
PRInt32 options, PRInt32 processType,
PRInt32 nRows, PRInt32 nCols,
PRInt32 xPixels, PRInt32 yPixels,
nsIDOMDocument *domDoc,
nsIObserver* anObserver,
nsString& aCookie);

View File

@ -50,9 +50,6 @@
#include "nsIHTMLContent.h"
#include "nsFont.h"
#include "nsIFontMetrics.h"
#include "mozXMLT.h"
#include "mozILineTermAux.h"
#include "mozIXMLTerminal.h"
@ -152,9 +149,9 @@ mozXMLTermSession::mozXMLTermSession() :
mPreTextDisplayed(""),
mScreenNode(nsnull),
mScreenRows(24),
mScreenCols(80),
mTopScrollRow(23),
mScreenRows(0),
mScreenCols(0),
mTopScrollRow(0),
mBotScrollRow(0),
mRestoreInputEcho(false),
@ -179,7 +176,8 @@ mozXMLTermSession::~mozXMLTermSession()
// Initialize XMLTermSession
NS_IMETHODIMP mozXMLTermSession::Init(mozIXMLTerminal* aXMLTerminal,
nsIPresShell* aPresShell,
nsIDOMDocument* aDOMDocument)
nsIDOMDocument* aDOMDocument,
PRInt32 nRows, PRInt32 nCols)
{
XMLT_LOG(mozXMLTermSession::Init,30,("\n"));
@ -193,6 +191,11 @@ NS_IMETHODIMP mozXMLTermSession::Init(mozIXMLTerminal* aXMLTerminal,
mPresShell = aPresShell; // presentation shell; no addref
mDOMDocument = aDOMDocument; // DOM document; no addref
mScreenRows = nRows;
mScreenCols = nCols;
mTopScrollRow = mScreenRows - 1;
mBotScrollRow = 0;
nsresult result = NS_OK;
nsCOMPtr<nsIDOMHTMLDocument> vDOMHTMLDocument
@ -300,64 +303,26 @@ NS_IMETHODIMP mozXMLTermSession::Resize(mozILineTermAux* lineTermAux)
{
nsresult result;
// Get presentation context
nsCOMPtr<nsIPresContext> presContext;
result = mPresShell->GetPresContext( getter_AddRefs(presContext) );
XMLT_LOG(mozXMLTermSession::Resize,70,("\n"));
// Determine current screen dimensions
PRInt32 nRows, nCols, xPixels, yPixels;
result = mXMLTerminal->ScreenSize(nRows, nCols, xPixels, yPixels);
if (NS_FAILED(result))
return result;
// Get the default fixed pitch font
nsFont defaultFixedFont("dummyfont", NS_FONT_STYLE_NORMAL,
NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL,
NS_FONT_DECORATION_NONE, 16);
// If dimensions haven't changed, do nothing
if ((nRows == mScreenRows) && (nCols == mScreenCols))
return NS_OK;
result = presContext->GetDefaultFixedFont(defaultFixedFont);
if (NS_FAILED(result))
return result;
// Get metrics for fixed font
nsCOMPtr<nsIFontMetrics> fontMetrics;
result = presContext->GetMetricsFor(defaultFixedFont,
getter_AddRefs(fontMetrics));
if (NS_FAILED(result) || !fontMetrics)
return result;
// Get font height (includes leading?)
nscoord fontHeight, fontWidth;
result = fontMetrics->GetHeight(fontHeight);
result = fontMetrics->GetMaxAdvance(fontWidth);
// Determine docshell size in twips
nsRect shellArea;
result = presContext->GetVisibleArea(shellArea);
if (NS_FAILED(result))
return result;
// Determine twips to pixels conversion factor
float pixelScale, frameHeight, frameWidth, xdel, ydel;
presContext->GetTwipsToPixels(&pixelScale);
// Convert dimensions to pixels
frameHeight = pixelScale * shellArea.height;
frameWidth = pixelScale * shellArea.width;
xdel = pixelScale * fontWidth;
ydel = pixelScale * fontHeight + 2;
// Determine number of rows/columns
mScreenRows = (int) ((frameHeight-44) / ydel);
mScreenCols = (int) ((frameWidth-20) / xdel);
if (mScreenRows < 1) mScreenRows = 1;
if (mScreenCols < 1) mScreenCols = 1;
mScreenRows = nRows;
mScreenCols = nCols;
mTopScrollRow = mScreenRows - 1;
mBotScrollRow = 0;
XMLT_LOG(mozXMLTermSession::Resize,0,
("Resizing XMLterm, xdel=%e, ydel=%e, rows=%d, cols=%d\n",
xdel, ydel, mScreenRows, mScreenCols));
("Resizing XMLterm, nRows=%d, nCols=%d\n", mScreenRows, mScreenCols));
if (lineTermAux) {
// Resize associated LineTerm
@ -378,6 +343,8 @@ NS_IMETHODIMP mozXMLTermSession::Preprocess(const nsString& aString,
PRBool& consumed)
{
XMLT_LOG(mozXMLTermSession::Preprocess,70,("\n"));
consumed = false;
if (mMetaCommandType == TREE_META_COMMAND) {
@ -451,6 +418,7 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
PRUnichar *buf_str, *buf_style;
PRBool newline, errorFlag, streamData, screenData;
nsAutoString bufString, bufStyle;
nsAutoString abortCode = "";
XMLT_LOG(mozXMLTermSession::ReadAll,60,("\n"));
@ -464,13 +432,18 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
PRBool metaNextCommand = false;
// NOTE: Do not execute return statements within this loop ;
// always break out of the loop after setting result to an error value,
// allowing cleanup processing on error
for (;;) {
// NOTE: Remember to de-allocate buf_str and buf_style
// using nsAllocator::Free, if opcodes != 0
result = lineTermAux->ReadAux(&opcodes, &opvals, &buf_row, &buf_col,
&buf_str, &buf_style);
if (NS_FAILED(result))
if (NS_FAILED(result)) {
abortCode = "lineTermReadAux";
break;
}
XMLT_LOG(mozXMLTermSession::ReadAll,62,
("opcodes=0x%x,mOutputType=%d,mEntryHasOutput=%d\n",
@ -1085,23 +1058,23 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
}
if (NS_FAILED(result)) {
// Close LineTerm
// Error processing; close LineTerm
XMLT_LOG(mozXMLTermSession::ReadAll,62,
("Closing LineTerm, result=%d\n", result));
("Aborting on error, result=0x%x\n", result));
lineTermAux->CloseAux();
Abort(lineTermAux, abortCode);
return result;
}
if (flushOutput) {
// Flush output, splitting off incomplete line
result = FlushOutput(SPLIT_INCOMPLETE_FLUSH);
FlushOutput(SPLIT_INCOMPLETE_FLUSH);
if (mEntryHasOutput)
PositionOutputCursor(lineTermAux);
result = mPresShell->ScrollSelectionIntoView(SELECTION_NORMAL,
SELECTION_FOCUS_REGION);
mPresShell->ScrollSelectionIntoView(SELECTION_NORMAL,
SELECTION_FOCUS_REGION);
}
// Show caret
@ -1114,6 +1087,51 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux,
}
/** Aborts session by closing LineTerm and displays an error message
* @param lineTermAux LineTermAux object to be closed
* @param abortCode abort code string to dbe displayed
*/
NS_IMETHODIMP mozXMLTermSession::Abort(mozILineTermAux* lineTermAux,
nsString& abortCode)
{
nsresult result;
XMLT_LOG(mozXMLTermSession::Abort,70,
("Aborting session; closing LineTerm\n"));
// Close LineTerm
lineTermAux->CloseAux();
// Display error message using DIV node
nsCOMPtr<nsIDOMNode> divNode, textNode;
nsAutoString tagName = "div";
nsAutoString elementName = "errmsg";
result = NewElementWithText(tagName, elementName, -1,
mSessionNode, divNode, textNode);
if (NS_SUCCEEDED(result) && divNode && textNode) {
nsAutoString errMsg = "Error in XMLterm (code ";
errMsg.Append(abortCode);
errMsg.Append("); session closed.");
SetDOMText(textNode, errMsg);
// Collapse selection and position cursor
nsCOMPtr<nsIDOMSelection> selection;
result = mPresShell->GetSelection(SELECTION_NORMAL,
getter_AddRefs(selection));
if (NS_SUCCEEDED(result) && selection) {
selection->Collapse(textNode, errMsg.Length());
if (NS_SUCCEEDED(result)) {
mPresShell->ScrollSelectionIntoView(SELECTION_NORMAL,
SELECTION_FOCUS_REGION);
}
}
}
return NS_OK;
}
/** Displays ("echoes") input text string with style and positions cursor
* @param aString string to be displayed
* @param aStyle style values for string (see lineterm.h)

View File

@ -52,10 +52,13 @@ class mozXMLTermSession
* @param aXMLTerminal containing XMLTerminal object
* @param aPresShell presentation shell associated with XMLterm
* @param aDOMDocument DOM document associated with XMLterm
* @param nRows initial number of rows
* @param nCols initial number of columns
*/
NS_IMETHOD Init(mozIXMLTerminal* aXMLTerminal,
nsIPresShell* aPresShell,
nsIDOMDocument* aDOMDocument);
nsIDOMDocument* aDOMDocument,
PRInt32 nRows, PRInt32 nCols);
/** Finalizes (closes) session
*/
@ -65,6 +68,11 @@ class mozXMLTermSession
*/
NS_IMETHOD NeedsResizing(void);
/** Resizes XMLterm to match a resized window.
* @param lineTermAux LineTermAux object to be resized (may be null)
*/
NS_IMETHOD Resize(mozILineTermAux* lineTermAux);
/** Preprocesses user input before it is transmitted to LineTerm
* @param aString (inout) input data to be preprocessed
* @param consumed (output) true if input data has been consumed
@ -78,6 +86,13 @@ class mozXMLTermSession
*/
NS_IMETHOD ReadAll(mozILineTermAux* lineTermAux, PRBool& processedData);
/** Aborts session by closing LineTerm and displays an error message
* @param lineTermAux LineTermAux object to be closed
* @param abortCode abort code string to be displayed
*/
NS_IMETHOD Abort(mozILineTermAux* lineTermAux,
nsString& abortCode);
/** Gets current entry (command) number
* @param aNumber (output) current entry number
*/
@ -212,11 +227,6 @@ protected:
TREE_ACTION_CODES = 7
};
/** Resizes XMLterm to match a resized window.
* @param lineTermAux LineTermAux object to be resized (may be null)
*/
NS_IMETHOD Resize(mozILineTermAux* lineTermAux);
/** Displays ("echoes") input text string with style and positions cursor
* @param aString string to be displayed
* @param aStyle style values for string (see lineterm.h)

View File

@ -50,6 +50,9 @@
#include "nsIClipboard.h"
#include "nsITransferable.h"
#include "nsFont.h"
#include "nsIFontMetrics.h"
#include "mozXMLT.h"
#include "mozXMLTermUtils.h"
#include "mozXMLTerminal.h"
@ -439,6 +442,23 @@ NS_IMETHODIMP mozXMLTerminal::Activate(void)
mPresShell = presShell; // no addref
mDOMDocument = domDocument; // no addref
// Show caret
ShowCaret();
// Determine current screen dimensions
PRInt32 nRows, nCols, xPixels, yPixels;
result = ScreenSize(nRows, nCols, xPixels, yPixels);
if (NS_FAILED(result))
return result;
// The above call does not return the correct screen dimensions.
// (because rendering is still in progress?)
// As a workaround, explicitly set screen dimensions
nRows = 24;
nCols = 80;
xPixels = 0;
yPixels = 0;
// Instantiate and initialize XMLTermSession object
mXMLTermSession = new mozXMLTermSession();
@ -446,17 +466,15 @@ NS_IMETHODIMP mozXMLTerminal::Activate(void)
return NS_ERROR_OUT_OF_MEMORY;
}
result = mXMLTermSession->Init(this, mPresShell, mDOMDocument);
result = mXMLTermSession->Init(this, mPresShell, mDOMDocument, nRows, nCols);
if (NS_FAILED(result)) {
XMLT_WARNING("mozXMLTerminal::Activate: Warning - Failed to initialize XMLTermSession\n");
return NS_ERROR_FAILURE;
}
// Show caret
ShowCaret();
// Instantiate LineTerm
XMLT_LOG(mozXMLTerminal::Activate,22,("instantiating lineterm\n"));
XMLT_LOG(mozXMLTerminal::Activate,22,
("instantiating lineterm, nRows=%d, nCols=%d\n", nRows, nCols));
result = NS_NewLineTermAux(getter_AddRefs(mLineTermAux));
if (NS_FAILED(result)) {
XMLT_WARNING("mozXMLTerminal::Activate: Warning - Failed to instantiate LineTermAux\n");
@ -477,6 +495,7 @@ NS_IMETHODIMP mozXMLTerminal::Activate(void)
mInitInput.GetUnicode(),
mPromptExpr.GetUnicode(),
options, LTERM_DETERMINE_PROCESS,
nRows, nCols, xPixels, yPixels,
mDOMDocument, anObserver, cookie);
if (NS_FAILED(result)) {
@ -488,7 +507,7 @@ NS_IMETHODIMP mozXMLTerminal::Activate(void)
// Save cookie
mCookie = cookie;
// Resize XMLterm
// Resize XMLterm (before displaying any output)
result = Resize();
if (NS_FAILED(result))
return result;
@ -567,6 +586,80 @@ NS_IMETHODIMP mozXMLTerminal::Activate(void)
}
/** Returns current screen size in rows/cols and in pixels
* @param (output) rows
* @param (output) cols
* @param (output) xPixels
* @param (output) yPixels
*/
NS_IMETHODIMP mozXMLTerminal::ScreenSize(PRInt32& rows, PRInt32& cols,
PRInt32& xPixels, PRInt32& yPixels)
{
nsresult result;
XMLT_LOG(mozXMLTerminal::ScreenSize,70,("\n"));
// Get presentation context
nsCOMPtr<nsIPresContext> presContext;
result = mPresShell->GetPresContext( getter_AddRefs(presContext) );
if (NS_FAILED(result))
return result;
// Get the default fixed pitch font
nsFont defaultFixedFont("dummyfont", NS_FONT_STYLE_NORMAL,
NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL,
NS_FONT_DECORATION_NONE, 16);
result = presContext->GetDefaultFixedFont(defaultFixedFont);
if (NS_FAILED(result))
return result;
// Get metrics for fixed font
nsCOMPtr<nsIFontMetrics> fontMetrics;
result = presContext->GetMetricsFor(defaultFixedFont,
getter_AddRefs(fontMetrics));
if (NS_FAILED(result) || !fontMetrics)
return result;
// Get font height (includes leading?)
nscoord fontHeight, fontWidth;
result = fontMetrics->GetHeight(fontHeight);
result = fontMetrics->GetMaxAdvance(fontWidth);
// Determine docshell size in twips
nsRect shellArea;
result = presContext->GetVisibleArea(shellArea);
if (NS_FAILED(result))
return result;
// Determine twips to pixels conversion factor
float pixelScale;
presContext->GetTwipsToPixels(&pixelScale);
// Convert dimensions to pixels
float xdel, ydel;
xdel = pixelScale * fontWidth;
ydel = pixelScale * fontHeight + 2;
xPixels = (int) (pixelScale * shellArea.height);
yPixels = (int) (pixelScale * shellArea.width);
// Determine number of rows/columns
rows = (int) ((xPixels-44) / ydel);
cols = (int) ((yPixels-20) / xdel);
if (rows < 1) rows = 1;
if (cols < 1) cols = 1;
XMLT_LOG(mozXMLTerminal::ScreenSize,72,
("rows=%d, cols=%d, xPixels=%d, yPixels=%d\n",
rows, cols, xPixels, yPixels));
return NS_OK;
}
// Transmit string to LineTerm (use saved cookie)
NS_IMETHODIMP mozXMLTerminal::SendTextAux(const nsString& aString)
{
@ -592,8 +685,9 @@ NS_IMETHODIMP mozXMLTerminal::SendText(const nsString& aString,
if (!consumed) {
result = mLineTermAux->Write(sendStr.GetUnicode(), aCookie);
if (NS_FAILED(result)) {
// Close LineTerm
mLineTermAux->Close(aCookie);
// Abort XMLterm session
nsAutoString abortCode = "SendText";
mXMLTermSession->Abort(mLineTermAux, abortCode);
return NS_ERROR_FAILURE;
}
}
@ -813,6 +907,7 @@ NS_IMETHODIMP mozXMLTerminal::Resize(void)
if (!mXMLTermSession)
return NS_ERROR_FAILURE;
// Delay resizing until next command output display
result = mXMLTermSession->NeedsResizing();
if (NS_FAILED(result))
return result;

View File

@ -87,6 +87,9 @@ class mozXMLTerminal : public mozIXMLTerminal,
NS_IMETHOD ShowCaret(void);
NS_IMETHOD ScreenSize(PRInt32& rows, PRInt32& cols,
PRInt32& xPixels, PRInt32& yPixels);
// nsIDocumentLoaderObserver interface
NS_DECL_NSIDOCUMENTLOADEROBSERVER

View File

@ -100,6 +100,7 @@ static void pty_error(const char *errmsg, const char *errmsg2);
/* creates a new pseudo-TTY */
int pty_create(struct ptys *ptyp, char *const argv[],
int rows, int cols, int x_pixels, int y_pixels,
int errfd, int noblock, int noecho, int noexport, int debug)
{
pid_t child_pid;
@ -124,7 +125,7 @@ int pty_create(struct ptys *ptyp, char *const argv[],
#ifndef BSDFAMILY
/* Set default TTY size */
if (pty_resize(ptyp, 24, 80, 0, 0) != 0)
if (pty_resize(ptyp, rows, cols, x_pixels, y_pixels) != 0)
return -1;
#endif
@ -170,7 +171,7 @@ int pty_create(struct ptys *ptyp, char *const argv[],
#ifdef BSDFAMILY
/* Set default TTY size */
if (pty_resize(NULL, 24, 80, 0, 0) != 0)
if (pty_resize(NULL, rows, cols, x_pixels, y_pixels) != 0)
return -1;
#endif

View File

@ -60,6 +60,9 @@ struct ptys { /* PTY structure */
/* creates a new pseudo-TTY (PTY) and also a new process attached to
* it to execute the command line contained in array ARGV.
* The PTY details are stored in the PTY structure PTYP.
* ROWS, COLS contain the initial no. of rows/columns.
* X_PIXELS, Y_PIXELS contain the initial screen size in pixels
* (may be set to zero if screen size is unknown).
* ERRFD is the file descriptor to which the STDERR output of the
* child process is directed.
* If ERRFD == -1, then the STDERR output is redirected to STDOUT.
@ -73,6 +76,7 @@ struct ptys { /* PTY structure */
* Returns 0 on success and -1 on error.
*/
int pty_create(struct ptys *ptyp, char *const argv[],
int rows, int cols, int x_pixels, int y_pixels,
int errfd, int noblock, int noecho, int noexport, int debug);
/* resizes a PTY; if ptyp is null, resizes file desciptor 0,

View File

@ -306,7 +306,9 @@ int main(int argc, char *argv[]) {
ltermNumber = lterm_new();
retValue = lterm_open(ltermNumber, commandArgs, NULL, NULL, uregexp,
options, processType, NULL, NULL);
options, processType,
24, 80, 0, 0,
NULL, NULL);
if (retValue < 0) {
fprintf(stderr, "lterm: Error %d in opening LTERM\n", retValue);
exit(1);

View File

@ -128,7 +128,8 @@ void ptyTest(int argc, char *argv[])
char temstr[3] = "^@";
/* Create a PTY */
if (pty_create(&ptyStruc,argv,-1,0,0,0,1) == -1) {
if (pty_create(&ptyStruc,argv,24,80,0,0,
-1,0,0,0,1) == -1) {
fprintf(stderr, "PTY creation failed\n");
exit(-1);
}
@ -153,7 +154,10 @@ void ptyTest(int argc, char *argv[])
ch = getchar();
/* Exit poll loop if a Control-] character is read */
if (ch == 0x1D) break;
if (ch == 0x1D) {
fprintf(stderr, "EXIT ptytest\n");
break;
}
if (write(ptyFD, &ch, 1) != 1) {
fprintf(stderr, "Error in writing to child STDIN\n");

View File

@ -28,7 +28,7 @@
<window id="xmlterm-window" xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="StartupXMLTerm();"
title="xmlterm" align="vertical" width="740" height="484">
title="xmlterm" align="vertical" width="586" height="444">
<html:script src="chrome://xmlterm/content/XMLTermChrome.js"></html:script>

View File

@ -13,6 +13,9 @@ PRE { font-family: monaco;
SPAN.prompt { color: blue }
SPAN.command { color: blue }
/* Error messages */
DIV.errmsg { color: red }
/* Explicit hyperlinks (underlined) */
DIV.textlink { font-family: monaco; color: blue; cursor: hand;
text-decoration: underline }