Skip to content
Snippets Groups Projects
Commit 58922dd6 authored by George Nachman's avatar George Nachman
Browse files

Keep track of how many lines are in the prompt so the whole thing can be...

Keep track of how many lines are in the prompt so the whole thing can be preserved when you clear the buffer. Issue 1330.
parent 562ef133
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -1809,7 +1809,8 @@ do { \
[lineBuffer setMaxLines:1];
int dropped = [grid resetWithLineBuffer:lineBuffer
unlimitedScrollback:NO
preserveCursorLine:NO];
preserveCursorLine:NO
additionalLinesToSave:0];
XCTAssert(dropped == 2);
XCTAssert([[grid compactLineDump] isEqualToString:
@"....\n"
Loading
Loading
@@ -1830,7 +1831,8 @@ do { \
[lineBuffer setMaxLines:1];
dropped = [grid resetWithLineBuffer:lineBuffer
unlimitedScrollback:YES
preserveCursorLine:NO];
preserveCursorLine:NO
additionalLinesToSave:0];
XCTAssert(dropped == 0);
XCTAssert([[grid compactLineDump] isEqualToString:
@"....\n"
Loading
Loading
@@ -1845,7 +1847,8 @@ do { \
[lineBuffer setMaxLines:1];
dropped = [grid resetWithLineBuffer:lineBuffer
unlimitedScrollback:YES
preserveCursorLine:NO];
preserveCursorLine:NO
additionalLinesToSave:0];
XCTAssert(dropped == 0);
XCTAssert([[grid compactLineDump] isEqualToString:
@"..\n"
Loading
Loading
@@ -1865,7 +1868,8 @@ do { \
[lineBuffer setMaxLines:1];
int dropped = [grid resetWithLineBuffer:lineBuffer
unlimitedScrollback:NO
preserveCursorLine:YES];
preserveCursorLine:YES
additionalLinesToSave:0];
XCTAssert(dropped == 2);
XCTAssert([[grid compactLineDump] isEqualToString:
@"....\n"
Loading
Loading
@@ -1891,7 +1895,8 @@ do { \
[lineBuffer setMaxLines:1];
dropped = [grid resetWithLineBuffer:lineBuffer
unlimitedScrollback:NO
preserveCursorLine:YES];
preserveCursorLine:YES
additionalLinesToSave:0];
XCTAssert(dropped == 1);
XCTAssert([[grid compactLineDump] isEqualToString:
@"efgh\n"
Loading
Loading
@@ -1917,7 +1922,8 @@ do { \
[lineBuffer setMaxLines:1];
dropped = [grid resetWithLineBuffer:lineBuffer
unlimitedScrollback:NO
preserveCursorLine:YES];
preserveCursorLine:YES
additionalLinesToSave:0];
XCTAssert(dropped == 0);
XCTAssert([[grid compactLineDump] isEqualToString:
@"abcd\n"
Loading
Loading
@@ -1939,7 +1945,8 @@ do { \
[lineBuffer setMaxLines:1];
dropped = [grid resetWithLineBuffer:lineBuffer
unlimitedScrollback:YES
preserveCursorLine:YES];
preserveCursorLine:YES
additionalLinesToSave:0];
XCTAssert(dropped == 0);
XCTAssert([[grid compactLineDump] isEqualToString:
@"....\n"
Loading
Loading
@@ -1954,7 +1961,8 @@ do { \
[lineBuffer setMaxLines:1];
dropped = [grid resetWithLineBuffer:lineBuffer
unlimitedScrollback:YES
preserveCursorLine:YES];
preserveCursorLine:YES
additionalLinesToSave:0];
XCTAssert(dropped == 0);
XCTAssert([[grid compactLineDump] isEqualToString:
@"..\n"
Loading
Loading
Loading
Loading
@@ -134,7 +134,8 @@
// for |leave|.
- (int)resetWithLineBuffer:(LineBuffer *)lineBuffer
unlimitedScrollback:(BOOL)unlimitedScrollback
preserveCursorLine:(BOOL)preserveCursorLine;
preserveCursorLine:(BOOL)preserveCursorLine
additionalLinesToSave:(int)additionalLinesToSave;
 
// Move the grid contents up, leaving only the whole wrapped line the cursor is on at the top.
- (void)moveWrappedCursorLineToTopOfGrid;
Loading
Loading
Loading
Loading
@@ -405,12 +405,13 @@ static NSString *const kGridSizeKey = @"Size";
 
- (int)resetWithLineBuffer:(LineBuffer *)lineBuffer
unlimitedScrollback:(BOOL)unlimitedScrollback
preserveCursorLine:(BOOL)preserveCursorLine {
preserveCursorLine:(BOOL)preserveCursorLine
additionalLinesToSave:(int)additionalLinesToSave {
self.scrollRegionRows = VT100GridRangeMake(0, size_.height);
self.scrollRegionCols = VT100GridRangeMake(0, size_.width);
int numLinesToScroll;
if (preserveCursorLine) {
numLinesToScroll = cursor_.y;
numLinesToScroll = MAX(0, cursor_.y - additionalLinesToSave);
} else {
numLinesToScroll = [self lineNumberOfLastNonEmptyLine] + 1;
}
Loading
Loading
@@ -423,7 +424,7 @@ static NSString *const kGridSizeKey = @"Size";
}
self.cursor = VT100GridCoordMake(0, 0);
 
[self setCharsFrom:VT100GridCoordMake(0, preserveCursorLine ? 1 : 0)
[self setCharsFrom:VT100GridCoordMake(0, preserveCursorLine ? 1 + additionalLinesToSave : 0)
to:VT100GridCoordMake(size_.width - 1, size_.height - 1)
toChar:[self defaultChar]];
 
Loading
Loading
Loading
Loading
@@ -142,6 +142,10 @@ NS_INLINE BOOL VT100GridCoordEquals(VT100GridCoord a, VT100GridCoord b) {
return a.x == b.x && a.y == b.y;
}
 
NS_INLINE BOOL VT100GridAbsCoordEquals(VT100GridAbsCoord a, VT100GridAbsCoord b) {
return a.x == b.x && a.y == b.y;
}
NS_INLINE BOOL VT100GridSizeEquals(VT100GridSize a, VT100GridSize b) {
return a.width == b.width && a.height == b.height;
}
Loading
Loading
Loading
Loading
@@ -154,12 +154,16 @@ static const double kInterBellQuietPeriod = 0.1;
 
// base64 value to copy to pasteboard, being built up bit by bit.
NSMutableString *_copyString;
// Valid while at the command prompt only. GIves the range of the current prompt. Meaningful
// only if the end is not equal to the start.
VT100GridAbsCoordRange _currentPromptRange;
}
 
static NSString *const kInlineFileName = @"name"; // NSString
static NSString *const kInlineFileWidth = @"width"; // NSNumber
static NSString *const kInlineFileWidthUnits = @"width units"; // NSNumber of VT100TerminalUnits
static NSString *const kInlineFileHeight = @"height"; // NSNumb er
static NSString *const kInlineFileHeight = @"height"; // NSNumber
static NSString *const kInlineFileHeightUnits = @"height units"; // NSNumber of VT100TerminalUnits
static NSString *const kInlineFilePreserveAspectRatio = @"preserve aspect ratio"; // NSNumber bool
static NSString *const kInlineFileBase64String = @"base64 string"; // NSMutableString
Loading
Loading
@@ -905,10 +909,16 @@ static NSString *const kInilineFileInset = @"inset"; // NSValue of NSEdgeInsets
[delegate_ screenTriggerableChangeDidOccur];
// This clears the screen.
int x = currentGrid_.cursorX;
int numberOfPromptLines = 1;
if (!VT100GridAbsCoordEquals(_currentPromptRange.start, _currentPromptRange.end)) {
numberOfPromptLines = MAX(1, _currentPromptRange.end.y - _currentPromptRange.start.y + 1);
}
[self incrementOverflowBy:[currentGrid_ resetWithLineBuffer:linebuffer_
unlimitedScrollback:unlimitedScrollback_
preserveCursorLine:YES]];
preserveCursorLine:YES
additionalLinesToSave:MAX(0, numberOfPromptLines - 1)]];
currentGrid_.cursorX = x;
currentGrid_.cursorY = numberOfPromptLines - 1;
}
 
- (void)clearScrollbackBuffer
Loading
Loading
@@ -2651,7 +2661,8 @@ static NSString *const kInilineFileInset = @"inset"; // NSValue of NSEdgeInsets
} else {
[self incrementOverflowBy:[currentGrid_ resetWithLineBuffer:linebuffer_
unlimitedScrollback:unlimitedScrollback_
preserveCursorLine:NO]];
preserveCursorLine:NO
additionalLinesToSave:0]];
}
 
[self setInitialTabStops];
Loading
Loading
@@ -3717,6 +3728,9 @@ static NSString *const kInilineFileInset = @"inset"; // NSValue of NSEdgeInsets
_lastCommandOutputRange.end = coord;
_lastCommandOutputRange.start = nextCommandOutputStart_;
 
_currentPromptRange.start = coord;
_currentPromptRange.end = coord;
// FinalTerm uses this to define the start of a collapsable region. That would be a nightmare
// to add to iTerm, and our answer to this is marks, which already existed anyway.
[delegate_ screenPromptDidStartAtLine:[self numberOfScrollbackLines] + self.cursorY - 1];
Loading
Loading
@@ -3724,6 +3738,8 @@ static NSString *const kInilineFileInset = @"inset"; // NSValue of NSEdgeInsets
 
- (void)terminalCommandDidStart {
DLog(@"FinalTerm: terminalCommandDidStart");
_currentPromptRange.end = VT100GridAbsCoordMake(currentGrid_.cursor.x,
currentGrid_.cursor.y + self.numberOfScrollbackLines + self.totalScrollbackOverflow);
[self commandDidStartAtScreenCoord:currentGrid_.cursor];
[delegate_ screenPromptDidEndAtLine:[self numberOfScrollbackLines] + self.cursorY - 1];
}
Loading
Loading
@@ -3740,6 +3756,8 @@ static NSString *const kInilineFileInset = @"inset"; // NSValue of NSEdgeInsets
 
- (void)terminalCommandDidEnd {
DLog(@"FinalTerm: terminalCommandDidEnd");
_currentPromptRange.start = _currentPromptRange.end = VT100GridAbsCoordMake(0, 0);
[self commandDidEndAtAbsCoord:VT100GridAbsCoordMake(currentGrid_.cursor.x, currentGrid_.cursor.y + [self numberOfScrollbackLines] + [self totalScrollbackOverflow])];
}
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment