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

Allow push and pop of key labels to take a name so multiple sets can be popped...

Allow push and pop of key labels to take a name so multiple sets can be popped at once if a program (e.g. ssh) exits unexpectedly
parent ca6be91b
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -1404,6 +1404,8 @@
A66DB83B1C9142C900233E88 /* iTermAltScreenMouseScrollInferer.m in Sources */ = {isa = PBXBuildFile; fileRef = A66DB8391C9142C900233E88 /* iTermAltScreenMouseScrollInferer.m */; };
A66DB8421CA24E8800233E88 /* iTermAutoMasterParser.h in Headers */ = {isa = PBXBuildFile; fileRef = A66DB8401CA24E8800233E88 /* iTermAutoMasterParser.h */; };
A66DB8431CA24E8900233E88 /* iTermAutoMasterParser.m in Sources */ = {isa = PBXBuildFile; fileRef = A66DB8411CA24E8800233E88 /* iTermAutoMasterParser.m */; };
A673BFDE1E16C54500FA2386 /* iTermKeyLabels.h in Headers */ = {isa = PBXBuildFile; fileRef = A673BFDC1E16C54500FA2386 /* iTermKeyLabels.h */; };
A673BFDF1E16C54500FA2386 /* iTermKeyLabels.m in Sources */ = {isa = PBXBuildFile; fileRef = A673BFDD1E16C54500FA2386 /* iTermKeyLabels.m */; };
A6755F431D728FFA00F3726C /* iTermImage.h in Headers */ = {isa = PBXBuildFile; fileRef = A6755F411D728FFA00F3726C /* iTermImage.h */; };
A6755F441D728FFA00F3726C /* iTermImage.m in Sources */ = {isa = PBXBuildFile; fileRef = A6755F421D728FFA00F3726C /* iTermImage.m */; };
A6755F4C1D729A0500F3726C /* image_decoder.m in Sources */ = {isa = PBXBuildFile; fileRef = A6755F4B1D729A0500F3726C /* image_decoder.m */; };
Loading
Loading
@@ -3142,6 +3144,8 @@
A66DB8391C9142C900233E88 /* iTermAltScreenMouseScrollInferer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = iTermAltScreenMouseScrollInferer.m; sourceTree = "<group>"; };
A66DB8401CA24E8800233E88 /* iTermAutoMasterParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iTermAutoMasterParser.h; sourceTree = "<group>"; };
A66DB8411CA24E8800233E88 /* iTermAutoMasterParser.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = iTermAutoMasterParser.m; sourceTree = "<group>"; };
A673BFDC1E16C54500FA2386 /* iTermKeyLabels.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iTermKeyLabels.h; sourceTree = "<group>"; };
A673BFDD1E16C54500FA2386 /* iTermKeyLabels.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = iTermKeyLabels.m; sourceTree = "<group>"; };
A6755F411D728FFA00F3726C /* iTermImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iTermImage.h; sourceTree = "<group>"; };
A6755F421D728FFA00F3726C /* iTermImage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = iTermImage.m; sourceTree = "<group>"; };
A6755F491D729A0500F3726C /* image_decoder */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = image_decoder; sourceTree = BUILT_PRODUCTS_DIR; };
Loading
Loading
@@ -5325,6 +5329,8 @@
A6ECA5991D76907400D19511 /* iTermImageDecoderDriver.m */,
A6374A261DEE941F000A136F /* iTermPromptOnCloseReason.h */,
A6374A271DEE941F000A136F /* iTermPromptOnCloseReason.m */,
A673BFDC1E16C54500FA2386 /* iTermKeyLabels.h */,
A673BFDD1E16C54500FA2386 /* iTermKeyLabels.m */,
);
name = Helpers;
sourceTree = "<group>";
Loading
Loading
@@ -6363,6 +6369,7 @@
A6EFF21C1D1CA9F800806EEF /* NSLocale+iTerm.h in Headers */,
A62C3A8D1BCAE08300B5629D /* iTermDirectoryTree.h in Headers */,
A66DB8361C8E4CBB00233E88 /* iTermOpenQuicklyCommands.h in Headers */,
A673BFDE1E16C54500FA2386 /* iTermKeyLabels.h in Headers */,
A6FC49861C3A31840061B3BA /* iTermSystemVersion.h in Headers */,
A6C760491B45C4CF00E3C992 /* iTermTip.h in Headers */,
A6936B4D1D2E0ABF00521B04 /* iTermScriptingWindow.h in Headers */,
Loading
Loading
@@ -7829,6 +7836,7 @@
A6C763971B45C52B00E3C992 /* TmuxController.m in Sources */,
A6C7633F1B45C52B00E3C992 /* iTermAnnouncementView.m in Sources */,
A6C763791B45C52B00E3C992 /* PreferencePanel.m in Sources */,
A673BFDF1E16C54500FA2386 /* iTermKeyLabels.m in Sources */,
A6C763031B45C52B00E3C992 /* VT100WorkingDirectory.m in Sources */,
A62C3B281BCC24AB00B5629D /* iTermHostRecordMO+CoreDataProperties.m in Sources */,
A6C763461B45C52B00E3C992 /* iTermProgressIndicator.m in Sources */,
Loading
Loading
@@ -20,6 +20,7 @@
#import "iTermHotKeyController.h"
#import "iTermInitialDirectory.h"
#import "iTermKeyBindingMgr.h"
#import "iTermKeyLabels.h"
#import "iTermMouseCursor.h"
#import "iTermPasteHelper.h"
#import "iTermPreferences.h"
Loading
Loading
@@ -409,7 +410,7 @@ static const NSUInteger kMaxHosts = 100;
 
