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;
868 sprintf(tmp,
"\033[%d;1;1;112;112;1;0x",p);
883 #define ANSWER_BACK ""
910 if ( cx<1 || cy<1 )
return;
913 if (cb >= 4) cb += 0x3c;
919 sprintf(tmp,
"\033[M%c%c%c",cb+0x20,cx+0x20,cy+0x20);
925 #define encodeMode(M,B) BITS(B,getMode(M))
926 #define encodeStat(M,B) BITS(B,((ev->modifiers() & (M)) == (M)))
930 if (!
text.isEmpty()) {
931 QKeyEvent event(QEvent::KeyPress,
942 Qt::KeyboardModifiers modifiers =
event->modifiers();
960 QByteArray textToSend;
969 if ( modifiers & Qt::AltModifier && !(wantsAltModifier || wantsAnyModifier)
970 && !event->text().isEmpty() )
972 #if !defined(Q_OS_MAC)
973 textToSend.prepend(
"\033");
983 else if ( !entry.
text().isEmpty() )
985 textToSend +=
_codec->fromUnicode(entry.
text(
true,modifiers));
987 else if (event->key() == Qt::Key_PageUp)
989 textToSend +=
"\033[5~";
991 else if (event->key() == Qt::Key_PageDown)
993 textToSend +=
"\033[6~";
996 textToSend +=
_codec->fromUnicode(event->text());
998 sendData( textToSend.constData() , textToSend.length() );
1004 QString translatorError = (
"No keyboard translator available. "
1005 "The information needed to convert key presses "
1006 "into characters to send to the terminal "
1010 receiveData( translatorError.toLatin1().constData() , translatorError.count() );
1038 #define CHARSET _charset[_currentScreen==_screen[1]]
1045 if (
CHARSET.pound && c ==
'#' )
return 0xa3;
1060 strncpy(
_charset[scrno].charset,
"BBBB",4);
1232 if ( entry.
text().count() > 0 )
1233 return entry.
text()[0];
1254 for (i = 0; i <
len; i++)
1259 if ((s[i]) > 32 && s[i] < 127)
1262 printf(
"\\%04x(hex)",s[i]);
1267 if (
ppos == 0 || (
ppos == 1 && (
pbuf[0] & 0xff) >= 32)) {
#define COLOR_SPACE_SYSTEM
#define COLOR_SPACE_DEFAULT
static const int LINE_DOUBLEHEIGHT
unsigned short vt100_graphics[32]
static const int LINE_DOUBLEWIDTH
@ NOTIFYBELL
The terminal program has triggered a bell event to get the user's attention.
static void hexdump(int *s, int len)
#define MODE_BracketedPaste
Base class for terminal emulation back-ends.
const QTextCodec * _codec
void receiveData(const char *buffer, int len)
Processes an incoming stream of characters.
void programUsesMouseChanged(bool usesMouse)
This is emitted when the program running in the shell indicates whether or not it is interested in mo...
void bufferedUpdate()
Schedules an update of attached views.
const KeyboardTranslator * _keyTranslator
void programBracketedPasteModeChanged(bool bracketedPasteMode)
void changeTabTextColorRequest(int color)
Requests that the color of the text used to represent the tabs associated with this emulation be chan...
void titleChanged(int title, const QString &newTitle)
Emitted when the program running in the terminal wishes to update the session's title.
void sendData(const char *data, int len)
Emitted when a buffer of data is ready to send to the standard input of the terminal.
virtual void setImageSize(int lines, int columns)
Change the size of the emulation's image.
void setScreen(int index)
Sets the active screen.
void stateSet(int state)
Emitted when the activity state of the emulation is set.
void setCodec(const QTextCodec *)
Sets the codec used to decode incoming characters.
Represents an association between a key sequence pressed by the user and the character sequence and c...
QByteArray text(bool expandWildCards=false, Qt::KeyboardModifiers modifiers=Qt::NoModifier) const
Returns the character sequence associated with this entry, optionally replacing wildcard '*' characte...
States state() const
Returns a bitwise-OR of the enabled state flags associated with this entry.
Command command() const
Returns the commands associated with this entry.
Qt::KeyboardModifiers modifiers() const
Returns a bitwise-OR of the enabled keyboard modifiers associated with this entry.
States stateMask() const
Returns the state flags which are valid in this entry.
Qt::KeyboardModifiers modifierMask() const
Returns the keyboard modifiers which are valid in this entry.
@ NewLineState
TODO More documentation.
@ NoState
Indicates that no special state is active.
@ AnyModifierState
Indicates that any of the modifier keys is active.
@ AnsiState
Indicates that the terminal is in 'Ansi' mode.
@ AlternateScreenState
Indicates that the alternate screen ( typically used by interactive programs such as screen or vim ) ...
@ CursorKeysState
TODO More documentation.
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...
@ EraseCommand
Echos the operating system specific erase character.
@ NoCommand
Indicates that no command is associated with this command sequence.
void backTabulate(int n)
Moves the cursor n tab-stops to the left.
void setCursorYX(int y, int x)
Position the cursor at line y, column x.
int getCursorY() const
Returns the line which the cursor is positioned on.
void clearToEndOfScreen()
Clear the area of the screen from the current cursor position to the end of the screen.
void deleteChars(int n)
Delete n characters beginning from the current cursor position.
void setMargins(int topLine, int bottomLine)
Sets the margins for scrolling the screen.
void reset(bool clearScreen=true)
Resets the state of the screen.
void clearEntireScreen()
Clear the whole screen, moving the current screen contents into the history first.
void saveCursor()
Saves the current position and appearence (text color and style) of the cursor.
void clearToBeginOfLine()
Clears from the current cursor position to the beginning of the line.
void clearEntireLine()
Clears the whole of the line on which the cursor is currently positioned.
void setCursorY(int y)
Position the cursor on line y.
void BackSpace()
Moves the cursor one column to the left and erases the character at the new cursor position.
void insertChars(int n)
Insert n blank characters beginning from the current cursor position.
void Return()
Moves the cursor to the beginning of the current line.
void changeTabStop(bool set)
Sets or removes a tab stop at the cursor's current column.
void cursorDown(int n)
Move the cursor down by n lines.
void setDefaultMargins()
Resets the scrolling margins back to the top and bottom lines of the screen.
void setCursorX(int x)
Position the cursor at column x.
void NewLine()
Moves the cursor down one line, if the MODE_NewLine mode flag is enabled then the cursor is returned ...
void clearTabStops()
Clears all the tab stops.
void clearToBeginOfScreen()
Clear the area of the screen from the current cursor position to the start of the screen.
void eraseChars(int n)
Erase n characters beginning from the current cursor position.
void helpAlign()
Fills the entire screen with the letter 'E'.
int getCursorX() const
Returns the column which the cursor is positioned at.
void Tabulate(int n=1)
Moves the cursor n tab-stops to the right.
void cursorUp(int n)
Move the cursor up by n lines.
void clearSelection()
Clears the current selection.
void setLineProperty(LineProperty property, bool enable)
Sets or clears an attribute of the current line.
void setMode(int mode)
Sets (enables) the specified screen mode.
void setDefaultRendition()
Resets the cursor's color back to the default and sets the character's rendition flags back to the de...
void scrollDown(int n)
Scroll the scrolling region of the screen down by n lines.
void scrollUp(int n)
Scroll the scrolling region of the screen up by n lines.
void NextLine()
Moves the cursor down one line and positions it at the beginning of the line.
void cursorRight(int n)
Move the cursor to the right by n columns.
void restoreMode(int mode)
Restores the state of a screen mode saved by calling saveMode()
void resetRendition(int rendition)
Disables the given rendition flag.
void restoreCursor()
Restores the position and appearence of the cursor.
void setBackColor(int space, int color)
Sets the cursor's background color.
void ShowCharacter(unsigned short c)
Displays a new character at the current cursor position.
void deleteLines(int n)
Removes n lines beginning from the current cursor position.
void resetMode(int mode)
Resets (clears) the specified screen mode.
void index()
Move the cursor down one line.
void reverseIndex()
Move the cursor up one line.
void clearToEndOfLine()
Clears from the current cursor position to the end of the line.
int getLines()
Return the number of lines.
void cursorLeft(int n)
Move the cursor to the left by n columns.
void setForeColor(int space, int color)
Sets the cursor's foreground color.
void insertLines(int n)
Inserts lines beginning from the current cursor position.
QTimer * _titleUpdateTimer
void reportTerminalType()
void setAndUseCharset(int n, int cs)
virtual void setMode(int mode)
void clearScreenAndSetColumns(int columnCount)
void setMargins(int top, int bottom)
virtual void reset()
Resets the state of the terminal.
void setCharset(int n, int cs)
virtual char getErase() const
TODO Document me.
void reportSecondaryAttributes()
void restoreMode(int mode)
virtual void sendMouseEvent(int buttons, int column, int line, int eventType)
virtual void sendKeyEvent(QKeyEvent *)
virtual void receiveChar(int cc)
Processes an incoming character.
virtual void sendText(const QString &text)
void reportTerminalParms(int p)
unsigned short applyCharset(unsigned short c)
QHash< int, QString > _pendingTitleUpdates
virtual void clearEntireScreen()
Copies the current image into the history and clears the screen.
Vt102Emulation()
Constructs a new emulation.
void reportCursorPosition()
void resetCharset(int scrno)
virtual void resetMode(int mode)
void scan_buffer_report()
virtual void sendString(const char *, int length=-1)
void tau(int code, int p, int q)
F77_RET_T const F77_INT & N
F77_RET_T const F77_INT F77_CMPLX * A
T::size_type strlen(const typename T::value_type *str)
bool mode[(MODES_SCREEN+9)]