mirror of
https://github.com/ksherlock/TwoTerm.git
synced 2024-12-22 07:30:40 +00:00
git-svn-id: svn://qnap.local/TwoTerm/trunk@1663 5590a31f-7b70-45f8-8c82-aa3a8e5f4507
This commit is contained in:
parent
9616e0ea39
commit
b2a91bd801
File diff suppressed because it is too large
Load Diff
@ -200,8 +200,8 @@
|
||||
<array/>
|
||||
<key>PerspectiveWidths</key>
|
||||
<array>
|
||||
<integer>1060</integer>
|
||||
<integer>1060</integer>
|
||||
<integer>1920</integer>
|
||||
<integer>1920</integer>
|
||||
</array>
|
||||
<key>Perspectives</key>
|
||||
<array>
|
||||
@ -285,13 +285,13 @@
|
||||
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
|
||||
<array>
|
||||
<array>
|
||||
<integer>4</integer>
|
||||
<integer>1</integer>
|
||||
<integer>24</integer>
|
||||
<integer>18</integer>
|
||||
<integer>0</integer>
|
||||
</array>
|
||||
</array>
|
||||
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
|
||||
<string>{{0, 0}, {324, 843}}</string>
|
||||
<string>{{0, 0}, {324, 1060}}</string>
|
||||
</dict>
|
||||
<key>PBXTopSmartGroupGIDs</key>
|
||||
<array/>
|
||||
@ -301,7 +301,7 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{0, 0}, {341, 861}}</string>
|
||||
<string>{{0, 0}, {341, 1078}}</string>
|
||||
<key>GroupTreeTableConfiguration</key>
|
||||
<array>
|
||||
<string>MainColumn</string>
|
||||
@ -322,7 +322,7 @@
|
||||
<key>PBXProjectModuleGUID</key>
|
||||
<string>B676054211DADB9000D6B66C</string>
|
||||
<key>PBXProjectModuleLabel</key>
|
||||
<string>VT52.mm</string>
|
||||
<string>EmulatorView.mm</string>
|
||||
<key>PBXSplitModuleInNavigatorKey</key>
|
||||
<dict>
|
||||
<key>Split0</key>
|
||||
@ -330,11 +330,11 @@
|
||||
<key>PBXProjectModuleGUID</key>
|
||||
<string>B676054311DADB9000D6B66C</string>
|
||||
<key>PBXProjectModuleLabel</key>
|
||||
<string>VT52.mm</string>
|
||||
<string>EmulatorView.mm</string>
|
||||
<key>_historyCapacity</key>
|
||||
<integer>0</integer>
|
||||
<key>bookmark</key>
|
||||
<string>B6358D1711F6863100437AA2</string>
|
||||
<string>B6D1D12B11FFB14A00196D8E</string>
|
||||
<key>history</key>
|
||||
<array>
|
||||
<string>B676058811DAE21100D6B66C</string>
|
||||
@ -347,7 +347,6 @@
|
||||
<string>B65FA28111E29EDE00EB447E</string>
|
||||
<string>B65FA2FE11E2A5D200EB447E</string>
|
||||
<string>B649E0B511E2A88D0061921F</string>
|
||||
<string>B699A0BE11E58D3B00F54CC8</string>
|
||||
<string>B699A0C211E58D3B00F54CC8</string>
|
||||
<string>B669797711E6A6CE002ED475</string>
|
||||
<string>B66979BD11E6ACB9002ED475</string>
|
||||
@ -367,11 +366,13 @@
|
||||
<string>B641C88811EA8DCC00B6359F</string>
|
||||
<string>B6E6A7BD11EAA92100A24C0C</string>
|
||||
<string>B64925C411EE622D0065E73A</string>
|
||||
<string>B609786811EEB3DC00623E03</string>
|
||||
<string>B609786911EEB3DC00623E03</string>
|
||||
<string>B6A0F71A11F22CD200AC3547</string>
|
||||
<string>B6358CC611F67B8200437AA2</string>
|
||||
<string>B6358CF511F683CA00437AA2</string>
|
||||
<string>B6BED9D111F7B4C30064628F</string>
|
||||
<string>B6FA9C5411FCE85B00F38EC1</string>
|
||||
<string>B6FA9C6611FCE9BC00F38EC1</string>
|
||||
<string>B6FA9C8711FCF97400F38EC1</string>
|
||||
<string>B6D1D11711FFA83D00196D8E</string>
|
||||
<string>B642D33111FFA14C00CBB349</string>
|
||||
</array>
|
||||
</dict>
|
||||
<key>SplitCount</key>
|
||||
@ -385,16 +386,16 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{0, 0}, {714, 331}}</string>
|
||||
<string>{{0, 0}, {1574, 497}}</string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXNavigatorGroup</string>
|
||||
<key>Proportion</key>
|
||||
<string>331pt</string>
|
||||
<string>497pt</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Proportion</key>
|
||||
<string>525pt</string>
|
||||
<string>576pt</string>
|
||||
<key>Tabs</key>
|
||||
<array>
|
||||
<dict>
|
||||
@ -408,7 +409,7 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{10, 27}, {714, 498}}</string>
|
||||
<string>{{10, 27}, {1574, 549}}</string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>XCDetailModule</string>
|
||||
@ -483,7 +484,7 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{10, 27}, {714, 498}}</string>
|
||||
<string>{{10, 27}, {714, 524}}</string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXBuildResultsModule</string>
|
||||
@ -492,7 +493,7 @@
|
||||
</dict>
|
||||
</array>
|
||||
<key>Proportion</key>
|
||||
<string>714pt</string>
|
||||
<string>1574pt</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>Name</key>
|
||||
@ -511,11 +512,11 @@
|
||||
</array>
|
||||
<key>TableOfContents</key>
|
||||
<array>
|
||||
<string>B6358CA811F667E200437AA2</string>
|
||||
<string>B6D1D11911FFA83D00196D8E</string>
|
||||
<string>1CA23ED40692098700951B8B</string>
|
||||
<string>B6358CA911F667E200437AA2</string>
|
||||
<string>B6D1D11A11FFA83D00196D8E</string>
|
||||
<string>B676054211DADB9000D6B66C</string>
|
||||
<string>B6358CAA11F667E200437AA2</string>
|
||||
<string>B6D1D11B11FFA83D00196D8E</string>
|
||||
<string>1CA23EDF0692099D00951B8B</string>
|
||||
<string>1CA23EE00692099D00951B8B</string>
|
||||
<string>1CA23EE10692099D00951B8B</string>
|
||||
@ -556,6 +557,8 @@
|
||||
<key>Layout</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>BecomeActive</key>
|
||||
<true/>
|
||||
<key>ContentConfiguration</key>
|
||||
<dict>
|
||||
<key>PBXProjectModuleGUID</key>
|
||||
@ -566,14 +569,14 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{0, 0}, {1060, 265}}</string>
|
||||
<string>{{0, 0}, {1920, 453}}</string>
|
||||
<key>RubberWindowFrame</key>
|
||||
<string>874 165 1060 902 0 0 1920 1178 </string>
|
||||
<string>0 59 1920 1119 0 0 1920 1178 </string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXDebugCLIModule</string>
|
||||
<key>Proportion</key>
|
||||
<string>265pt</string>
|
||||
<string>453pt</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>ContentConfiguration</key>
|
||||
@ -592,8 +595,8 @@
|
||||
<string>yes</string>
|
||||
<key>sizes</key>
|
||||
<array>
|
||||
<string>{{0, 0}, {517, 289}}</string>
|
||||
<string>{{517, 0}, {543, 289}}</string>
|
||||
<string>{{0, 0}, {936, 303}}</string>
|
||||
<string>{{936, 0}, {984, 303}}</string>
|
||||
</array>
|
||||
</dict>
|
||||
<key>VerticalSplitView</key>
|
||||
@ -608,8 +611,8 @@
|
||||
<string>yes</string>
|
||||
<key>sizes</key>
|
||||
<array>
|
||||
<string>{{0, 0}, {1060, 289}}</string>
|
||||
<string>{{0, 289}, {1060, 302}}</string>
|
||||
<string>{{0, 0}, {1920, 303}}</string>
|
||||
<string>{{0, 303}, {1920, 317}}</string>
|
||||
</array>
|
||||
</dict>
|
||||
</dict>
|
||||
@ -629,7 +632,7 @@
|
||||
<key>DebugSTDIOWindowFrame</key>
|
||||
<string>{{200, 200}, {500, 300}}</string>
|
||||
<key>Frame</key>
|
||||
<string>{{0, 270}, {1060, 591}}</string>
|
||||
<string>{{0, 458}, {1920, 620}}</string>
|
||||
<key>PBXDebugSessionStackFrameViewKey</key>
|
||||
<dict>
|
||||
<key>DebugVariablesTableConfiguration</key>
|
||||
@ -639,20 +642,20 @@
|
||||
<string>Value</string>
|
||||
<real>85</real>
|
||||
<string>Summary</string>
|
||||
<real>313</real>
|
||||
<real>754</real>
|
||||
</array>
|
||||
<key>Frame</key>
|
||||
<string>{{517, 0}, {543, 289}}</string>
|
||||
<string>{{936, 0}, {984, 303}}</string>
|
||||
<key>RubberWindowFrame</key>
|
||||
<string>874 165 1060 902 0 0 1920 1178 </string>
|
||||
<string>0 59 1920 1119 0 0 1920 1178 </string>
|
||||
</dict>
|
||||
<key>RubberWindowFrame</key>
|
||||
<string>874 165 1060 902 0 0 1920 1178 </string>
|
||||
<string>0 59 1920 1119 0 0 1920 1178 </string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXDebugSessionModule</string>
|
||||
<key>Proportion</key>
|
||||
<string>591pt</string>
|
||||
<string>620pt</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>Name</key>
|
||||
@ -670,14 +673,14 @@
|
||||
</array>
|
||||
<key>TableOfContents</key>
|
||||
<array>
|
||||
<string>B6358CAB11F667E200437AA2</string>
|
||||
<string>B6D1D11C11FFA83D00196D8E</string>
|
||||
<string>1CCC7628064C1048000F2A68</string>
|
||||
<string>1CCC7629064C1048000F2A68</string>
|
||||
<string>B6358CAC11F667E200437AA2</string>
|
||||
<string>B6358CAD11F667E200437AA2</string>
|
||||
<string>B6358CAE11F667E200437AA2</string>
|
||||
<string>B6358CAF11F667E200437AA2</string>
|
||||
<string>B6358CB011F667E200437AA2</string>
|
||||
<string>B6D1D11D11FFA83D00196D8E</string>
|
||||
<string>B6D1D11E11FFA83D00196D8E</string>
|
||||
<string>B6D1D11F11FFA83D00196D8E</string>
|
||||
<string>B6D1D12011FFA83D00196D8E</string>
|
||||
<string>B6D1D12111FFA83D00196D8E</string>
|
||||
</array>
|
||||
<key>ToolbarConfigUserDefaultsMinorVersion</key>
|
||||
<string>2</string>
|
||||
@ -711,15 +714,14 @@
|
||||
<integer>5</integer>
|
||||
<key>WindowOrderList</key>
|
||||
<array>
|
||||
<string>B6358D1411F685F800437AA2</string>
|
||||
<string>B6358CCA11F67B8200437AA2</string>
|
||||
<string>B6358CCB11F67B8200437AA2</string>
|
||||
<string>B6358CF411F683C800437AA2</string>
|
||||
<string>B6358CCC11F67B8200437AA2</string>
|
||||
<string>B6D1D12911FFAF5500196D8E</string>
|
||||
<string>B6D1D12311FFA83D00196D8E</string>
|
||||
<string>B6D1D12411FFA83D00196D8E</string>
|
||||
<string>B6D1D12511FFA83D00196D8E</string>
|
||||
<string>/Users/kelvin/Projects/2Term/2Term.xcodeproj</string>
|
||||
</array>
|
||||
<key>WindowString</key>
|
||||
<string>874 165 1060 902 0 0 1920 1178 </string>
|
||||
<string>0 59 1920 1119 0 0 1920 1178 </string>
|
||||
<key>WindowToolsV3</key>
|
||||
<array>
|
||||
<dict>
|
||||
@ -1092,7 +1094,7 @@
|
||||
<key>TableOfContents</key>
|
||||
<array>
|
||||
<string>1C530D5B069F1CE1000CFCEE</string>
|
||||
<string>B60EBE6811E91E1E00C1974F</string>
|
||||
<string>B6BED9FA11F7C2980064628F</string>
|
||||
<string>1C78EAAC065D492600B07095</string>
|
||||
</array>
|
||||
<key>ToolbarConfiguration</key>
|
||||
|
@ -124,12 +124,12 @@
|
||||
NSRect screenRect = dirtyRect;
|
||||
|
||||
unsigned x, y;
|
||||
unsigned lastFlag = 0;
|
||||
|
||||
|
||||
|
||||
NSColor *currentFront;
|
||||
NSColor *currentBack;
|
||||
unsigned currentFlag;
|
||||
BOOL setFront = YES;
|
||||
|
||||
screenRect.origin.x -= _paddingLeft;
|
||||
screenRect.origin.y -= _paddingTop;
|
||||
@ -163,7 +163,6 @@
|
||||
|
||||
currentFront = _foregroundColor;
|
||||
currentBack = _backgroundColor;
|
||||
currentFlag = Screen::FlagNormal;
|
||||
|
||||
_screen.lock();
|
||||
|
||||
@ -175,35 +174,36 @@
|
||||
NSRect charRect = NSMakeRect(_paddingLeft + x * _charWidth, _paddingTop + y *_charHeight, _charWidth, _charHeight);
|
||||
NSImage *img;
|
||||
CharInfo ci = _screen.getc(x, y);
|
||||
unsigned flag = ci.flag;
|
||||
|
||||
// todo -- check flags to determine fg/bg color, etc.
|
||||
// need to draw background individually....
|
||||
if (currentFlag != ci.flag)
|
||||
{
|
||||
currentFlag = ci.flag;
|
||||
|
||||
currentBack = _backgroundColor;
|
||||
currentFront = _foregroundColor;
|
||||
if (lastFlag & Screen::FlagBold)
|
||||
currentFront = _boldColor;
|
||||
|
||||
if (lastFlag & Screen::FlagInverse)
|
||||
{
|
||||
std::swap(currentFront, currentBack);
|
||||
}
|
||||
|
||||
if (currentFront != _foregroundColor)
|
||||
[currentFront setFill];
|
||||
}
|
||||
|
||||
currentBack = _backgroundColor;
|
||||
currentFront = _foregroundColor;
|
||||
|
||||
if (flag & Screen::FlagBold)
|
||||
currentFront = _boldColor;
|
||||
|
||||
|
||||
img = [_charGen imageForCharacter: ci.c];
|
||||
|
||||
if (flag & Screen::FlagInverse)
|
||||
{
|
||||
std::swap(currentBack, currentFront);
|
||||
}
|
||||
|
||||
if (currentBack != _backgroundColor)
|
||||
{
|
||||
[currentBack setFill];
|
||||
NSRectFill(charRect);
|
||||
[currentFront setFill];
|
||||
setFront = YES;
|
||||
}
|
||||
|
||||
if (_foregroundColor != currentFront) setFront = YES;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
[img drawAtPoint: NSMakePoint(x * _charWidth, y * _charHeight)
|
||||
@ -213,6 +213,8 @@
|
||||
*/
|
||||
if (img)
|
||||
{
|
||||
if (setFront) [currentFront setFill];
|
||||
|
||||
[img drawInRect: charRect
|
||||
fromRect: NSZeroRect operation: NSCompositeCopy
|
||||
fraction: 1.0
|
||||
|
21
VT100.h
21
VT100.h
@ -27,8 +27,27 @@
|
||||
BOOL _keyMode;
|
||||
BOOL _vt52Mode;
|
||||
BOOL _graphics;
|
||||
|
||||
|
||||
iPoint _dca;
|
||||
|
||||
|
||||
struct __vt100flags {
|
||||
unsigned int DECANM:1; // vt52 mode
|
||||
unsigned int DECARM:1; // auto repeat mode.
|
||||
unsigned int DECAWM:1; // autowrap mode
|
||||
unsigned int DECCKM:1; // cursor key mode.
|
||||
unsigned int DECKPAM:1; // alternate keypad.
|
||||
unsigned int DECKPNM:1; // not alternate keypad.
|
||||
unsigned int DECCOLM:1; // 80/132 mode.
|
||||
unsigned int DECSCLM:1; // scrolling
|
||||
unsigned int DECSCNM:1; // screen
|
||||
unsigned int DECOM:1; // origin
|
||||
unsigned int DECINLM:1; // interlace
|
||||
|
||||
unsigned int LNM:1; // line feed new line mode.
|
||||
|
||||
|
||||
} _flags;
|
||||
|
||||
#ifdef __cplusplus
|
||||
std::vector<int> _parms;
|
||||
|
354
VT100.mm
354
VT100.mm
@ -23,10 +23,18 @@ enum {
|
||||
StateDCAY,
|
||||
StateDCAX,
|
||||
StateBracket,
|
||||
StateBracketQuestion,
|
||||
StatePound
|
||||
};
|
||||
|
||||
|
||||
-(id)init
|
||||
{
|
||||
self = [super init];
|
||||
[self reset];
|
||||
|
||||
return self;
|
||||
}
|
||||
-(NSString *)name
|
||||
{
|
||||
return @"VT100";
|
||||
@ -53,6 +61,22 @@ enum {
|
||||
{
|
||||
_state = StateText;
|
||||
_vt52Mode = NO;
|
||||
|
||||
_flags.DECANM = 1; // ansi/vt100 mode
|
||||
_flags.DECARM = 0;
|
||||
_flags.DECAWM = 0;
|
||||
_flags.DECCKM = 0;
|
||||
_flags.DECKPAM = 0;
|
||||
_flags.DECKPNM = 1;
|
||||
_flags.DECCOLM = 0;
|
||||
|
||||
_flags.DECSCLM = 0;
|
||||
_flags.DECSCNM = 0;
|
||||
_flags.DECOM = 0;
|
||||
_flags.DECINLM = 0;
|
||||
_flags.LNM = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -200,6 +224,154 @@ enum {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (_state == StateBracketQuestion)
|
||||
{
|
||||
// ESC [? \d+ h|l
|
||||
switch(c)
|
||||
{
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
_parms.back() = _parms.back() * 10 + (c - '0');
|
||||
break;
|
||||
|
||||
case ';':
|
||||
_parms.push_back(0);
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
{
|
||||
// h = set
|
||||
std::vector<int>::iterator iter;
|
||||
|
||||
for (iter = _parms.begin(); iter != _parms.end(); ++iter)
|
||||
{
|
||||
switch (*iter)
|
||||
{
|
||||
/*
|
||||
case 20:
|
||||
_flags.LNM = 1;
|
||||
break;
|
||||
*/
|
||||
|
||||
case 1:
|
||||
_flags.DECCKM = 1;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
_flags.DECCOLM = 1;
|
||||
screen->setSize(132, 24);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
_flags.DECSCLM = 1;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
_flags.DECSCNM = 1;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
_flags.DECOM = 1;
|
||||
break;
|
||||
|
||||
case 7:
|
||||
_flags.DECAWM = 1;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
_flags.DECARM = 1;
|
||||
break;
|
||||
|
||||
case 9:
|
||||
_flags.DECINLM = 1;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
_state = StateText;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'l':
|
||||
{
|
||||
|
||||
// l = reset
|
||||
std::vector<int>::iterator iter;
|
||||
|
||||
for (iter = _parms.begin(); iter != _parms.end(); ++iter)
|
||||
{
|
||||
switch (*iter)
|
||||
{
|
||||
/*
|
||||
case 20:
|
||||
_flags.LNM = 0;
|
||||
break;
|
||||
*/
|
||||
|
||||
case 1:
|
||||
_flags.DECCKM = 0;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
_vt52Mode = YES;
|
||||
_flags.DECANM = 0;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
_flags.DECCOLM = 0;
|
||||
screen->setSize(80, 24);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
_flags.DECSCLM = 0;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
_flags.DECSCNM = 0;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
_flags.DECOM = 0;
|
||||
break;
|
||||
|
||||
case 7:
|
||||
_flags.DECAWM = 0;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
_flags.DECARM = 0;
|
||||
break;
|
||||
|
||||
case 9:
|
||||
_flags.DECINLM = 0;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
_state = StateText;
|
||||
break;
|
||||
|
||||
}
|
||||
default:
|
||||
NSLog(@"[%s %s]: unrecognized escape character: `ESC [? %d %c' (%02x)",
|
||||
object_getClassName(self), sel_getName(_cmd), _parms[0], c, (int)c);
|
||||
|
||||
_state = StateText;
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (_state == StateBracket)
|
||||
{
|
||||
// '[' [0-9]* CODE
|
||||
@ -224,6 +396,11 @@ enum {
|
||||
_parms.push_back(0);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
_parms.clear();
|
||||
_parms.push_back(0);
|
||||
_state = StateBracketQuestion;
|
||||
break;
|
||||
|
||||
case 'A':
|
||||
// cursor up. default 1.
|
||||
@ -339,6 +516,132 @@ enum {
|
||||
}
|
||||
|
||||
|
||||
case 'c':
|
||||
{
|
||||
// who are you?
|
||||
|
||||
output->write(ESC "[?1;0c");
|
||||
|
||||
_state = StateText;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case 'n':
|
||||
// status reports.
|
||||
{
|
||||
char *str = NULL;
|
||||
|
||||
switch (_parms[0])
|
||||
{
|
||||
case 5:
|
||||
// terminal status report
|
||||
// ESC [ 0 n == terminal ok
|
||||
// ESC [ 3 n == terminal not ok.
|
||||
output->write(ESC "0n");
|
||||
break;
|
||||
|
||||
case 6:
|
||||
// cursor position
|
||||
// ESC [ line ; column R
|
||||
asprintf(&str, ESC "[%u;%uR", screen->y() + 1, screen->x() + 1);
|
||||
if (str)
|
||||
{
|
||||
output->write(str);
|
||||
free(str);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
NSLog(@"[%s %s]: unrecognized escape character: `ESC [ %d %c'",
|
||||
object_getClassName(self), sel_getName(_cmd), _parms[0], c);
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
_state = StateText;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'l':
|
||||
{
|
||||
// l = reset
|
||||
std::vector<int>::iterator iter;
|
||||
|
||||
for (iter = _parms.begin(); iter != _parms.end(); ++iter)
|
||||
{
|
||||
switch (*iter)
|
||||
{
|
||||
case 20:
|
||||
_flags.LNM = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
_state = StateText;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'h':
|
||||
{
|
||||
// h = set
|
||||
std::vector<int>::iterator iter;
|
||||
|
||||
for (iter = _parms.begin(); iter != _parms.end(); ++iter)
|
||||
{
|
||||
switch (*iter)
|
||||
{
|
||||
case 20:
|
||||
_flags.LNM = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
_state = StateText;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
case 'm':
|
||||
{
|
||||
std::vector<int>::iterator iter;
|
||||
unsigned flag = screen->flag();
|
||||
|
||||
for (iter = _parms.begin(); iter != _parms.end(); ++iter)
|
||||
{
|
||||
switch (*iter)
|
||||
{
|
||||
case 0:
|
||||
// attributes off
|
||||
flag = Screen::FlagNormal;
|
||||
break;
|
||||
case 1:
|
||||
// bold/increased intensity.
|
||||
flag |= Screen::FlagBold;
|
||||
break;
|
||||
case 4:
|
||||
// underscore.
|
||||
flag |= Screen::FlagInverse;
|
||||
break;
|
||||
case 5:
|
||||
//blink
|
||||
flag |= Screen::FlagBlink;
|
||||
break;
|
||||
|
||||
case 7:
|
||||
// inverse
|
||||
flag |= Screen::FlagInverse;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
screen->setFlag(flag);
|
||||
_state = StateText;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
NSLog(@"[%s %s]: unrecognized escape character: `ESC [ %c' (%02x)", object_getClassName(self), sel_getName(_cmd), c, (int)c);
|
||||
_state = StateText;
|
||||
@ -369,6 +672,20 @@ enum {
|
||||
_state = StatePound;
|
||||
break;
|
||||
|
||||
case '=':
|
||||
_flags.DECKPAM = 1;
|
||||
_flags.DECKPNM = 0;
|
||||
_altKeyPad = YES;
|
||||
_state = StateText;
|
||||
break;
|
||||
|
||||
case '>':
|
||||
_flags.DECKPAM = 0;
|
||||
_flags.DECKPNM = 1;
|
||||
_altKeyPad = NO;
|
||||
_state = StateText;
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
// Index
|
||||
screen->lineFeed();
|
||||
@ -380,6 +697,11 @@ enum {
|
||||
_state = StateText;
|
||||
break;
|
||||
|
||||
case 'Z':
|
||||
output->write(ESC "[?1;0c");
|
||||
_state = StateText;
|
||||
break;
|
||||
|
||||
case '7':
|
||||
// save cursor + attributes
|
||||
case '8':
|
||||
@ -393,6 +715,7 @@ enum {
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (_state == StateText)
|
||||
@ -419,6 +742,8 @@ enum {
|
||||
|
||||
case '\n':
|
||||
screen->lineFeed();
|
||||
if (_flags.LNM)
|
||||
screen->setX(0);
|
||||
break;
|
||||
|
||||
case '\r':
|
||||
@ -439,12 +764,12 @@ enum {
|
||||
|
||||
|
||||
|
||||
static void vt100ModeKey(unichar uc, unsigned flags, Screen *screen, OutputChannel *output, BOOL altKeyPad)
|
||||
static void vt100ModeKey(unichar uc, unsigned flags, Screen *screen, OutputChannel *output, struct __vt100flags vt100flags)
|
||||
{
|
||||
const char *str = NULL;
|
||||
|
||||
|
||||
if (altKeyPad && (flags & NSFunctionKeyMask))
|
||||
if (vt100flags.DECKPAM && (flags & NSFunctionKeyMask))
|
||||
{
|
||||
switch (uc)
|
||||
{
|
||||
@ -507,16 +832,16 @@ static void vt100ModeKey(unichar uc, unsigned flags, Screen *screen, OutputChann
|
||||
switch(uc)
|
||||
{
|
||||
case NSUpArrowFunctionKey:
|
||||
str = altKeyPad ? ESC "OA" : ESC "[A";
|
||||
str = vt100flags.DECKPAM ? ESC "OA" : ESC "[A";
|
||||
break;
|
||||
case NSDownArrowFunctionKey:
|
||||
str = altKeyPad ? ESC "OB" : ESC "[B";
|
||||
str = vt100flags.DECKPAM ? ESC "OB" : ESC "[B";
|
||||
break;
|
||||
case NSRightArrowFunctionKey:
|
||||
str = altKeyPad ? ESC "OC" : ESC "[C";
|
||||
str = vt100flags.DECKPAM ? ESC "OC" : ESC "[C";
|
||||
break;
|
||||
case NSLeftArrowFunctionKey:
|
||||
str = altKeyPad ? ESC "OD" : ESC "[D";
|
||||
str = vt100flags.DECKPAM ? ESC "OD" : ESC "[D";
|
||||
break;
|
||||
|
||||
case NSF1FunctionKey:
|
||||
@ -532,6 +857,13 @@ static void vt100ModeKey(unichar uc, unsigned flags, Screen *screen, OutputChann
|
||||
str = ESC "OS";
|
||||
break;
|
||||
|
||||
|
||||
case '\n':
|
||||
if (vt100flags.LNM)
|
||||
output->write("\r\n");
|
||||
else output->write('\n');
|
||||
break;
|
||||
|
||||
case NSDeleteCharacter:
|
||||
uc = 0x7f;
|
||||
// fallthrough.
|
||||
@ -559,11 +891,11 @@ static void vt100ModeKey(unichar uc, unsigned flags, Screen *screen, OutputChann
|
||||
}
|
||||
|
||||
|
||||
static void vt52ModeKey(unichar uc, unsigned flags, Screen * screen, OutputChannel *output, BOOL altKeyPad)
|
||||
static void vt52ModeKey(unichar uc, unsigned flags, Screen * screen, OutputChannel *output, struct __vt100flags vt100flags)
|
||||
{
|
||||
const char *str = NULL;
|
||||
|
||||
if (altKeyPad && (flags & NSNumericPadKeyMask))
|
||||
if (vt100flags.DECKPAM && (flags & NSNumericPadKeyMask))
|
||||
{
|
||||
switch(uc)
|
||||
{
|
||||
@ -648,6 +980,8 @@ static void vt52ModeKey(unichar uc, unsigned flags, Screen * screen, OutputChann
|
||||
str = ESC "S";
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case NSDeleteCharacter:
|
||||
uc = 0x7f;
|
||||
// fallthrough..
|
||||
@ -683,9 +1017,9 @@ static void vt52ModeKey(unichar uc, unsigned flags, Screen * screen, OutputChann
|
||||
unichar uc = [chars characterAtIndex: i];
|
||||
|
||||
if (_vt52Mode)
|
||||
vt52ModeKey(uc, flags, screen, output, _altKeyPad);
|
||||
vt52ModeKey(uc, flags, screen, output, _flags);
|
||||
else
|
||||
vt100ModeKey(uc, flags, screen, output, _altKeyPad);
|
||||
vt100ModeKey(uc, flags, screen, output, _flags);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user