• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file
18 * @kit IMEKit
19 */
20import type { AsyncCallback, Callback } from './@ohos.base';
21import type { KeyEvent as InputKeyEvent } from './@ohos.multimodalInput.keyEvent';
22import InputMethodSubtype from './@ohos.InputMethodSubtype';
23import BaseContext from './application/BaseContext';
24import window from './@ohos.window';
25
26/**
27 * Input method engine
28 *
29 * @namespace inputMethodEngine
30 * @syscap SystemCapability.MiscServices.InputMethodFramework
31 * @since 8
32 */
33declare namespace inputMethodEngine {
34  /**
35   * When "enter" key is pressed, there is no action
36   *
37   * @syscap SystemCapability.MiscServices.InputMethodFramework
38   * @since 8
39   */
40  const ENTER_KEY_TYPE_UNSPECIFIED: number;
41
42  /**
43   * When "enter" key is pressed, it means GO
44   *
45   * @syscap SystemCapability.MiscServices.InputMethodFramework
46   * @since 8
47   */
48  const ENTER_KEY_TYPE_GO: number;
49
50  /**
51   * When "enter" key is pressed, it means SEARCH
52   *
53   * @syscap SystemCapability.MiscServices.InputMethodFramework
54   * @since 8
55   */
56  const ENTER_KEY_TYPE_SEARCH: number;
57
58  /**
59   * When "enter" key is pressed, it means SEND
60   *
61   * @syscap SystemCapability.MiscServices.InputMethodFramework
62   * @since 8
63   */
64  const ENTER_KEY_TYPE_SEND: number;
65
66  /**
67   * When "enter" key is pressed, it means NEXT
68   *
69   * @syscap SystemCapability.MiscServices.InputMethodFramework
70   * @since 8
71   */
72  const ENTER_KEY_TYPE_NEXT: number;
73
74  /**
75   * When "enter" key is pressed, it means DONE
76   *
77   * @syscap SystemCapability.MiscServices.InputMethodFramework
78   * @since 8
79   */
80  const ENTER_KEY_TYPE_DONE: number;
81
82  /**
83   * When "enter" key is pressed, it means PREVIOUS
84   *
85   * @syscap SystemCapability.MiscServices.InputMethodFramework
86   * @since 8
87   */
88  const ENTER_KEY_TYPE_PREVIOUS: number;
89
90  /**
91   * When "enter" key is pressed, it means NEWLINE
92   *
93   * @constant
94   * @syscap SystemCapability.MiscServices.InputMethodFramework
95   * @since 12
96   */
97  const ENTER_KEY_TYPE_NEWLINE: 8;
98
99  /**
100   * Editor with no special function
101   *
102   * @syscap SystemCapability.MiscServices.InputMethodFramework
103   * @since 8
104   */
105  const PATTERN_NULL: number;
106
107  /**
108   * Editor of type TEXT
109   *
110   * @syscap SystemCapability.MiscServices.InputMethodFramework
111   * @since 8
112   */
113  const PATTERN_TEXT: number;
114
115  /**
116   * Editor of type NUMBER
117   *
118   * @syscap SystemCapability.MiscServices.InputMethodFramework
119   * @since 8
120   */
121  const PATTERN_NUMBER: number;
122
123  /**
124   * Editor of type PHONE NUMBER
125   *
126   * @syscap SystemCapability.MiscServices.InputMethodFramework
127   * @since 8
128   */
129  const PATTERN_PHONE: number;
130
131  /**
132   * Editor of type DATETIME
133   *
134   * @syscap SystemCapability.MiscServices.InputMethodFramework
135   * @since 8
136   */
137  const PATTERN_DATETIME: number;
138
139  /**
140   * Editor of type EMAIL
141   *
142   * @syscap SystemCapability.MiscServices.InputMethodFramework
143   * @since 8
144   */
145  const PATTERN_EMAIL: number;
146
147  /**
148   * Editor of type URI
149   *
150   * @syscap SystemCapability.MiscServices.InputMethodFramework
151   * @since 8
152   */
153  const PATTERN_URI: number;
154
155  /**
156   * Editor of type PASSWORD
157   *
158   * @syscap SystemCapability.MiscServices.InputMethodFramework
159   * @since 8
160   */
161  const PATTERN_PASSWORD: number;
162
163  /**
164   * Editor of type SCREEN LOCK PASSWORD
165   *
166   * @syscap SystemCapability.MiscServices.InputMethodFramework
167   * @since 11
168   */
169  const PATTERN_PASSWORD_SCREEN_LOCK: number;
170
171  /**
172   * Editor of type NUMBER PASSWORD
173   *
174   * @syscap SystemCapability.MiscServices.InputMethodFramework
175   * @since 11
176   */
177  const PATTERN_PASSWORD_NUMBER: number;
178
179  /**
180   * Editor in SELECTING state
181   *
182   * @syscap SystemCapability.MiscServices.InputMethodFramework
183   * @since 8
184   */
185  const FLAG_SELECTING: number;
186
187  /**
188   * Editor in SINGLE_LINE state
189   *
190   * @syscap SystemCapability.MiscServices.InputMethodFramework
191   * @since 8
192   */
193  const FLAG_SINGLE_LINE: number;
194
195  /**
196   * The Editor displays in PART mode
197   *
198   * @syscap SystemCapability.MiscServices.InputMethodFramework
199   * @since 8
200   */
201  const DISPLAY_MODE_PART: number;
202
203  /**
204   * The Editor displays in FULL mode
205   *
206   * @syscap SystemCapability.MiscServices.InputMethodFramework
207   * @since 8
208   */
209  const DISPLAY_MODE_FULL: number;
210
211  /**
212   * Allows ASCII to be inputted
213   *
214   * @syscap SystemCapability.MiscServices.InputMethodFramework
215   * @since 8
216   */
217  const OPTION_ASCII: number;
218
219  /**
220   * Do not specify Editor's input type
221   *
222   * @syscap SystemCapability.MiscServices.InputMethodFramework
223   * @since 8
224   */
225  const OPTION_NONE: number;
226
227  /**
228   * Allows CHARACTERS to be inputted
229   *
230   * @syscap SystemCapability.MiscServices.InputMethodFramework
231   * @since 8
232   */
233  const OPTION_AUTO_CAP_CHARACTERS: number;
234
235  /**
236   * Allows SENTENCES to be inputted
237   *
238   * @syscap SystemCapability.MiscServices.InputMethodFramework
239   * @since 8
240   */
241  const OPTION_AUTO_CAP_SENTENCES: number;
242
243  /**
244   * Allows WORDS to be inputted
245   *
246   * @syscap SystemCapability.MiscServices.InputMethodFramework
247   * @since 8
248   */
249  const OPTION_AUTO_WORDS: number;
250
251  /**
252   * Allows MULTI_LINE to be inputted
253   *
254   * @syscap SystemCapability.MiscServices.InputMethodFramework
255   * @since 8
256   */
257  const OPTION_MULTI_LINE: number;
258
259  /**
260   * Half-screen mode
261   *
262   * @syscap SystemCapability.MiscServices.InputMethodFramework
263   * @since 8
264   */
265  const OPTION_NO_FULLSCREEN: number;
266
267  /**
268   * The move direction of cursor: UP
269   *
270   * @syscap SystemCapability.MiscServices.InputMethodFramework
271   * @since 9
272   */
273  const CURSOR_UP: number;
274
275  /**
276   * The move direction of cursor: DOWN
277   *
278   * @syscap SystemCapability.MiscServices.InputMethodFramework
279   * @since 9
280   */
281  const CURSOR_DOWN: number;
282
283  /**
284   * The move direction of cursor: LEFT
285   *
286   * @syscap SystemCapability.MiscServices.InputMethodFramework
287   * @since 9
288   */
289  const CURSOR_LEFT: number;
290
291  /**
292   * The move direction of cursor: RIGHT
293   *
294   * @syscap SystemCapability.MiscServices.InputMethodFramework
295   * @since 9
296   */
297  const CURSOR_RIGHT: number;
298
299  /**
300   * The window styles for input method ability.
301   *
302   * @syscap SystemCapability.MiscServices.InputMethodFramework
303   * @since 9
304   */
305  const WINDOW_TYPE_INPUT_METHOD_FLOAT: number;
306
307  /**
308   * Get InputMethodAbility object to subscribe events about IME.
309   *
310   * @returns { InputMethodAbility } the object of the InputMethodAbility.
311   * @syscap SystemCapability.MiscServices.InputMethodFramework
312   * @since 9
313   */
314  function getInputMethodAbility(): InputMethodAbility;
315
316  /**
317   * @returns { InputMethodEngine }
318   * @syscap SystemCapability.MiscServices.InputMethodFramework
319   * @since 8
320   * @deprecated since 9
321   * @useinstead inputMethodEngine#getInputMethodAbility
322   */
323  function getInputMethodEngine(): InputMethodEngine;
324
325  /**
326   * Get KeyboardDelegate object to subscribe key event or events about editor.
327   *
328   * @returns { KeyboardDelegate } the object of KeyboardDelegate.
329   * @syscap SystemCapability.MiscServices.InputMethodFramework
330   * @since 9
331   */
332  function getKeyboardDelegate(): KeyboardDelegate;
333
334  /**
335   * @returns { KeyboardDelegate }
336   * @syscap SystemCapability.MiscServices.InputMethodFramework
337   * @since 8
338   * @deprecated since 9
339   * @useinstead inputMethodEngine#getKeyboardDelegate
340   */
341  function createKeyboardDelegate(): KeyboardDelegate;
342
343  /**
344   * Indicates the possible data types of the command.
345   * @typedef { number | string | boolean }
346   * @syscap SystemCapability.MiscServices.InputMethodFramework
347   * @since 12
348   */
349  type CommandDataType = number | string | boolean;
350
351  /**
352   * The callback of 'sizeUpdate' event.
353   *
354   * @typedef { function } SizeUpdateCallback.
355   * @param { window.Size } size - panel size.
356   * @param { KeyboardArea } keyboardArea - keyboard area.
357   * @syscap SystemCapability.MiscServices.InputMethodFramework
358   * @systemapi
359   * @since 14
360   */
361  export type SizeUpdateCallback = (size: window.Size, keyboardArea: KeyboardArea) => void;
362
363  /**
364   * The callback of 'sizeChange' event.
365   *
366   * @typedef { function } SizeChangeCallback.
367   * @param { window.Size } size - panel size.
368   * @param { KeyboardArea } keyboardArea - keyboard area.
369   * @syscap SystemCapability.MiscServices.InputMethodFramework
370   * @since 15
371   */
372  export type SizeChangeCallback = (size: window.Size, keyboardArea?: KeyboardArea) => void;
373
374  /**
375   * @interface KeyboardController
376   * @syscap SystemCapability.MiscServices.InputMethodFramework
377   * @since 8
378   */
379  interface KeyboardController {
380    /**
381     * Hide soft keyboard
382     *
383     * @param { AsyncCallback<void> } callback - indicates the callback function of hide.
384     * @throws { BusinessError } 12800003 - input method client error.
385     * @syscap SystemCapability.MiscServices.InputMethodFramework
386     * @since 9
387     */
388    hide(callback: AsyncCallback<void>): void;
389
390    /**
391     * Hide soft keyboard
392     *
393     * @returns { Promise<void> } the promise returned by the function
394     * @throws { BusinessError } 12800003 - input method client error.
395     * @syscap SystemCapability.MiscServices.InputMethodFramework
396     * @since 9
397     */
398    hide(): Promise<void>;
399
400    /**
401     * @param { AsyncCallback<void> } callback - indicates the callback function of hideKeyboard.
402     * @syscap SystemCapability.MiscServices.InputMethodFramework
403     * @since 8
404     * @deprecated since 9
405     * @useinstead inputMethodEngine.KeyboardController#hide
406     */
407    hideKeyboard(callback: AsyncCallback<void>): void;
408
409    /**
410     * @returns { Promise<void> } the promise returned by the function
411     * @syscap SystemCapability.MiscServices.InputMethodFramework
412     * @since 8
413     * @deprecated since 9
414     * @useinstead inputMethodEngine.KeyboardController#hide
415     */
416    hideKeyboard(): Promise<void>;
417
418    /**
419     * Exit the current input type. This function can only be called by default input method configured by system.
420     *
421     * @param { AsyncCallback<void> } callback - the callback of exitCurrentInputType.
422     * @throws { BusinessError } 12800008 - input method manager service error.
423     * @throws { BusinessError } 12800010 - not the preconfigured default input method.
424     * @syscap SystemCapability.MiscServices.InputMethodFramework
425     * @since 11
426     */
427    exitCurrentInputType(callback: AsyncCallback<void>): void;
428
429    /**
430     * Exit the current input type. This function can only be called by default input method configured by system.
431     *
432     * @returns { Promise<void> } the promise returned by the function.
433     * @throws { BusinessError } 12800008 - input method manager service error.
434     * @throws { BusinessError } 12800010 - not the preconfigured default input method.
435     * @syscap SystemCapability.MiscServices.InputMethodFramework
436     * @since 11
437     */
438    exitCurrentInputType(): Promise<void>;
439  }
440
441  /**
442   * @interface InputMethodEngine
443   * @syscap SystemCapability.MiscServices.InputMethodFramework
444   * @since 8
445   */
446  interface InputMethodEngine {
447    /**
448     * Subscribe 'inputStart'
449     *
450     * @param { 'inputStart' } type - indicates the type of subscribe event.
451     * @param { function } callback - indicates the callback of on('inputStart').
452     * @syscap SystemCapability.MiscServices.InputMethodFramework
453     * @since 8
454     */
455    on(
456      type: 'inputStart',
457      callback: (kbController: KeyboardController, textInputClient: TextInputClient) => void
458    ): void;
459
460    /**
461     * Unsubscribe 'inputStart'
462     *
463     * @param { 'inputStart' } type - indicates the type of subscribe event.
464     * @param { function } callback - optional, indicates the callback of off('inputStart').
465     * @syscap SystemCapability.MiscServices.InputMethodFramework
466     * @since 8
467     */
468    off(
469      type: 'inputStart',
470      callback?: (kbController: KeyboardController, textInputClient: TextInputClient) => void
471    ): void;
472
473    /**
474     * Subscribe 'keyboardShow'|'keyboardHide'
475     *
476     * @param { 'keyboardShow' | 'keyboardHide' } type - indicates the type of subscribe event.
477     * @param { function } callback - indicates the callback of on('keyboardShow'|'keyboardHide').
478     * @syscap SystemCapability.MiscServices.InputMethodFramework
479     * @since 8
480     */
481    on(type: 'keyboardShow' | 'keyboardHide', callback: () => void): void;
482
483    /**
484     * Unsubscribe 'keyboardShow'|'keyboardHide'
485     *
486     * @param { 'keyboardShow' | 'keyboardHide' } type - indicates the type of subscribe event.
487     * @param { function } [callback] - optional, indicates the callback of off('keyboardShow'|'keyboardHide').
488     * @syscap SystemCapability.MiscServices.InputMethodFramework
489     * @since 8
490     */
491    off(type: 'keyboardShow' | 'keyboardHide', callback?: () => void): void;
492  }
493
494  /**
495   * <p>Control events about IME.</p>
496   * <p>Events provided for IME to subscribe with callback function. When those events occur, the corresponding callback
497   * will be invoked.</p>
498   *
499   * @interface InputMethodAbility
500   * @syscap SystemCapability.MiscServices.InputMethodFramework
501   * @since 9
502   */
503  interface InputMethodAbility {
504    /**
505     * Subscribe 'inputStart' event.
506     *
507     * @param { 'inputStart' } type - the type of subscribe event.
508     * @param { function } callback - the callback of on('inputStart').
509     * @syscap SystemCapability.MiscServices.InputMethodFramework
510     * @since 9
511     */
512    on(type: 'inputStart', callback: (kbController: KeyboardController, inputClient: InputClient) => void): void;
513
514    /**
515     * Unsubscribe 'inputStart' event.
516     *
517     * @param { 'inputStart' } type - the type of unsubscribe event.
518     * @param { function } [callback] - optional, the callback of off('inputStart').
519     * @syscap SystemCapability.MiscServices.InputMethodFramework
520     * @since 9
521     */
522    off(type: 'inputStart', callback?: (kbController: KeyboardController, inputClient: InputClient) => void): void;
523
524    /**
525     * Subscribe 'inputStop'.
526     *
527     * @param { 'inputStop' } type - the type of subscribe event.
528     * @param { function } callback - the callback of on('inputStop').
529     * @syscap SystemCapability.MiscServices.InputMethodFramework
530     * @since 9
531     */
532    on(type: 'inputStop', callback: () => void): void;
533
534    /**
535     * Unsubscribe 'inputStop'.
536     *
537     * @param { 'inputStop' } type - the type of unsubscribe event.
538     * @param { function } callback - the callback of off('inputStop').
539     * @syscap SystemCapability.MiscServices.InputMethodFramework
540     * @since 9
541     */
542    off(type: 'inputStop', callback: () => void): void;
543
544    /**
545     * Subscribe 'setCallingWindow'.
546     *
547     * @param { 'setCallingWindow' } type - the type of subscribe event.
548     * @param { function } callback - the callback of on('setCallingWindow').
549     * @syscap SystemCapability.MiscServices.InputMethodFramework
550     * @since 9
551     */
552    on(type: 'setCallingWindow', callback: (wid: number) => void): void;
553
554    /**
555     * Unsubscribe 'setCallingWindow'.
556     *
557     * @param { 'setCallingWindow' } type - the type of unsubscribe event.
558     * @param { function } callback - the callback of off('setCallingWindow').
559     * @syscap SystemCapability.MiscServices.InputMethodFramework
560     * @since 9
561     */
562    off(type: 'setCallingWindow', callback: (wid: number) => void): void;
563
564    /**
565     * Subscribe 'keyboardShow'|'keyboardHide'.
566     *
567     * @param { 'keyboardShow' | 'keyboardHide' } type - the type of subscribe event.
568     * @param { function } callback - the callback of on('keyboardShow'|'keyboardHide').
569     * @syscap SystemCapability.MiscServices.InputMethodFramework
570     * @since 9
571     */
572    on(type: 'keyboardShow' | 'keyboardHide', callback: () => void): void;
573
574    /**
575     * Unsubscribe 'keyboardShow'|'keyboardHide'.
576     *
577     * @param { 'keyboardShow' | 'keyboardHide' } type - the type of unsubscribe event.
578     * @param { function } [callback] - the callback of off('keyboardShow'|'keyboardHide').
579     * @syscap SystemCapability.MiscServices.InputMethodFramework
580     * @since 9
581     */
582    off(type: 'keyboardShow' | 'keyboardHide', callback?: () => void): void;
583
584    /**
585     * Subscribe 'setSubtype'.
586     *
587     * @param { 'setSubtype' } type - the type of subscribe event.
588     * @param { function } callback - the callback of on('setSubtype').
589     * @syscap SystemCapability.MiscServices.InputMethodFramework
590     * @since 9
591     */
592    on(type: 'setSubtype', callback: (inputMethodSubtype: InputMethodSubtype) => void): void;
593
594    /**
595     * Unsubscribe 'setSubtype'.
596     *
597     * @param { 'setSubtype' } type - the type of subscribe event.
598     * @param { function } [callback] - the callback of off('setSubtype').
599     * @syscap SystemCapability.MiscServices.InputMethodFramework
600     * @since 9
601     */
602    off(type: 'setSubtype', callback?: (inputMethodSubtype: InputMethodSubtype) => void): void;
603
604    /**
605     * Subscribe 'securityModeChange' event.
606     *
607     * @param { 'securityModeChange' } type - the type of subscribe event.
608     * @param { Callback<SecurityMode> } callback - the callback of on('securityModeChange').
609     * @syscap SystemCapability.MiscServices.InputMethodFramework
610     * @since 11
611     */
612    on(type: 'securityModeChange', callback: Callback<SecurityMode>): void;
613
614    /**
615     * Unsubscribe 'securityModeChange' event.
616     *
617     * @param { 'securityModeChange' } type - the type of unsubscribe event.
618     * @param { Callback<SecurityMode> } [callback] - optional, the callback of off('securityModeChange').
619     * @syscap SystemCapability.MiscServices.InputMethodFramework
620     * @since 11
621     */
622    off(type: 'securityModeChange', callback?: Callback<SecurityMode>): void;
623
624    /**
625     * Subscribe 'privateCommand'.This function can only be called by default input method configured by system.
626     *
627     * @param { 'privateCommand' } type - indicates the type of subscribe event.
628     * @param { Callback<Record<string, CommandDataType>> } callback - indicates the callback of on('privateCommand').
629     * @throws { BusinessError } 12800010 - not the preconfigured default input method.
630     * @syscap SystemCapability.MiscServices.InputMethodFramework
631     * @since 12
632     */
633    on(type: 'privateCommand', callback: Callback<Record<string, CommandDataType>>): void;
634
635    /**
636     * Unsubscribe 'privateCommand'.This function can only be called by default input method configured by system.
637     *
638     * @param { 'privateCommand' } type - indicates the type of subscribe event.
639     * @param { Callback<Record<string, CommandDataType>> } [callback] - optional,
640     * indicates the callback of off('privateCommand').
641     * @throws { BusinessError } 12800010 - not the preconfigured default input method.
642     * @syscap SystemCapability.MiscServices.InputMethodFramework
643     * @since 12
644     */
645    off(type: 'privateCommand', callback?: Callback<Record<string, CommandDataType>>): void;
646
647    /**
648     * Subscribe 'callingDisplayDidChange' event.
649     *
650     * @param { 'callingDisplayDidChange' } type - indicates the type of subscribe event.
651     * @param { Callback<number> } callback - indicates the callback of on('callingDisplayDidChange').
652     * @throws { BusinessError } 801 - capability not supported.
653     * @syscap SystemCapability.MiscServices.InputMethodFramework
654     * @since 18
655     */
656    on(type: 'callingDisplayDidChange', callback: Callback<number>): void;
657
658    /**
659     * Unsubscribe 'callingDisplayDidChange' event.
660     *
661     * @param { 'callingDisplayDidChange' } type - indicates the type of subscribe event.
662     * @param { Callback<number> } [callback] - optional, indicates the callback of off('callingDisplayDidChange').
663     * @syscap SystemCapability.MiscServices.InputMethodFramework
664     * @since 18
665     */
666    off(type: 'callingDisplayDidChange', callback?: Callback<number>): void;
667
668    /**
669     * Get input method's security mode.
670     *
671     * @returns { SecurityMode } return security mode.
672     * @throws { BusinessError } 12800004 - not an input method.
673     * @syscap SystemCapability.MiscServices.InputMethodFramework
674     * @since 11
675     */
676    getSecurityMode(): SecurityMode;
677
678    /**
679     * Creates a panel.
680     * <p>The system only allows one soft keyboard and one status bar to be created.</p>
681     *
682     * @param { BaseContext } ctx - indicates the context on which the window depends.
683     * @param { PanelInfo } info - the info of panel to be created.
684     * @param { AsyncCallback<Panel> } callback - the callback of createPanel.
685     * @throws { BusinessError } 401 - parameter error. Possible causes:
686     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types;
687     * @throws { BusinessError } 12800004 - not an input method.
688     * @syscap SystemCapability.MiscServices.InputMethodFramework
689     * @since 10
690     */
691    createPanel(ctx: BaseContext, info: PanelInfo, callback: AsyncCallback<Panel>): void;
692
693    /**
694     * Creates a panel.
695     * <p>The system only allows one soft keyboard and one status bar to be created.</p>
696     *
697     * @param { BaseContext } ctx - indicates the context on which the window depends.
698     * @param { PanelInfo } info - the info of panel to be created.
699     * @returns { Promise<Panel> } the promise returned by the function.
700     * @throws { BusinessError } 401 - parameter error. Possible causes:
701     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types;
702     * @throws { BusinessError } 12800004 - not an input method.
703     * @syscap SystemCapability.MiscServices.InputMethodFramework
704     * @since 10
705     */
706    createPanel(ctx: BaseContext, info: PanelInfo): Promise<Panel>;
707
708    /**
709     * Destroys a panel.
710     *
711     * @param { Panel } panel - to be destroyed.
712     * @param { AsyncCallback<void> } callback - the callback of destroyPanel.
713     * @throws { BusinessError } 401 - parameter error. Possible causes:
714     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
715     * @syscap SystemCapability.MiscServices.InputMethodFramework
716     * @since 10
717     */
718    destroyPanel(panel: Panel, callback: AsyncCallback<void>): void;
719
720    /**
721     * Destroys a panel.
722     *
723     * @param { Panel } panel - to be destroyed.
724     * @returns { Promise<void> } the promise returned by the function.
725     * @throws { BusinessError } 401 - parameter error. Possible causes:
726     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
727     * @syscap SystemCapability.MiscServices.InputMethodFramework
728     * @since 10
729     */
730    destroyPanel(panel: Panel): Promise<void>;
731  }
732
733  /**
734   * @interface TextInputClient
735   * @syscap SystemCapability.MiscServices.InputMethodFramework
736   * @since 8
737   * @deprecated since 9
738   * @useinstead inputMethodEngine#InputClient
739   */
740  interface TextInputClient {
741    /**
742     * @param { number } action - action indicates the function of "enter" key.
743     * @param { AsyncCallback<boolean> } callback - the callback of sendKeyFunction.
744     * @syscap SystemCapability.MiscServices.InputMethodFramework
745     * @since 8
746     * @deprecated since 9
747     * @useinstead inputMethodEngine.InputClient#sendKeyFunction
748     */
749    sendKeyFunction(action: number, callback: AsyncCallback<boolean>): void;
750
751    /**
752     * @param { number } action - action indicates the function of "enter" key.
753     * @returns { Promise<boolean> } the promise returned by the function.
754     * @syscap SystemCapability.MiscServices.InputMethodFramework
755     * @since 8
756     * @deprecated since 9
757     * @useinstead inputMethodEngine.InputClient#sendKeyFunction
758     */
759    sendKeyFunction(action: number): Promise<boolean>;
760
761    /**
762     * @param { number } length - length of text which will be deleted forward.
763     * @param { AsyncCallback<boolean> } callback - the callback of deleteForward.
764     * @syscap SystemCapability.MiscServices.InputMethodFramework
765     * @since 8
766     * @deprecated since 9
767     * @useinstead inputMethodEngine.InputClient#deleteForward
768     */
769    deleteForward(length: number, callback: AsyncCallback<boolean>): void;
770
771    /**
772     * @param { number } length - length of text which will be deleted forward.
773     * @returns { Promise<boolean> } the promise returned by the function.
774     * @syscap SystemCapability.MiscServices.InputMethodFramework
775     * @since 8
776     * @deprecated since 9
777     * @useinstead inputMethodEngine.InputClient#deleteForward
778     */
779    deleteForward(length: number): Promise<boolean>;
780
781    /**
782     * @param { number } length - length of text which will be deleted backward.
783     * @param { AsyncCallback<boolean> } callback - the callback of deleteBackward.
784     * @syscap SystemCapability.MiscServices.InputMethodFramework
785     * @since 8
786     * @deprecated since 9
787     * @useinstead inputMethodEngine.InputClient#deleteBackward
788     */
789    deleteBackward(length: number, callback: AsyncCallback<boolean>): void;
790
791    /**
792     * @param { number } length - length of text which will be deleted backward.
793     * @returns { Promise<boolean> } the promise returned by the function.
794     * @syscap SystemCapability.MiscServices.InputMethodFramework
795     * @since 8
796     * @deprecated since 9
797     * @useinstead inputMethodEngine.InputClient#deleteBackward
798     */
799    deleteBackward(length: number): Promise<boolean>;
800
801    /**
802     * @param { string } text - text which will be inserted.
803     * @param { AsyncCallback<boolean> } callback - the callback of insertText.
804     * @syscap SystemCapability.MiscServices.InputMethodFramework
805     * @since 8
806     * @deprecated since 9
807     * @useinstead inputMethodEngine.InputClient#insertText
808     */
809    insertText(text: string, callback: AsyncCallback<boolean>): void;
810
811    /**
812     * @param { string } text - text which will be inserted.
813     * @returns { Promise<boolean> } the promise returned by the function
814     * @syscap SystemCapability.MiscServices.InputMethodFramework
815     * @since 8
816     * @deprecated since 9
817     * @useinstead inputMethodEngine.InputClient#insertText
818     */
819    insertText(text: string): Promise<boolean>;
820
821    /**
822     * @param { number } length - the length of text which will be got.
823     * @param { AsyncCallback<string> } callback - the callback of getForward.
824     * @syscap SystemCapability.MiscServices.InputMethodFramework
825     * @since 8
826     * @deprecated since 9
827     * @useinstead inputMethodEngine.InputClient#getForward
828     */
829    getForward(length: number, callback: AsyncCallback<string>): void;
830
831    /**
832     * @param { number } length - the length of text which will be got.
833     * @returns { Promise<string> } the promise returned by the function
834     * @syscap SystemCapability.MiscServices.InputMethodFramework
835     * @since 8
836     * @deprecated since 9
837     * @useinstead inputMethodEngine.InputClient#getForward
838     */
839    getForward(length: number): Promise<string>;
840
841    /**
842     * @param { number } length - the length of text which will be got.
843     * @param { AsyncCallback<string> } callback - the callback of getBackward.
844     * @syscap SystemCapability.MiscServices.InputMethodFramework
845     * @since 8
846     * @deprecated since 9
847     * @useinstead inputMethodEngine.InputClient#getBackward
848     */
849    getBackward(length: number, callback: AsyncCallback<string>): void;
850
851    /**
852     * @param { number } length - the length of text which will be got.
853     * @returns { Promise<string> } the promise returned by the function.
854     * @syscap SystemCapability.MiscServices.InputMethodFramework
855     * @since 8
856     * @deprecated since 9
857     * @useinstead inputMethodEngine.InputClient#getBackward
858     */
859    getBackward(length: number): Promise<string>;
860
861    /**
862     * @param { AsyncCallback<EditorAttribute> } callback - the callback of getEditorAttribute.
863     * @syscap SystemCapability.MiscServices.InputMethodFramework
864     * @since 8
865     * @deprecated since 9
866     * @useinstead inputMethodEngine.InputClient#getEditorAttribute
867     */
868    getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void;
869
870    /**
871     * @returns { Promise<EditorAttribute> } the promise returned by the function.
872     * @syscap SystemCapability.MiscServices.InputMethodFramework
873     * @since 8
874     * @deprecated since 9
875     * @useinstead inputMethodEngine.InputClient#getEditorAttribute
876     */
877    getEditorAttribute(): Promise<EditorAttribute>;
878  }
879
880  /**
881   * Control events about Editor.
882   *
883   * @interface InputClient
884   * @syscap SystemCapability.MiscServices.InputMethodFramework
885   * @since 9
886   */
887  interface InputClient {
888    /**
889     * Send the function of the key.
890     *
891     * @param { number } action - action indicates the function of "enter" key.
892     * @param { AsyncCallback<boolean> } callback - the callback of sendKeyFunction.
893     * @throws { BusinessError } 401 - parameter error. Possible causes:
894     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
895     * @throws { BusinessError } 12800003 - input method client error.
896     * @syscap SystemCapability.MiscServices.InputMethodFramework
897     * @since 9
898     */
899    sendKeyFunction(action: number, callback: AsyncCallback<boolean>): void;
900
901    /**
902     * Send the function of the key.
903     *
904     * @param { number } action - action indicates the function of "enter" key.
905     * @returns { Promise<boolean> } the promise returned by the function.
906     * @throws { BusinessError } 401 - parameter error. Possible causes:
907     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
908     * @throws { BusinessError } 12800003 - input method client error.
909     * @syscap SystemCapability.MiscServices.InputMethodFramework
910     * @since 9
911     */
912    sendKeyFunction(action: number): Promise<boolean>;
913
914    /**
915     * Delete text forward.
916     *
917     * @param { number } length - length of text which will be deleted forward. It can't be less than 0.
918     * @param { AsyncCallback<boolean> } callback - the callback of deleteForward.
919     * @throws { BusinessError } 401 - parameter error. Possible causes:
920     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
921     * @throws { BusinessError } 12800002 - Input method engine error.
922     * @throws { BusinessError } 12800003 - input method client error.
923     * @syscap SystemCapability.MiscServices.InputMethodFramework
924     * @since 9
925     */
926    deleteForward(length: number, callback: AsyncCallback<boolean>): void;
927
928    /**
929     * Delete text forward.
930     *
931     * @param { number } length - length of text which will be deleted forward. It can't be less than 0.
932     * @returns { Promise<boolean> } the promise returned by the function.
933     * @throws { BusinessError } 401 - parameter error. Possible causes:
934     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
935     * @throws { BusinessError } 12800002 - Input method engine error.
936     * @throws { BusinessError } 12800003 - input method client error.
937     * @syscap SystemCapability.MiscServices.InputMethodFramework
938     * @since 9
939     */
940    deleteForward(length: number): Promise<boolean>;
941
942    /**
943     * Delete text forward.
944     *
945     * @param { number } length - length of text which will be deleted forward. It can't be less than 0.
946     * @throws { BusinessError } 401 - parameter error. Possible causes:
947     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
948     * @throws { BusinessError } 12800002 - input method engine error.
949     * @throws { BusinessError } 12800003 - input method client error.
950     * @syscap SystemCapability.MiscServices.InputMethodFramework
951     * @since 10
952     */
953    deleteForwardSync(length: number): void;
954
955    /**
956     * Delete text backward.
957     *
958     * @param { number } length - length of text which will be deleted backward. It can't be less than 0.
959     * @param { AsyncCallback<boolean> } callback - the callback of deleteBackward.
960     * @throws { BusinessError } 401 - parameter error. Possible causes:
961     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
962     * @throws { BusinessError } 12800002 - Input method engine error.
963     * @throws { BusinessError } 12800003 - input method client error.
964     * @syscap SystemCapability.MiscServices.InputMethodFramework
965     * @since 9
966     */
967    deleteBackward(length: number, callback: AsyncCallback<boolean>): void;
968
969    /**
970     * Delete text backward.
971     *
972     * @param { number } length - length of text which will be deleted backward. It can't be less than 0.
973     * @returns { Promise<boolean> } the promise returned by the function.
974     * @throws { BusinessError } 401 - parameter error. Possible causes:
975     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
976     * @throws { BusinessError } 12800002 - Input method engine error.
977     * @throws { BusinessError } 12800003 - input method client error.
978     * @syscap SystemCapability.MiscServices.InputMethodFramework
979     * @since 9
980     */
981    deleteBackward(length: number): Promise<boolean>;
982
983    /**
984     * Delete text backward.
985     *
986     * @param { number } length - length of text which will be deleted backward. It can't be less than 0.
987     * @throws { BusinessError } 401 - parameter error. Possible causes:
988     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
989     * @throws { BusinessError } 12800002 - input method engine error.
990     * @throws { BusinessError } 12800003 - input method client error.
991     * @syscap SystemCapability.MiscServices.InputMethodFramework
992     * @since 10
993     */
994    deleteBackwardSync(length: number): void;
995
996    /**
997     * Insert text into Editor.
998     *
999     * @param { string } text - text which will be inserted.
1000     * @param { AsyncCallback<boolean> } callback - the callback of insertText.
1001     * @throws { BusinessError } 401 - parameter error. Possible causes:
1002     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
1003     * @throws { BusinessError } 12800002 - Input method engine error.
1004     * @throws { BusinessError } 12800003 - input method client error.
1005     * @syscap SystemCapability.MiscServices.InputMethodFramework
1006     * @since 9
1007     */
1008    insertText(text: string, callback: AsyncCallback<boolean>): void;
1009
1010    /**
1011     * Insert text into Editor.
1012     *
1013     * @param { string } text - text which will be inserted.
1014     * @returns { Promise<boolean> } the promise returned by the function.
1015     * @throws { BusinessError } 401 - parameter error. Possible causes:
1016     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
1017     * @throws { BusinessError } 12800002 - Input method engine error.
1018     * @throws { BusinessError } 12800003 - input method client error.
1019     * @syscap SystemCapability.MiscServices.InputMethodFramework
1020     * @since 9
1021     */
1022    insertText(text: string): Promise<boolean>;
1023
1024    /**
1025     * Insert text into Editor.
1026     *
1027     * @param { string } text - text which will be inserted.
1028     * @throws { BusinessError } 401 - parameter error. Possible causes:
1029     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
1030     * @throws { BusinessError } 12800002 - input method engine error.
1031     * @throws { BusinessError } 12800003 - input method client error.
1032     * @syscap SystemCapability.MiscServices.InputMethodFramework
1033     * @since 10
1034     */
1035    insertTextSync(text: string): void;
1036
1037    /**
1038     * Get the text before cursor.
1039     *
1040     * @param { number } length - the length of text which will be got. It can't be less than 0.
1041     * @param { AsyncCallback<string> } callback - the callback of getForward.
1042     * @throws { BusinessError } 401 - parameter error. Possible causes:
1043     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
1044     * @throws { BusinessError } 12800003 - input method client error.
1045     * @throws { BusinessError } 12800006 - Input method controller error.
1046     * @syscap SystemCapability.MiscServices.InputMethodFramework
1047     * @since 9
1048     */
1049    getForward(length: number, callback: AsyncCallback<string>): void;
1050
1051    /**
1052     * Get the text before cursor.
1053     *
1054     * @param { number } length - the length of text which will be got. It can't be less than 0.
1055     * @returns { Promise<string> } the promise returned by the function.
1056     * @throws { BusinessError } 401 - parameter error. Possible causes:
1057     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
1058     * @throws { BusinessError } 12800003 - input method client error.
1059     * @throws { BusinessError } 12800006 - Input method controller error.
1060     * @syscap SystemCapability.MiscServices.InputMethodFramework
1061     * @since 9
1062     */
1063    getForward(length: number): Promise<string>;
1064
1065    /**
1066     * Get the text before cursor.
1067     *
1068     * @param { number } length - the length of text which will be got. It can't be less than 0.
1069     * @returns { string } the text string before cursor.
1070     * @throws { BusinessError } 401 - parameter error. Possible causes:
1071     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1072     * @throws { BusinessError } 12800003 - input method client error.
1073     * @throws { BusinessError } 12800006 - input method controller error.
1074     * @syscap SystemCapability.MiscServices.InputMethodFramework
1075     * @since 10
1076     */
1077    getForwardSync(length: number): string;
1078
1079    /**
1080     * Get the text after cursor.
1081     *
1082     * @param { number } length - the length of text which will be got.It can't be less than 0.
1083     * @param { AsyncCallback<string> } callback - the callback of getBackward.
1084     * @throws { BusinessError } 401 - parameter error. Possible causes:
1085     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
1086     * @throws { BusinessError } 12800003 - input method client error.
1087     * @throws { BusinessError } 12800006 - Input method controller error.
1088     * @syscap SystemCapability.MiscServices.InputMethodFramework
1089     * @since 9
1090     */
1091    getBackward(length: number, callback: AsyncCallback<string>): void;
1092
1093    /**
1094     * Get the text after cursor.
1095     *
1096     * @param { number } length - the length of text which will be got.It can't be less than 0.
1097     * @returns { Promise<string> } the promise returned by the function.
1098     * @throws { BusinessError } 401 - parameter error. Possible causes:
1099     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
1100     * @throws { BusinessError } 12800003 - input method client error.
1101     * @throws { BusinessError } 12800006 - Input method controller error.
1102     * @syscap SystemCapability.MiscServices.InputMethodFramework
1103     * @since 9
1104     */
1105    getBackward(length: number): Promise<string>;
1106
1107    /**
1108     * Get the text after cursor.
1109     *
1110     * @param { number } length - the length of text which will be got. It can't be less than 0.
1111     * @returns { string } the text string after cursor.
1112     * @throws { BusinessError } 401 - parameter error. Possible causes:
1113     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1114     * @throws { BusinessError } 12800003 - input method client error.
1115     * @throws { BusinessError } 12800006 - input method controller error.
1116     * @syscap SystemCapability.MiscServices.InputMethodFramework
1117     * @since 10
1118     */
1119    getBackwardSync(length: number): string;
1120
1121    /**
1122     * Get attribute about editor.
1123     *
1124     * @param { AsyncCallback<EditorAttribute> } callback - the callback of getEditorAttribute.
1125     * @throws { BusinessError } 12800003 - input method client error.
1126     * @syscap SystemCapability.MiscServices.InputMethodFramework
1127     * @since 9
1128     */
1129    getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void;
1130
1131    /**
1132     * Get attribute about editor.
1133     *
1134     * @returns { Promise<EditorAttribute> } the promise returned by the function.
1135     * @throws { BusinessError } 12800003 - input method client error.
1136     * @syscap SystemCapability.MiscServices.InputMethodFramework
1137     * @since 9
1138     */
1139    getEditorAttribute(): Promise<EditorAttribute>;
1140
1141    /**
1142     * Get attribute about editor.
1143     *
1144     * @returns { EditorAttribute } the attribute of editor.
1145     * @throws { BusinessError } 12800003 - input method client error.
1146     * @syscap SystemCapability.MiscServices.InputMethodFramework
1147     * @since 10
1148     */
1149    getEditorAttributeSync(): EditorAttribute;
1150
1151    /**
1152     * Move cursor from input method.
1153     *
1154     * @param { number } direction - Indicates the distance of cursor to be moved. It can't be less than 0.
1155     * @param { AsyncCallback<void> } callback - the callback of moveCursor.
1156     * @throws { BusinessError } 401 - parameter error. Possible causes:
1157     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1158     * @throws { BusinessError } 12800003 - input method client error.
1159     * @syscap SystemCapability.MiscServices.InputMethodFramework
1160     * @since 9
1161     */
1162    moveCursor(direction: number, callback: AsyncCallback<void>): void;
1163
1164    /**
1165     * Move cursor from input method.
1166     *
1167     * @param { number } direction - Indicates the distance of cursor to be moved. It can't be less than 0.
1168     * @returns { Promise<void> } the promise returned by the function.
1169     * @throws { BusinessError } 401 - parameter error. Possible causes:
1170     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1171     * @throws { BusinessError } 12800003 - input method client error.
1172     * @syscap SystemCapability.MiscServices.InputMethodFramework
1173     * @since 9
1174     */
1175    moveCursor(direction: number): Promise<void>;
1176
1177    /**
1178     * Move cursor from input method.
1179     *
1180     * @param { number } direction - Indicates the distance of cursor to be moved. It can't be less than 0.
1181     * @throws { BusinessError } 401 - parameter error. Possible causes:
1182     *    1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1183     * @throws { BusinessError } 12800003 - input method client error.
1184     * @syscap SystemCapability.MiscServices.InputMethodFramework
1185     * @since 10
1186     */
1187    moveCursorSync(direction: number): void;
1188
1189    /**
1190     * Select text in editor by range.
1191     *
1192     * @param { Range } range - indicates the range of selected text in editor.
1193     * @param { AsyncCallback<void> } callback - the callback of selectByRange.
1194     * @throws { BusinessError } 401 - parameter error. Possible causes:
1195     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1196     * @throws { BusinessError } 12800003 - input method client error.
1197     * @syscap SystemCapability.MiscServices.InputMethodFramework
1198     * @since 10
1199     */
1200    selectByRange(range: Range, callback: AsyncCallback<void>): void;
1201
1202    /**
1203     * Select text in editor by range.
1204     *
1205     * @param { Range } range - indicates the range of selected text in editor.
1206     * @returns { Promise<void> } the promise returned by the function.
1207     * @throws { BusinessError } 401 - parameter error. Possible causes:
1208     *    1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1209     * @throws { BusinessError } 12800003 - input method client error.
1210     * @syscap SystemCapability.MiscServices.InputMethodFramework
1211     * @since 10
1212     */
1213    selectByRange(range: Range): Promise<void>;
1214
1215    /**
1216     * Select text in editor by range.
1217     *
1218     * @param { Range } range - indicates the range of selected text in editor.
1219     * @throws { BusinessError } 401 - parameter error. Possible causes:
1220     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1221     * @throws { BusinessError } 12800003 - input method client error.
1222     * @syscap SystemCapability.MiscServices.InputMethodFramework
1223     * @since 10
1224     */
1225    selectByRangeSync(range: Range): void;
1226
1227    /**
1228     * Select text in editor by cursor movement.
1229     *
1230     * @param { Movement } movement - indicates the movement of cursor when selecting.
1231     * @param { AsyncCallback<void> } callback - the callback of selectByMovement.
1232     * @throws { BusinessError } 401 - parameter error. Possible causes:
1233     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1234     * @throws { BusinessError } 12800003 - input method client error.
1235     * @syscap SystemCapability.MiscServices.InputMethodFramework
1236     * @since 10
1237     */
1238    selectByMovement(movement: Movement, callback: AsyncCallback<void>): void;
1239
1240    /**
1241     * Select text in editor by cursor movement.
1242     *
1243     * @param { Movement } movement - indicates the movement of cursor when selecting.
1244     * @returns { Promise<void> } the promise returned by the function.
1245     * @throws { BusinessError } 401 - parameter error. Possible causes:
1246     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1247     * @throws { BusinessError } 12800003 - input method client error.
1248     * @syscap SystemCapability.MiscServices.InputMethodFramework
1249     * @since 10
1250     */
1251    selectByMovement(movement: Movement): Promise<void>;
1252
1253    /**
1254     * Select text in editor by cursor movement.
1255     *
1256     * @param { Movement } movement - indicates the movement of cursor when selecting.
1257     * @throws { BusinessError } 401 - parameter error. Possible causes:
1258     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
1259     * @throws { BusinessError } 12800003 - input method client error.
1260     * @syscap SystemCapability.MiscServices.InputMethodFramework
1261     * @since 10
1262     */
1263    selectByMovementSync(movement: Movement): void;
1264
1265    /**
1266     * Get the index number of text at cursor.
1267     *
1268     * @param { AsyncCallback<number> } callback - the callback of getTextIndexAtCursor, number represents the index
1269     *        number of text at cursor.
1270     * @throws { BusinessError } 12800003 - input method client error.
1271     * @throws { BusinessError } 12800006 - Input method controller error.
1272     * @syscap SystemCapability.MiscServices.InputMethodFramework
1273     * @since 10
1274     */
1275    getTextIndexAtCursor(callback: AsyncCallback<number>): void;
1276
1277    /**
1278     * Get the index number of text at cursor.
1279     *
1280     * @returns { Promise<number> } the promise returned by the function, number represents the index number of text
1281     *          at cursor.
1282     * @throws { BusinessError } 12800003 - input method client error.
1283     * @throws { BusinessError } 12800006 - Input method controller error.
1284     * @syscap SystemCapability.MiscServices.InputMethodFramework
1285     * @since 10
1286     */
1287    getTextIndexAtCursor(): Promise<number>;
1288
1289    /**
1290     * Get the index number of text at cursor.
1291     *
1292     * @returns { number } the index number of text at cursor.
1293     * @throws { BusinessError } 12800003 - input method client error.
1294     * @throws { BusinessError } 12800006 - Input method controller error.
1295     * @syscap SystemCapability.MiscServices.InputMethodFramework
1296     * @since 10
1297     */
1298    getTextIndexAtCursorSync(): number;
1299
1300    /**
1301     * Send extend action code.
1302     *
1303     * @param { ExtendAction } action - action code which will be send.
1304     * @param { AsyncCallback<void> } callback - the callback of sendExtendAction.
1305     * @throws { BusinessError } 401 - parameter error. Possible causes:
1306     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types
1307     * @throws { BusinessError } 12800003 - input method client error.
1308     * @throws { BusinessError } 12800006 - Input method controller error.
1309     * @syscap SystemCapability.MiscServices.InputMethodFramework
1310     * @since 10
1311     */
1312    sendExtendAction(action: ExtendAction, callback: AsyncCallback<void>): void;
1313
1314    /**
1315     * Send extend action code.
1316     *
1317     * @param { ExtendAction } action - action code which will be send.
1318     * @returns { Promise<void> } the promise returned by the function.
1319     * @throws { BusinessError } 401 - parameter error. Possible causes:
1320     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types
1321     * @throws { BusinessError } 12800003 - input method client error.
1322     * @throws { BusinessError } 12800006 - Input method controller error.
1323     * @syscap SystemCapability.MiscServices.InputMethodFramework
1324     * @since 10
1325     */
1326    sendExtendAction(action: ExtendAction): Promise<void>;
1327
1328    /**
1329     * Send private command.This function can only be called by default input method configured by system.
1330     *
1331     * @param { Record<string, CommandDataType> } commandData - command data which will be send.Max size 32KB.
1332     * @returns { Promise<void> } the promise returned by the function.
1333     * @throws { BusinessError } 401 - parameter error. Possible causes:
1334     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1335     * @throws { BusinessError } 12800003 - input method client error.
1336     * @throws { BusinessError } 12800010 - not the preconfigured default input method.
1337     * @syscap SystemCapability.MiscServices.InputMethodFramework
1338     * @since 12
1339     */
1340    sendPrivateCommand(commandData: Record<string, CommandDataType>): Promise<void>;
1341
1342    /**
1343     * Get info of the calling window.
1344     *
1345     * @returns { Promise<WindowInfo> } the promise returned by the function.
1346     * @throws { BusinessError } 12800003 - input method client error.
1347     * @throws { BusinessError } 12800012 - the input method panel does not exist.
1348     * @throws { BusinessError } 12800013 - window manager service error.
1349     * @syscap SystemCapability.MiscServices.InputMethodFramework
1350     * @since 12
1351     */
1352    getCallingWindowInfo(): Promise<WindowInfo>;
1353
1354    /**
1355     * Insert the provided text as preview text.
1356     *
1357     * @param { string } text - the text to be previewed.
1358     * @param { Range } range - the range of the text to be replaced by the preview text.
1359     * @returns { Promise<void> } the promise returned by the function.
1360     * @throws { BusinessError } 401 - parameter error. Possible causes:
1361     *    1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1362     * @throws { BusinessError } 12800003 - input method client error.
1363     * @throws { BusinessError } 12800011 - text preview not supported.
1364     * @syscap SystemCapability.MiscServices.InputMethodFramework
1365     * @since 12
1366     */
1367    setPreviewText(text: string, range: Range): Promise<void>;
1368
1369    /**
1370     * Insert the provided text as preview text.
1371     *
1372     * @param { string } text - the text to be previewed.
1373     * @param { Range } range - the range of the text to be replaced by the preview text.
1374     * @throws { BusinessError } 401 - parameter error. Possible causes:
1375     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1376     * @throws { BusinessError } 12800003 - input method client error.
1377     * @throws { BusinessError } 12800011 - text preview not supported.
1378     * @syscap SystemCapability.MiscServices.InputMethodFramework
1379     * @since 12
1380     */
1381    setPreviewTextSync(text: string, range: Range): void;
1382
1383    /**
1384     * Finish the text preview.
1385     *
1386     * @returns { Promise<void> } the promise returned by the function.
1387     * @throws { BusinessError } 12800003 - input method client error.
1388     * @throws { BusinessError } 12800011 - text preview not supported.
1389     * @syscap SystemCapability.MiscServices.InputMethodFramework
1390     * @since 12
1391     */
1392    finishTextPreview(): Promise<void>;
1393
1394    /**
1395     * Finish the text preview.
1396     *
1397     * @throws { BusinessError } 12800003 - input method client error.
1398     * @throws { BusinessError } 12800011 - text preview not supported.
1399     * @syscap SystemCapability.MiscServices.InputMethodFramework
1400     * @since 12
1401     */
1402    finishTextPreviewSync(): void;
1403
1404    /**
1405     * Send message to edit box.
1406     *
1407     * @param { string } msgId - the identifier of the message. Max size is 256B.
1408     * @param { ?ArrayBuffer } [msgParam] - the param of the custom message. Max size is 128KB.
1409     * @returns { Promise<void> } the promise returned by the function.
1410     * @throws { BusinessError } 401 - parameter error. Possible causes:
1411     *     1. Incorrect parameter types. 2. Incorrect parameter length.
1412     * @throws { BusinessError } 12800003 - input method client error.
1413     * @throws { BusinessError } 12800009 - input method client detached.
1414     * @throws { BusinessError } 12800014 - the input method is in basic mode.
1415     * @throws { BusinessError } 12800015 - the other side does not accept the request.
1416     * @throws { BusinessError } 12800016 - input method client is not editable.
1417     * @syscap SystemCapability.MiscServices.InputMethodFramework
1418     * @since 15
1419     */
1420    sendMessage(msgId: string, msgParam?: ArrayBuffer): Promise<void>;
1421
1422    /**
1423     * Start receiving message from edit box.
1424     *
1425     * @param { ?MessageHandler } [msgHandler] - optional, the handler of the custom message.
1426     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Incorrect parameter types.
1427     * @syscap SystemCapability.MiscServices.InputMethodFramework
1428     * @since 15
1429     */
1430    recvMessage(msgHandler?: MessageHandler): void;
1431  }
1432
1433  /**
1434   * @interface KeyboardDelegate
1435   * @syscap SystemCapability.MiscServices.InputMethodFramework
1436   * @since 8
1437   */
1438  interface KeyboardDelegate {
1439    /**
1440     * Subscribe key up or down event
1441     *
1442     * @param { 'keyDown' | 'keyUp' } type - indicates the type of subscribe event.
1443     * @param { function } callback - indicates the callback function of on('keyDown'|'keyUp').
1444     * @syscap SystemCapability.MiscServices.InputMethodFramework
1445     * @since 8
1446     */
1447    on(type: 'keyDown' | 'keyUp', callback: (event: KeyEvent) => boolean): void;
1448
1449    /**
1450     * Unsubscribe key up or down event
1451     *
1452     * @param { 'keyDown' | 'keyUp' } type - indicates the type of unsubscribe event.
1453     * @param { function } [callback] - optional, indicates the callback function of off('keyDown'|'keyUp').
1454     * @syscap SystemCapability.MiscServices.InputMethodFramework
1455     * @since 8
1456     */
1457    off(type: 'keyDown' | 'keyUp', callback?: (event: KeyEvent) => boolean): void;
1458
1459    /**
1460     * Subscribe key event.
1461     *
1462     * @param { 'keyEvent' } type - indicates the type of subscribe event.
1463     * @param { function } callback - indicates the callback function of on('keyEvent').
1464     *     If the key is processed by event subscriber, callback should be return true, else return false.
1465     * @syscap SystemCapability.MiscServices.InputMethodFramework
1466     * @since 10
1467     */
1468    on(type: 'keyEvent', callback: (event: InputKeyEvent) => boolean): void;
1469
1470    /**
1471     * Unsubscribe key event.
1472     *
1473     * @param { 'keyEvent' } type - indicates the type of unsubscribe event.
1474     * @param { function } [callback] - optional, indicates the callback function of off('keyEvent').
1475     * @syscap SystemCapability.MiscServices.InputMethodFramework
1476     * @since 10
1477     */
1478    off(type: 'keyEvent', callback?: (event: InputKeyEvent) => boolean): void;
1479
1480    /**
1481     * Subscribe cursor context change
1482     *
1483     * @param { 'cursorContextChange' } type - indicates the type of subscribe event.
1484     * @param { function } callback - indicates the callback function of on('cursorContextChange').
1485     * @syscap SystemCapability.MiscServices.InputMethodFramework
1486     * @since 8
1487     */
1488    on(type: 'cursorContextChange', callback: (x: number, y: number, height: number) => void): void;
1489
1490    /**
1491     * Unsubscribe cursor context change
1492     *
1493     * @param { 'cursorContextChange' } type - indicates the type of unsubscribe event.
1494     * @param { function } [callback] - optional, indicates the callback function of off('cursorContextChange').
1495     * @syscap SystemCapability.MiscServices.InputMethodFramework
1496     * @since 8
1497     */
1498    off(type: 'cursorContextChange', callback?: (x: number, y: number, height: number) => void): void;
1499
1500    /**
1501     * Subscribe selection change
1502     *
1503     * @param { 'selectionChange' } type - indicates the type of subscribe event.
1504     * @param { function } callback - indicates the callback function
1505     * of on('selectionChange').
1506     * @syscap SystemCapability.MiscServices.InputMethodFramework
1507     * @since 8
1508     */
1509    on(
1510      type: 'selectionChange',
1511      callback: (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void
1512    ): void;
1513
1514    /**
1515     * Unsubscribe selection change
1516     *
1517     * @param { 'selectionChange' } type - indicates the type of unsubscribe event.
1518     * @param { function } [callback] - optional,
1519     * indicates the callback function of off('selectionChange').
1520     * @syscap SystemCapability.MiscServices.InputMethodFramework
1521     * @since 8
1522     */
1523    off(
1524      type: 'selectionChange',
1525      callback?: (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void
1526    ): void;
1527
1528    /**
1529     * Subscribe text change
1530     *
1531     * @param { 'textChange' } type - indicates the type of subscribe event.
1532     * @param { function } callback - indicates the callback function of on('textChange').
1533     * @syscap SystemCapability.MiscServices.InputMethodFramework
1534     * @since 8
1535     */
1536    on(type: 'textChange', callback: (text: string) => void): void;
1537
1538    /**
1539     * Unsubscribe text change
1540     *
1541     * @param { 'textChange' } type - indicates the type of unsubscribe event.
1542     * @param { function } [callback] - optional, indicates the callback function of off('textChange').
1543     * @syscap SystemCapability.MiscServices.InputMethodFramework
1544     * @since 8
1545     */
1546    off(type: 'textChange', callback?: (text: string) => void): void;
1547
1548    /**
1549     * Subscribe input text attribute change
1550     *
1551     * @param { 'editorAttributeChanged' } type - indicates the type of subscribe event.
1552     * @param { function } callback - indicates the callback function of on('editorAttributeChanged').
1553     * @syscap SystemCapability.MiscServices.InputMethodFramework
1554     * @since 10
1555     */
1556    on(type: 'editorAttributeChanged', callback: (attr: EditorAttribute) => void): void;
1557
1558    /**
1559     * Unsubscribe input text attribute change
1560     *
1561     * @param { 'editorAttributeChanged' } type - indicates the type of subscribe event.
1562     * @param { function } [callback] - indicates the callback function of off('editorAttributeChanged').
1563     * @syscap SystemCapability.MiscServices.InputMethodFramework
1564     * @since 10
1565     */
1566    off(type: 'editorAttributeChanged', callback?: (attr: EditorAttribute) => void): void;
1567  }
1568
1569  /**
1570   * Defines the immersive mode.
1571   *
1572   * @enum { number }
1573   * @syscap SystemCapability.MiscServices.InputMethodFramework
1574   * @since 15
1575   */
1576  export enum ImmersiveMode {
1577    /**
1578     * Default immersive mode, the panel is not in immersive mode.
1579     *
1580     * @syscap SystemCapability.MiscServices.InputMethodFramework
1581     * @since 15
1582     */
1583    NONE_IMMERSIVE = 0,
1584
1585    /**
1586     * Immersive mode.
1587     *
1588     * @syscap SystemCapability.MiscServices.InputMethodFramework
1589     * @since 15
1590     */
1591    IMMERSIVE,
1592
1593    /**
1594     * Light immersive mode.
1595     *
1596     * @syscap SystemCapability.MiscServices.InputMethodFramework
1597     * @since 15
1598     */
1599    LIGHT_IMMERSIVE,
1600
1601    /**
1602     * Dark immersive mode.
1603     *
1604     * @syscap SystemCapability.MiscServices.InputMethodFramework
1605     * @since 15
1606     */
1607    DARK_IMMERSIVE
1608  }
1609
1610  /**
1611   * A panel is a container used to hold soft keyboard, candidate list, or status bar.
1612   *
1613   * @interface Panel
1614   * @syscap SystemCapability.MiscServices.InputMethodFramework
1615   * @since 10
1616   */
1617  interface Panel {
1618    /**
1619     * Sets ui content.
1620     * <p>When this method is executed successfully, the content of panel will be replaced.</p>
1621     *
1622     * @param { string } path - the path of ui content.
1623     * @param { AsyncCallback<void> } callback - the callback of setUiContent.
1624     * @throws { BusinessError } 401 - parameter error. Possible causes:
1625     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1626     * @syscap SystemCapability.MiscServices.InputMethodFramework
1627     * @since 10
1628     */
1629    setUiContent(path: string, callback: AsyncCallback<void>): void;
1630
1631    /**
1632     * Sets ui content.
1633     * <p>When this method is executed successfully, the content of panel will be replaced.</p>
1634     *
1635     * @param { string } path - the path of ui content.
1636     * @returns { Promise<void> } the promise returned by the function.
1637     * @throws { BusinessError } 401 - parameter error. Possible causes:
1638     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1639     * @syscap SystemCapability.MiscServices.InputMethodFramework
1640     * @since 10
1641     */
1642    setUiContent(path: string): Promise<void>;
1643
1644    /**
1645     * Sets ui content.
1646     * <p>When this method is executed successfully, the content of panel will be replaced.</p>
1647     *
1648     * @param { string } path - the path of ui content.
1649     * @param { LocalStorage } storage - the data object shared within the content instance loaded by the panel.
1650     * @param { AsyncCallback<void> } callback - the callback of setUiContent.
1651     * @throws { BusinessError } 401 - parameter error. Possible causes:
1652     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1653     * @syscap SystemCapability.MiscServices.InputMethodFramework
1654     * @since 10
1655     */
1656    setUiContent(path: string, storage: LocalStorage, callback: AsyncCallback<void>): void;
1657
1658    /**
1659     * Sets ui content.
1660     * <p>When this method is executed successfully, the content of panel will be replaced.</p>
1661     *
1662     * @param { string } path - the path of ui content.
1663     * @param { LocalStorage } storage - the data object shared within the content instance loaded by the panel.
1664     * @returns { Promise<void> } the promise returned by the function.
1665     * @throws { BusinessError } 401 - parameter error. Possible causes:
1666     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1667     * @syscap SystemCapability.MiscServices.InputMethodFramework
1668     * @since 10
1669     */
1670    setUiContent(path: string, storage: LocalStorage): Promise<void>;
1671
1672    /**
1673     * Resizes a panel.
1674     *
1675     * @param { number } width - the new width of the panel.
1676     * @param { number } height - the new height of the panel.
1677     * @param { AsyncCallback<void> } callback - the callback of resize.
1678     * @throws { BusinessError } 401 - parameter error. Possible causes:
1679     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1680     * @syscap SystemCapability.MiscServices.InputMethodFramework
1681     * @since 10
1682     */
1683    resize(width: number, height: number, callback: AsyncCallback<void>): void;
1684
1685    /**
1686     * Resizes a panel.
1687     *
1688     * @param { number } width - the new width of the panel.
1689     * @param { number } height - the new height of the panel.
1690     * @returns { Promise<void> } the promise returned by the function.
1691     * @throws { BusinessError } 401 - parameter error. Possible causes:
1692     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1693     * @syscap SystemCapability.MiscServices.InputMethodFramework
1694     * @since 10
1695     */
1696    resize(width: number, height: number): Promise<void>;
1697
1698    /**
1699     * Moves a panel.
1700     * <p>It's unusable for SOFT_KEYBOARD panel with FLG_FIXED.</p>
1701     *
1702     * @param { number } x - the x-coordinate of the new position.
1703     * @param { number } y - the y-coordinate of the new position.
1704     * @param { AsyncCallback<void> } callback - the callback of moveTo.
1705     * @throws { BusinessError } 401 - parameter error. Possible causes:
1706     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
1707     * @syscap SystemCapability.MiscServices.InputMethodFramework
1708     * @since 10
1709     */
1710    moveTo(x: number, y: number, callback: AsyncCallback<void>): void;
1711
1712    /**
1713     * Moves a panel.
1714     * <p>It's unusable for SOFT_KEYBOARD panel with FLG_FIXED.</p>
1715     *
1716     * @param { number } x - the x-coordinate of the new position.
1717     * @param { number } y - the y-coordinate of the new position.
1718     * @returns { Promise<void> } the promise returned by the function.
1719     * @throws { BusinessError } 401 - parameter error. Possible causes:
1720     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
1721     * @syscap SystemCapability.MiscServices.InputMethodFramework
1722     * @since 10
1723     */
1724    moveTo(x: number, y: number): Promise<void>;
1725
1726    /**
1727     * Starts moving a panel. The panel starts moving when pressed with finger or mouse and stops moving when released.
1728     * <p>It's Only used for STATUS_BAR panel.</p>
1729     *
1730     * @throws { BusinessError } 12800002 - input method engine error.
1731     * @throws { BusinessError } 12800013 - window manager service error.
1732     * @throws { BusinessError } 12800017 - invalid panel type or panel flag.
1733     * @syscap SystemCapability.MiscServices.InputMethodFramework
1734     * @since 15
1735     */
1736    /**
1737     * Starts moving a panel. The panel starts moving when pressed with finger or mouse and stops moving when released.
1738     * <p>It's Only used for STATUS_BAR panel.</p>
1739     *
1740     * @throws { BusinessError } 801 - capability not supported.
1741     * @throws { BusinessError } 12800002 - input method engine error.
1742     * @throws { BusinessError } 12800013 - window manager service error.
1743     * @throws { BusinessError } 12800017 - invalid panel type or panel flag.
1744     * @syscap SystemCapability.MiscServices.InputMethodFramework
1745     * @since 18
1746     */
1747    startMoving(): void;
1748
1749    /**
1750     * Get the ID of the display where the input method panel is located.
1751     *
1752     * @returns { Promise<number> } the promise returned by the function.
1753     * @throws { BusinessError } 12800002 - input method engine error.
1754     * @throws { BusinessError } 12800013 - window manager service error.
1755     * @syscap SystemCapability.MiscServices.InputMethodFramework
1756     * @since 15
1757     */
1758    getDisplayId(): Promise<number>;
1759
1760    /**
1761     * Shows panel.
1762     *
1763     * @param { AsyncCallback<void> } callback - the callback of show.
1764     * @syscap SystemCapability.MiscServices.InputMethodFramework
1765     * @since 10
1766     */
1767    show(callback: AsyncCallback<void>): void;
1768
1769    /**
1770     * Shows panel.
1771     *
1772     * @returns { Promise<void> } the promise returned by the function.
1773     * @syscap SystemCapability.MiscServices.InputMethodFramework
1774     * @since 10
1775     */
1776    show(): Promise<void>;
1777
1778    /**
1779     * Hides panel.
1780     *
1781     * @param { AsyncCallback<void> } callback - the callback of hide.
1782     * @syscap SystemCapability.MiscServices.InputMethodFramework
1783     * @since 10
1784     */
1785    hide(callback: AsyncCallback<void>): void;
1786
1787    /**
1788     * Hides panel.
1789     *
1790     * @returns { Promise<void> } the promise returned by the function.
1791     * @syscap SystemCapability.MiscServices.InputMethodFramework
1792     * @since 10
1793     */
1794    hide(): Promise<void>;
1795
1796    /**
1797     * Registers panel show event.
1798     * <p>The "show" events are triggered when the panel is shown.</p>
1799     *
1800     * @param { 'show' } type - events type.
1801     * @param { function } callback - the callback will be called when events are triggered.
1802     * @syscap SystemCapability.MiscServices.InputMethodFramework
1803     * @since 10
1804     */
1805    on(type: 'show', callback: () => void): void;
1806
1807    /**
1808     * Unregisters panel show event.
1809     *
1810     * @param { 'show' } type - events type.
1811     * @param { function } [callback] - the callback to Unregister.
1812     * @throws { BusinessError } 401 - parameter error. Possible causes:
1813     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1814     * @syscap SystemCapability.MiscServices.InputMethodFramework
1815     * @since 10
1816     */
1817    off(type: 'show', callback?: () => void): void;
1818
1819    /**
1820     * Registers panel hide event.
1821     * <p>The "hide" events are triggered when the panel is hidden.</p>
1822     *
1823     * @param { 'hide' } type - events type.
1824     * @param { function } callback - the callback will be called when events are triggered.
1825     * @syscap SystemCapability.MiscServices.InputMethodFramework
1826     * @since 10
1827     */
1828    on(type: 'hide', callback: () => void): void;
1829
1830    /**
1831     * Unregisters panel hide event.
1832     *
1833     * @param { 'hide' } type - events type.
1834     * @param { function } [callback] - the callback to Unregister.
1835     * @throws { BusinessError } 401 - parameter error. Possible causes:
1836     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1837     * @syscap SystemCapability.MiscServices.InputMethodFramework
1838     * @since 10
1839     */
1840    off(type: 'hide', callback?: () => void): void;
1841
1842    /**
1843     * Changes panel flag.
1844     * <p>Before flag is changed, Developers should hide the panel.After that, developers can change the content, size, point of the panel
1845     *    and show it again at appropriate opportunity.</p>
1846     *
1847     * @param { PanelFlag } flag - the callback of changeFlag.
1848     * @throws { BusinessError } 401 - parameter error. Possible causes:
1849     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1850     * @syscap SystemCapability.MiscServices.InputMethodFramework
1851     * @since 10
1852     */
1853    changeFlag(flag: PanelFlag): void;
1854
1855    /**
1856     * Sets ime panel private mode or not.
1857     *
1858     * @permission ohos.permission.PRIVACY_WINDOW
1859     * @param { boolean } isPrivacyMode - if the value is true, the privacy mode will be set,
1860     * otherwise the non-privacy mode will be set.
1861     * @throws { BusinessError } 201 - permissions check fails.
1862     * @throws { BusinessError } 401 - parameter error. Possible causes:
1863     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
1864     * @syscap SystemCapability.MiscServices.InputMethodFramework
1865     * @since 11
1866     */
1867    setPrivacyMode(isPrivacyMode: boolean): void;
1868
1869    /**
1870     * Adjust the rect of soft keyboard panel for landscape and portrait orientations.
1871     * <p>It's only used for SOFT_KEYBOARD panel with FLG_FIXED and FLG_FLOATING.</p>
1872     *
1873     * @param { PanelFlag } flag - panel flag.
1874     * @param { PanelRect } rect - panel rect.
1875     * @throws { BusinessError } 401 - parameter error. Possible causes:
1876     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1877     * @throws { BusinessError } 12800013 - window manager service error.
1878     * @syscap SystemCapability.MiscServices.InputMethodFramework
1879     * @since 12
1880     */
1881    adjustPanelRect(flag: PanelFlag, rect: PanelRect): void;
1882
1883    /**
1884     * Adjust the rect of soft keyboard panel for landscape and portrait orientations.
1885     * <p>It's only used for SOFT_KEYBOARD panel with fixed or floating flag.</p>
1886     *
1887     * @param { PanelFlag } flag - panel flag.
1888     * @param { EnhancedPanelRect } rect - panel rect.
1889     * @throws { BusinessError } 401 - parameter error. Possible causes:
1890     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1891     * @throws { BusinessError } 12800013 - window manager service error.
1892     * @throws { BusinessError } 12800017 - invalid panel type or panel flag.
1893     * @syscap SystemCapability.MiscServices.InputMethodFramework
1894     * @since 15
1895     */
1896    adjustPanelRect(flag: PanelFlag, rect: EnhancedPanelRect): void;
1897
1898    /**
1899     * <p>Update the region in the panel which accepts input events.</p>
1900     * <p>It's only used for SOFT_KEYBOARD panel with fixed flag or floating flag.</p>
1901     *
1902     * @param { Array<window.Rect> } inputRegion - region in the panel which accepts input event. The size of the array must range from 1 to 4.
1903     * @throws { BusinessError } 401 - parameter error. Possible causes:
1904     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1905     * @throws { BusinessError } 12800013 - window manager service error.
1906     * @throws { BusinessError } 12800017 - invalid panel type or panel flag.
1907     * @syscap SystemCapability.MiscServices.InputMethodFramework
1908     * @since 15
1909     */
1910    updateRegion(inputRegion: Array<window.Rect>): void;
1911
1912    /**
1913     * Subscribe 'sizeChange' event.
1914     * <p>It's only used for SOFT_KEYBOARD panel with FLG_FIXED and FLG_FLOATING.</p>
1915     *
1916     * @param { 'sizeChange' } type - the type of subscribe event.
1917     * @param { Callback<window.Size> } callback - the callback of on('sizeChange').
1918     * @syscap SystemCapability.MiscServices.InputMethodFramework
1919     * @since 12
1920     */
1921    /**
1922     * Subscribe 'sizeChange' event.
1923     * <p>It's only used for SOFT_KEYBOARD panel with FLG_FIXED and FLG_FLOATING.</p>
1924     *
1925     * @param { 'sizeChange' } type - the type of subscribe event.
1926     * @param { SizeChangeCallback } callback - the callback of on('sizeChange').
1927     * @syscap SystemCapability.MiscServices.InputMethodFramework
1928     * @since 15
1929     */
1930    on(type: 'sizeChange', callback: SizeChangeCallback): void;
1931
1932    /**
1933     * Unsubscribe 'sizeChange' event.
1934     * <p>It's only used for SOFT_KEYBOARD panel with FLG_FIXED and FLG_FLOATING.</p>
1935     *
1936     * @param { 'sizeChange' } type - the type of unsubscribe event.
1937     * @param { ?Callback<window.Size> } [callback] - optional, the callback of off('sizeChange').
1938     * @syscap SystemCapability.MiscServices.InputMethodFramework
1939     * @since 12
1940     */
1941    /**
1942     * Unsubscribe 'sizeChange' event.
1943     * <p>It's only used for SOFT_KEYBOARD panel with FLG_FIXED and FLG_FLOATING.</p>
1944     *
1945     * @param { 'sizeChange' } type - the type of unsubscribe event.
1946     * @param { ?SizeChangeCallback } [callback] - optional, the callback of off('sizeChange').
1947     * @syscap SystemCapability.MiscServices.InputMethodFramework
1948     * @since 15
1949     */
1950    off(type: 'sizeChange', callback?: SizeChangeCallback): void;
1951
1952    /**
1953     * Subscribe 'sizeUpdate' event.
1954     * <p>It's only used for SOFT_KEYBOARD panel with FLG_FIXED and FLG_FLOATING.</p>
1955     *
1956     * @param { 'sizeUpdate' } type - the type of subscribe event.
1957     * @param { SizeUpdateCallback } callback - the callback of on('sizeUpdate').
1958     * @syscap SystemCapability.MiscServices.InputMethodFramework
1959     * @systemapi
1960     * @since 14
1961     */
1962    on(type: 'sizeUpdate', callback: SizeUpdateCallback): void;
1963
1964    /**
1965     * Unsubscribe 'sizeUpdate' event.
1966     * <p>It's only used for SOFT_KEYBOARD panel with FLG_FIXED and FLG_FLOATING.</p>
1967     *
1968     * @param { 'sizeUpdate' } type - the type of unsubscribe event.
1969     * @param { ?SizeUpdateCallback } [callback] - optional, the callback of off('sizeUpdate').
1970     * @syscap SystemCapability.MiscServices.InputMethodFramework
1971     * @systemapi
1972     * @since 14
1973     */
1974    off(type: 'sizeUpdate', callback?: SizeUpdateCallback): void;
1975
1976    /**
1977     * Set immersive mode.
1978     *
1979     * @param { ImmersiveMode } mode - Immersive mode.
1980     * @throws { BusinessError } 401 - parameter error. Possible causes:
1981     *     1.Incorrect parameter types; 2.Parameter verification failed.
1982     * @throws { BusinessError } 12800002 - input method engine error.
1983     * @throws { BusinessError } 12800013 - window manager service error.
1984     * @syscap SystemCapability.MiscServices.InputMethodFramework
1985     * @since 15
1986     */
1987    setImmersiveMode(mode: ImmersiveMode): void;
1988
1989    /**
1990     * Get immersive mode.
1991     *
1992     * @returns { ImmersiveMode } Immersive mode.
1993     * @syscap SystemCapability.MiscServices.InputMethodFramework
1994     * @since 15
1995     */
1996    getImmersiveMode(): ImmersiveMode;
1997  }
1998
1999  /**
2000   * @interface EditorAttribute
2001   * @syscap SystemCapability.MiscServices.InputMethodFramework
2002   * @since 8
2003   */
2004  interface EditorAttribute {
2005    /**
2006     * Editor's pattern
2007     *
2008     * @type { number }
2009     * @readonly
2010     * @syscap SystemCapability.MiscServices.InputMethodFramework
2011     * @since 8
2012     */
2013    readonly inputPattern: number;
2014
2015    /**
2016     * Editor's key type
2017     *
2018     * @type { number }
2019     * @readonly
2020     * @syscap SystemCapability.MiscServices.InputMethodFramework
2021     * @since 8
2022     */
2023    readonly enterKeyType: number;
2024
2025    /**
2026     * Indicates whether the editor supports the text preview.
2027     *
2028     * @type { boolean }
2029     * @syscap SystemCapability.MiscServices.InputMethodFramework
2030     * @since 12
2031     */
2032    isTextPreviewSupported: boolean;
2033
2034    /**
2035     * Editor's bundle name.
2036     *
2037     * @type { ?string }
2038     * @readonly
2039     * @syscap SystemCapability.MiscServices.InputMethodFramework
2040     * @since 14
2041     */
2042    readonly bundleName?: string;
2043
2044    /**
2045     * Immersive mode.
2046     *
2047     * @type { ?ImmersiveMode }
2048     * @readonly
2049     * @syscap SystemCapability.MiscServices.InputMethodFramework
2050     * @since 15
2051     */
2052    readonly immersiveMode?: ImmersiveMode;
2053
2054    /**
2055     * Indicates the ID of the window where the edit box is located.
2056     *
2057     * @type { ?number }
2058     * @readonly
2059     * @syscap SystemCapability.MiscServices.InputMethodFramework
2060     * @since 18
2061     */
2062    readonly windowId?: number;
2063
2064    /**
2065     * Indicates the ID of the display where the edit box is located.
2066     *
2067     * @type { ?number }
2068     * @readonly
2069     * @syscap SystemCapability.MiscServices.InputMethodFramework
2070     * @since 18
2071     */
2072    readonly displayId?: number;
2073  }
2074
2075  /**
2076   * @interface KeyEvent
2077   * @syscap SystemCapability.MiscServices.InputMethodFramework
2078   * @since 8
2079   */
2080  interface KeyEvent {
2081    /**
2082     * Key code
2083     *
2084     * @type { number }
2085     * @readonly
2086     * @syscap SystemCapability.MiscServices.InputMethodFramework
2087     * @since 8
2088     */
2089    readonly keyCode: number;
2090
2091    /**
2092     * Key action
2093     *
2094     * @type { number }
2095     * @readonly
2096     * @syscap SystemCapability.MiscServices.InputMethodFramework
2097     * @since 8
2098     */
2099    readonly keyAction: number;
2100  }
2101
2102  /**
2103   * Enumerates the flags of panel
2104   *
2105   * @enum { number }
2106   * @syscap SystemCapability.MiscServices.InputMethodFramework
2107   * @since 10
2108   */
2109  export enum PanelFlag {
2110    /**
2111     * Fixed style.
2112     * <p>It's provided for the panel with type of SOFT_KEYBOARD.
2113     * When the flag is set, the soft keyboard is fixed at the bottom of the screen.</p>
2114     *
2115     * @syscap SystemCapability.MiscServices.InputMethodFramework
2116     * @since 10
2117     */
2118    FLG_FIXED = 0,
2119
2120    /**
2121     * Floating style.
2122     * <p>It's provided for the panel with type of SOFT_KEYBOARD.
2123     * When the flag is set, the soft keyboard is floating.</p>
2124     *
2125     * @syscap SystemCapability.MiscServices.InputMethodFramework
2126     * @since 10
2127     */
2128    FLG_FLOATING,
2129
2130    /**
2131     * Candidate style.
2132     * <p>It's provided for the panel with type of SOFT_KEYBOARD.
2133     * When the flag is set, the soft keyboard is a candidate window which will show the possible characters when user types a input code.
2134     * Panel with candidate style will not be automatically shown or hidden by input method service.
2135     * Input method application developers are supposed to control the panel status on their own.</p>
2136     *
2137     * @syscap SystemCapability.MiscServices.InputMethodFramework
2138     * @since 15
2139     */
2140    FLAG_CANDIDATE
2141  }
2142
2143  /**
2144   * <p>Panel types provided for input method applications.</p>
2145   * <p>Input method application developers should select the appropriate panel type according to the user scenario.</p>
2146   *
2147   * @enum { number }
2148   * @syscap SystemCapability.MiscServices.InputMethodFramework
2149   * @since 10
2150   */
2151  export enum PanelType {
2152    /**
2153     * Panel for displaying a virtual software keyboard.
2154     *
2155     * @syscap SystemCapability.MiscServices.InputMethodFramework
2156     * @since 10
2157     */
2158    SOFT_KEYBOARD = 0,
2159
2160    /**
2161     * Panel for displaying status bar.
2162     *
2163     * @syscap SystemCapability.MiscServices.InputMethodFramework
2164     * @since 10
2165     */
2166    STATUS_BAR
2167  }
2168
2169  /**
2170   * Panel information.
2171   *
2172   * @typedef PanelInfo
2173   * @syscap SystemCapability.MiscServices.InputMethodFramework
2174   * @since 10
2175   */
2176  export interface PanelInfo {
2177    /**
2178     * Panel type.
2179     *
2180     * @type { PanelType }
2181     * @syscap SystemCapability.MiscServices.InputMethodFramework
2182     * @since 10
2183     */
2184    type: PanelType;
2185
2186    /**
2187     * <p>Flag of Panel.</p>
2188     * <p>Currently only using for SOFT_KEYBOARD panel.</p>
2189     *
2190     * @type { ?PanelFlag }
2191     * @default FLG_FIXED
2192     * @syscap SystemCapability.MiscServices.InputMethodFramework
2193     * @since 10
2194     */
2195    flag?: PanelFlag;
2196  }
2197
2198  /**
2199   * Enumerates the moving direction of cursor
2200   *
2201   * @enum { number }
2202   * @syscap SystemCapability.MiscServices.InputMethodFramework
2203   * @since 10
2204   */
2205  export enum Direction {
2206    /**
2207     * Cursor moves up
2208     *
2209     * @syscap SystemCapability.MiscServices.InputMethodFramework
2210     * @since 10
2211     */
2212    CURSOR_UP = 1,
2213
2214    /**
2215     * Cursor moves down
2216     *
2217     * @syscap SystemCapability.MiscServices.InputMethodFramework
2218     * @since 10
2219     */
2220    CURSOR_DOWN,
2221
2222    /**
2223     * Cursor moves left
2224     *
2225     * @syscap SystemCapability.MiscServices.InputMethodFramework
2226     * @since 10
2227     */
2228    CURSOR_LEFT,
2229
2230    /**
2231     * Cursor moves right
2232     *
2233     * @syscap SystemCapability.MiscServices.InputMethodFramework
2234     * @since 10
2235     */
2236    CURSOR_RIGHT
2237  }
2238
2239  /**
2240   * Enumerates the security mode.
2241   *
2242   * @enum { number }
2243   * @syscap SystemCapability.MiscServices.InputMethodFramework
2244   * @since 11
2245   */
2246  export enum SecurityMode {
2247    /**
2248     * Basic security mode
2249     *
2250     * @syscap SystemCapability.MiscServices.InputMethodFramework
2251     * @since 11
2252     */
2253    BASIC = 0,
2254    /**
2255     * Full security mode
2256     *
2257     * @syscap SystemCapability.MiscServices.InputMethodFramework
2258     * @since 11
2259     */
2260    FULL
2261  }
2262
2263  /**
2264   * Range of selected text.
2265   *
2266   * @interface Range
2267   * @syscap SystemCapability.MiscServices.InputMethodFramework
2268   * @since 10
2269   */
2270  export interface Range {
2271    /**
2272     * Indicates the index of the first character of the selected text.
2273     *
2274     * @type { number }
2275     * @syscap SystemCapability.MiscServices.InputMethodFramework
2276     * @since 10
2277     */
2278    start: number;
2279
2280    /**
2281     * Indicates the index of the last character of the selected text.
2282     *
2283     * @type { number }
2284     * @syscap SystemCapability.MiscServices.InputMethodFramework
2285     * @since 10
2286     */
2287    end: number;
2288  }
2289
2290  /**
2291   * Movement of cursor.
2292   *
2293   * @interface Movement
2294   * @syscap SystemCapability.MiscServices.InputMethodFramework
2295   * @since 10
2296   */
2297  export interface Movement {
2298    /**
2299     * Indicates the direction of cursor movement
2300     *
2301     * @type { Direction }
2302     * @syscap SystemCapability.MiscServices.InputMethodFramework
2303     * @since 10
2304     */
2305    direction: Direction;
2306  }
2307
2308  /**
2309   * Enumerates the extend action.
2310   *
2311   * @enum { number }
2312   * @syscap SystemCapability.MiscServices.InputMethodFramework
2313   * @since 10
2314   */
2315  export enum ExtendAction {
2316    /**
2317     * Select all text.
2318     *
2319     * @syscap SystemCapability.MiscServices.InputMethodFramework
2320     * @since 10
2321     */
2322    SELECT_ALL = 0,
2323
2324    /**
2325     * Cut selecting text.
2326     *
2327     * @syscap SystemCapability.MiscServices.InputMethodFramework
2328     * @since 10
2329     */
2330    CUT = 3,
2331
2332    /**
2333     * Copy selecting text.
2334     *
2335     * @syscap SystemCapability.MiscServices.InputMethodFramework
2336     * @since 10
2337     */
2338    COPY = 4,
2339
2340    /**
2341     * Paste from paste board.
2342     *
2343     * @syscap SystemCapability.MiscServices.InputMethodFramework
2344     * @since 10
2345     */
2346    PASTE = 5
2347  }
2348
2349  /**
2350   * Window info.
2351   *
2352   * @interface WindowInfo
2353   * @syscap SystemCapability.MiscServices.InputMethodFramework
2354   * @since 12
2355   */
2356  export interface WindowInfo {
2357    /**
2358     * Rectangle.
2359     *
2360     * @type { window.Rect }
2361     * @syscap SystemCapability.MiscServices.InputMethodFramework
2362     * @since 12
2363     */
2364    rect: window.Rect;
2365
2366    /**
2367     * Window status.
2368     *
2369     * @type { window.WindowStatusType }
2370     * @syscap SystemCapability.MiscServices.InputMethodFramework
2371     * @since 12
2372     */
2373    status: window.WindowStatusType;
2374  }
2375
2376  /**
2377   * Panel Rect.
2378   *
2379   * @interface PanelRect
2380   * @syscap SystemCapability.MiscServices.InputMethodFramework
2381   * @since 12
2382   */
2383  export interface PanelRect {
2384    /**
2385     * Panel rect in landscape orientation.
2386     *
2387     * @type { window.Rect }
2388     * @syscap SystemCapability.MiscServices.InputMethodFramework
2389     * @since 12
2390     */
2391    landscapeRect: window.Rect;
2392
2393    /**
2394     * Panel rect in portrait orientation.
2395     *
2396     * @type { window.Rect }
2397     * @syscap SystemCapability.MiscServices.InputMethodFramework
2398     * @since 12
2399     */
2400    portraitRect: window.Rect;
2401  }
2402
2403  /**
2404   * <p>Custom message handler.</p>
2405   * <p>Implement this interface to respond to custem messages.</p>
2406   *
2407   * @interface MessageHandler
2408   * @syscap SystemCapability.MiscServices.InputMethodFramework
2409   * @since 15
2410   */
2411  interface MessageHandler {
2412    /**
2413     * This method is called when a custom message is received.
2414     *
2415     * @param { string } msgId - the identifier of the message.
2416     * @param { ?ArrayBuffer } [msgParam] - the parameter of the custom message.
2417     * @syscap SystemCapability.MiscServices.InputMethodFramework
2418     * @since 15
2419     */
2420    onMessage(msgId: string, msgParam?: ArrayBuffer): void;
2421
2422    /**
2423     * This method is called when a new message handler is set.
2424     *
2425     * @syscap SystemCapability.MiscServices.InputMethodFramework
2426     * @since 15
2427     */
2428    onTerminated(): void;
2429  }
2430
2431  /**
2432   * Enhanced panel rect information.
2433   *
2434   * @interface EnhancedPanelRect
2435   * @syscap SystemCapability.MiscServices.InputMethodFramework
2436   * @since 15
2437   */
2438  export interface EnhancedPanelRect {
2439    /**
2440     * <p>Panel rect in landscape orientation.</p>
2441     * <p>It must be filled when fullScreenMode is flase or not specified.</p>
2442     *
2443     * @type { ?window.Rect }
2444     * @syscap SystemCapability.MiscServices.InputMethodFramework
2445     * @since 15
2446     */
2447    landscapeRect?: window.Rect;
2448    /**
2449     * <p>Panel rect in portrait orientation.</P>
2450     * <p>It must be filled when fullScreenMode is flase or not specified.</p>
2451     *
2452     * @type { ?window.Rect }
2453     * @syscap SystemCapability.MiscServices.InputMethodFramework
2454     * @since 15
2455     */
2456    portraitRect?: window.Rect;
2457    /**
2458     * The distance between the top of the panel and the top of the avoidance area in landscape orientation.
2459     * <p>It's only used for SOFT_KEYBOARD panel with fixed flag or floating flag.</p>
2460     *
2461     * @type { ?number }
2462     * @default 0
2463     * @syscap SystemCapability.MiscServices.InputMethodFramework
2464     * @since 15
2465     */
2466    landscapeAvoidY?: number;
2467    /**
2468     * <p>Region in the panel that accepts input events in landsacpe mode.</p>
2469     * <p>It's only used for SOFT_KEYBOARD panel with fixed flag or floating flag. Max array size is 4.</p>
2470     * <p>Defaults to entire panel area if not specifed.</p>
2471     *
2472     * @type { ?Array<window.Rect> }
2473     * @syscap SystemCapability.MiscServices.InputMethodFramework
2474     * @since 15
2475     */
2476    landscapeInputRegion?: Array<window.Rect>;
2477    /**
2478     * The distance between the top of the panel and the top of the avoidance area in portrait orientation.
2479     * <p>It's only used for SOFT_KEYBOARD panel with fixed flag or floating flag.</p>
2480     *
2481     * @type { ?number }
2482     * @default 0
2483     * @syscap SystemCapability.MiscServices.InputMethodFramework
2484     * @since 15
2485     */
2486    portraitAvoidY?: number;
2487    /**
2488     * <p>Region in the panel that accepts input events in portrait mode.</p>
2489     * <p>It's only used for SOFT_KEYBOARD panel with fixed flag or floating flag. Max array size is 4.</p>
2490     * <p>Defaults to entire panel area if not specifed.</p>
2491     *
2492     * @type { ?Array<window.Rect> }
2493     * @syscap SystemCapability.MiscServices.InputMethodFramework
2494     * @since 15
2495     */
2496    portraitInputRegion?: Array<window.Rect>;
2497    /**
2498     * <p>Enter the full screen mode.</p>
2499     * <p>It's only used for SOFT_KEYBOARD panel with fixed flag or floating flag.</p>
2500     *
2501     * @type { ?boolean }
2502     * @default false
2503     * @syscap SystemCapability.MiscServices.InputMethodFramework
2504     * @since 15
2505     */
2506    fullScreenMode?: boolean;
2507  }
2508
2509  /**
2510   * Keyboard area.
2511   *
2512   * @interface KeyboardArea
2513   * @syscap SystemCapability.MiscServices.InputMethodFramework
2514   * @since 15
2515   */
2516  export interface KeyboardArea {
2517    /**
2518     * Top of the keyboard area in the panel.
2519     *
2520     * @type { number }
2521     * @syscap SystemCapability.MiscServices.InputMethodFramework
2522     * @since 15
2523     */
2524    top: number;
2525    /**
2526     * Bottom of the keyboard area in the panel.
2527     *
2528     * @type { number }
2529     * @syscap SystemCapability.MiscServices.InputMethodFramework
2530     * @since 15
2531     */
2532    bottom: number;
2533    /**
2534     * Left of the keyboard area in the panel.
2535     *
2536     * @type { number }
2537     * @syscap SystemCapability.MiscServices.InputMethodFramework
2538     * @since 15
2539     */
2540    left: number;
2541    /**
2542     * Right of the keyboard area in the panel.
2543     *
2544     * @type { number }
2545     * @syscap SystemCapability.MiscServices.InputMethodFramework
2546     * @since 15
2547     */
2548    right: number;
2549  }
2550}
2551
2552export default inputMethodEngine;
2553