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

Use TrackedObject protocol. Add LineBufferPosition. Fix tests.

parent c2f079d0
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -27,8 +27,11 @@
*/
 
#import <Cocoa/Cocoa.h>
#import "ScreenChar.h"
#import "FindContext.h"
#import "ScreenChar.h"
#import "TrackedObject.h"
#import "LineBufferPosition.h"
#import "VT100GridTypes.h"
 
// When receiving search results, you'll get an array of this class. Positions
// can be converted to x,y coordinates with -convertPosition:withWidth:toX:toY.
Loading
Loading
@@ -101,14 +104,25 @@
partial:(BOOL)partial
width:(int)width
timestamp:(NSTimeInterval)timestamp
object:(NSObject *)object;
object:(id<TrackedObject>)object;
 
- (void)setObject:(NSObject *)object forLine:(int)line width:(int)width;
- (void)setObject:(id<TrackedObject>)object forLine:(int)line width:(int)width;
 
// Try to get a line that is lineNum after the first line in this block after wrapping them to a given width.
// If the line is present, return a pointer to its start and fill in *lineLength with the number of bytes in the line.
// If the line is not present, decrement *lineNum by the number of lines in this block and return NULL.
- (screen_char_t*) getWrappedLineWithWrapWidth: (int) width lineNum: (int*) lineNum lineLength: (int*) lineLength includesEndOfLine: (int*) includesEndOfLine;
- (screen_char_t*) getWrappedLineWithWrapWidth:(int)width
lineNum:(int*)lineNum
lineLength:(int*)lineLength
includesEndOfLine:(int*)includesEndOfLine;
// Sets *yOffsetPtr (if not null) to the number of consecutive empty lines just before |lineNum| because
// there's no way for the returned pointer to indicate this.
- (screen_char_t*)getWrappedLineWithWrapWidth:(int)width
lineNum:(int*)lineNum
lineLength:(int*)lineLength
includesEndOfLine:(int*)includesEndOfLine
yOffset:(int*)yOffsetPtr;
 
// Get the number of lines in this block at a given screen width.
- (int) getNumLinesWithWrapWidth: (int) width;
Loading
Loading
@@ -124,7 +138,7 @@
withLength:(int*)length
upToWidth:(int)width
timestamp:(NSTimeInterval *)timestampPtr
object:(NSObject **)objectPtr;
object:(id<TrackedObject>*)objectPtr;
 
// Drop lines from the start of the buffer. Returns the number of lines actually dropped
// (either n or the number of lines in the block).
Loading
Loading
@@ -154,7 +168,7 @@
// Append a value to cumulativeLineLengths.
- (void)_appendCumulativeLineLength:(int)cumulativeLength
timestamp:(NSTimeInterval)timestamp
object:(NSObject *)object;
object:(id<TrackedObject>)object;
 
// Return a raw line
- (screen_char_t*) rawLine: (int) linenum;
Loading
Loading
@@ -166,7 +180,7 @@
- (NSTimeInterval)timestampForLineNumber:(int)lineNum width:(int)width;
 
// Returns the object associated with a line.
- (NSObject *)objectForLineNumber:(int)lineNum width:(int)width;
- (id<TrackedObject>)objectForLineNumber:(int)lineNum width:(int)width;
 
@end
 
Loading
Loading
@@ -229,9 +243,9 @@
partial:(BOOL)partial
width:(int)width
timestamp:(NSTimeInterval)timestamp
object:(NSObject *)object;
object:(id<TrackedObject>)object;
 
- (void)setObject:(NSObject *)object forLine:(int)line width:(int)width;
- (void)setObject:(id<TrackedObject>)object forLine:(int)line width:(int)width;
 
// If more lines are in the buffer than max_lines, call this function. It will adjust the count
// of excess lines and try to free the first block(s) if they are unused. Because this could happen
Loading
Loading
@@ -246,7 +260,7 @@
- (NSTimeInterval)timestampForLineNumber:(int)lineNum width:(int)width;
 
// Returns the object associated with a line when wrapped to the specified width.
- (NSObject *)objectForLineNumber:(int)lineNum width:(int)width;
- (id<TrackedObject>)objectForLineNumber:(int)lineNum width:(int)width;
 
// Copy a line into the buffer. If the line is shorter than 'width' then only the first 'width'
// characters will be modified.
Loading
Loading
@@ -267,7 +281,7 @@
width:(int)width
includesEndOfLine:(int*)includesEndOfLine
timestamp:(NSTimeInterval *)timestampPtr
object:(NSObject **)objectPtr;
object:(id<TrackedObject> *)objectPtr;
 
// Get the number of buffer lines at a given width.
- (int) numLinesWithWidth: (int) width;
Loading
Loading
@@ -300,8 +314,12 @@
 
// Convert x,y coordinates (with y=0 being the first line) into a position. Offset is added to the position safely.
// Returns TRUE if the conversion was successful, false, if out of bounds.
// DEPRECATED. Use positionForCoordinate:width:offset:
- (BOOL) convertCoordinatesAtX: (int) x atY: (int) y withWidth: (int) width toPosition: (int*) position offset:(int)offset;
 
- (LineBufferPosition *)positionForCoordinate:(VT100GridCoord)coord width:(int)width offset:(int)offset;
- (VT100GridCoord)coordinateForPosition:(LineBufferPosition *)position width:(int)width ok:(BOOL *)ok;
// Returns the position at the stat of the buffer
- (int) firstPos;
 
Loading
Loading
Loading
Loading
@@ -30,6 +30,7 @@
#import "LineBuffer.h"
#import "RegexKitLite/RegexKitLite.h"
#import "BackgroundThread.h"
#import "TrackedObject.h"
 
@implementation ResultRange
@end
Loading
Loading
@@ -108,7 +109,7 @@
}
}
 
