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

Add rudimentary notes

parent 3c407774
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -70,6 +70,7 @@
// cumulative_line_lengths[i-1] for i>0 or 0 for i==0.
int* cumulative_line_lengths;
NSTimeInterval *timestamps_;
NSMutableDictionary *objects_;
 
// The number of elements allocated for cumulative_line_lengths.
int cll_capacity;
Loading
Loading
@@ -95,7 +96,14 @@
 
// Try to append a line to the end of the buffer. Returns false if it does not fit. If length > buffer_size it will never succeed.
// Callers should split such lines into multiple pieces.
- (BOOL)appendLine:(screen_char_t*)buffer length:(int)length partial:(BOOL)partial width:(int)width timestamp:(NSTimeInterval)timestamp;
- (BOOL)appendLine:(screen_char_t*)buffer
length:(int)length
partial:(BOOL)partial
width:(int)width
timestamp:(NSTimeInterval)timestamp
object:(NSObject *)object;
- (void)setObject:(NSObject *)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.
Loading
Loading
@@ -112,7 +120,11 @@
- (BOOL) hasPartial;
 
// Remove the last line. Returns false if there was none.
- (BOOL)popLastLineInto:(screen_char_t**) ptr withLength:(int*)length upToWidth:(int)width timestamp:(NSTimeInterval *)timestampPtr;
- (BOOL)popLastLineInto:(screen_char_t**)ptr
withLength:(int*)length
upToWidth:(int)width
timestamp:(NSTimeInterval *)timestampPtr
object:(NSObject **)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
@@ -140,7 +152,9 @@
- (void) shrinkToFit;
 
// Append a value to cumulativeLineLengths.
- (void)_appendCumulativeLineLength:(int)cumulativeLength timestamp:(NSTimeInterval)timestamp;
- (void)_appendCumulativeLineLength:(int)cumulativeLength
timestamp:(NSTimeInterval)timestamp
object:(NSObject *)object;
 
// Return a raw line
- (screen_char_t*) rawLine: (int) linenum;
Loading
Loading
@@ -151,6 +165,9 @@
// Returns the timestamp associated with a line when wrapped to the specified width.
- (NSTimeInterval)timestampForLineNumber:(int)lineNum width:(int)width;
 
// Returns the object associated with a line.
- (NSObject *)objectForLineNumber:(int)lineNum width:(int)width;
@end
 
// A LineBuffer represents an ordered collection of strings of screen_char_t. Each string forms a
Loading
Loading
@@ -207,7 +224,14 @@
// that is to say, this buffer contains only a prefix or infix of the entire line.
//
// NOTE: call dropExcessLinesWithWidth after this if you want to limit the buffer to max_lines.
- (void)appendLine:(screen_char_t*)buffer length:(int)length partial:(BOOL)partial width:(int)width timestamp:(NSTimeInterval)timestamp;
- (void)appendLine:(screen_char_t*)buffer
length:(int)length
partial:(BOOL)partial
width:(int)width
timestamp:(NSTimeInterval)timestamp
object:(NSObject *)object;
- (void)setObject:(NSObject *)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
@@ -221,6 +245,9 @@
// Returns the timestamp associated with a line when wrapped to the specified width.
- (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;
// Copy a line into the buffer. If the line is shorter than 'width' then only the first 'width'
// characters will be modified.
// 0 <= lineNum < numLinesWithWidth:width
Loading
Loading
@@ -236,7 +263,11 @@
// Copy up to width chars from the last line into *ptr. The last line will be removed or
// truncated from the buffer. Sets *includesEndOfLine to true if this line should have a
// continuation marker.
- (BOOL)popAndCopyLastLineInto:(screen_char_t*)ptr width:(int)width includesEndOfLine:(int*)includesEndOfLine timestamp:(NSTimeInterval *)timestampPtr;
- (BOOL)popAndCopyLastLineInto:(screen_char_t*)ptr
width:(int)width
includesEndOfLine:(int*)includesEndOfLine
timestamp:(NSTimeInterval *)timestampPtr
object:(NSObject **)objectPtr;
 
// Get the number of buffer lines at a given width.
- (int) numLinesWithWidth: (int) width;
Loading
Loading
Loading
Loading
@@ -53,6 +53,7 @@
cll_entries = 0;
cumulative_line_lengths = (int*) malloc(sizeof(int) * cll_capacity);
timestamps_ = (NSTimeInterval *)malloc(sizeof(NSTimeInterval) * cll_capacity);
objects_ = [[NSMutableDictionary alloc] init];
is_partial = NO;
cached_numlines_width = -1;
}
Loading
Loading
@@ -70,6 +71,7 @@
if (timestamps_) {
free(timestamps_);
}
[objects_ release];
[super dealloc];
}
 
