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

Initial stab. needs a better icon.

parent a7c0f1d6
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -253,7 +253,7 @@ typedef enum {
// The last time at which a partial-line trigger check occurred. This keeps us from wasting CPU
// checking long lines over and over.
NSTimeInterval _lastPartialLineTriggerCheck;
// Maps announcement identifiers to view controllers.
NSMutableDictionary *_announcements;
 
Loading
Loading
@@ -5490,6 +5490,55 @@ static long long timeInTenthsOfSeconds(struct timeval t)
}
}
 
- (void)screenSetBackgroundImageFile:(NSString *)filename {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
static NSString *kIdentifier = @"SetBackgroundImageFile";
static NSString *kAllowedFilesKey = @"AlwaysAllowBackgroundImage";
static NSString *kDeniedFilesKey = @"AlwaysDenyBackgroundImage";
NSArray *allowedFiles = [userDefaults objectForKey:kAllowedFilesKey];
NSArray *deniedFiles = [userDefaults objectForKey:kAllowedFilesKey];
if ([deniedFiles containsObject:filename]) {
return;
}
if ([allowedFiles containsObject:filename]) {
[self setBackgroundImagePath:filename];
return;
}
NSString *title = [NSString stringWithFormat:@"Set background image to “%@”?", filename];
iTermAnnouncementViewController *announcement =
[iTermAnnouncementViewController announcemenWithTitle:title
style:kiTermAnnouncementViewStyleQuestion
withActions:@[ @"Yes", @"Always", @"Never" ]
completion:^(int selection) {
switch (selection) {
case -2: // Dismiss programmatically
break;
case -1: // No
break;
case 0: // Yes
[self setBackgroundImagePath:filename];
break;
case 1: // Always
[userDefaults setObject:[[userDefaults objectForKey:kAllowedFilesKey] arrayByAddingObject:filename]
forKey:kAllowedFilesKey];
[self setBackgroundImagePath:filename];
break;
case 2: // Never
[userDefaults setObject:[[userDefaults objectForKey:kDeniedFilesKey] arrayByAddingObject:filename]
forKey:kDeniedFilesKey];
break;
}
}];
[self queueAnnouncement:announcement identifier:kIdentifier];
}
- (iTermColorMap *)screenColorMap {
return _colorMap;
}
Loading
Loading
@@ -5713,7 +5762,7 @@ static long long timeInTenthsOfSeconds(struct timeval t)
case kiTermWarningSelection0:
[_textview installShellIntegration:nil];
break;
default:
break;
}
Loading
Loading
@@ -5743,7 +5792,7 @@ static long long timeInTenthsOfSeconds(struct timeval t)
case 0: // Yes
[self tryToRunShellIntegrationInstaller];
break;
case 1: // Never for this account
[userDefaults setBool:YES forKey:theKey];
break;
Loading
Loading
@@ -5764,7 +5813,7 @@ static long long timeInTenthsOfSeconds(struct timeval t)
[self dismissAnnouncementWithIdentifier:identifier];
 
_announcements[identifier] = announcement;
void (^originalCompletion)(int) = [announcement.completion copy];
NSString *identifierCopy = [identifier copy];
announcement.completion = ^(int selection) {
Loading
Loading
Loading
Loading
@@ -3082,6 +3082,10 @@ static NSString *const kInlineFileBase64String = @"base64 string"; // NSMutable
[delegate_ screenRequestAttention:request isCritical:YES];
}
 
- (void)terminalSetBackgroundImageFile:(NSString *)filename {
[delegate_ screenSetBackgroundImageFile:filename];
}
- (void)terminalSetForegroundColor:(NSColor *)color {
[[delegate_ screenColorMap] setColor:color forKey:kColorMapForeground];
}
Loading
Loading
Loading
Loading
@@ -218,4 +218,6 @@
 
- (void)screenSuggestShellIntegrationUpgrade;
 
- (void)screenSetBackgroundImageFile:(NSString *)filename;
@end
Loading
Loading
@@ -28,16 +28,16 @@
@implementation VT100Terminal {
// True if between BeginFile and EndFile codes.
BOOL receivingFile_;
// In FinalTerm command mode (user is at the prompt typing a command).
BOOL inCommand_;
 
id<VT100TerminalDelegate> delegate_;
BOOL ansiMode_; // YES=ANSI, NO=VT52
BOOL xon_; // YES=XON, NO=XOFF. Not currently used.
BOOL numLock_; // YES=ON, NO=OFF, default=YES;
int fgColorCode_;
int fgGreen_;
int fgBlue_;
Loading
Loading
@@ -47,7 +47,7 @@
int bgBlue_;
ColorMode bgColorMode_;
BOOL bold_, italic_, under_, blink_, reversed_;
BOOL saveBold_, saveItalic_, saveUnder_, saveBlink_, saveReversed_;
int saveCharset_;
int saveForeground_;
Loading
Loading
@@ -60,7 +60,7 @@
ColorMode saveBgColorMode_;
BOOL saveOriginMode_;
BOOL saveWraparoundMode_;
int sendModifiers_[NUM_MODIFIABLE_RESOURCES];
}
 
