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

Merge

parents e61b15c8 1f7f3491
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -26,7 +26,9 @@
int tempCount_;
NSMutableAttributedString *string_;
 
// Array of advances. Gets realloced.
// Array of advances. Gets realloced. If there are multiple characters in a cell, the first will
// have a positive advance and the others will have a 0 advance. Core Text's positions are used
// for those codes.
float *advances_;
int advancesSize_; // used space
int advancesCapacity_; // available space
Loading
Loading
@@ -44,20 +46,25 @@
// Returns YES if the codes in otherRun can be safely added to this run.
- (BOOL)isCompatibleWith:(CharacterRun *)otherRun;
 
// Append to |string_|.
// Append codes from |string|, which will be rendered in a single cell (perhaps double-width) and may
// include combining marks.
- (void)appendCodesFromString:(NSString *)string withAdvance:(CGFloat)advance;
 
// This adds the code to temporary storage; call |commit| to actually append.
- (void)appendCode:(unichar)code withAdvance:(CGFloat)advance;
 
- (void)updateAdvances:(NSSize *)advances
forSuggestedAdvances:(const NSSize *)suggestedAdvances
count:(int)glyphCount;
// Returns a newly allocated line.
- (CTLineRef)newLine;
 
// Commit appended codes to the internal string.
- (void)commit;
 
// Returns the positions for characters in the given run, which begins at the specified character
// and x position. Returns the number of characters.
- (int)getPositions:(NSPoint *)positions
forRun:(CTRunRef)run
startingAtIndex:(int)firstCharacterIndex
glyphCount:(int)glyphCount
runWidthPtr:(CGFloat *)runWidthPtr;
@end
Loading
Loading
@@ -48,8 +48,9 @@ static const int kDefaultAdvancesCapacity = 100;
theCopy.color = color_;
theCopy.fakeBold = fakeBold_;
theCopy.x = x_;
[theCopy->string_ release];
theCopy->string_ = [string_ mutableCopy];
theCopy->advances_ = (float*)malloc(advancesCapacity_ * sizeof(float));
theCopy->advances_ = (float*)realloc(theCopy->advances_, advancesCapacity_ * sizeof(float));
memcpy(theCopy->advances_, advances_, advancesCapacity_ * sizeof(float));
theCopy->advancesCapacity_ = advancesCapacity_;
memmove(theCopy->temp_, temp_, sizeof(temp_));
Loading
Loading
@@ -59,24 +60,48 @@ static const int kDefaultAdvancesCapacity = 100;
return theCopy;
}
 
