Changeset 26003
- Timestamp:
- 06/17/08 18:49:06 (5 months ago)
- Location:
- haiku/trunk/src/apps/terminal
- Files:
-
- 7 modified
-
BasicTerminalBuffer.cpp (modified) (6 diffs)
-
BasicTerminalBuffer.h (modified) (5 diffs)
-
TermParse.cpp (modified) (3 diffs)
-
TermParse.h (modified) (1 diff)
-
TermView.cpp (modified) (3 diffs)
-
TerminalBuffer.cpp (modified) (5 diffs)
-
TerminalBuffer.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
haiku/trunk/src/apps/terminal/BasicTerminalBuffer.cpp
r25988 r26003 121 121 122 122 fOverwriteMode = true; 123 fAlternateScreenActive = false; 123 124 124 125 fScreen = _AllocateLines(width, height); … … 163 164 return SetHistoryCapacity(historyCapacity); 164 165 165 // TODO: When alternate screen support is implemented, do that only when 166 // not using the alternate screen. 167 if (true) 168 return _ResizeRewrap(width, height, historyCapacity); 169 170 return _ResizeSimple(width, height, historyCapacity); 166 if (fAlternateScreenActive) 167 return _ResizeSimple(width, height, historyCapacity); 168 169 return _ResizeRewrap(width, height, historyCapacity); 171 170 } 172 171 … … 180 179 181 180 void 182 BasicTerminalBuffer::Clear( )181 BasicTerminalBuffer::Clear(bool resetCursor) 183 182 { 184 183 fScreenOffset = 0; 185 184 _ClearLines(0, fHeight - 1); 186 fCursor.SetTo(0, 0); 185 186 if (resetCursor) 187 fCursor.SetTo(0, 0); 187 188 188 189 if (fHistory != NULL) … … 586 587 _Scroll(fScrollTop, fScrollBottom, 1); 587 588 } else { 588 fCursor.y++; 589 if (fCursor.y < fHeight - 1) 590 fCursor.y++; 589 591 _CursorChanged(); 590 592 } … … 732 734 //debug_printf("BasicTerminalBuffer::SetCursor(%d, %d)\n", x, y); 733 735 x = restrict_value(x, 0, fWidth - 1); 734 y = restrict_value(y, fScrollTop, fScrollBottom);736 y = restrict_value(y, 0, fHeight - 1); 735 737 if (x != fCursor.x || y != fCursor.y) { 736 738 fCursor.x = x; … … 774 776 775 777 // #pragma mark - private methods 778 779 780 void 781 BasicTerminalBuffer::_InvalidateAll() 782 { 783 fDirtyInfo.invalidateAll = true; 784 785 if (!fDirtyInfo.messageSent) { 786 NotifyListener(); 787 fDirtyInfo.messageSent = true; 788 } 789 } 776 790 777 791 -
haiku/trunk/src/apps/terminal/BasicTerminalBuffer.h
r25988 r26003 22 22 int32 dirtyTop; // dirty line range 23 23 int32 dirtyBottom; // 24 bool invalidateAll; 24 25 bool messageSent; // listener has been notified 25 26 … … 42 43 dirtyTop = INT_MAX; 43 44 dirtyBottom = INT_MIN; 45 invalidateAll = false; 44 46 messageSent = false; 45 47 } … … 62 64 TerminalBufferDirtyInfo& DirtyInfo() { return fDirtyInfo; } 63 65 64 status_t ResizeTo(int32 width, int32 height);65 status_t ResizeTo(int32 width, int32 height,66 virtual status_t ResizeTo(int32 width, int32 height); 67 virtual status_t ResizeTo(int32 width, int32 height, 66 68 int32 historyCapacity); 67 69 status_t SetHistoryCapacity(int32 historyCapacity); 68 void Clear( );70 void Clear(bool resetCursor); 69 71 70 72 void SynchronizeWith( … … 140 142 inline void _Invalidate(int32 top, int32 bottom); 141 143 inline void _CursorChanged(); 144 void _InvalidateAll(); 142 145 143 146 static TerminalLine** _AllocateLines(int32 width, int32 count); … … 183 186 184 187 bool fOverwriteMode; // false for insert 188 bool fAlternateScreenActive; 185 189 186 190 int fEncoding; -
haiku/trunk/src/apps/terminal/TermParse.cpp
r25992 r26003 791 791 case CASE_DECSET: 792 792 /* DECSET */ 793 // dpmodes(term, bitset); 793 for (int i = 0; i < nparam; i++) 794 _DecPrivateModeSet(param[i]); 794 795 parsestate = groundtable; 795 796 break; … … 797 798 case CASE_DECRST: 798 799 /* DECRST */ 799 // dpmodes(term, bitclr); 800 for (int i = 0; i < nparam; i++) 801 _DecPrivateModeReset(param[i]); 800 802 parsestate = groundtable; 801 803 break; … … 1071 1073 } 1072 1074 } 1075 1076 1077 void 1078 TermParse::_DecPrivateModeSet(int value) 1079 { 1080 switch (value) { 1081 case 1: 1082 // Application Cursor Keys (whatever that means). 1083 // Not supported yet. 1084 break; 1085 case 5: 1086 // Reverse Video (inverses colors for the complete screen 1087 // -- when followed by normal video, that's shortly flashes the 1088 // screen). 1089 // Not supported yet. 1090 break; 1091 case 12: 1092 // Start Blinking Cursor. 1093 // Not supported yet. 1094 break; 1095 case 25: 1096 // Show Cursor 1097 // Not supported yet. 1098 break; 1099 case 1034: 1100 // Interpret "meta" key, sets eighth bit. 1101 // Not supported yet. 1102 break; 1103 case 1049: 1104 // Save cursor as in DECSC and use Alternate Screen Buffer, clearing 1105 // it first. 1106 fBuffer->SaveCursor(); 1107 fBuffer->UseAlternateScreenBuffer(); 1108 break; 1109 } 1110 } 1111 1112 1113 void 1114 TermParse::_DecPrivateModeReset(int value) 1115 { 1116 switch (value) { 1117 case 1: 1118 // Normal Cursor Keys (whatever that means). 1119 // Not supported yet. 1120 break; 1121 case 3: 1122 // 80 Column Mode. 1123 // Not supported yet. 1124 break; 1125 case 4: 1126 // Jump (Fast) Scroll. 1127 // Not supported yet. 1128 break; 1129 case 5: 1130 // Normal Video (Leaves Reverse Video, cf. there). 1131 // Not supported yet. 1132 break; 1133 case 12: 1134 // Stop Blinking Cursor. 1135 // Not supported yet. 1136 break; 1137 case 25: 1138 // Hide Cursor 1139 // Not supported yet. 1140 break; 1141 case 1034: 1142 // Don’t interpret "meta" key. 1143 // Not supported yet. 1144 break; 1145 case 1049: 1146 // Use Normal Screen Buffer and restore cursor as in DECRC. 1147 fBuffer->RestoreCursor(); 1148 fBuffer->UseNormalScreenBuffer(); 1149 break; 1150 } 1151 } -
haiku/trunk/src/apps/terminal/TermParse.h
r25911 r26003 77 77 78 78 void _DeviceStatusReport(int n); 79 void _DecPrivateModeSet(int value); 80 void _DecPrivateModeReset(int value); 79 81 80 82 int fFd; -
haiku/trunk/src/apps/terminal/TermView.cpp
r25981 r26003 711 711 { 712 712 BAutolock _(fTextBuffer); 713 fTextBuffer->Clear( );714 } 715 fVisibleTextBuffer->Clear( );713 fTextBuffer->Clear(true); 714 } 715 fVisibleTextBuffer->Clear(true); 716 716 717 717 //debug_printf("Invalidate()\n"); … … 1564 1564 TerminalBufferDirtyInfo& info = fTextBuffer->DirtyInfo(); 1565 1565 int32 linesScrolled = info.linesScrolled; 1566 BRect bounds = Bounds();1567 int32 firstVisible = _LineAt(0);1568 int32 lastVisible = _LineAt(bounds.bottom);1569 int32 historySize = fTextBuffer->HistorySize();1570 1566 1571 1567 //debug_printf("TermView::_SynchronizeWithTextBuffer(): dirty: %ld - %ld, " … … 1630 1626 fScrolledSinceLastSync = 0; 1631 1627 } 1628 1629 // Simple case first -- complete invalidation. 1630 if (info.invalidateAll) { 1631 Invalidate(); 1632 _UpdateScrollBarRange(); 1633 int32 offset = _LineAt(0); 1634 fVisibleTextBuffer->SynchronizeWith(fTextBuffer, offset, offset, 1635 offset + fTextBuffer->Height() + 2); 1636 info.Reset(); 1637 return; 1638 } 1639 1640 BRect bounds = Bounds(); 1641 int32 firstVisible = _LineAt(0); 1642 int32 lastVisible = _LineAt(bounds.bottom); 1643 int32 historySize = fTextBuffer->HistorySize(); 1632 1644 1633 1645 bool doScroll = false; -
haiku/trunk/src/apps/terminal/TerminalBuffer.cpp
r25964 r26003 6 6 #include "TerminalBuffer.h" 7 7 8 #include <algorithm> 9 8 10 #include <Message.h> 9 11 … … 19 21 BLocker("terminal buffer"), 20 22 fEncoding(M_UTF8), 23 fAlternateScreen(NULL), 24 fAlternateHistory(NULL), 25 fAlternateScreenOffset(0), 21 26 fListenerValid(false) 22 27 { … … 26 31 TerminalBuffer::~TerminalBuffer() 27 32 { 33 delete fAlternateScreen; 34 delete fAlternateHistory; 28 35 } 29 36 … … 34 41 if (Sem() < 0) 35 42 return Sem(); 43 44 fAlternateScreen = _AllocateLines(width, height); 45 if (fAlternateScreen == NULL) 46 return B_NO_MEMORY; 36 47 37 48 return BasicTerminalBuffer::Init(width, height, historySize); … … 96 107 fListener.SendMessage(MSG_TERMINAL_BUFFER_CHANGED); 97 108 } 109 110 111 status_t 112 TerminalBuffer::ResizeTo(int32 width, int32 height) 113 { 114 int32 historyCapacity = 0; 115 if (!fAlternateScreenActive) 116 historyCapacity = HistoryCapacity(); 117 else if (fAlternateHistory != NULL) 118 historyCapacity = fAlternateHistory->Capacity(); 119 120 return ResizeTo(width, height, historyCapacity); 121 } 122 123 124 status_t 125 TerminalBuffer::ResizeTo(int32 width, int32 height, int32 historyCapacity) 126 { 127 // switch to the normal screen buffer first 128 bool alternateScreenActive = fAlternateScreenActive; 129 if (alternateScreenActive) 130 _SwitchScreenBuffer(); 131 132 int32 oldWidth = fWidth; 133 int32 oldHeight = fHeight; 134 135 // Resize the normal screen buffer/history. 136 status_t error = BasicTerminalBuffer::ResizeTo(width, height, 137 historyCapacity); 138 if (error != B_OK) { 139 if (alternateScreenActive) 140 _SwitchScreenBuffer(); 141 return error; 142 } 143 144 TermPos cursor = fCursor; 145 146 // Switch to the alternate screen buffer and resize it. 147 if (fAlternateScreen != NULL) { 148 _SwitchScreenBuffer(); 149 150 fWidth = oldWidth; 151 fHeight = oldHeight; 152 fCursor.SetTo(0, 0); 153 154 error = BasicTerminalBuffer::ResizeTo(width, height, 0); 155 if (error != B_OK) { 156 // This sucks -- we can't do anything about it. Delete the 157 // alternate screen buffer. 158 _FreeLines(fAlternateScreen, oldHeight); 159 fAlternateScreen = NULL; 160 } 161 162 // Switch back. 163 if (!alternateScreenActive) 164 _SwitchScreenBuffer(); 165 166 fWidth = width; 167 fHeight = height; 168 fCursor = cursor; 169 } 170 171 return error; 172 } 173 174 175 void 176 TerminalBuffer::UseAlternateScreenBuffer() 177 { 178 if (fAlternateScreenActive || fAlternateScreen == NULL) 179 return; 180 181 _SwitchScreenBuffer(); 182 Clear(false); 183 _InvalidateAll(); 184 } 185 186 187 void 188 TerminalBuffer::UseNormalScreenBuffer() 189 { 190 if (!fAlternateScreenActive) 191 return; 192 193 _SwitchScreenBuffer(); 194 _InvalidateAll(); 195 } 196 197 198 void 199 TerminalBuffer::_SwitchScreenBuffer() 200 { 201 std::swap(fScreen, fAlternateScreen); 202 std::swap(fHistory, fAlternateHistory); 203 std::swap(fScreenOffset, fAlternateScreenOffset); 204 fAlternateScreenActive = !fAlternateScreenActive; 205 } -
haiku/trunk/src/apps/terminal/TerminalBuffer.h
r25964 r26003 29 29 void NotifyQuit(int32 reason); 30 30 31 virtual status_t ResizeTo(int32 width, int32 height); 32 virtual status_t ResizeTo(int32 width, int32 height, 33 int32 historyCapacity); 34 35 void UseAlternateScreenBuffer(); 36 void UseNormalScreenBuffer(); 37 31 38 protected: 32 39 virtual void NotifyListener(); 33 40 34 41 private: 42 void _SwitchScreenBuffer(); 43 44 private: 35 45 int fEncoding; 46 47 TerminalLine** fAlternateScreen; 48 HistoryBuffer* fAlternateHistory; 49 int32 fAlternateScreenOffset; 36 50 37 51 // listener/dirty region management