Loading
Loading
@@ -137,7 +137,7 @@ static const int kMaxScreenRows = 4096;
_encoding = NSASCIIStringEncoding;
_parser = [[VT100Parser alloc] init];
_parser.encoding = _encoding;
_wraparoundMode = YES;
_autorepeatMode = YES;
xon_ = YES;
Loading
Loading
@@ -695,19 +695,19 @@ static const int kMaxScreenRows = 4096;
3: CMY 3 YES
4: CMYK 4 YES
5: Indexed color 1 NO
Optional paramters go at position 7 and 8, and indicate toleranace as an
integer; and color space (0=CIELUV, 1=CIELAB). Example:
CSI 38:2:255:128:64:0:5:1 m
Also accepted for xterm compatibility, but never with optional parameters:
CSI 38;2;255;128;64 m
Set the foreground color to red=255, green=128, blue=64 with a tolerance of
5 in the CIELAB color space. The 0 at the 6th position has no meaning and
is just a filler. */
if (token.csi->subCount[i] > 0) {
// Preferred syntax using colons to delimit subparameters
if (token.csi->subCount[i] >= 2 && token.csi->sub[i][0] == 5) {
Loading
Loading
@@ -970,7 +970,7 @@ static const int kMaxScreenRows = 4096;
[delegate_ terminalHandleTmuxInput:token];
return;
}
// Handle sending input to pasteboard/receving files.
if (receivingFile_) {
if (token->type == VT100CC_BEL) {
Loading
Loading
@@ -1005,7 +1005,7 @@ static const int kMaxScreenRows = 4096;
![token.string hasPrefix:@"CopyToClipboard"]) {
// Append text to clipboard except for initial command that turns on copying to
// the clipboard.
[delegate_ terminalAppendDataToPasteboard:token.savedData];
}
}
Loading
Loading
@@ -1022,7 +1022,7 @@ static const int kMaxScreenRows = 4096;
SET_PARAM_DEFAULT(token.csi, 0, 0);
}
break;
default:
break;
}
Loading
Loading
@@ -1030,7 +1030,7 @@ static const int kMaxScreenRows = 4096;
// Update internal state.
[self executeModeUpdates:token];
[self executeSGR:token];
// Farm out work to the delegate.
switch (token->type) {
// our special code
Loading
Loading
@@ -1505,7 +1505,7 @@ static const int kMaxScreenRows = 4096;
case ITERM_GROWL:
[delegate_ terminalPostGrowlNotification:token.string];
break;
case XTERMCC_SET_KVP:
[self executeXtermSetKvp:token];
break;
Loading
Loading
@@ -1719,7 +1719,7 @@ static const int kMaxScreenRows = 4096;
dict[part] = @"";
}
}
NSString *widthString = dict[@"width"];
VT100TerminalUnits widthUnits = kVT100TerminalUnitsCells;
NSString *heightString = dict[@"height"];
Loading
Loading
@@ -1816,6 +1816,8 @@ static const int kMaxScreenRows = 4096;
[delegate_ terminalCopyBufferToPasteboard];
} else if ([key isEqualToString:@"RequestAttention"]) {
[delegate_ terminalRequestAttention:[value boolValue]]; // true: request, false: cancel
} else if ([key isEqualToString:@"BackgroundImageFile"]) {
[delegate_ terminalSetBackgroundImageFile:value];
}
}
 
