输入法编辑器(IME)程序设计(3)

2024-01-17 15:08

本文主要是介绍输入法编辑器(IME)程序设计(3),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

2004年03月20日 14:37:00

Composition String

The composition string is the current text in the composition window. This is the text that the IME converts to final characters. Each composition string consists of one or more clauses, where a clause is the smallest combination of characters that the IME can convert to a final character. To get and set the composition string, call the ImmGetCompositionString and ImmSetCompositionString functions.

As the user enters text in the composition window, the IME tracks the status of the composition string. This status includes attribute information, clause information, typing information, and cursor position. You can retrieve the composition status by using the ImmGetCompositionString function.

In the attribute information array, all characters of one clause must have the same attribute. The attribute information is an array of 8-bit values that specifies the status of characters in the composition string. There is one value for each byte in the string, including one byte each for the lead and second bytes of any double-byte characters in the string. For each value in the array, bits 0 through 3 can be one combination of the following values.

字母组合字符串(composition string)是指字母组合窗口中的当前文本。这是将被IME转换为最终字符的文本。每个字母组合字符串由一个或多个子串组成(clauses),子串是IME能转换成最终字符的最小字符组合。要获取或设置字母组合字符串,调用ImmGetCompositionString ImmSetCompositionString函数。

当用户在字母组合窗口中输入文本时,IME会跟踪字母组合字符串的状态。这些状态包括属性信息、子串信息、录入信息和子串的位置。你可以通过使用ImmGetCompositionString函数来检索字母组合的状态。

在属性信息数组中,同一个子串中的所有字母都必须具有相同的属性。属性信息是一个由8位值组成的数组,用于确定字母组合字符串中的字符。字符串中的每个字节都对应有一个值,其中,字符串中每个双字节字符的第一和第二字节也都对应的一个值。数组中的每个值,从第0位到第3位可以是下面各值的组合:

Value(值)

Meaning(含意)

ATTR_INPUT

Character being entered by the user. It is yet to be converted by the IME.

用户输入的字符。它将被IME转换。

ATTR_INPUT_ERROR

Character is an error character and cannot be converted by the IME. For example, some consonants cannot be put together.

字符是一个错误的字符,不能被IME所转换。使用某些辅音字母不能放在一起。

ATTR_TARGET_CONVERTED

Character converted by the IME. The user has selected this character and the IME has converted it.

IME所转换了的字符。用户已经选择了这个字符并且IME已经将其转换。

ATTR_CONVERTED

A converted character. The IME has already converted this character.

一个已经转换了的字符。IME已经将其转换。

ATTR_TARGET_NOTCONVERTED

Character being converted. The user has selected this character but the IME has not yet converted it.

正在转换中的字符。用户已经选择了这个字符,但是IME还没有转换它。

ATTR_FIXEDCONVERTED

Characters that will not be converted. The IME will not convert these characters anymore.

不能被转换的字符。IME将不能再对其转换。

All other values are reserved. In Japanese, any unconverted character having the ATTR_INPUT attribute is a Hiragana, Katakana, or alphanumeric character. In Korean, this character is a Hangeul character that is not converted by IME yet. In Traditional and Simplified Chinese, each IME may limit its character in some range.

其它值(大概是指8位中的)将被保留。在日文中,任何拥有ATTR_INPUT属性而不能被转换的字符都是一个平假名、片假名是数字字母。在韩文中,这样的字符是一个韩文字符,它也不能被IME所转换。在传统(也就是繁体)和简体中文中,各个IME(大概是指各个输入法)会以自己的范围内限制它的字符。

The clause information is an array of 32-bit values that specifies the positions of the clauses in the composition string. There is one value for each clause and a final value that specifies the length of the full string. Each value in the array specifies the offset, in bytes, from the beginning of the string to the clause. The first value is always 0 because the first clause always starts at the beginning of the string. For example, if a string has two clauses, the clause information has three values: the first value is 0, the second value is the offset of the second clause, and the third value is the length of the string. For Unicode, the position of a clause is the position counted in Unicode characters, and the length of a string is the size in Unicode characters.

