Flutter Engine
FlutterTextInputModel.mm File Reference
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterTextInputModel.h"

Go to the source code of this file.

Functions

static NSRange UpdateRangeFromBaseExtent (NSNumber *base, NSNumber *extent, NSRange range)
 
static long GetBaseForRange (NSRange range)
 
static long GetExtentForRange (NSRange range)
 

Variables

static NSString *const kTextAffinityDownstream = @"@"TextAffinity.downstream"
 
static NSString *const kTextAffinityUpstream = @"@"TextAffinity.upstream"
 
static NSString *const kTextInputAction = @"@"inputAction"
 
static NSString *const kTextInputType = @"@"inputType"
 
static NSString *const kTextInputTypeName = @"@"name"
 
static NSString *const kSelectionBaseKey = @"@"selectionBase"
 
static NSString *const kSelectionExtentKey = @"@"selectionExtent"
 
static NSString *const kSelectionAffinityKey = @"@"selectionAffinity"
 
static NSString *const kSelectionIsDirectionalKey = @"@"selectionIsDirectional"
 
static NSString *const kComposingBaseKey = @"@"composingBase"
 
static NSString *const kComposingExtentKey = @"@"composingExtent"
 
static NSString *const kTextKey = @"@"text"
 

Function Documentation

◆ GetBaseForRange()

static long GetBaseForRange ( NSRange  range)
static

Returns the appropriate base field for a given range.

Definition at line 48 of file FlutterTextInputModel.mm.

Referenced by GetExtentForRange().

48  {
49  if (range.location == NSNotFound) {
50  return -1;
51  }
52  return range.location;
53 }

◆ GetExtentForRange()

static long GetExtentForRange ( NSRange  range)
static

Returns the appropriate extent field for a given range.

Definition at line 58 of file FlutterTextInputModel.mm.

References FlutterTextInputModel::clientID, GetBaseForRange(), kComposingBaseKey, kComposingExtentKey, kSelectionAffinityKey, kSelectionBaseKey, kSelectionExtentKey, kSelectionIsDirectionalKey, kTextAffinityDownstream, kTextAffinityUpstream, kTextKey, FlutterTextInputModel::state, FlutterTextInputModel::text, FlutterTextInputModel::textAffinity, and UpdateRangeFromBaseExtent().

58  {
59  if (range.location == NSNotFound) {
60  return -1;
61  }
62  return range.location + range.length;
63 }

◆ UpdateRangeFromBaseExtent()

static NSRange UpdateRangeFromBaseExtent ( NSNumber *  base,
NSNumber *  extent,
NSRange  range 
)
static

These three static methods are necessary because Cocoa and Flutter have different idioms for signaling an empty range: Flutter uses {-1, -1} while Cocoa uses {NSNotFound, 0}. Also, despite the name, the "extent" fields are actually end indices, not lengths. Updates a range given base and extent fields.

Definition at line 31 of file FlutterTextInputModel.mm.

Referenced by GetExtentForRange().

31  {
32  if (base == nil || extent == nil) {
33  return range;
34  }
35  if (base.intValue == -1 && extent.intValue == -1) {
36  range.location = NSNotFound;
37  range.length = 0;
38  } else {
39  range.location = [base unsignedLongValue];
40  range.length = [extent unsignedLongValue] - range.location;
41  }
42  return range;
43 }

Variable Documentation

◆ kComposingBaseKey

NSString* const kComposingBaseKey = @"@"composingBase"
static

Definition at line 18 of file FlutterTextInputModel.mm.

Referenced by GetExtentForRange().

◆ kComposingExtentKey

NSString* const kComposingExtentKey = @"@"composingExtent"
static

Definition at line 19 of file FlutterTextInputModel.mm.

Referenced by GetExtentForRange().

◆ kSelectionAffinityKey

NSString* const kSelectionAffinityKey = @"@"selectionAffinity"
static

Definition at line 16 of file FlutterTextInputModel.mm.

Referenced by GetExtentForRange().

◆ kSelectionBaseKey

NSString* const kSelectionBaseKey = @"@"selectionBase"
static

Definition at line 14 of file FlutterTextInputModel.mm.

Referenced by GetExtentForRange().

◆ kSelectionExtentKey

NSString* const kSelectionExtentKey = @"@"selectionExtent"
static

Definition at line 15 of file FlutterTextInputModel.mm.

Referenced by GetExtentForRange().

◆ kSelectionIsDirectionalKey

NSString* const kSelectionIsDirectionalKey = @"@"selectionIsDirectional"
static

Definition at line 17 of file FlutterTextInputModel.mm.

Referenced by GetExtentForRange().

◆ kTextAffinityDownstream

NSString* const kTextAffinityDownstream = @"@"TextAffinity.downstream"
static

Definition at line 7 of file FlutterTextInputModel.mm.

Referenced by GetExtentForRange().

◆ kTextAffinityUpstream

NSString* const kTextAffinityUpstream = @"@"TextAffinity.upstream"
static

Definition at line 8 of file FlutterTextInputModel.mm.

Referenced by GetExtentForRange().

◆ kTextInputAction

NSString* const kTextInputAction = @"@"inputAction"
static

Definition at line 10 of file FlutterTextInputModel.mm.

◆ kTextInputType

NSString* const kTextInputType = @"@"inputType"
static

Definition at line 11 of file FlutterTextInputModel.mm.

◆ kTextInputTypeName

NSString* const kTextInputTypeName = @"@"name"
static

Definition at line 12 of file FlutterTextInputModel.mm.

◆ kTextKey

NSString* const kTextKey = @"@"text"
static

Definition at line 20 of file FlutterTextInputModel.mm.

Referenced by GetExtentForRange().