Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configurable tab label truncation style #220

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion ThirdParty/PSMTabBarControl/source/PSMYosemiteTabStyle.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import "PSMYosemiteTabStyle.h"
#import "PSMTabBarCell.h"
#import "PSMTabBarControl.h"
#import "iTermAdvancedSettingsModel.h"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want iTerm code leaking into PSM code. It really should be in a separate target. This should go up the delegate chain, instead.


#define kPSMMetalObjectCounterRadius 7.0
#define kPSMMetalCounterMinWidth 20
Expand Down Expand Up @@ -296,7 +297,16 @@ - (NSAttributedString *)attributedStringValueForTabCell:(PSMTabBarCell *)cell {
if (!truncatingTailParagraphStyle) {
truncatingTailParagraphStyle =
[[[NSParagraphStyle defaultParagraphStyle] mutableCopy] retain];
[truncatingTailParagraphStyle setLineBreakMode:NSLineBreakByTruncatingTail];
switch ([iTermAdvancedSettingsModel tabLabelTruncationStyle]) {
case kAdvancedSettingsTruncationStyleLeft:
[truncatingTailParagraphStyle setLineBreakMode:NSLineBreakByTruncatingHead];
break;
case kAdvancedSettingsTruncationStyleMiddle:
[truncatingTailParagraphStyle setLineBreakMode:NSLineBreakByTruncatingMiddle];
break;
default:
[truncatingTailParagraphStyle setLineBreakMode:NSLineBreakByTruncatingTail];
}
[truncatingTailParagraphStyle setAlignment:NSCenterTextAlignment];
}
[attrStr addAttribute:NSParagraphStyleAttributeName
Expand Down
7 changes: 7 additions & 0 deletions sources/iTermAdvancedSettingsModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@

#import <Foundation/Foundation.h>

enum {
kAdvancedSettingsTruncationStyleRight = 0,
kAdvancedSettingsTruncationStyleMiddle = 1,
kAdvancedSettingsTruncationStyleLeft = 2
};

@interface iTermAdvancedSettingsModel : NSObject

+ (int)tabLabelTruncationStyle;
+ (BOOL)useUnevenTabs;
+ (int)minTabWidth;
+ (int)minCompactTabWidth;
Expand Down
1 change: 1 addition & 0 deletions sources/iTermAdvancedSettingsModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ + (NSString *)name { \
}

#pragma mark Tabs
DEFINE_INT(tabLabelTruncationStyle, kAdvancedSettingsTruncationStyleRight, @"Tabs: Tab label truncation style.\n0=Right, 1=Middle, 2=Left.");
DEFINE_BOOL(useUnevenTabs, NO, @"Tabs: Uneven tab widths allowed.");
DEFINE_INT(minTabWidth, 75, @"Tabs: Minimum tab width when using uneven tab widths.");
DEFINE_INT(minCompactTabWidth, 60, @"Tabs: Minimum tab width when using uneven tab widths for compact tabs.");
Expand Down