子串信息是一个32位值的数组,用于确定子串在字母组合字符串中的位置。每个子串对应一个值,最后一个值确定整个字母组合字符串的长度。数组中的每个值在字节级别上(以字节为单位)确定了子串由字符串算起的偏移量。第一个值总是0,因为第一个子串总是从字符串的起点开始。例如,如果字符串有两个子串,子串消息(数组)就会有三个值:第一个值是0,第二个值是第二个子串的偏移量,第三个值是字符串的长度。对于Unicode,子串的位置是用Unicode字符计算出的位置,并且字符串的长度也是以Unicode字符计数。

The typing information is a null-terminated character string representing the characters entered at the keyboard.

The cursor position is a value indicating the position of the cursor relative to the characters in the composition string. The value is the offset, in bytes, from the beginning of the string. If this value is 0, the cursor is immediately before the first character in the string. If the value is equal to the length of the string, the cursor is immediately after the last character. If –1, the cursor is not present. For Unicode, both position and length are measured in Unicode characters.

录入信息是一个无终结字符(null-terminated character)字符串,代表由键盘输入的字符。光标位置(cursor position)是一个值,它指出光标相对于字母组合字符串中字符的位置。此值是个以字节计算的偏移量,从字符串的起点算起。如果值与字符串的长度相等,光标恰好处在最后一个字符的后面。如果值为-1,意味着没有光标(光标不显示)。对于Unicode,位置和长度都是以Unicode字符来度量的。

You can set the composition string or elements of the composition status by using the ImmSetCompositionString function. To ensure that the composition window updates its appearance based on these changes, the function allows you to send a notification message to the window. Applications that set a combination of composition status elements typically set the fNotify parameter to FALSE for all but the last call to this function so that only one notification message is generated for the composition window.

Finally, the edit control supports two messages for changing the IME's handling of composition strings. For more information, see EM_GETIMESTATUS and EM_SETIMESTATUS. For more information on the edit control, see Edit Controls.

你可以使用ImmSetCompositionString函数来设置字母组合字符串或者其中元素的属性。为了确保字母组合窗口已经根据这些改变更新了它的外观显示,函数允许你向窗口发送一个通知消息。设定字母组合字符串状态元素组合的应用程序,默认情况下会把所有对此函数调用中的fNotify参数设置为FASLE,除了最后一个调用,所以对字母组合窗口只会生成一个通知消息。

最后,编辑控件还支持两个IME的字母组合字符串处理消息。更多信息,参见EM_GETIMESTATUS EM_SETIMESTATUS。更多有关编辑控件的信息,参见Edit Controls



Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=22044


这篇关于输入法编辑器(IME)程序设计(3)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/616427

相关文章

韦季李输入法_输入法和鼠标的深度融合

在数字化输入的新纪元,传统键盘输入方式正悄然进化。以往,面对实体键盘,我们常需目光游离于屏幕与键盘之间,以确认指尖下的精准位置。而屏幕键盘虽直观可见,却常因占据屏幕空间,迫使我们在操作与视野间做出妥协,频繁调整布局以兼顾输入与界面浏览。 幸而,韦季李输入法的横空出世,彻底颠覆了这一现状。它不仅对输入界面进行了革命性的重构,更巧妙地将鼠标这一传统外设融入其中,开创了一种前所未有的交互体验。 想象

C语言程序设计(数据类型、运算符与表达式)

一、C的数据类型 C语言提供的数据类型: 二、常量和变量 2.1常量和符号常量 在程序运行过程中,其值不能被改变的量称为常量。 常量区分为不同的类型: 程序中用#define(预处理器指令)命令行定义变量将代表常量,用一个标识符代表一个常量,称为符合常量。 2.2变量 变量代表内存中具有特定属性的一个存储单元,用来存放数据,在程序运行期间,这些值是可以 改变的。 变

C语言程序设计(选择结构程序设计)

