`
luliangok
  • 浏览: 780715 次
文章分类
社区版块
存档分类
最新评论

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

 
阅读更多

原文链接:http://blog.csdn.net/FantasiaX/archive/2004/03/20/22044.aspx

原作者:刘铁猛

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

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能转换成最终字符的最小字符组合。要获取或设置字母组合字符串,调用ImmGetCompositionStringImmSetCompositionString函数。

当用户在字母组合窗口中输入文本时,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
分享到:
评论

相关推荐

    WIN7韩文输入法 KRO_IME x64位

    WIN7韩文输入法 KRO_IME x64位,纯净系统,换电脑 必备良药

    微软日本语输入法2007(IME2007-JPN).rar

    通过windows XP环境验证的输入法程序,下载解压后可通过查看文件属性检查签名是否存在。若签名信息存在则可放心使用,若签名信息与下列不符则建议不要安装,因为签名消失说明文件已经更改。 转载本程序请在醒目位置...

    微软朝鲜语输入法2007(IME2007-KOR)

    通过windows XP环境验证的输入法程序,验证后由网站eiiwa.vicp.net签署数字签名,下载解压后可通过查看文件属性检查签名是否存在。若签名信息存在则可放心使用,若签名信息与下列不符则建议不要安装,因为签名消失...

    输入法设置工具 IME TOOL 2.6.5

    注:在设计 IMETool 时,为了简单起见,在选择“输入法指示器”风格时,相应的切换输入法选项直接套用了“高级文字服务”的“切换输入语言”选项,见图一中④⑤处。 8、问:在使用 IMETool 后,有时输入法的指示条会...

    韩文输入法 IME2007

    IME KOREAN 2007 韩文输入法 GHOST版本的XP要想输入韩文就装这个补丁

    输入法设置工具 IME TOOL

    3、在 IME Tool 中刚添加的输入法不能立即设置属性。 4、如果使用输入法指示器方式时,在系统目录下未发现 internat.exe 和 indicdll.dll 文件,将会自动复制当前目录下的此二文件过去(如果存在)。 命令行参数...

    输入法修复工具ime-show

    输入法修复工具ime-show 任务栏输入法不见了,通过控制面板修改依旧不行,可以考虑用本输入法修复工具修复.

    输入法设置工具 IME TOOL v2.8.2

    输入法设置工具 IME TOOL v2.8.2。

    IME输入法编程指南

    讲述IME框架下开发输入法的基本原理和基本思路,以微软拼音为例,详细描述各种API函数的使用方法和源代码,很有指导意义。

    输入法设置工具 IME TOOL 2.8.3

    3、在 IME Tool 中刚添加的输入法不能立即设置属性。 4、如果使用输入法指示器方式时,在系统目录下未发现 internat.exe 和 indicdll.dll 文件,将会自动复制当前目录下的此二文件过去(如果存在)。 命令行参数...

    QQ拼音输入法皮肤编辑器 v2015.zip

    QQ拼音输入法皮肤编辑器,皮肤文件为qpys格式,是由QQ拼音皮肤编辑器采用加密压缩生成的。为保护作者版权,网友无法直接解压打开该文件获取资源图片。 QQ拼音2.3以后的版本支持皮肤文件的直接安装。用户下载qpys...

    百度输入法皮肤编辑器V2.3.2.49绿色免费版

    百度输入法皮肤编辑器,制作一款百度输入法皮肤主要需要经过以下四个步骤: 一. 设计产出效果图 二. 结合皮肤编辑器素材要求,对效果图进行切分 三. 利用皮肤编辑器使用生成的切分图编辑皮肤 四. 皮肤文件生成及检测 ...

    百度输入法皮肤编辑器 v2015.zip

    百度输入法皮肤编辑器设计产出效果图,结合皮肤编辑器素材要求,对效果图进行切分,利用皮肤编辑器使用生成的切分图编辑皮肤, 皮肤文件生成及检测。 百度输入法皮肤编辑器文件说明 1. 百度输入法皮肤文件为bps...

    wince 中文输入法编辑器

    CE包含了一种简体中文输入法编辑器,如果不想编写自己的输入法编辑器,那么可以直接调用默认的。在讲解中文输入法编辑器之前顺便提一下国际化(Internationalization),中文输入法及输入法编辑器只是国际化组件的一...

    ime-show输入法工具

    ime-show 输入法工具 输入法修复工具

    易语言源码易语言IME输入法源码.rar

    易语言源码易语言IME输入法源码.rar

    实用的 输入法 程序设计

    对于想自己开发一个输入法的朋友,是一个非常好的参考,里面有详细的源程序,附有详细的注解和程序设计思想在里面

    搜狗输入法皮肤编辑器

    搜狗输入法皮肤编辑器 搜狗输入法皮肤编辑 搜狗输入法皮肤编辑器器 好好用的

    ime.rar系统输入法

    输入法、日文输入法,C:\WINDOWS\ime 覆盖就OK了

    手心输入法皮肤编辑器 v2015.zip

    手心输入法皮肤编辑器是官方提供的一款皮肤编辑工具,可以自行设计输入法的字体大小、字型、拼音串颜色、焦点候选词颜色、光标颜色以及状态栏、横排窗口、竖排窗口等元素。如果厌倦了或者对官方提供的皮肤不满意,...

Global site tag (gtag.js) - Google Analytics