diff --git a/TodoTxtMac/TTMAppDelegate.m b/TodoTxtMac/TTMAppDelegate.m index 5805307..3b0ce9c 100644 --- a/TodoTxtMac/TTMAppDelegate.m +++ b/TodoTxtMac/TTMAppDelegate.m @@ -79,10 +79,12 @@ @NO, @"useCustomColorForDueTodayTasks", @NO, @"useCustomColorForProjects", @NO, @"useCustomColorForContexts", + @NO, @"useCustomColorForDueDates", [NSArchiver archivedDataWithRootObject:[NSColor redColor]], @"dueTodayColor", [NSArchiver archivedDataWithRootObject:[NSColor purpleColor]], @"overdueColor", [NSArchiver archivedDataWithRootObject:[NSColor darkGrayColor]], @"projectColor", [NSArchiver archivedDataWithRootObject:[NSColor darkGrayColor]], @"contextColor", + [NSArchiver archivedDataWithRootObject:[NSColor darkGrayColor]], @"dueDateColor", nil]; } return dict; diff --git a/TodoTxtMac/TTMPreferences.xib b/TodoTxtMac/TTMPreferences.xib index eaab916..a498da0 100644 --- a/TodoTxtMac/TTMPreferences.xib +++ b/TodoTxtMac/TTMPreferences.xib @@ -16,14 +16,14 @@ - + - + - + @@ -43,7 +43,7 @@ - + @@ -55,7 +55,7 @@ - + @@ -104,7 +104,7 @@ - + @@ -171,7 +171,7 @@ - + @@ -183,7 +183,7 @@ - + @@ -206,7 +206,7 @@ - + @@ -228,6 +228,29 @@ + + + + + + + + + NSUnarchiveFromData + + + + diff --git a/TodoTxtMac/TTMTableViewDelegate.m b/TodoTxtMac/TTMTableViewDelegate.m index 22fdb41..6edf833 100644 --- a/TodoTxtMac/TTMTableViewDelegate.m +++ b/TodoTxtMac/TTMTableViewDelegate.m @@ -53,6 +53,7 @@ @implementation TTMTableViewDelegate static NSString * const ProjectPattern = @"(?<=^|\\s)(\\+[^\\s]+)"; static NSString * const ContextPattern = @"(?<=^|\\s)(\\@[^\\s]+)"; +static NSString * const FullDueDatePattern = @"(\\sdue:)((\\d{4})-(\\d{2})-(\\d{2}))"; #pragma mark - TableView Delegate Methods @@ -115,6 +116,10 @@ - (NSAttributedString*)displayText:(TTMTask*)task boolForKey:@"useCustomColorForContexts"]) ? [[NSUserDefaults standardUserDefaults] colorForKey:@"contextColor"] : [NSColor darkGrayColor]; + NSColor *dueDateColor = ([[NSUserDefaults standardUserDefaults] + boolForKey:@"useCustomColorForDueDates"]) ? + [[NSUserDefaults standardUserDefaults] colorForKey:@"dueDateColor"] : + [NSColor darkGrayColor]; // Color due texts. if (task.dueState == DueToday) { @@ -145,6 +150,14 @@ - (NSAttributedString*)displayText:(TTMTask*)task value:contextsColor range:match.range]; } + + // Color due dates. + matches = [task.rawText matchesWithDetails:RX(FullDueDatePattern)]; + for (RxMatch *match in matches) { + [as addAttribute:NSForegroundColorAttributeName + value:dueDateColor + range:match.range]; + } } return as; diff --git a/TodoTxtMac/TTMTask.m b/TodoTxtMac/TTMTask.m index b95fdf5..ff7f5cc 100644 --- a/TodoTxtMac/TTMTask.m +++ b/TodoTxtMac/TTMTask.m @@ -239,6 +239,14 @@ - (NSAttributedString*)displayText { value:[NSColor darkGrayColor] range:match.range]; } + + // Highlight due dates. + matches = [self.rawText matchesWithDetails:RX(FullDueDatePattern)]; + for (RxMatch *match in matches) { + [as addAttribute:NSForegroundColorAttributeName + value:[NSColor darkGrayColor] + range:match.range]; + } return as; }