diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llwindow/llappdelegate-objc.h | 1 | ||||
-rw-r--r-- | indra/llwindow/llopenglview-objc.h | 4 | ||||
-rw-r--r-- | indra/llwindow/llopenglview-objc.mm | 66 | ||||
-rw-r--r-- | indra/llwindow/llwindowmacosx-objc.h | 13 | ||||
-rw-r--r-- | indra/llwindow/llwindowmacosx-objc.mm | 2 | ||||
-rw-r--r-- | indra/llwindow/llwindowmacosx.cpp | 13 | ||||
-rw-r--r-- | indra/newview/llappdelegate-objc.mm | 1 |
7 files changed, 51 insertions, 49 deletions
diff --git a/indra/llwindow/llappdelegate-objc.h b/indra/llwindow/llappdelegate-objc.h index 56b7a30797..6a4794f3c3 100644 --- a/indra/llwindow/llappdelegate-objc.h +++ b/indra/llwindow/llappdelegate-objc.h @@ -8,7 +8,6 @@ #import <Cocoa/Cocoa.h> #import "llopenglview-objc.h" -#include "llwindowmacosx-objc.h" @interface LLAppDelegate : NSObject <NSApplicationDelegate> { LLNSWindow *window; diff --git a/indra/llwindow/llopenglview-objc.h b/indra/llwindow/llopenglview-objc.h index 8140421e44..5f972b1a98 100644 --- a/indra/llwindow/llopenglview-objc.h +++ b/indra/llwindow/llopenglview-objc.h @@ -10,7 +10,7 @@ #import <IOKit/IOKitLib.h> #import <CoreFoundation/CFBase.h> #import <CoreFoundation/CFNumber.h> -#include "llwindowmacosx-objc.h" +#include <string> // Some nasty shovelling of LLOpenGLView from LLNativeBindings to prevent any C++ <-> Obj-C interop oddities. // Redraw callback handling removed (for now) due to being unneeded in the patch that preceeds this addition. @@ -42,8 +42,6 @@ - (unsigned long) getVramSize; -- (segment_t) getSegments:(NSAttributedString*)str; - @end @interface LLNSWindow : NSWindow diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm index 31b0e02ad8..376d238c90 100644 --- a/indra/llwindow/llopenglview-objc.mm +++ b/indra/llwindow/llopenglview-objc.mm @@ -7,6 +7,7 @@ // #import "llopenglview-objc.h" +#include "llwindowmacosx-objc.h" @implementation NSScreen (PointConversion) @@ -37,6 +38,37 @@ @end +attributedStringInfo getSegments(NSAttributedString *str) +{ + attributedStringInfo segments; + segment_lengths seg_lengths; + segment_standouts seg_standouts; + NSRange effectiveRange; + NSRange limitRange = NSMakeRange(0, [str length]); + while (limitRange.length > 0) { + NSNumber *attr = [str attribute:NSUnderlineStyleAttributeName atIndex:limitRange.location longestEffectiveRange:&effectiveRange inRange:limitRange]; + limitRange = NSMakeRange(NSMaxRange(effectiveRange), NSMaxRange(limitRange) - NSMaxRange(effectiveRange)); + + if (effectiveRange.length <= 0) + { + effectiveRange.length = 1; + } + + if ([attr integerValue] == 2) + { + seg_lengths.push_back(effectiveRange.length); + seg_standouts.push_back(true); + } else + { + seg_lengths.push_back(effectiveRange.length); + seg_standouts.push_back(false); + } + } + segments.seg_lengths = seg_lengths; + segments.seg_standouts = seg_standouts; + return segments; +} + @implementation LLOpenGLView - (unsigned long)getVramSize @@ -368,35 +400,6 @@ return NSMakeRange(range[0], range[1]); } -- (segment_t) getSegments:(NSAttributedString*)str -{ - segment_t segments; - - int segment = 0; - - NSRange l; - NSRange r = NSMakeRange(0, [str length]); - - while (r.length > 0) - { - NSNumber *segmentAttrib = [str attribute:NSUnderlineStyleAttributeName atIndex:r.location longestEffectiveRange:&l inRange:r]; - - r = NSMakeRange(NSMaxRange(l), NSMaxRange(r) - NSMaxRange(l)); - bool standout; - if ([segmentAttrib integerValue] == 1) - { - standout = false; - } else { - standout = true; - } - segments.insert(std::pair<int, bool>(l.length, standout)); - - segment++; - } - - return segments; -} - - (void)setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replacementRange:(NSRange)replacementRange { if ([aString class] == NSClassFromString(@"NSConcreteMutableAttributedString")) @@ -411,11 +414,9 @@ replacementRange.length }; - NSLog(@"Attributed string: %@", aString); - unichar text[[aString length]]; [[aString mutableString] getCharacters:text range:NSMakeRange(0, [aString length])]; - segment_t segments = [self getSegments:(NSAttributedString *)aString]; + attributedStringInfo segments = getSegments((NSAttributedString *)aString); setMarkedText(text, selected, replacement, [aString length], segments); mHasMarkedText = TRUE; mMarkedTextLength = [aString length]; @@ -452,6 +453,7 @@ // We may never get this point since unmarkText may be called before insertText ever gets called once we submit our text. // But just in case... resetPreedit(); + for (NSInteger i = 0; i < [aString length]; i++) { handleUnicodeCharacter([aString characterAtIndex:i]); diff --git a/indra/llwindow/llwindowmacosx-objc.h b/indra/llwindow/llwindowmacosx-objc.h index 2de185fed3..1d05db14b2 100644 --- a/indra/llwindow/llwindowmacosx-objc.h +++ b/indra/llwindow/llwindowmacosx-objc.h @@ -26,8 +26,17 @@ */ #include <map> +#include <vector> -typedef std::map<int, bool> segment_t; +typedef std::vector<std::pair<int, bool> > segment_t; + +typedef std::vector<int> segment_lengths; +typedef std::vector<int> segment_standouts; + +struct attributedStringInfo { + segment_lengths seg_lengths; + segment_standouts seg_standouts; +}; // This will actually hold an NSCursor*, but that type is only available in objective C. typedef void *CursorRef; @@ -122,7 +131,7 @@ void updatePreeditor(unsigned short *str); void setPreeditMarkedRange(int position, int length); void resetPreedit(); int wstring_length(const std::basic_string<wchar_t> & wstr, const int woffset, const int utf16_length, int *unaligned); -void setMarkedText(unsigned short *text, unsigned int *selectedRange, unsigned int *replacementRange, long text_len, segment_t segments); +void setMarkedText(unsigned short *text, unsigned int *selectedRange, unsigned int *replacementRange, long text_len, attributedStringInfo segments); void getPreeditLocation(float *location, unsigned int length); NSWindowRef getMainAppWindow(); diff --git a/indra/llwindow/llwindowmacosx-objc.mm b/indra/llwindow/llwindowmacosx-objc.mm index 1a0647485c..43f853bfd1 100644 --- a/indra/llwindow/llwindowmacosx-objc.mm +++ b/indra/llwindow/llwindowmacosx-objc.mm @@ -27,8 +27,8 @@ #include <AppKit/AppKit.h> #include <Cocoa/Cocoa.h> -#include "llwindowmacosx-objc.h" #include "llopenglview-objc.h" +#include "llwindowmacosx-objc.h" #include "llappdelegate-objc.h" /* diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index 4e8934b149..6f66da66a4 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -39,6 +39,7 @@ #include "indra_constants.h" #include <OpenGL/OpenGL.h> +#include <CoreServices/CoreServices.h> extern BOOL gDebugWindowProc; @@ -423,7 +424,7 @@ void resetPreedit() // For reasons of convenience, handle IME updates here. // This largely mirrors the old implementation, only sans the carbon parameters. -void setMarkedText(unsigned short *unitext, unsigned int *selectedRange, unsigned int *replacementRange, long text_len, segment_t segments) +void setMarkedText(unsigned short *unitext, unsigned int *selectedRange, unsigned int *replacementRange, long text_len, attributedStringInfo segments) { if (gWindowImplementation->getPreeditor()) { @@ -442,17 +443,9 @@ void setMarkedText(unsigned short *unitext, unsigned int *selectedRange, unsigne LLWString fix_str = utf16str_to_wstring(llutf16string(unitext, text_len)); - LLPreeditor::segment_lengths_t preedit_segment_lengths; - LLPreeditor::standouts_t preedit_standouts; S32 caret_position = fix_str.length(); - for (segment_t::iterator i = segments.begin(); i != segments.end(); i++) - { - preedit_segment_lengths.push_back(i->first); - preedit_standouts.push_back(i->second); - } - - preeditor->updatePreedit(fix_str, preedit_segment_lengths, preedit_standouts, caret_position); + preeditor->updatePreedit(fix_str, segments.seg_lengths, segments.seg_standouts, caret_position); } } diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index 9e0e0e35c5..5fb5087cd8 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -7,6 +7,7 @@ // #import "llappdelegate-objc.h" +#include "llwindowmacosx-objc.h" @implementation LLAppDelegate |