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

Adhoc build 3.0.20161114_211649

parent 596bb609
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -10,6 +10,7 @@
#import "FindContext.h"
#import "LineBufferHelpers.h"
#import "RegexKitLite.h"
#import "DebugLogging.h"
 
NSString *const kLineBlockRawBufferKey = @"Raw Buffer";
NSString *const kLineBlockBufferStartOffsetKey = @"Buffer Start Offset";
Loading
Loading
@@ -1147,12 +1148,15 @@ static int Search(NSString* needle,
toX:(int*)x
toY:(int*)y
{
DLog(@"Entering convertPosition:%@ withWidth:%@", @(position), @(width));
int i;
*x = 0;
*y = 0;
int prev = start_offset;
DLog(@"Begin iterating %d cll entries and initialize y to 0", cll_entries);
for (i = first_entry; i < cll_entries; ++i) {
int eol = cumulative_line_lengths[i];
DLog(@"cll[%d]=%d", i, eol);
int line_length = eol - prev;
if (position >= eol) {
// Get the number of full-width lines in the raw line. If there were
Loading
Loading
@@ -1163,18 +1167,26 @@ static int Search(NSString* needle,
width,
_mayHaveDoubleWidthCharacter);
*y += spans + 1;
DLog(@"Skip past %d spans, advance *y to %d", spans, *y);
} else {
DLog(@"Found the full line. Everything will be fine.");
// The position we're searching for is in this (unwrapped) line.
int bytes_to_consume_in_this_line = position - prev;
int dwc_peek = 0;
DLog(@"Bytes to consume=%@, line length=%@ prev=%@, eol=%@",
@(bytes_to_consume_in_this_line),
@(line_length),
@(prev),
@(eol));
// If the position is the left half of a double width char then include the right half in
// the following call to NumberOfFullLines.
 
if (bytes_to_consume_in_this_line < line_length &&
prev + bytes_to_consume_in_this_line + 1 < eol) {
DLog(@"Hit the left half of a DWC?");
assert(prev + bytes_to_consume_in_this_line + 1 < buffer_size);
if (raw_buffer[prev + bytes_to_consume_in_this_line + 1].code == DWC_RIGHT) {
DLog(@"Advance to include the right half");
++dwc_peek;
}
}
Loading
Loading
@@ -1183,6 +1195,7 @@ static int Search(NSString* needle,
width,
_mayHaveDoubleWidthCharacter);
*y += consume;
DLog(@"consume=%@, advance *y to %@", @(consume), @(*y));
if (consume > 0) {
// Offset from prev where the consume'th line begin.
int offset = OffsetOfWrappedLine(raw_buffer + prev,
Loading
Loading
@@ -1190,6 +1203,7 @@ static int Search(NSString* needle,
line_length,
width,
_mayHaveDoubleWidthCharacter);
DLog(@"Offset is %@", @(offset));
// We know that position falls in this line. Set x to the number
// of chars after the beginning on the line. If there were only
// single-width chars the formula would be:
Loading
Loading
Loading
Loading
@@ -30,6 +30,7 @@
#import "LineBuffer.h"
 
#import "BackgroundThread.h"
#import "DebugLogging.h"
#import "LineBlock.h"
#import "RegexKitLite.h"
 
Loading
Loading
@@ -896,7 +897,9 @@ static int RawNumLines(LineBuffer* buffer, int width) {
width:(int)width
ok:(BOOL *)ok
{
DLog(@"Entering coordinateForPosition:%@ width:%@ ok:&ok", position, @(width));
if (position.absolutePosition == [self lastPos] + droppedChars) {
DLog(@"absolute position equals the very last position. droppedChars=%@", @(droppedChars));
VT100GridCoord result;
// If the absolute position is equal to the last position, then
// numLinesWithWidth: will give the wrapped line number after all
Loading
Loading
@@ -920,26 +923,33 @@ static int RawNumLines(LineBuffer* buffer, int width) {
if (ok) {
*ok = YES;
}
DLog(@"Returning. This was easy");
return result;
}
int i;
int yoffset = 0;
int p = position.absolutePosition - droppedChars;
DLog(@"Begin iterating blocks. p=%d", p);
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];
DLog(@"p becomes %d", p);
} else {
int y;
int x;
DLog(@"Found the block.");
BOOL positionIsValid = [block convertPosition:p
withWidth:width
toX:&x
toY:&y];
DLog(@"convertPosition returned %@", @(positionIsValid));
if (ok) {
*ok = positionIsValid;
} else {
DLog(@"fml convertPosition failed");
}
if (position.yOffset > 0) {
x = 0;
Loading
Loading
Loading
Loading
@@ -479,6 +479,7 @@ static NSString *const kInilineFileInset = @"inset"; // NSValue of NSEdgeInsets
NSMutableArray *altScreenNotes = nil;
 
if (wasShowingAltScreen) {
DLog(@"Was showing alt screen");
if (couldHaveSelection) {
// In alternate screen mode, get the original positions of the
// selection. Later this will be used to set the selection positions
Loading
Loading
@@ -594,18 +595,23 @@ static NSString *const kInilineFileInset = @"inset"; // NSValue of NSEdgeInsets
 
// Convert ranges of notes to their new coordinates and replace the interval tree.
IntervalTree *replacementTree = [[IntervalTree alloc] init];
DLog(@"Checking interval tree");
for (id<IntervalTreeObject> note in [intervalTree_ allObjects]) {
DLog(@"Consider interval tree object: %@ with interval %@", note, note.entry.interval);
VT100GridCoordRange noteRange = [self coordRangeForInterval:note.entry.interval];
VT100GridCoordRange newRange;
if (noteRange.end.x < 0 && noteRange.start.y == 0 && noteRange.end.y < 0) {
DLog(@"It has scrolled off the top. Its range is %@", VT100GridCoordRangeDescription(noteRange));
// note has scrolled off top
[intervalTree_ removeObject:note];
} else {
DLog(@"Converting the range %@ to the new width %@", VT100GridCoordRangeDescription(noteRange), @(newSize.width));
if ([self convertRange:noteRange
toWidth:newSize.width
to:&newRange
inLineBuffer:linebuffer_
tolerateEmpty:[self intervalTreeObjectMayBeEmpty:note]]) {
DLog(@"LGTM new range is %@", VT100GridCoordRangeDescription(newRange));
assert(noteRange.start.y >= 0);
assert(noteRange.end.y >= 0);
Interval *newInterval = [self intervalForGridCoordRange:newRange
Loading
Loading
@@ -614,6 +620,8 @@ static NSString *const kInilineFileInset = @"inset"; // NSValue of NSEdgeInsets
[[note retain] autorelease];
[intervalTree_ removeObject:note];
[replacementTree addObject:note withInterval:newInterval];
} else {
DLog(@"Shit that failed");
}
}
}
Loading
Loading
@@ -3480,6 +3488,7 @@ static NSString *const kInilineFileInset = @"inset"; // NSValue of NSEdgeInsets
iTermImageMark *mark = [self addMarkStartingAtAbsoluteLine:absLine
oneLine:YES
ofClass:[iTermImageMark class]];
DLog(@"Add image mark %@ at absolute line %@, interval %@", mark, @(absLine), mark.entry.interval);
mark.imageCode = @(c.code);
[delegate_ screenNeedsRedraw];
}
Loading
Loading
@@ -4122,6 +4131,7 @@ static void SwapInt(int *a, int *b) {
inLineBuffer:(LineBuffer *)lineBuffer
tolerateEmpty:(BOOL)tolerateEmpty {
if (range.start.y < 0 || range.end.y < 0) {
DLog(@"Failing because range's start or end is negative");
return NO;
}
LineBufferPositionRange *selectionRange;
Loading
Loading
@@ -4136,6 +4146,7 @@ static void SwapInt(int *a, int *b) {
// One case where this happens is when the start and end of the range are past the last
// character in the line buffer (e.g., all nulls). It could occur when a note exists on a
// null line.
DLog(@"position range is nil");
return NO;
}
 
Loading
Loading
@@ -4147,6 +4158,7 @@ static void SwapInt(int *a, int *b) {
width:newWidth
ok:&ok];
if (ok) {
DLog(@"Converted range's end successfully");
newEnd.x++;
if (newEnd.x > newWidth) {
newEnd.y++;
Loading
Loading
@@ -4154,6 +4166,8 @@ static void SwapInt(int *a, int *b) {
}
resultPtr->end = newEnd;
} else {
DLog(@"Failed to convert selection range's end. It was %@", selectionRange.end);
// I'm not sure how to get here. It would happen if the endpoint of the selection could
// be converted into a LineBufferPosition with the original width but that LineBufferPosition
// could not be converted back into a VT100GridCoord with the new width.
Loading
Loading
@@ -4163,6 +4177,7 @@ static void SwapInt(int *a, int *b) {
if (selectionRange.end.extendsToEndOfLine) {
resultPtr->end.x = newWidth;
}
DLog(@"Returning success");
return YES;
}
 
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