// Touch bar labels for function keys.
NSMutableDictionary<NSString *, NSString *> *_keyLabels;
NSMutableArray<NSMutableDictionary<NSString *, NSString *> *> *_keyLabelsStack;
NSMutableArray<iTermKeyLabels *> *_keyLabelsStack;
}
 
+ (void)registerSessionInArrangement:(NSDictionary *)arrangement {
Loading
Loading
@@ -7601,20 +7602,34 @@ ITERM_WEAKLY_REFERENCEABLE
[_delegate sessionKeyLabelsDidChange:self];
}
 
- (void)screenPushKeyLabels {
- (void)screenPushKeyLabels:(NSString *)value {
if (!_keyLabels) {
return;
}
if (!_keyLabelsStack) {
_keyLabelsStack = [[NSMutableArray alloc] init];
}
[_keyLabelsStack addObject:[_keyLabels copy]];
iTermKeyLabels *labels = [[[iTermKeyLabels alloc] init] autorelease];
labels.name = value;
labels.map = _keyLabels;
[_keyLabelsStack addObject:labels];
}
 
- (void)screenPopKeyLabels {
[_keyLabels release];
_keyLabels = _keyLabelsStack.lastObject;
- (iTermKeyLabels *)popKeyLabels {
iTermKeyLabels *labels = [[_keyLabelsStack.lastObject retain] autorelease];
[_keyLabelsStack removeLastObject];
return labels;
}
- (void)screenPopKeyLabels:(NSString *)value {
[_keyLabels release];
_keyLabels = nil;
iTermKeyLabels *labels = [self popKeyLabels];
while (labels && value.length > 0 && ![labels.name isEqualToString:value]) {
labels = [self popKeyLabels];
}
labels = _keyLabelsStack.lastObject;
_keyLabels = [labels.map retain];
[_delegate sessionKeyLabelsDidChange:self];
}
 
Loading
Loading
Loading
Loading
@@ -151,7 +151,6 @@ static void SetAgainstGrainDim(BOOL isVertical, NSSize *dest, CGFloat value) {
 
// If there is a flexible root view, this is set and is the tabview's view.
// Otherwise it is nil.
#warning TODO: I believe this prevents tmux windows from being transparent.
SolidColorView *flexibleView_;
 
// The root of a tree of split views whose leaves are SessionViews. The root is the view of the
Loading
Loading
Loading
Loading
@@ -3863,12 +3863,12 @@ static NSString *const kInilineFileInset = @"inset"; // NSValue of NSEdgeInsets
[delegate_ screenSetLabel:label forKey:keyName];
}
 
- (void)terminalPushKeyLabels {
[delegate_ screenPushKeyLabels];
- (void)terminalPushKeyLabels:(NSString *)value {
[delegate_ screenPushKeyLabels:value];
}
 
- (void)terminalPopKeyLabels {
[delegate_ screenPopKeyLabels];
- (void)terminalPopKeyLabels:(NSString *)value {
[delegate_ screenPopKeyLabels:value];
}
 
// fg=ff0080,bg=srgb:808080
Loading
Loading
Loading
Loading
@@ -240,7 +240,7 @@
- (NSInteger)screenUnicodeVersion;
- (void)screenSetUnicodeVersion:(NSInteger)unicodeVersion;
- (void)screenSetLabel:(NSString *)label forKey:(NSString *)keyName;
- (void)screenPushKeyLabels;
- (void)screenPopKeyLabels;
- (void)screenPushKeyLabels:(NSString *)value;
- (void)screenPopKeyLabels:(NSString *)value;
 
@end
Loading
Loading
@@ -2167,9 +2167,9 @@ static const int kMaxScreenRows = 4096;
[delegate_ terminalSetLabel:label forKey:keyName];
}
} else if ([key isEqualToString:@"PushKeyLabels"]) {
[delegate_ terminalPushKeyLabels];
[delegate_ terminalPushKeyLabels:value];
} else if ([key isEqualToString:@"PopKeyLabels"]) {
[delegate_ terminalPopKeyLabels];
[delegate_ terminalPopKeyLabels:value];
}
}
 
Loading
Loading
Loading
Loading
@@ -374,6 +374,6 @@ typedef NS_ENUM(NSInteger, VT100TerminalUnits) {
 
// Touch bar
- (void)terminalSetLabel:(NSString *)label forKey:(NSString *)keyName;
- (void)terminalPushKeyLabels;
- (void)terminalPopKeyLabels;
- (void)terminalPushKeyLabels:(NSString *)value;
- (void)terminalPopKeyLabels:(NSString *)value;
@end
//
// iTermKeyLabels.h
// iTerm2
//
// Created by George Nachman on 12/30/16.
//
//
#import <Foundation/Foundation.h>
@interface iTermKeyLabels : NSObject
@property(nonatomic, copy) NSMutableDictionary<NSString *, NSString *> *map;
@property(nonatomic, copy) NSString *name;
@end
//
// iTermKeyLabels.m
// iTerm2
//
// Created by George Nachman on 12/30/16.
//
//
#import "iTermKeyLabels.h"
@implementation iTermKeyLabels
- (void)dealloc {
[_map release];
[_name release];
[super dealloc];
}
@end
Loading
Loading
@@ -21,11 +21,36 @@ function print_st() {
}
 
function show_help() {
echo "Usage:" 1>& 2
echo " it2setkeylabel.sh set Fn Label" 1>& 2
echo " Where n is a value from 1 to 20" 1>& 2
echo " it2setkeylabel.sh push" 1>& 2
echo " it2setkeylabel.sh pop" 1>& 2
echo 'Usage:' 1>& 2
echo ' it2setkeylabel.sh set Fn Label' 1>& 2
echo ' Where n is a value from 1 to 20' 1>& 2
echo ' it2setkeylabel.sh push [name]' 1>& 2
echo ' it2setkeylabel.sh pop [name]' 1>& 2
echo ' If name is given, all key labels up to one with the matching name are popped.' 1>& 2
echo '' 1>& 2
echo 'Example:' 1>& 2
echo '#!/bin/bash' 1>& 2
echo '# Wrapper script for mc that sets function key labels' 1>& 2
echo 'it2setkeylabel.sh set F1 Help' 1>& 2
echo 'it2setkeylabel.sh set F2 Menu' 1>& 2
echo 'it2setkeylabel.sh set F3 View' 1>& 2
echo 'it2setkeylabel.sh set F4 Edit' 1>& 2
echo 'it2setkeylabel.sh set F5 Copy' 1>& 2
echo 'it2setkeylabel.sh set F6 Move' 1>& 2
echo 'it2setkeylabel.sh set F7 Mkdir' 1>& 2
echo 'it2setkeylabel.sh set F8 Del' 1>& 2
echo 'it2setkeylabel.sh set F9 Menu' 1>& 2
echo 'it2setkeylabel.sh set F10 Quit' 1>& 2
echo 'it2setkeylabel.sh set F11 Menu' 1>& 2
echo 'it2setkeylabel.sh set F13 View' 1>& 2
echo 'it2setkeylabel.sh set F14 Edit' 1>& 2
echo 'it2setkeylabel.sh set F15 Copy' 1>& 2
echo 'it2setkeylabel.sh set F16 Move' 1>& 2
echo 'it2setkeylabel.sh set F17 Find' 1>& 2
echo 'NAME=mc_$RANDOM' 1>& 2
echo 'it2setkeylabel.sh push $NAME' 1>& 2
echo 'mc' 1>& 2
echo 'it2setkeylabel.sh pop $NAME' 1>& 2
}
 
## Main
Loading
Loading
@@ -47,24 +72,46 @@ then
print_st
elif [[ $1 == push ]]
then
if [[ $# != 1 ]]
if [[ $# == 1 ]]
then
print_osc
printf "1337;PushKeyLabels"
print_st
elif [[ $# == 2 ]]
then
if [[ $2 == "" ]]
then
echo "Name must not be empty" 1>& 2
exit 1
fi
print_osc
printf "1337;PushKeyLabels=%s" "$2"
print_st
else
show_help
exit 1
fi
print_osc
printf "1337;PushKeyLabels"
print_st
elif [[ $1 == pop ]]
then
if [[ $# != 1 ]]
if [[ $# == 1 ]]
then
print_osc
printf "1337;PopKeyLabels"
print_st
elif [[ $# == 2 ]]
then
if [[ $2 == "" ]]
then
echo "Name must not be empty" 1>& 2
exit 1
fi
print_osc
printf "1337;PopKeyLabels=%s" "$2"
print_st
else
show_help
exit 1
fi
print_osc
printf "1337;PopKeyLabels"
print_st
else
show_help
exit 1
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