Loading
Loading
@@ -87,6 +89,7 @@
memmove(theCopy->cumulative_line_lengths, cumulative_line_lengths, cll_size);
theCopy->timestamps_ = (NSTimeInterval *) malloc(sizeof(NSTimeInterval) * cll_capacity);
memmove(theCopy->timestamps_, timestamps_, sizeof(NSTimeInterval) * cll_capacity);
theCopy->objects_ = [objects_ mutableCopy];
theCopy->cll_capacity = cll_capacity;
theCopy->cll_entries = cll_entries;
theCopy->is_partial = is_partial;
Loading
Loading
@@ -105,7 +108,7 @@
}
}
 
- (void)_appendCumulativeLineLength:(int)cumulativeLength timestamp:(NSTimeInterval)timestamp
- (void)_appendCumulativeLineLength:(int)cumulativeLength timestamp:(NSTimeInterval)timestamp object:(NSObject *)object
{
if (cll_entries == cll_capacity) {
cll_capacity *= 2;
Loading
Loading
@@ -115,6 +118,11 @@
}
cumulative_line_lengths[cll_entries] = cumulativeLength;
timestamps_[cll_entries] = timestamp;
if (object) {
[objects_ setObject:object forKey:@(cll_entries)];
} else {
[objects_ removeObjectForKey:@(cll_entries)];
}
++cll_entries;
}
 
Loading
Loading
@@ -204,7 +212,12 @@ static int NumberOfFullLines(screen_char_t* buffer, int length, int width)
}
#endif
 
- (BOOL)appendLine:(screen_char_t*)buffer length:(int)length partial:(BOOL)partial width:(int)width timestamp:(NSTimeInterval)timestamp
- (BOOL)appendLine:(screen_char_t*)buffer
length:(int)length
partial:(BOOL)partial
width:(int)width
timestamp:(NSTimeInterval)timestamp
object:(NSObject *)object
{
const int space_used = [self rawSpaceUsed];
const int free_space = buffer_size - space_used - start_offset;
Loading
Loading
@@ -239,13 +252,19 @@ static int NumberOfFullLines(screen_char_t* buffer, int length, int width)
 
cumulative_line_lengths[cll_entries - 1] += length;
timestamps_[cll_entries - 1] = timestamp;
if (object) {
[objects_ setObject:object forKey:@(cll_entries - 1)];
} else {
[objects_ removeObjectForKey:@(cll_entries - 1)];
}
#ifdef TEST_LINEBUFFER_SANITY
[self checkAndResetCachedNumlines:@"appendLine partial case" width: width];
#endif
} else {
// add a new line
[self _appendCumulativeLineLength:(space_used + length)
timestamp:timestamp];
timestamp:timestamp
object:object];
if (width != cached_numlines_width) {
cached_numlines_width = -1;
} else {
Loading
Loading
@@ -274,7 +293,6 @@ static int NumberOfFullLines(screen_char_t* buffer, int length, int width)
}
}
 
// Finds a where the nth line begins after wrapping and returns its offset from the start of the buffer.
//
// In the following example, this would return:
Loading
Loading
@@ -327,6 +345,46 @@ static int OffsetOfWrappedLine(screen_char_t* p, int n, int length, int width) {
return 0;
}
 
- (NSObject *)objectForLineNumber:(int)lineNum width:(int)width
{
int prev = 0;
int length;
int i;
for (i = first_entry; i < cll_entries; ++i) {
int cll = cumulative_line_lengths[i] - start_offset;
length = cll - prev;
int spans = NumberOfFullLines(buffer_start + prev, length, width);
if (lineNum > spans) {
// Consume the entire raw line and keep looking for more.
int consume = spans + 1;
lineNum -= consume;
} else { // *lineNum <= spans
return objects_[@(i)];
}
prev = cll;
}
return 0;
}
- (void)setObject:(NSObject *)object forLine:(int)lineNum width:(int)width {
int prev = 0;
int length;
int i;
for (i = first_entry; i < cll_entries; ++i) {
int cll = cumulative_line_lengths[i] - start_offset;
length = cll - prev;
int spans = NumberOfFullLines(buffer_start + prev, length, width);
if (lineNum > spans) {
// Consume the entire raw line and keep looking for more.
int consume = spans + 1;
lineNum -= consume;
} else { // *lineNum <= spans
[objects_ setObject:object forKey:@(i)];
}
prev = cll;
}
}
- (screen_char_t*) getWrappedLineWithWrapWidth: (int) width
lineNum: (int*) lineNum
lineLength: (int*) lineLength
Loading
Loading
@@ -410,7 +468,11 @@ static int OffsetOfWrappedLine(screen_char_t* p, int n, int length, int width) {
return cached_numlines_width == width;
}
 