- (void)_appendCumulativeLineLength:(int)cumulativeLength timestamp:(NSTimeInterval)timestamp object:(NSObject *)object
- (void)_appendCumulativeLineLength:(int)cumulativeLength timestamp:(NSTimeInterval)timestamp object:(id<TrackedObject>)object
{
if (cll_entries == cll_capacity) {
cll_capacity *= 2;
Loading
Loading
@@ -217,7 +218,7 @@ static int NumberOfFullLines(screen_char_t* buffer, int length, int width)
partial:(BOOL)partial
width:(int)width
timestamp:(NSTimeInterval)timestamp
object:(NSObject *)object
object:(id<TrackedObject>)object
{
const int space_used = [self rawSpaceUsed];
const int free_space = buffer_size - space_used - start_offset;
Loading
Loading
@@ -278,18 +279,29 @@ static int NumberOfFullLines(screen_char_t* buffer, int length, int width)
return YES;
}
 
- (int) getPositionOfLine: (int*)lineNum atX: (int) x withWidth: (int)width
- (int)getPositionOfLine:(int*)lineNum
atX:(int)x
withWidth:(int)width
yOffset:(int *)yOffsetPtr
extends:(BOOL *)extendsPtr
{
int length;
int eol;
screen_char_t* p = [self getWrappedLineWithWrapWidth: width
lineNum: lineNum
lineLength: &length
includesEndOfLine: &eol];
screen_char_t* p = [self getWrappedLineWithWrapWidth:width
lineNum:lineNum
lineLength:&length
includesEndOfLine:&eol
yOffset:yOffsetPtr];
if (!p) {
return -1;
} else {
return p - raw_buffer + x;
if (x >= length) {
*extendsPtr = YES;
return p - raw_buffer + length;
} else {
*extendsPtr = NO;
return p - raw_buffer + x;
}
}
}
 
Loading
Loading
@@ -345,7 +357,7 @@ static int OffsetOfWrappedLine(screen_char_t* p, int n, int length, int width) {
return 0;
}
 
- (NSObject *)objectForLineNumber:(int)lineNum width:(int)width
- (id<TrackedObject>)objectForLineNumber:(int)lineNum width:(int)width
{
int prev = 0;
int length;
Loading
Loading
@@ -366,7 +378,7 @@ static int OffsetOfWrappedLine(screen_char_t* p, int n, int length, int width) {
return 0;
}
 
- (void)setObject:(NSObject *)object forLine:(int)lineNum width:(int)width {
- (void)setObject:(id<TrackedObject>)object forLine:(int)lineNum width:(int)width {
int prev = 0;
int length;
int i;
Loading
Loading
@@ -385,17 +397,36 @@ static int OffsetOfWrappedLine(screen_char_t* p, int n, int length, int width) {
}
}
 
- (screen_char_t*) getWrappedLineWithWrapWidth: (int) width
lineNum: (int*) lineNum
lineLength: (int*) lineLength
includesEndOfLine: (int*) includesEndOfLine
- (screen_char_t*)getWrappedLineWithWrapWidth:(int)width
lineNum:(int*)lineNum
lineLength:(int*)lineLength
includesEndOfLine:(int*)includesEndOfLine
{
return [self getWrappedLineWithWrapWidth:width
lineNum:lineNum
lineLength:lineLength
includesEndOfLine:includesEndOfLine
yOffset:NULL];
}
- (screen_char_t*)getWrappedLineWithWrapWidth:(int)width
lineNum:(int*)lineNum
lineLength:(int*)lineLength
includesEndOfLine:(int*)includesEndOfLine
yOffset:(int*)yOffsetPtr
{
int prev = 0;
int length;
int i;
int numEmptyLines = 0;
for (i = first_entry; i < cll_entries; ++i) {
int cll = cumulative_line_lengths[i] - start_offset;
length = cll - prev;
if (length == 0) {
++numEmptyLines;
} else {
numEmptyLines = 0;
}
int spans = NumberOfFullLines(buffer_start + prev, length, width);
if (*lineNum > spans) {
// Consume the entire raw line and keep looking for more.
Loading
Loading
@@ -430,6 +461,11 @@ static int OffsetOfWrappedLine(screen_char_t* p, int n, int length, int width) {
*includesEndOfLine = EOL_HARD;
}
}
if (yOffsetPtr) {
// Set *yOffsetPtr to the number of consecutive empty lines just before the requested
// line.
*yOffsetPtr = numEmptyLines;
}
return buffer_start + prev + offset;
}
prev = cll;
Loading
Loading
@@ -472,7 +508,7 @@ static int OffsetOfWrappedLine(screen_char_t* p, int n, int length, int width) {
withLength:(int*)length
upToWidth:(int)width
timestamp:(NSTimeInterval *)timestampPtr
object:(NSObject **)objectPtr
object:(id<TrackedObject> *)objectPtr
{
if (cll_entries == first_entry) {
// There is no last line to pop.
Loading
Loading
@@ -1292,7 +1328,7 @@ static int RawNumLines(LineBuffer* buffer, int width) {
partial:(BOOL)partial
width:(int)width
timestamp:(NSTimeInterval)timestamp
object:(NSObject *)object
object:(id<TrackedObject>)object
{
#ifdef LOG_MUTATIONS
{
Loading
Loading
@@ -1311,6 +1347,10 @@ static int RawNumLines(LineBuffer* buffer, int width) {
 
LineBlock* block = [blocks objectAtIndex: ([blocks count] - 1)];
 
if (object) {
object.isInLineBuffer = YES;
object.absolutePosition = [self absPositionForPosition:[self lastPos]];
}
int beforeLines = [block getNumLinesWithWrapWidth:width];
if (![block appendLine:buffer length:length partial:partial width:width timestamp:timestamp object:object]) {
// It's going to be complicated. Invalidate the number of wrapped lines
Loading
Loading
@@ -1318,7 +1358,7 @@ static int RawNumLines(LineBuffer* buffer, int width) {
num_wrapped_lines_width = -1;
int prefix_len = 0;
NSTimeInterval prefixTimestamp = 0;
NSObject *prefixObject = nil;
id<TrackedObject> prefixObject = nil;
screen_char_t* prefix = NULL;
if ([block hasPartial]) {
// There is a line that's too long for the current block to hold.
Loading
Loading
@@ -1402,7 +1442,7 @@ static int RawNumLines(LineBuffer* buffer, int width) {
return 0;
}
 
- (NSObject *)objectForLineNumber:(int)lineNum width:(int)width
- (id<TrackedObject>)objectForLineNumber:(int)lineNum width:(int)width
{
int line = lineNum;
int i;
Loading
Loading
@@ -1424,7 +1464,7 @@ static int RawNumLines(LineBuffer* buffer, int width) {
return 0;
}
 
- (void)setObject:(NSObject *)object forLine:(int)lineNum width:(int)width {
- (void)setObject:(id<TrackedObject>)object forLine:(int)lineNum width:(int)width {
int line = lineNum;
int i;
for (i = 0; i < [blocks count]; ++i) {
Loading
Loading
@@ -1439,8 +1479,16 @@ static int RawNumLines(LineBuffer* buffer, int width) {
line -= block_lines;
continue;
}
[block setObject:object forLine:line width:width];
int position;
if ([self convertCoordinatesAtX:0 atY:lineNum withWidth:width toPosition:&position offset:0]) {
[block setObject:object forLine:line width:width];
object.isInLineBuffer = YES;
object.absolutePosition = [self absPositionForPosition:position];
} else {
NSLog(@"Couldn't convert line number %d with width %d to position, not adding object.",
lineNum, position);
}
return;
}
}
Loading
Loading
@@ -1525,7 +1573,7 @@ static int RawNumLines(LineBuffer* buffer, int width) {
width:(int)width
includesEndOfLine:(int*)includesEndOfLine
timestamp:(NSTimeInterval *)timestampPtr
object:(NSObject **)objectPtr
object:(id<TrackedObject> *)objectPtr
{
if ([self numLinesWithWidth: width] == 0) {
return NO;
Loading
Loading
@@ -1570,6 +1618,9 @@ static int RawNumLines(LineBuffer* buffer, int width) {
NSLog(@"Pop: %s\n", a);
}
#endif
if (objectPtr) {
(*objectPtr).isInLineBuffer = NO;
}
return YES;
}
 
Loading
Loading
@@ -1839,49 +1890,27 @@ static int RawNumLines(LineBuffer* buffer, int width) {
toX:(int*)x
toY:(int*)y
{
if (position == [self lastPos]) {
*y = [self numLinesWithWidth:width] - 1;
ScreenCharArray *lastLine = [self wrappedLineAtIndex:*y width:width];
*x = lastLine.length;
if (*x == 0 && *y > 0) {
*y = *y - 1;
lastLine = [self wrappedLineAtIndex:*y width:width];
*x = lastLine.length;
} else if (*x < 0) {
return NO;
}
return YES;
}
int i;
int yoffset = 0;
for (i = 0; position >= 0 && i < [blocks count]; ++i) {
LineBlock* block = [blocks objectAtIndex:i];
int used = [block rawSpaceUsed];
if (position >= used) {
position -= used;
yoffset += [block getNumLinesWithWrapWidth:width];
} else {
BOOL positionIsValid = [block convertPosition:position
withWidth:width
toX:x
toY:y];
*y += yoffset;
return positionIsValid;
}
}
return NO;
BOOL ok;
LineBufferPosition *lbp = [LineBufferPosition position];
lbp.absolutePosition = position + droppedChars;
lbp.yOffset = 0;
lbp.extendsToEndOfLine = NO;
VT100GridCoord coord = [self coordinateForPosition:lbp width:width ok:&ok];
*x = coord.x;
*y = coord.y;
return ok;
}
 
// Returns YES if the (x,y) coord exists within the scrollback buffer.
- (BOOL)convertCoordinatesAtX:(int)x
atY:(int)y
withWidth:(int)width
toPosition:(int*)position
offset:(int)offset
- (LineBufferPosition *)positionForCoordinate:(VT100GridCoord)coord
width:(int)width
offset:(int)offset
{
int x = coord.x;
int y = coord.y;
long long absolutePosition = droppedChars;
int line = y;
int i;
*position = 0;
for (i = 0; i < [blocks count]; ++i) {
LineBlock* block = [blocks objectAtIndex: i];
NSAssert(block, @"Null block");
Loading
Loading
@@ -1892,36 +1921,113 @@ static int RawNumLines(LineBuffer* buffer, int width) {
int block_lines = [block getNumLinesWithWrapWidth:width];
if (block_lines <= line) {
line -= block_lines;
*position += [block rawSpaceUsed];
absolutePosition += [block rawSpaceUsed];
continue;
}
 
int pos;
pos = [block getPositionOfLine: &line atX: x withWidth: width];
int yOffset = 0;
BOOL extends = NO;
pos = [block getPositionOfLine:&line
atX:x
withWidth:width
yOffset:&yOffset
extends:&extends];
if (pos >= 0) {
int tempx=0, tempy=0;
// The correct position has been computed:
// *position = start of block
// pos = offset within block
// offset = additional offset the user requested
// but we need to see if the position actually exists after adding offset. If it can be
// converted to an x,y position then it's all right.
int candidatePosition = *position + pos + offset;
const BOOL positionIsValid = [self convertPosition:candidatePosition
withWidth:width
toX:&tempx
toY:&tempy];
if (positionIsValid &&
tempy >= 0 &&
tempx >= 0) {
*position = candidatePosition;
return YES;
absolutePosition += pos + offset;
LineBufferPosition *result = [LineBufferPosition position];
result.absolutePosition = absolutePosition;
result.yOffset = yOffset;
result.extendsToEndOfLine = extends;
// Make sure position is valid (might not be because of offset).
BOOL ok;
[self coordinateForPosition:result width:width ok:&ok];
if (ok) {
return result;
} else {
return NO;
return nil;
}
}
}
return NO;
return nil;
}
- (VT100GridCoord)coordinateForPosition:(LineBufferPosition *)position
width:(int)width
ok:(BOOL *)ok
{
if (position.absolutePosition == [self lastPos] + droppedChars) {
VT100GridCoord result;
result.y = [self numLinesWithWidth:width] - 1;
ScreenCharArray *lastLine = [self wrappedLineAtIndex:result.y width:width];
result.x = lastLine.length;
if (position.yOffset > 0) {
result.x = 0;
result.y += position.yOffset;
} else {
result.x = lastLine.length;
}
if (position.extendsToEndOfLine) {
result.x = width - 1;
}
if (ok) {
*ok = YES;
}
return result;
}
int i;
int yoffset = 0;
int p = position.absolutePosition - droppedChars;
for (i = 0; p >= 0 && i < [blocks count]; ++i) {
LineBlock* block = [blocks objectAtIndex:i];
int used = [block rawSpaceUsed];
if (p >= used) {
p -= used;
yoffset += [block getNumLinesWithWrapWidth:width];
} else {
int y;
int x;
BOOL positionIsValid = [block convertPosition:p
withWidth:width
toX:&x
toY:&y];
if (ok) {
*ok = positionIsValid;
}
if (position.yOffset > 0) {
x = 0;
y += position.yOffset;
}
if (position.extendsToEndOfLine) {
x = width - 1;
}
return VT100GridCoordMake(x, y + yoffset);
}
}
if (ok) {
*ok = NO;
}
return VT100GridCoordMake(0, 0);
}
// Returns YES if the (x,y) coord exists within the scrollback buffer.
// DEPRECATED
- (BOOL)convertCoordinatesAtX:(int)x
atY:(int)y
withWidth:(int)width
toPosition:(int*)position
offset:(int)offset
{
LineBufferPosition *result = [self positionForCoordinate:VT100GridCoordMake(x, y)
width:width
offset:offset];
if (!result) {
return NO;
} else {
*position = result.absolutePosition - droppedChars;
return YES;
}
}
 
- (int) firstPos
Loading
Loading
#import <Foundation/Foundation.h>
@interface LineBufferPosition : NSObject {
long long absolutePosition_;
int yOffset_;
BOOL extendsToEndOfLine_;
}
// Absolute position - bytes from start of line buffer plus total number of bytes that ever have
// been dropped.
@property(nonatomic, assign) long long absolutePosition;
// Number of lines past that absolute position because empty lines aren't taken into account in
// absolute position.
@property(nonatomic, assign) int yOffset;
// Indicates if the position extends to the end of the line (on a hard-wrapped line, one or more
// nulls that aren't stored in the line buffer appear on the screen, and a position can be either
// on the text or at the end of the wrapped line).
@property(nonatomic, assign) BOOL extendsToEndOfLine;
+ (LineBufferPosition *)position;
@end
#import "LineBufferPosition.h"
@implementation LineBufferPosition
@synthesize absolutePosition = absolutePosition_;
@synthesize yOffset = yOffset_;
@synthesize extendsToEndOfLine = extendsToEndOfLine_;
+ (LineBufferPosition *)position {
return [[[self alloc] init] autorelease];
}
@end
Loading
Loading
@@ -8,6 +8,7 @@
 
#import <Cocoa/Cocoa.h>
#import "PTYNoteView.h"
#import "TrackedObject.h"
 
// Post this when the note view's anchor has a chance to become centered.
extern NSString * const PTYNoteViewControllerShouldUpdatePosition;
Loading
Loading
@@ -15,13 +16,16 @@ extern NSString * const PTYNoteViewControllerShouldUpdatePosition;
@protocol PTYNoteViewControllerDelegate
@end
 
@interface PTYNoteViewController : NSViewController {
@interface PTYNoteViewController : NSViewController <TrackedObject> {
PTYNoteView *noteView_;
NSTextView *textView_;
NSPoint anchor_;
BOOL watchForUpdate_;
BOOL hidden_;
long long absLine_;
BOOL isInLineBuffer_;
long long absolutePosition_;
long long absoluteLineNumber_;
}
 
@property(nonatomic, retain) PTYNoteView *noteView;
Loading
Loading
Loading
Loading
@@ -22,7 +22,9 @@ NSString * const PTYNoteViewControllerShouldUpdatePosition = @"PTYNoteViewContro
@synthesize textView = textView_;
@synthesize anchor = anchor_;
@synthesize watchForUpdate = watchForUpdate_;
@synthesize absLine = absLine_;
@synthesize isInLineBuffer = isInLineBuffer_;
@synthesize absolutePosition = absolutePosition_;
@synthesize absoluteLineNumber = absoluteLineNumber_;
 
- (void)dealloc {
[noteView_ removeFromSuperview];
Loading
Loading
Loading
Loading
@@ -4554,7 +4554,6 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
[note.view removeFromSuperview];
[self addSubview:note.view];
note.anchor = NSMakePoint(0, line * lineHeight + lineHeight / 2);
note.absLine = line + [dataSource totalScrollbackOverflow];
[note setNoteHidden:NO];
}
}
Loading
Loading
@@ -4585,12 +4584,7 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
if ([view isKindOfClass:[PTYNoteView class]]) {
PTYNoteView *noteView = (PTYNoteView *)view;
PTYNoteViewController *note = (PTYNoteViewController *)noteView.noteViewController;
// TODO: This is wrong. If the note is in the scrollback buffer, then its absolute line
// number is subject to change when the width changes. The note should remember its
// position in the line buffer and dynamically compute its line from that given the
// current width. In other words, store a line number if it's onscreen and a linebuffer
// position if it's not. Ugh!
int line = (note.absLine - [dataSource totalScrollbackOverflow]);
int line = [dataSource lineNumberOfNote:note];
[note setAnchor:NSMakePoint(0, line * lineHeight + lineHeight / 2)];
}
}
Loading
Loading
Loading
Loading
@@ -88,5 +88,6 @@ typedef enum {
 
- (PTYNoteViewController *)noteForLine:(int)y;
- (void)setNote:(PTYNoteViewController *)note forLine:(int)y;
- (int)lineNumberOfNote:(PTYNoteViewController *)note;
 
@end
//
// TrackedObject.h
// iTerm
//
// Created by George Nachman on 11/21/13.
//
//
#import <Foundation/Foundation.h>
@protocol TrackedObject <NSObject>
@property(nonatomic, assign) BOOL isInLineBuffer;
// If in line buffer, this is the absolute position in the line buffer of the tracked object.
@property(nonatomic, assign) long long absolutePosition;
// If not line buffer, this is the absolute line number of the tracked object.
@property(nonatomic, assign) long long absoluteLineNumber;
@end
Loading
Loading
@@ -9,6 +9,7 @@
#import <Foundation/Foundation.h>
#import "DVRIndexEntry.h"
#import "ScreenChar.h"
#import "TrackedObject.h"
#import "VT100GridTypes.h"
 
@class LineBuffer;
Loading
Loading
@@ -78,7 +79,11 @@
- (int)numberOfLinesUsed;
 
// Append the first numLines to the given line buffer. Returns the number of lines appended.
- (int)appendLines:(int)numLines toLineBuffer:(LineBuffer *)lineBuffer;
// If |withObjects| is set then tracked objects are placed in the line buffer and removed from the
// grid. If unset, they are left in the grid and not placed in the line buffer.
- (int)appendLines:(int)numLines
toLineBuffer:(LineBuffer *)lineBuffer
withObjects:(BOOL)withObjects;
 
// Number of used chars in line at lineNumber.
- (int)lengthOfLineNumber:(int)lineNumber;
Loading
Loading
@@ -180,7 +185,8 @@
// popping, lines to be modified will first be filled with defaultChar.
- (void)restoreScreenFromLineBuffer:(LineBuffer *)lineBuffer
withDefaultChar:(screen_char_t)defaultChar
maxLinesToRestore:(int)maxLines;
maxLinesToRestore:(int)maxLines
absoluteOffset:(long long)absoluteOffset;
 
// Ensure the cursor and savedCursor positions are valid.
- (void)clampCursorPositionToValid;
Loading
Loading
@@ -213,8 +219,10 @@
 
// Returns the timestamp of a given line.
- (NSTimeInterval)timestampForLine:(int)y;
- (NSObject *)objectForLine:(int)y;
- (void)setObject:(NSObject *)object forLine:(int)y;
- (id<TrackedObject>)objectForLine:(int)y;
- (void)setObject:(id<TrackedObject>)object
forLine:(int)y
absoluteOffset:(long long)absoluteOffset;
 
- (NSString *)compactLineDump;
- (NSString *)compactLineDumpWithTimestamps;
Loading
Loading
Loading
Loading
@@ -170,7 +170,9 @@
return numberOfLinesUsed;
}
 
- (int)appendLines:(int)numLines toLineBuffer:(LineBuffer *)lineBuffer {
- (int)appendLines:(int)numLines
toLineBuffer:(LineBuffer *)lineBuffer
withObjects:(BOOL)withObjects {
assert(numLines <= size_.height);
 
// Set numLines to the number of lines on the screen that are in use.
Loading
Loading
@@ -210,7 +212,10 @@
partial:(continuation != EOL_HARD)
width:size_.width
timestamp:[[self lineInfoAtLineNumber:i] timestamp]
object:[[self lineInfoAtLineNumber:i] object]];
object:withObjects ? [[self lineInfoAtLineNumber:i] object] : nil];
if (withObjects) {
[[self lineInfoAtLineNumber:i] setObject:nil];
}
#ifdef DEBUG_RESIZEDWIDTH
NSLog(@"Appended a line. now have %d lines for width %d\n",
[lineBuffer numLinesWithWidth:size_.width], size_.width);
Loading
Loading
@@ -224,11 +229,15 @@
return [[self lineInfoAtLineNumber:y] timestamp];
}
 
- (NSObject *)objectForLine:(int)y {
- (id<TrackedObject>)objectForLine:(int)y {
return [[self lineInfoAtLineNumber:y] object];
}
 
- (void)setObject:(NSObject *)object forLine:(int)y {
- (void)setObject:(id<TrackedObject>)object
forLine:(int)y
absoluteOffset:(long long)absoluteOffset {
object.isInLineBuffer = NO;
object.absoluteLineNumber = y + absoluteOffset;
[[self lineInfoAtLineNumber:y] setObject:object];
}
 
Loading
Loading
@@ -1179,6 +1188,7 @@
- (void)restoreScreenFromLineBuffer:(LineBuffer *)lineBuffer
withDefaultChar:(screen_char_t)defaultChar
maxLinesToRestore:(int)maxLines
absoluteOffset:(long long)absoluteOffset
{
// Move scrollback lines into screen
int numLinesInLineBuffer = [lineBuffer numLinesWithWidth:size_.width];
Loading
Loading
@@ -1195,6 +1205,7 @@
 
BOOL foundCursor = NO;
BOOL prevLineStartsWithDoubleWidth = NO;
int numPopped = 0;
while (destLineNumber >= 0) {
screen_char_t *dest = [self screenCharsAtLineNumber:destLineNumber];
memcpy(dest, defaultLine, sizeof(screen_char_t) * size_.width);
Loading
Loading
@@ -1208,13 +1219,18 @@
}
int cont;
NSTimeInterval timestamp;
NSObject *object;
id<TrackedObject> object;
++numPopped;
assert([lineBuffer popAndCopyLastLineInto:dest
width:size_.width
includesEndOfLine:&cont
timestamp:&timestamp
object:&object]);
[[self lineInfoAtLineNumber:destLineNumber] setTimestamp:timestamp];
if (object) {
object.isInLineBuffer = NO;
object.absoluteLineNumber = destLineNumber + absoluteOffset;
}
[[self lineInfoAtLineNumber:destLineNumber] setObject:object];
if (cont && dest[size_.width - 1].code == 0 && prevLineStartsWithDoubleWidth) {
// If you pop a soft-wrapped line that's a character short and the
Loading
Loading
@@ -1234,6 +1250,15 @@
}
--destLineNumber;
}
// Fix up object line numbers where were wrong because the absoluteOffset included lines that
// were popped.
for (int i = 0; i < size_.height; i++) {
id<TrackedObject> object = [[self lineInfoAtLineNumber:i] object];
if (object) {
object.absoluteLineNumber = i + absoluteOffset - numPopped;
}
}
}
 
 
Loading
Loading
Loading
Loading
@@ -7,12 +7,13 @@
//
 
#import <Foundation/Foundation.h>
#import "TrackedObject.h"
#import "VT100GridTypes.h"
 
@interface VT100LineInfo : NSObject <NSCopying>
 
@property(nonatomic, assign) NSTimeInterval timestamp;
@property(nonatomic, retain) NSObject *object;
@property(nonatomic, retain) id<TrackedObject> object;
 
- (id)initWithWidth:(int)width;
- (void)setDirty:(BOOL)dirty inRange:(VT100GridRange)range updateTimestamp:(BOOL)updateTimestamp;
Loading
Loading
Loading
Loading
@@ -13,7 +13,7 @@
int width_;
BOOL anyCharPossiblyDirty_; // No means nothing is dirty. Yes means MAYBE something is dirty.
NSTimeInterval timestamp_;
NSObject *object_;
id<TrackedObject> object_;
}
 
@synthesize timestamp = timestamp_;
Loading
Loading
Loading
Loading
@@ -174,7 +174,8 @@ static const double kInterBellQuietPeriod = 0.1;
[self appendScreen:currentGrid_
toScrollback:lineBufferWithAltScreen
withUsedHeight:usedHeight
newHeight:new_height];
newHeight:new_height
withObjects:NO];
[self getNullCorrectedSelectionStartPosition:&originalStartPos
endPosition:&originalEndPos
isFullLineSelection:&originalIsFullLine
Loading
Loading
@@ -193,12 +194,14 @@ static const double kInterBellQuietPeriod = 0.1;
[self appendScreen:altGrid_
toScrollback:altScreenLineBuffer
withUsedHeight:usedHeight
newHeight:new_height];
newHeight:new_height
withObjects:YES];
}
[self appendScreen:primaryGrid_
toScrollback:linebuffer_
withUsedHeight:[primaryGrid_ numberOfLinesUsed]
newHeight:new_height];
newHeight:new_height
withObjects:YES];
 
int newSelStartX = -1;
int newSelStartY = -1;
Loading
Loading
@@ -221,7 +224,8 @@ static const double kInterBellQuietPeriod = 0.1;
// Restore the screen contents that were pushed onto the linebuffer.
[currentGrid_ restoreScreenFromLineBuffer:wasShowingAltScreen ? altScreenLineBuffer : linebuffer_
withDefaultChar:[currentGrid_ defaultChar]
maxLinesToRestore:[linebuffer_ numLinesWithWidth:currentGrid_.size.width]];
maxLinesToRestore:[linebuffer_ numLinesWithWidth:currentGrid_.size.width]
absoluteOffset:[self numberOfScrollbackLines] + [self totalScrollbackOverflow]];
 
// If we're in the alternate screen, restore its contents from the temporary
// linebuffer.
Loading
Loading
@@ -247,7 +251,8 @@ static const double kInterBellQuietPeriod = 0.1;
// line because it was just initialized with default lines.
[primaryGrid_ restoreScreenFromLineBuffer:realLineBuffer
withDefaultChar:[primaryGrid_ defaultChar]
maxLinesToRestore:oldSize.height];
maxLinesToRestore:oldSize.height
absoluteOffset:[self numberOfScrollbackLines] + [self totalScrollbackOverflow]];
} else {
// Shrinking (avoid pulling in stuff from scrollback, pull in no more
// than might have been pushed, even if more is available). Note there's a little hack
Loading
Loading
@@ -255,7 +260,8 @@ static const double kInterBellQuietPeriod = 0.1;
// default lines.
[primaryGrid_ restoreScreenFromLineBuffer:realLineBuffer
withDefaultChar:[primaryGrid_ defaultChar]
maxLinesToRestore:new_height];
maxLinesToRestore:new_height
absoluteOffset:[self numberOfScrollbackLines] + [self totalScrollbackOverflow]];
}
 
int newLastPos = [realLineBuffer lastPos];
Loading
Loading
@@ -273,7 +279,8 @@ static const double kInterBellQuietPeriod = 0.1;
[self appendScreen:copyOfAltGrid
toScrollback:appendOnlyLineBuffer
withUsedHeight:usedHeight
newHeight:new_height];
newHeight:new_height
withObjects:NO];
 
if (hasSelection) {
// Compute selection positions relative to the end of the line buffer, which may have
Loading
Loading
@@ -721,7 +728,8 @@ static const double kInterBellQuietPeriod = 0.1;
[currentGrid_ restoreScreenFromLineBuffer:linebuffer_
withDefaultChar:[currentGrid_ defaultChar]
maxLinesToRestore:MIN([linebuffer_ numLinesWithWidth:currentGrid_.size.width],
currentGrid_.size.height - numberOfConsecutiveEmptyLines)];
currentGrid_.size.height - numberOfConsecutiveEmptyLines)
absoluteOffset:[self numberOfScrollbackLines] + [self totalScrollbackOverflow]];
}
 
- (void)setAltScreen:(NSArray *)lines
Loading
Loading
@@ -874,7 +882,8 @@ static const double kInterBellQuietPeriod = 0.1;
{
int linesPushed;
linesPushed = [currentGrid_ appendLines:[currentGrid_ numberOfLinesUsed]
toLineBuffer:linebuffer_];
toLineBuffer:linebuffer_
withObjects:NO];
 
[linebuffer_ storeLocationOfAbsPos:savedFindContextAbsPos_
inContext:context];
Loading
Loading
@@ -1027,7 +1036,8 @@ static const double kInterBellQuietPeriod = 0.1;
{
// Append the screen contents to the scrollback buffer so they are included in the search.
int linesPushed = [currentGrid_ appendLines:[currentGrid_ numberOfLinesUsed]
toLineBuffer:linebuffer_];
toLineBuffer:linebuffer_
withObjects:NO];
 
// Get the start position of (x,y)
int startPos;
Loading
Loading
@@ -1071,7 +1081,8 @@ static const double kInterBellQuietPeriod = 0.1;
{
int linesPushed;
linesPushed = [currentGrid_ appendLines:[currentGrid_ numberOfLinesUsed]
toLineBuffer:linebuffer_];
toLineBuffer:linebuffer_
withObjects:NO];
 
savedFindContextAbsPos_ = [self findContextAbsPosition];
[self popScrollbackLines:linesPushed];
Loading
Loading
@@ -1201,12 +1212,31 @@ static const double kInterBellQuietPeriod = 0.1;
int numLinesInLineBuffer = [linebuffer_ numLinesWithWidth:currentGrid_.size.width];
NSTimeInterval interval;
if (y >= numLinesInLineBuffer) {
[currentGrid_ setObject:note forLine:y - numLinesInLineBuffer];
[currentGrid_ setObject:note
forLine:y - numLinesInLineBuffer
absoluteOffset:[self numberOfScrollbackLines] + [self totalScrollbackOverflow]];
} else {
[linebuffer_ setObject:note forLine:y width:currentGrid_.size.width];
}
}
 
- (int)lineNumberOfNote:(PTYNoteViewController *)note {
if (note.isInLineBuffer) {
int pos = [linebuffer_ positionForAbsPosition:note.absolutePosition];
int x;
int y;
if ([linebuffer_ convertPosition:pos withWidth:currentGrid_.size.width toX:&x toY:&y]) {
return y;
} else {
NSLog(@"Failed to convert absolute position %lld (position %d)",
note.absolutePosition, pos);
return -1;
}
} else {
return note.absoluteLineNumber - [self totalScrollbackOverflow];
}
}
#pragma mark - VT100TerminalDelegate
 
- (void)terminalAppendString:(NSString *)string isAscii:(BOOL)isAscii
Loading
Loading
@@ -2196,21 +2226,28 @@ static const double kInterBellQuietPeriod = 0.1;
toScrollback:(LineBuffer *)lineBufferToUse
withUsedHeight:(int)usedHeight
newHeight:(int)newHeight
withObjects:(BOOL)withObjects
{
if (grid.size.height - newHeight >= usedHeight) {
// Height is decreasing but pushing HEIGHT lines into the buffer would scroll all the used
// lines off the top, leaving the cursor floating without any text. Keep all used lines that
// fit onscreen.
[grid appendLines:MAX(usedHeight, newHeight) toLineBuffer:lineBufferToUse];
[grid appendLines:MAX(usedHeight, newHeight)
toLineBuffer:lineBufferToUse
withObjects:withObjects];
} else {
if (newHeight < grid.size.height) {
// Screen is shrinking.
// If possible, keep the last used line a fixed distance from the top of
// the screen. If not, at least save all the used lines.
[grid appendLines:usedHeight toLineBuffer:lineBufferToUse];
[grid appendLines:usedHeight
toLineBuffer:lineBufferToUse
withObjects:withObjects];
} else {
// Screen is growing. New content may be brought in on top.
[grid appendLines:grid.size.height toLineBuffer:lineBufferToUse];
[grid appendLines:grid.size.height
toLineBuffer:lineBufferToUse
withObjects:withObjects];
}
}
}
Loading
Loading
@@ -2625,7 +2662,8 @@ static void SwapInt(int *a, int *b) {
// Append the screen contents to the scrollback buffer so they are included in the search.
int linesPushed;
linesPushed = [currentGrid_ appendLines:[currentGrid_ numberOfLinesUsed]
toLineBuffer:linebuffer_];
toLineBuffer:linebuffer_
withObjects:NO];
 
// Search one block.
int stopAt;
Loading
Loading
Loading
Loading
@@ -255,6 +255,10 @@
1D70BA351680158700824B72 /* PTYFontInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 1D70BA331680158700824B72 /* PTYFontInfo.h */; };
1D70BA361680158700824B72 /* PTYFontInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D70BA341680158700824B72 /* PTYFontInfo.m */; };
1D72439011F416F300BD4924 /* LineBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1D72438F11F416F300BD4924 /* LineBuffer.h */; };
1D78B55E183EE1C000014D49 /* LineBufferPosition.h in Headers */ = {isa = PBXBuildFile; fileRef = 1D78B55C183EE1C000014D49 /* LineBufferPosition.h */; };
1D78B55F183EE1C000014D49 /* LineBufferPosition.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D78B55D183EE1C000014D49 /* LineBufferPosition.m */; };
1D78B560183EE1C000014D49 /* LineBufferPosition.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D78B55D183EE1C000014D49 /* LineBufferPosition.m */; };
1D78B561183EEB9700014D49 /* ScriptingBridge.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D81F0BC183C3B0100910838 /* ScriptingBridge.framework */; };
1D7B9A691491D82F003A2A22 /* IntervalMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 1D7B9A671491D82F003A2A22 /* IntervalMap.h */; };
1D7B9A6A1491D82F003A2A22 /* IntervalMap.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D7B9A681491D82F003A2A22 /* IntervalMap.m */; };
1D7C18811275D22900461E55 /* PasteboardHistory.h in Headers */ = {isa = PBXBuildFile; fileRef = 1D7C187F1275D22900461E55 /* PasteboardHistory.h */; };
Loading
Loading
@@ -758,6 +762,8 @@
1D72438F11F416F300BD4924 /* LineBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LineBuffer.h; sourceTree = "<group>"; };
1D72477211F55E5700BD4924 /* LineBufferTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LineBufferTest.h; sourceTree = "<group>"; };
1D72477311F55E5700BD4924 /* LineBufferTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LineBufferTest.m; sourceTree = "<group>"; };
1D78B55C183EE1C000014D49 /* LineBufferPosition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LineBufferPosition.h; sourceTree = "<group>"; };
1D78B55D183EE1C000014D49 /* LineBufferPosition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LineBufferPosition.m; sourceTree = "<group>"; };
1D7B9A671491D82F003A2A22 /* IntervalMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntervalMap.h; sourceTree = "<group>"; };
1D7B9A681491D82F003A2A22 /* IntervalMap.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IntervalMap.m; sourceTree = "<group>"; };
1D7C187F1275D22900461E55 /* PasteboardHistory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PasteboardHistory.h; sourceTree = "<group>"; };
Loading
Loading
@@ -863,6 +869,7 @@
1DB67CF01485C578005849A1 /* TmuxHistoryParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TmuxHistoryParser.m; sourceTree = "<group>"; };
1DB67CF31486BD3D005849A1 /* TmuxStateParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TmuxStateParser.h; sourceTree = "<group>"; };
1DB67CF41486BD3D005849A1 /* TmuxStateParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TmuxStateParser.m; sourceTree = "<group>"; };
1DB7188C183E8E3600ADC5DD /* TrackedObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TrackedObject.h; sourceTree = "<group>"; };
1DB72CF51396059200EB1005 /* xterm-terminfo.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "xterm-terminfo.txt"; sourceTree = "<group>"; };
1DC38816148E840600B89F7C /* SolidColorView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SolidColorView.h; sourceTree = "<group>"; };
1DC38817148E840700B89F7C /* SolidColorView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SolidColorView.m; sourceTree = "<group>"; };
Loading
Loading
@@ -1089,6 +1096,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
1D78B561183EEB9700014D49 /* ScriptingBridge.framework in Frameworks */,
1D9A55BA180FAA1100B42CE9 /* Growl in Frameworks */,
1D9A55B9180FA93000B42CE9 /* AddressBook.framework in Frameworks */,
1D9A55B8180FA92100B42CE9 /* libncurses.dylib in Frameworks */,
Loading
Loading
@@ -1121,6 +1129,9 @@
0464AB0D006CD2EC7F000001 /* JTerminal */ = {
isa = PBXGroup;
children = (
1D78B55C183EE1C000014D49 /* LineBufferPosition.h */,
1D78B55D183EE1C000014D49 /* LineBufferPosition.m */,
1DB7188C183E8E3600ADC5DD /* TrackedObject.h */,
A63F4093183B398C003A6A6D /* PTYNoteViewController.h */,
A63F4094183B398C003A6A6D /* PTYNoteViewController.m */,
A63F4098183B3AA7003A6A6D /* PTYNoteView.h */,
Loading
Loading
@@ -1838,6 +1849,7 @@
1D5FDD4C1208E8F000C46BA3 /* FindCommandHandler.h in Headers */,
1D5FDD4D1208E8F000C46BA3 /* iTerm.h in Headers */,
1D5FDD4E1208E8F000C46BA3 /* charmaps.h in Headers */,
1D78B55E183EE1C000014D49 /* LineBufferPosition.h in Headers */,
1D53FD15181C4B4B00524D4F /* FindContext.h in Headers */,
1D5FDD4F1208E8F000C46BA3 /* PseudoTerminal.h in Headers */,
1D5FDD501208E8F000C46BA3 /* PTToolbarController.h in Headers */,
Loading
Loading
@@ -2266,6 +2278,7 @@
1D9A555F180FA83900B42CE9 /* SmartSelectionController.m in Sources */,
1D9A55AA180FA8B700B42CE9 /* PSMOverflowPopUpButton.m in Sources */,
1D9A5560180FA83900B42CE9 /* TriggerController.m in Sources */,
1D78B560183EE1C000014D49 /* LineBufferPosition.m in Sources */,
1D9A5549180FA82E00B42CE9 /* TmuxDashboardController.m in Sources */,
1D9A5579180FA85D00B42CE9 /* ScriptTrigger.m in Sources */,
1D9A5551180FA82E00B42CE9 /* TSVParser.m in Sources */,
Loading
Loading
@@ -2413,6 +2426,7 @@
1D5FDDC21208E93600C46BA3 /* NSBezierPath_AMShading.m in Sources */,
1D5FDDC31208E93600C46BA3 /* PSMTabDragAssistant.m in Sources */,
1D5FDDC41208E93600C46BA3 /* PSMUnifiedTabStyle.m in Sources */,
1D78B55F183EE1C000014D49 /* LineBufferPosition.m in Sources */,
1D5FDDC51208E93600C46BA3 /* PSMAdiumTabStyle.m in Sources */,
1D5FDDC61208E93600C46BA3 /* PSMTabDragWindow.m in Sources */,
1D5FDDC71208E93600C46BA3 /* iTermGrowlDelegate.m in Sources */,
Loading
Loading
Loading
Loading
@@ -54,7 +54,7 @@
#import "iTermKeyBindingMgr.h"
#import <Carbon/Carbon.h>
#import <ScriptingBridge/ScriptingBridge.h>
#import <iTermGrowlDelegate.h>
#import "iTermGrowlDelegate.h"
#import <objc/runtime.h>
#include <objc/runtime.h>
 
Loading
Loading
Loading
Loading
@@ -289,24 +289,24 @@ do { \
- (void)testAppendLineToLineBuffer {
VT100Grid *grid = [self gridFromCompactLines:@"abcd\nefgh\n....\n...."];
LineBuffer *lineBuffer = [[[LineBuffer alloc] initWithBlockSize:1000] autorelease];
[grid appendLines:2 toLineBuffer:lineBuffer];
[grid appendLines:2 toLineBuffer:lineBuffer withObjects:NO];
assert([[lineBuffer debugString] isEqualToString:@"abcd!\nefgh!"]);
 
grid = [self gridFromCompactLinesWithContinuationMarks:@"abcd!\nefgh+\n....!\n....!"];
lineBuffer = [[[LineBuffer alloc] initWithBlockSize:1000] autorelease];
[grid appendLines:2 toLineBuffer:lineBuffer];
[grid appendLines:2 toLineBuffer:lineBuffer withObjects:NO];
assert([[lineBuffer debugString] isEqualToString:@"abcd!\nefgh+"]);
 
grid = [self gridFromCompactLinesWithContinuationMarks:@"abcd+\nefgh!\n....!\n....!"];
lineBuffer = [[[LineBuffer alloc] initWithBlockSize:1000] autorelease];
[grid appendLines:2 toLineBuffer:lineBuffer];
[grid appendLines:2 toLineBuffer:lineBuffer withObjects:NO];
assert([[lineBuffer debugString] isEqualToString:@"abcdefgh!"]);
 
grid = [self gridFromCompactLines:@"abcd\nefgh\n....\n...."];
lineBuffer = [[[LineBuffer alloc] initWithBlockSize:1000] autorelease];
grid.cursorX = 2;
grid.cursorY = 1;
[grid appendLines:2 toLineBuffer:lineBuffer];
[grid appendLines:2 toLineBuffer:lineBuffer withObjects:NO];
int x;
assert([lineBuffer getCursorInLastLineWithWidth:4 atX:&x]);
assert(x == 2);
Loading
Loading
@@ -317,7 +317,7 @@ do { \
lineBuffer = [[[LineBuffer alloc] initWithBlockSize:1000] autorelease];
grid.cursorX = 0;
grid.cursorY = 2;
[grid appendLines:2 toLineBuffer:lineBuffer];
[grid appendLines:2 toLineBuffer:lineBuffer withObjects:NO];
assert([lineBuffer getCursorInLastLineWithWidth:4 atX:&x]);
assert(x == 4);
}
Loading
Loading
@@ -1385,7 +1385,8 @@ do { \
length:string.length
partial:i == strings.count - 1
width:80
timestamp:0];
timestamp:0
object:nil];
i++;
}
va_end(args);
Loading
Loading
@@ -1398,7 +1399,8 @@ do { \
LineBuffer *lineBuffer = [self lineBufferWithStrings:@"test", @"hello wor*ld", nil];
[grid restoreScreenFromLineBuffer:lineBuffer
withDefaultChar:[grid defaultChar]
maxLinesToRestore:1];
maxLinesToRestore:1
absoluteOffset:0];
assert([[grid compactLineDump] isEqualToString:
@"rld.....\n"
@"........\n"
Loading
Loading
@@ -1415,7 +1417,8 @@ do { \
lineBuffer = [self lineBufferWithStrings:@"test", @"hello wo*rld", nil];
[grid restoreScreenFromLineBuffer:lineBuffer
withDefaultChar:[grid defaultChar]
maxLinesToRestore:100];
maxLinesToRestore:100
absoluteOffset:0];
assert([[grid compactLineDump] isEqualToString:
@"test....\n"
@"hello wo\n"
Loading
Loading
@@ -1435,7 +1438,8 @@ do { \
dc.backgroundColorMode = ColorModeNormal;
[grid restoreScreenFromLineBuffer:lineBuffer
withDefaultChar:dc
maxLinesToRestore:100];
maxLinesToRestore:100
absoluteOffset:0];
assert([[grid compactLineDump] isEqualToString:
@"rl\n"
@"d."]);
Loading
Loading
@@ -1451,7 +1455,8 @@ do { \
lineBuffer = [self lineBufferWithStrings:@"abc*W-xy", nil];
[grid restoreScreenFromLineBuffer:lineBuffer
withDefaultChar:[grid defaultChar]
maxLinesToRestore:100];
maxLinesToRestore:100
absoluteOffset:0];
assert([[grid compactLineDump] isEqualToString:
@"abc>\n"
@"W-xy\n"
Loading
Loading
Loading
Loading
@@ -3589,6 +3589,9 @@
[write_ appendData:data];
}
 
- (void)screenDidChangeNumberOfScrollbackLines {
}
- (void)testPasting {
VT100Screen *screen = [self screen];
screen.delegate = (id<VT100ScreenDelegate>)self;
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