26 #if defined(__osf__) || defined(__APPLE__)
32 #if defined(AVOID_XKB)
42 #include <QtCore/QEvent>
44 #include <QtCore/QByteRef>
51 void scrolllock_set_off();
52 void scrolllock_set_on();
82 _titleUpdateTimer(new QTimer(this))
182 #define TY_CONSTR(T,A,N) ( ((((int)N) & 0xffff) << 16) | ((((int)A) & 0xff) << 8) | (((int)T) & 0xff) )
184 #define TY_CHR( ) TY_CONSTR(0,0,0)
185 #define TY_CTL(A ) TY_CONSTR(1,A,0)
186 #define TY_ESC(A ) TY_CONSTR(2,A,0)
187 #define TY_ESC_CS(A,B) TY_CONSTR(3,A,B)
188 #define TY_ESC_DE(A ) TY_CONSTR(4,A,0)
189 #define TY_CSI_PS(A,N) TY_CONSTR(5,A,N)
190 #define TY_CSI_PN(A ) TY_CONSTR(6,A,0)
191 #define TY_CSI_PR(A,N) TY_CONSTR(7,A,N)
193 #define TY_VT52(A ) TY_CONSTR(8,A,0)
195 #define TY_CSI_PG(A ) TY_CONSTR(9,A,0)
197 #define TY_CSI_PE(A ) TY_CONSTR(10,A,0)
242 for(i = 0; i < 256; i++)
tbl[ i] = 0;
243 for(i = 0; i < 32; i++)
tbl[ i] |=
CTL;
244 for(i = 32; i < 256; i++)
tbl[ i] |=
CHR;
245 for(s = (quint8*)
"@ABCDGHILMPSTXZcdfry"; *s; s++)
tbl[*s] |=
CPN;
247 for(s = (quint8*)
"t"; *s; s++)
tbl[*s] |=
CPS;
248 for(s = (quint8*)
"0123456789" ; *s; s++)
tbl[*s] |=
DIG;
249 for(s = (quint8*)
"()+*%" ; *s; s++)
tbl[*s] |=
SCS;
250 for(s = (quint8*)
"()+*#[]%" ; *s; s++)
tbl[*s] |=
GRP;
269 #define lec(P,L,C) (p == (P) && s[(L)] == (C))
270 #define lun( ) (p == 1 && cc >= 32 )
271 #define les(P,L,C) (p == (P) && s[L] < 256 && (tbl[s[(L)]] & (C)) == (C))
272 #define eec(C) (p >= 3 && cc == (C))
273 #define ees(C) (p >= 3 && cc < 256 && (tbl[ cc ] & (C)) == (C))
274 #define eps(C) (p >= 3 && s[2] != '?' && s[2] != '!' && s[2] != '>' && cc < 256 && (tbl[ cc ] & (C)) == (C))
275 #define epp( ) (p >= 3 && s[2] == '?' )
276 #define epe( ) (p >= 3 && s[2] == '!' )
277 #define egt( ) (p >= 3 && s[2] == '>' )
278 #define Xpe (ppos>=2 && pbuf[1] == ']' )
279 #define Xte (Xpe && cc == 7 )
280 #define ces(C) ( cc < 256 && (tbl[ cc ] & (C)) == (C) && !Xte)
283 #define CNTL(c) ((c)-'@')
290 if (cc == 127)
return;
308 if (
lec(1,0,
ESC)) {
return; }
310 if (
les(2,1,
GRP)) {
return; }
312 if (
Xpe ) {
return; }
313 if (
lec(3,2,
'?')) {
return; }
314 if (
lec(3,2,
'>')) {
return; }
315 if (
lec(3,2,
'!')) {
return; }
328 for (i=0;i<=
argc;i++)
331 else if (cc ==
'm' &&
argc - i >= 4 && (
argv[i] == 38 ||
argv[i] == 48) &&
argv[i+1] == 2)
337 else if (cc ==
'm' &&
argc - i >= 2 && (
argv[i] == 38 ||
argv[i] == 48) &&
argv[i+1] == 5)
349 if (
lec(2,1,
'Y'))
return;
350 if (
lec(3,1,
'Y'))
return;
358 for (i = 2; i <
ppos &&
'0'<=
pbuf[i] &&
pbuf[i]<
'9' ; i++)
359 arg = 10*arg + (pbuf[i]-
'0');
361 QChar *str =
new QChar[ppos-i-2];
362 for (
int j = 0; j < ppos-i-2; j++) str[j] = pbuf[i+1+j];
363 QString unistr(str,ppos-i-2);
377 while (iter.hasNext()) {
378 int arg = iter.next();
406 int N = (token>>0)&0xff;
407 int A = (token>>8)&0xff;
410 case 0: printf(
"%c", (p < 128) ? p :
'?');
412 case 1:
if (A ==
'J') printf(
"\r");
413 else if (A ==
'M') printf(
"\n");
414 else printf(
"CTL-%c ", (token>>8)&0xff);
416 case 2: printf(
"ESC-%c ", (token>>8)&0xff);
418 case 3: printf(
"ESC_CS-%c-%c ", (token>>8)&0xff, (token>>16)&0xff);
420 case 4: printf(
"ESC_DE-%c ", (token>>8)&0xff);
422 case 5: printf(
"CSI-PS-%c-%d", (token>>8)&0xff, (token>>16)&0xff );
424 case 6: printf(
"CSI-PN-%c [%d]", (token>>8)&0xff, p);
426 case 7: printf(
"CSI-PR-%c-%d", (token>>8)&0xff, (token>>16)&0xff );
428 case 8: printf(
"VT52-%c", (token>>8)&0xff);
430 case 9: printf(
"CSI-PG-%c", (token>>8)&0xff);
432 case 10: printf(
"CSI-PE-%c", (token>>8)&0xff);
444 case TY_CTL(
'@' ) :
break;
445 case TY_CTL(
'A' ) :
break;
446 case TY_CTL(
'B' ) :
break;
447 case TY_CTL(
'C' ) :
break;
448 case TY_CTL(
'D' ) :
break;
450 case TY_CTL(
'F' ) :
break;
463 case TY_CTL(
'P' ) :
break;
464 case TY_CTL(
'Q' ) :
break;
465 case TY_CTL(
'R' ) :
break;
466 case TY_CTL(
'S' ) :
break;
467 case TY_CTL(
'T' ) :
break;
468 case TY_CTL(
'U' ) :
break;
469 case TY_CTL(
'V' ) :
break;
470 case TY_CTL(
'W' ) :
break;
472 case TY_CTL(
'Y' ) :
break;
474 case TY_CTL(
'[' ) :
break;
475 case TY_CTL(
'\\' ) :
break;
476 case TY_CTL(
']' ) :
break;
477 case TY_CTL(
'^' ) :
break;
478 case TY_CTL(
'_' ) :
break;
863 sprintf(tmp,
"\033[%d;1;1;112;112;1;0x",p);
878 #define ANSWER_BACK "" // This is really obsolete VT100 stuff.
905 if ( cx<1 || cy<1 )
return;
908 if (cb >= 4) cb += 0x3c;
914 sprintf(tmp,
"\033[M%c%c%c",cb+0x20,cx+0x20,cy+0x20);
920 #define encodeMode(M,B) BITS(B,getMode(M))
921 #define encodeStat(M,B) BITS(B,((ev->modifiers() & (M)) == (M)))
925 if (!text.isEmpty()) {
926 QKeyEvent event(QEvent::KeyPress,
937 Qt::KeyboardModifiers modifiers =
event->modifiers();
955 QByteArray textToSend;
964 if ( modifiers & Qt::AltModifier && !(wantsAltModifier || wantsAnyModifier)
965 && !event->text().isEmpty() )
967 #if !defined(Q_OS_MAC)
968 textToSend.prepend(
"\033");
978 else if ( !entry.
text().isEmpty() )
980 textToSend +=
_codec->fromUnicode(entry.
text(
true,modifiers));
983 textToSend +=
_codec->fromUnicode(event->text());
985 sendData( textToSend.constData() , textToSend.length() );
991 QString translatorError = (
"No keyboard translator available. "
992 "The information needed to convert key presses "
993 "into characters to send to the terminal "
997 receiveData( translatorError.toAscii().constData() , translatorError.count() );
1025 #define CHARSET _charset[_currentScreen==_screen[1]]
1032 if (
CHARSET.pound && c ==
'#' )
return 0xa3;
1047 strncpy(
_charset[scrno].charset,
"BBBB",4);
1210 if ( entry.
text().count() > 0 )
1211 return entry.
text()[0];
1232 for (i = 0; i < len; i++)
1237 if ((s[i]) > 32 && s[i] < 127)
1240 printf(
"\\%04x(hex)",s[i]);
1245 if (
ppos == 0 || (
ppos == 1 && (
pbuf[0] & 0xff) >= 32)) {
void changeTabStop(bool set)
Sets or removes a tab stop at the cursor's current column.
void clearToEndOfLine()
Clears from the current cursor position to the end of the line.
void setForeColor(int space, int color)
Sets the cursor's foreground color.
void setAndUseCharset(int n, int cs)
void setCursorY(int y)
Position the cursor on line y.
void clearSelection()
Clears the current selection.
The terminal program has triggered a bell event to get the user's attention.
Qt::KeyboardModifiers modifierMask() const
Returns the keyboard modifiers which are valid in this entry.
void setBackColor(int space, int color)
Sets the cursor's background color.
virtual char getErase() const
TODO Document me.
static void hexdump(int *s, int len)
virtual void resetMode(int mode)
void reset(bool clearScreen=true)
Resets the state of the screen.
void setDefaultMargins()
Resets the scrolling margins back to the top and bottom lines of the screen.
virtual void clearEntireScreen()
Copies the current image into the history and clears the screen.
static const int LINE_DOUBLEWIDTH
Echos the operating system specific erase character.
void reportTerminalType()
void setScreen(int index)
Sets the active screen.
Command command() const
Returns the commands associated with this entry.
virtual void receiveChar(int cc)
Processes an incoming character.
Vt102Emulation()
Constructs a new emulation.
void Tabulate(int n=1)
Moves the cursor n tab-stops to the right.
void bufferedUpdate()
Schedules an update of attached views.
int getCursorY() const
Returns the line which the cursor is positioned on.
void setCursorYX(int y, int x)
Position the cursor at line y, column x.
Entry findEntry(int keyCode, Qt::KeyboardModifiers modifiers, States state=NoState) const
Looks for an entry in this keyboard translator which matches the given key code, keyboard modifiers a...
void eraseChars(int n)
Erase n characters beginning from the current cursor position.
int getLines()
Return the number of lines.
void reportSecondaryAttributes()
void cursorRight(int n)
Move the cursor to the right by n columns.
F77_RET_T const octave_idx_type Complex * A
void helpAlign()
Fills the entire screen with the letter 'E'.
Base class for terminal emulation back-ends.
#define COLOR_SPACE_DEFAULT
void reportTerminalParms(int p)
QHash< int, QString > _pendingTitleUpdates
void resetCharset(int scrno)
void scan_buffer_report()
void clearToEndOfScreen()
Clear the area of the screen from the current cursor position to the end of the screen.
void setMargins(int top, int bottom)
void resetMode(int mode)
Resets (clears) the specified screen mode.
void backTabulate(int n)
Moves the cursor n tab-stops to the left.
virtual void setImageSize(int lines, int columns)
Change the size of the emulation's image.
void sendData(const char *data, int len)
Emitted when a buffer of data is ready to send to the standard input of the terminal.
void BackSpace()
Moves the cursor one column to the left and erases the character at the new cursor position...
void reportCursorPosition()
Indicates that no special state is active.
void Return()
Moves the cursor to the beginning of the current line.
void setMargins(int topLine, int bottomLine)
Sets the margins for scrolling the screen.
QByteArray text(bool expandWildCards=false, Qt::KeyboardModifiers modifiers=Qt::NoModifier) const
Returns the character sequence associated with this entry, optionally replacing wildcard '*' characte...
unsigned short vt100_graphics[32]
void NewLine()
Moves the cursor down one line, if the MODE_NewLine mode flag is enabled then the cursor is returned ...
void clearEntireScreen()
Clear the whole screen, moving the current screen contents into the history first.
void programUsesMouseChanged(bool usesMouse)
This is emitted when the program running in the shell indicates whether or not it is interested in mo...
void clearToBeginOfScreen()
Clear the area of the screen from the current cursor position to the start of the screen...
void tau(int code, int p, int q)
void clearScreenAndSetColumns(int columnCount)
virtual void sendString(const char *, int length=-1)
void stateSet(int state)
Emitted when the activity state of the emulation is set.
virtual void setMode(int mode)
unsigned short applyCharset(unsigned short c)
bool mode[(MODES_SCREEN+8)]
const QTextCodec * _codec
States state() const
Returns a bitwise-OR of the enabled state flags associated with this entry.
void setDefaultRendition()
Resets the cursor's color back to the default and sets the character's rendition flags back to the de...
void clearToBeginOfLine()
Clears from the current cursor position to the beginning of the line.
void deleteLines(int n)
Removes n lines beginning from the current cursor position.
States stateMask() const
Returns the state flags which are valid in this entry.
void reverseIndex()
Move the cursor up one line.
virtual void sendKeyEvent(QKeyEvent *)
Indicates that the alternate screen ( typically used by interactive programs such as screen or vim ) ...
Indicates that the terminal is in 'Ansi' mode.
void insertChars(int n)
Insert n blank characters beginning from the current cursor position.
virtual void sendText(const QString &text)
int getCursorX() const
Returns the column which the cursor is positioned at.
Indicates that no command is associated with this command sequence.
void titleChanged(int title, const QString &newTitle)
Emitted when the program running in the terminal wishes to update the session's title.
void index()
Move the cursor down one line.
void changeTabTextColorRequest(int color)
Requests that the color of the text used to represent the tabs associated with this emulation be chan...
const KeyboardTranslator * _keyTranslator
void restoreMode(int mode)
void setLineProperty(LineProperty property, bool enable)
Sets or clears an attribute of the current line.
void resetRendition(int rendition)
Disables the given rendition flag.
Qt::KeyboardModifiers modifiers() const
Returns a bitwise-OR of the enabled keyboard modifiers associated with this entry.
void clearEntireLine()
Clears the whole of the line on which the cursor is currently positioned.
void NextLine()
Moves the cursor down one line and positions it at the beginning of the line.
virtual void sendMouseEvent(int buttons, int column, int line, int eventType)
void insertLines(int n)
Inserts lines beginning from the current cursor position.
F77_RET_T const octave_idx_type & N
Represents an association between a key sequence pressed by the user and the character sequence and c...
void setCodec(const QTextCodec *)
Sets the codec used to decode incoming characters.
virtual void reset()
Resets the state of the terminal.
void deleteChars(int n)
Delete n characters beginning from the current cursor position.
void setCharset(int n, int cs)
void setMode(int mode)
Sets (enables) the specified screen mode.
void clearTabStops()
Clears all the tab stops.
void restoreCursor()
Restores the position and appearence of the cursor.
void restoreMode(int mode)
Restores the state of a screen mode saved by calling saveMode()
void scrollUp(int n)
Scroll the scrolling region of the screen up by n lines.
Indicates that any of the modifier keys is active.
void saveCursor()
Saves the current position and appearence (text color and style) of the cursor.
void cursorUp(int n)
Move the cursor up by n lines.
void receiveData(const char *buffer, int len)
Processes an incoming stream of characters.
void cursorDown(int n)
Move the cursor down by n lines.
void ShowCharacter(unsigned short c)
Displays a new character at the current cursor position.
void cursorLeft(int n)
Move the cursor to the left by n columns.
void scrollDown(int n)
Scroll the scrolling region of the screen down by n lines.
#define COLOR_SPACE_SYSTEM
void setCursorX(int x)
Position the cursor at column x.
static const int LINE_DOUBLEHEIGHT
QTimer * _titleUpdateTimer