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

Make badges wrap. Fix up escape codes for setting badges....

Make badges wrap. Fix up escape codes for setting badges. SetBadgeFormat=base64format and SetUserVar=key=base64value
parent 857c6526
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -5601,14 +5601,20 @@ static long long timeInTenthsOfSeconds(struct timeval t)
}
 
- (void)screenSetBadgeFormat:(NSString *)theFormat {
theFormat = [theFormat stringByBase64DecodingStringWithEncoding:NSUTF8StringEncoding];
[self setSessionSpecificProfileValues:@{ KEY_BADGE_FORMAT: theFormat }];
_textview.badgeLabel = [self badgeLabel];
}
 
- (void)screenSetBadgeVar:(NSString *)kvpString {
- (void)screenSetUserVar:(NSString *)kvpString {
NSArray *kvp = [kvpString keyValuePair];
if (kvp) {
_badgeVars[kvp[0]] = kvp[1];
NSString *key = [NSString stringWithFormat:@"user.%@", kvp[0]];
if (![kvp[1] length]) {
[_badgeVars removeObjectForKey:key];
} else {
_badgeVars[key] = [kvp[1] stringByBase64DecodingStringWithEncoding:NSUTF8StringEncoding];
}
}
[_textview setBadgeLabel:[self badgeLabel]];
}
Loading
Loading
Loading
Loading
@@ -5224,13 +5224,17 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
saturation = MAX(0, saturation);
NSColor *fillColor = [NSColor colorWithCalibratedHue:hue saturation:saturation brightness:brightness alpha:1];
NSFontManager *fontManager = [NSFontManager sharedFontManager];
NSMutableParagraphStyle *paragraphStyle = [[[NSMutableParagraphStyle alloc] init] autorelease];
paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping;
paragraphStyle.alignment = NSRightTextAlignment;
while (points != prevPoints) {
font = [fontManager convertFont:[NSFont fontWithName:@"Helvetica" size:points]
toHaveTrait:NSBoldFontMask];
attributes = @{ NSFontAttributeName: font,
NSForegroundColorAttributeName: fillColor };
sizeWithFont = [badgeLabel sizeWithAttributes:attributes];
NSForegroundColorAttributeName: fillColor,
NSParagraphStyleAttributeName: paragraphStyle };
NSRect bounds = [badgeLabel boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:attributes];
sizeWithFont = bounds.size;
if (sizeWithFont.width > maxSize.width || sizeWithFont.height > maxSize.height) {
max = points;
} else if (sizeWithFont.width < maxSize.width && sizeWithFont.height < maxSize.height) {
Loading
Loading
@@ -5245,7 +5249,9 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
NSMutableDictionary *temp = [[attributes mutableCopy] autorelease];
temp[NSStrokeWidthAttributeName] = @-2;
temp[NSStrokeColorAttributeName] = backgroundColor;
[badgeLabel drawAtPoint:NSZeroPoint withAttributes:temp];
[badgeLabel drawWithRect:NSMakeRect(0, 0, sizeWithFont.width, sizeWithFont.height)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:temp];
[image unlockFocus];
 
self.badgeImage = image;
Loading
Loading
Loading
Loading
@@ -3094,8 +3094,8 @@ static NSString *const kInlineFileBase64String = @"base64 string"; // NSMutable
[delegate_ screenSetBadgeFormat:badge];
}
 
- (void)terminalSetBadgeVar:(NSString *)kvp {
[delegate_ screenSetBadgeVar:kvp];
- (void)terminalSetUserVar:(NSString *)kvp {
[delegate_ screenSetUserVar:kvp];
}
 
- (void)terminalSetForegroundColor:(NSColor *)color {
Loading
Loading
Loading
Loading
@@ -221,6 +221,6 @@
 
- (void)screenSetBackgroundImageFile:(NSString *)filename;
- (void)screenSetBadgeFormat:(NSString *)theFormat;
- (void)screenSetBadgeVar:(NSString *)kvp;
- (void)screenSetUserVar:(NSString *)kvp;
 
@end
Loading
Loading
@@ -1820,8 +1820,8 @@ static const int kMaxScreenRows = 4096;
[delegate_ terminalSetBackgroundImageFile:value];
} else if ([key isEqualToString:@"SetBadgeFormat"]) {
[delegate_ terminalSetBadgeFormat:value];
} else if ([key isEqualToString:@"SetBadgeVar"]) {
[delegate_ terminalSetBadgeVar:value];
} else if ([key isEqualToString:@"SetUserVar"]) {
[delegate_ terminalSetUserVar:value];
}
}
 
Loading
Loading
Loading
Loading
@@ -364,6 +364,6 @@ typedef enum {
 
- (void)terminalSetBackgroundImageFile:(NSString *)filename;
- (void)terminalSetBadgeFormat:(NSString *)badge;
- (void)terminalSetBadgeVar:(NSString *)kvp;
- (void)terminalSetUserVar:(NSString *)kvp;
 
@end
#!/bin/bash
printf '\e]1337;SetBadgeFormat=%s\a' `echo -n "$1" | base64`
#!/bin/bash
printf '\e]1337;SetUserVar=%s=%s\a' "$1" `echo -n "$2" | base64`
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