Skip to content

Commit f25c62d

Browse files
committed
Add a hidden preference to control the size of the UI's monospaced font.
1 parent afadd02 commit f25c62d

17 files changed

+83
-50
lines changed

Source/SPConstants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ extern NSString *SPAlwaysShowWindowTabBar;
371371
extern NSString *SPResetAutoIncrementAfterDeletionOfAllRows;
372372
extern NSString *SPFavoriteColorList;
373373
extern NSString *SPDisplayBinaryDataAsHex;
374+
extern NSString *SPMonospacedFontSize;
374375

375376
// Hidden Prefs
376377
extern NSString *SPPrintWarningRowLimit;

Source/SPConstants.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@
177177
NSString *SPResetAutoIncrementAfterDeletionOfAllRows = @"ResetAutoIncrementAfterDeletionOfAllRows";
178178
NSString *SPFavoriteColorList = @"FavoriteColorList";
179179
NSString *SPDisplayBinaryDataAsHex = @"DisplayBinaryDataAsHex";
180+
NSString *SPMonospacedFontSize = @"MonospacedFontSize";
180181

181182
// Hidden Prefs
182183
NSString *SPPrintWarningRowLimit = @"PrintWarningRowLimit";

Source/SPDataImport.m

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,12 +1634,10 @@ - (void)setConnection:(SPMySQLConnection *)theConnection
16341634
[switchButton setButtonType:NSSwitchButton];
16351635
[switchButton setControlSize:NSSmallControlSize];
16361636
[switchButton release];
1637-
1638-
if ([prefs boolForKey:SPUseMonospacedFonts]) {
1639-
[errorsView setFont:[NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]]];
1640-
} else {
1641-
[errorsView setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
1642-
}
1637+
1638+
CGFloat monospacedFontSize = [[NSUserDefaults standardUserDefaults] floatForKey:SPMonospacedFontSize] > 0 ? [prefs floatForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize];
1639+
1640+
[errorsView setFont:[prefs boolForKey:SPUseMonospacedFonts] ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
16431641
}
16441642

16451643
/**

Source/SPFieldEditorController.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ - (void)editWithObject:(id)data
232232
if ([fieldEncoding length])
233233
[label appendString:fieldEncoding];
234234

235+
CGFloat monospacedFontSize = [prefs floatForKey:SPMonospacedFontSize] > 0 ? [prefs floatForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize];
236+
235237
if ([fieldType length] && [[fieldType uppercaseString] isEqualToString:@"BIT"]) {
236238

237239
sheetEditData = [(NSString*)data retain];
@@ -284,7 +286,7 @@ - (void)editWithObject:(id)data
284286
#endif
285287
[editTextView setFont:
286288
#ifndef SP_CODA
287-
([prefs boolForKey:SPUseMonospacedFonts]) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] :
289+
[prefs boolForKey:SPUseMonospacedFonts] ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] :
288290
#endif
289291
[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
290292
#ifndef SP_CODA
@@ -302,7 +304,7 @@ - (void)editWithObject:(id)data
302304
#endif
303305
];
304306

305-
[hexTextView setFont:[NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]]];
307+
[hexTextView setFont:[NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize]];
306308

307309
[editSheetFieldName setStringValue:[NSString stringWithFormat:@"%@: %@", NSLocalizedString(@"Field", @"Field"), label]];
308310

Source/SPFieldMapperController.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1639,7 +1639,9 @@ - (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView;
16391639
- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
16401640
{
16411641
#ifndef SP_CODA
1642-
[aCell setFont:([prefs boolForKey:SPUseMonospacedFonts]) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
1642+
CGFloat monospacedFontSize = [prefs floatForKey:SPMonospacedFontSize] > 0 ? [prefs floatForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize];
1643+
1644+
[aCell setFont:[prefs boolForKey:SPUseMonospacedFonts] ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
16431645
#endif
16441646
}
16451647

Source/SPIndexesController.m

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,19 @@ - (void)awakeFromNib
132132
BOOL useMonospacedFont = NO;
133133
#endif
134134

135+
CGFloat monospacedFontSize = [prefs floatForKey:SPMonospacedFontSize] > 0 ? [prefs floatForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize];
136+
135137
// Set the double-click action in blank areas of the table to create new rows
136138
[indexesTableView setEmptyDoubleClickAction:@selector(addIndex:)];
137139

138140
for (NSTableColumn *indexColumn in [indexesTableView tableColumns])
139141
{
140-
[[indexColumn dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
142+
[[indexColumn dataCell] setFont:useMonospacedFont ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
141143
}
142144

143145
for (NSTableColumn *fieldColumn in [indexedColumnsTableView tableColumns])
144146
{
145-
[[fieldColumn dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
147+
[[fieldColumn dataCell] setFont:useMonospacedFont ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
146148
}
147149

148150
#ifndef SP_CODA /* patch */
@@ -707,18 +709,20 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
707709
else if ([keyPath isEqualToString:SPUseMonospacedFonts]) {
708710

709711
BOOL useMonospacedFont = [[change objectForKey:NSKeyValueChangeNewKey] boolValue];
712+
CGFloat monospacedFontSize = [prefs floatForKey:SPMonospacedFontSize] > 0 ? [prefs floatForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize];
710713

711714
for (NSTableColumn *indexColumn in [indexesTableView tableColumns])
712715
{
713-
[[indexColumn dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
716+
[[indexColumn dataCell] setFont:useMonospacedFont ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
714717
}
715718

716719
for (NSTableColumn *indexColumn in [indexedColumnsTableView tableColumns])
717720
{
718-
[[indexColumn dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
721+
[[indexColumn dataCell] setFont:useMonospacedFont ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
719722
}
720723

721724
[indexesTableView reloadData];
725+
722726
[self _reloadIndexedColumnsTableData];
723727
}
724728
}

Source/SPProcessListController.m

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,11 @@ - (void)awakeFromNib
9797

9898
// Set the strutcture and index view's font
9999
BOOL useMonospacedFont = [prefs boolForKey:SPUseMonospacedFonts];
100-
100+
CGFloat monospacedFontSize = [prefs floatForKey:SPMonospacedFontSize] > 0 ? [prefs floatForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize];
101+
101102
for (NSTableColumn *column in [processListTableView tableColumns])
102103
{
103-
[[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
104+
[[column dataCell] setFont:useMonospacedFont ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
104105

105106
// Add a formatter for linebreak display
106107
[[column dataCell] setFormatter:[[SPDataCellFormatter new] autorelease]];
@@ -460,10 +461,11 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
460461
else if ([keyPath isEqualToString:SPUseMonospacedFonts]) {
461462

462463
BOOL useMonospacedFont = [[change objectForKey:NSKeyValueChangeNewKey] boolValue];
463-
464+
CGFloat monospacedFontSize = [prefs floatForKey:SPMonospacedFontSize] > 0 ? [prefs floatForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize];
465+
464466
for (NSTableColumn *column in [processListTableView tableColumns])
465467
{
466-
[[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
468+
[[column dataCell] setFont:useMonospacedFont ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
467469
}
468470

469471
[processListTableView reloadData];

Source/SPQueryController.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,11 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
353353
else if ([keyPath isEqualToString:SPUseMonospacedFonts]) {
354354

355355
BOOL useMonospacedFont = [[change objectForKey:NSKeyValueChangeNewKey] boolValue];
356+
CGFloat monospacedFontSize = [prefs floatForKey:SPMonospacedFontSize] > 0 ? [prefs floatForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize];
356357

357358
for (NSTableColumn *column in [consoleTableView tableColumns])
358359
{
359-
[[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
360+
[[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
360361
}
361362

362363
[consoleTableView reloadData];

Source/SPQueryControllerInitializer.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,11 @@ - (void)awakeFromNib
7878

7979
// Set the strutcture and index view's font
8080
BOOL useMonospacedFont = [prefs boolForKey:SPUseMonospacedFonts];
81-
81+
CGFloat monospacedFontSize = [prefs floatForKey:SPMonospacedFontSize] > 0 ? [prefs floatForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize];
82+
8283
for (NSTableColumn *column in [consoleTableView tableColumns])
8384
{
84-
[[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
85+
[[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
8586
}
8687
#endif
8788
}

Source/SPServerVariablesController.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
@interface SPServerVariablesController : NSWindowController
3434
{
3535
SPMySQLConnection *connection;
36-
36+
37+
NSUserDefaults *prefs;
3738
NSMutableArray *variables, *variablesFiltered;
3839

3940
IBOutlet NSTableView *variablesTableView;

0 commit comments

Comments
 (0)