IME support is pretty much finished at this point.
parent
258b77b647
commit
80a79e5d7b
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "llopenglview-objc.h"
|
||||
#include "llwindowmacosx-objc.h"
|
||||
|
||||
@interface LLAppDelegate : NSObject <NSApplicationDelegate> {
|
||||
LLNSWindow *window;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
//
|
||||
|
||||
#import "llappdelegate-objc.h"
|
||||
#include "llwindowmacosx-objc.h"
|
||||
|
||||
@implementation LLAppDelegate
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue