Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
#2485: Make external links in help viewer more readable in dark mode.
  • Loading branch information
stuconnolly committed Oct 3, 2018
1 parent 87ea3c0 commit 562eb1d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 18 deletions.
4 changes: 4 additions & 0 deletions Resources/Templates/SPMySQLHelpTemplate.html
Expand Up @@ -49,6 +49,10 @@
.dark .internallink {
color: rgb(65, 156, 255);
}

.dark a {
color: rgb(65, 156, 255);
}
</style>
<script type="text/javascript">
window.onThemeChange = function(theme) {
Expand Down
54 changes: 36 additions & 18 deletions Source/SPHelpViewerClient.m
Expand Up @@ -79,21 +79,11 @@ - (instancetype)init
NSBeep();
}
}

return self;
}

- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
[controller setDataSource:nil]; // we are the (unretained) datasource, but the controller may outlive us (if retained by other objects)
[controller close]; // hide the window if it is still visible (can't update anymore without delegate anyway)

mySQLConnection = nil;
SPClear(controller);
SPClear(helpHTMLTemplate);
SPClear(engine);
[super dealloc];
}
#pragma mark -

- (void)helpViewerClosed:(NSNotification *)notification
{
Expand All @@ -104,10 +94,14 @@ - (void)helpViewerClosed:(NSNotification *)notification
- (void)openOnlineHelpForTopic:(NSString *)searchString
{
NSString *version = nil;
if(![mySQLConnection serverVersionIsGreaterThanOrEqualTo:4 minorVersion:1 releaseVersion:0])

if (![mySQLConnection serverVersionIsGreaterThanOrEqualTo:4 minorVersion:1 releaseVersion:0])
{
version = @"4.1";
else
}
else {
version = [NSString stringWithFormat:@"%u.%u",(unsigned int)[mySQLConnection serverMajorVersion], (unsigned int)[mySQLConnection serverMinorVersion]];
}

NSString *url = [[NSString stringWithFormat:
SPMySQLSearchURL,
Expand All @@ -116,7 +110,9 @@ - (void)openOnlineHelpForTopic:(NSString *)searchString
searchString]
stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];

if([url length]) [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:url]];
if ([url length]) {
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:url]];
}
}

- (NSString *)HTMLHelpContentsForSearchString:(NSString *)searchString autoHelp:(BOOL)autoHelp
Expand Down Expand Up @@ -218,10 +214,14 @@ - (NSString *)HTMLHelpContentsForSearchString:(NSString *)searchString autoHelp:
// iterate through all found rows and print them as HTML ul/li list
[theHelp appendString:@"<ul>"];
[theResult setDefaultRowReturnType:SPMySQLResultRowAsArray];
for (NSArray *eachRow in theResult) {
NSString *topic = [eachRow objectAtIndex:[eachRow count]-2];
[theHelp appendFormat:@"<li>%@</li>",[[self class] linkToHelpTopic:topic]];

for (NSArray *eachRow in theResult)
{
NSString *topic = [eachRow objectAtIndex:[eachRow count] - 2];

[theHelp appendFormat:@"<li>%@</li>", [[self class] linkToHelpTopic:topic]];
}

[theHelp appendString:@"</ul>"];
}

Expand Down Expand Up @@ -280,4 +280,22 @@ - (IBAction)showHelpForCurrentWord:(id)sender
[controller showHelpFor:searchString addToHistory:YES calledByAutoHelp:NO];
}

#pragma mark -

- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];

[controller setDataSource:nil]; // we are the (unretained) datasource, but the controller may outlive us (if retained by other objects)
[controller close]; // hide the window if it is still visible (can't update anymore without delegate anyway)

mySQLConnection = nil;

SPClear(controller);
SPClear(helpHTMLTemplate);
SPClear(engine);

[super dealloc];
}

@end

0 comments on commit 562eb1d

Please sign in to comment.