- (NSString *)description {
return [string_ description];
}
- (void)updateAdvances:(NSSize *)advances
forSuggestedAdvances:(const NSSize *)suggestedAdvances
count:(int)glyphCount {
int i = 0; // Index into suggestedAdvances (input) and advances (output)
int j = 0; // Index into advances_
while (i < glyphCount) {
if (suggestedAdvances[i].width> 0) {
advances[i] = NSMakeSize(advances_[j], 0);
j++;
} else {
advances[i] = NSMakeSize(0, 0);
// Align positions into cells.
- (int)getPositions:(NSPoint *)positions
forRun:(CTRunRef)run
startingAtIndex:(int)firstCharacterIndex
glyphCount:(int)glyphCount
runWidthPtr:(CGFloat *)runWidthPtr {
const NSPoint *suggestedPositions = CTRunGetPositionsPtr(run);
const CFIndex *indices = CTRunGetStringIndicesPtr(run);
int characterIndex = firstCharacterIndex;
int indexOfFirstGlyphInCurrentCell = 0;
CGFloat basePosition = 0; // X coord of the current cell relative to the start of this CTRun.
int numChars = 0;
CGFloat width = 0;
if (glyphCount > 0) {
numChars = 1;
width = advances_[firstCharacterIndex];
}
for (int glyphIndex = 0; glyphIndex < glyphCount; glyphIndex++) {
CGFloat x = basePosition + suggestedPositions[glyphIndex].x - suggestedPositions[indexOfFirstGlyphInCurrentCell].x;
positions[glyphIndex] = NSMakePoint(x, suggestedPositions[glyphIndex].y);
if (indices[glyphIndex] != characterIndex) {
// The glyph we just added is for a new character in string_.
// Some characters, such as THAI CHARACTER SARA AM, are composed of
// multiple glyphs.
if (advances_[characterIndex] > 0) {
// The glyph we just added was the first in a new cell.
basePosition += advances_[characterIndex];
indexOfFirstGlyphInCurrentCell = glyphIndex;
width += advances_[characterIndex];
}
characterIndex = indices[glyphIndex];
++numChars;
}
i++;
}
*runWidthPtr = width;
return numChars;
}
- (NSString *)description {
return [string_ description];
}
 
- (CTLineRef)newLine {
Loading
Loading
@@ -131,6 +156,9 @@ static const int kDefaultAdvancesCapacity = 100;
 
- (void)appendCodesFromString:(NSString *)string withAdvance:(CGFloat)advance {
[self commit];
for (int i = 1; i < [string length]; i++) {
[self appendToAdvances:0];
}
[self appendToAdvances:advance];
[string_ appendAttributedString:[self attributedStringForString:string]];
}
Loading
Loading
Loading
Loading
@@ -1154,7 +1154,9 @@ static NSString* FormatRect(NSRect r) {
0,
theSize.width,
theSize.height)];
[[theSession view] setAutoresizesSubviews:NO];
if ([self isTmuxTab]) {
[[theSession view] setAutoresizesSubviews:NO];
}
[[theSession view] updateTitleFrame];
}
}
Loading
Loading
@@ -2124,7 +2126,7 @@ static NSString* FormatRect(NSRect r) {
[self updateFlexibleViewColors];
[flexibleView_ setFrameSize:[[realParentWindow_ tabView] frame].size];
for (PTYSession *aSession in [self sessions]) {
[[aSession view] setAutoresizesSubviews:NO];
[[aSession view] setAutoresizesSubviews:NO]; // This is ok because it is a tmux tab
[[aSession view] updateTitleFrame];
}
}
Loading
Loading
@@ -2498,7 +2500,7 @@ static NSString* FormatRect(NSRect r) {
theTab->parseTree_ = [parseTree retain];
// The only way a tmux view should resize is because the server told it to.
for (PTYSession *aSession in [theTab sessions]) {
[[aSession view] setAutoresizesSubviews:NO];
[[aSession view] setAutoresizesSubviews:NO]; // This is ok because it's a tmux tab
}
[theTab addToTerminal:term
withArrangement:arrangement];
Loading
Loading
@@ -2730,6 +2732,7 @@ static NSString* FormatRect(NSRect r) {
return [self _recursiveParseTree:parseTree matchesViewHierarchy:view];
}
 
// NOTE: This is only called on tmux tabs.
- (void)_recursiveResizeViewsInViewHierarchy:(NSView *)view
forArrangement:(NSDictionary *)arrangement
{
Loading
Loading
Loading
Loading
@@ -6138,10 +6138,10 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
int lastBold = 2; // Bold is a one-bit field so it can never equal 2.
NSColor *lastColor = nil;
 
CharacterRun *prevChar = [[[CharacterRun alloc] init] autorelease];
CharacterRun *prevChar = [[CharacterRun alloc] init];
BOOL havePrevChar = NO;
CGFloat curX = initialPoint.x;
CharacterRun *thisChar = [[[CharacterRun alloc] init] autorelease];
CharacterRun *thisChar = [[CharacterRun alloc] init];
thisChar.advancedFontRendering = advancedFontRendering;
for (int i = indexRange.location; i < indexRange.location + indexRange.length; i++) {
if (theLine[i].code == DWC_RIGHT) {
Loading
Loading
@@ -6315,6 +6315,8 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
if (currentRun) {
[runs addObject:currentRun];
}
[prevChar release];
[thisChar release];
}
 
- (void)drawRun:(CharacterRun *)currentRun
Loading
Loading
@@ -6323,6 +6325,7 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
CTLineRef line = [currentRun newLine];
NSArray *runs = (NSArray *)CTLineGetGlyphRuns(line);
int x = currentRun.x;
int characterIndex = 0;
 
CGContextSetShouldAntialias(ctx, currentRun.antiAlias);
CTRunRef run;
Loading
Loading
@@ -6330,11 +6333,14 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
run = (CTRunRef) [runs objectAtIndex:i];
 
CFIndex glyphCount = CTRunGetGlyphCount(run);
const NSSize *suggestedAdvances = CTRunGetAdvancesPtr(run);
const CGGlyph *glyphs = CTRunGetGlyphsPtr(run);
NSSize advances[glyphCount];
[currentRun updateAdvances:advances forSuggestedAdvances:suggestedAdvances count:glyphCount];
NSPoint positions[glyphCount];
CGFloat runWidth;
characterIndex += [currentRun getPositions:positions
forRun:run
startingAtIndex:characterIndex
glyphCount:glyphCount
runWidthPtr:&runWidth];
 
CTFontRef runFont =
CFDictionaryGetValue(CTRunGetAttributes(run), kCTFontAttributeName);
Loading
Loading
@@ -6355,7 +6361,7 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
0.0, -1.0,
x, y));
 
CGContextShowGlyphsWithAdvances(ctx, glyphs, advances, glyphCount);
CGContextShowGlyphsAtPositions(ctx, glyphs, positions, glyphCount);
 
if (currentRun.fakeBold) {
// If anti-aliased, drawing twice at the same position makes the strokes thicker.
Loading
Loading
@@ -6365,11 +6371,9 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
x + (currentRun.antiAlias ? 0 : 1),
y));
 
CGContextShowGlyphsWithAdvances(ctx, glyphs, advances, glyphCount);
}
for (int j = 0; j < glyphCount; j++) {
x += advances[j].width;
CGContextShowGlyphsAtPositions(ctx, glyphs, positions, glyphCount);
}
x += runWidth;
}
CFRelease(line);
}
Loading
Loading
Loading
Loading
@@ -929,6 +929,7 @@ NSString *sessionsKey = @"sessions";
forKey:@"ShowFullScreenTabBar"];
}
[self repositionWidgets];
[self fitTabsToWindow];
}
 
- (IBAction)closeCurrentTab:(id)sender
Loading
Loading
@@ -5045,7 +5046,7 @@ NSString *sessionsKey = @"sessions";
- (void)fitTabToWindow:(PTYTab*)aTab
{
NSSize size = [TABVIEW contentRect].size;
PtyLog(@"fitTabToWindow calling setSize for content size of %@", [NSValue valueWithSize:size]);
PtyLog(@"fitTabToWindow calling setSize for content size of %@", [NSValue valueWithSize:size]);
[aTab setSize:size];
}
 
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