- (BOOL)popLastLineInto:(screen_char_t**)ptr withLength:(int*)length upToWidth:(int)width timestamp:(NSTimeInterval *)timestampPtr
- (BOOL)popLastLineInto:(screen_char_t**)ptr
withLength:(int*)length
upToWidth:(int)width
timestamp:(NSTimeInterval *)timestampPtr
object:(NSObject **)objectPtr
{
if (cll_entries == first_entry) {
// There is no last line to pop.
Loading
Loading
@@ -425,6 +487,10 @@ static int OffsetOfWrappedLine(screen_char_t* p, int n, int length, int width) {
if (timestampPtr) {
*timestampPtr = timestamps_[cll_entries - 1];
}
if (objectPtr) {
*objectPtr = objects_[@(cll_entries - 1)];
}
const int end = cumulative_line_lengths[cll_entries - 1] - start_offset;
const int available_len = end - start;
if (available_len > width) {
Loading
Loading
@@ -1217,7 +1283,12 @@ static int RawNumLines(LineBuffer* buffer, int width) {
return [self initWithBlockSize:BLOCK_SIZE];
}
 
- (void)appendLine:(screen_char_t*)buffer length:(int)length partial:(BOOL)partial width:(int)width timestamp:(NSTimeInterval)timestamp
- (void)appendLine:(screen_char_t*)buffer
length:(int)length
partial:(BOOL)partial
width:(int)width
timestamp:(NSTimeInterval)timestamp
object:(NSObject *)object
{
#ifdef LOG_MUTATIONS
{
Loading
Loading
@@ -1237,12 +1308,13 @@ static int RawNumLines(LineBuffer* buffer, int width) {
LineBlock* block = [blocks objectAtIndex: ([blocks count] - 1)];
 
int beforeLines = [block getNumLinesWithWrapWidth:width];
if (![block appendLine:buffer length:length partial:partial width:width timestamp:timestamp]) {
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
// cache.
num_wrapped_lines_width = -1;
int prefix_len = 0;
NSTimeInterval prefixTimestamp = 0;
NSObject *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
@@ -1252,7 +1324,8 @@ static int RawNumLines(LineBuffer* buffer, int width) {
BOOL ok = [block popLastLineInto:&temp
withLength:&prefix_len
upToWidth:[block rawBufferSize]+1
timestamp:&prefixTimestamp];
timestamp:&prefixTimestamp
object:&prefixObject];
assert(ok);
prefix = (screen_char_t*) malloc(MAX(1, prefix_len) * sizeof(screen_char_t));
memcpy(prefix, temp, prefix_len * sizeof(screen_char_t));
Loading
Loading
@@ -1284,13 +1357,13 @@ static int RawNumLines(LineBuffer* buffer, int width) {
// Append the prefix if there is one (the prefix was a partial line that we're
// moving out of the last block into the new block)
if (prefix) {
BOOL ok = [block appendLine:prefix length:prefix_len partial:YES width:width timestamp:prefixTimestamp];
BOOL ok = [block appendLine:prefix length:prefix_len partial:YES width:width timestamp:prefixTimestamp object:prefixObject];
NSAssert(ok, @"append can't fail here");
free(prefix);
}
// Finally, append this line to the new block. We know it'll fit because we made
// enough room for it.
BOOL ok = [block appendLine:buffer length:length partial:partial width:width timestamp:timestamp];
BOOL ok = [block appendLine:buffer length:length partial:partial width:width timestamp:timestamp object:object];
NSAssert(ok, @"append can't fail here");
} else if (num_wrapped_lines_width == width) {
// Straightforward addition of a line to an existing block. Update the
Loading
Loading
@@ -1325,6 +1398,49 @@ static int RawNumLines(LineBuffer* buffer, int width) {
return 0;
}
 
- (NSObject *)objectForLineNumber:(int)lineNum width:(int)width
{
int line = lineNum;
int i;
for (i = 0; i < [blocks count]; ++i) {
LineBlock* block = [blocks objectAtIndex:i];
NSAssert(block, @"Null block");
// getNumLinesWithWrapWidth caches its result for the last-used width so
// this is usually faster than calling getWrappedLineWithWrapWidth since
// most calls to the latter will just decrement line and return NULL.
int block_lines = [block getNumLinesWithWrapWidth:width];
if (block_lines < line) {
line -= block_lines;
continue;
}
return [block objectForLineNumber:line width:width];
}
return 0;
}
- (void)setObject:(NSObject *)object forLine:(int)lineNum width:(int)width {
int line = lineNum;
int i;
for (i = 0; i < [blocks count]; ++i) {
LineBlock* block = [blocks objectAtIndex:i];
NSAssert(block, @"Null block");
// getNumLinesWithWrapWidth caches its result for the last-used width so
// this is usually faster than calling getWrappedLineWithWrapWidth since
// most calls to the latter will just decrement line and return NULL.
int block_lines = [block getNumLinesWithWrapWidth:width];
if (block_lines < line) {
line -= block_lines;
continue;
}
[block setObject:object forLine:line width:width];
return;
}
}
// Copy a line into the buffer. If the line is shorter than 'width' then only
// the first 'width' characters will be modified.
// 0 <= lineNum < numLinesWithWidth:width
Loading
Loading
@@ -1401,7 +1517,11 @@ static int RawNumLines(LineBuffer* buffer, int width) {
return RawNumLines(self, width);
}
 
- (BOOL)popAndCopyLastLineInto:(screen_char_t*)ptr width:(int)width includesEndOfLine:(int*)includesEndOfLine timestamp:(NSTimeInterval *)timestampPtr
- (BOOL)popAndCopyLastLineInto:(screen_char_t*)ptr
width:(int)width
includesEndOfLine:(int*)includesEndOfLine
timestamp:(NSTimeInterval *)timestampPtr
object:(NSObject **)objectPtr
{
if ([self numLinesWithWidth: width] == 0) {
return NO;
Loading
Loading
@@ -1417,7 +1537,11 @@ static int RawNumLines(LineBuffer* buffer, int width) {
// Pop the last up-to-width chars off the last line.
int length;
screen_char_t* temp;
BOOL ok = [block popLastLineInto:&temp withLength:&length upToWidth:width timestamp:timestampPtr];
BOOL ok = [block popLastLineInto:&temp
withLength:&length
upToWidth:width
timestamp:timestampPtr
object:objectPtr];
NSAssert(ok, @"Unexpected empty block");
NSAssert(length <= width, @"Length too large");
NSAssert(length >= 0, @"Negative length");
Loading
Loading
//
// PTYNoteView.h
// iTerm
//
// Created by George Nachman on 11/18/13.
//
//
#import <Cocoa/Cocoa.h>
@protocol PTYNoteViewDelegate <NSObject>
@end
@interface PTYNoteView : NSView {
id<PTYNoteViewDelegate> delegate_;
}
@property(nonatomic, assign) id<PTYNoteViewDelegate> delegate;
@end
//
// PTYNoteView.m
// iTerm
//
// Created by George Nachman on 11/18/13.
//
//
#import "PTYNoteView.h"
@implementation PTYNoteView
@synthesize delegate = delegate_;
- (void)drawRect:(NSRect)dirtyRect
{
[super drawRect:dirtyRect];
NSBezierPath* path = [[[NSBezierPath alloc] init] autorelease];
NSSize size = self.frame.size;
size.width -= 5;
size.height -= 5;
CGFloat radius = 5;
CGFloat arrowWidth = 10;
CGFloat arrowHeight = 7;
CGFloat offset = 0.5;
CGFloat yoffset = 4.5;
[path moveToPoint:NSMakePoint(offset + 0, yoffset + size.height)];
[path lineToPoint:NSMakePoint(offset + size.width - radius, yoffset + size.height)];
[path curveToPoint:NSMakePoint(offset + size.width, yoffset + size.height - radius)
controlPoint1:NSMakePoint(offset + size.width, yoffset + size.height)
controlPoint2:NSMakePoint(offset + size.width, yoffset + size.height)];
[path lineToPoint:NSMakePoint(offset + size.width, yoffset + radius)];
[path curveToPoint:NSMakePoint(offset + size.width - radius, yoffset + 0)
controlPoint1:NSMakePoint(offset + size.width, yoffset + 0)
controlPoint2:NSMakePoint(offset + size.width, yoffset + 0)];
[path lineToPoint:NSMakePoint(offset + arrowWidth + radius, yoffset + 0)];
[path curveToPoint:NSMakePoint(offset + arrowWidth, yoffset + radius)
controlPoint1:NSMakePoint(offset + arrowWidth, yoffset + 0)
controlPoint2:NSMakePoint(offset + arrowWidth, yoffset + 0)];
[path lineToPoint:NSMakePoint(offset + arrowWidth, yoffset + size.height - arrowHeight)];
[path lineToPoint:NSMakePoint(offset + 0, yoffset + size.height)];
[[NSColor colorWithCalibratedRed:252.0/255.0 green:250.0/255.0 blue:198.0/255.0 alpha:0.95] set];
[path fill];
[[NSColor colorWithCalibratedRed:255.0/255.0 green:229.0/255.0 blue:114.0/255.0 alpha:0.95] set];
[path setLineWidth:1];
[path stroke];
}
@end
//
// PTYNoteViewController.h
// iTerm
//
// Created by George Nachman on 11/18/13.
//
//
#import <Cocoa/Cocoa.h>
#import "PTYNoteView.h"
@interface PTYNoteViewController : NSViewController <PTYNoteViewDelegate> {
PTYNoteView *noteView_;
NSTextField *textField_;
}
@property(nonatomic, retain) PTYNoteView *noteView;
- (void)beginEditing;
@end
//
// PTYNoteViewController.m
// iTerm
//
// Created by George Nachman on 11/18/13.
//
//
#import "PTYNoteViewController.h"
#import "PTYNoteView.h"
@interface PTYNoteViewController ()
@property(nonatomic, retain) NSTextField *textField;
@end
@implementation PTYNoteViewController
@synthesize noteView = noteView_;
@synthesize textField = textField_;
- (void)setNoteView:(PTYNoteView *)noteView {
[noteView_ autorelease];
noteView_ = [noteView retain];
[self setView:noteView];
}
- (void)loadView {
[super loadView];
const CGFloat kWidth = 300;
const CGFloat kHeight = 50;
self.noteView = [[[PTYNoteView alloc] initWithFrame:NSMakeRect(0, 0, kWidth, kHeight)] autorelease];
self.noteView.delegate = self;
const CGFloat kLeftMargin = 15;
const CGFloat kRightMargin = 10;
const CGFloat kTopMargin = 10;
const CGFloat kBottomMargin = 5;
self.textField = [[[NSTextField alloc] initWithFrame:NSMakeRect(kLeftMargin,
kTopMargin,
kWidth - kLeftMargin - kRightMargin,
kHeight - kTopMargin - kBottomMargin)] autorelease];
[textField_ setStringValue:@""];
[textField_ setBezeled:NO];
[textField_ setEditable:YES];
[textField_ setDrawsBackground:NO];
[textField_ setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
NSTextFieldCell *cell = textField_.cell;
cell.placeholderString = @"Enter note here";
[noteView_ addSubview:textField_];
}
- (void)beginEditing {
[[textField_ window] makeFirstResponder:textField_];
}
@end
Loading
Loading
@@ -71,6 +71,7 @@ static const int kMaxSelectedTextLinesForCustomActions = 100;
#import "FutureMethods.h"
#import "MovingAverage.h"
#import "SearchResult.h"
#import "PTYNoteViewController.h"
 
#include <sys/time.h>
#include <math.h>
Loading
Loading
@@ -4500,6 +4501,27 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
[[dataSource session] clearBuffer];
}
 
- (void)addOrEditNoteForLine:(int)line
{
PTYNoteViewController *note = [dataSource noteForLine:line];
if (!note) {
note = [[[PTYNoteViewController alloc] init] autorelease];
[dataSource setNote:note forLine:line];
}
[note.view removeFromSuperview];
note.view.frame = NSMakeRect(0,
line * lineHeight + lineHeight / 2, note.view.frame.size.width, note.view.frame.size.height);
[self addSubview:note.view];
[note beginEditing];
}
- (void)addNote:(id)sender
{
if (startY >= 0) {
[self addOrEditNoteForLine:startY];
}
}
- (void)editTextViewSession:(id)sender
{
[[[[dataSource session] tab] realParentWindow] editSession:[dataSource session]];
Loading
Loading
@@ -4601,6 +4623,7 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
if ([item action]==@selector(mail:) ||
[item action]==@selector(browse:) ||
[item action]==@selector(searchInBrowser:) ||
[item action]==@selector(addNote:) ||
[item action]==@selector(copy:) ||
[item action]==@selector(pasteSelection:) ||
([item action]==@selector(print:) && [item tag] == 1)) { // print selection
Loading
Loading
@@ -4821,6 +4844,12 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
keyEquivalent:@""];
[[theMenu itemAtIndex:[theMenu numberOfItems] - 1] setTarget:self];
 
// Make note
[theMenu addItemWithTitle:@"Add Note…"
action:@selector(addNote:)
keyEquivalent:@""];
[[theMenu itemAtIndex:[theMenu numberOfItems] - 1] setTarget:self];
// Separator
[theMenu addItem:[NSMenuItem separatorItem]];
 
Loading
Loading
Loading
Loading
@@ -9,6 +9,7 @@ typedef enum {
FlashBell, FlashWrapToTop, FlashWrapToBottom
} FlashImage;
 
@class PTYNoteViewController;
@class PTYSession;
@class PTYTask;
@class VT100Terminal;
Loading
Loading
@@ -85,4 +86,7 @@ typedef enum {
// Returns the last modified date for a given line.
- (NSDate *)timestampForLine:(int)y;
 
- (PTYNoteViewController *)noteForLine:(int)y;
- (void)setNote:(PTYNoteViewController *)note forLine:(int)y;
@end
Loading
Loading
@@ -213,6 +213,8 @@
 
// Returns the timestamp of a given line.
- (NSTimeInterval)timestampForLine:(int)y;
- (NSObject *)objectForLine:(int)y;
- (void)setObject:(NSObject *)object forLine:(int)y;
 
- (NSString *)compactLineDump;
- (NSString *)compactLineDumpWithTimestamps;
Loading
Loading
Loading
Loading
@@ -209,7 +209,8 @@
length:currentLineLength
partial:(continuation != EOL_HARD)
width:size_.width
timestamp:[[self lineInfoAtLineNumber:i] timestamp]];
timestamp:[[self lineInfoAtLineNumber:i] timestamp]
object:[[self lineInfoAtLineNumber:i] object]];
#ifdef DEBUG_RESIZEDWIDTH
NSLog(@"Appended a line. now have %d lines for width %d\n",
[lineBuffer numLinesWithWidth:size_.width], size_.width);
Loading
Loading
@@ -223,6 +224,14 @@
return [[self lineInfoAtLineNumber:y] timestamp];
}
 
- (NSObject *)objectForLine:(int)y {
return [[self lineInfoAtLineNumber:y] object];
}
- (void)setObject:(NSObject *)object forLine:(int)y {
[[self lineInfoAtLineNumber:y] setObject:object];
}
- (int)lengthOfLineNumber:(int)lineNumber {
screen_char_t *line = [self screenCharsAtLineNumber:lineNumber];
return [self lengthOfLine:line];
Loading
Loading
@@ -1198,8 +1207,14 @@
}
int cont;
NSTimeInterval timestamp;
assert([lineBuffer popAndCopyLastLineInto:dest width:size_.width includesEndOfLine:&cont timestamp:&timestamp]);
NSObject *object;
assert([lineBuffer popAndCopyLastLineInto:dest
width:size_.width
includesEndOfLine:&cont
timestamp:&timestamp
object:&object]);
[[self lineInfoAtLineNumber:destLineNumber] setTimestamp:timestamp];
[[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
// line below it starts with a DWC, it's safe to conclude that a DWC
Loading
Loading
@@ -1553,7 +1568,8 @@
length:len
partial:(continuationMark != EOL_HARD)
width:size_.width
timestamp:[[self lineInfoAtLineNumber:0] timestamp]];
timestamp:[[self lineInfoAtLineNumber:0] timestamp]
object:[[self lineInfoAtLineNumber:0] object]];
int dropped;
if (!unlimitedScrollback) {
dropped = [lineBuffer dropExcessLinesWithWidth:size_.width];
Loading
Loading
Loading
Loading
@@ -12,6 +12,7 @@
@interface VT100LineInfo : NSObject <NSCopying>
 
@property(nonatomic, assign) NSTimeInterval timestamp;
@property(nonatomic, retain) NSObject *object;
 
- (id)initWithWidth:(int)width;
- (void)setDirty:(BOOL)dirty inRange:(VT100GridRange)range updateTimestamp:(BOOL)updateTimestamp;
Loading
Loading
Loading
Loading
@@ -13,9 +13,11 @@
int width_;
BOOL anyCharPossiblyDirty_; // No means nothing is dirty. Yes means MAYBE something is dirty.
NSTimeInterval timestamp_;
NSObject *object_;
}
 
@synthesize timestamp = timestamp_;
@synthesize object = object_;
 
- (id)initWithWidth:(int)width {
self = [super init];
Loading
Loading
Loading
Loading
@@ -8,6 +8,7 @@
 
#import "DebugLogging.h"
#import "DVR.h"
#import "PTYNoteViewController.h"
#import "PTYTextView.h"
#import "RegexKitLite.h"
#import "SearchResult.h"
Loading
Loading
@@ -673,7 +674,8 @@ static const double kInterBellQuietPeriod = 0.1;
length:len
partial:NO
width:currentGrid_.size.width
timestamp:now];
timestamp:now
object:nil];
}
NSMutableArray *wrappedLines = [NSMutableArray array];
int n = [temp numLinesWithWidth:currentGrid_.size.width];
Loading
Loading
@@ -698,7 +700,8 @@ static const double kInterBellQuietPeriod = 0.1;
length:line.length
partial:(line.eol != EOL_HARD)
width:currentGrid_.size.width
timestamp:now];
timestamp:now
object:nil];
}
if (!unlimitedScrollback_) {
[linebuffer_ dropExcessLinesWithWidth:currentGrid_.size.width];
Loading
Loading
@@ -1175,6 +1178,26 @@ static const double kInterBellQuietPeriod = 0.1;
return [NSDate dateWithTimeIntervalSinceReferenceDate:interval];
}
 
- (PTYNoteViewController *)noteForLine:(int)y {
int numLinesInLineBuffer = [linebuffer_ numLinesWithWidth:currentGrid_.size.width];
NSTimeInterval interval;
if (y >= numLinesInLineBuffer) {
return (PTYNoteViewController *)[currentGrid_ objectForLine:y - numLinesInLineBuffer];
} else {
return (PTYNoteViewController *)[linebuffer_ objectForLineNumber:y width:currentGrid_.size.width];
}
}
- (void)setNote:(PTYNoteViewController *)note forLine:(int)y {
int numLinesInLineBuffer = [linebuffer_ numLinesWithWidth:currentGrid_.size.width];
NSTimeInterval interval;
if (y >= numLinesInLineBuffer) {
[currentGrid_ setObject:note forLine:y - numLinesInLineBuffer];
} else {
[linebuffer_ setObject:note forLine:y width:currentGrid_.size.width];
}
}
#pragma mark - VT100TerminalDelegate
 
- (void)terminalAppendString:(NSString *)string isAscii:(BOOL)isAscii
Loading
Loading
@@ -2530,7 +2553,8 @@ static void SwapInt(int *a, int *b) {
BOOL isOk = [linebuffer_ popAndCopyLastLineInto:dummy
width:currentGrid_.size.width
includesEndOfLine:&cont
timestamp:NULL];
timestamp:NULL
object:NULL];
NSAssert(isOk, @"Pop shouldn't fail");
}
free(dummy);
Loading
Loading
Loading
Loading
@@ -571,6 +571,12 @@
A63F4090183948E4003A6A6D /* VT100LineInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = A63F408E183948E4003A6A6D /* VT100LineInfo.h */; };
A63F4091183948E4003A6A6D /* VT100LineInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = A63F408F183948E4003A6A6D /* VT100LineInfo.m */; };
A63F4092183962D3003A6A6D /* VT100LineInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = A63F408F183948E4003A6A6D /* VT100LineInfo.m */; };
A63F4095183B398C003A6A6D /* PTYNoteViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = A63F4093183B398C003A6A6D /* PTYNoteViewController.h */; };
A63F4096183B398C003A6A6D /* PTYNoteViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A63F4094183B398C003A6A6D /* PTYNoteViewController.m */; };
A63F4097183B398C003A6A6D /* PTYNoteViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A63F4094183B398C003A6A6D /* PTYNoteViewController.m */; };
A63F409A183B3AA7003A6A6D /* PTYNoteView.h in Headers */ = {isa = PBXBuildFile; fileRef = A63F4098183B3AA7003A6A6D /* PTYNoteView.h */; };
A63F409B183B3AA7003A6A6D /* PTYNoteView.m in Sources */ = {isa = PBXBuildFile; fileRef = A63F4099183B3AA7003A6A6D /* PTYNoteView.m */; };
A63F409C183B3AA7003A6A6D /* PTYNoteView.m in Sources */ = {isa = PBXBuildFile; fileRef = A63F4099183B3AA7003A6A6D /* PTYNoteView.m */; };
DDF0FD65062916F70080EF74 /* iTermApplication.h in Headers */ = {isa = PBXBuildFile; fileRef = DDF0FD63062916F70080EF74 /* iTermApplication.h */; };
DDF0FD66062916F70080EF74 /* iTermApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = DDF0FD64062916F70080EF74 /* iTermApplication.m */; };
F638C2620AD483BF00BEE23D /* iTerm.strings in Resources */ = {isa = PBXBuildFile; fileRef = FB151F2903648AC401F955DB /* iTerm.strings */; };
Loading
Loading
@@ -962,6 +968,10 @@
A073973F14C7694600786414 /* ColorsMenuItemView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ColorsMenuItemView.m; sourceTree = "<group>"; };
A63F408E183948E4003A6A6D /* VT100LineInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VT100LineInfo.h; sourceTree = "<group>"; };
A63F408F183948E4003A6A6D /* VT100LineInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VT100LineInfo.m; sourceTree = "<group>"; };
A63F4093183B398C003A6A6D /* PTYNoteViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PTYNoteViewController.h; sourceTree = "<group>"; };
A63F4094183B398C003A6A6D /* PTYNoteViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PTYNoteViewController.m; sourceTree = "<group>"; };
A63F4098183B3AA7003A6A6D /* PTYNoteView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PTYNoteView.h; sourceTree = "<group>"; };
A63F4099183B3AA7003A6A6D /* PTYNoteView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PTYNoteView.m; sourceTree = "<group>"; };
DD02572409CB9398008F320C /* PSMAquaTabStyle.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PSMAquaTabStyle.h; sourceTree = "<group>"; };
DD02572509CB9398008F320C /* PSMAquaTabStyle.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = PSMAquaTabStyle.m; sourceTree = "<group>"; };
DD02572609CB9398008F320C /* PSMMetalTabStyle.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PSMMetalTabStyle.h; sourceTree = "<group>"; };
Loading
Loading
@@ -1096,6 +1106,10 @@
0464AB0D006CD2EC7F000001 /* JTerminal */ = {
isa = PBXGroup;
children = (
A63F4093183B398C003A6A6D /* PTYNoteViewController.h */,
A63F4094183B398C003A6A6D /* PTYNoteViewController.m */,
A63F4098183B3AA7003A6A6D /* PTYNoteView.h */,
A63F4099183B3AA7003A6A6D /* PTYNoteView.m */,
A63F408E183948E4003A6A6D /* VT100LineInfo.h */,
A63F408F183948E4003A6A6D /* VT100LineInfo.m */,
0464AB0E006CD2EC7F000001 /* Classes */,
Loading
Loading
@@ -1805,6 +1819,7 @@
1D5FDD4F1208E8F000C46BA3 /* PseudoTerminal.h in Headers */,
1D5FDD501208E8F000C46BA3 /* PTToolbarController.h in Headers */,
1D5FDD511208E8F000C46BA3 /* ITAddressBookMgr.h in Headers */,
A63F4095183B398C003A6A6D /* PTYNoteViewController.h in Headers */,
1D5FDD521208E8F000C46BA3 /* ITViewLocalizer.h in Headers */,
1D5FDD541208E8F000C46BA3 /* iTermKeyBindingMgr.h in Headers */,
1D5FDD591208E8F000C46BA3 /* PSMAquaTabStyle.h in Headers */,
Loading
Loading
@@ -1883,6 +1898,7 @@
1DF0895B13DBAE1F00A52AD8 /* NSBitmapImageRep+CoreImage.h in Headers */,
1DF0895D13DBAE1F00A52AD8 /* NSImage+CoreImage.h in Headers */,
1DCA5ECF13EE507800B7725E /* WindowArrangements.h in Headers */,
A63F409A183B3AA7003A6A6D /* PTYNoteView.h in Headers */,
1D2560AA13EE60E4006B35CD /* ArrangementPreviewView.h in Headers */,
1DF8AF5813FD781700C8A435 /* SplitPanel.h in Headers */,
1D29732714082676004C5DBE /* MovePaneController.h in Headers */,
Loading
Loading
@@ -2193,6 +2209,7 @@
files = (
1D9A557C180FA87000B42CE9 /* ColorsMenuItemView.m in Sources */,
1D9A552D180FA69900B42CE9 /* SearchResult.m in Sources */,
A63F409C183B3AA7003A6A6D /* PTYNoteView.m in Sources */,
1D9A55AB180FA8B700B42CE9 /* PSMProgressIndicator.m in Sources */,
1D9A5568180FA84700B42CE9 /* NSView+iTerm.m in Sources */,
1D9A5593180FA87000B42CE9 /* PTYFontInfo.m in Sources */,
Loading
Loading
@@ -2289,6 +2306,7 @@
1D9A556D180FA85900B42CE9 /* ToolWrapper.m in Sources */,
1D9A554A180FA82E00B42CE9 /* TmuxGateway.m in Sources */,
1D9A553C180FA7E600B42CE9 /* DVRIndexEntry.m in Sources */,
A63F4097183B398C003A6A6D /* PTYNoteViewController.m in Sources */,
1D9A555A180FA83900B42CE9 /* ArrangementPreviewView.m in Sources */,
1D9A55B2180FA8D400B42CE9 /* UKCrashReporter.m in Sources */,
1D9A55B4180FA8D400B42CE9 /* UKSystemInfo.m in Sources */,
Loading
Loading
@@ -2342,6 +2360,7 @@
1D5FDDA71208E93600C46BA3 /* PTYTextView.m in Sources */,
1D5FDDA81208E93600C46BA3 /* PTYTask.m in Sources */,
1D0AABC217B59B3D0072B5AF /* SearchResult.m in Sources */,
A63F4096183B398C003A6A6D /* PTYNoteViewController.m in Sources */,
1D5FDDA91208E93600C46BA3 /* VT100Screen.m in Sources */,
1D5FDDAA1208E93600C46BA3 /* VT100Terminal.m in Sources */,
1D5FDDAB1208E93600C46BA3 /* iTermController.m in Sources */,
Loading
Loading
@@ -2461,6 +2480,7 @@
1DA26AC115007507004B5792 /* BackgroundThread.m in Sources */,
1D2F3B3E1516BA470044C337 /* iTermFontPanel.m in Sources */,
1D48B32416706FC3000046EE /* NSView+iTerm.m in Sources */,
A63F409B183B3AA7003A6A6D /* PTYNoteView.m in Sources */,
1D48B37A167E809D000046EE /* CharacterRun.m in Sources */,
1D70BA361680158700824B72 /* PTYFontInfo.m in Sources */,
1D6944D8169E96AC00C7048A /* ThreeFingerTapGestureRecognizer.m in Sources */,
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