adium-1.4 3051:961833271e26: Fixes #13987. Allow accounts to ove...
commits at adium.im
commits at adium.im
Mon Sep 20 10:25:52 UTC 2010
details: http://hg.adium.im/adium-1.4/rev/961833271e26
revision: 3051:961833271e26
author: Robert Vehse
date: Sun Sep 19 20:41:15 2010 +0200
Fixes #13987. Allow accounts to override the suffix/prefix for chat autocomplete. Add the "@" sign as a prefix and remove ":" as a suffix for Twitter. "mlei" and "wbowling" worked together on this patch.
(transplanted from a534d21369d528c9b96604f06487ce41be631087)
Subject: adium-1.4 3052:85903a7dd4f3: Remove prefix code path that will never be used. Refs #13987. Patch by "mlei". Thanks!
details: http://hg.adium.im/adium-1.4/rev/85903a7dd4f3
revision: 3052:85903a7dd4f3
author: Robert Vehse
date: Mon Sep 20 00:42:20 2010 +0200
Remove prefix code path that will never be used. Refs #13987. Patch by "mlei". Thanks!
(transplanted from 0e3dafd316e82fd6aa71f6c164e8a0d45cc9872f)
diffs (123 lines):
diff -r 0e7fd2c07797 -r 85903a7dd4f3 Frameworks/Adium Framework/Source/AIAccount.h
--- a/Frameworks/Adium Framework/Source/AIAccount.h Mon Sep 20 00:09:27 2010 -0500
+++ b/Frameworks/Adium Framework/Source/AIAccount.h Mon Sep 20 00:42:20 2010 +0200
@@ -275,6 +275,16 @@
- (BOOL)chatShouldAutocompleteUID:(AIChat *)inChat;
/*!
+ * @brief Suffix for autocompleted contacts
+ */
+- (NSString *)suffixForAutocomplete:(AIChat *)inChat forPartialWordRange:(NSRange)charRange;
+
+/*!
+ * @brief Prefix for autocompleted contacts
+ */
+- (NSString *)prefixForAutocomplete:(AIChat *)inChat forPartialWordRange:(NSRange)charRange;
+
+/*!
* @brief Does the account support sending notifications?
*/
- (BOOL)supportsSendingNotifications;
diff -r 0e7fd2c07797 -r 85903a7dd4f3 Frameworks/Adium Framework/Source/AIAccount.m
--- a/Frameworks/Adium Framework/Source/AIAccount.m Mon Sep 20 00:09:27 2010 -0500
+++ b/Frameworks/Adium Framework/Source/AIAccount.m Mon Sep 20 00:42:20 2010 +0200
@@ -930,6 +930,28 @@
return NO;
}
+/*!
+ * @brief Suffix for autocompleted contacts
+ */
+- (NSString *)suffixForAutocomplete:(AIChat *)inChat forPartialWordRange:(NSRange)charRange
+{
+ NSString *suffix = nil;
+ if (charRange.location == 0)
+ {
+ suffix = @": ";
+ }
+ return suffix;
+}
+
+/*!
+ * @brief Prefix for autocompleted contacts
+ */
+- (NSString *)prefixForAutocomplete:(AIChat *)inChat forPartialWordRange:(NSRange)charRange
+{
+ return nil;
+}
+
+
-(NSMenu*)actionMenuForChat:(AIChat*)chat
{
return nil;
diff -r 0e7fd2c07797 -r 85903a7dd4f3 Plugins/Dual Window Interface/AIMessageViewController.m
--- a/Plugins/Dual Window Interface/AIMessageViewController.m Mon Sep 20 00:09:27 2010 -0500
+++ b/Plugins/Dual Window Interface/AIMessageViewController.m Mon Sep 20 00:42:20 2010 +0200
@@ -1046,13 +1046,28 @@
NSMutableArray *completions = nil;
if (self.chat.isGroupChat) {
- NSString *suffix = nil;
+ NSString *suffix = [self.chat.account suffixForAutocomplete:self.chat forPartialWordRange:charRange];
+ NSString *prefix = [self.chat.account prefixForAutocomplete:self.chat forPartialWordRange:charRange];
NSString *partialWord = [textView.textStorage.string substringWithRange:charRange];
BOOL autoCompleteUID = [self.chat.account chatShouldAutocompleteUID:self.chat];
- //At the start of a line, append ": "
- if (charRange.location == 0) {
- suffix = @": ";
+ // Check to see if the prefix is already present
+ if (charRange.location != 0 && charRange.location >= prefix.length) {
+ prefix = [[textView.textStorage.string substringWithRange:
+ NSMakeRange(charRange.location-prefix.length, prefix.length)] isEqualToString:prefix] ? nil : prefix;
+ }
+
+ // If we need to add a prefix, insert it into the text, then call [textView complete:] again; return early with no completions.
+ if (prefix.length > 0) {
+ [textView.textStorage insertAttributedString:[[NSAttributedString alloc] initWithString:prefix] atIndex:charRange.location];
+ [textView complete:nil];
+ return nil;
+ }
+
+ // Check to see if the suffix is already present
+ if (charRange.location + charRange.length + suffix.length <= textView.textStorage.string.length ) {
+ suffix = [[textView.textStorage.string substringWithRange:
+ NSMakeRange(charRange.location + charRange.length, suffix.length)] isEqualToString:suffix] ? nil : suffix;
}
completions = [NSMutableArray array];
@@ -1070,7 +1085,7 @@
completion = aliasOrDisplayName;
}
- // Add what we came up with to the completions list (with suffix if at beginning of line)
+ // Add what we came up with to the completions list (with suffix if required)
[completions addObject:(suffix ? [completion stringByAppendingString:suffix] : completion)];
}
diff -r 0e7fd2c07797 -r 85903a7dd4f3 Plugins/Twitter Plugin/AITwitterAccount.m
--- a/Plugins/Twitter Plugin/AITwitterAccount.m Mon Sep 20 00:09:27 2010 -0500
+++ b/Plugins/Twitter Plugin/AITwitterAccount.m Mon Sep 20 00:42:20 2010 +0200
@@ -352,6 +352,22 @@
}
/*!
+ * @brief Suffix for autocompleted contacts
+ */
+- (NSString *)suffixForAutocomplete:(AIChat *)inChat forPartialWordRange:(NSRange)charRange
+{
+ return nil;
+}
+
+/*!
+ * @brief Prefix for autocompleted contacts
+ */
+- (NSString *)prefixForAutocomplete:(AIChat *)inChat forPartialWordRange:(NSRange)charRange
+{
+ return @"@";
+}
+
+/*!
* @brief A chat opened.
*
* If this is a group chat which belongs to us, aka a timeline chat, set it up how we want it.
More information about the commits
mailing list