Loading
Loading
@@ -1914,7 +1916,7 @@ static const int kMaxScreenRows = 4096;
if (args.count == 0) {
return;
}
NSString *command = args[0];
if (command.length != 1) {
return;
Loading
Loading
@@ -1924,7 +1926,7 @@ static const int kMaxScreenRows = 4096;
// Sequence marking the start of the command prompt (FTCS_PROMPT_START)
[delegate_ terminalPromptDidStart];
break;
case 'B':
// Sequence marking the start of the command read from the command prompt
// (FTCS_COMMAND_START)
Loading
Loading
@@ -1933,7 +1935,7 @@ static const int kMaxScreenRows = 4096;
inCommand_ = YES;
}
break;
case 'C':
// Sequence marking the end of the command read from the command prompt (FTCS_COMMAND_END)
if (inCommand_) {
Loading
Loading
@@ -1941,7 +1943,7 @@ static const int kMaxScreenRows = 4096;
inCommand_ = NO;
}
break;
case 'D':
// Return code of last command
if (args.count >= 2) {
Loading
Loading
@@ -1962,7 +1964,7 @@ static const int kMaxScreenRows = 4096;
}
}
break;
case 'F':
// Semantic text is ending.
// First argument is same as 'D'.
Loading
Loading
@@ -1973,7 +1975,7 @@ static const int kMaxScreenRows = 4096;
}
}
break;
case 'G':
// Update progress bar.
// First argument: perecentage
Loading
Loading
@@ -1984,7 +1986,7 @@ static const int kMaxScreenRows = 4096;
int percent = [args[1] intValue];
double fraction = MAX(MIN(1, 100.0 / (double)percent), 0);
NSString *label = nil;
if (args.count >= 3) {
label = args[2];
}
Loading
Loading
Loading
Loading
@@ -362,4 +362,6 @@ typedef enum {
 
- (NSString *)terminalProfileName;
 
- (void)terminalSetBackgroundImageFile:(NSString *)filename;
@end
Loading
Loading
@@ -9,7 +9,8 @@
#import <Cocoa/Cocoa.h>
 
typedef enum {
kiTermAnnouncementViewStyleWarning
kiTermAnnouncementViewStyleWarning,
kiTermAnnouncementViewStyleQuestion
} iTermAnnouncementViewStyle;
 
@interface iTermAnnouncementView : NSView
Loading
Loading
Loading
Loading
@@ -92,7 +92,7 @@ static const CGFloat kMargin = 8;
 
[self setWantsLayer:YES];
[self setShadow:dropShadow];
NSImage *closeImage = [NSImage imageNamed:@"closebutton"];
NSSize closeSize = closeImage.size;
_buttonWidth = ceil(closeSize.width + kMargin);
Loading
Loading
@@ -164,6 +164,9 @@ static const CGFloat kMargin = 8;
case kiTermAnnouncementViewStyleWarning:
iconString = @"⚠"; // Warning sign
break;
case kiTermAnnouncementViewStyleQuestion:
iconString = @"?\u20e4";
break;
}
 
NSFont *emojiFont = [NSFont fontWithName:@"Apple Color Emoji" size:18];
Loading
Loading
@@ -176,7 +179,7 @@ static const CGFloat kMargin = 8;
[iconImage lockFocus];
[iconString drawAtPoint:NSMakePoint(0, 0) withAttributes:attributes];
[iconImage unlockFocus];
return iconImage;
}
 
Loading
Loading
@@ -201,7 +204,7 @@ static const CGFloat kMargin = 8;
[textView setEditable:NO];
textView.autoresizingMask = NSViewWidthSizable | NSViewMaxXMargin;
textView.drawsBackground = NO;
NSFont *font = [NSFont systemFontOfSize:12];
[textView setFont:font];
[textView setSelectable:NO];
Loading
Loading
@@ -235,7 +238,7 @@ static const CGFloat kMargin = 8;
floor((_internalView.frame.size.height - closeSize.height) / 2),
closeSize.width,
closeSize.height);
for (NSButton *button in _actionButtons) {
NSRect buttonFrame = button.frame;
button.frame = NSMakeRect(buttonFrame.origin.x,
Loading
Loading
@@ -243,7 +246,7 @@ static const CGFloat kMargin = 8;
buttonFrame.size.width,
buttonFrame.size.height);
}
CGRect iconFrame = _icon.frame;
CGFloat y = floor((_internalView.frame.size.height - iconFrame.size.height) / 2);
_icon.frame = NSMakeRect(kMargin,
Loading
Loading
Loading
Loading
@@ -11,10 +11,10 @@
 
@interface iTermAnnouncementViewController ()
@property(nonatomic, copy) NSArray *actions;
@property(nonatomic, assign) iTermAnnouncementViewStyle style;
@end
 
@implementation iTermAnnouncementViewController {
iTermAnnouncementViewStyle _style;
BOOL _dismissing;
}
 
Loading
Loading
@@ -26,6 +26,7 @@
announcement.title = title;
announcement.actions = actions;
announcement.completion = completion;
announcement.style = style;
return announcement;
}
 
Loading
Loading
@@ -43,7 +44,7 @@
if (!_dismissing) {
self.completion(index);
[self dismiss];
}
}
}];
}
 
Loading
Loading
]1337;BackgroundImageFile=/Users/georgen/Default.png
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