一、关系运算符和关系表达式 1.1关系运算符及其优先次序 ①<(小于) ②<=(小于或等于) ③>(大于) ④>=(大于或等于 ) ⑤==(等于) ⑥!=(不等于) 说明: 前4个优先级相同,后2个优先级相同,关系运算符的优先级低于算术运算符,关系运算符的优先级高于赋值运算符 1.2关系表达式 用关系运算符将两个表达式(可以是算术表达式或关系表达式,逻辑表达式,赋值表达式,字符

智能工厂程序设计 之1 智能工厂都本俱的方面(Facet,Aspect和Respect)即智能依赖的基底Substrate 之1

Q1、昨天分别给出了三个智能工厂的 “面face”(里面inter-face,外面outer-face和表面surface) 以及每个“面face” 各自使用的“方”(StringProcessor,CaseFilter和ModeAdapter)  。今天我们将继续说说三个智能工厂的“方面” 。在展开之前先看一下三个单词:面向facing,取向oriented,朝向toword。理解这三个词 和

C语言程序设计 笔记代码梳理 重制版

前言 本篇以笔记为主的C语言详解,全篇一共十章内容,会持续更新基础内容,争取做到更详细。多一句没有,少一句不行!  形而上学者谓之道,形而下学者谓之器 形而上学者谓之道,形而下学者谓之器 第1章 C语言的流程 1.C程序经历的六个阶段 编辑(Edit)预处理(Preprocess)编译(Compile)汇编(Assemble)链接(Link)执行(Execute)  2.

ACM东北地区程序设计大赛

不得不说随着参赛级别的提高,题目真的是越来越难啊,不过队长真是给力啊,在我们三个共同努力之下拿下了地区赛三等奖,哈哈我们可是大一唯一一只获奖队,终于在这次比赛打败了田大神。。。大神是失手了,俺和他差距还是挺大的。。。队友陈彤马上要去服兵役了,他说这是我们送给他最好的离别礼物,希望那家伙在部队好好干,以后谁干揍我!!!东北地区赛结束后,今年已经估计没机会参加亚洲区比赛了,赶紧补高数和线数啊!!别挂了

Linux下vi编辑器命令

UNIX下的编辑器有ex,sed和vi等,其中,使用最为广泛的是vi。vi是一个创建、修改文本和数据对象的程序。他和字处理程序和桌面出版程序的区别是他只处理 plain ASCII 文本,没有格式信息。 vi 编辑器有三种处理文本的基本模式: ●一般模式:以vi处理文件时,一进入该文件就是一般模式了。在这个模式中,您可以使用上下左右按键来移动光标,可以使用“删除字符”或“删除整行”来处理文

pdf文件编辑器有哪些?分享适合新手用的5个PDF编辑器(解锁教程)

pdf是一种通用文件格式,也是一种夸操作系统平台的文件格式。 好用的PDF文件编辑器可以让您更改和添加文本、编辑图像、添加图形、签署签名、填写表单数据等。下面整理了关于pdf文件编辑方法介绍,以及一些好用的pdf编辑器,有需要的可以了解下。 一、pdf编辑软件 pdf编辑器1:金舟PDF编辑器——专业的pdf编辑 专业的pdf文件编辑工具,适用于Windows7以上的操作系统。能够完成

解决TMP_InputField 在WebGL(抖音)上不能唤起虚拟键盘,不能使用手机内置输入法的问题

整整花费了一天时间测试和解决。试验了多个方法,花了不少美刀,最终才发现抖音这个官方文档,哭了: https://partner.open-douyin.com/docs/resource/zh-CN/mini-game/develop/guide/game-engine/rd-to-SCgame/open-capacity/capability-adaptation/sc_webgl_keyboa

pta-2024年秋面向对象程序设计实验一-java

文章申明:作者也为初学者,解答仅供参考,不一定是最优解; 一:7-1 sdut-sel-2 汽车超速罚款(选择结构) 答案: import java.util.Scanner;         public class Main { public static void main(String[] arg){         Scanner sc=new Scanner(System