1 // Copyright 2013 The Flutter Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #import <Foundation/Foundation.h> 6 7 /** 8 * The affinity of the current cursor position. If the cursor is at a position representing 9 * a line break, the cursor may be drawn either at the end of the current line (upstream) 10 * or at the beginning of the next (downstream). 11 */ 12 typedef NS_ENUM(NSUInteger, FlutterTextAffinity) { 13 FlutterTextAffinityUpstream, 14 FlutterTextAffinityDownstream 15 }; 16 17 /** 18 * Data model representing text input state during an editing session. 19 */ 20 @interface FlutterTextInputModel : NSObject 21 22 /** 23 * The full text being edited. 24 */ 25 @property(nonnull, copy) NSMutableString* text; 26 /** 27 * The range of text currently selected. This may have length zero to represent a single 28 * cursor position. 29 */ 30 @property NSRange selectedRange; 31 /** 32 * The affinity for the current cursor position. 33 */ 34 @property FlutterTextAffinity textAffinity; 35 /** 36 * The range of text that is marked for edit, i.e. under the effects of a multi-keystroke input 37 * combination. 38 */ 39 @property NSRange markedRange; 40 41 /** 42 * Representation of the model's data as a state dictionary suitable for interchange with the 43 * Flutter Dart layer. 44 */ 45 @property(nonnull) NSDictionary* state; 46 47 /** 48 * ID of the text input client. 49 */ 50 @property(nonatomic, readonly, nonnull) NSNumber* clientID; 51 52 /** 53 * Keyboard type of the client. See available options: 54 * https://docs.flutter.io/flutter/services/TextInputType-class.html 55 */ 56 @property(nonatomic, readonly, nonnull) NSString* inputType; 57 58 /** 59 * An action requested by the user on the input client. See available options: 60 * https://docs.flutter.io/flutter/services/TextInputAction-class.html 61 */ 62 @property(nonatomic, readonly, nonnull) NSString* inputAction; 63 64 - (nullable instancetype)init NS_UNAVAILABLE; 65 66 /** 67 * Initializes a text input model with a [clientId] and [config] arguments. [config] arguments 68 * provide information on the text input connection. 69 */ 70 - (nullable instancetype)initWithClientID:(nonnull NSNumber*)clientID 71 configuration:(nonnull NSDictionary*)config; 72 @end 73