• 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     * Get input method's security mode.
649     *
650     * @returns { SecurityMode } return security mode.
651     * @throws { BusinessError } 12800004 - not an input method.
652     * @syscap SystemCapability.MiscServices.InputMethodFramework
653     * @since 11
654     */
655    getSecurityMode(): SecurityMode;
656
657    /**
658     * Creates a panel.
659     * <p>The system only allows one soft keyboard and one status bar to be created.</p>
660     *
661     * @param { BaseContext } ctx - indicates the context on which the window depends.
662     * @param { PanelInfo } info - the info of panel to be created.
663     * @param { AsyncCallback<Panel> } callback - the callback of createPanel.
664     * @throws { BusinessError } 401 - parameter error. Possible causes:
665     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types;
666     * @throws { BusinessError } 12800004 - not an input method.
667     * @syscap SystemCapability.MiscServices.InputMethodFramework
668     * @since 10
669     */
670    createPanel(ctx: BaseContext, info: PanelInfo, callback: AsyncCallback<Panel>): void;
671
672    /**
673     * Creates a panel.
674     * <p>The system only allows one soft keyboard and one status bar to be created.</p>
675     *
676     * @param { BaseContext } ctx - indicates the context on which the window depends.
677     * @param { PanelInfo } info - the info of panel to be created.
678     * @returns { Promise<Panel> } the promise returned by the function.
679     * @throws { BusinessError } 401 - parameter error. Possible causes:
680     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types;
681     * @throws { BusinessError } 12800004 - not an input method.
682     * @syscap SystemCapability.MiscServices.InputMethodFramework
683     * @since 10
684     */
685    createPanel(ctx: BaseContext, info: PanelInfo): Promise<Panel>;
686
687    /**
688     * Destroys a panel.
689     *
690     * @param { Panel } panel - to be destroyed.
691     * @param { AsyncCallback<void> } callback - the callback of destroyPanel.
692     * @throws { BusinessError } 401 - parameter error. Possible causes:
693     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
694     * @syscap SystemCapability.MiscServices.InputMethodFramework
695     * @since 10
696     */
697    destroyPanel(panel: Panel, callback: AsyncCallback<void>): void;
698
699    /**
700     * Destroys a panel.
701     *
702     * @param { Panel } panel - to be destroyed.
703     * @returns { Promise<void> } the promise returned by the function.
704     * @throws { BusinessError } 401 - parameter error. Possible causes:
705     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
706     * @syscap SystemCapability.MiscServices.InputMethodFramework
707     * @since 10
708     */
709    destroyPanel(panel: Panel): Promise<void>;
710  }
711
712  /**
713   * @interface TextInputClient
714   * @syscap SystemCapability.MiscServices.InputMethodFramework
715   * @since 8
716   * @deprecated since 9
717   * @useinstead inputMethodEngine#InputClient
718   */
719  interface TextInputClient {
720    /**
721     * @param { number } action - action indicates the function of "enter" key.
722     * @param { AsyncCallback<boolean> } callback - the callback of sendKeyFunction.
723     * @syscap SystemCapability.MiscServices.InputMethodFramework
724     * @since 8
725     * @deprecated since 9
726     * @useinstead inputMethodEngine.InputClient#sendKeyFunction
727     */
728    sendKeyFunction(action: number, callback: AsyncCallback<boolean>): void;
729
730    /**
731     * @param { number } action - action indicates the function of "enter" key.
732     * @returns { Promise<boolean> } the promise returned by the function.
733     * @syscap SystemCapability.MiscServices.InputMethodFramework
734     * @since 8
735     * @deprecated since 9
736     * @useinstead inputMethodEngine.InputClient#sendKeyFunction
737     */
738    sendKeyFunction(action: number): Promise<boolean>;
739
740    /**
741     * @param { number } length - length of text which will be deleted forward.
742     * @param { AsyncCallback<boolean> } callback - the callback of deleteForward.
743     * @syscap SystemCapability.MiscServices.InputMethodFramework
744     * @since 8
745     * @deprecated since 9
746     * @useinstead inputMethodEngine.InputClient#deleteForward
747     */
748    deleteForward(length: number, callback: AsyncCallback<boolean>): void;
749
750    /**
751     * @param { number } length - length of text which will be deleted forward.
752     * @returns { Promise<boolean> } the promise returned by the function.
753     * @syscap SystemCapability.MiscServices.InputMethodFramework
754     * @since 8
755     * @deprecated since 9
756     * @useinstead inputMethodEngine.InputClient#deleteForward
757     */
758    deleteForward(length: number): Promise<boolean>;
759
760    /**
761     * @param { number } length - length of text which will be deleted backward.
762     * @param { AsyncCallback<boolean> } callback - the callback of deleteBackward.
763     * @syscap SystemCapability.MiscServices.InputMethodFramework
764     * @since 8
765     * @deprecated since 9
766     * @useinstead inputMethodEngine.InputClient#deleteBackward
767     */
768    deleteBackward(length: number, callback: AsyncCallback<boolean>): void;
769
770    /**
771     * @param { number } length - length of text which will be deleted backward.
772     * @returns { Promise<boolean> } the promise returned by the function.
773     * @syscap SystemCapability.MiscServices.InputMethodFramework
774     * @since 8
775     * @deprecated since 9
776     * @useinstead inputMethodEngine.InputClient#deleteBackward
777     */
778    deleteBackward(length: number): Promise<boolean>;
779
780    /**
781     * @param { string } text - text which will be inserted.
782     * @param { AsyncCallback<boolean> } callback - the callback of insertText.
783     * @syscap SystemCapability.MiscServices.InputMethodFramework
784     * @since 8
785     * @deprecated since 9
786     * @useinstead inputMethodEngine.InputClient#insertText
787     */
788    insertText(text: string, callback: AsyncCallback<boolean>): void;
789
790    /**
791     * @param { string } text - text which will be inserted.
792     * @returns { Promise<boolean> } the promise returned by the function
793     * @syscap SystemCapability.MiscServices.InputMethodFramework
794     * @since 8
795     * @deprecated since 9
796     * @useinstead inputMethodEngine.InputClient#insertText
797     */
798    insertText(text: string): Promise<boolean>;
799
800    /**
801     * @param { number } length - the length of text which will be got.
802     * @param { AsyncCallback<string> } callback - the callback of getForward.
803     * @syscap SystemCapability.MiscServices.InputMethodFramework
804     * @since 8
805     * @deprecated since 9
806     * @useinstead inputMethodEngine.InputClient#getForward
807     */
808    getForward(length: number, callback: AsyncCallback<string>): void;
809
810    /**
811     * @param { number } length - the length of text which will be got.
812     * @returns { Promise<string> } the promise returned by the function
813     * @syscap SystemCapability.MiscServices.InputMethodFramework
814     * @since 8
815     * @deprecated since 9
816     * @useinstead inputMethodEngine.InputClient#getForward
817     */
818    getForward(length: number): Promise<string>;
819
820    /**
821     * @param { number } length - the length of text which will be got.
822     * @param { AsyncCallback<string> } callback - the callback of getBackward.
823     * @syscap SystemCapability.MiscServices.InputMethodFramework
824     * @since 8
825     * @deprecated since 9
826     * @useinstead inputMethodEngine.InputClient#getBackward
827     */
828    getBackward(length: number, callback: AsyncCallback<string>): void;
829
830    /**
831     * @param { number } length - the length of text which will be got.
832     * @returns { Promise<string> } the promise returned by the function.
833     * @syscap SystemCapability.MiscServices.InputMethodFramework
834     * @since 8
835     * @deprecated since 9
836     * @useinstead inputMethodEngine.InputClient#getBackward
837     */
838    getBackward(length: number): Promise<string>;
839
840    /**
841     * @param { AsyncCallback<EditorAttribute> } callback - the callback of getEditorAttribute.
842     * @syscap SystemCapability.MiscServices.InputMethodFramework
843     * @since 8
844     * @deprecated since 9
845     * @useinstead inputMethodEngine.InputClient#getEditorAttribute
846     */
847    getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void;
848
849    /**
850     * @returns { Promise<EditorAttribute> } the promise returned by the function.
851     * @syscap SystemCapability.MiscServices.InputMethodFramework
852     * @since 8
853     * @deprecated since 9
854     * @useinstead inputMethodEngine.InputClient#getEditorAttribute
855     */
856    getEditorAttribute(): Promise<EditorAttribute>;
857  }
858
859  /**
860   * Control events about Editor.
861   *
862   * @interface InputClient
863   * @syscap SystemCapability.MiscServices.InputMethodFramework
864   * @since 9
865   */
866  interface InputClient {
867    /**
868     * Send the function of the key.
869     *
870     * @param { number } action - action indicates the function of "enter" key.
871     * @param { AsyncCallback<boolean> } callback - the callback of sendKeyFunction.
872     * @throws { BusinessError } 401 - parameter error. Possible causes:
873     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
874     * @throws { BusinessError } 12800003 - input method client error.
875     * @syscap SystemCapability.MiscServices.InputMethodFramework
876     * @since 9
877     */
878    sendKeyFunction(action: number, callback: AsyncCallback<boolean>): void;
879
880    /**
881     * Send the function of the key.
882     *
883     * @param { number } action - action indicates the function of "enter" key.
884     * @returns { Promise<boolean> } the promise returned by the function.
885     * @throws { BusinessError } 401 - parameter error. Possible causes:
886     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
887     * @throws { BusinessError } 12800003 - input method client error.
888     * @syscap SystemCapability.MiscServices.InputMethodFramework
889     * @since 9
890     */
891    sendKeyFunction(action: number): Promise<boolean>;
892
893    /**
894     * Delete text forward.
895     *
896     * @param { number } length - length of text which will be deleted forward. It can't be less than 0.
897     * @param { AsyncCallback<boolean> } callback - the callback of deleteForward.
898     * @throws { BusinessError } 401 - parameter error. Possible causes:
899     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
900     * @throws { BusinessError } 12800002 - Input method engine error.
901     * @throws { BusinessError } 12800003 - input method client error.
902     * @syscap SystemCapability.MiscServices.InputMethodFramework
903     * @since 9
904     */
905    deleteForward(length: number, callback: AsyncCallback<boolean>): void;
906
907    /**
908     * Delete text forward.
909     *
910     * @param { number } length - length of text which will be deleted forward. It can't be less than 0.
911     * @returns { Promise<boolean> } the promise returned by the function.
912     * @throws { BusinessError } 401 - parameter error. Possible causes:
913     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
914     * @throws { BusinessError } 12800002 - Input method engine error.
915     * @throws { BusinessError } 12800003 - input method client error.
916     * @syscap SystemCapability.MiscServices.InputMethodFramework
917     * @since 9
918     */
919    deleteForward(length: number): Promise<boolean>;
920
921    /**
922     * Delete text forward.
923     *
924     * @param { number } length - length of text which will be deleted forward. It can't be less than 0.
925     * @throws { BusinessError } 401 - parameter error. Possible causes:
926     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
927     * @throws { BusinessError } 12800002 - input method engine error.
928     * @throws { BusinessError } 12800003 - input method client error.
929     * @syscap SystemCapability.MiscServices.InputMethodFramework
930     * @since 10
931     */
932    deleteForwardSync(length: number): void;
933
934    /**
935     * Delete text backward.
936     *
937     * @param { number } length - length of text which will be deleted backward. It can't be less than 0.
938     * @param { AsyncCallback<boolean> } callback - the callback of deleteBackward.
939     * @throws { BusinessError } 401 - parameter error. Possible causes:
940     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
941     * @throws { BusinessError } 12800002 - Input method engine error.
942     * @throws { BusinessError } 12800003 - input method client error.
943     * @syscap SystemCapability.MiscServices.InputMethodFramework
944     * @since 9
945     */
946    deleteBackward(length: number, callback: AsyncCallback<boolean>): void;
947
948    /**
949     * Delete text backward.
950     *
951     * @param { number } length - length of text which will be deleted backward. It can't be less than 0.
952     * @returns { Promise<boolean> } the promise returned by the function.
953     * @throws { BusinessError } 401 - parameter error. Possible causes:
954     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
955     * @throws { BusinessError } 12800002 - Input method engine error.
956     * @throws { BusinessError } 12800003 - input method client error.
957     * @syscap SystemCapability.MiscServices.InputMethodFramework
958     * @since 9
959     */
960    deleteBackward(length: number): Promise<boolean>;
961
962    /**
963     * Delete text backward.
964     *
965     * @param { number } length - length of text which will be deleted backward. It can't be less than 0.
966     * @throws { BusinessError } 401 - parameter error. Possible causes:
967     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
968     * @throws { BusinessError } 12800002 - input method engine error.
969     * @throws { BusinessError } 12800003 - input method client error.
970     * @syscap SystemCapability.MiscServices.InputMethodFramework
971     * @since 10
972     */
973    deleteBackwardSync(length: number): void;
974
975    /**
976     * Insert text into Editor.
977     *
978     * @param { string } text - text which will be inserted.
979     * @param { AsyncCallback<boolean> } callback - the callback of insertText.
980     * @throws { BusinessError } 401 - parameter error. Possible causes:
981     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
982     * @throws { BusinessError } 12800002 - Input method engine error.
983     * @throws { BusinessError } 12800003 - input method client error.
984     * @syscap SystemCapability.MiscServices.InputMethodFramework
985     * @since 9
986     */
987    insertText(text: string, callback: AsyncCallback<boolean>): void;
988
989    /**
990     * Insert text into Editor.
991     *
992     * @param { string } text - text which will be inserted.
993     * @returns { Promise<boolean> } the promise returned by the function.
994     * @throws { BusinessError } 401 - parameter error. Possible causes:
995     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
996     * @throws { BusinessError } 12800002 - Input method engine error.
997     * @throws { BusinessError } 12800003 - input method client error.
998     * @syscap SystemCapability.MiscServices.InputMethodFramework
999     * @since 9
1000     */
1001    insertText(text: string): Promise<boolean>;
1002
1003    /**
1004     * Insert text into Editor.
1005     *
1006     * @param { string } text - text which will be inserted.
1007     * @throws { BusinessError } 401 - parameter error. Possible causes:
1008     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
1009     * @throws { BusinessError } 12800002 - input method engine error.
1010     * @throws { BusinessError } 12800003 - input method client error.
1011     * @syscap SystemCapability.MiscServices.InputMethodFramework
1012     * @since 10
1013     */
1014    insertTextSync(text: string): void;
1015
1016    /**
1017     * Get the text before cursor.
1018     *
1019     * @param { number } length - the length of text which will be got. It can't be less than 0.
1020     * @param { AsyncCallback<string> } callback - the callback of getForward.
1021     * @throws { BusinessError } 401 - parameter error. Possible causes:
1022     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
1023     * @throws { BusinessError } 12800003 - input method client error.
1024     * @throws { BusinessError } 12800006 - Input method controller error.
1025     * @syscap SystemCapability.MiscServices.InputMethodFramework
1026     * @since 9
1027     */
1028    getForward(length: number, callback: AsyncCallback<string>): void;
1029
1030    /**
1031     * Get the text before cursor.
1032     *
1033     * @param { number } length - the length of text which will be got. It can't be less than 0.
1034     * @returns { Promise<string> } the promise returned by the function.
1035     * @throws { BusinessError } 401 - parameter error. Possible causes:
1036     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
1037     * @throws { BusinessError } 12800003 - input method client error.
1038     * @throws { BusinessError } 12800006 - Input method controller error.
1039     * @syscap SystemCapability.MiscServices.InputMethodFramework
1040     * @since 9
1041     */
1042    getForward(length: number): Promise<string>;
1043
1044    /**
1045     * Get the text before cursor.
1046     *
1047     * @param { number } length - the length of text which will be got. It can't be less than 0.
1048     * @returns { string } the text string before cursor.
1049     * @throws { BusinessError } 401 - parameter error. Possible causes:
1050     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1051     * @throws { BusinessError } 12800003 - input method client error.
1052     * @throws { BusinessError } 12800006 - input method controller error.
1053     * @syscap SystemCapability.MiscServices.InputMethodFramework
1054     * @since 10
1055     */
1056    getForwardSync(length: number): string;
1057
1058    /**
1059     * Get the text after cursor.
1060     *
1061     * @param { number } length - the length of text which will be got.It can't be less than 0.
1062     * @param { AsyncCallback<string> } callback - the callback of getBackward.
1063     * @throws { BusinessError } 401 - parameter error. Possible causes:
1064     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
1065     * @throws { BusinessError } 12800003 - input method client error.
1066     * @throws { BusinessError } 12800006 - Input method controller error.
1067     * @syscap SystemCapability.MiscServices.InputMethodFramework
1068     * @since 9
1069     */
1070    getBackward(length: number, callback: AsyncCallback<string>): void;
1071
1072    /**
1073     * Get the text after cursor.
1074     *
1075     * @param { number } length - the length of text which will be got.It can't be less than 0.
1076     * @returns { Promise<string> } the promise returned by the function.
1077     * @throws { BusinessError } 401 - parameter error. Possible causes:
1078     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
1079     * @throws { BusinessError } 12800003 - input method client error.
1080     * @throws { BusinessError } 12800006 - Input method controller error.
1081     * @syscap SystemCapability.MiscServices.InputMethodFramework
1082     * @since 9
1083     */
1084    getBackward(length: number): Promise<string>;
1085
1086    /**
1087     * Get the text after cursor.
1088     *
1089     * @param { number } length - the length of text which will be got. It can't be less than 0.
1090     * @returns { string } the text string after cursor.
1091     * @throws { BusinessError } 401 - parameter error. Possible causes:
1092     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1093     * @throws { BusinessError } 12800003 - input method client error.
1094     * @throws { BusinessError } 12800006 - input method controller error.
1095     * @syscap SystemCapability.MiscServices.InputMethodFramework
1096     * @since 10
1097     */
1098    getBackwardSync(length: number): string;
1099
1100    /**
1101     * Get attribute about editor.
1102     *
1103     * @param { AsyncCallback<EditorAttribute> } callback - the callback of getEditorAttribute.
1104     * @throws { BusinessError } 12800003 - input method client error.
1105     * @syscap SystemCapability.MiscServices.InputMethodFramework
1106     * @since 9
1107     */
1108    getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void;
1109
1110    /**
1111     * Get attribute about editor.
1112     *
1113     * @returns { Promise<EditorAttribute> } the promise returned by the function.
1114     * @throws { BusinessError } 12800003 - input method client error.
1115     * @syscap SystemCapability.MiscServices.InputMethodFramework
1116     * @since 9
1117     */
1118    getEditorAttribute(): Promise<EditorAttribute>;
1119
1120    /**
1121     * Get attribute about editor.
1122     *
1123     * @returns { EditorAttribute } the attribute of editor.
1124     * @throws { BusinessError } 12800003 - input method client error.
1125     * @syscap SystemCapability.MiscServices.InputMethodFramework
1126     * @since 10
1127     */
1128    getEditorAttributeSync(): EditorAttribute;
1129
1130    /**
1131     * Move cursor from input method.
1132     *
1133     * @param { number } direction - Indicates the distance of cursor to be moved. It can't be less than 0.
1134     * @param { AsyncCallback<void> } callback - the callback of moveCursor.
1135     * @throws { BusinessError } 401 - parameter error. Possible causes:
1136     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1137     * @throws { BusinessError } 12800003 - input method client error.
1138     * @syscap SystemCapability.MiscServices.InputMethodFramework
1139     * @since 9
1140     */
1141    moveCursor(direction: number, callback: AsyncCallback<void>): void;
1142
1143    /**
1144     * Move cursor from input method.
1145     *
1146     * @param { number } direction - Indicates the distance of cursor to be moved. It can't be less than 0.
1147     * @returns { Promise<void> } the promise returned by the function.
1148     * @throws { BusinessError } 401 - parameter error. Possible causes:
1149     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1150     * @throws { BusinessError } 12800003 - input method client error.
1151     * @syscap SystemCapability.MiscServices.InputMethodFramework
1152     * @since 9
1153     */
1154    moveCursor(direction: number): Promise<void>;
1155
1156    /**
1157     * Move cursor from input method.
1158     *
1159     * @param { number } direction - Indicates the distance of cursor to be moved. It can't be less than 0.
1160     * @throws { BusinessError } 401 - parameter error. Possible causes:
1161     *    1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1162     * @throws { BusinessError } 12800003 - input method client error.
1163     * @syscap SystemCapability.MiscServices.InputMethodFramework
1164     * @since 10
1165     */
1166    moveCursorSync(direction: number): void;
1167
1168    /**
1169     * Select text in editor by range.
1170     *
1171     * @param { Range } range - indicates the range of selected text in editor.
1172     * @param { AsyncCallback<void> } callback - the callback of selectByRange.
1173     * @throws { BusinessError } 401 - parameter error. Possible causes:
1174     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1175     * @throws { BusinessError } 12800003 - input method client error.
1176     * @syscap SystemCapability.MiscServices.InputMethodFramework
1177     * @since 10
1178     */
1179    selectByRange(range: Range, callback: AsyncCallback<void>): void;
1180
1181    /**
1182     * Select text in editor by range.
1183     *
1184     * @param { Range } range - indicates the range of selected text in editor.
1185     * @returns { Promise<void> } the promise returned by the function.
1186     * @throws { BusinessError } 401 - parameter error. Possible causes:
1187     *    1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1188     * @throws { BusinessError } 12800003 - input method client error.
1189     * @syscap SystemCapability.MiscServices.InputMethodFramework
1190     * @since 10
1191     */
1192    selectByRange(range: Range): Promise<void>;
1193
1194    /**
1195     * Select text in editor by range.
1196     *
1197     * @param { Range } range - indicates the range of selected text in editor.
1198     * @throws { BusinessError } 401 - parameter error. Possible causes:
1199     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1200     * @throws { BusinessError } 12800003 - input method client error.
1201     * @syscap SystemCapability.MiscServices.InputMethodFramework
1202     * @since 10
1203     */
1204    selectByRangeSync(range: Range): void;
1205
1206    /**
1207     * Select text in editor by cursor movement.
1208     *
1209     * @param { Movement } movement - indicates the movement of cursor when selecting.
1210     * @param { AsyncCallback<void> } callback - the callback of selectByMovement.
1211     * @throws { BusinessError } 401 - parameter error. Possible causes:
1212     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1213     * @throws { BusinessError } 12800003 - input method client error.
1214     * @syscap SystemCapability.MiscServices.InputMethodFramework
1215     * @since 10
1216     */
1217    selectByMovement(movement: Movement, callback: AsyncCallback<void>): void;
1218
1219    /**
1220     * Select text in editor by cursor movement.
1221     *
1222     * @param { Movement } movement - indicates the movement of cursor when selecting.
1223     * @returns { Promise<void> } the promise returned by the function.
1224     * @throws { BusinessError } 401 - parameter error. Possible causes:
1225     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1226     * @throws { BusinessError } 12800003 - input method client error.
1227     * @syscap SystemCapability.MiscServices.InputMethodFramework
1228     * @since 10
1229     */
1230    selectByMovement(movement: Movement): Promise<void>;
1231
1232    /**
1233     * Select text in editor by cursor movement.
1234     *
1235     * @param { Movement } movement - indicates the movement of cursor when selecting.
1236     * @throws { BusinessError } 401 - parameter error. Possible causes:
1237     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
1238     * @throws { BusinessError } 12800003 - input method client error.
1239     * @syscap SystemCapability.MiscServices.InputMethodFramework
1240     * @since 10
1241     */
1242    selectByMovementSync(movement: Movement): void;
1243
1244    /**
1245     * Get the index number of text at cursor.
1246     *
1247     * @param { AsyncCallback<number> } callback - the callback of getTextIndexAtCursor, number represents the index
1248     *        number of text at cursor.
1249     * @throws { BusinessError } 12800003 - input method client error.
1250     * @throws { BusinessError } 12800006 - Input method controller error.
1251     * @syscap SystemCapability.MiscServices.InputMethodFramework
1252     * @since 10
1253     */
1254    getTextIndexAtCursor(callback: AsyncCallback<number>): void;
1255
1256    /**
1257     * Get the index number of text at cursor.
1258     *
1259     * @returns { Promise<number> } the promise returned by the function, number represents the index number of text
1260     *          at cursor.
1261     * @throws { BusinessError } 12800003 - input method client error.
1262     * @throws { BusinessError } 12800006 - Input method controller error.
1263     * @syscap SystemCapability.MiscServices.InputMethodFramework
1264     * @since 10
1265     */
1266    getTextIndexAtCursor(): Promise<number>;
1267
1268    /**
1269     * Get the index number of text at cursor.
1270     *
1271     * @returns { number } the index number of text at cursor.
1272     * @throws { BusinessError } 12800003 - input method client error.
1273     * @throws { BusinessError } 12800006 - Input method controller error.
1274     * @syscap SystemCapability.MiscServices.InputMethodFramework
1275     * @since 10
1276     */
1277    getTextIndexAtCursorSync(): number;
1278
1279    /**
1280     * Send extend action code.
1281     *
1282     * @param { ExtendAction } action - action code which will be send.
1283     * @param { AsyncCallback<void> } callback - the callback of sendExtendAction.
1284     * @throws { BusinessError } 401 - parameter error. Possible causes:
1285     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types
1286     * @throws { BusinessError } 12800003 - input method client error.
1287     * @throws { BusinessError } 12800006 - Input method controller error.
1288     * @syscap SystemCapability.MiscServices.InputMethodFramework
1289     * @since 10
1290     */
1291    sendExtendAction(action: ExtendAction, callback: AsyncCallback<void>): void;
1292
1293    /**
1294     * Send extend action code.
1295     *
1296     * @param { ExtendAction } action - action code which will be send.
1297     * @returns { Promise<void> } the promise returned by the function.
1298     * @throws { BusinessError } 401 - parameter error. Possible causes:
1299     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types
1300     * @throws { BusinessError } 12800003 - input method client error.
1301     * @throws { BusinessError } 12800006 - Input method controller error.
1302     * @syscap SystemCapability.MiscServices.InputMethodFramework
1303     * @since 10
1304     */
1305    sendExtendAction(action: ExtendAction): Promise<void>;
1306
1307    /**
1308     * Send private command.This function can only be called by default input method configured by system.
1309     *
1310     * @param { Record<string, CommandDataType> } commandData - command data which will be send.Max size 32KB.
1311     * @returns { Promise<void> } the promise returned by the function.
1312     * @throws { BusinessError } 401 - parameter error. Possible causes:
1313     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1314     * @throws { BusinessError } 12800003 - input method client error.
1315     * @throws { BusinessError } 12800010 - not the preconfigured default input method.
1316     * @syscap SystemCapability.MiscServices.InputMethodFramework
1317     * @since 12
1318     */
1319    sendPrivateCommand(commandData: Record<string, CommandDataType>): Promise<void>;
1320
1321    /**
1322     * Get info of the calling window.
1323     *
1324     * @returns { Promise<WindowInfo> } the promise returned by the function.
1325     * @throws { BusinessError } 12800003 - input method client error.
1326     * @throws { BusinessError } 12800012 - the input method panel does not exist.
1327     * @throws { BusinessError } 12800013 - window manager service error.
1328     * @syscap SystemCapability.MiscServices.InputMethodFramework
1329     * @since 12
1330     */
1331    getCallingWindowInfo(): Promise<WindowInfo>;
1332
1333    /**
1334     * Insert the provided text as preview text.
1335     *
1336     * @param { string } text - the text to be previewed.
1337     * @param { Range } range - the range of the text to be replaced by the preview text.
1338     * @returns { Promise<void> } the promise returned by the function.
1339     * @throws { BusinessError } 401 - parameter error. Possible causes:
1340     *    1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1341     * @throws { BusinessError } 12800003 - input method client error.
1342     * @throws { BusinessError } 12800011 - text preview not supported.
1343     * @syscap SystemCapability.MiscServices.InputMethodFramework
1344     * @since 12
1345     */
1346    setPreviewText(text: string, range: Range): Promise<void>;
1347
1348    /**
1349     * Insert the provided text as preview text.
1350     *
1351     * @param { string } text - the text to be previewed.
1352     * @param { Range } range - the range of the text to be replaced by the preview text.
1353     * @throws { BusinessError } 401 - parameter error. Possible causes:
1354     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1355     * @throws { BusinessError } 12800003 - input method client error.
1356     * @throws { BusinessError } 12800011 - text preview not supported.
1357     * @syscap SystemCapability.MiscServices.InputMethodFramework
1358     * @since 12
1359     */
1360    setPreviewTextSync(text: string, range: Range): void;
1361
1362    /**
1363     * Finish the text preview.
1364     *
1365     * @returns { Promise<void> } the promise returned by the function.
1366     * @throws { BusinessError } 12800003 - input method client error.
1367     * @throws { BusinessError } 12800011 - text preview not supported.
1368     * @syscap SystemCapability.MiscServices.InputMethodFramework
1369     * @since 12
1370     */
1371    finishTextPreview(): Promise<void>;
1372
1373    /**
1374     * Finish the text preview.
1375     *
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    finishTextPreviewSync(): void;
1382
1383    /**
1384     * Send message to edit box.
1385     *
1386     * @param { string } msgId - the identifier of the message. Max size is 256B.
1387     * @param { ?ArrayBuffer } [msgParam] - the param of the custom message. Max size is 128KB.
1388     * @returns { Promise<void> } the promise returned by the function.
1389     * @throws { BusinessError } 401 - parameter error. Possible causes:
1390     *     1. Incorrect parameter types. 2. Incorrect parameter length.
1391     * @throws { BusinessError } 12800003 - input method client error.
1392     * @throws { BusinessError } 12800009 - input method client detached.
1393     * @throws { BusinessError } 12800014 - the input method is in basic mode.
1394     * @throws { BusinessError } 12800015 - the other side does not accept the request.
1395     * @throws { BusinessError } 12800016 - input method client is not editable.
1396     * @syscap SystemCapability.MiscServices.InputMethodFramework
1397     * @since 15
1398     */
1399    sendMessage(msgId: string, msgParam?: ArrayBuffer): Promise<void>;
1400
1401    /**
1402     * Start receiving message from edit box.
1403     *
1404     * @param { ?MessageHandler } [msgHandler] - optional, the handler of the custom message.
1405     * @throws { BusinessError } 401 - parameter error. Possible causes: 1. Incorrect parameter types.
1406     * @syscap SystemCapability.MiscServices.InputMethodFramework
1407     * @since 15
1408     */
1409    recvMessage(msgHandler?: MessageHandler): void;
1410  }
1411
1412  /**
1413   * @interface KeyboardDelegate
1414   * @syscap SystemCapability.MiscServices.InputMethodFramework
1415   * @since 8
1416   */
1417  interface KeyboardDelegate {
1418    /**
1419     * Subscribe key up or down event
1420     *
1421     * @param { 'keyDown' | 'keyUp' } type - indicates the type of subscribe event.
1422     * @param { function } callback - indicates the callback function of on('keyDown'|'keyUp').
1423     * @syscap SystemCapability.MiscServices.InputMethodFramework
1424     * @since 8
1425     */
1426    on(type: 'keyDown' | 'keyUp', callback: (event: KeyEvent) => boolean): void;
1427
1428    /**
1429     * Unsubscribe key up or down event
1430     *
1431     * @param { 'keyDown' | 'keyUp' } type - indicates the type of unsubscribe event.
1432     * @param { function } [callback] - optional, indicates the callback function of off('keyDown'|'keyUp').
1433     * @syscap SystemCapability.MiscServices.InputMethodFramework
1434     * @since 8
1435     */
1436    off(type: 'keyDown' | 'keyUp', callback?: (event: KeyEvent) => boolean): void;
1437
1438    /**
1439     * Subscribe key event.
1440     *
1441     * @param { 'keyEvent' } type - indicates the type of subscribe event.
1442     * @param { function } callback - indicates the callback function of on('keyEvent').
1443     *     If the key is processed by event subscriber, callback should be return true, else return false.
1444     * @syscap SystemCapability.MiscServices.InputMethodFramework
1445     * @since 10
1446     */
1447    on(type: 'keyEvent', callback: (event: InputKeyEvent) => boolean): void;
1448
1449    /**
1450     * Unsubscribe key event.
1451     *
1452     * @param { 'keyEvent' } type - indicates the type of unsubscribe event.
1453     * @param { function } [callback] - optional, indicates the callback function of off('keyEvent').
1454     * @syscap SystemCapability.MiscServices.InputMethodFramework
1455     * @since 10
1456     */
1457    off(type: 'keyEvent', callback?: (event: InputKeyEvent) => boolean): void;
1458
1459    /**
1460     * Subscribe cursor context change
1461     *
1462     * @param { 'cursorContextChange' } type - indicates the type of subscribe event.
1463     * @param { function } callback - indicates the callback function of on('cursorContextChange').
1464     * @syscap SystemCapability.MiscServices.InputMethodFramework
1465     * @since 8
1466     */
1467    on(type: 'cursorContextChange', callback: (x: number, y: number, height: number) => void): void;
1468
1469    /**
1470     * Unsubscribe cursor context change
1471     *
1472     * @param { 'cursorContextChange' } type - indicates the type of unsubscribe event.
1473     * @param { function } [callback] - optional, indicates the callback function of off('cursorContextChange').
1474     * @syscap SystemCapability.MiscServices.InputMethodFramework
1475     * @since 8
1476     */
1477    off(type: 'cursorContextChange', callback?: (x: number, y: number, height: number) => void): void;
1478
1479    /**
1480     * Subscribe selection change
1481     *
1482     * @param { 'selectionChange' } type - indicates the type of subscribe event.
1483     * @param { function } callback - indicates the callback function
1484     * of on('selectionChange').
1485     * @syscap SystemCapability.MiscServices.InputMethodFramework
1486     * @since 8
1487     */
1488    on(
1489      type: 'selectionChange',
1490      callback: (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void
1491    ): void;
1492
1493    /**
1494     * Unsubscribe selection change
1495     *
1496     * @param { 'selectionChange' } type - indicates the type of unsubscribe event.
1497     * @param { function } [callback] - optional,
1498     * indicates the callback function of off('selectionChange').
1499     * @syscap SystemCapability.MiscServices.InputMethodFramework
1500     * @since 8
1501     */
1502    off(
1503      type: 'selectionChange',
1504      callback?: (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void
1505    ): void;
1506
1507    /**
1508     * Subscribe text change
1509     *
1510     * @param { 'textChange' } type - indicates the type of subscribe event.
1511     * @param { function } callback - indicates the callback function of on('textChange').
1512     * @syscap SystemCapability.MiscServices.InputMethodFramework
1513     * @since 8
1514     */
1515    on(type: 'textChange', callback: (text: string) => void): void;
1516
1517    /**
1518     * Unsubscribe text change
1519     *
1520     * @param { 'textChange' } type - indicates the type of unsubscribe event.
1521     * @param { function } [callback] - optional, indicates the callback function of off('textChange').
1522     * @syscap SystemCapability.MiscServices.InputMethodFramework
1523     * @since 8
1524     */
1525    off(type: 'textChange', callback?: (text: string) => void): void;
1526
1527    /**
1528     * Subscribe input text attribute change
1529     *
1530     * @param { 'editorAttributeChanged' } type - indicates the type of subscribe event.
1531     * @param { function } callback - indicates the callback function of on('editorAttributeChanged').
1532     * @syscap SystemCapability.MiscServices.InputMethodFramework
1533     * @since 10
1534     */
1535    on(type: 'editorAttributeChanged', callback: (attr: EditorAttribute) => void): void;
1536
1537    /**
1538     * Unsubscribe input text attribute change
1539     *
1540     * @param { 'editorAttributeChanged' } type - indicates the type of subscribe event.
1541     * @param { function } [callback] - indicates the callback function of off('editorAttributeChanged').
1542     * @syscap SystemCapability.MiscServices.InputMethodFramework
1543     * @since 10
1544     */
1545    off(type: 'editorAttributeChanged', callback?: (attr: EditorAttribute) => void): void;
1546  }
1547
1548  /**
1549   * Defines the immersive mode.
1550   *
1551   * @enum { number }
1552   * @syscap SystemCapability.MiscServices.InputMethodFramework
1553   * @since 15
1554   */
1555  export enum ImmersiveMode {
1556    /**
1557     * Default immersive mode, the panel is not in immersive mode.
1558     *
1559     * @syscap SystemCapability.MiscServices.InputMethodFramework
1560     * @since 15
1561     */
1562    NONE_IMMERSIVE = 0,
1563
1564    /**
1565     * Immersive mode.
1566     *
1567     * @syscap SystemCapability.MiscServices.InputMethodFramework
1568     * @since 15
1569     */
1570    IMMERSIVE,
1571
1572    /**
1573     * Light immersive mode.
1574     *
1575     * @syscap SystemCapability.MiscServices.InputMethodFramework
1576     * @since 15
1577     */
1578    LIGHT_IMMERSIVE,
1579
1580    /**
1581     * Dark immersive mode.
1582     *
1583     * @syscap SystemCapability.MiscServices.InputMethodFramework
1584     * @since 15
1585     */
1586    DARK_IMMERSIVE
1587  }
1588
1589  /**
1590   * A panel is a container used to hold soft keyboard, candidate list, or status bar.
1591   *
1592   * @interface Panel
1593   * @syscap SystemCapability.MiscServices.InputMethodFramework
1594   * @since 10
1595   */
1596  interface Panel {
1597    /**
1598     * Sets ui content.
1599     * <p>When this method is executed successfully, the content of panel will be replaced.</p>
1600     *
1601     * @param { string } path - the path of ui content.
1602     * @param { AsyncCallback<void> } callback - the callback of setUiContent.
1603     * @throws { BusinessError } 401 - parameter error. Possible causes:
1604     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1605     * @syscap SystemCapability.MiscServices.InputMethodFramework
1606     * @since 10
1607     */
1608    setUiContent(path: string, callback: AsyncCallback<void>): void;
1609
1610    /**
1611     * Sets ui content.
1612     * <p>When this method is executed successfully, the content of panel will be replaced.</p>
1613     *
1614     * @param { string } path - the path of ui content.
1615     * @returns { Promise<void> } the promise returned by the function.
1616     * @throws { BusinessError } 401 - parameter error. Possible causes:
1617     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1618     * @syscap SystemCapability.MiscServices.InputMethodFramework
1619     * @since 10
1620     */
1621    setUiContent(path: string): Promise<void>;
1622
1623    /**
1624     * Sets ui content.
1625     * <p>When this method is executed successfully, the content of panel will be replaced.</p>
1626     *
1627     * @param { string } path - the path of ui content.
1628     * @param { LocalStorage } storage - the data object shared within the content instance loaded by the panel.
1629     * @param { AsyncCallback<void> } callback - the callback of setUiContent.
1630     * @throws { BusinessError } 401 - parameter error. Possible causes:
1631     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1632     * @syscap SystemCapability.MiscServices.InputMethodFramework
1633     * @since 10
1634     */
1635    setUiContent(path: string, storage: LocalStorage, callback: AsyncCallback<void>): void;
1636
1637    /**
1638     * Sets ui content.
1639     * <p>When this method is executed successfully, the content of panel will be replaced.</p>
1640     *
1641     * @param { string } path - the path of ui content.
1642     * @param { LocalStorage } storage - the data object shared within the content instance loaded by the panel.
1643     * @returns { Promise<void> } the promise returned by the function.
1644     * @throws { BusinessError } 401 - parameter error. Possible causes:
1645     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1646     * @syscap SystemCapability.MiscServices.InputMethodFramework
1647     * @since 10
1648     */
1649    setUiContent(path: string, storage: LocalStorage): Promise<void>;
1650
1651    /**
1652     * Resizes a panel.
1653     *
1654     * @param { number } width - the new width of the panel.
1655     * @param { number } height - the new height of the panel.
1656     * @param { AsyncCallback<void> } callback - the callback of resize.
1657     * @throws { BusinessError } 401 - parameter error. Possible causes:
1658     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1659     * @syscap SystemCapability.MiscServices.InputMethodFramework
1660     * @since 10
1661     */
1662    resize(width: number, height: number, callback: AsyncCallback<void>): void;
1663
1664    /**
1665     * Resizes a panel.
1666     *
1667     * @param { number } width - the new width of the panel.
1668     * @param { number } height - the new height of the panel.
1669     * @returns { Promise<void> } the promise returned by the function.
1670     * @throws { BusinessError } 401 - parameter error. Possible causes:
1671     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1672     * @syscap SystemCapability.MiscServices.InputMethodFramework
1673     * @since 10
1674     */
1675    resize(width: number, height: number): Promise<void>;
1676
1677    /**
1678     * Moves a panel.
1679     * <p>It's unusable for SOFT_KEYBOARD panel with FLG_FIXED.</p>
1680     *
1681     * @param { number } x - the x-coordinate of the new position.
1682     * @param { number } y - the y-coordinate of the new position.
1683     * @param { AsyncCallback<void> } callback - the callback of moveTo.
1684     * @throws { BusinessError } 401 - parameter error. Possible causes:
1685     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
1686     * @syscap SystemCapability.MiscServices.InputMethodFramework
1687     * @since 10
1688     */
1689    moveTo(x: number, y: number, callback: AsyncCallback<void>): void;
1690
1691    /**
1692     * Moves a panel.
1693     * <p>It's unusable for SOFT_KEYBOARD panel with FLG_FIXED.</p>
1694     *
1695     * @param { number } x - the x-coordinate of the new position.
1696     * @param { number } y - the y-coordinate of the new position.
1697     * @returns { Promise<void> } the promise returned by the function.
1698     * @throws { BusinessError } 401 - parameter error. Possible causes:
1699     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
1700     * @syscap SystemCapability.MiscServices.InputMethodFramework
1701     * @since 10
1702     */
1703    moveTo(x: number, y: number): Promise<void>;
1704
1705    /**
1706     * Starts moving a panel. The panel starts moving when pressed with finger or mouse and stops moving when released.
1707     * <p>It's Only used for STATUS_BAR panel.</p>
1708     *
1709     * @throws { BusinessError } 12800002 - input method engine error.
1710     * @throws { BusinessError } 12800013 - window manager service error.
1711     * @throws { BusinessError } 12800017 - invalid panel type or panel flag.
1712     * @syscap SystemCapability.MiscServices.InputMethodFramework
1713     * @since 15
1714     */
1715    startMoving(): void;
1716
1717    /**
1718     * Get the ID of the display where the input method panel is located.
1719     *
1720     * @returns { Promise<number> } the promise returned by the function.
1721     * @throws { BusinessError } 12800002 - input method engine error.
1722     * @throws { BusinessError } 12800013 - window manager service error.
1723     * @syscap SystemCapability.MiscServices.InputMethodFramework
1724     * @since 15
1725     */
1726    getDisplayId(): Promise<number>;
1727
1728    /**
1729     * Set immersive mode.
1730     *
1731     * @param { ImmersiveMode } mode - Immersive mode.
1732     * @throws { BusinessError } 401 - parameter error. Possible causes:
1733     *     1.Incorrect parameter types; 2.Parameter verification failed.
1734     * @throws { BusinessError } 12800002 - input method engine error.
1735     * @throws { BusinessError } 12800013 - window manager service error.
1736     * @syscap SystemCapability.MiscServices.InputMethodFramework
1737     * @since 15
1738     */
1739    setImmersiveMode(mode: ImmersiveMode): void;
1740
1741    /**
1742     * Get immersive mode.
1743     *
1744     * @returns { ImmersiveMode } Immersive mode.
1745     * @syscap SystemCapability.MiscServices.InputMethodFramework
1746     * @since 15
1747     */
1748    getImmersiveMode(): ImmersiveMode;
1749
1750    /**
1751     * Shows panel.
1752     *
1753     * @param { AsyncCallback<void> } callback - the callback of show.
1754     * @syscap SystemCapability.MiscServices.InputMethodFramework
1755     * @since 10
1756     */
1757    show(callback: AsyncCallback<void>): void;
1758
1759    /**
1760     * Shows panel.
1761     *
1762     * @returns { Promise<void> } the promise returned by the function.
1763     * @syscap SystemCapability.MiscServices.InputMethodFramework
1764     * @since 10
1765     */
1766    show(): Promise<void>;
1767
1768    /**
1769     * Hides panel.
1770     *
1771     * @param { AsyncCallback<void> } callback - the callback of hide.
1772     * @syscap SystemCapability.MiscServices.InputMethodFramework
1773     * @since 10
1774     */
1775    hide(callback: AsyncCallback<void>): void;
1776
1777    /**
1778     * Hides panel.
1779     *
1780     * @returns { Promise<void> } the promise returned by the function.
1781     * @syscap SystemCapability.MiscServices.InputMethodFramework
1782     * @since 10
1783     */
1784    hide(): Promise<void>;
1785
1786    /**
1787     * Registers panel show event.
1788     * <p>The "show" events are triggered when the panel is shown.</p>
1789     *
1790     * @param { 'show' } type - events type.
1791     * @param { function } callback - the callback will be called when events are triggered.
1792     * @syscap SystemCapability.MiscServices.InputMethodFramework
1793     * @since 10
1794     */
1795    on(type: 'show', callback: () => void): void;
1796
1797    /**
1798     * Unregisters panel show event.
1799     *
1800     * @param { 'show' } type - events type.
1801     * @param { function } [callback] - the callback to Unregister.
1802     * @throws { BusinessError } 401 - parameter error. Possible causes:
1803     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1804     * @syscap SystemCapability.MiscServices.InputMethodFramework
1805     * @since 10
1806     */
1807    off(type: 'show', callback?: () => void): void;
1808
1809    /**
1810     * Registers panel hide event.
1811     * <p>The "hide" events are triggered when the panel is hidden.</p>
1812     *
1813     * @param { 'hide' } type - events type.
1814     * @param { function } callback - the callback will be called when events are triggered.
1815     * @syscap SystemCapability.MiscServices.InputMethodFramework
1816     * @since 10
1817     */
1818    on(type: 'hide', callback: () => void): void;
1819
1820    /**
1821     * Unregisters panel hide event.
1822     *
1823     * @param { 'hide' } type - events type.
1824     * @param { function } [callback] - the callback to Unregister.
1825     * @throws { BusinessError } 401 - parameter error. Possible causes:
1826     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1827     * @syscap SystemCapability.MiscServices.InputMethodFramework
1828     * @since 10
1829     */
1830    off(type: 'hide', callback?: () => void): void;
1831
1832    /**
1833     * Changes panel flag.
1834     * <p>Before flag is changed, Developers should hide the panel.After that, developers can change the content, size, point of the panel
1835     *    and show it again at appropriate opportunity.</p>
1836     *
1837     * @param { PanelFlag } flag - the callback of changeFlag.
1838     * @throws { BusinessError } 401 - parameter error. Possible causes:
1839     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1840     * @syscap SystemCapability.MiscServices.InputMethodFramework
1841     * @since 10
1842     */
1843    changeFlag(flag: PanelFlag): void;
1844
1845    /**
1846     * Sets ime panel private mode or not.
1847     *
1848     * @permission ohos.permission.PRIVACY_WINDOW
1849     * @param { boolean } isPrivacyMode - if the value is true, the privacy mode will be set,
1850     * otherwise the non-privacy mode will be set.
1851     * @throws { BusinessError } 201 - permissions check fails.
1852     * @throws { BusinessError } 401 - parameter error. Possible causes:
1853     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types.
1854     * @syscap SystemCapability.MiscServices.InputMethodFramework
1855     * @since 11
1856     */
1857    setPrivacyMode(isPrivacyMode: boolean): void;
1858
1859    /**
1860     * Adjust the rect of soft keyboard panel for landscape and portrait orientations.
1861     * <p>It's only used for SOFT_KEYBOARD panel with FLG_FIXED and FLG_FLOATING.</p>
1862     *
1863     * @param { PanelFlag } flag - panel flag.
1864     * @param { PanelRect } rect - panel rect.
1865     * @throws { BusinessError } 401 - parameter error. Possible causes:
1866     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1867     * @throws { BusinessError } 12800013 - window manager service error.
1868     * @syscap SystemCapability.MiscServices.InputMethodFramework
1869     * @since 12
1870     */
1871    adjustPanelRect(flag: PanelFlag, rect: PanelRect): void;
1872
1873    /**
1874     * Adjust the rect of soft keyboard panel for landscape and portrait orientations.
1875     * <p>It's only used for SOFT_KEYBOARD panel with fixed or floating flag.</p>
1876     *
1877     * @param { PanelFlag } flag - panel flag.
1878     * @param { EnhancedPanelRect } rect - panel rect.
1879     * @throws { BusinessError } 401 - parameter error. Possible causes:
1880     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1881     * @throws { BusinessError } 12800013 - window manager service error.
1882     * @throws { BusinessError } 12800017 - invalid panel type or panel flag.
1883     * @syscap SystemCapability.MiscServices.InputMethodFramework
1884     * @since 15
1885     */
1886    adjustPanelRect(flag: PanelFlag, rect: EnhancedPanelRect): void;
1887
1888    /**
1889     * <p>Update the region in the panel which accepts input events.</p>
1890     * <p>It's only used for SOFT_KEYBOARD panel with fixed flag or floating flag.</p>
1891     *
1892     * @param { Array<window.Rect> } inputRegion - region in the panel which accepts input event. The size of the array must range from 1 to 4.
1893     * @throws { BusinessError } 401 - parameter error. Possible causes:
1894     *     1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed.
1895     * @throws { BusinessError } 12800013 - window manager service error.
1896     * @throws { BusinessError } 12800017 - invalid panel type or panel flag.
1897     * @syscap SystemCapability.MiscServices.InputMethodFramework
1898     * @since 15
1899     */
1900    updateRegion(inputRegion: Array<window.Rect>): void;
1901
1902    /**
1903     * Subscribe 'sizeChange' event.
1904     * <p>It's only used for SOFT_KEYBOARD panel with FLG_FIXED and FLG_FLOATING.</p>
1905     *
1906     * @param { 'sizeChange' } type - the type of subscribe event.
1907     * @param { Callback<window.Size> } callback - the callback of on('sizeChange').
1908     * @syscap SystemCapability.MiscServices.InputMethodFramework
1909     * @since 12
1910     */
1911    /**
1912     * Subscribe 'sizeChange' event.
1913     * <p>It's only used for SOFT_KEYBOARD panel with FLG_FIXED and FLG_FLOATING.</p>
1914     *
1915     * @param { 'sizeChange' } type - the type of subscribe event.
1916     * @param { SizeChangeCallback } callback - the callback of on('sizeChange').
1917     * @syscap SystemCapability.MiscServices.InputMethodFramework
1918     * @since 15
1919     */
1920    on(type: 'sizeChange', callback: SizeChangeCallback): void;
1921
1922    /**
1923     * Unsubscribe 'sizeChange' event.
1924     * <p>It's only used for SOFT_KEYBOARD panel with FLG_FIXED and FLG_FLOATING.</p>
1925     *
1926     * @param { 'sizeChange' } type - the type of unsubscribe event.
1927     * @param { ?Callback<window.Size> } [callback] - optional, the callback of off('sizeChange').
1928     * @syscap SystemCapability.MiscServices.InputMethodFramework
1929     * @since 12
1930     */
1931    /**
1932     * Unsubscribe 'sizeChange' event.
1933     * <p>It's only used for SOFT_KEYBOARD panel with FLG_FIXED and FLG_FLOATING.</p>
1934     *
1935     * @param { 'sizeChange' } type - the type of unsubscribe event.
1936     * @param { ?SizeChangeCallback } [callback] - optional, the callback of off('sizeChange').
1937     * @syscap SystemCapability.MiscServices.InputMethodFramework
1938     * @since 15
1939     */
1940    off(type: 'sizeChange', callback?: SizeChangeCallback): void;
1941
1942    /**
1943     * Subscribe 'sizeUpdate' event.
1944     * <p>It's only used for SOFT_KEYBOARD panel with FLG_FIXED and FLG_FLOATING.</p>
1945     *
1946     * @param { 'sizeUpdate' } type - the type of subscribe event.
1947     * @param { SizeUpdateCallback } callback - the callback of on('sizeUpdate').
1948     * @throws { BusinessError } 202 - not system application.
1949     * @syscap SystemCapability.MiscServices.InputMethodFramework
1950     * @systemapi
1951     * @since 14
1952     */
1953    on(type: 'sizeUpdate', callback: SizeUpdateCallback): void;
1954
1955    /**
1956     * Unsubscribe 'sizeUpdate' event.
1957     * <p>It's only used for SOFT_KEYBOARD panel with FLG_FIXED and FLG_FLOATING.</p>
1958     *
1959     * @param { 'sizeUpdate' } type - the type of unsubscribe event.
1960     * @param { ?SizeUpdateCallback } [callback] - optional, the callback of off('sizeUpdate').
1961     * @syscap SystemCapability.MiscServices.InputMethodFramework
1962     * @systemapi
1963     * @since 14
1964     */
1965    off(type: 'sizeUpdate', callback?: SizeUpdateCallback): void;
1966  }
1967
1968  /**
1969   * @interface EditorAttribute
1970   * @syscap SystemCapability.MiscServices.InputMethodFramework
1971   * @since 8
1972   */
1973  interface EditorAttribute {
1974    /**
1975     * Editor's pattern
1976     *
1977     * @type { number }
1978     * @readonly
1979     * @syscap SystemCapability.MiscServices.InputMethodFramework
1980     * @since 8
1981     */
1982    readonly inputPattern: number;
1983
1984    /**
1985     * Editor's key type
1986     *
1987     * @type { number }
1988     * @readonly
1989     * @syscap SystemCapability.MiscServices.InputMethodFramework
1990     * @since 8
1991     */
1992    readonly enterKeyType: number;
1993
1994    /**
1995     * Indicates whether the editor supports the text preview.
1996     *
1997     * @type { boolean }
1998     * @syscap SystemCapability.MiscServices.InputMethodFramework
1999     * @since 12
2000     */
2001    isTextPreviewSupported: boolean;
2002
2003    /**
2004     * Editor's bundle name.
2005     *
2006     * @type { ?string }
2007     * @readonly
2008     * @syscap SystemCapability.MiscServices.InputMethodFramework
2009     * @since 14
2010     */
2011    readonly bundleName?: string;
2012
2013    /**
2014     * Immersive mode.
2015     *
2016     * @type { ?ImmersiveMode }
2017     * @readonly
2018     * @syscap SystemCapability.MiscServices.InputMethodFramework
2019     * @since 15
2020     */
2021    readonly immersiveMode?: ImmersiveMode;
2022  }
2023
2024  /**
2025   * @interface KeyEvent
2026   * @syscap SystemCapability.MiscServices.InputMethodFramework
2027   * @since 8
2028   */
2029  interface KeyEvent {
2030    /**
2031     * Key code
2032     *
2033     * @type { number }
2034     * @readonly
2035     * @syscap SystemCapability.MiscServices.InputMethodFramework
2036     * @since 8
2037     */
2038    readonly keyCode: number;
2039
2040    /**
2041     * Key action
2042     *
2043     * @type { number }
2044     * @readonly
2045     * @syscap SystemCapability.MiscServices.InputMethodFramework
2046     * @since 8
2047     */
2048    readonly keyAction: number;
2049  }
2050
2051  /**
2052   * Enumerates the flags of panel
2053   *
2054   * @enum { number }
2055   * @syscap SystemCapability.MiscServices.InputMethodFramework
2056   * @since 10
2057   */
2058  export enum PanelFlag {
2059    /**
2060     * Fixed style.
2061     * <p>It's provided for the panel with type of SOFT_KEYBOARD.
2062     * When the flag is set, the soft keyboard is fixed at the bottom of the screen.</p>
2063     *
2064     * @syscap SystemCapability.MiscServices.InputMethodFramework
2065     * @since 10
2066     */
2067    FLG_FIXED = 0,
2068
2069    /**
2070     * Floating style.
2071     * <p>It's provided for the panel with type of SOFT_KEYBOARD.
2072     * When the flag is set, the soft keyboard is floating.</p>
2073     *
2074     * @syscap SystemCapability.MiscServices.InputMethodFramework
2075     * @since 10
2076     */
2077    FLG_FLOATING,
2078
2079    /**
2080     * Candidate style.
2081     * <p>It's provided for the panel with type of SOFT_KEYBOARD.
2082     * When the flag is set, the soft keyboard is a candidate window which will show the possible characters when user types a input code.
2083     * Panel with candidate style will not be automatically shown or hidden by input method service.
2084     * Input method application developers are supposed to control the panel status on their own.</p>
2085     *
2086     * @syscap SystemCapability.MiscServices.InputMethodFramework
2087     * @since 15
2088     */
2089    FLAG_CANDIDATE
2090  }
2091
2092  /**
2093   * <p>Panel types provided for input method applications.</p>
2094   * <p>Input method application developers should select the appropriate panel type according to the user scenario.</p>
2095   *
2096   * @enum { number }
2097   * @syscap SystemCapability.MiscServices.InputMethodFramework
2098   * @since 10
2099   */
2100  export enum PanelType {
2101    /**
2102     * Panel for displaying a virtual software keyboard.
2103     *
2104     * @syscap SystemCapability.MiscServices.InputMethodFramework
2105     * @since 10
2106     */
2107    SOFT_KEYBOARD = 0,
2108
2109    /**
2110     * Panel for displaying status bar.
2111     *
2112     * @syscap SystemCapability.MiscServices.InputMethodFramework
2113     * @since 10
2114     */
2115    STATUS_BAR
2116  }
2117
2118  /**
2119   * Panel information.
2120   *
2121   * @typedef PanelInfo
2122   * @syscap SystemCapability.MiscServices.InputMethodFramework
2123   * @since 10
2124   */
2125  export interface PanelInfo {
2126    /**
2127     * Panel type.
2128     *
2129     * @type { PanelType }
2130     * @syscap SystemCapability.MiscServices.InputMethodFramework
2131     * @since 10
2132     */
2133    type: PanelType;
2134
2135    /**
2136     * <p>Flag of Panel.</p>
2137     * <p>Currently only using for SOFT_KEYBOARD panel.</p>
2138     *
2139     * @type { ?PanelFlag }
2140     * @default FLG_FIXED
2141     * @syscap SystemCapability.MiscServices.InputMethodFramework
2142     * @since 10
2143     */
2144    flag?: PanelFlag;
2145  }
2146
2147  /**
2148   * Enumerates the moving direction of cursor
2149   *
2150   * @enum { number }
2151   * @syscap SystemCapability.MiscServices.InputMethodFramework
2152   * @since 10
2153   */
2154  export enum Direction {
2155    /**
2156     * Cursor moves up
2157     *
2158     * @syscap SystemCapability.MiscServices.InputMethodFramework
2159     * @since 10
2160     */
2161    CURSOR_UP = 1,
2162
2163    /**
2164     * Cursor moves down
2165     *
2166     * @syscap SystemCapability.MiscServices.InputMethodFramework
2167     * @since 10
2168     */
2169    CURSOR_DOWN,
2170
2171    /**
2172     * Cursor moves left
2173     *
2174     * @syscap SystemCapability.MiscServices.InputMethodFramework
2175     * @since 10
2176     */
2177    CURSOR_LEFT,
2178
2179    /**
2180     * Cursor moves right
2181     *
2182     * @syscap SystemCapability.MiscServices.InputMethodFramework
2183     * @since 10
2184     */
2185    CURSOR_RIGHT
2186  }
2187
2188  /**
2189   * Enumerates the security mode.
2190   *
2191   * @enum { number }
2192   * @syscap SystemCapability.MiscServices.InputMethodFramework
2193   * @since 11
2194   */
2195  export enum SecurityMode {
2196    /**
2197     * Basic security mode
2198     *
2199     * @syscap SystemCapability.MiscServices.InputMethodFramework
2200     * @since 11
2201     */
2202    BASIC = 0,
2203    /**
2204     * Full security mode
2205     *
2206     * @syscap SystemCapability.MiscServices.InputMethodFramework
2207     * @since 11
2208     */
2209    FULL
2210  }
2211
2212  /**
2213   * Range of selected text.
2214   *
2215   * @interface Range
2216   * @syscap SystemCapability.MiscServices.InputMethodFramework
2217   * @since 10
2218   */
2219  export interface Range {
2220    /**
2221     * Indicates the index of the first character of the selected text.
2222     *
2223     * @type { number }
2224     * @syscap SystemCapability.MiscServices.InputMethodFramework
2225     * @since 10
2226     */
2227    start: number;
2228
2229    /**
2230     * Indicates the index of the last character of the selected text.
2231     *
2232     * @type { number }
2233     * @syscap SystemCapability.MiscServices.InputMethodFramework
2234     * @since 10
2235     */
2236    end: number;
2237  }
2238
2239  /**
2240   * Movement of cursor.
2241   *
2242   * @interface Movement
2243   * @syscap SystemCapability.MiscServices.InputMethodFramework
2244   * @since 10
2245   */
2246  export interface Movement {
2247    /**
2248     * Indicates the direction of cursor movement
2249     *
2250     * @type { Direction }
2251     * @syscap SystemCapability.MiscServices.InputMethodFramework
2252     * @since 10
2253     */
2254    direction: Direction;
2255  }
2256
2257  /**
2258   * Enumerates the extend action.
2259   *
2260   * @enum { number }
2261   * @syscap SystemCapability.MiscServices.InputMethodFramework
2262   * @since 10
2263   */
2264  export enum ExtendAction {
2265    /**
2266     * Select all text.
2267     *
2268     * @syscap SystemCapability.MiscServices.InputMethodFramework
2269     * @since 10
2270     */
2271    SELECT_ALL = 0,
2272
2273    /**
2274     * Cut selecting text.
2275     *
2276     * @syscap SystemCapability.MiscServices.InputMethodFramework
2277     * @since 10
2278     */
2279    CUT = 3,
2280
2281    /**
2282     * Copy selecting text.
2283     *
2284     * @syscap SystemCapability.MiscServices.InputMethodFramework
2285     * @since 10
2286     */
2287    COPY = 4,
2288
2289    /**
2290     * Paste from paste board.
2291     *
2292     * @syscap SystemCapability.MiscServices.InputMethodFramework
2293     * @since 10
2294     */
2295    PASTE = 5
2296  }
2297
2298  /**
2299   * Window info.
2300   *
2301   * @interface WindowInfo
2302   * @syscap SystemCapability.MiscServices.InputMethodFramework
2303   * @since 12
2304   */
2305  export interface WindowInfo {
2306    /**
2307     * Rectangle.
2308     *
2309     * @type { window.Rect }
2310     * @syscap SystemCapability.MiscServices.InputMethodFramework
2311     * @since 12
2312     */
2313    rect: window.Rect;
2314
2315    /**
2316     * Window status.
2317     *
2318     * @type { window.WindowStatusType }
2319     * @syscap SystemCapability.MiscServices.InputMethodFramework
2320     * @since 12
2321     */
2322    status: window.WindowStatusType;
2323  }
2324
2325  /**
2326   * Panel Rect.
2327   *
2328   * @interface PanelRect
2329   * @syscap SystemCapability.MiscServices.InputMethodFramework
2330   * @since 12
2331   */
2332  export interface PanelRect {
2333    /**
2334     * Panel rect in landscape orientation.
2335     *
2336     * @type { window.Rect }
2337     * @syscap SystemCapability.MiscServices.InputMethodFramework
2338     * @since 12
2339     */
2340    landscapeRect: window.Rect;
2341
2342    /**
2343     * Panel rect in portrait orientation.
2344     *
2345     * @type { window.Rect }
2346     * @syscap SystemCapability.MiscServices.InputMethodFramework
2347     * @since 12
2348     */
2349    portraitRect: window.Rect;
2350  }
2351
2352  /**
2353   * Enhanced panel rect information.
2354   *
2355   * @interface EnhancedPanelRect
2356   * @syscap SystemCapability.MiscServices.InputMethodFramework
2357   * @since 15
2358   */
2359  export interface EnhancedPanelRect {
2360    /**
2361     * <p>Panel rect in landscape orientation.</p>
2362     * <p>It must be filled when fullScreenMode is flase or not specified.</p>
2363     *
2364     * @type { ?window.Rect }
2365     * @syscap SystemCapability.MiscServices.InputMethodFramework
2366     * @since 15
2367     */
2368    landscapeRect?: window.Rect;
2369    /**
2370     * <p>Panel rect in portrait orientation.</P>
2371     * <p>It must be filled when fullScreenMode is flase or not specified.</p>
2372     *
2373     * @type { ?window.Rect }
2374     * @syscap SystemCapability.MiscServices.InputMethodFramework
2375     * @since 15
2376     */
2377    portraitRect?: window.Rect;
2378    /**
2379     * The distance between the top of the panel and the top of the avoidance area in landscape orientation.
2380     * <p>It's only used for SOFT_KEYBOARD panel with fixed flag or floating flag.</p>
2381     *
2382     * @type { ?number }
2383     * @default 0
2384     * @syscap SystemCapability.MiscServices.InputMethodFramework
2385     * @since 15
2386     */
2387    landscapeAvoidY?: number;
2388    /**
2389     * <p>Region in the panel that accepts input events in landsacpe mode.</p>
2390     * <p>It's only used for SOFT_KEYBOARD panel with fixed flag or floating flag. Max array size is 4.</p>
2391     * <p>Defaults to entire panel area if not specifed.</p>
2392     *
2393     * @type { ?Array<window.Rect> }
2394     * @syscap SystemCapability.MiscServices.InputMethodFramework
2395     * @since 15
2396     */
2397    landscapeInputRegion?: Array<window.Rect>;
2398    /**
2399     * The distance between the top of the panel and the top of the avoidance area in portrait orientation.
2400     * <p>It's only used for SOFT_KEYBOARD panel with fixed flag or floating flag.</p>
2401     *
2402     * @type { ?number }
2403     * @default 0
2404     * @syscap SystemCapability.MiscServices.InputMethodFramework
2405     * @since 15
2406     */
2407    portraitAvoidY?: number;
2408    /**
2409     * <p>Region in the panel that accepts input events in portrait mode.</p>
2410     * <p>It's only used for SOFT_KEYBOARD panel with fixed flag or floating flag. Max array size is 4.</p>
2411     * <p>Defaults to entire panel area if not specifed.</p>
2412     *
2413     * @type { ?Array<window.Rect> }
2414     * @syscap SystemCapability.MiscServices.InputMethodFramework
2415     * @since 15
2416     */
2417    portraitInputRegion?: Array<window.Rect>;
2418    /**
2419     * <p>Enter the full screen mode.</p>
2420     * <p>It's only used for SOFT_KEYBOARD panel with fixed flag or floating flag.</p>
2421     *
2422     * @type { ?boolean }
2423     * @default false
2424     * @syscap SystemCapability.MiscServices.InputMethodFramework
2425     * @since 15
2426     */
2427    fullScreenMode?: boolean;
2428  }
2429
2430  /**
2431   * Keyboard area.
2432   *
2433   * @interface KeyboardArea
2434   * @syscap SystemCapability.MiscServices.InputMethodFramework
2435   * @since 15
2436   */
2437  export interface KeyboardArea {
2438    /**
2439     * Top of the keyboard area in the panel.
2440     *
2441     * @type { number }
2442     * @syscap SystemCapability.MiscServices.InputMethodFramework
2443     * @since 15
2444     */
2445    top: number;
2446    /**
2447     * Bottom of the keyboard area in the panel.
2448     *
2449     * @type { number }
2450     * @syscap SystemCapability.MiscServices.InputMethodFramework
2451     * @since 15
2452     */
2453    bottom: number;
2454    /**
2455     * Left of the keyboard area in the panel.
2456     *
2457     * @type { number }
2458     * @syscap SystemCapability.MiscServices.InputMethodFramework
2459     * @since 15
2460     */
2461    left: number;
2462    /**
2463     * Right of the keyboard area in the panel.
2464     *
2465     * @type { number }
2466     * @syscap SystemCapability.MiscServices.InputMethodFramework
2467     * @since 15
2468     */
2469    right: number;
2470  }
2471
2472  /**
2473   * <p>Custom message handler.</p>
2474   * <p>Implement this interface to respond to custem messages.</p>
2475   *
2476   * @interface MessageHandler
2477   * @syscap SystemCapability.MiscServices.InputMethodFramework
2478   * @since 15
2479   */
2480  interface MessageHandler {
2481    /**
2482     * This method is called when a custom message is received.
2483     *
2484     * @param { string } msgId - the identifier of the message.
2485     * @param { ?ArrayBuffer } [msgParam] - the parameter of the custom message.
2486     * @syscap SystemCapability.MiscServices.InputMethodFramework
2487     * @since 15
2488     */
2489    onMessage(msgId: string, msgParam?: ArrayBuffer): void;
2490
2491    /**
2492     * This method is called when a new message handler is set.
2493     *
2494     * @syscap SystemCapability.MiscServices.InputMethodFramework
2495     * @since 15
2496     */
2497    onTerminated(): void;
2498  }
2499}
2500
2501export default inputMethodEngine;
2502